/** * Deferred tool loading via a meta-tool * * Instead of sending all tool schemas upfront, only a `tool_search` meta-tool * is sent. When the LLM calls it, matching tools are activated and their * schemas appear in the next loop iteration. */ import { type ToolFunction } from './types.js'; /** * Symbol used to mark a tool as a toolbox (carries the pending queue) */ export declare const TOOLBOX_SYMBOL: unique symbol; /** * Metadata attached to a toolbox meta-tool */ export interface ToolboxMeta { pending: ToolFunction[]; } /** * A tool function that also carries toolbox metadata */ export type ToolboxFunction = ToolFunction & { [TOOLBOX_SYMBOL]: ToolboxMeta; }; /** * Custom match function for tool search. * Receives the query and all registered tools, returns the matching subset. */ export type ToolSearchMatcher = (query: string, tools: ToolFunction[]) => ToolFunction[] | Promise; /** * Options for toolSearch */ export interface ToolSearchOptions { match?: ToolSearchMatcher; } /** * Create a deferred tool loader. * * Accepts raw functions or `tool()`-wrapped functions, with an optional * options object as the last argument. Only a `tool_search` meta-tool is * sent to the LLM. When it calls `tool_search("query")`, matching tools * are activated for the next iteration. * * @example * ```ts * // Default substring matching * const search = toolSearch(readFile, writeFile, sendEmail) * * // Custom match function (embeddings, LLM-based, etc.) * const search = toolSearch(readFile, writeFile, sendEmail, { * match: async (query, tools) => { ... } * }) * * const result = await prompt`Help the user: ${userMessage} ${search}`() * ``` */ export declare function toolSearch(...args: [...((...args: any[]) => any)[], ToolSearchOptions] | ((...args: any[]) => any)[]): ToolboxFunction; //# sourceMappingURL=toolbox.d.ts.map