import { type JsonSchema7Type } from 'zod-to-json-schema'; import type { AgentExecutionCounter, BuiltTelemetry, BuiltTool, PendingToolCall } from '../../types'; import type { AgentPersistenceOptions, ToolResultEntry } from '../../types/sdk/agent'; import type { AgentMessage } from '../../types/sdk/message'; import type { JSONValue } from '../../types/utils/json'; import type { WorkspaceFilesystem } from '../../workspace/types'; import type { AgentMessageList } from '../model/message-list'; import type { TokenCounter } from '../model/model-token-counter'; import type { AgentEventBus } from '../state/event-bus'; import type { RuntimeTelemetry } from '../telemetry/runtime-telemetry'; export interface PendingResume { pendingToolCalls: Record; resumeToolCallId: string; resumeData: unknown; } export interface ToolCallSuccess { toolCallId: string; toolName: string; input: JSONValue; toolEntry: ToolResultEntry; modelOutput: unknown; customMessage?: AgentMessage; } export interface ToolCallSuspension { toolCallId: string; toolName: string; input: JSONValue; payload: unknown; resumeSchema: JsonSchema7Type; } export interface ToolCallError { toolCallId: string; toolName: string; input: JSONValue; error: unknown; } export interface ToolCallBatchResult { results: ToolCallSuccess[]; suspensions: ToolCallSuspension[]; errors: ToolCallError[]; pending: Record; } export interface ToolBatchContext { toolMap: Map; list: AgentMessageList; runId: string; persistence?: AgentPersistenceOptions; telemetry?: BuiltTelemetry; executionCounter?: AgentExecutionCounter; abortSignal: AbortSignal; isAborted: () => boolean; } export interface ToolCallExecutorDeps { telemetry: RuntimeTelemetry; eventBus: AgentEventBus; concurrency: number; onCancelled: () => void; tokenCounter: TokenCounter; workspaceFilesystem?: WorkspaceFilesystem; } export declare class ToolCallExecutor { private readonly deps; constructor(deps: ToolCallExecutorDeps); private get telemetry(); private get eventBus(); private get concurrency(); private isDelegateSubAgentCall; private getToolCallBatchSize; private takeNextToolCallBatch; iterateToolCallsConcurrent(ctx: ToolBatchContext & { toolCalls: Array<{ toolCallId: string; toolName: string; input: unknown; providerExecuted?: boolean; }>; }): Promise; iteratePendingToolCallsConcurrent(ctx: ToolBatchContext & { pendingResume: PendingResume; }): Promise; private processToolCall; private runCancellationCleanup; cleanupPendingToolCalls(pending: Record, ctx: ToolBatchContext, message?: string): Promise; private finalizeBatch; private pendingToolCallParams; private retainPendingToolCall; private toolError; private findSettledToolCall; private completeSettledToolCall; private buildCancelledOutcome; private validateToolInput; private runToolHandler; private buildSuspendedOutcome; private buildSuccessOutcome; private getResultStorage; }