/** * Cache Patcher for NCP * Provides incremental, MCP-by-MCP cache patching operations * Enables fast startup by avoiding full re-indexing */ export interface Tool { name: string; description: string; inputSchema?: any; } export interface ToolMetadataCache { version: string; profileHash: string; lastModified: number; mcps: { [mcpName: string]: { configHash: string; discoveredAt: number; tools: Array<{ name: string; description: string; inputSchema: any; }>; serverInfo: { name: string; version: string; description?: string; }; }; }; } export interface EmbeddingsCache { version: string; modelVersion: string; lastModified: number; vectors: { [toolId: string]: number[]; }; metadata: { [toolId: string]: { mcpName: string; generatedAt: number; enhancedDescription: string; }; }; } export interface MCPConfig { command?: string; args?: string[]; env?: Record; url?: string; } export declare class CachePatcher { private cacheDir; private toolMetadataCachePath; private embeddingsCachePath; private embeddingsMetadataCachePath; constructor(); /** * Ensure cache directory exists (lazy, called before writes) */ private ensureCacheDir; /** * Generate SHA256 hash for MCP configuration */ generateConfigHash(config: MCPConfig): string; /** * Generate SHA256 hash for entire profile */ generateProfileHash(profile: any): string; /** * Load cache with atomic file operations and error handling */ private loadCache; /** * Save cache with atomic file operations to prevent corruption */ private saveCache; /** * Load tool metadata cache */ loadToolMetadataCache(): Promise; /** * Save tool metadata cache */ saveToolMetadataCache(cache: ToolMetadataCache): Promise; /** * Load embeddings cache */ loadEmbeddingsCache(): Promise; /** * Save embeddings cache */ saveEmbeddingsCache(cache: EmbeddingsCache): Promise; /** * Patch tool metadata cache - Add MCP */ patchAddMCP(mcpName: string, config: MCPConfig, tools: Tool[], serverInfo: any): Promise; /** * Patch tool metadata cache - Remove MCP */ patchRemoveMCP(mcpName: string): Promise; /** * Patch tool metadata cache - Update MCP */ patchUpdateMCP(mcpName: string, config: MCPConfig, tools: Tool[], serverInfo: any): Promise; /** * Patch embeddings cache - Add MCP tools */ patchAddEmbeddings(mcpName: string, toolEmbeddings: Map): Promise; /** * Patch embeddings cache - Remove MCP tools */ patchRemoveEmbeddings(mcpName: string): Promise; /** * Update profile hash in tool metadata cache */ updateProfileHash(profileHash: string): Promise; /** * Validate if cache is current with profile */ validateCacheWithProfile(currentProfileHash: string): Promise; /** * Validate cache integrity and repair if needed */ validateAndRepairCache(): Promise<{ valid: boolean; repaired: boolean; }>; /** * Get cache statistics */ getCacheStats(): Promise<{ toolMetadataExists: boolean; embeddingsExists: boolean; mcpCount: number; toolCount: number; embeddingCount: number; lastModified: Date | null; }>; } //# sourceMappingURL=cache-patcher.d.ts.map