import type { ToolCallRequest } from './provider-base.js'; /** Outcome of executing one tool call. Mirrors mcp-client.ToolCallResult * so dispatchers can pass it through unchanged. */ export interface DispatcherResult { text: string; isError: boolean; /** Optional dispatcher tag for audit / debug — e.g. 'mcp:filesystem' * or 'builtin'. Lets the agent loop's audit row distinguish where * the cost is going. Default empty string. */ source?: string; } /** v1.2.111 — per-call context the agent loop hands to the dispatcher. * Lets dispatchers that fan out further (notably agim-dispatcher's * call_agent / A2A path) chain the parent trace id instead of minting * a fresh root, so an entire turn's tool chain is traceable end-to-end * via a single trace id prefix. Optional — dispatchers that don't fan * out can ignore. */ export interface ToolDispatcherContext { /** Trace id from the calling agent loop's `input.audit?.traceId`. * Undefined when the caller didn't supply one (e.g. test fixtures). */ traceId?: string; } /** * Async function the agent loop invokes once per tool call. Signal is * the loop's overall AbortSignal — dispatchers should honor it to * abort in-flight tool work on /stop or timeout. `ctx` was added in * v1.2.111 and is optional for backward compatibility; pre-v1.2.111 * dispatchers ignore the third argument and continue to work. */ export type ToolDispatcher = (call: ToolCallRequest, signal: AbortSignal, ctx?: ToolDispatcherContext) => Promise; /** * Build the default dispatcher: every call name beginning with `mcp_` * is routed to the MCP registry; everything else gets a graceful * "tool unknown" error. The agent loop's job is to surface that error * back to the model so it can choose a different tool or give up. */ export declare function buildMcpDispatcher(): ToolDispatcher; /** * Stack dispatchers: the first one that returns a non-"unknown" result * wins. Use this in sub-PR #4 to put built-in tools above MCP, so * `echo` / `time` etc. resolve locally and don't accidentally hit a * server's same-named tool. * * Implementation note: we identify "unknown" by checking `source === * 'unknown'`. Dispatchers signal "I don't handle this" by returning * isError=true with source='unknown'; everything else (including * domain-level tool errors) is considered handled. */ export declare function combineDispatchers(...dispatchers: ToolDispatcher[]): ToolDispatcher; //# sourceMappingURL=tool-dispatcher.d.ts.map