import type { AtomicTextRange, SemanticChunker, TextChunk } from '../chunker/index.js'; import type { EmbedderInterface } from '../chunker/semantic-chunker.js'; import type { ParseResult } from '../parser/index.js'; import type { ImageRendition } from '../pdf-visual/types.js'; import type { VectorChunk, VisualAttachment } from '../vectordb/index.js'; /** * Result of the shared chunk + embed computation. * * - `chunks` is the result of a single `chunker.chunkText` call. * - `embeddings` is the result of `embedder.embedBatch(chunks.map(c => c.text))` * and has the same length as `chunks`. */ export interface BuildChunksAndEmbeddingsResult { chunks: TextChunk[]; embeddings: number[][]; } export interface BuildChunksFromParseResultResult extends BuildChunksAndEmbeddingsResult { visualAttachments: Map; omittedImageCount: number; } export declare function findNearestChunk(chunks: readonly TextChunk[], sourceOffset: number): TextChunk | undefined; export declare function createVisualAttachment(imageIndex: number, rendition: ImageRendition): VisualAttachment; /** * Compute semantic chunks and their embeddings for already-extracted text. * * Calls `chunker.chunkText` exactly once and then * `embedder.embedBatch` on the resulting chunk texts. Does NOT touch * `vectorStore`. Does NOT fail-fast on zero chunks — callers decide * how to handle an empty result (the MCP handler throws `McpError`; * the CLI logs a warning and returns 0). * * Errors from the chunker or embedder propagate verbatim. * * @param text Already-extracted document text (parser output, raw-data * payload, or joined visual-enriched per-page text). * @param chunker Semantic chunker instance (owned by the caller). * @param embedder Embedder implementing the structural `EmbedderInterface` * (only `embedBatch` is required). */ export declare function buildChunksAndEmbeddings(text: string, chunker: SemanticChunker, embedder: EmbedderInterface, atomicRanges?: readonly AtomicTextRange[]): Promise; /** * Preserve the parser content/range mapping at one shared boundary. Display * title handling stays in each dispatch root because it does not affect chunks. */ export declare function buildChunksFromParseResult(result: ParseResult, chunker: SemanticChunker, embedder: EmbedderInterface): Promise; /** * Content identity of a source file: the lowercase SHA-256 hex digest of its * raw bytes. * * Hashing the bytes (not the parsed or normalized text) keeps the value * reproducible by any caller that can read the file, which is what lets a later * sync pass decide "unchanged" without re-parsing. Pure: the caller reads the * file and passes the bytes in. */ export declare function computeContentHash(bytes: Uint8Array): string; /** * Build persistable `VectorChunk`s from computed chunks + embeddings. * * Single source of truth for the chunk→VectorChunk mapping shared by the MCP * ingest handler (`handleIngestFile`) and both CLI ingest paths (default + * visual). Assigns one shared `timestamp` to every chunk, a fresh `id`, and * derives `fileName`/`fileType` from `filePath` via `node:path` (cross-platform). * Does NOT touch `vectorStore` — persistence stays in each caller. * * Throws when a chunk has no corresponding embedding (index mismatch); * `embeddings` must align 1:1 with `chunks`. * * @param fileSize Length value recorded in `metadata.fileSize`. The caller * chooses the source: the default path passes parsed text length; the visual * path passes the joined enriched-page text length (pre-chunking). * @param contentHash {@link computeContentHash} of the source file bytes, * shared by every chunk of that file exactly like `timestamp`. `null` for a * chunk set with no source file; the key is then omitted rather than stored * empty, so a hashless row is never mistaken for a hash of nothing. Required * (not optional) so a new call site cannot silently write hashless rows. */ export declare function buildVectorChunks(params: { filePath: string; chunks: TextChunk[]; embeddings: number[][]; fileSize: number; fileTitle: string | null; contentHash: string | null; visualAttachments?: ReadonlyMap; }): VectorChunk[]; //# sourceMappingURL=compute.d.ts.map