import type { StreamFrame } from './spi/token-stream-sink.js';
import type { AgentStreamEvent } from './stream-events.js';
/**
 * A reconnect cursor from `?after=` or the `Last-Event-ID` header: a non-negative integer, or
 * `undefined` for anything else (absent, malformed).
 */
export declare function parseStreamCursor(raw: unknown): number | undefined;
/**
 * The agent-protocol events one {@link StreamFrame} stands for. Pure: the same frame at the same
 * position always yields the same events, which is what lets a re-attaching reader number them the
 * way the first reader did.
 *
 * `position` is the frame's 0-based index in the run's buffer; it names a component frame buffered
 * before the loop stamped ids on them (`ui:<position>`), so a replay replaces rather than duplicates.
 */
export declare function frameToEvents(frame: StreamFrame, position: number): AgentStreamEvent[];
/**
 * Writes a run's frames in the agent protocol, one `data:` frame per event. Stateful only in the
 * positions it counts, so feed it every frame of the run in buffer order.
 *
 * Every event carries an SSE `id:` — its 1-based sequence number within the run. The number is a
 * pure function of the run's buffered stream (every sink replays a run from its first frame, in
 * write order, and {@link frameToEvents} is pure), so the same event gets the same number on the
 * POST that started the run and on any later `GET …/stream`, whichever replica serves it. Events at
 * or below `after` — what a reconnecting client already has — are counted but not written. `meta`,
 * `done` and `error` carry no id.
 */
export declare class AgentSseEncoder {
    private readonly after;
    private position;
    private seq;
    private failed;
    constructor(after?: number);
    /** The SSE text for the next frame of the run (possibly `''`). */
    encode(frame: StreamFrame): string;
    /**
     * The closing frame: `event: done` for a run that ended, nothing after an `event: error` — a
     * reader takes the error as the end, and a `done` after it would read as a success.
     */
    close(): string;
}
//# sourceMappingURL=sse.d.ts.map