TanStack

encodeWsFrame

Function: encodeWsFrame()

ts
function encodeWsFrame(chunk, id): string;

Defined in: packages/ai/src/stream-to-websocket.ts:35

Encode one server→client frame. Durable frames carry the opaque offset in an { id, chunk } envelope (identical to the NDJSON wire); non-durable frames are the bare chunk. Unambiguous because a bare chunk always has a top-level type and the envelope never does.

Parameters

chunk

AGUIEvent

id

string | undefined

Returns

string