ai 7.0.112 → 7.0.114

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 (105) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +6 -6
  3. package/dist/index.d.ts +16 -0
  4. package/dist/index.js +378 -256
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +2 -1
  7. package/dist/internal/index.js +182 -78
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/02-foundations/02-providers-and-models.mdx +3 -0
  10. package/docs/02-foundations/03-prompts.mdx +1 -1
  11. package/docs/02-foundations/04-tools.mdx +2 -2
  12. package/docs/02-foundations/06-provider-options.mdx +11 -11
  13. package/docs/02-getting-started/00-choosing-a-provider.mdx +4 -4
  14. package/docs/02-getting-started/02-nextjs-app-router.mdx +3 -3
  15. package/docs/02-getting-started/03-nextjs-pages-router.mdx +3 -3
  16. package/docs/02-getting-started/04-svelte.mdx +7 -7
  17. package/docs/02-getting-started/05-nuxt.mdx +7 -7
  18. package/docs/02-getting-started/06-nodejs.mdx +3 -3
  19. package/docs/02-getting-started/07-expo.mdx +3 -3
  20. package/docs/02-getting-started/08-tanstack-start.mdx +3 -3
  21. package/docs/02-getting-started/09-coding-agents.mdx +1 -1
  22. package/docs/03-agents/03-workflows.mdx +2 -2
  23. package/docs/03-agents/04-loop-control.mdx +1 -1
  24. package/docs/03-agents/05-configuring-call-options.mdx +4 -2
  25. package/docs/03-agents/06-memory.mdx +2 -2
  26. package/docs/03-agents/06-policy-tool-approvals.mdx +2 -2
  27. package/docs/03-agents/06-tool-approvals.mdx +16 -0
  28. package/docs/03-agents/07-workflow-agent.mdx +11 -11
  29. package/docs/03-agents/08-terminal-ui.mdx +2 -2
  30. package/docs/03-ai-sdk-core/05-generating-text.mdx +2 -2
  31. package/docs/03-ai-sdk-core/17-mcp-apps.mdx +1 -1
  32. package/docs/03-ai-sdk-core/20-prompt-engineering.mdx +1 -1
  33. package/docs/03-ai-sdk-core/26-reasoning.mdx +13 -12
  34. package/docs/03-ai-sdk-core/31-reranking.mdx +12 -10
  35. package/docs/03-ai-sdk-core/32-evaluation.mdx +1 -1
  36. package/docs/03-ai-sdk-core/35-image-generation.mdx +2 -2
  37. package/docs/03-ai-sdk-core/37-speech.mdx +8 -6
  38. package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
  39. package/docs/03-ai-sdk-core/41-skill-uploads.mdx +1 -1
  40. package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
  41. package/docs/03-ai-sdk-core/45-provider-management.mdx +21 -21
  42. package/docs/03-ai-sdk-core/60-telemetry.mdx +1 -1
  43. package/docs/03-ai-sdk-core/65-devtools.mdx +3 -3
  44. package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +1 -1
  45. package/docs/04-ai-sdk-ui/02-chatbot.mdx +3 -3
  46. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +3 -3
  47. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +1 -1
  48. package/docs/05-ai-sdk-rsc/02-streaming-react-components.mdx +5 -5
  49. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
  50. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +1 -1
  51. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +3 -3
  52. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +5 -3
  53. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -3
  54. package/docs/07-reference/01-ai-sdk-core/06-rerank.mdx +5 -5
  55. package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +1 -1
  56. package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +3 -3
  57. package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +4 -2
  58. package/docs/07-reference/01-ai-sdk-core/20-start-batch.mdx +1 -1
  59. package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +18 -0
  60. package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +1 -1
  61. package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +4 -4
  62. package/docs/07-reference/01-ai-sdk-core/60-wrap-language-model.mdx +1 -1
  63. package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +1 -1
  64. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +3 -3
  65. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +1 -1
  66. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +8 -8
  67. package/docs/07-reference/06-ai-sdk-tui/01-run-agent-tui.mdx +1 -1
  68. package/docs/09-troubleshooting/11-use-chat-custom-request-options.mdx +3 -3
  69. package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
  70. package/docs/09-troubleshooting/17-use-chat-stale-body-data.mdx +1 -1
  71. package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
  72. package/package.json +11 -11
  73. package/src/embed/embed-many.ts +18 -2
  74. package/src/evaluate/evaluate.ts +1 -10
  75. package/src/generate-speech/generate-speech.ts +15 -4
  76. package/src/generate-speech/generated-audio-file.ts +0 -8
  77. package/src/generate-text/execute-tools-from-stream.ts +0 -2
  78. package/src/generate-text/generate-text.ts +1 -0
  79. package/src/generate-text/generated-file.ts +0 -8
  80. package/src/generate-text/invoke-tool-callbacks-from-stream.ts +9 -8
  81. package/src/generate-text/output.ts +0 -2
  82. package/src/generate-text/parse-tool-call.ts +38 -25
  83. package/src/generate-text/restricted-telemetry-dispatcher.ts +6 -58
  84. package/src/generate-text/stream-text.ts +1 -0
  85. package/src/generate-text/to-response-messages.ts +7 -0
  86. package/src/generate-text/tool-call.ts +26 -0
  87. package/src/generate-text/validate-tool-approvals.ts +39 -3
  88. package/src/generate-video/generate-video.ts +0 -2
  89. package/src/middleware/extract-reasoning-middleware.ts +1 -1
  90. package/src/middleware/wrap-embedding-model.ts +9 -1
  91. package/src/model/get-embedding-model-provider-options-transformer.ts +17 -0
  92. package/src/prompt/content-part.ts +3 -0
  93. package/src/prompt/standardize-prompt.ts +2 -0
  94. package/src/registry/custom-provider.ts +12 -5
  95. package/src/telemetry/create-telemetry-dispatcher.ts +58 -6
  96. package/src/telemetry/filter-included-context.ts +57 -2
  97. package/src/ui/chat.ts +108 -17
  98. package/src/ui/convert-to-model-messages.ts +8 -0
  99. package/src/ui/direct-chat-transport.ts +2 -0
  100. package/src/ui/process-ui-message-stream.ts +6 -0
  101. package/src/ui/ui-messages.ts +10 -0
  102. package/src/ui/validate-ui-messages.ts +98 -132
  103. package/src/ui-message-stream/to-ui-message-chunk.ts +7 -0
  104. package/src/ui-message-stream/ui-message-chunks.ts +2 -0
  105. package/src/util/write-to-server-response.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.114
4
+
5
+ ### Patch Changes
6
+
7
+ - b5679a7: fix(ai): filter tracing-channel context with telemetry allowlists
8
+ - ca31b89: Clarify in the prompt validation code that `allowSystemInMessages` permits all system messages, including instruction text.
9
+ - Updated dependencies [124b6ef]
10
+ - @ai-sdk/gateway@4.0.92
11
+
12
+ ## 7.0.113
13
+
14
+ ### Patch Changes
15
+
16
+ - dcdb011: fix(ai): route completed streamed tool input callbacks to repaired tools
17
+ - 8f72832: fix(ai): preserve video models from legacy fallback providers
18
+ - fe07867: Fix Google `embedMany` calls with more than 100 values by keeping per-value multimodal content aligned across automatic batches, including text-only entries. Validate content length before sending requests and validate each batch's provider options after middleware transforms them.
19
+ - b74c0cb: fix(ai): resume tool approvals from earlier messages
20
+ - a4b0940: fix(ai): execute manually approved tool inputs produced by schema transforms
21
+
22
+ Preserve approved inputs during revalidation and reject histories whose reconstructed schema output differs, including signed approvals with missing original input. Validate transformed UI tool inputs against the reconstructed output before returning them as static tool parts.
23
+
24
+ - 2693319: Add Gemini 3.8 TTS support with structured speech metadata and per-turn speaker and style controls for prebuilt voices. Preserve native WAV responses without adding a second header, support explicit raw PCM, mu-law, and A-law output, and identify headerless audio formats correctly. Add the Gemini 3.8 speech model IDs to Google and Gateway types.
25
+
26
+ Share transcript and custom-voice inspection through the Google provider internal export, and reject empty speech transcripts before sending a request. Default newer and custom model IDs to structured speech while preserving the legacy format for Gemini 2.5 and 3.1.
27
+
28
+ - c93ee90: fix(ai): preserve message history for direct transport stream callbacks
29
+ - 771e74b: chore: enable dead code lint rules
30
+ - Updated dependencies [fe07867]
31
+ - Updated dependencies [a4b0940]
32
+ - Updated dependencies [2693319]
33
+ - Updated dependencies [b73f2f9]
34
+ - Updated dependencies [771e74b]
35
+ - @ai-sdk/provider-utils@5.0.47
36
+ - @ai-sdk/gateway@4.0.91
37
+
3
38
  ## 7.0.112
4
39
 
5
40
  ### Patch Changes
package/README.md CHANGED
@@ -30,7 +30,7 @@ By default, the AI SDK uses the [Vercel AI Gateway](https://vercel.com/docs/ai-g
30
30
 
31
31
  ```ts
32
32
  const result = await generateText({
33
- model: 'anthropic/claude-opus-4.6', // or 'openai/gpt-5.4', 'google/gemini-3-flash', etc.
33
+ model: 'anthropic/claude-opus-5.5', // or 'openai/gpt-6-astra', 'google/gemini-3.8-flash', etc.
34
34
  prompt: 'Hello!',
35
35
  });
36
36
  ```
@@ -45,7 +45,7 @@ npm install @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google
45
45
  import { anthropic } from '@ai-sdk/anthropic';
46
46
 
47
47
  const result = await generateText({
48
- model: anthropic('claude-opus-4-6'), // or openai('gpt-5.4'), google('gemini-3-flash'), etc.
48
+ model: anthropic('claude-opus-5-5'), // or openai('gpt-6-astra'), google('gemini-3.8-flash'), etc.
49
49
  prompt: 'Hello!',
50
50
  });
51
51
  ```
@@ -58,7 +58,7 @@ const result = await generateText({
58
58
  import { generateText } from 'ai';
59
59
 
60
60
  const { text } = await generateText({
61
- model: 'openai/gpt-5.4', // use Vercel AI Gateway
61
+ model: 'openai/gpt-6-astra', // use Vercel AI Gateway
62
62
  prompt: 'What is an agent?',
63
63
  });
64
64
  ```
@@ -70,7 +70,7 @@ import { generateText, Output } from 'ai';
70
70
  import { z } from 'zod';
71
71
 
72
72
  const { output } = await generateText({
73
- model: 'openai/gpt-5.4',
73
+ model: 'openai/gpt-6-astra',
74
74
  output: Output.object({
75
75
  schema: z.object({
76
76
  recipe: z.object({
@@ -92,7 +92,7 @@ const { output } = await generateText({
92
92
  import { ToolLoopAgent } from 'ai';
93
93
 
94
94
  const sandboxAgent = new ToolLoopAgent({
95
- model: 'openai/gpt-5.4',
95
+ model: 'openai/gpt-6-astra',
96
96
  system: 'You are an agent with access to a shell environment.',
97
97
  tools: {
98
98
  shell: openai.tools.localShell({
@@ -124,7 +124,7 @@ import { openai } from '@ai-sdk/openai';
124
124
  import { ToolLoopAgent, InferAgentUIMessage } from 'ai';
125
125
 
126
126
  export const imageGenerationAgent = new ToolLoopAgent({
127
- model: 'openai/gpt-5.4',
127
+ model: 'openai/gpt-6-astra',
128
128
  tools: {
129
129
  generateImage: openai.tools.imageGeneration({
130
130
  partialImages: 3,
package/dist/index.d.ts CHANGED
@@ -2186,6 +2186,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
2186
2186
  reason?: never;
2187
2187
  isAutomatic?: boolean;
2188
2188
  signature?: string;
2189
+ inputSchemaInput?: unknown;
2189
2190
  };
2190
2191
  } | {
2191
2192
  state: 'approval-responded';
@@ -2201,6 +2202,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
2201
2202
  reason?: string;
2202
2203
  isAutomatic?: boolean;
2203
2204
  signature?: string;
2205
+ inputSchemaInput?: unknown;
2204
2206
  };
2205
2207
  } | {
2206
2208
  state: 'output-available';
@@ -2218,6 +2220,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
2218
2220
  reason?: string;
2219
2221
  isAutomatic?: boolean;
2220
2222
  signature?: string;
2223
+ inputSchemaInput?: unknown;
2221
2224
  };
2222
2225
  } | {
2223
2226
  state: 'output-error';
@@ -2239,6 +2242,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
2239
2242
  reason?: string;
2240
2243
  isAutomatic?: boolean;
2241
2244
  signature?: string;
2245
+ inputSchemaInput?: unknown;
2242
2246
  };
2243
2247
  } | {
2244
2248
  state: 'output-denied';
@@ -2254,6 +2258,7 @@ type UIToolInvocation<TOOL extends UITool | Tool> = {
2254
2258
  reason?: string;
2255
2259
  isAutomatic?: boolean;
2256
2260
  signature?: string;
2261
+ inputSchemaInput?: unknown;
2257
2262
  };
2258
2263
  });
2259
2264
  type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
@@ -2305,6 +2310,7 @@ type DynamicToolUIPart = {
2305
2310
  reason?: never;
2306
2311
  isAutomatic?: boolean;
2307
2312
  signature?: string;
2313
+ inputSchemaInput?: unknown;
2308
2314
  };
2309
2315
  } | {
2310
2316
  state: 'approval-responded';
@@ -2320,6 +2326,7 @@ type DynamicToolUIPart = {
2320
2326
  reason?: string;
2321
2327
  isAutomatic?: boolean;
2322
2328
  signature?: string;
2329
+ inputSchemaInput?: unknown;
2323
2330
  };
2324
2331
  } | {
2325
2332
  state: 'output-available';
@@ -2337,6 +2344,7 @@ type DynamicToolUIPart = {
2337
2344
  reason?: string;
2338
2345
  isAutomatic?: boolean;
2339
2346
  signature?: string;
2347
+ inputSchemaInput?: unknown;
2340
2348
  };
2341
2349
  } | {
2342
2350
  state: 'output-error';
@@ -2353,6 +2361,7 @@ type DynamicToolUIPart = {
2353
2361
  reason?: string;
2354
2362
  isAutomatic?: boolean;
2355
2363
  signature?: string;
2364
+ inputSchemaInput?: unknown;
2356
2365
  };
2357
2366
  } | {
2358
2367
  state: 'output-denied';
@@ -2368,6 +2377,7 @@ type DynamicToolUIPart = {
2368
2377
  reason?: string;
2369
2378
  isAutomatic?: boolean;
2370
2379
  signature?: string;
2380
+ inputSchemaInput?: unknown;
2371
2381
  };
2372
2382
  });
2373
2383
  /**
@@ -2523,6 +2533,7 @@ type UIMessageChunk<METADATA = unknown, DATA_TYPES extends UIDataTypes = UIDataT
2523
2533
  approvalId: string;
2524
2534
  toolCallId: string;
2525
2535
  approvalDescriptor?: unknown;
2536
+ inputSchemaInput?: unknown;
2526
2537
  reason?: string;
2527
2538
  isAutomatic?: boolean;
2528
2539
  signature?: string;
@@ -5802,6 +5813,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
5802
5813
  private onData?;
5803
5814
  private sendAutomaticallyWhen?;
5804
5815
  private pendingMessagePreparations;
5816
+ private pendingApprovalMessageId;
5805
5817
  private activeResponse;
5806
5818
  private activeResumeRequest;
5807
5819
  private jobExecutor;
@@ -5871,6 +5883,7 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
5871
5883
  */
5872
5884
  stop: () => Promise<void>;
5873
5885
  private shouldSendAutomatically;
5886
+ private makeRequestForToolApproval;
5874
5887
  private makeRequest;
5875
5888
  }
5876
5889
 
@@ -6162,6 +6175,9 @@ type ValidateUIMessagesOptions<UI_MESSAGE extends UIMessage> = {
6162
6175
  outputSchema?: FlexibleSchema<InferUIMessageTools<UI_MESSAGE>[NAME]['output']>;
6163
6176
  };
6164
6177
  };
6178
+ experimental_refineToolInput?: {
6179
+ [NAME in keyof InferUIMessageTools<UI_MESSAGE> & string]?: (input: InferUIMessageTools<UI_MESSAGE>[NAME]['input']) => MaybePromiseLike<InferUIMessageTools<UI_MESSAGE>[NAME]['input']>;
6180
+ };
6165
6181
  };
6166
6182
  /**
6167
6183
  * Validates a list of UI messages like `validateUIMessages`,