/**
 * Embedding Cache
 *
 * Caches vector embeddings for semantic search and RAG operations.
 * Key features:
 * - Content hash-based keys for change detection
 * - Batched persistence for performance
 * - Dimension-aware storage
 * - LRU eviction with frequency weighting
 *
 * Embeddings are expensive to compute - caching provides significant speedup.
 */
import { EventEmitter } from 'events';
export interface EmbeddingCacheEntry {
    key: string;
    contentHash: string;
    embedding: number[];
    dimension: number;
    model: string;
    timestamp: number;
    expiresAt: number;
    hits: number;
    metadata?: {
        source?: string;
        chunkIndex?: number;
        tokenCount?: number;
    };
}
export interface EmbeddingCacheConfig {
    enabled: boolean;
    ttlMs: number;
    maxEntries: number;
    dimension: number;
    modelName: string;
    persistToDisk: boolean;
    cachePath: string;
    compressionEnabled: boolean;
    saveBatchSize: number;
}
export interface EmbeddingCacheStats {
    totalEntries: number;
    hits: number;
    misses: number;
    hitRate: number;
    computationsSaved: number;
    dimensionMismatches: number;
    evictions: number;
}
export declare class EmbeddingCache extends EventEmitter {
    private cache;
    private config;
    private stats;
    private pendingSave;
    private saveTimeout;
    private readonly saveDebounceMs;
    constructor(config?: Partial<EmbeddingCacheConfig>);
    /**
     * Get cached embedding for content
     */
    get(content: string, model?: string): number[] | null;
    /**
     * Store embedding in cache
     */
    set(content: string, embedding: number[], metadata?: EmbeddingCacheEntry['metadata']): void;
    /**
     * Get or compute embedding
     */
    getOrCompute(content: string, computeFn: () => Promise<number[]>, metadata?: EmbeddingCacheEntry['metadata']): Promise<{
        embedding: number[];
        cached: boolean;
    }>;
    /**
     * Batch get embeddings
     */
    getBatch(contents: string[]): Map<string, number[] | null>;
    /**
     * Batch set embeddings
     */
    setBatch(items: Array<{
        content: string;
        embedding: number[];
        metadata?: EmbeddingCacheEntry['metadata'];
    }>): void;
    /**
     * Create cache key from content
     */
    private createKey;
    /**
     * Hash content
     */
    private hashContent;
    /**
     * Compress embedding for storage (quantize to fewer bits)
     */
    private compressEmbedding;
    /**
     * Check if entry is expired
     */
    private isExpired;
    /**
     * Evict entries if needed
     */
    private evictIfNeeded;
    /**
     * Evict least recently used entry (with frequency weighting)
     */
    private evictLRU;
    /**
     * Update hit rate statistic
     */
    private updateHitRate;
    /**
     * Invalidate entries for a source file
     */
    invalidateSource(source: string): number;
    /**
     * Get statistics
     */
    getStats(): EmbeddingCacheStats;
    /**
     * Format statistics
     */
    formatStats(): string;
    /**
     * Clear cache
     */
    clear(): void;
    /**
     * Schedule debounced save
     */
    private scheduleSave;
    /**
     * Save to disk
     */
    private saveToDisk;
    /**
     * Load from disk
     */
    private loadFromDisk;
    /**
     * Dispose resources
     */
    dispose(): void;
}
export declare function getEmbeddingCache(config?: Partial<EmbeddingCacheConfig>): EmbeddingCache;
export declare function resetEmbeddingCache(): void;
