/** * Liveness protocol — Layer 1: Shutdown Guard + stopAllAgents dispatcher. * Spec: §5.1, §6.1.1 stop */ import type { AgentStatusFile } from "@pi-orca/core"; /** * Stop ALL agents across all isolation modes. * Spec: §5.1.1 stopAllAgents dispatcher * * For non-SDK children: fire-and-forget `agent-control: graceful-stop` ping, * then wait up to `gracefulStopWaitSeconds` for voluntary termination. * After the window, fall through to per-mode hard kill. * * @param params - Parameters * @returns Counts of agents stopped per mode */ export declare function stopAllAgents(params: { parentSessionPath: string; gracefulStopWaitSeconds: number; notifyChild?: (sockPath: string, agentId: string) => Promise; }): Promise<{ sdk: number; rpc: number; tmux: number; }>; export type ShutdownChoice = "Wait" | "Stop agents first" | "Orphan and quit"; export declare const SHUTDOWN_CHOICES: ShutdownChoice[]; export type ShutdownReason = "quit" | "reload" | "new" | "resume" | "fork"; /** * Filter agent statuses to those that are non-terminal (running/orphaned with * live PIDs). Used by the shutdown guard prompt. * * @param statuses - All agent statuses for the parent * @returns Non-terminal statuses */ export declare function filterNonTerminal(statuses: Array<[string, AgentStatusFile]>): Array<[string, AgentStatusFile]>; /** * Format the prompt message for the shutdown-guard ctx.ui.select. * * @param remaining - Non-terminal agents * @returns Human-readable prompt body */ export declare function formatRemainingPrompt(remaining: Array<[string, AgentStatusFile]>): string; export interface ShutdownGuardParams { reason: ShutdownReason; hasUI: boolean; /** Config flag — when false, the entire guard is skipped */ shutdownGuardEnabled: boolean; parentSessionPath: string; gracefulStopWaitSeconds: number; shutdownWaitMaxSeconds: number; /** * Interactive selector. Required when `hasUI: true`. Returns the user's choice. */ uiSelect?: (message: string, choices: string[]) => Promise; /** * Optional reset hook — clears module-scoped state for the agents extension * (parent-writable session manager, drainFlag, injectedCompletions, etc.). */ resetModuleState?: () => void; /** * Notify hook for child push-pings (agent-control: graceful-stop). */ notifyChild?: (sockPath: string, agentId: string) => Promise; } /** * Shutdown guard logic. Called from the `session_shutdown` handler. * Spec: §5.1.1 * * @param params - Shutdown parameters */ export declare function runShutdownGuard(params: ShutdownGuardParams): Promise; /** * For tests: reset the module-scoped wait-start. */ export declare function resetLivenessState(): void; //# sourceMappingURL=liveness.d.ts.map