Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

WebSocketStreamInit.md

104 lines2.2 KB

1---
2id: WebSocketStreamInit
3title: WebSocketStreamInit
4---
5​
6Defined in: [packages/ai/src/stream-to-websocket.ts:90](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L90)
7​
8## Type Parameters
9​
10### TOffset
11​
12`TOffset` *extends* `string` = `string`
13​
14## Properties
15​
16### batch?
17​
18```ts
19optional batch?: number;
20```
21​
22Defined in: [packages/ai/src/stream-to-websocket.ts:96](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L96)
23​
24Chunks buffered per durability append (default 32).
25​
26***
27​
28### debug?
29​
30```ts
31optional debug?: DebugOption;
32```
33​
34Defined in: [packages/ai/src/stream-to-websocket.ts:105](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L105)
35​
36***
37​
38### durability?
39​
40```ts
41optional durability?: (ctx) => StreamDurability<TOffset>;
42```
43​
44Defined in: [packages/ai/src/stream-to-websocket.ts:94](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L94)
45​
46Per-TURN durability factory, keyed by the frame's runId via ctx.request.
47​
48#### Parameters
49​
50##### ctx
51​
52[`WsRunContext`](WsRunContext.md)
53​
54#### Returns
55​
56[`StreamDurability`](StreamDurability.md)\<`TOffset`\>
57​
58***
59​
60### heartbeatMs?
61​
62```ts
63optional heartbeatMs?: number;
64```
65​
66Defined in: [packages/ai/src/stream-to-websocket.ts:98](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L98)
67​
68Heartbeat ping interval in ms (default 30_000).
69​
70***
71​
72### idleTimeoutMs?
73​
74```ts
75optional idleTimeoutMs?: number;
76```
77​
78Defined in: [packages/ai/src/stream-to-websocket.ts:104](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L104)
79​
80Close after this many ms without any inbound frame (default 300_000).
81Never fires while a turn is still streaming, so a long single generation
82(agentic loop, >5-min turn) is safe.
83​
84***
85​
86### onRun
87​
88```ts
89onRun: (ctx) => AsyncIterable<AGUIEvent>;
90```
91​
92Defined in: [packages/ai/src/stream-to-websocket.ts:92](https://github.com/TanStack/ai/blob/main/packages/ai/src/stream-to-websocket.ts#L92)
93​
94Build a fresh chat() stream for each inbound RunAgentInput frame.
95​
96#### Parameters
97​
98##### ctx
99​
100[`WsRunContext`](WsRunContext.md)
101​
102#### Returns
103​
104`AsyncIterable`\<[`AGUIEvent`](../type-aliases/AGUIEvent.md)\>