import { PiAnyClientEvent } from "../types.js"; //#region src/client/eventSource.d.ts /** A decoded SSE frame. `data` is the concatenation of every `data:` line in the * frame (joined by `\n`, per the SSE spec); `event`/`id` are the last-seen field * values, omitted when the frame carried none. */ export interface SseFrame { event?: string; data: string; id?: string; } /** * Incremental SSE frame parser. `push(chunk)` returns every frame completed by * that chunk; partial trailing data is buffered by the shared decoder until its * terminating blank line arrives. */ export declare const createSseDecoder: () => { push(chunk: string): SseFrame[]; }; export interface PiEventStreamOptions { /** Absolute or relative URL of the SSE endpoint. */ url: string; /** Called with each decoded `PiClientEvent`. */ onEvent: (event: PiAnyClientEvent) => void; /** Called after each successful SSE response is opened, before events. */ onConnect?: () => void; /** Non-fatal stream errors (network drop, bad JSON, reconnect-delay failures). * The loop reconnects after each; surface these for logging, not control flow. */ onError?: (error: unknown) => void; /** Injected `fetch` (defaults to the global). */ fetchImpl?: typeof fetch; /** Extra request headers (e.g. auth). */ headers?: Record; /** Thread ID expected in every event envelope. */ expectedThreadId?: string; /** Snapshot-enabled URL used to recover after a stream disconnect. */ snapshotRecoveryUrl?: string; /** Reconnect backoff between a dropped stream and the next attempt. Rejections * are reported via `onError`, then followed by the default ~1s backoff. */ reconnectDelay?: () => Promise; } /** * Open a reconnecting SSE stream. Returns a synchronous unsubscribe that aborts * the in-flight request and stops reconnecting. Frames named `ping` and empty * frames are treated as heartbeats and dropped; every other frame's `data` is * JSON-parsed into a `PiAnyClientEvent`. */ export declare const openPiEventStream: (options: PiEventStreamOptions) => (() => void); export type PiEventStreamConnection = { close: () => void; reconnect: () => boolean; finished: Promise; }; export declare const createPiEventStreamConnection: (options: PiEventStreamOptions) => PiEventStreamConnection; //#endregion //# sourceMappingURL=eventSource.d.ts.map