export type SearchableToolMetadata = { name: string; label?: string; description?: string; parameters?: unknown; namespace?: { name: string; aliases?: readonly string[]; description?: string; instructions?: string; }; annotations?: { readOnlyHint?: boolean; destructiveHint?: boolean; }; deviceRole?: 'source' | 'selected' | 'other'; }; export type ToolEnrichmentRecord = { schemaHash: string; bilingualSummary?: string; syntheticQueries: string[]; embedding?: number[]; updatedAt: number; }; export type RankedToolMatch = { name: string; score: number; exact: boolean; serverMatched: boolean; }; /** Improved lightweight English stemmer (safe for technical identifiers). */ export declare function stemEnglishTerm(term: string): string; /** * Bilingual Unicode tokenizer supporting: * - camelCase / PascalCase / snake_case / kebab-case splitting * - English stemming * - CJK segmentation via Intl.Segmenter plus overlapping 2-gram fallback for long CJK chunks */ export declare function tokenizeBilingual(text: string): string[]; /** Expand query terms with bilingual & domain synonyms (excluding the original terms). */ export declare function expandQuerySynonyms(terms: Iterable): Set; export declare function normalizeIdentifier(value: string): string; /** Extract original un-hashed MCP tool name from label (`server/orig_tool`) or description hint. */ export declare function extractOriginalMcpToolName(tool: Pick): string | undefined; /** Extract canonical MCP server name (without `mcp__` prefix) when a tool belongs to an MCP server. */ export declare function extractMcpServerName(tool: Pick): string | undefined; /** Check whether a tool belongs to the requested server/namespace filter. */ export declare function matchesServerFilter(tool: SearchableToolMetadata, serverFilter: string): boolean; export declare function computeToolSchemaHash(tool: Pick): string; /** * Deterministic, zero-latency bilingual synthetic enrichment derived from tool name, * original MCP name, description, and schema property names. */ export declare function synthesizeDeterministicToolEnrichment(tool: SearchableToolMetadata): ToolEnrichmentRecord; /** * Schema-hash keyed persistent enrichment cache backed by DurableState when the xopc SQLite DB is open, * with a clean in-memory fallback for tests or offline runners. */ export declare class McpToolEnrichmentCache { private readonly memory; private readonly durable; getOrSynthesize(tool: SearchableToolMetadata): ToolEnrichmentRecord; get(toolName: string, expectedSchemaHash?: string): ToolEnrichmentRecord | undefined; set(toolName: string, record: ToolEnrichmentRecord): void; /** Merge externally computed bilingual summary, synthetic queries, or embedding vector. */ upsertExternalEnrichment(tool: SearchableToolMetadata, patch: { bilingualSummary?: string; syntheticQueries?: string[]; embedding?: number[]; }): ToolEnrichmentRecord; } export declare const defaultMcpToolEnrichmentCache: McpToolEnrichmentCache; export type HybridRankOptions = { limit: number; server?: string; queryEmbedding?: readonly number[]; enrichmentCache?: McpToolEnrichmentCache; }; /** * Multi-field BM25 + bilingual synonym expansion + optional vector RRF ranker. * Replaces rigid coverage-cliff ranking with smooth coverage weighting, elevated original * MCP names, server/namespace scoping, and cross-lingual recall. */ export declare function rankToolsHybrid(query: string, tools: readonly SearchableToolMetadata[], options: HybridRankOptions): RankedToolMatch[]; /** * Bilingual relevance scorer for external connector tools (CLI / Composio), * fixing zero-hit Chinese queries without spaces. */ export declare function scoreExternalToolRelevance(hit: { title: string; summary: string; namespace: string; }, query: string): number;