@ai-sdk/provider-utils 5.0.0-beta.9 → 5.0.0-canary.32

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 +184 -0
  2. package/dist/index.d.ts +1346 -878
  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 +138 -19
  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 +19 -3
  84. package/src/types/infer-tool-context.ts +7 -2
  85. package/src/types/infer-tool-set-context.ts +7 -9
  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.ts +236 -223
  97. package/src/types/user-model-message.ts +2 -2
  98. package/src/validate-types.ts +5 -3
  99. package/dist/index.d.mts +0 -1578
  100. package/dist/index.mjs +0 -2817
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/test/index.d.mts +0 -17
  103. package/dist/test/index.mjs +0 -77
  104. package/dist/test/index.mjs.map +0 -1
  105. package/src/types/union-to-intersection.ts +0 -17
package/CHANGELOG.md CHANGED
@@ -1,5 +1,189 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 5.0.0-canary.32
4
+
5
+ ### Major Changes
6
+
7
+ - 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5463d0d]
12
+ - @ai-sdk/provider@4.0.0-canary.16
13
+
14
+ ## 5.0.0-canary.31
15
+
16
+ ### Patch Changes
17
+
18
+ - 0c4c275: trigger initial canary release
19
+ - Updated dependencies [0c4c275]
20
+ - @ai-sdk/provider@4.0.0-canary.15
21
+
22
+ ## 5.0.0-beta.30
23
+
24
+ ### Patch Changes
25
+
26
+ - 08d2129: feat(mcp): propagate the server name through dynamic tool parts
27
+
28
+ ## 5.0.0-beta.29
29
+
30
+ ### Patch Changes
31
+
32
+ - 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
33
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
34
+ - b6783da: refactoring: restructure Tool types
35
+ - Updated dependencies [9bd6512]
36
+ - Updated dependencies [258c093]
37
+ - @ai-sdk/provider@4.0.0-beta.14
38
+
39
+ ## 5.0.0-beta.28
40
+
41
+ ### Patch Changes
42
+
43
+ - 9f0e36c: trigger release for all packages after provenance setup
44
+ - Updated dependencies [9f0e36c]
45
+ - @ai-sdk/provider@4.0.0-beta.13
46
+
47
+ ## 5.0.0-beta.27
48
+
49
+ ### Patch Changes
50
+
51
+ - 785fe16: feat: distinguish provider-defined and provider-executed tools
52
+ - 67df0a0: feat: add sensitiveContext property to Tool
53
+ - befb78c: refactoring: remove real-time delays in unit tests
54
+ - 0458559: fix: deprecate needsApproval on Tool
55
+ - 5852c0a: refactoring(provider-utils): add controller as property to StreamingToolCallTracker
56
+ - fc92055: feat(ai): automatic tool approval
57
+
58
+ ## 5.0.0-beta.26
59
+
60
+ ### Patch Changes
61
+
62
+ - 2e98477: fix: retain stack traces on async errors
63
+
64
+ ## 5.0.0-beta.25
65
+
66
+ ### Patch Changes
67
+
68
+ - eea8d98: refactoring: rename tool execution events
69
+
70
+ ## 5.0.0-beta.24
71
+
72
+ ### Patch Changes
73
+
74
+ - 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.
75
+
76
+ ## 5.0.0-beta.23
77
+
78
+ ### Patch Changes
79
+
80
+ - 350ea38: refactoring: introduce Arrayable type
81
+
82
+ ## 5.0.0-beta.22
83
+
84
+ ### Patch Changes
85
+
86
+ - 083947b: feat(ai): separate toolsContext from context
87
+
88
+ ## 5.0.0-beta.21
89
+
90
+ ### Patch Changes
91
+
92
+ - add1126: refactoring: executeTool uses tool as parameter
93
+
94
+ ## 5.0.0-beta.20
95
+
96
+ ### Patch Changes
97
+
98
+ - b3976a2: Add workflow serialization support to all provider models.
99
+
100
+ **`@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.
101
+
102
+ **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.
103
+
104
+ All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
105
+
106
+ - ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
107
+ - Updated dependencies [ff5eba1]
108
+ - @ai-sdk/provider@4.0.0-beta.12
109
+
110
+ ## 5.0.0-beta.19
111
+
112
+ ### Major Changes
113
+
114
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [ef992f8]
119
+ - @ai-sdk/provider@4.0.0-beta.11
120
+
121
+ ## 5.0.0-beta.18
122
+
123
+ ### Patch Changes
124
+
125
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
126
+
127
+ ## 5.0.0-beta.17
128
+
129
+ ### Patch Changes
130
+
131
+ - 3ae1786: fix: better context type inference
132
+
133
+ ## 5.0.0-beta.16
134
+
135
+ ### Patch Changes
136
+
137
+ - Updated dependencies [176466a]
138
+ - @ai-sdk/provider@4.0.0-beta.10
139
+
140
+ ## 5.0.0-beta.15
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [e311194]
145
+ - @ai-sdk/provider@4.0.0-beta.9
146
+
147
+ ## 5.0.0-beta.14
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies [34bd95d]
152
+ - Updated dependencies [008271d]
153
+ - @ai-sdk/provider@4.0.0-beta.8
154
+
155
+ ## 5.0.0-beta.13
156
+
157
+ ### Major Changes
158
+
159
+ - 7e26e81: chore: rename experimental_context to context
160
+
161
+ ### Patch Changes
162
+
163
+ - b0c2869: chore(ai): remove deprecated `media` type part from `ToolResultOutput`
164
+
165
+ ## 5.0.0-beta.12
166
+
167
+ ### Patch Changes
168
+
169
+ - 46d1149: chore(provider-utils,google): fix grammar errors in error and warning messages
170
+
171
+ ## 5.0.0-beta.11
172
+
173
+ ### Patch Changes
174
+
175
+ - 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
176
+ - Updated dependencies [6fd51c0]
177
+ - @ai-sdk/provider@4.0.0-beta.7
178
+
179
+ ## 5.0.0-beta.10
180
+
181
+ ### Patch Changes
182
+
183
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
184
+ - Updated dependencies [c29a26f]
185
+ - @ai-sdk/provider@4.0.0-beta.6
186
+
3
187
  ## 5.0.0-beta.9
4
188
 
5
189
  ### Patch Changes