import type { loadEmbedder } from "./embeddings.js"; import type { Vault } from "./vault.js"; /** * v3.9.0-rc.28 (external-audit M-2) — hard upper bound on the assembled * late-chunking embed text. Any embedding model truncates at its token budget * (the default `paraphrase-multilingual-MiniLM-L12-v2` at 128 tokens ≈ ~512 * chars), so passing arbitrarily long text just wastes tokenizer work. This cap * (~2000 tokens, well above any model's window) bounds the worst case a large * opt-in `--late-chunk-context` could produce. The DEFAULT path * (`contextChars <= 0`) never assembles context and is unaffected. */ export declare const MAX_EMBED_CHARS = 8000; /** * v2.15.0 — context-prefixed embedding text builder ("late-chunking-style" * context windowing). Pre-pends the document title + heading breadcrumb, * then includes a tail of the previous chunk + the chunk itself + a head * of the next chunk, all bounded so the multilingual model's 128-token * context budget isn't blown. * * Why: short standalone chunks ("Use Adam β=0.9, β=0.999") embed * identically across documents, losing the surrounding context that * disambiguates them. Adding ~50-100 chars of neighbor text + the * doc title + breadcrumb gives the bi-encoder enough signal to keep * cross-document semantic separation. Per Chroma 2024 + Jina AI's late * chunking blog: +2-5 NDCG@10 typical at zero new dep cost. * * Returns the concatenated text. When `contextChars` ≤ 0, returns the * legacy v2.1.0 form (just breadcrumb + chunk text), preserving * bit-for-bit behavior for users who don't opt in. * * v3.8.0-rc.6 ARCH-1 — moved here from server.ts to break circular import. */ export declare function buildEmbedText(chunks: ReadonlyArray<{ text: string; breadcrumb?: string; }>, i: number, opts: { docTitle?: string; contextChars: number; }): string; /** * Per-chunk row shape used by both embedSingleNote + embedSinglePdf. * Matches the row shape that EmbedDb.upsertNote accepts. */ export interface EmbedRow { chunkIndex: number; lineStart: number; lineEnd: number; textPreview: string; vector: Float32Array; } /** * v3.8.0-rc.2 R-7 — embed-vector pipeline for a single markdown note. * Extracted from the inner loop of `syncEmbedDb` so both the bulk sync * and the runtime watcher can use the same chunking + embedding + * upsert path without duplicating logic. * * Returns null if the note has no body chunks (empty / whitespace-only * — caller should `db.deleteNote(relPath)` to drop any stale rows). * * v3.8.0-rc.4 — moved here from src/server.ts (see file header). */ export declare function embedSingleNote(vault: Vault, embedder: Awaited>, entry: { relPath: string; absPath: string; mtimeMs: number; }, opts?: { lateChunkContext?: number; }): Promise<{ chunks: number; rows: EmbedRow[]; } | null>; /** * v3.8.0-rc.3 R-7 (continuation) — embed-vector pipeline for a single * PDF file. Mirrors `embedSingleNote` but reads PDF bytes + extracts * text via pdfjs + joins pages with `[page: N]` markers before chunking. * * Returns null in two cases: * - PDF is image-only (`hasText === false`); caller should * `db.deleteNote(relPath)` to drop stale rows (round-22 H-4 fix). * - PDF body chunks to zero (rare; would indicate all pages empty * even after concatenation). * * v3.8.0-rc.4 — moved here from src/server.ts (see file header). */ export declare function embedSinglePdf(vault: Vault, embedder: Awaited>, entry: { relPath: string; absPath: string; mtimeMs: number; }, opts?: { lateChunkContext?: number; /** * v3.9.0-rc.1 — optional pre-extracted pages (e.g. from OCR). When * provided, skips the cheap pdfjs text extraction step entirely * and uses the supplied text directly. Each page needs `pageNumber` * + `text`. Caller is responsible for the source — common case is * `extractPdfWithOcr()` for image-only / scanned PDFs that pdfjs * can't read text from but Tesseract can. * * Supplying this for a PDF that pdfjs CAN read text from is also * valid (e.g. an explicit OCR re-pass for higher-quality * embeddings); we don't second-guess the caller. */ preExtractedPages?: ReadonlyArray<{ pageNumber: number; text: string; }>; }): Promise<{ chunks: number; rows: EmbedRow[]; } | null>; //# sourceMappingURL=embed-pipeline.d.ts.map