/** * Child-boot watchdog (RPC/tmux only). * Spec: §4.1.1 step 11 — VERIFY CHILD BOOT * * After the parent writes the initial status YAML (step 8) for an RPC or tmux * agent, the child must boot, load the agents extension, and write its first * heartbeat (which advances the file's mtime and — for RPC — populates `pid`). * If that never happens within `parentLiveness.spawnBootDeadlineSeconds`, the * watchdog: * 1) writes terminal `failed` status with an actionable diagnostic (W9), and * 2) hard-kills the child via the per-mode stop path (`stopRpcAgent` / * `stopTmuxAgent`). * * SDK agents skip this — their parent's event subscription proves boot. * * Design notes: * - Non-blocking: the caller spawns the watchdog and returns. We never * `await` the `done` Promise from `spawnAgent`. * - Self-rescheduling `setTimeout` so vitest fake timers can advance it. * - Idempotent: success and timeout paths both flip `cancelled` to true, * guaranteeing the terminal-write/onTimeout runs at most once. * - Cancel hook is returned so other boot signals (e.g. RPC's first * heartbeat that calls `setRpcAgentPid`) can short-circuit the watchdog. */ export interface VerifyChildBootDiagnostics { /** Captured pi binary invocation (node + pi paths). */ piInvocation: string[]; /** Inherited --extension/-e/--no-extensions/-ne flags from parent argv. */ inheritedCliFlags: string[]; /** Template's `extensions: [...]` field, if any. */ templateExtensions: string[]; /** Child cwd. */ cwd: string; } export interface VerifyChildBootParams { /** Agent ID to watch. */ agentId: string; /** Parent session path (used to resolve `agents/.yaml`). */ parentSessionPath: string; /** mtime (ms since epoch) of the initial status file the parent just wrote. */ initialMtimeMs: number; /** Deadline in ms (typically `spawnBootDeadlineSeconds * 1000`). */ deadlineMs: number; /** Poll interval in ms; default 500. */ pollIntervalMs?: number; /** Diagnostic context captured at spawn for the timeout dump. */ diagnostics: VerifyChildBootDiagnostics; /** * Per-mode hard-kill dispatcher. Implementer wires this to * `stopRpcAgent(agentId)` for `process` isolation or * `stopTmuxAgent(agentId)` for `tmux` isolation. */ onTimeout: (agentId: string) => Promise; /** Optional user-visible warning hook. */ notify?: (msg: string, type?: "info" | "warning" | "error") => void; /** Test override for the mtime probe. */ statMtimeProbe?: (path: string) => Promise; } export interface ChildBootWatchdog { /** Cancel the watchdog (call when boot is verified by another signal). */ cancel: () => void; /** Resolves after the watchdog terminates (success, timeout, or cancel). */ done: Promise; } /** * Start a non-blocking child-boot watchdog. * Spec: §4.1.1 step 11. * * @param params - Watchdog parameters * @returns Handle with `cancel()` and a `done` Promise */ export declare function verifyChildBoot(params: VerifyChildBootParams): ChildBootWatchdog; //# sourceMappingURL=verify-child-boot.d.ts.map