/** * [WHO]: ToolInfo, ToolOrchestrator class * [FROM]: Depends on agent-core, extensions, tool-registry, tool-name * [TO]: Consumed by core/runtime/agent-session.ts * [HERE]: core/tools/orchestrator.ts - runtime tool registry, lookup, and active-tool resolution * * REFACTORED: Now uses ToolRegistry internally for namespace-aware collision detection. * Legacy API preserved for backward compatibility. * * Shape note (intentional, not a bug): `_legacyRegistry` and `_registry` are * kept in sync — for any registered AgentTool, both paths return the same * instance. They differ only in lookup shape: * - `_registry` is the canonical view (strict namespace). * - `_legacyRegistry` mirrors it under both `bash` and `functions.bash` keys * so legacy callers that pre-date the namespace refactor keep working. */ import type { AgentTool } from "@catui/agent-core"; import type { ToolDefinition, ToolInfo } from "../extensions-host/index.js"; export interface ToolOrchestratorOptions { /** Initial custom tools from SDK options */ customTools?: ToolDefinition[]; /** Initial active tool names */ initialActiveToolNames?: string[]; /** Tool registry from extensions */ getExtensionTools: () => Map; /** Enable strict tool collision detection (default: true) */ strictToolRegistry?: boolean; } export declare class ToolOrchestrator { /** Legacy map for backward compatibility with un-namespaced lookups. */ private _legacyRegistry; /** New namespace-aware registry with collision detection. */ private _registry; private _activeToolNames; private _customTools; private _initialActiveToolNames?; private _getExtensionTools; /** Track if strict mode is enabled for collision detection. */ private _strictMode; constructor(options: ToolOrchestratorOptions); /** * Get all registered tool names */ getToolNames(): string[]; /** * Get the names of currently active tools */ getActiveToolNames(): string[]; /** * Replace the runtime registry after tools are rebuilt. * Now uses ToolRegistry for collision detection. */ replaceTools(tools: Iterable, activeToolNames?: string[]): void; /** * Get all configured tools with name, description, and parameter schema */ getAllTools(): ToolInfo[]; /** * Get tool by name (supports both namespaced and un-namespaced forms). * Legacy: "bash" → returns functions.bash * New: "functions.bash" → returns functions.bash */ getTool(name: string): AgentTool | undefined; /** * Check if tool exists (supports both namespaced and un-namespaced forms). */ hasTool(name: string): boolean; /** * Set active tools by name * Returns the tools that were actually set and valid tool names */ setActiveToolsByName(toolNames: string[]): { tools: AgentTool[]; validToolNames: string[]; }; /** * Register a tool (supports both namespaced and un-namespaced forms). */ registerTool(name: string, tool: AgentTool): void; /** * Get custom tools */ getCustomTools(): ToolDefinition[]; /** * Replace custom tools after dynamic MCP refresh. */ setCustomTools(customTools: ToolDefinition[]): void; /** * Get initial active tool names */ getInitialActiveToolNames(): string[] | undefined; /** * Get extension tools map */ getExtensionTools(): Map; }