import { type RealtimeIdFactory } from './id.js'; import type { AnyRealtimeTool, InferRealtimeSchema, RealtimeClock, RealtimeTool, RealtimeToolCall, RealtimeToolExecutionOptions, RealtimeToolResult, RealtimeToolSchema } from './types.js'; /** Options for `defineTool()` with a schema whose type the tool's input is inferred from. */ export interface DefineRealtimeToolOptions, Output> extends Omit, Output>, 'schema'> { /** Validates the input and gives the tool its input type. */ schema: Schema; } /** Defines a realtime tool, checking it has a name and a description. */ export declare function defineTool, Output>(definition: DefineRealtimeToolOptions): RealtimeTool, Output>; export declare function defineTool, Output>(definition: RealtimeTool): RealtimeTool; /** Callbacks as tool calls progress. */ export interface RealtimeToolExecutorHooks { /** Called when a call starts running. */ onStarted?: (call: RealtimeToolCall) => void; /** Called when a call is waiting for confirmation. */ onConfirmationRequired?: (call: RealtimeToolCall) => void; /** Called when a call finishes, successfully or not. */ onCompleted?: (result: RealtimeToolResult) => void; } /** Options for a realtime tool executor. */ export interface RealtimeToolExecutorOptions extends RealtimeToolExecutionOptions, RealtimeToolExecutorHooks { /** The session the calls belong to, passed to each tool. */ sessionId: string; /** Aborts queued and running calls. */ signal?: AbortSignal; /** Replaces the system clock, for tests. */ clock?: RealtimeClock; /** Creates idempotency keys. */ idFactory?: RealtimeIdFactory; } /** * Runs realtime tool calls: validates input, asks for confirmation when required, limits * concurrency and duration, and runs each call id at most once. */ export declare class RealtimeToolExecutor { private readonly options; private readonly tools; private readonly completed; private readonly inFlight; private readonly queue; private active; private readonly clock; private readonly idFactory; constructor(tools: AnyRealtimeTool[] | undefined, options: RealtimeToolExecutorOptions); /** Adds a tool. Throws when one with the same name exists. Returns the executor, for chaining. */ register(tool: AnyRealtimeTool): this; /** Whether a tool is registered. */ has(name: string): boolean; /** Every registered tool. */ list(): AnyRealtimeTool[]; /** Forgets completed results, for one call id or all of them, so those ids can run again. */ clearCompleted(callId?: string): void; /** * Runs a call. A call id already running or completed returns the same result instead of running * twice. */ execute(call: Omit & { idempotencyKey?: string; }): Promise; private runQueued; private resolveTool; private cacheKey; private readCache; private writeCache; private confirmIfRequired; private executeAttempt; private acquire; private release; private finish; } /** Converts tools to OpenAI realtime tool definitions. */ export declare function toOpenAIRealtimeTools(tools: AnyRealtimeTool[]): Array>;