/** Measures true, unclamped token lengths for each input text. */ export type TokenCounter = (texts: string[]) => Promise; /** The unit shape containment reads. `text` must be the exact slice `[sourceStart, sourceEnd)`. */ export interface ContainmentUnit { text: string; sourceStart: number; sourceEnd: number; } export interface ContainmentBudget { /** Resolved token cap: a piece measuring at or below it fits the model's window. */ cap: number; countTokens: TokenCounter; } export interface RunContainmentBudget extends ContainmentBudget { /** * Joins a run exactly as the chunk text is built, so the measured text is the * text that will be embedded. */ joinUnits: (units: readonly T[]) => string; } /** * Divide one sentence unit into pieces that each measure at or below the cap. * * Halving, not a search for the longest fitting prefix: token count is not * monotonic in prefix length — the prefixes of `playingx` measure 3, 3, 4, 3, * 4, 4, 3, 4 here. A single grapheme over the cap is emitted anyway, leaving * the embedder's clamp to truncate it. */ export declare function splitUnitToFit(unit: T, budget: ContainmentBudget): Promise; /** * Divide a group into consecutive runs of whole units whose joined text measures * at or below the cap. * * A one-unit run is final even above the cap: {@link splitUnitToFit} already * reduced that unit as far as a valid cut allows. Each division strictly reduces * the units per run, so progress does not depend on the text. */ export declare function splitUnitsIntoFittingRuns(units: readonly T[], budget: RunContainmentBudget): Promise; //# sourceMappingURL=token-containment.d.ts.map