/**
 * @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 { EventEmitter } from 'node:events';
import type { MessageBus } from '../confirmation-bus/message-bus.js';
type ToolParams = Record<string, unknown>;
export declare class DiscoveredTool extends BaseTool<ToolParams, ToolResult> {
    private readonly config;
    readonly description: string;
    readonly parameterSchema: Record<string, unknown>;
    constructor(config: Config, name: string, description: string, parameterSchema: Record<string, unknown>);
    build(params: ToolParams): DiscoveredToolInvocation;
    execute(params: ToolParams, _signal: AbortSignal, _updateOutput?: (output: string) => void): Promise<ToolResult>;
}
declare class DiscoveredToolInvocation extends BaseToolInvocation<ToolParams, ToolResult> {
    private readonly tool;
    constructor(tool: DiscoveredTool, params: ToolParams, messageBus?: MessageBus);
    getDescription(): string;
    execute(signal: AbortSignal, updateOutput?: (output: string) => void): Promise<ToolResult>;
}
export declare class ToolRegistry {
    private tools;
    private config;
    private mcpClientManager;
    private logger;
    private discoveryLock;
    constructor(config: Config, eventEmitter?: EventEmitter);
    /**
     * 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;
    /**
     * 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 discover tools from the command line and from MCP servers.
     * Uses truly atomic updates to prevent race conditions.
     */
    discoverAllTools(): Promise<void>;
    /**
     * Discovers tools from project (if available and configured).
     * Can be called multiple times to update discovered tools.
     * This will NOT discover tools from the command line, only from MCP servers.
     * Uses truly atomic updates to prevent race conditions.
     */
    discoverMcpTools(): Promise<void>;
    /**
     * Restarts all MCP servers and re-discovers tools.
     */
    restartMcpServers(): Promise<void>;
    /**
     * Discover or re-discover tools for a single MCP server.
     * Uses truly atomic updates to prevent race conditions.
     * @param serverName - The name of the server to discover tools from.
     */
    discoverToolsForServer(serverName: string): Promise<void>;
    private discoverAndRegisterToolsFromCommand;
    /**
     * 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.
     * @returns An array of FunctionDeclarations.
     */
    getFunctionDeclarations(): FunctionDeclaration[];
    /**
     * Retrieves a filtered list of tool schemas based on a list of tool names.
     * @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 {};
