/** * Agentic QE v3 - AgentDB Memory Backend * High-performance vector storage with HNSW indexing for O(log n) search */ import { MemoryBackend, StoreOptions, VectorSearchResult } from './interfaces'; /** * AgentDB connection configuration */ export interface AgentDBConfig { /** Database file path or connection string */ path: string; /** HNSW index configuration */ hnsw: HNSWConfig; /** Enable write-ahead logging for durability */ walEnabled: boolean; /** Cache size in bytes */ cacheSize: number; } /** * HNSW (Hierarchical Navigable Small World) index configuration * Provides O(log n) approximate nearest neighbor search */ export interface HNSWConfig { /** Number of neighbors per node (default: 16) */ M: number; /** Size of dynamic candidate list during construction (default: 200) */ efConstruction: number; /** Size of dynamic candidate list during search (default: 100) */ efSearch: number; /** Distance metric */ metric: 'cosine' | 'euclidean' | 'dot'; /** Vector dimensions */ dimensions: number; } /** * Connection state for AgentDB */ type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error'; interface IndexStats { vectorCount: number; indexSize: number; buildTime: number; queryLatencyP50: number; queryLatencyP99: number; } /** * AgentDB Memory Backend * * Provides high-performance vector storage and retrieval using HNSW indexing. * Key features: * - O(log n) approximate nearest neighbor search * - 150x faster than linear scan for large datasets * - Persistent storage with WAL for durability * - Configurable distance metrics (cosine, euclidean, dot product) */ export declare class AgentDBBackend implements MemoryBackend { private client; private config; private state; private initPromise; constructor(config?: Partial); /** * Initialize the AgentDB connection */ initialize(): Promise; private doInitialize; /** * Dispose of the AgentDB connection */ dispose(): Promise; /** * Store a value in AgentDB */ set(key: string, value: T, options?: StoreOptions): Promise; /** * Retrieve a value from AgentDB */ get(key: string): Promise; /** * Delete a value from AgentDB */ delete(key: string): Promise; /** * Check if a key exists in AgentDB */ has(key: string): Promise; /** * Search for keys matching a pattern */ search(pattern: string, limit?: number): Promise; /** * Perform vector similarity search using HNSW index * * Performance: O(log n) due to HNSW hierarchical graph traversal * Compared to O(n) linear scan, this provides ~150x speedup for 1M vectors * * @param embedding - Query vector * @param k - Number of nearest neighbors to return * @returns Top k most similar vectors with scores */ vectorSearch(embedding: number[], k: number): Promise; /** * Store a vector embedding with HNSW indexing * * @param key - Unique identifier for the vector * @param embedding - Vector to store * @param metadata - Optional metadata to associate with the vector */ storeVector(key: string, embedding: number[], metadata?: unknown): Promise; /** * Get HNSW index statistics */ getIndexStats(): Promise; /** * Rebuild the HNSW index * Call after bulk insertions for optimal performance */ rebuildIndex(): Promise; /** * Get current connection state */ getConnectionState(): ConnectionState; /** * Get backend configuration */ getConfig(): Readonly; private ensureConnected; private buildKey; } export {}; //# sourceMappingURL=agentdb-backend.d.ts.map