/** * DeferredToolRegistry: tracks the deferred tool pool and which tools the * agent has discovered (loaded) during this session. * * Lives on the CortexAgent instance. `refreshTools()` populates the deferred * pool from the union of registered + MCP tools (filtered by deferral * criteria), and `ToolSearch` updates the discovered set when the agent * resolves a query. * * The slot content (`formatSlotContent`) is the canonical text that goes * into the `_available_tools` slot. It is byte-stable for any given pool + * discovered set so the prompt cache hits cleanly. */ import type { CortexTool } from '../../tool-contract.js'; /** * Result of resolving a ToolSearch query. */ export interface ToolSearchResult { /** Tools that were resolved by the query (newly loaded + already loaded). */ resolved: CortexTool[]; /** Names of tools newly added to the discovered set by this query. */ newlyDiscovered: string[]; /** Names of tools the query referenced that were not found in the pool. */ notFound: string[]; } export declare class DeferredToolRegistry { /** Tools currently eligible for deferral, keyed by name. */ private deferredPool; /** Names the model has loaded via ToolSearch. Persists for the session. */ private discovered; /** * Replace the deferred pool. Called by `refreshTools()` whenever the * underlying tool set changes (MCP server connect/disconnect, etc). * * Tools that were previously discovered remain in the discovered set even * if they're temporarily missing from the pool (e.g., MCP server briefly * disconnected). The next `refreshTools()` call will see them again. */ setDeferredPool(tools: readonly CortexTool[]): void; /** * Mark tool names as discovered. Subsequent `refreshTools()` calls will * include their full schemas in the agent's tools array. * * Returns the subset that were newly added (i.e., were not already * discovered). Used by ToolSearch to report what changed. */ markDiscovered(names: readonly string[]): string[]; /** * The set of tool names the agent has loaded so far. */ getDiscovered(): ReadonlySet; /** * Names currently in the deferred pool that have NOT yet been discovered. * These are the names that should appear in the `_available_tools` slot. * Returned sorted alphabetically for deterministic, cache-stable output. */ getUndiscoveredNames(): string[]; /** * Format the `_available_tools` slot content. Names only (no descriptions), * sorted, in a fixed format. Returns an empty string when there are no * undiscovered tools (the slot will be set to empty content, which still * occupies a slot index but contributes no tokens). */ formatSlotContent(): string; /** * Resolve a ToolSearch query against the deferred pool. * * Query formats: * - "select:NameA,NameB" Direct load by name. Bypasses scoring. * - "ExactToolName" Exact name match if it exists in the pool. * - "prefix__" Returns all tools starting with the prefix. * - "keyword another" Keyword search; scored by name + description. * * Discovered tools that are referenced by the query are still returned * (harmless no-op so the model gets confirmation), but they don't count * as "newly discovered". */ resolveQuery(query: string, maxResults: number): ToolSearchResult; private resolveByNames; private scoreKeywordQuery; } //# sourceMappingURL=registry.d.ts.map