import type { MetadataFilter } from "../retrieval/filter.js"; import type { ChunkMetadata, IndexMetadata, StoredChunk } from "../types.js"; /** A stored chunk without its embedding. */ export type IndexedChunk = Pick; export interface VectorSearchHit { id: string; text: string; metadata: ChunkMetadata; score: number; distance: number; } export interface VectorStore { readonly namespace: string; load(): Promise; reset(): Promise; add(chunks: StoredChunk[]): Promise; /** * `filter` holds conditions on per-chunk metadata (`chunk`, `totalChunks`, * `page`, `pageEnd`, `section`); see `matchesFilter()`. Apply it before the * `topK` cut. A store that ignores it still returns correct results, since * Document filters again, but may return fewer than `topK`. */ search(embedding: number[], topK: number, filter?: MetadataFilter): Promise; count(): number; saveIndexMetadata(metadata: IndexMetadata): Promise; readIndexMetadata(): Promise; /** * Optional. Every stored chunk, without embeddings. Lets keyword and hybrid * search rebuild a missing keyword index from the store instead of asking * for a full rebuild. */ listChunks?(): Promise; /** * Optional. Native keyword search (for example a full-text index), used in * place of the built-in BM25 index. Higher `score` means a better match. */ keywordSearch?(query: string, topK: number, filter?: MetadataFilter): Promise; }