import type { CoreClientEvent, CoreServerEvent, FunctionCallArgumentsDoneEvent } from "./types"; /** * Represents a tool-call stream tracked by the accumulator. */ export type ToolCallAccumulatorEntry = { argumentText: string; callId: string; doneArguments?: string; isDone: boolean; itemId: string; name?: string; responseId: string; updatedAtMs: number; }; /** * Represents immutable accumulator state for active and completed tool calls. */ export type ToolCallAccumulatorState = { callsById: Readonly>; }; /** * Represents an internal tool definition for orchestration. */ export type OrchestrationTool = { description: string; handler: (input: unknown, abortSignal: AbortSignal) => Promise; name: string; }; /** * Represents structured function call output returned to the model. */ export type ToolOutputEnvelope = { data?: unknown; error?: { code?: string; message: string; type: "invalid_arguments" | "tool_error" | "tool_timeout" | "unknown_tool"; }; meta?: { toolName?: string; timeoutMs?: number; }; ok: boolean; }; /** * Represents the result of running a tool invocation. */ export type ToolInvocationResult = { callId: string; output: ToolOutputEnvelope; status: "invalid_arguments" | "success" | "tool_error" | "tool_timeout" | "unknown_tool"; }; /** * Represents input required to invoke a tool from a final done event. */ export type ToolInvocationInput = { doneEvent: FunctionCallArgumentsDoneEvent; timeoutMs: number; toolsByName: ReadonlyMap; }; /** * Creates an empty tool-call accumulator state. * * @returns Empty state. */ export declare const createToolCallAccumulatorState: () => ToolCallAccumulatorState; /** * Reduces a single core server event into updated tool-call accumulator state. * * @param state Previous accumulator state. * @param event Core server event. * @param updatedAtMs Timestamp applied to changed records. * @returns Updated accumulator state. */ export declare const reduceToolCallAccumulatorState: (state: ToolCallAccumulatorState, event: CoreServerEvent, updatedAtMs: number) => ToolCallAccumulatorState; /** * Creates a validated tool registry map keyed by tool name. * * @param tools Tools to index. * @returns Readonly map keyed by name. */ export declare const createToolRegistry: (tools: readonly OrchestrationTool[]) => ReadonlyMap; /** * Executes a tool invocation from a done event with timeout and structured failures. * * @param input Invocation input. * @returns Structured invocation result without throwing. */ export declare const runToolInvocation: (input: ToolInvocationInput) => Promise; /** * Determines whether a done event should trigger a tool execution for a call id. * * @param state Current tool-call accumulator state. * @param event Done event candidate. * @returns True when invocation should run for this done event. */ export declare const shouldInvokeToolCall: (state: ToolCallAccumulatorState, event: FunctionCallArgumentsDoneEvent) => boolean; /** * Creates OpenAI-compatible client events for a function-call output payload. * * @param input Output envelope details. * @returns Client events to send through the core realtime client. */ export declare const createFunctionCallOutputEvents: (input: { autoResponse?: boolean; callId: string; output: ToolOutputEnvelope; }) => readonly CoreClientEvent[]; //# sourceMappingURL=tool-orchestration.d.ts.map