import type { Tool } from '../core/tools/tool-types.js'; export declare function setKillEscalationMsForTests(ms: number): void; type BackgroundStatus = 'running' | 'exited' | 'killed' | 'error'; export interface BackgroundProcSnapshot { id: string; command: string; label?: string; pid?: number; status: BackgroundStatus; exitCode: number | null; signal: NodeJS.Signals | null; startedAt: number; endedAt?: number; errorMessage?: string; droppedBytes?: number; } export interface BackgroundOutputChunk { id: string; stream: 'stdout' | 'stderr'; chunk: string; } export type BackgroundOutputListener = (event: BackgroundOutputChunk) => void; export type BackgroundLifecycleListener = (snapshot: BackgroundProcSnapshot) => void; export declare function clearBackgroundRegistryForTests(): void; export declare function subscribeBackgroundOutput(id: string, listener: BackgroundOutputListener): () => void; export declare function subscribeBackgroundLifecycle(listener: BackgroundLifecycleListener): () => void; export declare function getBackgroundProcessSnapshot(id: string): BackgroundProcSnapshot | null; export declare function listBackgroundProcessSnapshots(): BackgroundProcSnapshot[]; /** * Wait until no background process is still running, or until timeoutMs elapses. * Used by oneshot CLI to flush user-visible completion notices before process exit. * Returns true if idle (or never had running procs), false on timeout. */ export declare function waitForBackgroundProcessesIdle(timeoutMs?: number, pollMs?: number): Promise; export type BackgroundWaitMode = 'wait_any' | 'wait_all'; export interface BackgroundWaitResult { /** Whether the mode condition was satisfied before the timeout. */ completed: boolean; /** Whether the wait was cut short by an abort signal. */ aborted: boolean; /** ids the caller asked for that are not in the registry (reported, not waited). */ missing: string[]; /** Snapshots of the known ids at wait end. */ snapshots: BackgroundProcSnapshot[]; } /** * Wait for a specific subset of background processes to finish — `wait_any` * resolves when the first completes, `wait_all` waits for every one. Mirrors * grok-build's `wait_commands_or_subagents`. Unlike `waitForBackgroundProcessesIdle` * (which waits for ALL processes), this scopes to caller-named ids and supports * `wait_any` + abort. Unknown ids are reported in `missing` (not treated as * pending). Exported for unit testing. */ export declare function waitForBackgroundProcesses(ids: string[], mode?: BackgroundWaitMode, timeoutMs?: number, options?: { pollMs?: number; signal?: AbortSignal; }): Promise; /** Trailing output lines for a background process (model-facing reminders). */ export declare function getBackgroundProcessOutputTail(id: string, lines?: number): string; export declare function stopBackgroundProcess(id: string): boolean; export declare const execBackgroundTool: Tool; export declare const execLogsTool: Tool; export declare const execStopTool: Tool; export declare const execWaitTool: Tool; export declare const backgroundExecTools: Tool[]; export {}; //# sourceMappingURL=background-exec.d.ts.map