/** * The SSE wire format the CLI-lane endpoints speak (`api-server/src/cli/cli-assets.ts`, * `cli-forge.ts`): `event:` / `data:` lines terminated by a blank line, with `: keepalive` * comment lines interleaved. * * Extracted from `generate/stream.ts` — which still re-exports `parseSseChunks` so its own * tests and callers are unchanged — because `forge/stream.ts` consumes the identical format * from a different endpoint. Two copies of a frame buffer that must agree byte-for-byte with * one server is exactly the kind of thing that drifts silently: a fix to one (a multi-line * `data:`, a chunk boundary mid-frame) would not reach the other, and the symptom would be a * dropped terminal frame on one command only. */ export interface SseEvent { event: string; data: unknown; } /** * Incremental frame buffer: SSE frames arrive in arbitrary chunks over the wire — one frame can * span two reads, and two frames can arrive in one — so this accumulates bytes and only emits * events once a full `\n\n`-delimited frame is available. The trailing, not-yet-delimited * remainder stays in `buffer` for the next push. */ export declare function createSseFrameBuffer(): { push: (chunk: string) => SseEvent[]; }; /** * Pure, synchronous parse of a full set of chunks — cheap and exhaustive to test. Production * streaming uses the same underlying buffer one network read at a time, so this function is not * itself on that path. */ export declare function parseSseChunks(chunks: string[]): SseEvent[]; /** * Read an SSE response body to completion, handing every parsed event to `onEvent`. Stops early * — and returns `true` — the moment `onEvent` reports the terminal frame arrived, so a server * that holds the connection open after its result does not stall the command. * * Returns `false` when the stream ended with no terminal frame: a truncated connection, which * every caller must report as "not a confirmed failure" rather than as a clean empty result. */ export declare function consumeSseStream(body: ReadableStream, onEvent: (event: SseEvent) => boolean): Promise;