/** * Process signal handling, shutdown, and crash/suspend lifecycle extracted from * interactive-mode. * * These register SIGTERM/SIGHUP/uncaughtException/dead-terminal handlers, run the * graceful and emergency shutdown paths (preserving the #4144/#5080 ordering * where signal-triggered shutdown emits extension cleanup before terminal * writes), and implement Ctrl+Z suspend/resume. They operate through a * `SignalLifecycleHost` seam: `isShuttingDown`/`signalCleanupHandlers` are * threaded via get/set, and the cross-cluster calls (shutdown, unregister, * emergency, crash) go through host seams so interactive-mode's thin wrappers — * and the #5080/suspend behaviour tests that stub them — keep working. */ import type { TUI } from "@caupulican/pi-tui"; import type { AgentSessionRuntime } from "../../core/agent-session-runtime.ts"; export interface SignalLifecycleHost { isShuttingDown: boolean; signalCleanupHandlers: Array<() => void>; readonly shutdownRequested: boolean; readonly runtimeHost: Pick; readonly ui: TUI; stop(): void; formatResumeCommand(): string | undefined; showStatus(message: string): void; shutdown(options?: { fromSignal?: boolean; }): Promise; unregisterSignalHandlers(): void; emergencyTerminalExit(): never; uncaughtCrash(error: Error): never; } export declare function shutdown(host: SignalLifecycleHost, options?: { fromSignal?: boolean; }): Promise; export declare function emergencyTerminalExit(host: SignalLifecycleHost): never; /** * Last-resort handler for uncaught exceptions. The TUI puts stdin into raw * mode and hides the cursor; without this handler, an uncaught throw from * anywhere (e.g. an extension's async `ChildProcess.on("exit")` callback) * tears down the process while leaving the terminal in raw mode with no * cursor, requiring `stty sane && reset` to recover. * * Unlike emergencyTerminalExit, the terminal is still alive here, so we * call ui.stop() to restore cooked mode, the cursor, and disable bracketed * paste / Kitty / modifyOtherKeys sequences. */ export declare function uncaughtCrash(host: SignalLifecycleHost, error: Error): never; /** * Check if shutdown was requested and perform shutdown if so. */ export declare function checkShutdownRequested(host: SignalLifecycleHost): Promise; export declare function registerSignalHandlers(host: SignalLifecycleHost): void; export declare function unregisterSignalHandlers(host: SignalLifecycleHost): void; export declare function handleCtrlZ(host: Pick): void; //# sourceMappingURL=signal-lifecycle.d.ts.map