import type { ToolExecutionOptions } from "ai";
import type { Logger } from "../../../util/logger.js";
import type { CompactionSummary } from "../../llm/context-v2/types.js";
import type { EntityPermissionStore } from "./entity-permissions.js";
import { type Tool, type ToolFactory, type AccessControlContext, type AccessControlRule, type PromptHandler, type ToolExecutionResult, PermissionLevel, type ToolMiddleware } from "./types.js";
export type SummaryStoreCallback = (toolCallId: string, summary: CompactionSummary) => void;
/**
 * Middleware that captures compaction summaries for tool outputs.
 *
 * If a tool has a `getSummary` function, this middleware will call it
 * after execution and store the summary via the provided callback.
 *
 * Unlike the previous implementation, this does NOT mutate the tool output,
 * which fixes compatibility issues with type-safe providers like Bedrock.
 *
 * @param storeSummary - Callback to store summaries (typically context.storeSummary)
 * @returns ToolMiddleware that captures summaries
 */
export declare function summaryInjector(storeSummary: SummaryStoreCallback): ToolMiddleware;
/**
 * Central registry for tools with access control.
 *
 * Provides:
 * - Tool registration and instantiation
 * - Access control middleware
 * - User prompt handling
 * - Tool discovery and metadata
 */
export declare class ToolRegistry {
    private factories;
    private instances;
    private accessRules;
    private middleware;
    private logger?;
    private promptHandler?;
    private promptQueue;
    private entityPermissionStore?;
    private scopeStrategy;
    /**
     * Register a tool factory and optionally instantiate it immediately.
     *
     * @param factory - Tool factory to register
     * @param deps - Optional dependencies to instantiate the tool immediately
     * @throws Error if tool with same name already registered
     */
    register<TDeps>(factory: ToolFactory<TDeps>, deps?: TDeps): void;
    /**
     * Register an already-instantiated tool (for tools not using factory pattern).
     *
     * @param tool - Tool instance to register (must have name and execute)
     * @throws Error if tool with same name already registered
     */
    registerTool(tool: any): void;
    /**
     * Get list of all registered tool names.
     *
     * @returns Array of tool names
     */
    listTools(): string[];
    /**
     * Register multiple tool factories at once.
     *
     * @param factories - Array of tool factories to register
     */
    registerAll(factories: ToolFactory[]): void;
    /**
     * Get a tool instance by name.
     *
     * Returns a wrapped version where execute() enforces access control.
     *
     * @param name - Tool name
     * @param context - Access control context (optional)
     * @returns Wrapped tool instance or undefined if not found
     */
    getTool(name: string, context?: AccessControlContext): Tool | undefined;
    /**
     * Get all tool instances.
     *
     * Returns wrapped versions where execute() enforces access control.
     *
     * @param context - Access control context (optional)
     * @returns Array of all wrapped tool instances
     */
    getAllTools(context?: AccessControlContext): Tool[];
    /**
     * Get metadata for all tools.
     *
     * @returns Array of metadata for all instantiated tools
     */
    getToolMetadata(context?: AccessControlContext): Array<{
        name: string;
        description: string;
        category?: string;
        defaultPermission?: PermissionLevel;
    }>;
    /**
     * Get tools as a record for AI SDK.
     *
     * Returns wrapped versions where execute() enforces access control.
     * Filters out tools that are BLOCKED by access control rules.
     *
     * @param context - Access control context (optional, e.g., { mode: AiMode.PLAN })
     * @returns Record mapping tool names to wrapped tool instances
     */
    getToolsRecord(context?: AccessControlContext): Promise<Record<string, Tool>>;
    /**
     * Add one or more access control rules.
     *
     * Rules are evaluated in order when checking permissions.
     * Most restrictive permission level wins.
     *
     * @param rules - Access control rule function(s)
     */
    addAccessRule(...rules: AccessControlRule[]): void;
    /**
     * Add middleware to transform tools.
     *
     * Middleware is applied in the order it's added - first-added middleware
     * executes first (outermost wrapper).
     *
     * @param middleware - Middleware function(s)
     *
     * @example
     * registry.addMiddleware(loggingMiddleware);    // executes first
     * registry.addMiddleware(outputLimiter);         // executes second
     * registry.addMiddleware((tool) => profileTool(tool)); // executes last
     */
    addMiddleware(...middleware: ToolMiddleware[]): void;
    /**
     * Set handler for prompting user for confirmation.
     *
     * @param handler - Prompt handler function
     */
    setPromptHandler(handler: PromptHandler): void;
    /**
     * Set entity permission store for tracking per-entity approvals.
     *
     * When set, tools with `getRequiredPermissions` defined will automatically
     * check if required permissions have been approved before execution.
     * If any permission is not approved, the user will be prompted.
     *
     * @param store - Entity permission store instance
     */
    setEntityPermissionStore(store: EntityPermissionStore): void;
    setLogger(logger: Logger): void;
    /**
     * Get permission scope for a tool.
     *
     * Computes the scope string using the configured strategy.
     * This scope is used to isolate permissions between different tools/categories.
     *
     * @param tool - Tool to get scope for
     * @returns Permission scope string
     */
    private getPermissionScope;
    private getPendingPermissions;
    /**
     * Check permission level for tool execution.
     *
     * Evaluates all access control rules and returns most restrictive permission.
     *
     * @param toolName - Name of tool to check
     * @param context - Access control context
     * @param input - Tool input
     * @returns Permission level for execution
     */
    checkPermission(toolName: string, context: AccessControlContext, input?: any): Promise<PermissionLevel>;
    /**
     * Execute a tool with access control.
     *
     * Checks permissions, prompts user if needed, validates input,
     * and executes the tool.
     *
     * @param toolName - Name of tool to execute
     * @param input - Input data for tool
     * @param context - Access control context
     * @returns Execution result with success status and data/error
     */
    execute<Input, Output>(toolName: string, input: Input, context?: AccessControlContext, options?: ToolExecutionOptions): Promise<ToolExecutionResult<Output>>;
    /**
     * Determines whether a user prompt is required for executing a tool with PROMPT permission.
     *
     * If the tool supports entity extraction and all required entities have already been approved
     * for the relevant permission scope, no prompt is needed and this returns false.
     * If entity extraction is not supported or the entity permission store isn't configured, returns true.
     * If any required entity is not yet approved, returns true (prompt needed).
     *
     * @param tool - The tool to check.
     * @param input - Input from which to extract required entities.
     * @returns True if prompting the user is required; false if all approvals are in place.
     */
    private shouldPromptForEntities;
    /**
     * Store entity approvals after successful user prompt.
     *
     * Extracts entities from tool input and marks them as approved for this
     * tool's scope in the entity permission store. No-op if entity system
     * is not configured.
     *
     * @param tool - Tool that was approved
     * @param input - Tool input to extract entities from
     */
    private approveEntitiesAfterPrompt;
    /**
     * Wrap a tool to enforce access control on execute().
     *
     * Returns a proxied version where execute() goes through the registry's
     * permission checks, ensuring access control is enforced regardless of
     * how the tool is accessed.
     *
     * @param tool - Raw tool instance
     * @param context - Access control context to use for permission checks
     * @returns Wrapped tool with access-controlled execute()
     */
    private wrapTool;
    /**
     * Internal method to get raw tool instance without wrapping
     * or access control. Used internally to avoid infinite recursion.
     *
     * The returned tool will still have middleware applied.
     */
    private getToolInternal;
    private applyMiddleware;
    /**
     * Clear all registered tools and rules.
     *
     * Useful for testing or resetting state.
     */
    clear(): void;
}
//# sourceMappingURL=registry.d.ts.map