/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { type FunctionDeclaration } from '@google/genai'; import { type AnyDeclarativeTool, type ToolResult, BaseTool, BaseToolInvocation } from './tools.js'; import { type ToolContext } from './tool-context.js'; import { Config } from '../config/config.js'; import type { MessageBus } from '../confirmation-bus/message-bus.js'; export declare const DISCOVERED_TOOL_PREFIX = "discovered_tool_"; type ToolParams = Record; export declare class DiscoveredTool extends BaseTool { private readonly config; readonly description: string; readonly parameterSchema: Record; constructor(config: Config, name: string, description: string, parameterSchema: Record); build(params: ToolParams): DiscoveredToolInvocation; execute(params: ToolParams, signal: AbortSignal, _updateOutput?: (output: string) => void): Promise; } declare class DiscoveredToolInvocation extends BaseToolInvocation { private readonly tool; constructor(tool: DiscoveredTool, params: ToolParams, messageBus?: MessageBus); getDescription(): string; execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise; } export declare class ToolRegistry { private tools; private config; private logger; private discoveryLock; constructor(config: Config); /** * Sets the message bus for the registry and all registered tools. * Message bus wiring now happens unconditionally via Config, so this is kept * only for API completeness/future overrides. */ setMessageBus(): void; private getToolGovernance; private isToolActive; /** * Registers a tool definition. * @param tool - The tool object containing schema and execution logic. */ registerTool(tool: AnyDeclarativeTool): void; /** * Sorts tools as: * 1. Built in tools. * 2. Discovered tools. * 3. MCP tools ordered by server name. * * This is a stable sort in that ties preserve existing order. */ sortTools(): void; /** * Builds a new tool map with only non-discovered tools (core tools). * This is used for atomic updates to avoid race conditions. */ private buildCoreToolsMap; /** * Removes all tools from a specific MCP server. * @param serverName The name of the server to remove tools from. */ removeMcpToolsByServer(serverName: string): void; /** * Discovers tools from project (if available and configured). * Can be called multiple times to update discovered tools. * This will ONLY discover tools from the command line, NOT from MCP servers. * Uses truly atomic updates to prevent race conditions. */ discoverAllTools(): Promise; private discoverAndRegisterToolsFromCommand; /** * Gets schema transformation config based on current settings. * Used to conditionally hide tool parameters that are disabled by settings. */ private getSchemaTransforms; /** * Applies schema transformations based on settings. * Removes parameters that are disabled by user/profile settings. */ private applySchemaTransforms; /** * Retrieves the list of tool schemas (FunctionDeclaration array). * Extracts the declarations from the ToolListUnion structure. * Includes discovered (vs registered) tools if configured. * Filters out disabled tools based on ephemeral settings. * Applies schema transformations to hide disabled parameters. * @returns An array of FunctionDeclarations. */ getFunctionDeclarations(): FunctionDeclaration[]; /** * Retrieves a filtered list of tool schemas based on a list of tool names. * Applies schema transformations to hide disabled parameters. * @param toolNames - An array of tool names to include. * @returns An array of FunctionDeclarations for the specified tools. */ getFunctionDeclarationsFiltered(toolNames: string[]): FunctionDeclaration[]; /** * Returns an array of all registered and discovered tool names. */ getAllToolNames(): string[]; /** * Returns an array of all registered and discovered tool instances. */ getAllTools(): AnyDeclarativeTool[]; /** * Returns an array of enabled tool instances (excludes disabled tools). */ getEnabledTools(): AnyDeclarativeTool[]; /** * Returns an array of tools registered from a specific MCP server. */ getToolsByServer(serverName: string): AnyDeclarativeTool[]; /** * Get the definition of a specific tool. * @param name The name of the tool to retrieve * @param context Optional context to inject into the tool instance */ getTool(name: string, context?: ToolContext): AnyDeclarativeTool | undefined; private registerToolIntoMap; private withDiscoveryLock; } export {};