/** * 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 and the line's own start, * through `onOverflow` (or through `pushItems`, which keeps the reports * in stream order among the lines). */ 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). * `head` is the line's own start - the first characters of the line, up * to `LINE_HEAD_MAX` - kept so the caller can tell WHAT was discarded * without keeping the whole line resident. */ export interface LineOverflow { readonly characters: number; readonly bytes: number; readonly limit: number; readonly head: string; } /** How much of a discarded line's start a report carries. Bounded: the * report must not grow with the line it describes. */ export declare const LINE_HEAD_MAX = 256; /** One item a buffer produced: a complete line, or the report of an * over-long line that was discarded. The two arrive in stream order, so a * caller can act on the report between the lines around it - which is * what decides whether a discarded line still matters. */ export type LineItem = { readonly kind: "line"; readonly text: string; } | { readonly kind: "overflow"; readonly overflow: LineOverflow; }; 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; private head; /** Feed a chunk and return everything it produced, in stream order. */ pushItems(chunk: string | Uint8Array): LineItem[]; /** Feed a chunk and return its complete lines. The reports of * over-long lines go to the `onOverflow` callback. */ push(chunk: string | Uint8Array): string[]; private ingest; private append; private endLine; /** Everything the stream close produced: the final partial line, if * any, and the report of an over-long final line. The two are * exclusive - a line that overflowed leaves no partial line behind. */ flushItems(): LineItem[]; /** 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