import type { ChildProcess } from "node:child_process";
import { TaskOutput } from "./task-output.js";
export interface ExecResult {
    stdout: string;
    stderr: string;
    /** Exit code. 137 = SIGKILL, 143 = SIGTERM, 145 = aborted. */
    code: number;
    /** Whether the process was interrupted (killed or timed out). */
    interrupted: boolean;
    /** Set when backgrounded. */
    backgroundTaskId?: string;
    /** Set when the user explicitly backgrounded. */
    backgroundedByUser?: boolean;
    /** Set when assistant mode auto-backgrounded. */
    assistantAutoBackgrounded?: boolean;
    /** Path to raw output file for large outputs. */
    outputFilePath?: string;
    /** Total output file size in bytes. */
    outputFileSize?: number;
    /** Error message when command failed before spawning. */
    preSpawnError?: string;
}
export interface ShellCommand {
    /** Move the process to background. Returns true if successful. */
    background(taskId: string): boolean;
    /** Promise resolving when the process exits. */
    result: Promise<ExecResult>;
    /** Kill the process immediately. */
    kill(): void;
    /** Current lifecycle status. */
    status: "running" | "backgrounded" | "completed" | "killed";
    /** Clean up stream resources and listeners. */
    cleanup(): void;
    /** Register timeout callback (for auto-backgrounding). */
    onTimeout?: (callback: (backgroundFn: (taskId: string) => boolean) => void) => void;
    /** Output container. */
    taskOutput: TaskOutput;
}
/**
 * Wrap a child process with lifecycle management.
 * Ported from cc's wrapSpawn().
 */
export declare function wrapSpawn(childProcess: ChildProcess, abortSignal: AbortSignal, timeout: number, taskOutput: TaskOutput, shouldAutoBackground?: boolean, maxOutputBytes?: number): ShellCommand;
/**
 * Create a ShellCommand for commands that were aborted before execution.
 */
export declare function createAbortedCommand(backgroundTaskId?: string, opts?: {
    stderr?: string;
    code?: number;
}): ShellCommand;
/**
 * Create a ShellCommand for commands that failed before spawn.
 */
export declare function createFailedCommand(preSpawnError: string): ShellCommand;
