/** * Per-chunk configuration. Sensible defaults — callers rarely override. */ export interface ChunkerConfig { /** Soft max size (chars) for a single chunk. Oversized sections get split. */ chunkSize: number; /** Heading depth we still split on (H1..Hn). Beyond this, a section stays atomic. */ headingSplitDepth: number; /** Keep fenced code blocks whole even if oversized. */ preserveCodeBlocks: boolean; /** Keep $$...$$ LaTeX blocks whole even if oversized. */ preserveLatexBlocks: boolean; /** Drop chunks shorter than this after trimming. */ minChunkChars: number; } /** * Build the default chunker config. `chunkBudgetChars` — sourced from * capacity.ts at runtime — should be passed as `chunkSize` by callers. * The fallback of 1000 chars is retained only for backward-compat in tests * and callers that don't yet have a capacity object; it no longer represents * a hardcoded model-family limit. * * Env override: OBSIDIAN_BRAIN_MAX_CHUNK_TOKENS (handled in capacity.ts). * Callers that pass `chunkBudgetChars` from getCapacity() automatically * honour the env var because getCapacity() reads it first. */ export declare const DEFAULT_CHUNKER_CONFIG: ChunkerConfig; /** * Build a ChunkerConfig from a capacity-provided char budget. Inherits all * other defaults from DEFAULT_CHUNKER_CONFIG so callers only need to supply * what varies. */ export declare function chunkerConfigFromBudget(chunkBudgetChars: number): ChunkerConfig; /** * A single emitted chunk. `chunkIndex` is the ordinal within the parent note, * `contentHash` is a stable fingerprint over heading + content so the indexer * can skip re-embedding an unchanged chunk. */ export interface Chunk { chunkIndex: number; heading: string | null; headingLevel: number | null; content: string; contentHash: string; startLine: number; endLine: number; } /** * Split a markdown document into embedding-sized chunks. * * Strategy: * 1. Strip frontmatter. * 2. Replace protected regions (code fences + $$...$$) with sentinel tokens * so later splits can't cut them in half. * 3. Segment by headings up to `headingSplitDepth`. * 4. For oversize sections, recursively split on paragraph → sentence → hard. * 5. Restore protected regions. Emit Chunks. */ export declare function chunkMarkdown(content: string, config?: ChunkerConfig): Chunk[]; /** * Build the text we actually feed to the embedder for a chunk. Heading is * prepended so semantic queries line up with heading-anchored content. */ export declare function buildChunkEmbeddingText(chunk: Chunk): string; /** * Build the stable chunk id from the parent node's id and the chunk index. * Uses `::` as the separator — node ids are file paths (no `::`) so this * is collision-safe. */ export declare function chunkId(nodeId: string, chunkIndex: number): string;