import type { EventEmitter } from 'node:events'; import { type Tool } from 'ai'; export type ManagedChild = { stdout: Pick | null; stderr: Pick | null; pid?: number | undefined; on: EventEmitter['on']; kill(signal?: NodeJS.Signals | number): boolean; }; export type SpawnFn = (command: string, args: readonly string[], options: { cwd: string; env: NodeJS.ProcessEnv; detached: boolean; }) => ManagedChild; export type BackgroundProcessInit = { cwd: string; maxBufferBytes?: number; killGraceMs?: number; onExit?: (id: string, status: ProcessStatus) => void; spawn?: SpawnFn; }; export type ProcessStatus = { id: string; command: string; running: boolean; exitCode: number | null; pid: number | null; }; export type ProcessOutput = { id: string; stdout: string; stderr: string; running: boolean; exitCode: number | null; truncated: boolean; }; export declare class ProcessManager { private readonly cwd; private readonly cap; private readonly killGraceMs; private readonly onExit; private readonly spawn; private readonly procs; private counter; constructor(init: BackgroundProcessInit); start(command: string): ProcessStatus; output(id: string, filter?: string): ProcessOutput | null; private filterStream; kill(id: string, signal?: NodeJS.Signals): boolean; killAll(signal?: NodeJS.Signals): void; list(): ProcessStatus[]; private signalGroup; private scheduleEscalation; private finalize; private statusOf; } export type BackgroundBashInput = { command: string; }; export type BackgroundBashOutput = ProcessStatus; export type BashOutputInput = { id: string; filter?: string | undefined; }; export type KillBashInput = { id: string; }; export type KillBashOutput = { id: string; killed: boolean; }; export type ListBackgroundOutput = { processes: ProcessStatus[]; }; export type BackgroundProcessTools = { manager: ProcessManager; backgroundBash: Tool; bashOutput: Tool; killBash: Tool; listBackground: Tool, ListBackgroundOutput>; }; export declare function backgroundProcessTools(init: BackgroundProcessInit): BackgroundProcessTools;