/** One embedding, as a host hands it over. */ export interface EmbeddingInput { /** the row id it describes — `##` */ id: string; /** which model produced it; vectors are only comparable within one */ model: string; vector: number[]; } export interface EmbeddingRecord { id: string; kind: 'row'; model: string; dims: number; /** float32, little-endian — 4 bytes per dimension */ v: Uint8Array; } export declare class EmbeddingError extends Error { } /** Pack to float32. A 768-dim vector costs 3,072 bytes; 5,000 of them are * 15 MB, which is the number that decides whether they can stay resident. */ export declare function packVector(vector: number[]): Uint8Array; export declare function unpackVector(bytes: Uint8Array | ArrayBufferView): Float32Array; /** * Validate a batch before it reaches storage. Everything here is a real * failure mode of a pipeline that calls a model: a truncated response, two * models mixed in one index, a vector for a row that no longer exists after a * document was rewritten. */ export declare function prepareEmbeddings(batch: EmbeddingInput[], knownRowIds: Set): { records: EmbeddingRecord[]; skipped: { id: string; reason: string; }[]; }; export interface ScoredCandidate { id: string; score: number; [k: string]: unknown; } /** * Cosine similarity against the candidates SQLite handed back, top K. * * Vectors are NOT assumed to be normalised — some providers return unit * vectors and some do not, and silently treating one as the other is the kind * of bug that degrades results without ever failing. */ export declare function cosineTopK(query: number[] | Float32Array, candidates: { id: string; v: Uint8Array | ArrayBufferView; dims: number; [k: string]: unknown; }[], k?: number): ScoredCandidate[]; /** * Fuse keyword and semantic results — reciprocal rank fusion, which needs no * score calibration between two rankings that are not on the same scale. A row * both halves agree on rises; a row only one found still surfaces. */ export declare function fuseRankings(rankings: { id: string; [k: string]: unknown; }[][], k?: number): ScoredCandidate[];