import { type ArchiveSource, type ZipOptions } from './archive.ts'; export interface Chunk { id: string; text: string; vector: Float32Array; meta?: Record; } export interface SearchHit { chunk: Chunk; score: number; } /** In-memory vector index: add chunks, cosine top-k search, JSON round-trip. * Deliberately dependency-free — for thousands of chunks this is plenty; * swap in a real store when you outgrow it. */ export declare class MemoryIndex { private chunks; add(chunk: Chunk): void; addAll(chunks: Chunk[]): void; get size(): number; /** All indexed chunks (insertion order). */ all(): readonly Chunk[]; /** Top-k most similar chunks to the query vector. */ search(queryVector: Float32Array, k?: number): SearchHit[]; /** Assemble a context block from top hits (for stuffing into a user turn). */ contextFor(queryVector: Float32Array, k?: number, maxChars?: number): string; /** Serialize to a plain JSON-able object (vectors as number arrays). */ serialize(): { chunks: Array<{ id: string; text: string; vector: number[]; meta?: Record; }>; }; static restore(data: ReturnType): MemoryIndex; } /** Serialize an index to a flat file map — vectors stay raw Float32. * * manifest.json { kind: 'rag', count, dims, createdAt } * chunks.json [{ id, text, meta }] * vectors.bin Float32 matrix, row-major */ export declare function indexToFiles(index: MemoryIndex): Map; export declare function indexFromFiles(files: Map): MemoryIndex; /** Pack a vector store into a portable zip. */ export declare function exportIndex(index: MemoryIndex, opts?: ZipOptions): Promise; /** Read a vector store back from a zip, URL, File or bytes. */ export declare function importIndex(source: ArchiveSource, opts?: ZipOptions): Promise; /** Split text into ~size-char chunks on sentence-ish boundaries. */ export declare function chunkText(text: string, size?: number, overlap?: number): string[];