/** * Semantic Enhancement Engine for Tool Discovery * * INDUSTRY PURPOSE: Addresses semantic gaps in vector-based tool discovery through * two complementary enhancement mechanisms: * * 1. CAPABILITY INFERENCE SYSTEM (Global Domain Knowledge) * - Infers implicit capabilities from tool categories/types * - Example: shell MCP → can perform git, docker, ffmpeg operations * - Fills knowledge gaps that vector similarity cannot capture * * 2. SEMANTIC INTENT RESOLUTION (Context-Specific Language Mapping) * - Maps natural language expressions to domain-specific operations * - Example: "upload my code" → git:push, github:create_repository * - Resolves contextual language that differs from tool naming * * This follows established NLP/IR patterns for query expansion and semantic matching. */ /** * Domain Capability Inference - Maps tool types to their implicit capabilities * INDUSTRY TERM: Capability Inference / Domain Knowledge Graph */ interface CapabilityInferenceRule { implicitDomains: string[]; confidenceScore: number; applicableContext?: string; } /** * Semantic Intent Resolution - Maps user language to specific tool operations * INDUSTRY TERM: Intent Entity Resolution / Contextual Semantic Mapping */ interface SemanticResolutionRule { targetOperations: string[]; resolutionRationale: string; confidenceScore: number; domainContext?: string; } /** * Enhancement Result - Output of semantic enhancement process * INDUSTRY TERM: Semantic Augmentation / Relevance Enhancement */ interface SemanticEnhancement { enhancementType: 'capability_inference' | 'intent_resolution'; relevanceBoost: number; enhancementReason: string; confidenceLevel: number; } export declare class SemanticEnhancementEngine { /** * CAPABILITY INFERENCE SYSTEM * Maps tool types/categories to their implicit capability domains * * PURPOSE: Vector search doesn't know that 'shell' can do git operations, * but humans intuitively understand this domain knowledge. */ private capabilityInferenceRules; /** * SEMANTIC INTENT RESOLUTION SYSTEM * Maps natural language user expressions to specific tool operations * * PURPOSE: Users say "upload my code" but tools are named "git push". * This bridges the language gap with contextual semantic mapping. */ private semanticResolutionRules; /** * Apply semantic enhancement to a query-tool pair * * PROCESS: * 1. Capability Inference: Check if tool type has implicit capabilities matching query * 2. Intent Resolution: Check if query maps to specific operations this tool provides * 3. Combine enhancements with confidence weighting * 4. Apply anti-pattern prevention (confidence capping) * * @param userQuery Natural language user query * @param toolIdentifier Tool identifier (format: "mcp:tool" or just tool name) * @param toolDescription Tool description for context * @returns Array of semantic enhancements to apply */ applySemanticalEnhancement(userQuery: string, toolIdentifier: string, toolDescription: string): SemanticEnhancement[]; /** * Check if user query matches a semantic pattern * Uses improved fuzzy keyword matching with flexible thresholds */ private matchesSemanticPattern; /** * Add new capability inference rule (for dynamic expansion) */ addCapabilityInferenceRule(toolType: string, rule: CapabilityInferenceRule): void; /** * Add new semantic resolution rule (for dynamic expansion) */ addSemanticResolutionRule(semanticPattern: string, rule: SemanticResolutionRule): void; /** * Get enhancement engine statistics */ getEnhancementStatistics(): { capabilityInferenceRules: number; semanticResolutionRules: number; totalImplicitDomains: number; totalTargetOperations: number; averageConfidence: { capabilityInference: number; intentResolution: number; }; }; } export {}; //# sourceMappingURL=semantic-enhancement-engine.d.ts.map