Files
EJClaw/src/restart-context-cli.ts
Eyejoker b647502a10 feat: add seq cursor, work_items, provider fallback, and delivery reliability
Major reliability improvements to the message processing pipeline:

- Add messages.seq monotonic cursor replacing timestamp-based cursors,
  preventing message loss from timestamp collisions with LIMIT queries
- Add work_items table separating agent production from delivery,
  enabling delivery retry without re-running the agent
- Propagate Discord send failures instead of silently swallowing them
- Add Claude 429 → Kimi K2.5 automatic provider fallback with cooldown
- Fix follow-up turn state reset in live index.ts path (not just
  message-runtime.ts) to prevent final output from being lost
- Add restart context tracking for graceful restart announcements
- Lazy migration from timestamp cursors to seq cursors for existing data

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 00:11:32 +09:00

71 lines
1.3 KiB
TypeScript

import { SERVICE_ID } from './config.js';
import { writeRestartContext } from './restart-context.js';
function printUsageAndExit(): never {
console.error(
[
'Usage:',
' tsx src/restart-context-cli.ts write --chat-jid <jid> --summary <text> [--verify <text> ...] [--service-id <id> ...]',
].join('\n'),
);
process.exit(1);
}
const [, , command, ...args] = process.argv;
if (command !== 'write') {
printUsageAndExit();
}
let chatJid = '';
let summary = '';
const verify: string[] = [];
const serviceIds: string[] = [];
for (let i = 0; i < args.length; i += 1) {
const arg = args[i];
const value = args[i + 1];
if (!value) {
printUsageAndExit();
}
if (arg === '--chat-jid' || arg === '--jid') {
chatJid = value;
i += 1;
continue;
}
if (arg === '--summary') {
summary = value;
i += 1;
continue;
}
if (arg === '--verify') {
verify.push(value);
i += 1;
continue;
}
if (arg === '--service-id') {
serviceIds.push(value);
i += 1;
continue;
}
printUsageAndExit();
}
if (!chatJid || !summary) {
printUsageAndExit();
}
const written = writeRestartContext(
{
chatJid,
summary,
verify,
},
serviceIds.length > 0 ? serviceIds : [SERVICE_ID],
);
for (const filePath of written) {
console.log(filePath);
}