Open History to see the last commit
1---
2id: encodeWsFrame
3title: encodeWsFrame
4---
5
6```ts
7function encodeWsFrame(chunk, id): string;
8```
9
10Defined in: packages/ai/src/stream-to-websocket.ts:35
11
12Encode one server→client frame. Durable frames carry the opaque offset in an
13`{ id, chunk }` envelope (identical to the NDJSON wire); non-durable frames
14are the bare chunk. Unambiguous because a bare chunk always has a top-level
15`type` and the envelope never does.
16
17## Parameters
18
19### chunk
20
21[`AGUIEvent`](../type-aliases/AGUIEvent.md)
22
23### id
24
25`string` \| `undefined`
26
27## Returns
28
29`string`