/** * Pure, synchronous history chunker for the chunked `session_ready` protocol. * * Splits a `WireMessage[]` history tail into atomic chunks bounded by both a * max-message count and a max-byte size (whichever triggers first). A single * message is never split across chunks — if one message alone exceeds * `maxBytes`, it is emitted as its own chunk and a `console.warn` is logged * (anomaly, not fatal). * * This module has no I/O and no side effects beyond the documented `console.warn` * for oversize messages. It is safe to unit-test in isolation. */ import type { WireMessage } from "../server/wire.js"; /** Maximum number of messages packed into a single `history_chunk`. */ export declare const MAX_MESSAGES_PER_CHUNK = 50; /** Maximum serialized byte size of a single `history_chunk`'s messages. */ export declare const MAX_BYTES_PER_CHUNK: number; /** A single atomic slice of the history tail. */ export interface HistoryChunk { /** 0-based position of this chunk in the emitted sequence. */ index: number; /** Total number of chunks that will be emitted for this history. */ total: number; /** Atomic message slice. Never split mid-message. */ messages: WireMessage[]; } export interface ChunkHistoryOptions { maxMessages?: number; maxBytes?: number; } /** * Split `history` into atomic chunks bounded by `maxMessages` and `maxBytes`. * * - Empty history → `[]` (the caller still emits `session_ready_start` + * `session_ready_end` with zero `history_chunk` frames in between). * - `index` is 0-based; `total` is the final chunk count and is identical on * every chunk in the returned array (computed after packing so it is always * accurate, even when oversize messages force solo chunks). * - Messages are atomic: a single message is never split across two chunks. * - If a single message exceeds `maxBytes`, it is emitted alone in its own * chunk and `console.warn` is called with the message id and index. * * Pure and synchronous — no I/O, no async, no external state. */ export declare function chunkHistory(history: WireMessage[], opts?: ChunkHistoryOptions): HistoryChunk[]; //# sourceMappingURL=history-chunker.d.ts.map