import type { spawnSync } from "node:child_process";
import type { AgentNotificationQueue } from "./agent-notifications.js";
export interface BackgroundProcess {
    id: string;
    pid: number;
    command: string;
    logFile: string;
    startedAt: number;
    exitCode: number | null;
    lastReadOffset: number;
}
export interface StartResult {
    id: string;
    pid: number;
    logFile: string;
}
export interface ReadOutputResult {
    id: string;
    isRunning: boolean;
    exitCode: number | null;
    output: string;
}
export interface ProcessManagerOps {
    platform?: NodeJS.Platform;
    kill?: typeof process.kill;
    killProcessTree?: (pid: number) => void;
    spawnSync?: typeof spawnSync;
    /**
     * Push queue for background-process progress checkpoints. When set, a long
     * build reports progress and its exit code into the agent's next turn
     * instead of waiting to be polled with `task_output`.
     */
    notifications?: AgentNotificationQueue;
}
export declare class ProcessManager {
    private readonly ops;
    private processes;
    private children;
    /** Per-process progress timers. Cleared on exit, stop and shutdown. */
    private watchers;
    /** Log size at the last emitted checkpoint, so a quiet process stays quiet. */
    private watchedSizes;
    constructor(ops?: ProcessManagerOps);
    start(command: string, cwd: string): Promise<StartResult>;
    /**
     * Arm a debounced progress watcher for one background process. Emits at most
     * one latest-only checkpoint per interval, and only when the log actually
     * grew — so a 60s build reports itself without the agent ever calling
     * `task_output`, while an idle process stays silent.
     *
     * No-op when no notification queue is wired, so hosts that never drain
     * notifications pay nothing.
     */
    private armWatcher;
    private emitProgress;
    private notifyExit;
    /** Read the trailing bytes of a log without loading the whole file. */
    private readTail;
    /** Stop and forget a process's watcher. A finished process keeps no timer. */
    private disposeWatcher;
    /** Live watcher ids. Exposed for leak assertions in tests. */
    activeWatchers(): string[];
    readOutput(id: string, fromStart?: boolean): Promise<ReadOutputResult>;
    /**
     * Write input to a running background process's stdin, enabling interactive
     * control (answer prompts, drive a REPL, feed a scaffolder). By default a
     * newline is appended (as if the user pressed Enter). Set `eof` to close
     * stdin afterwards, signalling end-of-input (Ctrl-D) to the program.
     */
    sendInput(id: string, input: string, opts?: {
        enter?: boolean;
        eof?: boolean;
    }): Promise<string>;
    stop(id: string): Promise<string>;
    list(): BackgroundProcess[];
    shutdownAll(): void;
}
//# sourceMappingURL=process-manager.d.ts.map