@ai-sdk/provider-utils 5.0.0-beta.8 → 5.0.0-canary.31

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 +181 -0
  2. package/dist/index.d.ts +1299 -862
  3. package/dist/index.js +813 -325
  4. package/dist/index.js.map +1 -1
  5. package/dist/test/index.d.ts +2 -1
  6. package/dist/test/index.js +18 -37
  7. package/dist/test/index.js.map +1 -1
  8. package/package.json +13 -11
  9. package/src/add-additional-properties-to-json-schema.ts +1 -1
  10. package/src/as-array.ts +12 -0
  11. package/src/convert-image-model-file-to-data-uri.ts +1 -1
  12. package/src/convert-inline-file-data-to-uint8-array.ts +30 -0
  13. package/src/create-tool-name-mapping.ts +1 -1
  14. package/src/detect-media-type.ts +312 -0
  15. package/src/filter-nullable.ts +11 -0
  16. package/src/get-error-message.ts +1 -15
  17. package/src/get-from-api.ts +2 -2
  18. package/src/has-required-key.ts +6 -0
  19. package/src/index.ts +39 -14
  20. package/src/inject-json-instruction.ts +1 -1
  21. package/src/is-buffer.ts +9 -0
  22. package/src/is-json-serializable.ts +29 -0
  23. package/src/is-provider-reference.ts +21 -0
  24. package/src/is-url-supported.ts +17 -2
  25. package/src/load-api-key.ts +1 -1
  26. package/src/load-setting.ts +1 -1
  27. package/src/map-reasoning-to-provider.ts +4 -1
  28. package/src/maybe-promise-like.ts +3 -0
  29. package/src/parse-json-event-stream.ts +3 -3
  30. package/src/parse-json.ts +3 -3
  31. package/src/parse-provider-options.ts +1 -1
  32. package/src/post-to-api.ts +4 -4
  33. package/src/{provider-tool-factory.ts → provider-defined-tool-factory.ts} +22 -29
  34. package/src/provider-executed-tool-factory.ts +69 -0
  35. package/src/resolve-full-media-type.ts +49 -0
  36. package/src/resolve-provider-reference.ts +26 -0
  37. package/src/resolve.ts +16 -1
  38. package/src/response-handler.ts +3 -3
  39. package/src/schema.ts +6 -3
  40. package/src/secure-json-parse.ts +1 -1
  41. package/src/serialize-model-options.ts +63 -0
  42. package/src/streaming-tool-call-tracker.ts +241 -0
  43. package/src/test/convert-response-stream-to-array.ts +1 -1
  44. package/src/test/is-node-version.ts +22 -1
  45. package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
  46. package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
  47. package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
  51. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
  52. package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +4 -4
  53. package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
  54. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
  55. package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
  56. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +5 -5
  57. package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
  58. package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -5
  59. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
  60. package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -2
  61. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
  62. package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
  63. package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
  64. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
  65. package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +4 -4
  66. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
  67. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
  68. package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +9 -10
  69. package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
  70. package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
  71. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
  72. package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -2
  73. package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
  74. package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -2
  75. package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
  76. package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
  77. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
  78. package/src/types/assistant-model-message.ts +3 -3
  79. package/src/types/content-part.ts +82 -24
  80. package/src/types/executable-tool.ts +17 -0
  81. package/src/types/execute-tool.ts +23 -23
  82. package/src/types/file-data.ts +48 -0
  83. package/src/types/index.ts +21 -3
  84. package/src/types/infer-tool-context.ts +7 -2
  85. package/src/types/infer-tool-set-context.ts +15 -0
  86. package/src/types/model-message.ts +4 -4
  87. package/src/types/never-optional.ts +7 -0
  88. package/src/types/provider-options.ts +1 -1
  89. package/src/types/provider-reference.ts +10 -0
  90. package/src/types/sensitive-context.ts +9 -0
  91. package/src/types/system-model-message.ts +1 -1
  92. package/src/types/tool-approval-request.ts +7 -0
  93. package/src/types/tool-execute-function.ts +50 -0
  94. package/src/types/tool-model-message.ts +3 -3
  95. package/src/types/tool-needs-approval-function.ts +39 -0
  96. package/src/types/tool-set.ts +22 -0
  97. package/src/types/tool.ts +230 -223
  98. package/src/types/user-model-message.ts +2 -2
  99. package/src/validate-types.ts +5 -3
  100. package/dist/index.d.mts +0 -1547
  101. package/dist/index.mjs +0 -2817
  102. package/dist/index.mjs.map +0 -1
  103. package/dist/test/index.d.mts +0 -17
  104. package/dist/test/index.mjs +0 -77
  105. package/dist/test/index.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,186 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.0-canary.31
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c4c275: trigger initial canary release
8
+ - Updated dependencies [0c4c275]
9
+ - @ai-sdk/provider@4.0.0-canary.15
10
+
11
+ ## 5.0.0-beta.30
12
+
13
+ ### Patch Changes
14
+
15
+ - 08d2129: feat(mcp): propagate the server name through dynamic tool parts
16
+
17
+ ## 5.0.0-beta.29
18
+
19
+ ### Patch Changes
20
+
21
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
22
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
23
+ - b6783da: refactoring: restructure Tool types
24
+ - Updated dependencies [9bd6512]
25
+ - Updated dependencies [258c093]
26
+ - @ai-sdk/provider@4.0.0-beta.14
27
+
28
+ ## 5.0.0-beta.28
29
+
30
+ ### Patch Changes
31
+
32
+ - 9f0e36c: trigger release for all packages after provenance setup
33
+ - Updated dependencies [9f0e36c]
34
+ - @ai-sdk/provider@4.0.0-beta.13
35
+
36
+ ## 5.0.0-beta.27
37
+
38
+ ### Patch Changes
39
+
40
+ - 785fe16: feat: distinguish provider-defined and provider-executed tools
41
+ - 67df0a0: feat: add sensitiveContext property to Tool
42
+ - befb78c: refactoring: remove real-time delays in unit tests
43
+ - 0458559: fix: deprecate needsApproval on Tool
44
+ - 5852c0a: refactoring(provider-utils): add controller as property to StreamingToolCallTracker
45
+ - fc92055: feat(ai): automatic tool approval
46
+
47
+ ## 5.0.0-beta.26
48
+
49
+ ### Patch Changes
50
+
51
+ - 2e98477: fix: retain stack traces on async errors
52
+
53
+ ## 5.0.0-beta.25
54
+
55
+ ### Patch Changes
56
+
57
+ - eea8d98: refactoring: rename tool execution events
58
+
59
+ ## 5.0.0-beta.24
60
+
61
+ ### Patch Changes
62
+
63
+ - f807e45: Extract shared `StreamingToolCallTracker` class into `@ai-sdk/provider-utils` to deduplicate streaming tool call handling across OpenAI-compatible providers. Also adds missing `generateId()` fallback for `toolCallId` in Alibaba's `doGenerate` path and ensures all providers finalize unfinished tool calls during stream flush.
64
+
65
+ ## 5.0.0-beta.23
66
+
67
+ ### Patch Changes
68
+
69
+ - 350ea38: refactoring: introduce Arrayable type
70
+
71
+ ## 5.0.0-beta.22
72
+
73
+ ### Patch Changes
74
+
75
+ - 083947b: feat(ai): separate toolsContext from context
76
+
77
+ ## 5.0.0-beta.21
78
+
79
+ ### Patch Changes
80
+
81
+ - add1126: refactoring: executeTool uses tool as parameter
82
+
83
+ ## 5.0.0-beta.20
84
+
85
+ ### Patch Changes
86
+
87
+ - b3976a2: Add workflow serialization support to all provider models.
88
+
89
+ **`@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.
90
+
91
+ **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.
92
+
93
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
94
+
95
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
96
+ - Updated dependencies [ff5eba1]
97
+ - @ai-sdk/provider@4.0.0-beta.12
98
+
99
+ ## 5.0.0-beta.19
100
+
101
+ ### Major Changes
102
+
103
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [ef992f8]
108
+ - @ai-sdk/provider@4.0.0-beta.11
109
+
110
+ ## 5.0.0-beta.18
111
+
112
+ ### Patch Changes
113
+
114
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
115
+
116
+ ## 5.0.0-beta.17
117
+
118
+ ### Patch Changes
119
+
120
+ - 3ae1786: fix: better context type inference
121
+
122
+ ## 5.0.0-beta.16
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies [176466a]
127
+ - @ai-sdk/provider@4.0.0-beta.10
128
+
129
+ ## 5.0.0-beta.15
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [e311194]
134
+ - @ai-sdk/provider@4.0.0-beta.9
135
+
136
+ ## 5.0.0-beta.14
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [34bd95d]
141
+ - Updated dependencies [008271d]
142
+ - @ai-sdk/provider@4.0.0-beta.8
143
+
144
+ ## 5.0.0-beta.13
145
+
146
+ ### Major Changes
147
+
148
+ - 7e26e81: chore: rename experimental_context to context
149
+
150
+ ### Patch Changes
151
+
152
+ - b0c2869: chore(ai): remove deprecated `media` type part from `ToolResultOutput`
153
+
154
+ ## 5.0.0-beta.12
155
+
156
+ ### Patch Changes
157
+
158
+ - 46d1149: chore(provider-utils,google): fix grammar errors in error and warning messages
159
+
160
+ ## 5.0.0-beta.11
161
+
162
+ ### Patch Changes
163
+
164
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
165
+ - Updated dependencies [6fd51c0]
166
+ - @ai-sdk/provider@4.0.0-beta.7
167
+
168
+ ## 5.0.0-beta.10
169
+
170
+ ### Patch Changes
171
+
172
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
173
+ - Updated dependencies [c29a26f]
174
+ - @ai-sdk/provider@4.0.0-beta.6
175
+
176
+ ## 5.0.0-beta.9
177
+
178
+ ### Patch Changes
179
+
180
+ - 2e17091: fix(types): move shared tool set utility types into provider-utils
181
+
182
+ 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.
183
+
3
184
  ## 5.0.0-beta.8
4
185
 
5
186
  ### Major Changes