/** * Parent liveness monitor (child-side). * Spec: §5.2 — Layer 2: Child Self-Rescue * * RPC/tmux children poll their parent's PID via the parent's * `orca:session-self` entry. After detecting parent death AND surviving * `orphanGracePeriodSeconds` AND `ctx.isIdle()` returning true, the child * writes orphaned status and shuts down. * * SDK children skip the entire monitor (round-2 W14): if the parent's event * loop is wedged enough to be considered "dead", the child's monitor timer * also can't fire — there's no observable scenario where the check helps. */ export interface ParentMonitorParams { /** Absolute path to the parent's session JSONL */ parentAbsoluteSessionPath: string; /** How often to poll (ms) — typically config.polling.idleIntervalSeconds * 1000 */ pollIntervalMs: number; /** Grace period before declaring orphaned (ms) — typically orphanGracePeriodSeconds * 1000 */ gracePeriodMs: number; /** Cap on the grace-period clock; ms since epoch when the grace window expires */ /** * Probe whether the current agent is idle (no in-flight LLM turn). * Defaults to always-idle for tests; production wires this to `ctx.isIdle()`. */ isIdle: () => boolean; /** * Resolve the parent's PID by reading the latest orca:session-self entry * from the parent's session file. Return null when the file is missing or * has no such entry (treat as unknown — don't declare dead). * * In tests this is mocked; in production it opens a SessionManager against * parentAbsoluteSessionPath and walks getEntries() for the entry. */ resolveParentPid: () => Promise; /** * Action to take when the child should orphan-shutdown. Implementer wires * this to write status + stop heartbeat + deliver completion + ctx.shutdown(). */ onOrphaned: (parentPid: number) => Promise; /** * Optional liveness probe override (for testing). * Defaults to `isPidAlive` from @pi-orca/core. */ isAliveOverride?: (pid: number) => boolean; } /** * Start the parent-liveness monitor. Self-rescheduling setTimeout pattern * with an inProgress guard (round-2 W2). * * @param params - Monitor parameters */ export declare function startParentMonitor(params: ParentMonitorParams): void; /** * Stop the parent-liveness monitor. */ export declare function stopParentMonitor(): void; /** * For tests: snapshot of internal state. */ export declare function _internalState(): { parentDeadSince: number | undefined; monitorActive: boolean; }; /** * For tests: reset all module-scoped state. */ export declare function resetParentMonitor(): void; //# sourceMappingURL=parent-monitor.d.ts.map