import type { ChildProcess, ExecFileException, ExecFileOptions, SpawnOptions } from "node:child_process";
export type ProcessContext = {
    runId?: string | null;
    source?: string | null;
};
type ExecFileCallback = (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void;
export type ProcessRegistration = {
    command: string;
    args: string[];
    label?: string | null;
    kind?: string | null;
    cwd?: string | null;
    env?: Record<string, string | undefined> | null;
    runId?: string | null;
    source?: string | null;
};
export type ProcessHandle = {
    id: string;
    setPid: (pid: number | null) => void;
    appendOutput: (stream: "stdout" | "stderr", line: string) => void;
    setProgress: (progress: number | null, detail?: string | null) => void;
    setStatus: (text: string | null) => void;
    finish: (result: {
        exitCode: number | null;
        signal: string | null;
        error?: string | null;
    }) => void;
};
export type ProcessObserver = {
    register: (info: ProcessRegistration) => ProcessHandle;
};
export type SpawnTrackedOptions = SpawnOptions & {
    label?: string | null;
    kind?: string | null;
    runId?: string | null;
    source?: string | null;
    captureOutput?: boolean;
};
export declare function setProcessObserver(next: ProcessObserver | null): void;
export declare function getProcessContext(): ProcessContext;
export declare function runWithProcessContext<T>(ctx: ProcessContext, fn: () => T): T;
export declare function terminateTrackedProcesses(signal: NodeJS.Signals): void;
export declare function trackChildProcess(proc: ChildProcess, info: ProcessRegistration, options?: {
    captureOutput?: boolean;
    processGroup?: boolean;
}): ProcessHandle | null;
export declare function spawnTracked(command: string, args: string[], options?: SpawnTrackedOptions): {
    proc: ChildProcess;
    handle: ProcessHandle | null;
};
export declare function execFileTracked(file: string, args?: readonly string[] | ExecFileOptions | ExecFileCallback, options?: ExecFileOptions | ExecFileCallback, callback?: ExecFileCallback): ChildProcess;
export {};
