/** * Vector operations for semantic search. * * Pure JS implementations — no native dependencies or SQLite UDFs needed. * Vectors are computed and compared in JS, stored as BLOBs in SQLite. */ /** * Compute cosine similarity between two normalized vectors. * * For normalized vectors, cosine similarity is simply the dot product: * cos(a, b) = Σ a[i] * b[i] * * Returns a value in [-1, 1] where 1 = identical, 0 = orthogonal, -1 = opposite. */ export declare function cosineSimilarity(a: Float32Array, b: Float32Array): number; /** * Pack a Float32Array into a Buffer for SQLite BLOB storage. * * Creates a copy to ensure the buffer isn't shared with other typed arrays. */ export declare function packVector(vector: Float32Array): Buffer; /** * Unpack a BLOB (Uint8Array from node:sqlite) back to a Float32Array. * * The returned array shares the underlying buffer with the input for * zero-copy performance. Callers should not mutate the input after calling. */ export declare function unpackVector(blob: Uint8Array): Float32Array; /** * Find the top-K most similar vectors from a set. * * Computes cosine similarity between the query vector and every candidate, * then returns the K highest-scoring results sorted by descending score. * * Uses a simple full scan — suitable for the index sizes we expect in a * single-project codebase (typically <100K chunks). For millions of vectors, * an approximate nearest neighbor index (HNSW, IVF) would be needed. */ export declare function topKSimilar(query: Float32Array, vectors: Map, k: number): Array<{ id: number; score: number; }>; //# sourceMappingURL=vector-store.d.ts.map