feat: race-free on-wake messages and explicit restart CLI

Decouple container restart from config updates — config CLI ops now only
write to the DB; restart is a separate `ncl groups restart` command with
--rebuild and --message flags. Add on_wake column to messages_in so wake
messages are only picked up by a fresh container's first poll, preventing
dying containers from stealing them during the SIGTERM grace window.
killContainer accepts an onExit callback for race-free respawn. Agent-
called restart auto-scopes to the calling session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-05-09 19:02:15 +03:00
parent 08698da0d2
commit be3a8a97c6
12 changed files with 381 additions and 61 deletions

View File

@@ -216,6 +216,11 @@ export function writeSessionMessage(
* path so the target's reply routes back to that exact session.
*/
sourceSessionId?: string | null;
/**
* 1 = only deliver on the container's first poll (fresh start).
* Dying containers (past first poll) skip these rows.
*/
onWake?: 0 | 1;
},
): void {
// Extract base64 attachment data, save to inbox, replace with file paths
@@ -235,6 +240,7 @@ export function writeSessionMessage(
recurrence: message.recurrence ?? null,
trigger: message.trigger ?? 1,
sourceSessionId: message.sourceSessionId ?? null,
onWake: message.onWake ?? 0,
});
} finally {
db.close();