You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/classes/StreamProcessor.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: StreamProcessor
5
5
6
6
# Class: StreamProcessor
7
7
8
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:128](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L128)
8
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:132](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L132)
9
9
10
10
StreamProcessor - State machine for processing AI response streams
11
11
@@ -32,7 +32,7 @@ State tracking:
32
32
newStreamProcessor(options): StreamProcessor;
33
33
```
34
34
35
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:155](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L155)
35
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:160](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L160)
36
36
37
37
#### Parameters
38
38
@@ -52,7 +52,7 @@ Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:155]
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:313](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L313)
55
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:318](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L318)
56
56
57
57
Add an approval response (called by client after handling onApprovalRequest)
58
58
@@ -81,7 +81,7 @@ addToolResult(
81
81
error?):void;
82
82
```
83
83
84
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:269](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L269)
84
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:274](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L274)
85
85
86
86
Add a tool result (called by client after handling onToolCall)
87
87
@@ -111,7 +111,7 @@ Add a tool result (called by client after handling onToolCall)
111
111
addUserMessage(content, id?):UIMessage;
112
112
```
113
113
114
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:202](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L202)
114
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:207](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L207)
115
115
116
116
Add a user message to the conversation.
117
117
Supports both simple string content and multimodal content arrays.
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:344](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L344)
163
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:349](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L349)
164
164
165
165
Check if all tool calls in the last assistant message are complete
166
166
Useful for auto-continue logic
@@ -177,7 +177,7 @@ Useful for auto-continue logic
177
177
clearMessages(): void;
178
178
```
179
179
180
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:388](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L388)
180
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:393](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L393)
181
181
182
182
Clear all messages
183
183
@@ -193,7 +193,7 @@ Clear all messages
193
193
finalizeStream(): void;
194
194
```
195
195
196
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1444](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1444)
196
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1562](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1562)
197
197
198
198
Finalize the stream — complete all pending operations.
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:253](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L253)
220
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:258](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L258)
221
221
222
222
Get the current assistant message ID (if one has been created).
223
223
Returns null if prepareAssistantMessage() was called but no content
@@ -235,7 +235,7 @@ has arrived yet.
235
235
getMessages(): UIMessage[];
236
236
```
237
237
238
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:336](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L336)
238
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:341](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L341)
239
239
240
240
Get current messages
241
241
@@ -251,7 +251,7 @@ Get current messages
251
251
getRecording(): ChunkRecording|null;
252
252
```
253
253
254
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1576](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1576)
254
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1698](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1698)
255
255
256
256
Get the current recording
257
257
@@ -267,7 +267,7 @@ Get the current recording
267
267
getState(): ProcessorState;
268
268
```
269
269
270
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1535](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1535)
270
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1655](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1655)
271
271
272
272
Get current processor state (aggregated across all messages)
273
273
@@ -283,7 +283,7 @@ Get current processor state (aggregated across all messages)
283
283
prepareAssistantMessage(): void;
284
284
```
285
285
286
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:232](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L232)
286
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:237](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L237)
287
287
288
288
Prepare for a new assistant message stream.
289
289
Does NOT create the message immediately -- the message is created lazily
@@ -303,7 +303,7 @@ auto-continuation produces no content.
303
303
process(stream): Promise<ProcessorResult>;
304
304
```
305
305
306
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:404](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L404)
306
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:409](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L409)
307
307
308
308
Process a stream and emit events through handlers
309
309
@@ -325,7 +325,7 @@ Process a stream and emit events through handlers
325
325
processChunk(chunk): void;
326
326
```
327
327
328
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:438](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L438)
328
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:443](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L443)
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:380](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L380)
358
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:385](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L385)
359
359
360
360
Remove messages after a certain index (for reload/retry)
361
361
@@ -377,7 +377,7 @@ Remove messages after a certain index (for reload/retry)
377
377
reset(): void;
378
378
```
379
379
380
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1598](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1598)
380
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1721](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1721)
381
381
382
382
Full reset (including messages)
383
383
@@ -393,7 +393,7 @@ Full reset (including messages)
393
393
setMessages(messages): void;
394
394
```
395
395
396
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:174](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L174)
396
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:179](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L179)
397
397
398
398
Set the messages array (e.g., from persisted state)
399
399
@@ -415,7 +415,7 @@ Set the messages array (e.g., from persisted state)
415
415
startAssistantMessage(messageId?):string;
416
416
```
417
417
418
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:241](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L241)
418
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:246](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L246)
419
419
420
420
#### Parameters
421
421
@@ -440,7 +440,7 @@ an assistant message which can cause empty message flicker.
440
440
startRecording(): void;
441
441
```
442
442
443
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1563](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1563)
443
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1685](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1685)
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:325](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L325)
462
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:330](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L330)
463
463
464
464
Get the conversation as ModelMessages (for sending to LLM)
465
465
@@ -478,7 +478,7 @@ Get the conversation as ModelMessages (for sending to LLM)
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1617](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1617)
481
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1740](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1740)
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:113](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L113)
72
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:115](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L115)
73
73
74
74
Add a TOOL_CALL_ARGS event to accumulate arguments (AG-UI)
75
75
@@ -113,7 +113,7 @@ Add a TOOL_CALL_START event to begin tracking a tool call (AG-UI)
113
113
clear(): void;
114
114
```
115
115
116
-
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:262](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L262)
116
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:264](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L264)
117
117
118
118
Clear the tool calls map for the next iteration
119
119
@@ -129,7 +129,7 @@ Clear the tool calls map for the next iteration
129
129
completeToolCall(event): void;
130
130
```
131
131
132
-
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:127](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L127)
132
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:129](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L129)
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:162](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L162)
158
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:164](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L164)
159
159
160
160
Execute all tool calls and return tool result messages
161
161
Yields TOOL_CALL_END events for streaming
@@ -183,7 +183,7 @@ RUN_FINISHED event from the stream
183
183
getToolCalls(): ToolCall[];
184
184
```
185
185
186
-
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:151](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L151)
186
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:153](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L153)
187
187
188
188
Get all complete tool calls (filtered for valid ID and name)
189
189
@@ -199,7 +199,7 @@ Get all complete tool calls (filtered for valid ID and name)
199
199
hasToolCalls(): boolean;
200
200
```
201
201
202
-
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:144](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L144)
202
+
Defined in: [packages/typescript/ai/src/activities/chat/tools/tool-calls.ts:146](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/tools/tool-calls.ts#L146)
203
203
204
204
Check if there are any complete tool calls to execute
Copy file name to clipboardExpand all lines: docs/reference/functions/chat.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: chat
9
9
function chat<TAdapter, TSchema, TStream>(options):TextActivityResult<TSchema, TStream>;
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/index.ts:1512](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1512)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/index.ts:1575](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/index.ts#L1575)
13
13
14
14
Text activity - handles agentic text generation, one-shot text generation, and agentic structured output.
Copy file name to clipboardExpand all lines: docs/reference/functions/createReplayStream.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: createReplayStream
9
9
function createReplayStream(recording):AsyncIterable<AGUIEvent>;
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1629](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1629)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/stream/processor.ts:1752](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/processor.ts#L1752)
Copy file name to clipboardExpand all lines: docs/reference/functions/generateMessageId.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: generateMessageId
9
9
function generateMessageId():string;
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:434](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L434)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:456](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L456)
Copy file name to clipboardExpand all lines: docs/reference/functions/modelMessageToUIMessage.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: modelMessageToUIMessage
9
9
function modelMessageToUIMessage(modelMessage, id?):UIMessage;
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:303](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L303)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:314](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L314)
Copy file name to clipboardExpand all lines: docs/reference/functions/modelMessagesToUIMessages.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: modelMessagesToUIMessages
9
9
function modelMessagesToUIMessages(modelMessages):UIMessage[];
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:362](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L362)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:384](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L384)
Copy file name to clipboardExpand all lines: docs/reference/functions/normalizeToUIMessage.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ title: normalizeToUIMessage
9
9
function normalizeToUIMessage(message, generateId):UIMessage;
10
10
```
11
11
12
-
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:411](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L411)
12
+
Defined in: [packages/typescript/ai/src/activities/chat/messages.ts:433](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/messages.ts#L433)
13
13
14
14
Normalize a message (UIMessage or ModelMessage) to a UIMessage
15
15
Ensures the message has an ID and createdAt timestamp
0 commit comments