import type { Readable } from "node:stream"; export interface WatchdogOptions { eofGraceMs: number; idleMs: number; timeoutMs: number; killGraceMs: number; } export interface WatchdogHooks { /** True once the run is finalized; watchdogs stop firing. */ isSettled(): boolean; /** The child is about to be killed (SIGTERM). reason explains why. */ onKill(reason: string): void; /** stdout EOF passed without the process exiting; force-finalize now. */ onEofGrace(): void; } export interface WatchdogHandle { /** Re-arm the idle timer (call on every stdout data). */ poke(): void; /** Stop all timers (call on finalize). */ dispose(): void; } /** * Guarantees a hung child process gets killed. A stuck child holds its stdout * fd open, so stdout EOF never fires — hence the idle timer (no output for * idleMs) is the main defense; the hard time limit and the EOF grace period * cover the rest. Kill is SIGTERM, escalated to SIGKILL after killGraceMs. */ export declare function attachWatchdogs(child: { kill(signal: NodeJS.Signals): boolean; stdout: Readable | null; }, hooks: WatchdogHooks, opts: WatchdogOptions): WatchdogHandle;