/** * @typedef {{ mode: "convert" | "markdown" | "text" | "blob", format: string }} DocClass */ /** * Classify an ingest by filename extension (or an explicit `format` override) into a routing `mode` * and the `format` tag stored on the row. `convert`/`markdown`/`text` are chunkable (body-searchable); * `blob` is stored byte-exact with only its filename indexed. `format` is the lowercased extension * ("md" canonicalizes "markdown", "txt" canonicalizes "text"; a blob with no extension is "bin"). * @param {string} [filename] * @param {string} [explicit] caller override, e.g. "pdf" | "docx" | "csv" * @returns {DocClass} */ export function classifyDocument(filename?: string, explicit?: string): DocClass; /** * @typedef {object} DocSegmentOptions * @property {"convert"|"markdown"|"text"} mode routing from {@link classifyDocument} — "convert" runs * a parser (pdf/docx), "markdown" segments md text directly, "text" packs flat plaintext * (txt/text/log/csv). (Blobs never reach here.) * @property {string} format the resolved format tag ("pdf" | "docx" | "md" | "txt" | "log" | "csv") * @property {number} [maxSize] byte cap; over → reject before parse (default 10 MB) * @property {number} [maxPages] page cap for PDF (default 2000) * @property {number} [parseTimeoutMs] wall-clock parse cap (default 30 s) */ /** * Convert a chunkable document buffer (pdf/docx/md) to recall-ready markdown segments, BOUNDED and * failing with a CLEAR, specific error (never a crash; never an empty/garbage unit). The conversion + * segmentation half of {@link LiteCtx#ingest}; storage is the caller's. Routing (`mode`/`format`) * comes from {@link classifyDocument} — blobs are handled by the caller and never reach here. * @param {Uint8Array} buffer the document bytes * @param {DocSegmentOptions} opts * @returns {Promise<{ format: string, segments: string[] }>} */ export function documentToSegments(buffer: Uint8Array, opts: DocSegmentOptions): Promise<{ format: string; segments: string[]; }>; export const DEFAULT_MAX_SIZE: number; export type DocClass = { mode: "convert" | "markdown" | "text" | "blob"; format: string; }; export type DocSegmentOptions = { /** * routing from {@link classifyDocument} — "convert" runs * a parser (pdf/docx), "markdown" segments md text directly, "text" packs flat plaintext * (txt/text/log/csv). (Blobs never reach here.) */ mode: "convert" | "markdown" | "text"; /** * the resolved format tag ("pdf" | "docx" | "md" | "txt" | "log" | "csv") */ format: string; /** * byte cap; over → reject before parse (default 10 MB) */ maxSize?: number | undefined; /** * page cap for PDF (default 2000) */ maxPages?: number | undefined; /** * wall-clock parse cap (default 30 s) */ parseTimeoutMs?: number | undefined; };