@ai-sdk/provider-utils 5.0.0-beta.2 → 5.0.0-beta.21

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 (49) hide show
  1. package/CHANGELOG.md +226 -0
  2. package/dist/index.d.ts +433 -174
  3. package/dist/index.js +322 -284
  4. package/dist/index.js.map +1 -1
  5. package/dist/test/index.js +2 -35
  6. package/dist/test/index.js.map +1 -1
  7. package/package.json +8 -10
  8. package/src/convert-image-model-file-to-data-uri.ts +3 -3
  9. package/src/create-tool-name-mapping.ts +5 -21
  10. package/src/get-error-message.ts +1 -15
  11. package/src/has-required-key.ts +6 -0
  12. package/src/index.ts +17 -7
  13. package/src/inject-json-instruction.ts +5 -5
  14. package/src/is-json-serializable.ts +29 -0
  15. package/src/is-provider-reference.ts +18 -0
  16. package/src/load-api-key.ts +1 -1
  17. package/src/load-setting.ts +1 -1
  18. package/src/map-reasoning-to-provider.ts +105 -0
  19. package/src/provider-tool-factory.ts +43 -32
  20. package/src/resolve-provider-reference.ts +27 -0
  21. package/src/resolve.ts +15 -0
  22. package/src/response-handler.ts +1 -1
  23. package/src/secure-json-parse.ts +1 -1
  24. package/src/serialize-model-options.ts +63 -0
  25. package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +1 -1
  26. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +1 -1
  27. package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +2 -2
  28. package/src/types/assistant-model-message.ts +4 -0
  29. package/src/types/content-part.ts +98 -14
  30. package/src/types/context.ts +4 -0
  31. package/src/types/executable-tool.ts +17 -0
  32. package/src/types/execute-tool.ts +28 -9
  33. package/src/types/index.ts +11 -9
  34. package/src/types/infer-tool-context.ts +12 -0
  35. package/src/types/infer-tool-input.ts +7 -0
  36. package/src/types/infer-tool-output.ts +7 -0
  37. package/src/types/infer-tool-set-context.ts +17 -0
  38. package/src/types/provider-options.ts +2 -2
  39. package/src/types/provider-reference.ts +10 -0
  40. package/src/types/tool-set.ts +22 -0
  41. package/src/types/tool.ts +74 -40
  42. package/src/types/union-to-intersection.ts +17 -0
  43. package/src/validate-download-url.ts +7 -2
  44. package/dist/index.d.mts +0 -1433
  45. package/dist/index.mjs +0 -2759
  46. package/dist/index.mjs.map +0 -1
  47. package/dist/test/index.d.mts +0 -17
  48. package/dist/test/index.mjs +0 -77
  49. package/dist/test/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,231 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.0-beta.21
4
+
5
+ ### Patch Changes
6
+
7
+ - add1126: refactoring: executeTool uses tool as parameter
8
+
9
+ ## 5.0.0-beta.20
10
+
11
+ ### Patch Changes
12
+
13
+ - b3976a2: Add workflow serialization support to all provider models.
14
+
15
+ **`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
16
+
17
+ **All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
18
+
19
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
20
+
21
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
22
+ - Updated dependencies [ff5eba1]
23
+ - @ai-sdk/provider@4.0.0-beta.12
24
+
25
+ ## 5.0.0-beta.19
26
+
27
+ ### Major Changes
28
+
29
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [ef992f8]
34
+ - @ai-sdk/provider@4.0.0-beta.11
35
+
36
+ ## 5.0.0-beta.18
37
+
38
+ ### Patch Changes
39
+
40
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
41
+
42
+ ## 5.0.0-beta.17
43
+
44
+ ### Patch Changes
45
+
46
+ - 3ae1786: fix: better context type inference
47
+
48
+ ## 5.0.0-beta.16
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [176466a]
53
+ - @ai-sdk/provider@4.0.0-beta.10
54
+
55
+ ## 5.0.0-beta.15
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [e311194]
60
+ - @ai-sdk/provider@4.0.0-beta.9
61
+
62
+ ## 5.0.0-beta.14
63
+
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [34bd95d]
67
+ - Updated dependencies [008271d]
68
+ - @ai-sdk/provider@4.0.0-beta.8
69
+
70
+ ## 5.0.0-beta.13
71
+
72
+ ### Major Changes
73
+
74
+ - 7e26e81: chore: rename experimental_context to context
75
+
76
+ ### Patch Changes
77
+
78
+ - b0c2869: chore(ai): remove deprecated `media` type part from `ToolResultOutput`
79
+
80
+ ## 5.0.0-beta.12
81
+
82
+ ### Patch Changes
83
+
84
+ - 46d1149: chore(provider-utils,google): fix grammar errors in error and warning messages
85
+
86
+ ## 5.0.0-beta.11
87
+
88
+ ### Patch Changes
89
+
90
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
91
+ - Updated dependencies [6fd51c0]
92
+ - @ai-sdk/provider@4.0.0-beta.7
93
+
94
+ ## 5.0.0-beta.10
95
+
96
+ ### Patch Changes
97
+
98
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
99
+ - Updated dependencies [c29a26f]
100
+ - @ai-sdk/provider@4.0.0-beta.6
101
+
102
+ ## 5.0.0-beta.9
103
+
104
+ ### Patch Changes
105
+
106
+ - 2e17091: fix(types): move shared tool set utility types into provider-utils
107
+
108
+ Moved `ToolSet`, `InferToolSetContext`, and `UnionToIntersection` into `@ai-sdk/provider-utils` and updated `ai` internals to import them directly from there. This keeps the shared tool typing utilities colocated with the core tool type definitions.
109
+
110
+ ## 5.0.0-beta.8
111
+
112
+ ### Major Changes
113
+
114
+ - 986c6fd: feat(ai): change type of experimental_context from unknown to generic
115
+ - 493295c: Remove the deprecated `ToolCallOptions` export.
116
+
117
+ Use `ToolExecutionOptions` instead.
118
+
119
+ ## 5.0.0-beta.7
120
+
121
+ ### Patch Changes
122
+
123
+ - 1f509d4: fix(ai): force template check on 'kind' param
124
+ - Updated dependencies [1f509d4]
125
+ - @ai-sdk/provider@4.0.0-beta.5
126
+
127
+ ## 5.0.0-beta.6
128
+
129
+ ### Patch Changes
130
+
131
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
132
+ - Updated dependencies [3887c70]
133
+ - @ai-sdk/provider@4.0.0-beta.4
134
+
135
+ ## 5.0.0-beta.5
136
+
137
+ ### Major Changes
138
+
139
+ - 776b617: feat(provider): adding new 'custom' content type
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [776b617]
144
+ - @ai-sdk/provider@4.0.0-beta.3
145
+
146
+ ## 5.0.0-beta.4
147
+
148
+ ### Major Changes
149
+
150
+ - 61753c3: ### `@ai-sdk/openai`: remove redundant `name` argument from `openai.tools.customTool()`
151
+
152
+ `openai.tools.customTool()` no longer accepts a `name` field. the tool name is now derived from the sdk tool key (the object key in the `tools` object).
153
+
154
+ migration: remove the `name` property from `customTool()` calls. the object key is now used as the tool name sent to the openai api.
155
+
156
+ before:
157
+
158
+ ```ts
159
+ tools: {
160
+ write_sql: openai.tools.customTool({
161
+ name: 'write_sql',
162
+ description: '...',
163
+ }),
164
+ }
165
+ ```
166
+
167
+ after:
168
+
169
+ ```ts
170
+ tools: {
171
+ write_sql: openai.tools.customTool({
172
+ description: '...',
173
+ }),
174
+ }
175
+ ```
176
+
177
+ ### `@ai-sdk/provider-utils`: `createToolNameMapping()` no longer accepts the `resolveProviderToolName` parameter
178
+
179
+ before: tool name can be set dynamically
180
+
181
+ ```ts
182
+ const toolNameMapping = createToolNameMapping({
183
+ tools,
184
+ providerToolNames: {
185
+ "openai.code_interpreter": "code_interpreter",
186
+ "openai.file_search": "file_search",
187
+ "openai.image_generation": "image_generation",
188
+ "openai.local_shell": "local_shell",
189
+ "openai.shell": "shell",
190
+ "openai.web_search": "web_search",
191
+ "openai.web_search_preview": "web_search_preview",
192
+ "openai.mcp": "mcp",
193
+ "openai.apply_patch": "apply_patch",
194
+ },
195
+ resolveProviderToolName: (tool) =>
196
+ tool.id === "openai.custom"
197
+ ? (tool.args as { name?: string }).name
198
+ : undefined,
199
+ });
200
+ ```
201
+
202
+ after: tool name is static based on `tools` keys
203
+
204
+ ```
205
+ const toolNameMapping = createToolNameMapping({
206
+ tools,
207
+ providerToolNames: {
208
+ 'openai.code_interpreter': 'code_interpreter',
209
+ 'openai.file_search': 'file_search',
210
+ 'openai.image_generation': 'image_generation',
211
+ 'openai.local_shell': 'local_shell',
212
+ 'openai.shell': 'shell',
213
+ 'openai.web_search': 'web_search',
214
+ 'openai.web_search_preview': 'web_search_preview',
215
+ 'openai.mcp': 'mcp',
216
+ 'openai.apply_patch': 'apply_patch',
217
+ }
218
+ });
219
+ ```
220
+
221
+ ## 5.0.0-beta.3
222
+
223
+ ### Patch Changes
224
+
225
+ - f7d4f01: feat(provider): add support for `reasoning-file` type for files that are part of reasoning
226
+ - Updated dependencies [f7d4f01]
227
+ - @ai-sdk/provider@4.0.0-beta.2
228
+
3
229
  ## 5.0.0-beta.2
4
230
 
5
231
  ### Patch Changes