/** * Vector Store for LLM Browser (V-001) * * Provides vector embedding storage using LanceDB for semantic similarity search. * Supplements SQLite storage - vectors are linked to SQLite records by ID. */ /** * Entity types that can be stored in the vector store */ export type EntityType = 'pattern' | 'skill' | 'content' | 'error'; /** * Record stored in the vector database */ export interface EmbeddingRecord { /** Primary key (matches SQLite record) */ id: string; /** The embedding vector (dimension depends on model) */ vector: number[] | Float32Array; /** Embedding model used */ model: string; /** Version for re-embedding on model changes */ version: number; /** Creation timestamp */ createdAt: number; /** Entity type for filtering */ entityType: EntityType; /** Domain for domain-scoped searches */ domain?: string; /** Tenant ID for multi-tenant isolation */ tenantId?: string; /** Original text that was embedded (for debugging) */ text?: string; } /** * Search options for vector queries */ export interface SearchOptions { /** Maximum results to return (default: 10) */ limit?: number; /** Minimum similarity score threshold (0-1) */ minScore?: number; /** Include vector in results */ includeVector?: boolean; } /** * Filter expression for scoped searches */ export interface FilterExpression { entityType?: EntityType; domain?: string; tenantId?: string; minVersion?: number; } /** * Search result from vector query */ export interface SearchResult { id: string; score: number; metadata: { entityType: EntityType; domain?: string; tenantId?: string; model: string; version: number; createdAt: number; text?: string; }; vector?: number[]; } /** * Vector store statistics */ export interface VectorStoreStats { totalRecords: number; recordsByType: Record; tableExists: boolean; dimensions: number; lastModified?: number; } /** * Options for VectorStore initialization */ export interface VectorStoreOptions { /** Path to LanceDB database directory */ dbPath: string; /** Table name for embeddings (default: 'embeddings') */ tableName?: string; /** Vector dimensions (default: 384 for all-MiniLM-L6-v2) */ dimensions?: number; } /** * VectorStore - LanceDB-backed vector storage for semantic search * * Provides CRUD operations and similarity search for embedding vectors. * Falls back gracefully when LanceDB is not available. */ export declare class VectorStore { private db; private table; private lancedb; private initialized; private readonly dbPath; private readonly tableName; private readonly dimensions; constructor(options: VectorStoreOptions); /** * Check if LanceDB is available */ static isAvailable(): Promise; /** * Initialize the vector store */ initialize(): Promise; /** * Ensure the table exists (creates with seed data if needed) */ private ensureTable; /** * Add a single embedding record */ add(record: EmbeddingRecord): Promise; /** * Add multiple embedding records in batch */ addBatch(records: EmbeddingRecord[]): Promise; /** * Search for similar vectors */ search(vector: number[] | Float32Array, options?: SearchOptions): Promise; /** * Search with metadata filters */ searchFiltered(vector: number[] | Float32Array, filter: FilterExpression, options?: SearchOptions): Promise; /** * Format raw LanceDB results into SearchResult objects */ private formatResults; /** * Get a single record by ID */ get(id: string): Promise; /** * Delete a record by ID * Returns true if a record was deleted, false otherwise. */ delete(id: string): Promise; /** * Delete records matching a filter */ deleteByFilter(filter: FilterExpression): Promise; /** * Recreate the index for optimized search */ reindex(): Promise; /** * Get statistics about the vector store */ getStats(): Promise; /** * Check if the store is using LanceDB */ isUsingLanceDB(): boolean; /** * Close the database connection and release resources */ close(): Promise; } /** * Create a VectorStore instance with default options */ export declare function createVectorStore(options: VectorStoreOptions): VectorStore; /** * Get or create the global vector store (singleton pattern). * * Note: If the global store already exists, the provided options are ignored * and the existing instance is returned. To use different options, call * closeVectorStore() first, then call getVectorStore() with new options. * * @param options - Configuration options (only used when creating new instance) * @returns The global VectorStore instance, or null if LanceDB is unavailable */ export declare function getVectorStore(options?: Partial): Promise; /** * Close the global vector store and release resources. * After calling this, getVectorStore() will create a new instance. */ export declare function closeVectorStore(): Promise; //# sourceMappingURL=vector-store.d.ts.map