@ai-sdk/provider-utils 5.0.0-beta.3 → 5.0.0-beta.30
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.
- package/CHANGELOG.md +284 -0
- package/dist/index.d.ts +1339 -813
- package/dist/index.js +837 -288
- package/dist/index.js.map +1 -1
- package/dist/test/index.d.ts +2 -1
- package/dist/test/index.js +18 -37
- package/dist/test/index.js.map +1 -1
- package/package.json +13 -13
- package/src/add-additional-properties-to-json-schema.ts +1 -1
- package/src/as-array.ts +12 -0
- package/src/convert-image-model-file-to-data-uri.ts +3 -3
- package/src/convert-inline-file-data-to-uint8-array.ts +30 -0
- package/src/create-tool-name-mapping.ts +6 -22
- package/src/detect-media-type.ts +312 -0
- package/src/filter-nullable.ts +11 -0
- package/src/get-error-message.ts +1 -15
- package/src/get-from-api.ts +2 -2
- package/src/has-required-key.ts +6 -0
- package/src/index.ts +42 -12
- package/src/inject-json-instruction.ts +6 -6
- package/src/is-buffer.ts +9 -0
- package/src/is-json-serializable.ts +29 -0
- package/src/is-provider-reference.ts +21 -0
- package/src/is-url-supported.ts +17 -2
- package/src/load-api-key.ts +1 -1
- package/src/load-setting.ts +1 -1
- package/src/map-reasoning-to-provider.ts +108 -0
- package/src/maybe-promise-like.ts +3 -0
- package/src/parse-json-event-stream.ts +3 -3
- package/src/parse-json.ts +3 -3
- package/src/parse-provider-options.ts +1 -1
- package/src/post-to-api.ts +4 -4
- package/src/provider-defined-tool-factory.ts +129 -0
- package/src/provider-executed-tool-factory.ts +69 -0
- package/src/resolve-full-media-type.ts +49 -0
- package/src/resolve-provider-reference.ts +26 -0
- package/src/resolve.ts +16 -1
- package/src/response-handler.ts +3 -3
- package/src/schema.ts +6 -3
- package/src/secure-json-parse.ts +1 -1
- package/src/serialize-model-options.ts +63 -0
- package/src/streaming-tool-call-tracker.ts +241 -0
- package/src/test/convert-response-stream-to-array.ts +1 -1
- package/src/test/is-node-version.ts +22 -1
- package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
- package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +4 -4
- package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +5 -5
- package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -5
- package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
- package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +4 -4
- package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +9 -10
- package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
- package/src/types/assistant-model-message.ts +5 -3
- package/src/types/content-part.ts +102 -24
- package/src/types/context.ts +4 -0
- package/src/types/executable-tool.ts +17 -0
- package/src/types/execute-tool.ts +29 -9
- package/src/types/file-data.ts +48 -0
- package/src/types/index.ts +26 -11
- package/src/types/infer-tool-context.ts +12 -0
- package/src/types/infer-tool-input.ts +7 -0
- package/src/types/infer-tool-output.ts +7 -0
- package/src/types/infer-tool-set-context.ts +15 -0
- package/src/types/model-message.ts +4 -4
- package/src/types/never-optional.ts +7 -0
- package/src/types/provider-options.ts +2 -2
- package/src/types/provider-reference.ts +10 -0
- package/src/types/sensitive-context.ts +9 -0
- package/src/types/system-model-message.ts +1 -1
- package/src/types/tool-approval-request.ts +7 -0
- package/src/types/tool-execute-function.ts +50 -0
- package/src/types/tool-model-message.ts +3 -3
- package/src/types/tool-needs-approval-function.ts +39 -0
- package/src/types/tool-set.ts +22 -0
- package/src/types/tool.ts +251 -222
- package/src/types/user-model-message.ts +2 -2
- package/src/validate-download-url.ts +7 -2
- package/src/validate-types.ts +5 -3
- package/dist/index.d.mts +0 -1458
- package/dist/index.mjs +0 -2759
- package/dist/index.mjs.map +0 -1
- package/dist/test/index.d.mts +0 -17
- package/dist/test/index.mjs +0 -77
- package/dist/test/index.mjs.map +0 -1
- package/src/provider-tool-factory.ts +0 -125
package/dist/index.js
CHANGED
|
@@ -1,98 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name2 in all)
|
|
10
|
-
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var index_exports = {};
|
|
32
|
-
__export(index_exports, {
|
|
33
|
-
DEFAULT_MAX_DOWNLOAD_SIZE: () => DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
34
|
-
DelayedPromise: () => DelayedPromise,
|
|
35
|
-
DownloadError: () => DownloadError,
|
|
36
|
-
EventSourceParserStream: () => import_stream2.EventSourceParserStream,
|
|
37
|
-
VERSION: () => VERSION,
|
|
38
|
-
asSchema: () => asSchema,
|
|
39
|
-
combineHeaders: () => combineHeaders,
|
|
40
|
-
convertAsyncIteratorToReadableStream: () => convertAsyncIteratorToReadableStream,
|
|
41
|
-
convertBase64ToUint8Array: () => convertBase64ToUint8Array,
|
|
42
|
-
convertImageModelFileToDataUri: () => convertImageModelFileToDataUri,
|
|
43
|
-
convertToBase64: () => convertToBase64,
|
|
44
|
-
convertToFormData: () => convertToFormData,
|
|
45
|
-
convertUint8ArrayToBase64: () => convertUint8ArrayToBase64,
|
|
46
|
-
createBinaryResponseHandler: () => createBinaryResponseHandler,
|
|
47
|
-
createEventSourceResponseHandler: () => createEventSourceResponseHandler,
|
|
48
|
-
createIdGenerator: () => createIdGenerator,
|
|
49
|
-
createJsonErrorResponseHandler: () => createJsonErrorResponseHandler,
|
|
50
|
-
createJsonResponseHandler: () => createJsonResponseHandler,
|
|
51
|
-
createProviderToolFactory: () => createProviderToolFactory,
|
|
52
|
-
createProviderToolFactoryWithOutputSchema: () => createProviderToolFactoryWithOutputSchema,
|
|
53
|
-
createStatusCodeErrorResponseHandler: () => createStatusCodeErrorResponseHandler,
|
|
54
|
-
createToolNameMapping: () => createToolNameMapping,
|
|
55
|
-
delay: () => delay,
|
|
56
|
-
downloadBlob: () => downloadBlob,
|
|
57
|
-
dynamicTool: () => dynamicTool,
|
|
58
|
-
executeTool: () => executeTool,
|
|
59
|
-
extractResponseHeaders: () => extractResponseHeaders,
|
|
60
|
-
generateId: () => generateId,
|
|
61
|
-
getErrorMessage: () => getErrorMessage,
|
|
62
|
-
getFromApi: () => getFromApi,
|
|
63
|
-
getRuntimeEnvironmentUserAgent: () => getRuntimeEnvironmentUserAgent,
|
|
64
|
-
injectJsonInstructionIntoMessages: () => injectJsonInstructionIntoMessages,
|
|
65
|
-
isAbortError: () => isAbortError,
|
|
66
|
-
isNonNullable: () => isNonNullable,
|
|
67
|
-
isParsableJson: () => isParsableJson,
|
|
68
|
-
isUrlSupported: () => isUrlSupported,
|
|
69
|
-
jsonSchema: () => jsonSchema,
|
|
70
|
-
lazySchema: () => lazySchema,
|
|
71
|
-
loadApiKey: () => loadApiKey,
|
|
72
|
-
loadOptionalSetting: () => loadOptionalSetting,
|
|
73
|
-
loadSetting: () => loadSetting,
|
|
74
|
-
mediaTypeToExtension: () => mediaTypeToExtension,
|
|
75
|
-
normalizeHeaders: () => normalizeHeaders,
|
|
76
|
-
parseJSON: () => parseJSON,
|
|
77
|
-
parseJsonEventStream: () => parseJsonEventStream,
|
|
78
|
-
parseProviderOptions: () => parseProviderOptions,
|
|
79
|
-
postFormDataToApi: () => postFormDataToApi,
|
|
80
|
-
postJsonToApi: () => postJsonToApi,
|
|
81
|
-
postToApi: () => postToApi,
|
|
82
|
-
readResponseWithSizeLimit: () => readResponseWithSizeLimit,
|
|
83
|
-
removeUndefinedEntries: () => removeUndefinedEntries,
|
|
84
|
-
resolve: () => resolve,
|
|
85
|
-
safeParseJSON: () => safeParseJSON,
|
|
86
|
-
safeValidateTypes: () => safeValidateTypes,
|
|
87
|
-
stripFileExtension: () => stripFileExtension,
|
|
88
|
-
tool: () => tool,
|
|
89
|
-
validateDownloadUrl: () => validateDownloadUrl,
|
|
90
|
-
validateTypes: () => validateTypes,
|
|
91
|
-
withUserAgentSuffix: () => withUserAgentSuffix,
|
|
92
|
-
withoutTrailingSlash: () => withoutTrailingSlash,
|
|
93
|
-
zodSchema: () => zodSchema
|
|
94
|
-
});
|
|
95
|
-
module.exports = __toCommonJS(index_exports);
|
|
1
|
+
// src/as-array.ts
|
|
2
|
+
function asArray(value) {
|
|
3
|
+
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
4
|
+
}
|
|
96
5
|
|
|
97
6
|
// src/combine-headers.ts
|
|
98
7
|
function combineHeaders(...headers) {
|
|
@@ -143,33 +52,90 @@ function convertAsyncIteratorToReadableStream(iterator) {
|
|
|
143
52
|
});
|
|
144
53
|
}
|
|
145
54
|
|
|
55
|
+
// src/uint8-utils.ts
|
|
56
|
+
var { btoa, atob } = globalThis;
|
|
57
|
+
function convertBase64ToUint8Array(base64String) {
|
|
58
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
59
|
+
const latin1string = atob(base64Url);
|
|
60
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
61
|
+
}
|
|
62
|
+
function convertUint8ArrayToBase64(array) {
|
|
63
|
+
let latin1string = "";
|
|
64
|
+
for (let i = 0; i < array.length; i++) {
|
|
65
|
+
latin1string += String.fromCodePoint(array[i]);
|
|
66
|
+
}
|
|
67
|
+
return btoa(latin1string);
|
|
68
|
+
}
|
|
69
|
+
function convertToBase64(value) {
|
|
70
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/convert-inline-file-data-to-uint8-array.ts
|
|
74
|
+
function convertInlineFileDataToUint8Array(data) {
|
|
75
|
+
if (data.type === "text") {
|
|
76
|
+
return new TextEncoder().encode(data.text);
|
|
77
|
+
}
|
|
78
|
+
if (data.data instanceof Uint8Array) {
|
|
79
|
+
return data.data;
|
|
80
|
+
}
|
|
81
|
+
if (data.data instanceof ArrayBuffer) {
|
|
82
|
+
return new Uint8Array(data.data);
|
|
83
|
+
}
|
|
84
|
+
return convertBase64ToUint8Array(data.data);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/convert-image-model-file-to-data-uri.ts
|
|
88
|
+
function convertImageModelFileToDataUri(file) {
|
|
89
|
+
if (file.type === "url") return file.url;
|
|
90
|
+
return `data:${file.mediaType};base64,${typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data)}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/convert-to-form-data.ts
|
|
94
|
+
function convertToFormData(input, options = {}) {
|
|
95
|
+
const { useArrayBrackets = true } = options;
|
|
96
|
+
const formData = new FormData();
|
|
97
|
+
for (const [key, value] of Object.entries(input)) {
|
|
98
|
+
if (value == null) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
if (value.length === 1) {
|
|
103
|
+
formData.append(key, value[0]);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
107
|
+
for (const item of value) {
|
|
108
|
+
formData.append(arrayKey, item);
|
|
109
|
+
}
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
formData.append(key, value);
|
|
113
|
+
}
|
|
114
|
+
return formData;
|
|
115
|
+
}
|
|
116
|
+
|
|
146
117
|
// src/create-tool-name-mapping.ts
|
|
147
118
|
function createToolNameMapping({
|
|
148
119
|
tools = [],
|
|
149
|
-
providerToolNames
|
|
150
|
-
resolveProviderToolName
|
|
120
|
+
providerToolNames
|
|
151
121
|
}) {
|
|
152
|
-
var _a2;
|
|
153
122
|
const customToolNameToProviderToolName = {};
|
|
154
123
|
const providerToolNameToCustomToolName = {};
|
|
155
124
|
for (const tool2 of tools) {
|
|
156
|
-
if (tool2.type === "provider") {
|
|
157
|
-
const providerToolName =
|
|
158
|
-
if (providerToolName == null) {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
125
|
+
if (tool2.type === "provider" && tool2.id in providerToolNames) {
|
|
126
|
+
const providerToolName = providerToolNames[tool2.id];
|
|
161
127
|
customToolNameToProviderToolName[tool2.name] = providerToolName;
|
|
162
128
|
providerToolNameToCustomToolName[providerToolName] = tool2.name;
|
|
163
129
|
}
|
|
164
130
|
}
|
|
165
131
|
return {
|
|
166
132
|
toProviderToolName: (customToolName) => {
|
|
167
|
-
var
|
|
168
|
-
return (
|
|
133
|
+
var _a2;
|
|
134
|
+
return (_a2 = customToolNameToProviderToolName[customToolName]) != null ? _a2 : customToolName;
|
|
169
135
|
},
|
|
170
136
|
toCustomToolName: (providerToolName) => {
|
|
171
|
-
var
|
|
172
|
-
return (
|
|
137
|
+
var _a2;
|
|
138
|
+
return (_a2 = providerToolNameToCustomToolName[providerToolName]) != null ? _a2 : providerToolName;
|
|
173
139
|
}
|
|
174
140
|
};
|
|
175
141
|
}
|
|
@@ -251,66 +217,285 @@ var DelayedPromise = class {
|
|
|
251
217
|
}
|
|
252
218
|
};
|
|
253
219
|
|
|
254
|
-
// src/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
//
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
220
|
+
// src/detect-media-type.ts
|
|
221
|
+
var imageMediaTypeSignatures = [
|
|
222
|
+
{
|
|
223
|
+
mediaType: "image/gif",
|
|
224
|
+
bytesPrefix: [71, 73, 70]
|
|
225
|
+
// GIF
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
mediaType: "image/png",
|
|
229
|
+
bytesPrefix: [137, 80, 78, 71]
|
|
230
|
+
// PNG
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
mediaType: "image/jpeg",
|
|
234
|
+
bytesPrefix: [255, 216]
|
|
235
|
+
// JPEG
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
mediaType: "image/webp",
|
|
239
|
+
bytesPrefix: [
|
|
240
|
+
82,
|
|
241
|
+
73,
|
|
242
|
+
70,
|
|
243
|
+
70,
|
|
244
|
+
// "RIFF"
|
|
245
|
+
null,
|
|
246
|
+
null,
|
|
247
|
+
null,
|
|
248
|
+
null,
|
|
249
|
+
// file size (variable)
|
|
250
|
+
87,
|
|
251
|
+
69,
|
|
252
|
+
66,
|
|
253
|
+
80
|
|
254
|
+
// "WEBP"
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
mediaType: "image/bmp",
|
|
259
|
+
bytesPrefix: [66, 77]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
mediaType: "image/tiff",
|
|
263
|
+
bytesPrefix: [73, 73, 42, 0]
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
mediaType: "image/tiff",
|
|
267
|
+
bytesPrefix: [77, 77, 0, 42]
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
mediaType: "image/avif",
|
|
271
|
+
bytesPrefix: [
|
|
272
|
+
0,
|
|
273
|
+
0,
|
|
274
|
+
0,
|
|
275
|
+
32,
|
|
276
|
+
102,
|
|
277
|
+
116,
|
|
278
|
+
121,
|
|
279
|
+
112,
|
|
280
|
+
97,
|
|
281
|
+
118,
|
|
282
|
+
105,
|
|
283
|
+
102
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
mediaType: "image/heic",
|
|
288
|
+
bytesPrefix: [
|
|
289
|
+
0,
|
|
290
|
+
0,
|
|
291
|
+
0,
|
|
292
|
+
32,
|
|
293
|
+
102,
|
|
294
|
+
116,
|
|
295
|
+
121,
|
|
296
|
+
112,
|
|
297
|
+
104,
|
|
298
|
+
101,
|
|
299
|
+
105,
|
|
300
|
+
99
|
|
301
|
+
]
|
|
270
302
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
303
|
+
];
|
|
304
|
+
var documentMediaTypeSignatures = [
|
|
305
|
+
{
|
|
306
|
+
mediaType: "application/pdf",
|
|
307
|
+
bytesPrefix: [37, 80, 68, 70]
|
|
308
|
+
// %PDF
|
|
309
|
+
}
|
|
310
|
+
];
|
|
311
|
+
var audioMediaTypeSignatures = [
|
|
312
|
+
{
|
|
313
|
+
mediaType: "audio/mpeg",
|
|
314
|
+
bytesPrefix: [255, 251]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
mediaType: "audio/mpeg",
|
|
318
|
+
bytesPrefix: [255, 250]
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
mediaType: "audio/mpeg",
|
|
322
|
+
bytesPrefix: [255, 243]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
mediaType: "audio/mpeg",
|
|
326
|
+
bytesPrefix: [255, 242]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
mediaType: "audio/mpeg",
|
|
330
|
+
bytesPrefix: [255, 227]
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
mediaType: "audio/mpeg",
|
|
334
|
+
bytesPrefix: [255, 226]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
mediaType: "audio/wav",
|
|
338
|
+
bytesPrefix: [
|
|
339
|
+
82,
|
|
340
|
+
// R
|
|
341
|
+
73,
|
|
342
|
+
// I
|
|
343
|
+
70,
|
|
344
|
+
// F
|
|
345
|
+
70,
|
|
346
|
+
// F
|
|
347
|
+
null,
|
|
348
|
+
null,
|
|
349
|
+
null,
|
|
350
|
+
null,
|
|
351
|
+
87,
|
|
352
|
+
// W
|
|
353
|
+
65,
|
|
354
|
+
// A
|
|
355
|
+
86,
|
|
356
|
+
// V
|
|
357
|
+
69
|
|
358
|
+
// E
|
|
359
|
+
]
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
mediaType: "audio/ogg",
|
|
363
|
+
bytesPrefix: [79, 103, 103, 83]
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
mediaType: "audio/flac",
|
|
367
|
+
bytesPrefix: [102, 76, 97, 67]
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
mediaType: "audio/aac",
|
|
371
|
+
bytesPrefix: [64, 21, 0, 0]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
mediaType: "audio/mp4",
|
|
375
|
+
bytesPrefix: [102, 116, 121, 112]
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
mediaType: "audio/webm",
|
|
379
|
+
bytesPrefix: [26, 69, 223, 163]
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
var videoMediaTypeSignatures = [
|
|
383
|
+
{
|
|
384
|
+
mediaType: "video/mp4",
|
|
385
|
+
bytesPrefix: [
|
|
386
|
+
0,
|
|
387
|
+
0,
|
|
388
|
+
0,
|
|
389
|
+
null,
|
|
390
|
+
102,
|
|
391
|
+
116,
|
|
392
|
+
121,
|
|
393
|
+
112
|
|
394
|
+
// ftyp
|
|
395
|
+
]
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
mediaType: "video/webm",
|
|
399
|
+
bytesPrefix: [26, 69, 223, 163]
|
|
400
|
+
// EBML
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
mediaType: "video/quicktime",
|
|
404
|
+
bytesPrefix: [
|
|
405
|
+
0,
|
|
406
|
+
0,
|
|
407
|
+
0,
|
|
408
|
+
20,
|
|
409
|
+
102,
|
|
410
|
+
116,
|
|
411
|
+
121,
|
|
412
|
+
112,
|
|
413
|
+
113,
|
|
414
|
+
116
|
|
415
|
+
// ftypqt
|
|
416
|
+
]
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
mediaType: "video/x-msvideo",
|
|
420
|
+
bytesPrefix: [82, 73, 70, 70]
|
|
421
|
+
// RIFF (AVI)
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
var stripID3 = (data) => {
|
|
425
|
+
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
426
|
+
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
427
|
+
return bytes.slice(id3Size + 10);
|
|
428
|
+
};
|
|
429
|
+
function stripID3TagsIfPresent(data) {
|
|
430
|
+
const hasId3 = typeof data === "string" && data.startsWith("SUQz") || typeof data !== "string" && data.length > 10 && data[0] === 73 && // 'I'
|
|
431
|
+
data[1] === 68 && // 'D'
|
|
432
|
+
data[2] === 51;
|
|
433
|
+
return hasId3 ? stripID3(data) : data;
|
|
434
|
+
}
|
|
435
|
+
function detectMediaTypeBySignatures({
|
|
436
|
+
data,
|
|
437
|
+
signatures
|
|
438
|
+
}) {
|
|
439
|
+
const processedData = stripID3TagsIfPresent(data);
|
|
440
|
+
const bytes = typeof processedData === "string" ? convertBase64ToUint8Array(
|
|
441
|
+
processedData.substring(0, Math.min(processedData.length, 24))
|
|
442
|
+
) : processedData;
|
|
443
|
+
for (const signature of signatures) {
|
|
444
|
+
if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
|
|
445
|
+
(byte, index) => byte === null || bytes[index] === byte
|
|
446
|
+
)) {
|
|
447
|
+
return signature.mediaType;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return void 0;
|
|
451
|
+
}
|
|
452
|
+
var topLevelSignatureTables = {
|
|
453
|
+
image: imageMediaTypeSignatures,
|
|
454
|
+
audio: audioMediaTypeSignatures,
|
|
455
|
+
video: videoMediaTypeSignatures,
|
|
456
|
+
application: documentMediaTypeSignatures
|
|
457
|
+
};
|
|
458
|
+
function detectMediaType({
|
|
459
|
+
data,
|
|
460
|
+
topLevelType
|
|
461
|
+
}) {
|
|
462
|
+
if (topLevelType === void 0) {
|
|
463
|
+
return detectMediaTypeBySignatures({
|
|
464
|
+
data,
|
|
465
|
+
signatures: [
|
|
466
|
+
...imageMediaTypeSignatures,
|
|
467
|
+
...documentMediaTypeSignatures,
|
|
468
|
+
...audioMediaTypeSignatures,
|
|
469
|
+
...videoMediaTypeSignatures
|
|
470
|
+
]
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
const signatures = topLevelSignatureTables[topLevelType];
|
|
474
|
+
if (signatures === void 0) {
|
|
475
|
+
return void 0;
|
|
476
|
+
}
|
|
477
|
+
return detectMediaTypeBySignatures({ data, signatures });
|
|
275
478
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (file.type === "url") return file.url;
|
|
280
|
-
return `data:${file.mediaType};base64,${typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data)}`;
|
|
479
|
+
function getTopLevelMediaType(mediaType) {
|
|
480
|
+
const slashIndex = mediaType.indexOf("/");
|
|
481
|
+
return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
|
|
281
482
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const formData = new FormData();
|
|
287
|
-
for (const [key, value] of Object.entries(input)) {
|
|
288
|
-
if (value == null) {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
if (Array.isArray(value)) {
|
|
292
|
-
if (value.length === 1) {
|
|
293
|
-
formData.append(key, value[0]);
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
297
|
-
for (const item of value) {
|
|
298
|
-
formData.append(arrayKey, item);
|
|
299
|
-
}
|
|
300
|
-
continue;
|
|
301
|
-
}
|
|
302
|
-
formData.append(key, value);
|
|
483
|
+
function isFullMediaType(mediaType) {
|
|
484
|
+
const slashIndex = mediaType.indexOf("/");
|
|
485
|
+
if (slashIndex === -1) {
|
|
486
|
+
return false;
|
|
303
487
|
}
|
|
304
|
-
|
|
488
|
+
const subtype = mediaType.substring(slashIndex + 1);
|
|
489
|
+
return subtype.length > 0 && subtype !== "*";
|
|
305
490
|
}
|
|
306
491
|
|
|
307
492
|
// src/download-error.ts
|
|
308
|
-
|
|
493
|
+
import { AISDKError } from "@ai-sdk/provider";
|
|
309
494
|
var name = "AI_DownloadError";
|
|
310
495
|
var marker = `vercel.ai.error.${name}`;
|
|
311
496
|
var symbol = Symbol.for(marker);
|
|
312
497
|
var _a, _b;
|
|
313
|
-
var DownloadError = class extends (_b =
|
|
498
|
+
var DownloadError = class extends (_b = AISDKError, _a = symbol, _b) {
|
|
314
499
|
constructor({
|
|
315
500
|
url,
|
|
316
501
|
statusCode,
|
|
@@ -325,7 +510,7 @@ var DownloadError = class extends (_b = import_provider.AISDKError, _a = symbol,
|
|
|
325
510
|
this.statusText = statusText;
|
|
326
511
|
}
|
|
327
512
|
static isInstance(error) {
|
|
328
|
-
return
|
|
513
|
+
return AISDKError.hasMarker(error, marker);
|
|
329
514
|
}
|
|
330
515
|
};
|
|
331
516
|
|
|
@@ -395,10 +580,13 @@ function validateDownloadUrl(url) {
|
|
|
395
580
|
message: `Invalid URL: ${url}`
|
|
396
581
|
});
|
|
397
582
|
}
|
|
583
|
+
if (parsed.protocol === "data:") {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
398
586
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
399
587
|
throw new DownloadError({
|
|
400
588
|
url,
|
|
401
|
-
message: `URL scheme must be http or
|
|
589
|
+
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
402
590
|
});
|
|
403
591
|
}
|
|
404
592
|
const hostname = parsed.hostname;
|
|
@@ -513,8 +701,18 @@ async function downloadBlob(url, options) {
|
|
|
513
701
|
}
|
|
514
702
|
}
|
|
515
703
|
|
|
704
|
+
// src/extract-response-headers.ts
|
|
705
|
+
function extractResponseHeaders(response) {
|
|
706
|
+
return Object.fromEntries([...response.headers]);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/filter-nullable.ts
|
|
710
|
+
function filterNullable(...values) {
|
|
711
|
+
return values.filter((value) => value != null);
|
|
712
|
+
}
|
|
713
|
+
|
|
516
714
|
// src/generate-id.ts
|
|
517
|
-
|
|
715
|
+
import { InvalidArgumentError } from "@ai-sdk/provider";
|
|
518
716
|
var createIdGenerator = ({
|
|
519
717
|
prefix,
|
|
520
718
|
size = 16,
|
|
@@ -533,7 +731,7 @@ var createIdGenerator = ({
|
|
|
533
731
|
return generator;
|
|
534
732
|
}
|
|
535
733
|
if (alphabet.includes(separator)) {
|
|
536
|
-
throw new
|
|
734
|
+
throw new InvalidArgumentError({
|
|
537
735
|
argument: "separator",
|
|
538
736
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
539
737
|
});
|
|
@@ -543,24 +741,13 @@ var createIdGenerator = ({
|
|
|
543
741
|
var generateId = createIdGenerator();
|
|
544
742
|
|
|
545
743
|
// src/get-error-message.ts
|
|
546
|
-
|
|
547
|
-
if (error == null) {
|
|
548
|
-
return "unknown error";
|
|
549
|
-
}
|
|
550
|
-
if (typeof error === "string") {
|
|
551
|
-
return error;
|
|
552
|
-
}
|
|
553
|
-
if (error instanceof Error) {
|
|
554
|
-
return error.message;
|
|
555
|
-
}
|
|
556
|
-
return JSON.stringify(error);
|
|
557
|
-
}
|
|
744
|
+
import { getErrorMessage } from "@ai-sdk/provider";
|
|
558
745
|
|
|
559
746
|
// src/get-from-api.ts
|
|
560
|
-
|
|
747
|
+
import { APICallError as APICallError2 } from "@ai-sdk/provider";
|
|
561
748
|
|
|
562
749
|
// src/handle-fetch-error.ts
|
|
563
|
-
|
|
750
|
+
import { APICallError } from "@ai-sdk/provider";
|
|
564
751
|
|
|
565
752
|
// src/is-abort-error.ts
|
|
566
753
|
function isAbortError(error) {
|
|
@@ -600,7 +787,7 @@ function handleFetchError({
|
|
|
600
787
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
601
788
|
const cause = error.cause;
|
|
602
789
|
if (cause != null) {
|
|
603
|
-
return new
|
|
790
|
+
return new APICallError({
|
|
604
791
|
message: `Cannot connect to API: ${cause.message}`,
|
|
605
792
|
cause,
|
|
606
793
|
url,
|
|
@@ -611,7 +798,7 @@ function handleFetchError({
|
|
|
611
798
|
}
|
|
612
799
|
}
|
|
613
800
|
if (isBunNetworkError(error)) {
|
|
614
|
-
return new
|
|
801
|
+
return new APICallError({
|
|
615
802
|
message: `Cannot connect to API: ${error.message}`,
|
|
616
803
|
cause: error,
|
|
617
804
|
url,
|
|
@@ -675,7 +862,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
675
862
|
}
|
|
676
863
|
|
|
677
864
|
// src/version.ts
|
|
678
|
-
var VERSION = true ? "5.0.0-beta.
|
|
865
|
+
var VERSION = true ? "5.0.0-beta.30" : "0.0.0-test";
|
|
679
866
|
|
|
680
867
|
// src/get-from-api.ts
|
|
681
868
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -707,10 +894,10 @@ var getFromApi = async ({
|
|
|
707
894
|
requestBodyValues: {}
|
|
708
895
|
});
|
|
709
896
|
} catch (error) {
|
|
710
|
-
if (isAbortError(error) ||
|
|
897
|
+
if (isAbortError(error) || APICallError2.isInstance(error)) {
|
|
711
898
|
throw error;
|
|
712
899
|
}
|
|
713
|
-
throw new
|
|
900
|
+
throw new APICallError2({
|
|
714
901
|
message: "Failed to process error response",
|
|
715
902
|
cause: error,
|
|
716
903
|
statusCode: response.status,
|
|
@@ -729,11 +916,11 @@ var getFromApi = async ({
|
|
|
729
916
|
});
|
|
730
917
|
} catch (error) {
|
|
731
918
|
if (error instanceof Error) {
|
|
732
|
-
if (isAbortError(error) ||
|
|
919
|
+
if (isAbortError(error) || APICallError2.isInstance(error)) {
|
|
733
920
|
throw error;
|
|
734
921
|
}
|
|
735
922
|
}
|
|
736
|
-
throw new
|
|
923
|
+
throw new APICallError2({
|
|
737
924
|
message: "Failed to process successful response",
|
|
738
925
|
cause: error,
|
|
739
926
|
statusCode: response.status,
|
|
@@ -786,11 +973,22 @@ function injectJsonInstructionIntoMessages({
|
|
|
786
973
|
];
|
|
787
974
|
}
|
|
788
975
|
|
|
976
|
+
// src/is-buffer.ts
|
|
977
|
+
function isBuffer(value) {
|
|
978
|
+
var _a2, _b2;
|
|
979
|
+
return (_b2 = (_a2 = globalThis.Buffer) == null ? void 0 : _a2.isBuffer(value)) != null ? _b2 : false;
|
|
980
|
+
}
|
|
981
|
+
|
|
789
982
|
// src/is-non-nullable.ts
|
|
790
983
|
function isNonNullable(value) {
|
|
791
984
|
return value != null;
|
|
792
985
|
}
|
|
793
986
|
|
|
987
|
+
// src/is-provider-reference.ts
|
|
988
|
+
function isProviderReference(data) {
|
|
989
|
+
return typeof data === "object" && data !== null && !(data instanceof Uint8Array) && !(data instanceof URL) && !(data instanceof ArrayBuffer) && !isBuffer(data) && !("type" in data);
|
|
990
|
+
}
|
|
991
|
+
|
|
794
992
|
// src/is-url-supported.ts
|
|
795
993
|
function isUrlSupported({
|
|
796
994
|
mediaType,
|
|
@@ -799,14 +997,23 @@ function isUrlSupported({
|
|
|
799
997
|
}) {
|
|
800
998
|
url = url.toLowerCase();
|
|
801
999
|
mediaType = mediaType.toLowerCase();
|
|
1000
|
+
const isTopLevelOnly = !mediaType.includes("/");
|
|
802
1001
|
return Object.entries(supportedUrls).map(([key, value]) => {
|
|
803
1002
|
const mediaType2 = key.toLowerCase();
|
|
804
1003
|
return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
|
|
805
|
-
}).filter(({ mediaTypePrefix }) =>
|
|
1004
|
+
}).filter(({ mediaTypePrefix }) => {
|
|
1005
|
+
if (mediaTypePrefix === "") {
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
if (isTopLevelOnly) {
|
|
1009
|
+
return `${mediaType}/` === mediaTypePrefix;
|
|
1010
|
+
}
|
|
1011
|
+
return mediaType.startsWith(mediaTypePrefix);
|
|
1012
|
+
}).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));
|
|
806
1013
|
}
|
|
807
1014
|
|
|
808
1015
|
// src/load-api-key.ts
|
|
809
|
-
|
|
1016
|
+
import { LoadAPIKeyError } from "@ai-sdk/provider";
|
|
810
1017
|
function loadApiKey({
|
|
811
1018
|
apiKey,
|
|
812
1019
|
environmentVariableName,
|
|
@@ -817,23 +1024,23 @@ function loadApiKey({
|
|
|
817
1024
|
return apiKey;
|
|
818
1025
|
}
|
|
819
1026
|
if (apiKey != null) {
|
|
820
|
-
throw new
|
|
1027
|
+
throw new LoadAPIKeyError({
|
|
821
1028
|
message: `${description} API key must be a string.`
|
|
822
1029
|
});
|
|
823
1030
|
}
|
|
824
1031
|
if (typeof process === "undefined") {
|
|
825
|
-
throw new
|
|
826
|
-
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables
|
|
1032
|
+
throw new LoadAPIKeyError({
|
|
1033
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables are not supported in this environment.`
|
|
827
1034
|
});
|
|
828
1035
|
}
|
|
829
1036
|
apiKey = process.env[environmentVariableName];
|
|
830
1037
|
if (apiKey == null) {
|
|
831
|
-
throw new
|
|
1038
|
+
throw new LoadAPIKeyError({
|
|
832
1039
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
833
1040
|
});
|
|
834
1041
|
}
|
|
835
1042
|
if (typeof apiKey !== "string") {
|
|
836
|
-
throw new
|
|
1043
|
+
throw new LoadAPIKeyError({
|
|
837
1044
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
838
1045
|
});
|
|
839
1046
|
}
|
|
@@ -859,7 +1066,7 @@ function loadOptionalSetting({
|
|
|
859
1066
|
}
|
|
860
1067
|
|
|
861
1068
|
// src/load-setting.ts
|
|
862
|
-
|
|
1069
|
+
import { LoadSettingError } from "@ai-sdk/provider";
|
|
863
1070
|
function loadSetting({
|
|
864
1071
|
settingValue,
|
|
865
1072
|
environmentVariableName,
|
|
@@ -870,29 +1077,86 @@ function loadSetting({
|
|
|
870
1077
|
return settingValue;
|
|
871
1078
|
}
|
|
872
1079
|
if (settingValue != null) {
|
|
873
|
-
throw new
|
|
1080
|
+
throw new LoadSettingError({
|
|
874
1081
|
message: `${description} setting must be a string.`
|
|
875
1082
|
});
|
|
876
1083
|
}
|
|
877
1084
|
if (typeof process === "undefined") {
|
|
878
|
-
throw new
|
|
879
|
-
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables
|
|
1085
|
+
throw new LoadSettingError({
|
|
1086
|
+
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables are not supported in this environment.`
|
|
880
1087
|
});
|
|
881
1088
|
}
|
|
882
1089
|
settingValue = process.env[environmentVariableName];
|
|
883
1090
|
if (settingValue == null) {
|
|
884
|
-
throw new
|
|
1091
|
+
throw new LoadSettingError({
|
|
885
1092
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
886
1093
|
});
|
|
887
1094
|
}
|
|
888
1095
|
if (typeof settingValue !== "string") {
|
|
889
|
-
throw new
|
|
1096
|
+
throw new LoadSettingError({
|
|
890
1097
|
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
891
1098
|
});
|
|
892
1099
|
}
|
|
893
1100
|
return settingValue;
|
|
894
1101
|
}
|
|
895
1102
|
|
|
1103
|
+
// src/map-reasoning-to-provider.ts
|
|
1104
|
+
function isCustomReasoning(reasoning) {
|
|
1105
|
+
return reasoning !== void 0 && reasoning !== "provider-default";
|
|
1106
|
+
}
|
|
1107
|
+
function mapReasoningToProviderEffort({
|
|
1108
|
+
reasoning,
|
|
1109
|
+
effortMap,
|
|
1110
|
+
warnings
|
|
1111
|
+
}) {
|
|
1112
|
+
const mapped = effortMap[reasoning];
|
|
1113
|
+
if (mapped == null) {
|
|
1114
|
+
warnings.push({
|
|
1115
|
+
type: "unsupported",
|
|
1116
|
+
feature: "reasoning",
|
|
1117
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
1118
|
+
});
|
|
1119
|
+
return void 0;
|
|
1120
|
+
}
|
|
1121
|
+
if (mapped !== reasoning) {
|
|
1122
|
+
warnings.push({
|
|
1123
|
+
type: "compatibility",
|
|
1124
|
+
feature: "reasoning",
|
|
1125
|
+
details: `reasoning "${reasoning}" is not directly supported by this model. mapped to effort "${mapped}".`
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
return mapped;
|
|
1129
|
+
}
|
|
1130
|
+
var DEFAULT_REASONING_BUDGET_PERCENTAGES = {
|
|
1131
|
+
minimal: 0.02,
|
|
1132
|
+
low: 0.1,
|
|
1133
|
+
medium: 0.3,
|
|
1134
|
+
high: 0.6,
|
|
1135
|
+
xhigh: 0.9
|
|
1136
|
+
};
|
|
1137
|
+
function mapReasoningToProviderBudget({
|
|
1138
|
+
reasoning,
|
|
1139
|
+
maxOutputTokens,
|
|
1140
|
+
maxReasoningBudget,
|
|
1141
|
+
minReasoningBudget = 1024,
|
|
1142
|
+
budgetPercentages = DEFAULT_REASONING_BUDGET_PERCENTAGES,
|
|
1143
|
+
warnings
|
|
1144
|
+
}) {
|
|
1145
|
+
const pct = budgetPercentages[reasoning];
|
|
1146
|
+
if (pct == null) {
|
|
1147
|
+
warnings.push({
|
|
1148
|
+
type: "unsupported",
|
|
1149
|
+
feature: "reasoning",
|
|
1150
|
+
details: `reasoning "${reasoning}" is not supported by this model.`
|
|
1151
|
+
});
|
|
1152
|
+
return void 0;
|
|
1153
|
+
}
|
|
1154
|
+
return Math.min(
|
|
1155
|
+
maxReasoningBudget,
|
|
1156
|
+
Math.max(minReasoningBudget, Math.round(maxOutputTokens * pct))
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
|
|
896
1160
|
// src/media-type-to-extension.ts
|
|
897
1161
|
function mediaTypeToExtension(mediaType) {
|
|
898
1162
|
var _a2;
|
|
@@ -907,7 +1171,10 @@ function mediaTypeToExtension(mediaType) {
|
|
|
907
1171
|
}
|
|
908
1172
|
|
|
909
1173
|
// src/parse-json.ts
|
|
910
|
-
|
|
1174
|
+
import {
|
|
1175
|
+
JSONParseError,
|
|
1176
|
+
TypeValidationError as TypeValidationError3
|
|
1177
|
+
} from "@ai-sdk/provider";
|
|
911
1178
|
|
|
912
1179
|
// src/secure-json-parse.ts
|
|
913
1180
|
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
@@ -959,11 +1226,13 @@ function secureJsonParse(text) {
|
|
|
959
1226
|
}
|
|
960
1227
|
|
|
961
1228
|
// src/validate-types.ts
|
|
962
|
-
|
|
1229
|
+
import {
|
|
1230
|
+
TypeValidationError as TypeValidationError2
|
|
1231
|
+
} from "@ai-sdk/provider";
|
|
963
1232
|
|
|
964
1233
|
// src/schema.ts
|
|
965
|
-
|
|
966
|
-
|
|
1234
|
+
import { TypeValidationError } from "@ai-sdk/provider";
|
|
1235
|
+
import * as z4 from "zod/v4";
|
|
967
1236
|
|
|
968
1237
|
// src/add-additional-properties-to-json-schema.ts
|
|
969
1238
|
function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
@@ -1035,7 +1304,7 @@ var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
|
1035
1304
|
};
|
|
1036
1305
|
|
|
1037
1306
|
// src/to-json-schema/zod3-to-json-schema/select-parser.ts
|
|
1038
|
-
|
|
1307
|
+
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind3 } from "zod/v3";
|
|
1039
1308
|
|
|
1040
1309
|
// src/to-json-schema/zod3-to-json-schema/parsers/any.ts
|
|
1041
1310
|
function parseAnyDef() {
|
|
@@ -1043,13 +1312,13 @@ function parseAnyDef() {
|
|
|
1043
1312
|
}
|
|
1044
1313
|
|
|
1045
1314
|
// src/to-json-schema/zod3-to-json-schema/parsers/array.ts
|
|
1046
|
-
|
|
1315
|
+
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
1047
1316
|
function parseArrayDef(def, refs) {
|
|
1048
1317
|
var _a2, _b2, _c;
|
|
1049
1318
|
const res = {
|
|
1050
1319
|
type: "array"
|
|
1051
1320
|
};
|
|
1052
|
-
if (((_a2 = def.type) == null ? void 0 : _a2._def) && ((_c = (_b2 = def.type) == null ? void 0 : _b2._def) == null ? void 0 : _c.typeName) !==
|
|
1321
|
+
if (((_a2 = def.type) == null ? void 0 : _a2._def) && ((_c = (_b2 = def.type) == null ? void 0 : _b2._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
|
|
1053
1322
|
res.items = parseDef(def.type._def, {
|
|
1054
1323
|
...refs,
|
|
1055
1324
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1119,7 +1388,7 @@ function parseDateDef(def, refs, overrideDateStrategy) {
|
|
|
1119
1388
|
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
1120
1389
|
if (Array.isArray(strategy)) {
|
|
1121
1390
|
return {
|
|
1122
|
-
anyOf: strategy.map((item
|
|
1391
|
+
anyOf: strategy.map((item) => parseDateDef(def, refs, item))
|
|
1123
1392
|
};
|
|
1124
1393
|
}
|
|
1125
1394
|
switch (strategy) {
|
|
@@ -1200,7 +1469,7 @@ function parseIntersectionDef(def, refs) {
|
|
|
1200
1469
|
} else {
|
|
1201
1470
|
let nestedSchema = schema;
|
|
1202
1471
|
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
1203
|
-
const { additionalProperties, ...rest } = schema;
|
|
1472
|
+
const { additionalProperties: _additionalProperties, ...rest } = schema;
|
|
1204
1473
|
nestedSchema = rest;
|
|
1205
1474
|
}
|
|
1206
1475
|
mergedAllOf.push(nestedSchema);
|
|
@@ -1224,7 +1493,9 @@ function parseLiteralDef(def) {
|
|
|
1224
1493
|
}
|
|
1225
1494
|
|
|
1226
1495
|
// src/to-json-schema/zod3-to-json-schema/parsers/record.ts
|
|
1227
|
-
|
|
1496
|
+
import {
|
|
1497
|
+
ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2
|
|
1498
|
+
} from "zod/v3";
|
|
1228
1499
|
|
|
1229
1500
|
// src/to-json-schema/zod3-to-json-schema/parsers/string.ts
|
|
1230
1501
|
var emojiRegex = void 0;
|
|
@@ -1572,21 +1843,21 @@ function parseRecordDef(def, refs) {
|
|
|
1572
1843
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1573
1844
|
})) != null ? _a2 : refs.allowedAdditionalProperties
|
|
1574
1845
|
};
|
|
1575
|
-
if (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) ===
|
|
1576
|
-
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1846
|
+
if (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1847
|
+
const { type: _type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1577
1848
|
return {
|
|
1578
1849
|
...schema,
|
|
1579
1850
|
propertyNames: keyType
|
|
1580
1851
|
};
|
|
1581
|
-
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) ===
|
|
1852
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind2.ZodEnum) {
|
|
1582
1853
|
return {
|
|
1583
1854
|
...schema,
|
|
1584
1855
|
propertyNames: {
|
|
1585
1856
|
enum: def.keyType._def.values
|
|
1586
1857
|
}
|
|
1587
1858
|
};
|
|
1588
|
-
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) ===
|
|
1589
|
-
const { type, ...keyType } = parseBrandedDef(
|
|
1859
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind2.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind2.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
1860
|
+
const { type: _type, ...keyType } = parseBrandedDef(
|
|
1590
1861
|
def.keyType._def,
|
|
1591
1862
|
refs
|
|
1592
1863
|
);
|
|
@@ -1959,73 +2230,73 @@ var parseReadonlyDef = (def, refs) => {
|
|
|
1959
2230
|
// src/to-json-schema/zod3-to-json-schema/select-parser.ts
|
|
1960
2231
|
var selectParser = (def, typeName, refs) => {
|
|
1961
2232
|
switch (typeName) {
|
|
1962
|
-
case
|
|
2233
|
+
case ZodFirstPartyTypeKind3.ZodString:
|
|
1963
2234
|
return parseStringDef(def, refs);
|
|
1964
|
-
case
|
|
2235
|
+
case ZodFirstPartyTypeKind3.ZodNumber:
|
|
1965
2236
|
return parseNumberDef(def);
|
|
1966
|
-
case
|
|
2237
|
+
case ZodFirstPartyTypeKind3.ZodObject:
|
|
1967
2238
|
return parseObjectDef(def, refs);
|
|
1968
|
-
case
|
|
2239
|
+
case ZodFirstPartyTypeKind3.ZodBigInt:
|
|
1969
2240
|
return parseBigintDef(def);
|
|
1970
|
-
case
|
|
2241
|
+
case ZodFirstPartyTypeKind3.ZodBoolean:
|
|
1971
2242
|
return parseBooleanDef();
|
|
1972
|
-
case
|
|
2243
|
+
case ZodFirstPartyTypeKind3.ZodDate:
|
|
1973
2244
|
return parseDateDef(def, refs);
|
|
1974
|
-
case
|
|
2245
|
+
case ZodFirstPartyTypeKind3.ZodUndefined:
|
|
1975
2246
|
return parseUndefinedDef();
|
|
1976
|
-
case
|
|
2247
|
+
case ZodFirstPartyTypeKind3.ZodNull:
|
|
1977
2248
|
return parseNullDef();
|
|
1978
|
-
case
|
|
2249
|
+
case ZodFirstPartyTypeKind3.ZodArray:
|
|
1979
2250
|
return parseArrayDef(def, refs);
|
|
1980
|
-
case
|
|
1981
|
-
case
|
|
2251
|
+
case ZodFirstPartyTypeKind3.ZodUnion:
|
|
2252
|
+
case ZodFirstPartyTypeKind3.ZodDiscriminatedUnion:
|
|
1982
2253
|
return parseUnionDef(def, refs);
|
|
1983
|
-
case
|
|
2254
|
+
case ZodFirstPartyTypeKind3.ZodIntersection:
|
|
1984
2255
|
return parseIntersectionDef(def, refs);
|
|
1985
|
-
case
|
|
2256
|
+
case ZodFirstPartyTypeKind3.ZodTuple:
|
|
1986
2257
|
return parseTupleDef(def, refs);
|
|
1987
|
-
case
|
|
2258
|
+
case ZodFirstPartyTypeKind3.ZodRecord:
|
|
1988
2259
|
return parseRecordDef(def, refs);
|
|
1989
|
-
case
|
|
2260
|
+
case ZodFirstPartyTypeKind3.ZodLiteral:
|
|
1990
2261
|
return parseLiteralDef(def);
|
|
1991
|
-
case
|
|
2262
|
+
case ZodFirstPartyTypeKind3.ZodEnum:
|
|
1992
2263
|
return parseEnumDef(def);
|
|
1993
|
-
case
|
|
2264
|
+
case ZodFirstPartyTypeKind3.ZodNativeEnum:
|
|
1994
2265
|
return parseNativeEnumDef(def);
|
|
1995
|
-
case
|
|
2266
|
+
case ZodFirstPartyTypeKind3.ZodNullable:
|
|
1996
2267
|
return parseNullableDef(def, refs);
|
|
1997
|
-
case
|
|
2268
|
+
case ZodFirstPartyTypeKind3.ZodOptional:
|
|
1998
2269
|
return parseOptionalDef(def, refs);
|
|
1999
|
-
case
|
|
2270
|
+
case ZodFirstPartyTypeKind3.ZodMap:
|
|
2000
2271
|
return parseMapDef(def, refs);
|
|
2001
|
-
case
|
|
2272
|
+
case ZodFirstPartyTypeKind3.ZodSet:
|
|
2002
2273
|
return parseSetDef(def, refs);
|
|
2003
|
-
case
|
|
2274
|
+
case ZodFirstPartyTypeKind3.ZodLazy:
|
|
2004
2275
|
return () => def.getter()._def;
|
|
2005
|
-
case
|
|
2276
|
+
case ZodFirstPartyTypeKind3.ZodPromise:
|
|
2006
2277
|
return parsePromiseDef(def, refs);
|
|
2007
|
-
case
|
|
2008
|
-
case
|
|
2278
|
+
case ZodFirstPartyTypeKind3.ZodNaN:
|
|
2279
|
+
case ZodFirstPartyTypeKind3.ZodNever:
|
|
2009
2280
|
return parseNeverDef();
|
|
2010
|
-
case
|
|
2281
|
+
case ZodFirstPartyTypeKind3.ZodEffects:
|
|
2011
2282
|
return parseEffectsDef(def, refs);
|
|
2012
|
-
case
|
|
2283
|
+
case ZodFirstPartyTypeKind3.ZodAny:
|
|
2013
2284
|
return parseAnyDef();
|
|
2014
|
-
case
|
|
2285
|
+
case ZodFirstPartyTypeKind3.ZodUnknown:
|
|
2015
2286
|
return parseUnknownDef();
|
|
2016
|
-
case
|
|
2287
|
+
case ZodFirstPartyTypeKind3.ZodDefault:
|
|
2017
2288
|
return parseDefaultDef(def, refs);
|
|
2018
|
-
case
|
|
2289
|
+
case ZodFirstPartyTypeKind3.ZodBranded:
|
|
2019
2290
|
return parseBrandedDef(def, refs);
|
|
2020
|
-
case
|
|
2291
|
+
case ZodFirstPartyTypeKind3.ZodReadonly:
|
|
2021
2292
|
return parseReadonlyDef(def, refs);
|
|
2022
|
-
case
|
|
2293
|
+
case ZodFirstPartyTypeKind3.ZodCatch:
|
|
2023
2294
|
return parseCatchDef(def, refs);
|
|
2024
|
-
case
|
|
2295
|
+
case ZodFirstPartyTypeKind3.ZodPipeline:
|
|
2025
2296
|
return parsePipelineDef(def, refs);
|
|
2026
|
-
case
|
|
2027
|
-
case
|
|
2028
|
-
case
|
|
2297
|
+
case ZodFirstPartyTypeKind3.ZodFunction:
|
|
2298
|
+
case ZodFirstPartyTypeKind3.ZodVoid:
|
|
2299
|
+
case ZodFirstPartyTypeKind3.ZodSymbol:
|
|
2029
2300
|
return void 0;
|
|
2030
2301
|
default:
|
|
2031
2302
|
return /* @__PURE__ */ ((_) => void 0)(typeName);
|
|
@@ -2224,7 +2495,7 @@ function standardSchema(standardSchema2) {
|
|
|
2224
2495
|
const result = await standardSchema2["~standard"].validate(value);
|
|
2225
2496
|
return "value" in result ? { success: true, value: result.value } : {
|
|
2226
2497
|
success: false,
|
|
2227
|
-
error: new
|
|
2498
|
+
error: new TypeValidationError({
|
|
2228
2499
|
value,
|
|
2229
2500
|
cause: result.issues
|
|
2230
2501
|
})
|
|
@@ -2288,7 +2559,7 @@ async function validateTypes({
|
|
|
2288
2559
|
}) {
|
|
2289
2560
|
const result = await safeValidateTypes({ value, schema, context });
|
|
2290
2561
|
if (!result.success) {
|
|
2291
|
-
throw
|
|
2562
|
+
throw TypeValidationError2.wrap({ value, cause: result.error, context });
|
|
2292
2563
|
}
|
|
2293
2564
|
return result.value;
|
|
2294
2565
|
}
|
|
@@ -2308,13 +2579,13 @@ async function safeValidateTypes({
|
|
|
2308
2579
|
}
|
|
2309
2580
|
return {
|
|
2310
2581
|
success: false,
|
|
2311
|
-
error:
|
|
2582
|
+
error: TypeValidationError2.wrap({ value, cause: result.error, context }),
|
|
2312
2583
|
rawValue: value
|
|
2313
2584
|
};
|
|
2314
2585
|
} catch (error) {
|
|
2315
2586
|
return {
|
|
2316
2587
|
success: false,
|
|
2317
|
-
error:
|
|
2588
|
+
error: TypeValidationError2.wrap({ value, cause: error, context }),
|
|
2318
2589
|
rawValue: value
|
|
2319
2590
|
};
|
|
2320
2591
|
}
|
|
@@ -2330,12 +2601,12 @@ async function parseJSON({
|
|
|
2330
2601
|
if (schema == null) {
|
|
2331
2602
|
return value;
|
|
2332
2603
|
}
|
|
2333
|
-
return validateTypes({ value, schema });
|
|
2604
|
+
return await validateTypes({ value, schema });
|
|
2334
2605
|
} catch (error) {
|
|
2335
|
-
if (
|
|
2606
|
+
if (JSONParseError.isInstance(error) || TypeValidationError3.isInstance(error)) {
|
|
2336
2607
|
throw error;
|
|
2337
2608
|
}
|
|
2338
|
-
throw new
|
|
2609
|
+
throw new JSONParseError({ text, cause: error });
|
|
2339
2610
|
}
|
|
2340
2611
|
}
|
|
2341
2612
|
async function safeParseJSON({
|
|
@@ -2351,7 +2622,7 @@ async function safeParseJSON({
|
|
|
2351
2622
|
} catch (error) {
|
|
2352
2623
|
return {
|
|
2353
2624
|
success: false,
|
|
2354
|
-
error:
|
|
2625
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text, cause: error }),
|
|
2355
2626
|
rawValue: void 0
|
|
2356
2627
|
};
|
|
2357
2628
|
}
|
|
@@ -2366,12 +2637,14 @@ function isParsableJson(input) {
|
|
|
2366
2637
|
}
|
|
2367
2638
|
|
|
2368
2639
|
// src/parse-json-event-stream.ts
|
|
2369
|
-
|
|
2640
|
+
import {
|
|
2641
|
+
EventSourceParserStream
|
|
2642
|
+
} from "eventsource-parser/stream";
|
|
2370
2643
|
function parseJsonEventStream({
|
|
2371
2644
|
stream,
|
|
2372
2645
|
schema
|
|
2373
2646
|
}) {
|
|
2374
|
-
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
2647
|
+
return stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
2375
2648
|
new TransformStream({
|
|
2376
2649
|
async transform({ data }, controller) {
|
|
2377
2650
|
if (data === "[DONE]") {
|
|
@@ -2384,7 +2657,7 @@ function parseJsonEventStream({
|
|
|
2384
2657
|
}
|
|
2385
2658
|
|
|
2386
2659
|
// src/parse-provider-options.ts
|
|
2387
|
-
|
|
2660
|
+
import { InvalidArgumentError as InvalidArgumentError2 } from "@ai-sdk/provider";
|
|
2388
2661
|
async function parseProviderOptions({
|
|
2389
2662
|
provider,
|
|
2390
2663
|
providerOptions,
|
|
@@ -2398,7 +2671,7 @@ async function parseProviderOptions({
|
|
|
2398
2671
|
schema
|
|
2399
2672
|
});
|
|
2400
2673
|
if (!parsedProviderOptions.success) {
|
|
2401
|
-
throw new
|
|
2674
|
+
throw new InvalidArgumentError2({
|
|
2402
2675
|
argument: "providerOptions",
|
|
2403
2676
|
message: `invalid ${provider} provider options`,
|
|
2404
2677
|
cause: parsedProviderOptions.error
|
|
@@ -2408,7 +2681,7 @@ async function parseProviderOptions({
|
|
|
2408
2681
|
}
|
|
2409
2682
|
|
|
2410
2683
|
// src/post-to-api.ts
|
|
2411
|
-
|
|
2684
|
+
import { APICallError as APICallError3 } from "@ai-sdk/provider";
|
|
2412
2685
|
var getOriginalFetch2 = () => globalThis.fetch;
|
|
2413
2686
|
var postJsonToApi = async ({
|
|
2414
2687
|
url,
|
|
@@ -2418,7 +2691,7 @@ var postJsonToApi = async ({
|
|
|
2418
2691
|
successfulResponseHandler,
|
|
2419
2692
|
abortSignal,
|
|
2420
2693
|
fetch: fetch2
|
|
2421
|
-
}) => postToApi({
|
|
2694
|
+
}) => await postToApi({
|
|
2422
2695
|
url,
|
|
2423
2696
|
headers: {
|
|
2424
2697
|
"Content-Type": "application/json",
|
|
@@ -2441,7 +2714,7 @@ var postFormDataToApi = async ({
|
|
|
2441
2714
|
successfulResponseHandler,
|
|
2442
2715
|
abortSignal,
|
|
2443
2716
|
fetch: fetch2
|
|
2444
|
-
}) => postToApi({
|
|
2717
|
+
}) => await postToApi({
|
|
2445
2718
|
url,
|
|
2446
2719
|
headers,
|
|
2447
2720
|
body: {
|
|
@@ -2483,10 +2756,10 @@ var postToApi = async ({
|
|
|
2483
2756
|
requestBodyValues: body.values
|
|
2484
2757
|
});
|
|
2485
2758
|
} catch (error) {
|
|
2486
|
-
if (isAbortError(error) ||
|
|
2759
|
+
if (isAbortError(error) || APICallError3.isInstance(error)) {
|
|
2487
2760
|
throw error;
|
|
2488
2761
|
}
|
|
2489
|
-
throw new
|
|
2762
|
+
throw new APICallError3({
|
|
2490
2763
|
message: "Failed to process error response",
|
|
2491
2764
|
cause: error,
|
|
2492
2765
|
statusCode: response.status,
|
|
@@ -2505,11 +2778,11 @@ var postToApi = async ({
|
|
|
2505
2778
|
});
|
|
2506
2779
|
} catch (error) {
|
|
2507
2780
|
if (error instanceof Error) {
|
|
2508
|
-
if (isAbortError(error) ||
|
|
2781
|
+
if (isAbortError(error) || APICallError3.isInstance(error)) {
|
|
2509
2782
|
throw error;
|
|
2510
2783
|
}
|
|
2511
2784
|
}
|
|
2512
|
-
throw new
|
|
2785
|
+
throw new APICallError3({
|
|
2513
2786
|
message: "Failed to process successful response",
|
|
2514
2787
|
cause: error,
|
|
2515
2788
|
statusCode: response.status,
|
|
@@ -2531,8 +2804,8 @@ function dynamicTool(tool2) {
|
|
|
2531
2804
|
return { ...tool2, type: "dynamic" };
|
|
2532
2805
|
}
|
|
2533
2806
|
|
|
2534
|
-
// src/provider-tool-factory.ts
|
|
2535
|
-
function
|
|
2807
|
+
// src/provider-defined-tool-factory.ts
|
|
2808
|
+
function createProviderDefinedToolFactory({
|
|
2536
2809
|
id,
|
|
2537
2810
|
inputSchema
|
|
2538
2811
|
}) {
|
|
@@ -2547,6 +2820,7 @@ function createProviderToolFactory({
|
|
|
2547
2820
|
...args
|
|
2548
2821
|
}) => tool({
|
|
2549
2822
|
type: "provider",
|
|
2823
|
+
isProviderExecuted: false,
|
|
2550
2824
|
id,
|
|
2551
2825
|
args,
|
|
2552
2826
|
inputSchema,
|
|
@@ -2559,11 +2833,10 @@ function createProviderToolFactory({
|
|
|
2559
2833
|
onInputAvailable
|
|
2560
2834
|
});
|
|
2561
2835
|
}
|
|
2562
|
-
function
|
|
2836
|
+
function createProviderDefinedToolFactoryWithOutputSchema({
|
|
2563
2837
|
id,
|
|
2564
2838
|
inputSchema,
|
|
2565
|
-
outputSchema
|
|
2566
|
-
supportsDeferredResults
|
|
2839
|
+
outputSchema
|
|
2567
2840
|
}) {
|
|
2568
2841
|
return ({
|
|
2569
2842
|
execute,
|
|
@@ -2575,6 +2848,7 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
2575
2848
|
...args
|
|
2576
2849
|
}) => tool({
|
|
2577
2850
|
type: "provider",
|
|
2851
|
+
isProviderExecuted: false,
|
|
2578
2852
|
id,
|
|
2579
2853
|
args,
|
|
2580
2854
|
inputSchema,
|
|
@@ -2584,6 +2858,31 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
2584
2858
|
toModelOutput,
|
|
2585
2859
|
onInputStart,
|
|
2586
2860
|
onInputDelta,
|
|
2861
|
+
onInputAvailable
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
// src/provider-executed-tool-factory.ts
|
|
2866
|
+
function createProviderExecutedToolFactory({
|
|
2867
|
+
id,
|
|
2868
|
+
inputSchema,
|
|
2869
|
+
outputSchema,
|
|
2870
|
+
supportsDeferredResults
|
|
2871
|
+
}) {
|
|
2872
|
+
return ({
|
|
2873
|
+
onInputStart,
|
|
2874
|
+
onInputDelta,
|
|
2875
|
+
onInputAvailable,
|
|
2876
|
+
...args
|
|
2877
|
+
}) => tool({
|
|
2878
|
+
type: "provider",
|
|
2879
|
+
isProviderExecuted: true,
|
|
2880
|
+
id,
|
|
2881
|
+
args,
|
|
2882
|
+
inputSchema,
|
|
2883
|
+
outputSchema,
|
|
2884
|
+
onInputStart,
|
|
2885
|
+
onInputDelta,
|
|
2587
2886
|
onInputAvailable,
|
|
2588
2887
|
supportsDeferredResults
|
|
2589
2888
|
});
|
|
@@ -2604,8 +2903,53 @@ async function resolve(value) {
|
|
|
2604
2903
|
return Promise.resolve(value);
|
|
2605
2904
|
}
|
|
2606
2905
|
|
|
2906
|
+
// src/resolve-full-media-type.ts
|
|
2907
|
+
import {
|
|
2908
|
+
UnsupportedFunctionalityError
|
|
2909
|
+
} from "@ai-sdk/provider";
|
|
2910
|
+
function resolveFullMediaType({
|
|
2911
|
+
part
|
|
2912
|
+
}) {
|
|
2913
|
+
if (isFullMediaType(part.mediaType)) {
|
|
2914
|
+
return part.mediaType;
|
|
2915
|
+
}
|
|
2916
|
+
if (part.data.type === "data") {
|
|
2917
|
+
const detected = detectMediaType({
|
|
2918
|
+
data: part.data.data,
|
|
2919
|
+
topLevelType: getTopLevelMediaType(part.mediaType)
|
|
2920
|
+
});
|
|
2921
|
+
if (detected) {
|
|
2922
|
+
return detected;
|
|
2923
|
+
}
|
|
2924
|
+
throw new UnsupportedFunctionalityError({
|
|
2925
|
+
functionality: `file of media type "${part.mediaType}" must specify subtype since it could not be auto-detected`
|
|
2926
|
+
});
|
|
2927
|
+
}
|
|
2928
|
+
throw new UnsupportedFunctionalityError({
|
|
2929
|
+
functionality: `file of media type "${part.mediaType}" must specify subtype since it is not passed as inline bytes`
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
// src/resolve-provider-reference.ts
|
|
2934
|
+
import {
|
|
2935
|
+
NoSuchProviderReferenceError
|
|
2936
|
+
} from "@ai-sdk/provider";
|
|
2937
|
+
function resolveProviderReference({
|
|
2938
|
+
reference,
|
|
2939
|
+
provider
|
|
2940
|
+
}) {
|
|
2941
|
+
const id = reference[provider];
|
|
2942
|
+
if (id != null) {
|
|
2943
|
+
return id;
|
|
2944
|
+
}
|
|
2945
|
+
throw new NoSuchProviderReferenceError({
|
|
2946
|
+
provider,
|
|
2947
|
+
reference
|
|
2948
|
+
});
|
|
2949
|
+
}
|
|
2950
|
+
|
|
2607
2951
|
// src/response-handler.ts
|
|
2608
|
-
|
|
2952
|
+
import { APICallError as APICallError4, EmptyResponseBodyError } from "@ai-sdk/provider";
|
|
2609
2953
|
var createJsonErrorResponseHandler = ({
|
|
2610
2954
|
errorSchema,
|
|
2611
2955
|
errorToMessage,
|
|
@@ -2616,7 +2960,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2616
2960
|
if (responseBody.trim() === "") {
|
|
2617
2961
|
return {
|
|
2618
2962
|
responseHeaders,
|
|
2619
|
-
value: new
|
|
2963
|
+
value: new APICallError4({
|
|
2620
2964
|
message: response.statusText,
|
|
2621
2965
|
url,
|
|
2622
2966
|
requestBodyValues,
|
|
@@ -2634,7 +2978,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2634
2978
|
});
|
|
2635
2979
|
return {
|
|
2636
2980
|
responseHeaders,
|
|
2637
|
-
value: new
|
|
2981
|
+
value: new APICallError4({
|
|
2638
2982
|
message: errorToMessage(parsedError),
|
|
2639
2983
|
url,
|
|
2640
2984
|
requestBodyValues,
|
|
@@ -2645,10 +2989,10 @@ var createJsonErrorResponseHandler = ({
|
|
|
2645
2989
|
isRetryable: isRetryable == null ? void 0 : isRetryable(response, parsedError)
|
|
2646
2990
|
})
|
|
2647
2991
|
};
|
|
2648
|
-
} catch (
|
|
2992
|
+
} catch (e) {
|
|
2649
2993
|
return {
|
|
2650
2994
|
responseHeaders,
|
|
2651
|
-
value: new
|
|
2995
|
+
value: new APICallError4({
|
|
2652
2996
|
message: response.statusText,
|
|
2653
2997
|
url,
|
|
2654
2998
|
requestBodyValues,
|
|
@@ -2663,7 +3007,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2663
3007
|
var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
|
|
2664
3008
|
const responseHeaders = extractResponseHeaders(response);
|
|
2665
3009
|
if (response.body == null) {
|
|
2666
|
-
throw new
|
|
3010
|
+
throw new EmptyResponseBodyError({});
|
|
2667
3011
|
}
|
|
2668
3012
|
return {
|
|
2669
3013
|
responseHeaders,
|
|
@@ -2681,7 +3025,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
2681
3025
|
});
|
|
2682
3026
|
const responseHeaders = extractResponseHeaders(response);
|
|
2683
3027
|
if (!parsedResult.success) {
|
|
2684
|
-
throw new
|
|
3028
|
+
throw new APICallError4({
|
|
2685
3029
|
message: "Invalid JSON response",
|
|
2686
3030
|
cause: parsedResult.error,
|
|
2687
3031
|
statusCode: response.status,
|
|
@@ -2700,7 +3044,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
2700
3044
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
2701
3045
|
const responseHeaders = extractResponseHeaders(response);
|
|
2702
3046
|
if (!response.body) {
|
|
2703
|
-
throw new
|
|
3047
|
+
throw new APICallError4({
|
|
2704
3048
|
message: "Response body is empty",
|
|
2705
3049
|
url,
|
|
2706
3050
|
requestBodyValues,
|
|
@@ -2716,7 +3060,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
|
2716
3060
|
value: new Uint8Array(buffer)
|
|
2717
3061
|
};
|
|
2718
3062
|
} catch (error) {
|
|
2719
|
-
throw new
|
|
3063
|
+
throw new APICallError4({
|
|
2720
3064
|
message: "Failed to read response as array buffer",
|
|
2721
3065
|
url,
|
|
2722
3066
|
requestBodyValues,
|
|
@@ -2732,7 +3076,7 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2732
3076
|
const responseBody = await response.text();
|
|
2733
3077
|
return {
|
|
2734
3078
|
responseHeaders,
|
|
2735
|
-
value: new
|
|
3079
|
+
value: new APICallError4({
|
|
2736
3080
|
message: response.statusText,
|
|
2737
3081
|
url,
|
|
2738
3082
|
requestBodyValues,
|
|
@@ -2743,6 +3087,185 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2743
3087
|
};
|
|
2744
3088
|
};
|
|
2745
3089
|
|
|
3090
|
+
// src/is-json-serializable.ts
|
|
3091
|
+
function isJSONSerializable(value) {
|
|
3092
|
+
if (value === null || value === void 0) return true;
|
|
3093
|
+
const type = typeof value;
|
|
3094
|
+
if (type === "string" || type === "number" || type === "boolean") return true;
|
|
3095
|
+
if (type === "function" || type === "symbol" || type === "bigint")
|
|
3096
|
+
return false;
|
|
3097
|
+
if (Array.isArray(value)) {
|
|
3098
|
+
return value.every(isJSONSerializable);
|
|
3099
|
+
}
|
|
3100
|
+
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
3101
|
+
return Object.values(value).every(
|
|
3102
|
+
isJSONSerializable
|
|
3103
|
+
);
|
|
3104
|
+
}
|
|
3105
|
+
return false;
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
// src/serialize-model-options.ts
|
|
3109
|
+
function serializeModelOptions(options) {
|
|
3110
|
+
const serializableConfig = {};
|
|
3111
|
+
for (const [key, value] of Object.entries(options.config)) {
|
|
3112
|
+
if (key === "headers") {
|
|
3113
|
+
const resolvedHeaders = resolveSync(value);
|
|
3114
|
+
if (isJSONSerializable(resolvedHeaders)) {
|
|
3115
|
+
serializableConfig[key] = resolvedHeaders;
|
|
3116
|
+
}
|
|
3117
|
+
} else if (isJSONSerializable(value)) {
|
|
3118
|
+
serializableConfig[key] = value;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
return { modelId: options.modelId, config: serializableConfig };
|
|
3122
|
+
}
|
|
3123
|
+
function resolveSync(value) {
|
|
3124
|
+
let next = value;
|
|
3125
|
+
if (typeof value === "function") {
|
|
3126
|
+
next = value();
|
|
3127
|
+
}
|
|
3128
|
+
if (next instanceof Promise) {
|
|
3129
|
+
throw new Error("Promise returned from resolveSync");
|
|
3130
|
+
}
|
|
3131
|
+
return next;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
// src/streaming-tool-call-tracker.ts
|
|
3135
|
+
import {
|
|
3136
|
+
InvalidResponseDataError
|
|
3137
|
+
} from "@ai-sdk/provider";
|
|
3138
|
+
var StreamingToolCallTracker = class {
|
|
3139
|
+
constructor(controller, options = {}) {
|
|
3140
|
+
this.toolCalls = [];
|
|
3141
|
+
var _a2, _b2;
|
|
3142
|
+
this.controller = controller;
|
|
3143
|
+
this._generateId = (_a2 = options.generateId) != null ? _a2 : generateId;
|
|
3144
|
+
this.typeValidation = (_b2 = options.typeValidation) != null ? _b2 : "none";
|
|
3145
|
+
this.extractMetadata = options.extractMetadata;
|
|
3146
|
+
this.buildToolCallProviderMetadata = options.buildToolCallProviderMetadata;
|
|
3147
|
+
}
|
|
3148
|
+
/**
|
|
3149
|
+
* Process a tool call delta from a streaming response chunk.
|
|
3150
|
+
* Emits tool-input-start, tool-input-delta, tool-input-end, and tool-call
|
|
3151
|
+
* events as appropriate.
|
|
3152
|
+
*/
|
|
3153
|
+
processDelta(toolCallDelta) {
|
|
3154
|
+
var _a2;
|
|
3155
|
+
const index = (_a2 = toolCallDelta.index) != null ? _a2 : this.toolCalls.length;
|
|
3156
|
+
if (this.toolCalls[index] == null) {
|
|
3157
|
+
this.processNewToolCall(index, toolCallDelta);
|
|
3158
|
+
} else {
|
|
3159
|
+
this.processExistingToolCall(index, toolCallDelta);
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Finalize any unfinished tool calls. Should be called during the stream's
|
|
3164
|
+
* flush handler to ensure all tool calls are properly completed.
|
|
3165
|
+
*/
|
|
3166
|
+
flush() {
|
|
3167
|
+
for (const toolCall of this.toolCalls) {
|
|
3168
|
+
if (!toolCall.hasFinished) {
|
|
3169
|
+
this.finishToolCall(toolCall);
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
processNewToolCall(index, toolCallDelta) {
|
|
3174
|
+
var _a2, _b2, _c;
|
|
3175
|
+
if (this.typeValidation === "required") {
|
|
3176
|
+
if (toolCallDelta.type !== "function") {
|
|
3177
|
+
throw new InvalidResponseDataError({
|
|
3178
|
+
data: toolCallDelta,
|
|
3179
|
+
message: `Expected 'function' type.`
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
} else if (this.typeValidation === "if-present") {
|
|
3183
|
+
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
3184
|
+
throw new InvalidResponseDataError({
|
|
3185
|
+
data: toolCallDelta,
|
|
3186
|
+
message: `Expected 'function' type.`
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
if (toolCallDelta.id == null) {
|
|
3191
|
+
throw new InvalidResponseDataError({
|
|
3192
|
+
data: toolCallDelta,
|
|
3193
|
+
message: `Expected 'id' to be a string.`
|
|
3194
|
+
});
|
|
3195
|
+
}
|
|
3196
|
+
if (((_a2 = toolCallDelta.function) == null ? void 0 : _a2.name) == null) {
|
|
3197
|
+
throw new InvalidResponseDataError({
|
|
3198
|
+
data: toolCallDelta,
|
|
3199
|
+
message: `Expected 'function.name' to be a string.`
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
this.controller.enqueue({
|
|
3203
|
+
type: "tool-input-start",
|
|
3204
|
+
id: toolCallDelta.id,
|
|
3205
|
+
toolName: toolCallDelta.function.name
|
|
3206
|
+
});
|
|
3207
|
+
const metadata = (_b2 = this.extractMetadata) == null ? void 0 : _b2.call(this, toolCallDelta);
|
|
3208
|
+
this.toolCalls[index] = {
|
|
3209
|
+
id: toolCallDelta.id,
|
|
3210
|
+
type: "function",
|
|
3211
|
+
function: {
|
|
3212
|
+
name: toolCallDelta.function.name,
|
|
3213
|
+
arguments: (_c = toolCallDelta.function.arguments) != null ? _c : ""
|
|
3214
|
+
},
|
|
3215
|
+
hasFinished: false,
|
|
3216
|
+
metadata
|
|
3217
|
+
};
|
|
3218
|
+
const toolCall = this.toolCalls[index];
|
|
3219
|
+
if (toolCall.function.arguments.length > 0) {
|
|
3220
|
+
this.controller.enqueue({
|
|
3221
|
+
type: "tool-input-delta",
|
|
3222
|
+
id: toolCall.id,
|
|
3223
|
+
delta: toolCall.function.arguments
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
if (isParsableJson(toolCall.function.arguments)) {
|
|
3227
|
+
this.finishToolCall(toolCall);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
processExistingToolCall(index, toolCallDelta) {
|
|
3231
|
+
var _a2;
|
|
3232
|
+
const toolCall = this.toolCalls[index];
|
|
3233
|
+
if (toolCall.hasFinished) {
|
|
3234
|
+
return;
|
|
3235
|
+
}
|
|
3236
|
+
if (((_a2 = toolCallDelta.function) == null ? void 0 : _a2.arguments) != null) {
|
|
3237
|
+
toolCall.function.arguments += toolCallDelta.function.arguments;
|
|
3238
|
+
this.controller.enqueue({
|
|
3239
|
+
type: "tool-input-delta",
|
|
3240
|
+
id: toolCall.id,
|
|
3241
|
+
delta: toolCallDelta.function.arguments
|
|
3242
|
+
});
|
|
3243
|
+
}
|
|
3244
|
+
if (isParsableJson(toolCall.function.arguments)) {
|
|
3245
|
+
this.finishToolCall(toolCall);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
finishToolCall(toolCall) {
|
|
3249
|
+
var _a2, _b2;
|
|
3250
|
+
this.controller.enqueue({
|
|
3251
|
+
type: "tool-input-end",
|
|
3252
|
+
id: toolCall.id
|
|
3253
|
+
});
|
|
3254
|
+
const providerMetadata = (_a2 = this.buildToolCallProviderMetadata) == null ? void 0 : _a2.call(
|
|
3255
|
+
this,
|
|
3256
|
+
toolCall.metadata
|
|
3257
|
+
);
|
|
3258
|
+
this.controller.enqueue({
|
|
3259
|
+
type: "tool-call",
|
|
3260
|
+
toolCallId: (_b2 = toolCall.id) != null ? _b2 : this._generateId(),
|
|
3261
|
+
toolName: toolCall.function.name,
|
|
3262
|
+
input: toolCall.function.arguments,
|
|
3263
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3264
|
+
});
|
|
3265
|
+
toolCall.hasFinished = true;
|
|
3266
|
+
}
|
|
3267
|
+
};
|
|
3268
|
+
|
|
2746
3269
|
// src/strip-file-extension.ts
|
|
2747
3270
|
function stripFileExtension(filename) {
|
|
2748
3271
|
const firstDotIndex = filename.indexOf(".");
|
|
@@ -2761,11 +3284,11 @@ function isAsyncIterable(obj) {
|
|
|
2761
3284
|
|
|
2762
3285
|
// src/types/execute-tool.ts
|
|
2763
3286
|
async function* executeTool({
|
|
2764
|
-
|
|
3287
|
+
tool: tool2,
|
|
2765
3288
|
input,
|
|
2766
3289
|
options
|
|
2767
3290
|
}) {
|
|
2768
|
-
const result = execute(input, options);
|
|
3291
|
+
const result = tool2.execute(input, options);
|
|
2769
3292
|
if (isAsyncIterable(result)) {
|
|
2770
3293
|
let lastOutput;
|
|
2771
3294
|
for await (const output of result) {
|
|
@@ -2778,20 +3301,32 @@ async function* executeTool({
|
|
|
2778
3301
|
}
|
|
2779
3302
|
}
|
|
2780
3303
|
|
|
3304
|
+
// src/types/executable-tool.ts
|
|
3305
|
+
function isExecutableTool(tool2) {
|
|
3306
|
+
return tool2 != null && typeof tool2.execute === "function";
|
|
3307
|
+
}
|
|
3308
|
+
|
|
2781
3309
|
// src/index.ts
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
3310
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@workflow/serde";
|
|
3311
|
+
import {
|
|
3312
|
+
EventSourceParserStream as EventSourceParserStream2
|
|
3313
|
+
} from "eventsource-parser/stream";
|
|
3314
|
+
export {
|
|
2785
3315
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
2786
3316
|
DelayedPromise,
|
|
2787
3317
|
DownloadError,
|
|
2788
|
-
EventSourceParserStream,
|
|
3318
|
+
EventSourceParserStream2 as EventSourceParserStream,
|
|
3319
|
+
StreamingToolCallTracker,
|
|
2789
3320
|
VERSION,
|
|
3321
|
+
WORKFLOW_DESERIALIZE,
|
|
3322
|
+
WORKFLOW_SERIALIZE,
|
|
3323
|
+
asArray,
|
|
2790
3324
|
asSchema,
|
|
2791
3325
|
combineHeaders,
|
|
2792
3326
|
convertAsyncIteratorToReadableStream,
|
|
2793
3327
|
convertBase64ToUint8Array,
|
|
2794
3328
|
convertImageModelFileToDataUri,
|
|
3329
|
+
convertInlineFileDataToUint8Array,
|
|
2795
3330
|
convertToBase64,
|
|
2796
3331
|
convertToFormData,
|
|
2797
3332
|
convertUint8ArrayToBase64,
|
|
@@ -2800,29 +3335,40 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2800
3335
|
createIdGenerator,
|
|
2801
3336
|
createJsonErrorResponseHandler,
|
|
2802
3337
|
createJsonResponseHandler,
|
|
2803
|
-
|
|
2804
|
-
|
|
3338
|
+
createProviderDefinedToolFactory,
|
|
3339
|
+
createProviderDefinedToolFactoryWithOutputSchema,
|
|
3340
|
+
createProviderExecutedToolFactory,
|
|
2805
3341
|
createStatusCodeErrorResponseHandler,
|
|
2806
3342
|
createToolNameMapping,
|
|
2807
3343
|
delay,
|
|
3344
|
+
detectMediaType,
|
|
2808
3345
|
downloadBlob,
|
|
2809
3346
|
dynamicTool,
|
|
2810
3347
|
executeTool,
|
|
2811
3348
|
extractResponseHeaders,
|
|
3349
|
+
filterNullable,
|
|
2812
3350
|
generateId,
|
|
2813
3351
|
getErrorMessage,
|
|
2814
3352
|
getFromApi,
|
|
2815
3353
|
getRuntimeEnvironmentUserAgent,
|
|
3354
|
+
getTopLevelMediaType,
|
|
2816
3355
|
injectJsonInstructionIntoMessages,
|
|
2817
3356
|
isAbortError,
|
|
3357
|
+
isBuffer,
|
|
3358
|
+
isCustomReasoning,
|
|
3359
|
+
isExecutableTool,
|
|
3360
|
+
isFullMediaType,
|
|
2818
3361
|
isNonNullable,
|
|
2819
3362
|
isParsableJson,
|
|
3363
|
+
isProviderReference,
|
|
2820
3364
|
isUrlSupported,
|
|
2821
3365
|
jsonSchema,
|
|
2822
3366
|
lazySchema,
|
|
2823
3367
|
loadApiKey,
|
|
2824
3368
|
loadOptionalSetting,
|
|
2825
3369
|
loadSetting,
|
|
3370
|
+
mapReasoningToProviderBudget,
|
|
3371
|
+
mapReasoningToProviderEffort,
|
|
2826
3372
|
mediaTypeToExtension,
|
|
2827
3373
|
normalizeHeaders,
|
|
2828
3374
|
parseJSON,
|
|
@@ -2834,8 +3380,11 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2834
3380
|
readResponseWithSizeLimit,
|
|
2835
3381
|
removeUndefinedEntries,
|
|
2836
3382
|
resolve,
|
|
3383
|
+
resolveFullMediaType,
|
|
3384
|
+
resolveProviderReference,
|
|
2837
3385
|
safeParseJSON,
|
|
2838
3386
|
safeValidateTypes,
|
|
3387
|
+
serializeModelOptions,
|
|
2839
3388
|
stripFileExtension,
|
|
2840
3389
|
tool,
|
|
2841
3390
|
validateDownloadUrl,
|
|
@@ -2843,5 +3392,5 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2843
3392
|
withUserAgentSuffix,
|
|
2844
3393
|
withoutTrailingSlash,
|
|
2845
3394
|
zodSchema
|
|
2846
|
-
}
|
|
3395
|
+
};
|
|
2847
3396
|
//# sourceMappingURL=index.js.map
|