/** * Line assembly for process streams: chunks arrive torn at arbitrary BYTE * boundaries, so the byte->string step must stream (a multibyte character * split across chunks decodes whole, never as replacement bytes), and * complete lines are only ever cut at '\n'. The pending partial is scanned * incrementally (never re-split from the start) and bounded: a payload * must not become parseable - or resident - by luck of where the pipe * split it, so an over-long line flips to discard until its newline, and * the owner hears of it once, with its size, through `onOverflow`. */ export declare const LINE_MAX = 65536; /** * The line bound for every output stream of a run or a session. A harness * writes one whole message per line, and pi's `message_end` carries the * full reasoning trace plus the answer, repeated on `turn_end` and * `agent_end`. A maximal reply sets the size: GLM 5.3 emits up to 131,072 * output tokens; at a generous 16 characters per token and 2x JSON * escaping (newlines and quotes) that is 4 MiB on one line. 16 MiB keeps * 4x headroom over that and holds at most 32 MB of UTF-16 per stream while * a line assembles. A longer line is discarded and reported, never * silently dropped: see `LineBuffer`'s `onOverflow`. */ export declare const RUN_LINE_MAX: number; /** One over-long line, reported once when it ends (at its newline or at * stream close). `characters` counts the decoded line (UTF-16 code units, * the unit `limit` is in); `bytes` is its UTF-8 size, exact for byte * chunks (a surrogate pair torn across two string chunks counts 6). */ export interface LineOverflow { readonly characters: number; readonly bytes: number; readonly limit: number; } export declare class LineBuffer { private readonly limit; private readonly onOverflow?; constructor(limit?: number, onOverflow?: ((overflow: LineOverflow) => void) | undefined); private readonly decoder; private pending; private discarding; private discardedCharacters; private discardedBytes; push(chunk: string | Uint8Array): string[]; private ingest; private append; private endLine; /** The final partial line at stream close, if any. */ flush(): string | null; } /** Strict UTF-8 NDJSON framing for a control channel. The limit includes the * newline, and an incomplete final frame is never a command. Unlike diagnostic * line assembly, invalid bytes and oversized frames terminate this channel. */ export declare class ControlFrameError extends Error { readonly code: "frame-too-large" | "invalid-utf8"; constructor(code: "frame-too-large" | "invalid-utf8"); } export declare class ControlLines { private readonly limit; private readonly decoder; private readonly encoder; private pending; private bytes; constructor(limit: number); push(chunk: string | Uint8Array): Iterable; } //# sourceMappingURL=lines.d.ts.map