ai 7.0.34 → 7.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/index.d.ts +26 -10
  3. package/dist/index.js +144 -47
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal/index.d.ts +5 -2
  6. package/dist/internal/index.js +26 -3
  7. package/dist/internal/index.js.map +1 -1
  8. package/docs/03-ai-sdk-core/25-settings.mdx +15 -2
  9. package/docs/03-ai-sdk-core/65-devtools.mdx +6 -0
  10. package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +42 -0
  11. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +29 -0
  12. package/docs/04-ai-sdk-ui/21-error-handling.mdx +10 -4
  13. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +4 -4
  14. package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +10 -8
  15. package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +6 -1
  16. package/docs/08-migration-guides/24-migration-guide-6-0.mdx +28 -0
  17. package/package.json +2 -2
  18. package/src/agent/agent.ts +4 -1
  19. package/src/agent/pipe-agent-ui-stream-to-response.ts +1 -1
  20. package/src/generate-object/stream-object-result.ts +4 -1
  21. package/src/generate-object/stream-object.ts +1 -1
  22. package/src/generate-text/generate-text-events.ts +2 -1
  23. package/src/generate-text/stream-text-result.ts +5 -2
  24. package/src/generate-text/stream-text.ts +113 -33
  25. package/src/generate-text/tool-approval-signature.ts +54 -2
  26. package/src/prompt/index.ts +1 -0
  27. package/src/prompt/request-options.ts +20 -2
  28. package/src/text-stream/pipe-text-stream-to-response.ts +3 -2
  29. package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -2
  30. package/src/util/create-stitchable-stream.ts +41 -15
  31. package/src/util/write-to-server-response.ts +2 -2
@@ -142,7 +142,8 @@ You can specify the timeout either as a number (milliseconds) or as an object wi
142
142
 
143
143
  - `totalMs`: The total timeout for the entire call including all steps.
144
144
  - `stepMs`: The timeout for each individual step (LLM call). This is useful for multi-step generations where you want to limit the time spent on each step independently.
145
- - `chunkMs`: The timeout between stream chunks (streaming only). The call will abort if no new chunk is received within this duration. This is useful for detecting stalled streams.
145
+ - `firstChunkMs`: The timeout until the first content-bearing output of each step (streaming only). Text deltas, reasoning deltas, tool-input deltas, generated files, and tool calls satisfy the timeout. Response metadata, stream starts, empty deltas, raw chunks, and transport activity do not satisfy or reset it.
146
+ - `chunkMs`: The timeout between content-bearing output chunks after output has started (streaming only). Non-content chunks do not reset it. This is useful for detecting streams that stall after generation begins.
146
147
  - `toolMs`: The default timeout for all tool executions. If a tool takes longer, it aborts and returns a tool-error so the model can respond or retry.
147
148
  - `tools`: Per-tool timeout overrides using `{toolName}Ms` keys (e.g. `weatherMs`, `slowApiMs`). Takes precedence over `toolMs`. Tool names are type-checked for autocomplete.
148
149
 
@@ -195,7 +196,19 @@ const result = await generateText({
195
196
  const result = streamText({
196
197
  model: __MODEL__,
197
198
  prompt: 'Invent a new holiday and describe its traditions.',
198
- timeout: { chunkMs: 5000 }, // abort if no chunk received for 5 seconds
199
+ timeout: { chunkMs: 5000 }, // abort if content stalls for 5 seconds
200
+ });
201
+ ```
202
+
203
+ #### Example: First-content timeout for streaming (streamText only)
204
+
205
+ ```ts
206
+ const result = streamText({
207
+ model: __MODEL__,
208
+ prompt: 'Invent a new holiday and describe its traditions.',
209
+ timeout: {
210
+ firstChunkMs: 10000, // 10 seconds for first content in each step
211
+ },
199
212
  });
200
213
  ```
201
214
 
@@ -79,6 +79,12 @@ npx @ai-sdk/devtools@latest
79
79
 
80
80
  Open [http://localhost:4983](http://localhost:4983) to view your AI SDK interactions.
81
81
 
82
+ ### Choose a viewer theme
83
+
84
+ The viewer uses the dark theme by default. Use the theme button in the viewer
85
+ header to switch between dark and light themes. Your selection is stored in
86
+ your browser and restored the next time you open the viewer at the same origin.
87
+
82
88
  ### Monorepo usage
83
89
 
84
90
  If you are using a monorepo setup (e.g. Turborepo, Nx), start DevTools from the same workspace where your AI SDK code runs.
@@ -192,6 +192,46 @@ const result = await agent.continueStream({ session });
192
192
  Use `continueStream()` for incremental output, or `continueGenerate()` to drain
193
193
  the continued turn and return a `GenerateTextResult`.
194
194
 
195
+ ## Stop After a Harness Step
196
+
197
+ Use `stopWhen` to opt into semantic step boundaries. Predicates run after real
198
+ harness tool steps that can continue into another model step, and receive the
199
+ completed steps from the current invocation. When a predicate matches, the
200
+ returned result finishes while the underlying turn remains unfinished. A
201
+ terminal text-only step instead consumes the turn's `finish` event and finishes
202
+ naturally.
203
+
204
+ ```ts
205
+ import { isStepCount } from 'ai';
206
+
207
+ const steppedAgent = new HarnessAgent({
208
+ harness: claudeCode,
209
+ sandbox: createVercelSandbox({
210
+ runtime: 'node24',
211
+ ports: [4000],
212
+ }),
213
+ stopWhen: isStepCount(1),
214
+ });
215
+
216
+ const session = await steppedAgent.createSession();
217
+ const result = await steppedAgent.generate({
218
+ session,
219
+ prompt: 'Create a short TODO.md for this repository.',
220
+ });
221
+
222
+ if (session.hasUnfinishedTurn()) {
223
+ const continueFrom = await session.suspendTurn();
224
+ await persistContinuationState({ chatId, continuationState: continueFrom });
225
+ }
226
+ ```
227
+
228
+ `stopWhen` has no default. When omitted, `HarnessAgent` continues running until
229
+ the turn naturally finishes or pauses for host input, preserving the behavior
230
+ of agents without step control. Pass one predicate or an array; matching any
231
+ predicate finishes the current result slice. Resume a stopped turn with
232
+ `createSession({ continueFrom })` and `continueStream()` or
233
+ `continueGenerate()`.
234
+
195
235
  ## Prepare the Sandbox
196
236
 
197
237
  Use `sandboxConfig` to prepare the sandbox before the harness starts.
@@ -325,6 +365,8 @@ console.log(preparation.identity);
325
365
  - `sandbox`: a `HarnessV1SandboxProvider`.
326
366
  - `id`: optional stable agent identifier.
327
367
  - `instructions`: instructions applied once to a fresh session.
368
+ - `stopWhen`: condition(s) for finishing a result slice after a completed
369
+ harness tool step that can continue into another model step.
328
370
  - `tools`: AI SDK tools executed by the host when the harness calls them.
329
371
  - `activeTools`: allowlist of built-in and host-executed tools the harness can
330
372
  call.
@@ -128,6 +128,11 @@ There are three things worth mentioning:
128
128
  It asks the user for confirmation and displays the result once the user confirms or denies the execution.
129
129
  The result is added to the chat using `addToolOutput` with the `tool` parameter for type safety.
130
130
 
131
+ Typed tool parts also include the `approval-requested`, `approval-responded`,
132
+ and `output-denied` states. Include these states when handling `part.state`
133
+ exhaustively, even when a tool does not require approval. See
134
+ [Tool execution approval](#tool-execution-approval) for a complete approval UI.
135
+
131
136
  ```tsx filename='app/page.tsx' highlight="6,11,16,19-23,25-26,28-33,51,66-70,77-81"
132
137
  'use client';
133
138
 
@@ -217,6 +222,10 @@ export default function Chat() {
217
222
  </div>
218
223
  </div>
219
224
  );
225
+ case 'approval-requested':
226
+ return <div key={callId}>Approval requested.</div>;
227
+ case 'approval-responded':
228
+ return <div key={callId}>Approval response received.</div>;
220
229
  case 'output-available':
221
230
  return (
222
231
  <div key={callId}>
@@ -225,6 +234,8 @@ export default function Chat() {
225
234
  );
226
235
  case 'output-error':
227
236
  return <div key={callId}>Error: {part.errorText}</div>;
237
+ case 'output-denied':
238
+ return <div key={callId}>Tool call denied.</div>;
228
239
  }
229
240
  break;
230
241
  }
@@ -239,6 +250,10 @@ export default function Chat() {
239
250
  );
240
251
  case 'input-available':
241
252
  return <div key={callId}>Getting location...</div>;
253
+ case 'approval-requested':
254
+ return <div key={callId}>Approval requested.</div>;
255
+ case 'approval-responded':
256
+ return <div key={callId}>Approval response received.</div>;
242
257
  case 'output-available':
243
258
  return <div key={callId}>Location: {part.output}</div>;
244
259
  case 'output-error':
@@ -247,6 +262,8 @@ export default function Chat() {
247
262
  Error getting location: {part.errorText}
248
263
  </div>
249
264
  );
265
+ case 'output-denied':
266
+ return <div key={callId}>Location request denied.</div>;
250
267
  }
251
268
  break;
252
269
  }
@@ -266,6 +283,10 @@ export default function Chat() {
266
283
  Getting weather information for {part.input.city}...
267
284
  </div>
268
285
  );
286
+ case 'approval-requested':
287
+ return <div key={callId}>Approval requested.</div>;
288
+ case 'approval-responded':
289
+ return <div key={callId}>Approval response received.</div>;
269
290
  case 'output-available':
270
291
  return (
271
292
  <div key={callId}>
@@ -279,6 +300,8 @@ export default function Chat() {
279
300
  {part.errorText}
280
301
  </div>
281
302
  );
303
+ case 'output-denied':
304
+ return <div key={callId}>Weather request denied.</div>;
282
305
  }
283
306
  break;
284
307
  }
@@ -631,10 +654,16 @@ export default function Chat() {
631
654
  return <pre>{JSON.stringify(part.input, null, 2)}</pre>;
632
655
  case 'input-available':
633
656
  return <pre>{JSON.stringify(part.input, null, 2)}</pre>;
657
+ case 'approval-requested':
658
+ return <div>Approval requested.</div>;
659
+ case 'approval-responded':
660
+ return <div>Approval response received.</div>;
634
661
  case 'output-available':
635
662
  return <pre>{JSON.stringify(part.output, null, 2)}</pre>;
636
663
  case 'output-error':
637
664
  return <div>Error: {part.errorText}</div>;
665
+ case 'output-denied':
666
+ return <div>Tool call denied.</div>;
638
667
  }
639
668
  }
640
669
  })}
@@ -111,11 +111,13 @@ export default function Chat() {
111
111
  }
112
112
  ```
113
113
 
114
- #### Alternative: replace last message
114
+ #### Alternative: replace the failed message
115
115
 
116
- Alternatively you can write a custom submit handler that replaces the last message when an error is present.
116
+ Alternatively, you can write a custom submit handler that replaces the failed
117
+ user message with new input. If the assistant response started streaming before
118
+ the error, remove both the partial assistant response and its user message.
117
119
 
118
- ```tsx file="app/page.tsx" highlight="13-15,17-18,35"
120
+ ```tsx file="app/page.tsx" highlight="13-19,21-22,39"
119
121
  'use client';
120
122
 
121
123
  import { useChat } from '@ai-sdk/react';
@@ -129,7 +131,11 @@ export default function Chat() {
129
131
  event.preventDefault();
130
132
 
131
133
  if (error != null) {
132
- setMessages(messages.slice(0, -1)); // remove last message
134
+ setMessages(messages =>
135
+ messages.at(-1)?.role === 'assistant'
136
+ ? messages.slice(0, -2)
137
+ : messages.slice(0, -1),
138
+ );
133
139
  }
134
140
 
135
141
  sendMessage({ text: input });
@@ -477,10 +477,10 @@ To see `streamText` in action, check out [these examples](#examples).
477
477
  },
478
478
  {
479
479
  name: 'timeout',
480
- type: 'number | { totalMs?: number; stepMs?: number; chunkMs?: number; toolMs?: number; tools?: { [toolName]Ms?: number } }',
480
+ type: 'number | { totalMs?: number; stepMs?: number; firstChunkMs?: number; chunkMs?: number; toolMs?: number; tools?: { [toolName]Ms?: number } }',
481
481
  isOptional: true,
482
482
  description:
483
- 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, chunkMs, toolMs, and/or tools properties. totalMs sets the total timeout for the entire call. stepMs sets the timeout for each individual step (LLM call). chunkMs sets the timeout between stream chunks - the call will abort if no new chunk is received within this duration. toolMs sets the default timeout for all tool executions. tools sets per-tool timeout overrides using the pattern {toolName}Ms (e.g. weatherMs, slowApiMs) that take precedence over toolMs - tool names are type-checked for autocomplete. If a tool takes longer than its timeout, it aborts and returns a tool-error so the model can respond or retry. Can be used alongside abortSignal.',
483
+ 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, firstChunkMs, chunkMs, toolMs, and/or tools properties. totalMs sets the total timeout for the entire call. stepMs sets the timeout for each individual step (LLM call). firstChunkMs sets the timeout until the first content-bearing output in each step; metadata, stream starts, empty deltas, raw chunks, and transport activity do not satisfy it. chunkMs sets the timeout between content-bearing output chunks after output has started; non-content chunks do not reset it. toolMs sets the default timeout for all tool executions. tools sets per-tool timeout overrides using the pattern {toolName}Ms (e.g. weatherMs, slowApiMs) that take precedence over toolMs - tool names are type-checked for autocomplete. If a tool takes longer than its timeout, it aborts and returns a tool-error so the model can respond or retry. Can be used alongside abortSignal.',
484
484
  },
485
485
  {
486
486
  name: 'headers',
@@ -4020,7 +4020,7 @@ To see `streamText` in action, check out [these examples](#examples).
4020
4020
  },
4021
4021
  {
4022
4022
  name: 'pipeUIMessageStreamToResponse',
4023
- type: '(response: ServerResponse, options?: ResponseInit & UIMessageStreamOptions) => void',
4023
+ type: '(response: ServerResponse, options?: ResponseInit & UIMessageStreamOptions) => Promise<void>',
4024
4024
  description:
4025
4025
  'Writes UI message stream output to a Node.js response-like object.',
4026
4026
  properties: [
@@ -4051,7 +4051,7 @@ To see `streamText` in action, check out [these examples](#examples).
4051
4051
  },
4052
4052
  {
4053
4053
  name: 'pipeTextStreamToResponse',
4054
- type: '(response: ServerResponse, init?: ResponseInit) => void',
4054
+ type: '(response: ServerResponse, init?: ResponseInit) => Promise<void>',
4055
4055
  description:
4056
4056
  'Writes text delta output to a Node.js response-like object. It sets a `Content-Type` header to `text/plain; charset=utf-8` and writes each text delta as a separate chunk.',
4057
4057
  properties: [
@@ -246,8 +246,9 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
246
246
  },
247
247
  {
248
248
  name: 'timeout',
249
- type: 'number | { totalMs?: number; stepMs?: number; chunkMs?: number } | undefined',
250
- description: 'Timeout configuration for the generation.',
249
+ type: 'number | { totalMs?: number; stepMs?: number; firstChunkMs?: number; chunkMs?: number } | undefined',
250
+ description:
251
+ 'Timeout configuration for the generation. firstChunkMs and chunkMs are only enforced by stream().',
251
252
  },
252
253
  {
253
254
  name: 'headers',
@@ -360,8 +361,9 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
360
361
  },
361
362
  {
362
363
  name: 'timeout',
363
- type: 'number | { totalMs?: number; stepMs?: number; chunkMs?: number } | undefined',
364
- description: 'Timeout configuration for the generation.',
364
+ type: 'number | { totalMs?: number; stepMs?: number; firstChunkMs?: number; chunkMs?: number } | undefined',
365
+ description:
366
+ 'Timeout configuration for the generation. firstChunkMs and chunkMs are only enforced by stream().',
365
367
  },
366
368
  {
367
369
  name: 'headers',
@@ -712,10 +714,10 @@ const result = await agent.generate({
712
714
  },
713
715
  {
714
716
  name: 'timeout',
715
- type: 'number | { totalMs?: number; stepMs?: number; chunkMs?: number }',
717
+ type: 'number | { totalMs?: number; stepMs?: number; firstChunkMs?: number; chunkMs?: number }',
716
718
  isOptional: true,
717
719
  description:
718
- 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, and/or chunkMs properties. The call will be aborted if it takes longer than the specified timeout. Can be used alongside abortSignal.',
720
+ 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, firstChunkMs, and/or chunkMs properties. firstChunkMs and chunkMs have no effect on generate(); they are streaming-only and are enforced by stream(). Can be used alongside abortSignal.',
719
721
  },
720
722
  {
721
723
  name: 'experimental_sandbox',
@@ -828,10 +830,10 @@ for await (const chunk of stream.textStream) {
828
830
  },
829
831
  {
830
832
  name: 'timeout',
831
- type: 'number | { totalMs?: number; stepMs?: number; chunkMs?: number }',
833
+ type: 'number | { totalMs?: number; stepMs?: number; firstChunkMs?: number; chunkMs?: number }',
832
834
  isOptional: true,
833
835
  description:
834
- 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, and/or chunkMs properties. The call will be aborted if it takes longer than the specified timeout. Can be used alongside abortSignal.',
836
+ 'Timeout in milliseconds. Can be specified as a number or as an object with totalMs, stepMs, firstChunkMs, and/or chunkMs properties. firstChunkMs limits the wait for the first content-bearing output in each model-call step. chunkMs limits gaps between later content-bearing output chunks. Can be used alongside abortSignal.',
835
837
  },
836
838
  {
837
839
  name: 'experimental_sandbox',
@@ -17,7 +17,7 @@ The `pipeUIMessageStreamToResponse` function pipes streaming data to a Node.js S
17
17
  ## Example
18
18
 
19
19
  ```tsx
20
- pipeUIMessageStreamToResponse({
20
+ await pipeUIMessageStreamToResponse({
21
21
  response: serverResponse,
22
22
  status: 200,
23
23
  statusText: 'OK',
@@ -75,3 +75,8 @@ pipeUIMessageStreamToResponse({
75
75
  },
76
76
  ]}
77
77
  />
78
+
79
+ ### Returns
80
+
81
+ A `Promise<void>` that resolves when the stream has been written to the response
82
+ and rejects when reading or writing the stream fails.
@@ -525,6 +525,34 @@ The `unknown` finish reason has been removed. It is now returned as `other`.
525
525
 
526
526
  ## AI SDK UI
527
527
 
528
+ ### Tool UI Part Approval States
529
+
530
+ AI SDK 6 adds `approval-requested`, `approval-responded`, and `output-denied`
531
+ to the tool UI part `state` union. Update exhaustive `switch` statements and
532
+ other state handling to cover the three approval states.
533
+
534
+ ```tsx filename="AI SDK 6"
535
+ switch (part.state) {
536
+ case 'input-streaming':
537
+ return 'Loading input';
538
+ case 'input-available':
539
+ return 'Input ready';
540
+ case 'approval-requested':
541
+ return 'Approval requested';
542
+ case 'approval-responded':
543
+ return 'Approval response received';
544
+ case 'output-available':
545
+ return 'Output ready';
546
+ case 'output-error':
547
+ return part.errorText;
548
+ case 'output-denied':
549
+ return 'Tool call denied';
550
+ }
551
+ ```
552
+
553
+ See [Tool execution approval](/docs/ai-sdk-ui/chatbot-tool-usage#tool-execution-approval)
554
+ for handling approval requests and responses in a chat UI.
555
+
528
556
  ### Tool UI Part Helper Functions Rename
529
557
 
530
558
  The tool UI part helper functions have been renamed to better reflect their purpose and to accommodate both static and dynamic tool parts ([PR #XXXX](https://github.com/vercel/ai/pull/XXXX)).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "7.0.34",
3
+ "version": "7.0.36",
4
4
  "type": "module",
5
5
  "description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "@ai-sdk/gateway": "4.0.26",
45
+ "@ai-sdk/gateway": "4.0.27",
46
46
  "@ai-sdk/provider": "4.0.3",
47
47
  "@ai-sdk/provider-utils": "5.0.12"
48
48
  },
@@ -70,7 +70,10 @@ export type AgentCallParameters<
70
70
  abortSignal?: AbortSignal;
71
71
 
72
72
  /**
73
- * Timeout in milliseconds. Can be specified as a number or as an object with `totalMs`.
73
+ * Timeout in milliseconds. Can be specified as a number or as an object
74
+ * with total, per-step, first-content, inter-content, and tool timeouts.
75
+ * First-content and inter-content timeouts are only enforced by streaming
76
+ * calls.
74
77
  */
75
78
  timeout?: TimeoutConfiguration<TOOLS>;
76
79
 
@@ -66,7 +66,7 @@ export async function pipeAgentUIStreamToResponse<
66
66
  UIMessageStreamOptions<
67
67
  UIMessage<MESSAGE_METADATA, never, InferUITools<TOOLS>>
68
68
  >): Promise<void> {
69
- pipeUIMessageStreamToResponse({
69
+ return pipeUIMessageStreamToResponse({
70
70
  response,
71
71
  headers,
72
72
  status,
@@ -85,7 +85,10 @@ export interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
85
85
  * @param response A Node.js response-like object (ServerResponse).
86
86
  * @param init Optional headers, status code, and status text.
87
87
  */
88
- pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
88
+ pipeTextStreamToResponse(
89
+ response: ServerResponse,
90
+ init?: ResponseInit,
91
+ ): Promise<void>;
89
92
 
90
93
  /**
91
94
  * Creates a simple text stream response.
@@ -964,7 +964,7 @@ class DefaultStreamObjectResult<
964
964
  }
965
965
 
966
966
  pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit) {
967
- pipeTextStreamToResponse({
967
+ return pipeTextStreamToResponse({
968
968
  response,
969
969
  stream: this.textStream,
970
970
  ...init,
@@ -56,7 +56,8 @@ export type GenerateTextStartEvent<
56
56
 
57
57
  /**
58
58
  * Timeout configuration for the generation.
59
- * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs, toolMs, and per-tool overrides via tools.
59
+ * Can be a number (milliseconds) or an object with totalMs, stepMs,
60
+ * firstChunkMs (streaming only), chunkMs, toolMs, and per-tool overrides via tools.
60
61
  */
61
62
  readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
62
63
 
@@ -381,7 +381,7 @@ export interface StreamTextResult<
381
381
  pipeUIMessageStreamToResponse<UI_MESSAGE extends UIMessage>(
382
382
  response: ServerResponse,
383
383
  options?: UIMessageStreamResponseInit & UIMessageStreamOptions<UI_MESSAGE>,
384
- ): void;
384
+ ): Promise<void>;
385
385
 
386
386
  /**
387
387
  * Writes text delta output to a Node.js response-like object.
@@ -395,7 +395,10 @@ export interface StreamTextResult<
395
395
  * `pipeTextStreamToResponse` helpers from `'ai'` with `result.stream`
396
396
  * instead. This method will be removed in the next major release.
397
397
  */
398
- pipeTextStreamToResponse(response: ServerResponse, init?: ResponseInit): void;
398
+ pipeTextStreamToResponse(
399
+ response: ServerResponse,
400
+ init?: ResponseInit,
401
+ ): Promise<void>;
399
402
 
400
403
  /**
401
404
  * Converts the result to a streamed response object with a stream data part stream.