/** * Tool wrapper for marking functions as LLM tools * * Supports multiple ways to define tools: * - Auto-inference from function signature * - Simple schema: { field: 'description', 'field?': 'optional' } * - Zod schema for full type safety */ import { TOOL_SYMBOL, type ToolMetadata, type ToolFunction, type ToolOptions } from './types.js'; export { TOOL_SYMBOL, type ToolMetadata, type ToolFunction }; export { jsonSchemaToTypeString } from './jsdoc.js'; /** * Convert camelCase/PascalCase to snake_case. * Already-snake_case names pass through unchanged. */ export declare function toSnakeCase(name: string): string; /** * Reset anonymous counter (useful for testing) */ export declare function resetAnonymousCounter(): void; /** * Check if a value is a tool function */ export declare function isTool(value: unknown): value is ToolFunction; /** * Get tool metadata from a tool function */ export declare function getToolMetadata(fn: ToolFunction): ToolMetadata; /** * Wrap a function with tool metadata for LLM use * * Args is always an array where each element corresponds to a function parameter: * - string: description only, param name from parsed function * - [name, desc]: explicit param name and description * - ZodType: Zod schema, param name from .meta({ name }) or parsed function * * @example * ```typescript * // Auto-inferred * tool(readFile); * * // String descriptions * tool(copyFile, { * description: 'Copy a file', * args: ['Source path', 'Destination path'] * }); * * // Tuple [name, description] * tool(search, { * args: [['query', 'Search query'], ['limit', 'Max results']] * }); * * // Zod schemas (arity + type checked) * tool(readFile, { * args: [z.string().describe('Path to the file')] * }); * * // Object syntax for const arrow functions * const myFunc = async (x: string) => x.toUpperCase(); * tool({ myFunc }, { args: ['Input text'] }); * ``` */ export declare function tool any>(fn: T): ToolFunction; export declare function tool any>(fn: T, options: ToolOptions): ToolFunction; export declare function tool any>(namedFn: { [K: string]: T; }): ToolFunction; export declare function tool any>(namedFn: { [K: string]: T; }, options: ToolOptions): ToolFunction; //# sourceMappingURL=tool.d.ts.map