import type { AgentToolConfig } from '@contractspec/lib.contracts-spec/agent'; import type { AnyOperationSpec } from '@contractspec/lib.contracts-spec/operations/operation'; import type { OperationSpecRegistry } from '@contractspec/lib.contracts-spec/operations/registry'; import { type Tool } from 'ai'; import * as z from 'zod'; import type { ToolExecutionContext, ToolHandler } from '../types'; import { type SubagentLike } from './subagent-tool'; export declare function specToolToAISDKTool(specTool: AgentToolConfig, handler: ToolHandler, context?: Partial, effectiveInputSchema?: z.ZodType, /** Optional operation spec for output ref fallback when specTool has no output refs */ operationSpec?: AnyOperationSpec): Tool; /** * Registry for resolving subagents by agentId. */ export type SubagentRegistry = Map; /** * Options for specToolsToAISDKTools. */ export interface SpecToolsToAISDKToolsOptions { /** Optional OperationSpecRegistry for operation-backed tools (operationRef) */ operationRegistry?: OperationSpecRegistry; /** Optional registry for subagent-backed tools (subagentRef) */ subagentRegistry?: SubagentRegistry; } /** * Convert multiple ContractSpec tool configs to AI SDK tools. * * When a tool has operationRef and operationRegistry is provided, the handler * and input schema are derived from the operation. Otherwise, handlers must * be supplied for each tool. * * @param specTools - Array of tool configurations * @param handlers - Map of tool name to handler function (for inline tools) * @param context - Partial context to inject into handler calls * @param options - Optional operationRegistry for operation-backed tools * @returns Record of AI SDK tools keyed by name */ export declare function specToolsToAISDKTools(specTools: AgentToolConfig[], handlers: Map, context?: Partial, options?: SpecToolsToAISDKToolsOptions): Record>; /** * Type-safe tool handler builder. * * @example * ```typescript * const handler = createToolHandler<{ query: string }>((input, ctx) => { * return `Searched for: ${input.query}`; * }); * ``` */ export declare function createToolHandler(handler: (input: TInput, context: ToolExecutionContext) => Promise | TOutput | AsyncGenerator): ToolHandler; /** * Build a tool handlers map from an object. * * @example * ```typescript * const handlers = buildToolHandlers({ * search: async (input: { query: string }) => `Found: ${input.query}`, * calculate: async (input: { a: number, b: number }) => `${input.a + input.b}`, * }); * ``` */ export declare function buildToolHandlers(handlersObj: Record): Map;