Skip to content

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

1.2 KB
Raw Blame
import { acknowledgeClaudeMemMessage } from '../shared/claude-mem-messages.js';

const usage = 'Usage: claude-mem messages acknowledge <message-id>';
const failureMessages = {
  unknown: 'Unknown Claude-Mem message.',
  'not-dispatched': 'This Claude-Mem message has not been dispatched on this installation.',
  unavailable: 'Could not record the acknowledgment on this installation.',
} satisfies Record<Exclude<ReturnType<typeof acknowledgeClaudeMemMessage>, 'acknowledged' | 'already-acknowledged'>, string>;

/** Only an issued first-party message can be acknowledged. This command is local. */
export function runMessagesCommand(args: string[]): number {
  const [action, id] = args;
  if (args.length === 1 && (action === '--help' || action === '-h')) {
    process.stdout.write(usage + '\n');
    return 0;
  }
  if (action !== 'acknowledge' || !id || args.length !== 2) {
    process.stderr.write(usage + '\n');
    return 1;
  }

  const status = acknowledgeClaudeMemMessage(id);
  if (status === 'acknowledged' || status === 'already-acknowledged') {
    process.stdout.write(`Acknowledged Claude-Mem message ${id}.\n`);
    return 0;
  }
  process.stderr.write(failureMessages[status] + '\n');
  return 1;
}