/** * Tool Registry * * Manages agent tools, their schemas, and execution. * Provides tool conversion for LLM tool calling format. */ import { IAgentTool, IAgentToolSchema, IToolCallResult, IAgentToolContext } from './types'; /** * LLM-specific tool format (Anthropic Claude) */ export interface IClaudeToolDefinition { name: string; description: string; input_schema: { type: 'object'; properties: Record; required?: string[]; }; } /** * LLM-specific tool format (OpenAI) */ export interface IOpenAIToolDefinition { type: 'function'; function: { name: string; description: string; parameters: { type: 'object'; properties: Record; required?: string[]; }; }; } /** * Tool execution options */ export interface IToolExecutionOptions { /** Timeout override */ timeout?: number; /** Retry count override */ retries?: number; /** Skip confirmation even if tool requires it */ skipConfirmation?: boolean; } /** * Tool Registry * * Manages tool definitions, validation, and execution for agents. */ export declare class ToolRegistry { /** Registered tools by tag */ private tools; /** Tool handlers (stored separately for serialization) */ private handlers; /** * Register a single tool */ register(tool: IAgentTool): void; /** * Register multiple tools */ registerMany(tools: IAgentTool[]): void; /** * Unregister a tool */ unregister(tag: string): boolean; /** * Check if a tool exists */ has(tag: string): boolean; /** * Get a tool by tag */ get(tag: string): IAgentTool | undefined; /** * Get all tool tags */ getTags(): string[]; /** * Get tool count */ get size(): number; /** * Get tool schemas (without handlers, for storage/API) */ getSchemas(): IAgentToolSchema[]; /** * Convert tools to Claude/Anthropic format */ toClaudeFormat(): IClaudeToolDefinition[]; /** * Convert tools to OpenAI format */ toOpenAIFormat(): IOpenAIToolDefinition[]; /** * Execute a tool */ execute(tag: string, params: Record, context: IAgentToolContext, options?: IToolExecutionOptions): Promise; /** * Check if tool requires confirmation */ requiresConfirmation(tag: string): boolean; /** * Get estimated cost for a tool */ getCostEstimate(tag: string): number | undefined; /** * Clear all tools */ clear(): void; /** * Convert IToolParam to JSON Schema format */ private convertParametersToJsonSchema; /** * Convert single parameter to JSON Schema */ private convertParamToJsonSchema; /** * Get required parameter names */ private getRequiredParameters; /** * Validate parameters against schema */ private validateParameters; /** * Validate parameter type */ private validateType; /** * Execute with timeout */ private executeWithTimeout; /** * Sleep helper */ private sleep; } export default ToolRegistry;