import type { PortableTool } from "../portable-tool.js";
import type { BashTaskHandle } from "../../runtime/infra/background-tasks.js";
import type { CommandClassification } from "./shell/command-classification.js";
import type { SandboxConfig } from "./shell/sandbox/sandbox-types.js";
export declare const EXEC_TOOL_NAME: "exec";
export interface ExecToolParams {
    command: string;
    description?: string;
    workdir?: string;
    timeout?: number;
    /** Explicit background request (cc: run_in_background). */
    background?: boolean;
}
export declare const EXEC_TOOL_SCHEMA: {
    readonly type: "object";
    readonly properties: {
        readonly command: {
            readonly type: "string";
            readonly description: "Shell command to execute in PowerShell." | "Shell command to execute in bash. Use Unix-style commands (ls, cat, mkdir -p, etc.).";
        };
        readonly description: {
            readonly type: "string";
            readonly description: string;
        };
        readonly workdir: {
            readonly type: "string";
            readonly description: "Working directory for the command.";
        };
        readonly timeout: {
            readonly type: "number";
            readonly description: string;
        };
        readonly background: {
            readonly type: "boolean";
            readonly description: string;
        };
    };
    readonly required: readonly ["command"];
};
export interface ExecToolOutput {
    stdout: string;
    stderr: string;
    exitCode: number;
    interrupted: boolean;
    rawOutputPath?: string;
    backgroundTaskId?: string;
    assistantAutoBackgrounded?: boolean;
    returnCodeInterpretation?: string;
    noOutputExpected?: boolean;
    persistedOutputPath?: string;
    persistedOutputSize?: number;
    classification?: CommandClassification;
}
export interface ExecProgress {
    type: "exec_progress";
    output: string;
    fullOutput: string;
    elapsedTimeSeconds: number;
    totalLines: number;
    totalBytes: number;
    taskId?: string;
}
/**
 * Minimal host dependency — ONLY for permission checking.
 * The tool owns everything else (spawn, lifecycle, output).
 *
 * This replaces the old ExecToolDeps which required the host to
 * implement the entire exec() pipeline. Now the tool owns the
 * process directly (cc architecture).
 */
export interface ExecToolHost {
    /**
     * Validate a command before execution.
     * Returns null/undefined if allowed, or an error message if blocked.
     */
    validateCommand?(command: string): Promise<string | null | undefined>;
    /**
     * Resolve the OS-sandbox context for this exec (snapshot of the permission
     * single-source: mode + active workdir + approved dirs + helper availability).
     * Returns undefined to disable the OS sandbox (degrade to prompt-only).
     */
    resolveSandbox?(): SandboxConfig | undefined;
    /**
     * Interpret a non-zero exit code.
     * E.g. 127 → "command not found", 137 → "killed by SIGKILL".
     */
    interpretExitCode?(exitCode: number, stderr: string): string | undefined;
    /**
     * Called during foreground execution with incremental progress.
     * The host can forward these to the UI for real-time output display.
     */
    onProgress?(progress: ExecProgress): void;
    /**
     * Register a backgrounded command in the host's unified task registry
     * (lifecycle tracking + output queries + cancellation).
     * Returns false when the host has no registry — background mode is then refused.
     */
    registerBackgroundTask?(info: {
        command: string;
        cwd: string;
        description?: string;
        pid?: number;
        handle: BashTaskHandle;
    }): boolean;
}
/**
 * Auto-background trigger threshold (assistant mode).
 * cc: ASSISTANT_BLOCKING_BUDGET_MS = 15_000
 */
export declare const ASSISTANT_BLOCKING_BUDGET_MS = 15000;
/**
 * Create the exec tool with direct process ownership (cc architecture).
 *
 * @param host Minimal host interface — only permission checking.
 *             Pass `{}` for unrestricted mode (tests only).
 */
export declare function createExecTool(host?: ExecToolHost): PortableTool<ExecToolParams>;
