/** * ChunkStrategy — Document chunking strategies. * * Provides multiple strategies for splitting content into chunks: * 1. By heading (default) — each heading section is a chunk * 2. By token budget — split into chunks of maxTokens size * 3. With overlap window — chunks overlap by overlapTokens * * Token estimation: ~4 chars per token (rough approximation for mixed CJK/Latin). */ import type { ParsedSection } from './document-parser.js'; export interface ChunkOptions { /** Maximum tokens per chunk (default: 512) */ maxTokens?: number; /** Overlap tokens between consecutive chunks (default: 0) */ overlapTokens?: number; } export interface Chunk { content: string; index: number; tokenEstimate: number; metadata: Record; } /** Approximate token count: ~4 chars per token for mixed content */ declare function estimateTokens(text: string): number; export declare class ChunkStrategy { private maxTokens; private overlapTokens; constructor(options?: ChunkOptions); /** * Chunk by heading — each ParsedSection becomes one chunk. * This is the default strategy. */ chunkByHeading(sections: ParsedSection[]): Chunk[]; /** * Chunk by token budget — split text into chunks respecting maxTokens. * Splits at paragraph boundaries when possible. */ chunkByTokenBudget(text: string): Chunk[]; /** * Chunk sections by token budget — applies token budget to each section, * splitting large sections into multiple chunks. */ chunkSectionsByTokenBudget(sections: ParsedSection[]): Chunk[]; private createChunk; private splitLargeParagraph; /** * Get overlap text from the tail of content. * Returns approximately overlapTokens worth of trailing text. */ private getOverlapText; } export { estimateTokens }; //# sourceMappingURL=chunk-strategy.d.ts.map