/** * Pure SSE helpers for the base-platform invoke contract. Zero React / DOM / * platform dependencies — unit-tested in isolation (`sse.test.ts`) and shared * verbatim across web (Studio) and React-Native (Portal). */ import type { ProfileLinkRequest } from "./types.js"; export interface ParsedSseEvent { event: string; data: unknown; } /** * Parse complete `event:`/`data:` frames out of an SSE buffer. Returns the * parsed events plus the unparsed remainder (a partial trailing frame). Frames * are separated by a blank line; `data:` JSON is parsed best-effort. */ export declare function parseSseEvents(buffer: string): { events: ParsedSseEvent[]; rest: string; }; /** * Fold one `message` SSE payload into the running assistant text. `assistant` * messages APPEND (streaming). The success `result` message carries the SAME * final text, so it REPLACES rather than appends — otherwise the answer renders * twice. The result is also the fallback for result-only turns. * * Block boundaries become paragraph breaks: a silver `text.start` frame (and, * on the bypass arm, each new `assistant` message) opens a new block, so the * separator lands exactly there — never per `text.delta`, which must stay a * raw append for streaming (#91). */ export declare function reduceAssistantText(current: string, data: unknown): string; /** * Best-effort assistant text from one `message` payload — BOTH protocols: * * - **silver (the pod default)**: AgJSON events — `text.delta` carries the * streamed text in `.delta`; every other event family (turn/message/tool * lifecycle) contributes "". AgJSON never resends the final text, so * deltas are append-only (no result-replacement leg). * - **bypass**: SDKMessage shapes — text blocks off an `assistant` message; * the success `result` string as fallback/replacement. * * The silver arm was MISSING while silver became the pod default — live * portal/studio chat rendered EMPTY assistant messages (0.3.2 coverage * audit G14, confirmed by reducing a live wire capture to ""). */ export declare function extractAssistantText(data: unknown): string; /** Read a string field off an SSE `data` object, or undefined. */ export declare function stringField(data: unknown, key: string): string | undefined; /** * Parse a `profile-link-needed` SSE payload into a typed * {@link ProfileLinkRequest}, or `null` if it does not conform. `appId` must * be a non-empty string and `requested` exactly `"read"` or `"read-write"`; * extra keys are tolerated (ignored). Returns a fresh normalized object so * callers get exactly the typed shape, never the raw wire payload with * unknown extras. */ export declare function parseLinkRequest(data: unknown): ProfileLinkRequest | null; //# sourceMappingURL=sse.d.ts.map