/** * Corpus persistence — one JSON file per named corpus. * * Location: ~/.ollama-intern/corpora/.json (override via INTERN_CORPUS_DIR) * * Schema is explicitly versioned so we can evolve without silent breakage. * Raw vectors are stored (this file is the database), but they never reach * Claude — search handlers strip them before returning. */ export declare const CORPUS_SCHEMA_VERSION = 2; /** * Hard cap on in-memory chunk count per corpus. A single JSON file that * holds 1M+ chunks will blow past Node's string-length ceiling and OOM on * write. If you hit this, split the corpus. */ export declare const MAX_CHUNKS = 100000; export declare const SCHEMA_WRITER_VERSION: string; export type ChunkType = "heading" | "paragraph" | "code" | "list" | "frontmatter"; export interface CorpusChunk { id: string; path: string; file_hash: string; file_mtime: string; chunk_index: number; char_start: number; char_end: number; text: string; vector: number[]; heading_path: string[]; chunk_type: ChunkType; } export interface CorpusFile { schema_version: number; /** * Package version that wrote this file. Used to reject the case where a * newer build wrote the corpus and an older build (still on the same * schema number) loads it and silently downgrades. Optional for * backward-compat with files written before this field existed. */ schema_version_written_by?: string; name: string; model_version: string; model_digest: string | null; indexed_at: string; chunk_chars: number; chunk_overlap: number; stats: { documents: number; chunks: number; total_chars: number; }; titles: Record; chunks: CorpusChunk[]; } export declare function corpusDir(): string; export declare function corpusPath(name: string): string; export declare function assertValidCorpusName(name: string): void; export declare function loadCorpus(name: string): Promise; export declare function saveCorpus(corpus: CorpusFile): Promise; export interface CorpusSummary { name: string; model_version: string; indexed_at: string; documents: number; chunks: number; total_chars: number; bytes_on_disk: number; /** * Number of paths the last index/refresh recorded as failed to read * (symlink, size cap, TOCTOU, permission). 0 on the happy path. Non-zero * means callers should consider ollama_corpus_refresh({retry_failed: true}). */ failed_path_count?: number; /** * False when the manifest is missing `completed_at` — the previous * mutation landed the corpus JSON but was interrupted before the * manifest completed. Absent (undefined) on legacy pre-Stage-B+C * manifests that never had the marker. Treat undefined as "unknown, not * necessarily bad"; treat false as "run corpus_refresh to restore * inter-file consistency". */ write_complete?: boolean; } export declare function listCorpora(): Promise; /** * Fast stale-detection primitive. * * Compares each manifest-declared path's current stat.mtime against the * mtime stored in the corpus's chunks. Returns as soon as any drift is * found — does NOT re-read file contents or re-hash, so it's cheap enough * for callers to poll before deciding whether to pay the full refresh * cost. * * Reasons: * - "no_corpus" — corpus JSON missing * - "no_manifest" — manifest JSON missing * - "path_missing:" — manifest declares a path that isn't on disk * - "path_added:" — manifest declares a path the corpus has never seen * - "path_removed:" — corpus has a path the manifest no longer lists * - "mtime_drift:" — file's mtime is later than the corpus record */ export declare function isCorpusStale(name: string): Promise<{ stale: boolean; reason?: string; }>; //# sourceMappingURL=storage.d.ts.map