/** * ToolRegistry - Manages available tools for an agent */ import type { Tool, ToolDefinition, ToolRegistry as IToolRegistry, ToolExecutionResult, ToolExecutionContext, ToolFallbackHandler } from './types.js'; export type { ToolFallbackHandler } from './types.js'; /** * Options for creating a DefaultToolRegistry */ export interface ToolRegistryOptions { /** * Default timeout for tool execution in milliseconds. * Default: 30000 (30 seconds). Set to 0 to disable timeout. */ defaultTimeoutMs?: number; /** * Per-tool timeout overrides (tool name -> timeout in ms) */ toolTimeouts?: Record; /** * Fallback handler for tools not found in the primary registry. * Enables transparent routing to secondary registries (e.g., meta-tools). */ fallbackHandler?: ToolFallbackHandler; } /** * Default implementation of ToolRegistry */ export declare class DefaultToolRegistry implements IToolRegistry { private readonly tools; private readonly defaultTimeoutMs; private readonly toolTimeouts; private fallbackHandler; constructor(options?: ToolRegistryOptions); /** * Set a fallback handler for tools not found in the primary registry. * Enables transparent routing to secondary registries (e.g., meta-tools). */ setFallbackHandler(handler: ToolFallbackHandler | null): void; /** * Register a tool */ register(tool: Tool): void; /** * Register multiple tools at once */ registerAll(tools: Tool[]): void; /** * Unregister a tool by name */ unregister(name: string): boolean; /** * Get a tool by name */ get(name: string): Tool | undefined; /** * Check if a tool is registered */ has(name: string): boolean; /** * Get all registered tool names */ getNames(): string[]; /** * Get all tool definitions (for sending to LLM) */ getDefinitions(): ToolDefinition[]; /** * Get the number of registered tools */ get size(): number; /** * Execute a tool by name with given input * * @param name - Tool name * @param input - Tool input parameters * @param contextOrTimeout - Optional execution context or timeout override * @param timeoutMs - Optional timeout override (uses default if not provided) */ execute(name: string, input: Record, contextOrTimeout?: ToolExecutionContext | number, timeoutMs?: number): Promise; /** * Execute a tool with a timeout */ private executeWithTimeout; /** * Clear all registered tools */ clear(): void; /** * Get the registry options (for inheritance by sub-agents) */ getOptions(): ToolRegistryOptions; } /** * Create a new ToolRegistry with optional initial tools and options */ export declare function createToolRegistry(tools?: Tool[], options?: ToolRegistryOptions): DefaultToolRegistry;