/**
 * Streaming Tool Executor — CC StreamingToolExecutor parity.
 *
 * Executes tools as they stream in with concurrency control:
 *   - Concurrent-safe tools execute in parallel with other concurrent-safe tools
 *   - Non-concurrent tools execute alone (exclusive access)
 *   - Results are buffered and emitted in the order tools were received
 *   - Bash errors cascade to abort sibling tools
 *   - Progress messages are yielded immediately
 *
 * Reference: claude-code src/services/tools/StreamingToolExecutor.ts
 */
import type { ToolInvoker, AgentLogger, HookRegistry } from "../ports/agent-execution-contracts.js";
import { type OpenAiToolCall } from "../ports/tool-call-contracts.js";
export type ToolStatus = "queued" | "executing" | "completed" | "yielded";
export interface ToolExecutionResult {
    callId: string;
    toolName: string;
    ok: boolean;
    error?: string;
    blocked?: boolean;
    blockReason?: string;
    durationMs?: number;
    details?: Record<string, unknown>;
    message: unknown;
}
export interface StreamingToolExecutorConfig {
    toolInvoker: ToolInvoker;
    hooks?: HookRegistry;
    sessionId: string;
    turnId: string;
    log: AgentLogger;
    signal?: AbortSignal;
    /** Tool names that are considered concurrency-safe */
    concurrencySafeTools?: Set<string>;
    /** Hard ceiling on simultaneous tool executions (0 = unlimited). CC parity. */
    maxConcurrentTools?: number;
    /** Per foreground tool deadline. 0 or undefined means no executor deadline. */
    maxExecutionMs?: number;
}
/**
 * Executes tools with concurrency control and streaming progress.
 *
 * Usage:
 *   1. Call addTool() for each tool call as they arrive from the LLM stream
 *   2. Call getCompletedResults() to drain completed results (non-blocking)
 *   3. Call getRemainingResults() to wait for all remaining tools
 */
export declare class StreamingToolExecutor {
    private tools;
    private hasErrored;
    private erroredToolDescription;
    private discarded;
    private siblingAbortController;
    private progressResolve?;
    private readonly config;
    private readonly concurrencySafe;
    constructor(config: StreamingToolExecutorConfig);
    /**
     * Discard all pending and in-progress tools.
     * Queued tools won't start, and in-progress tools receive synthetic errors.
     */
    discard(): void;
    /**
     * Add a tool to the execution queue. Starts executing immediately if conditions allow.
     */
    addTool(toolCall: OpenAiToolCall): void;
    /**
     * Check if a tool can execute based on current concurrency state.
     */
    private canExecuteTool;
    /**
     * Process the queue, starting tools when concurrency conditions allow.
     */
    private processQueue;
    /**
     * Get abort reason for a tool.
     */
    private getAbortReason;
    /**
     * Get a human-readable description of a tool for error messages.
     */
    private getToolDescription;
    /**
     * Create a synthetic error result for an aborted tool.
     */
    private createSyntheticError;
    /**
     * Execute a single tool.
     */
    private executeTool;
    /**
     * Get completed results that haven't been yielded yet (non-blocking).
     * Maintains order where necessary.
     */
    getCompletedResults(): Generator<ToolExecutionResult>;
    /**
     * Wait for remaining tools and yield results as they complete.
     */
    getRemainingResults(): AsyncGenerator<ToolExecutionResult>;
    private hasCompletedResults;
    private hasExecutingTools;
    private hasUnfinishedTools;
    private invokeToolWithDeadline;
}
