@ai-sdk/provider-utils 4.0.0-beta.53 → 4.0.0-beta.55
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 +14 -0
- package/dist/index.d.mts +98 -3
- package/dist/index.d.ts +98 -3
- package/dist/index.js +214 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -82
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var
|
|
10
|
-
__defProp(target,
|
|
9
|
+
for (var name2 in all)
|
|
10
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -32,13 +32,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
34
|
DelayedPromise: () => DelayedPromise,
|
|
35
|
+
DownloadError: () => DownloadError,
|
|
35
36
|
EventSourceParserStream: () => import_stream2.EventSourceParserStream,
|
|
36
37
|
VERSION: () => VERSION,
|
|
37
38
|
asSchema: () => asSchema,
|
|
38
39
|
combineHeaders: () => combineHeaders,
|
|
39
40
|
convertAsyncIteratorToReadableStream: () => convertAsyncIteratorToReadableStream,
|
|
40
41
|
convertBase64ToUint8Array: () => convertBase64ToUint8Array,
|
|
42
|
+
convertImageModelFileToDataUri: () => convertImageModelFileToDataUri,
|
|
41
43
|
convertToBase64: () => convertToBase64,
|
|
44
|
+
convertToFormData: () => convertToFormData,
|
|
42
45
|
convertUint8ArrayToBase64: () => convertUint8ArrayToBase64,
|
|
43
46
|
createBinaryResponseHandler: () => createBinaryResponseHandler,
|
|
44
47
|
createEventSourceResponseHandler: () => createEventSourceResponseHandler,
|
|
@@ -50,6 +53,7 @@ __export(src_exports, {
|
|
|
50
53
|
createStatusCodeErrorResponseHandler: () => createStatusCodeErrorResponseHandler,
|
|
51
54
|
createToolNameMapping: () => createToolNameMapping,
|
|
52
55
|
delay: () => delay,
|
|
56
|
+
downloadBlob: () => downloadBlob,
|
|
53
57
|
dynamicTool: () => dynamicTool,
|
|
54
58
|
executeTool: () => executeTool,
|
|
55
59
|
extractResponseHeaders: () => extractResponseHeaders,
|
|
@@ -152,12 +156,12 @@ function createToolNameMapping({
|
|
|
152
156
|
}
|
|
153
157
|
return {
|
|
154
158
|
toProviderToolName: (customToolName) => {
|
|
155
|
-
var
|
|
156
|
-
return (
|
|
159
|
+
var _a2;
|
|
160
|
+
return (_a2 = customToolNameToProviderToolName[customToolName]) != null ? _a2 : customToolName;
|
|
157
161
|
},
|
|
158
162
|
toCustomToolName: (providerToolName) => {
|
|
159
|
-
var
|
|
160
|
-
return (
|
|
163
|
+
var _a2;
|
|
164
|
+
return (_a2 = providerToolNameToCustomToolName[providerToolName]) != null ? _a2 : providerToolName;
|
|
161
165
|
}
|
|
162
166
|
};
|
|
163
167
|
}
|
|
@@ -215,17 +219,17 @@ var DelayedPromise = class {
|
|
|
215
219
|
return this._promise;
|
|
216
220
|
}
|
|
217
221
|
resolve(value) {
|
|
218
|
-
var
|
|
222
|
+
var _a2;
|
|
219
223
|
this.status = { type: "resolved", value };
|
|
220
224
|
if (this._promise) {
|
|
221
|
-
(
|
|
225
|
+
(_a2 = this._resolve) == null ? void 0 : _a2.call(this, value);
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
reject(error) {
|
|
225
|
-
var
|
|
229
|
+
var _a2;
|
|
226
230
|
this.status = { type: "rejected", error };
|
|
227
231
|
if (this._promise) {
|
|
228
|
-
(
|
|
232
|
+
(_a2 = this._reject) == null ? void 0 : _a2.call(this, error);
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
isResolved() {
|
|
@@ -244,8 +248,101 @@ function extractResponseHeaders(response) {
|
|
|
244
248
|
return Object.fromEntries([...response.headers]);
|
|
245
249
|
}
|
|
246
250
|
|
|
247
|
-
// src/
|
|
251
|
+
// src/uint8-utils.ts
|
|
252
|
+
var { btoa, atob } = globalThis;
|
|
253
|
+
function convertBase64ToUint8Array(base64String) {
|
|
254
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
255
|
+
const latin1string = atob(base64Url);
|
|
256
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
257
|
+
}
|
|
258
|
+
function convertUint8ArrayToBase64(array) {
|
|
259
|
+
let latin1string = "";
|
|
260
|
+
for (let i = 0; i < array.length; i++) {
|
|
261
|
+
latin1string += String.fromCodePoint(array[i]);
|
|
262
|
+
}
|
|
263
|
+
return btoa(latin1string);
|
|
264
|
+
}
|
|
265
|
+
function convertToBase64(value) {
|
|
266
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/convert-image-model-file-to-data-uri.ts
|
|
270
|
+
function convertImageModelFileToDataUri(file) {
|
|
271
|
+
if (file.type === "url") return file.url;
|
|
272
|
+
return `data:${file.mediaType};base64,${typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data)}`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// src/convert-to-form-data.ts
|
|
276
|
+
function convertToFormData(input, options = {}) {
|
|
277
|
+
const { useArrayBrackets = true } = options;
|
|
278
|
+
const formData = new FormData();
|
|
279
|
+
for (const [key, value] of Object.entries(input)) {
|
|
280
|
+
if (value == null) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (Array.isArray(value)) {
|
|
284
|
+
if (value.length === 1) {
|
|
285
|
+
formData.append(key, value[0]);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
289
|
+
for (const item of value) {
|
|
290
|
+
formData.append(arrayKey, item);
|
|
291
|
+
}
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
formData.append(key, value);
|
|
295
|
+
}
|
|
296
|
+
return formData;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/download-error.ts
|
|
248
300
|
var import_provider = require("@ai-sdk/provider");
|
|
301
|
+
var name = "AI_DownloadError";
|
|
302
|
+
var marker = `vercel.ai.error.${name}`;
|
|
303
|
+
var symbol = Symbol.for(marker);
|
|
304
|
+
var _a, _b;
|
|
305
|
+
var DownloadError = class extends (_b = import_provider.AISDKError, _a = symbol, _b) {
|
|
306
|
+
constructor({
|
|
307
|
+
url,
|
|
308
|
+
statusCode,
|
|
309
|
+
statusText,
|
|
310
|
+
cause,
|
|
311
|
+
message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
|
|
312
|
+
}) {
|
|
313
|
+
super({ name, message, cause });
|
|
314
|
+
this[_a] = true;
|
|
315
|
+
this.url = url;
|
|
316
|
+
this.statusCode = statusCode;
|
|
317
|
+
this.statusText = statusText;
|
|
318
|
+
}
|
|
319
|
+
static isInstance(error) {
|
|
320
|
+
return import_provider.AISDKError.hasMarker(error, marker);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// src/download-blob.ts
|
|
325
|
+
async function downloadBlob(url) {
|
|
326
|
+
try {
|
|
327
|
+
const response = await fetch(url);
|
|
328
|
+
if (!response.ok) {
|
|
329
|
+
throw new DownloadError({
|
|
330
|
+
url,
|
|
331
|
+
statusCode: response.status,
|
|
332
|
+
statusText: response.statusText
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return await response.blob();
|
|
336
|
+
} catch (error) {
|
|
337
|
+
if (DownloadError.isInstance(error)) {
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
throw new DownloadError({ url, cause: error });
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/generate-id.ts
|
|
345
|
+
var import_provider2 = require("@ai-sdk/provider");
|
|
249
346
|
var createIdGenerator = ({
|
|
250
347
|
prefix,
|
|
251
348
|
size = 16,
|
|
@@ -264,7 +361,7 @@ var createIdGenerator = ({
|
|
|
264
361
|
return generator;
|
|
265
362
|
}
|
|
266
363
|
if (alphabet.includes(separator)) {
|
|
267
|
-
throw new
|
|
364
|
+
throw new import_provider2.InvalidArgumentError({
|
|
268
365
|
argument: "separator",
|
|
269
366
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
270
367
|
});
|
|
@@ -288,10 +385,10 @@ function getErrorMessage(error) {
|
|
|
288
385
|
}
|
|
289
386
|
|
|
290
387
|
// src/get-from-api.ts
|
|
291
|
-
var
|
|
388
|
+
var import_provider4 = require("@ai-sdk/provider");
|
|
292
389
|
|
|
293
390
|
// src/handle-fetch-error.ts
|
|
294
|
-
var
|
|
391
|
+
var import_provider3 = require("@ai-sdk/provider");
|
|
295
392
|
|
|
296
393
|
// src/is-abort-error.ts
|
|
297
394
|
function isAbortError(error) {
|
|
@@ -312,7 +409,7 @@ function handleFetchError({
|
|
|
312
409
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
313
410
|
const cause = error.cause;
|
|
314
411
|
if (cause != null) {
|
|
315
|
-
return new
|
|
412
|
+
return new import_provider3.APICallError({
|
|
316
413
|
message: `Cannot connect to API: ${cause.message}`,
|
|
317
414
|
cause,
|
|
318
415
|
url,
|
|
@@ -327,14 +424,14 @@ function handleFetchError({
|
|
|
327
424
|
|
|
328
425
|
// src/get-runtime-environment-user-agent.ts
|
|
329
426
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
330
|
-
var
|
|
427
|
+
var _a2, _b2, _c;
|
|
331
428
|
if (globalThisAny.window) {
|
|
332
429
|
return `runtime/browser`;
|
|
333
430
|
}
|
|
334
|
-
if ((
|
|
431
|
+
if ((_a2 = globalThisAny.navigator) == null ? void 0 : _a2.userAgent) {
|
|
335
432
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
336
433
|
}
|
|
337
|
-
if ((_c = (
|
|
434
|
+
if ((_c = (_b2 = globalThisAny.process) == null ? void 0 : _b2.versions) == null ? void 0 : _c.node) {
|
|
338
435
|
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
339
436
|
}
|
|
340
437
|
if (globalThisAny.EdgeRuntime) {
|
|
@@ -378,7 +475,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
378
475
|
}
|
|
379
476
|
|
|
380
477
|
// src/version.ts
|
|
381
|
-
var VERSION = true ? "4.0.0-beta.
|
|
478
|
+
var VERSION = true ? "4.0.0-beta.55" : "0.0.0-test";
|
|
382
479
|
|
|
383
480
|
// src/get-from-api.ts
|
|
384
481
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -388,10 +485,10 @@ var getFromApi = async ({
|
|
|
388
485
|
successfulResponseHandler,
|
|
389
486
|
failedResponseHandler,
|
|
390
487
|
abortSignal,
|
|
391
|
-
fetch = getOriginalFetch()
|
|
488
|
+
fetch: fetch2 = getOriginalFetch()
|
|
392
489
|
}) => {
|
|
393
490
|
try {
|
|
394
|
-
const response = await
|
|
491
|
+
const response = await fetch2(url, {
|
|
395
492
|
method: "GET",
|
|
396
493
|
headers: withUserAgentSuffix(
|
|
397
494
|
headers,
|
|
@@ -410,10 +507,10 @@ var getFromApi = async ({
|
|
|
410
507
|
requestBodyValues: {}
|
|
411
508
|
});
|
|
412
509
|
} catch (error) {
|
|
413
|
-
if (isAbortError(error) ||
|
|
510
|
+
if (isAbortError(error) || import_provider4.APICallError.isInstance(error)) {
|
|
414
511
|
throw error;
|
|
415
512
|
}
|
|
416
|
-
throw new
|
|
513
|
+
throw new import_provider4.APICallError({
|
|
417
514
|
message: "Failed to process error response",
|
|
418
515
|
cause: error,
|
|
419
516
|
statusCode: response.status,
|
|
@@ -432,11 +529,11 @@ var getFromApi = async ({
|
|
|
432
529
|
});
|
|
433
530
|
} catch (error) {
|
|
434
531
|
if (error instanceof Error) {
|
|
435
|
-
if (isAbortError(error) ||
|
|
532
|
+
if (isAbortError(error) || import_provider4.APICallError.isInstance(error)) {
|
|
436
533
|
throw error;
|
|
437
534
|
}
|
|
438
535
|
}
|
|
439
|
-
throw new
|
|
536
|
+
throw new import_provider4.APICallError({
|
|
440
537
|
message: "Failed to process successful response",
|
|
441
538
|
cause: error,
|
|
442
539
|
statusCode: response.status,
|
|
@@ -475,8 +572,8 @@ function injectJsonInstructionIntoMessages({
|
|
|
475
572
|
schemaPrefix,
|
|
476
573
|
schemaSuffix
|
|
477
574
|
}) {
|
|
478
|
-
var
|
|
479
|
-
const systemMessage = ((
|
|
575
|
+
var _a2, _b2;
|
|
576
|
+
const systemMessage = ((_a2 = messages[0]) == null ? void 0 : _a2.role) === "system" ? { ...messages[0] } : { role: "system", content: "" };
|
|
480
577
|
systemMessage.content = injectJsonInstruction({
|
|
481
578
|
prompt: systemMessage.content,
|
|
482
579
|
schema,
|
|
@@ -485,7 +582,7 @@ function injectJsonInstructionIntoMessages({
|
|
|
485
582
|
});
|
|
486
583
|
return [
|
|
487
584
|
systemMessage,
|
|
488
|
-
...((
|
|
585
|
+
...((_b2 = messages[0]) == null ? void 0 : _b2.role) === "system" ? messages.slice(1) : messages
|
|
489
586
|
];
|
|
490
587
|
}
|
|
491
588
|
|
|
@@ -509,7 +606,7 @@ function isUrlSupported({
|
|
|
509
606
|
}
|
|
510
607
|
|
|
511
608
|
// src/load-api-key.ts
|
|
512
|
-
var
|
|
609
|
+
var import_provider5 = require("@ai-sdk/provider");
|
|
513
610
|
function loadApiKey({
|
|
514
611
|
apiKey,
|
|
515
612
|
environmentVariableName,
|
|
@@ -520,23 +617,23 @@ function loadApiKey({
|
|
|
520
617
|
return apiKey;
|
|
521
618
|
}
|
|
522
619
|
if (apiKey != null) {
|
|
523
|
-
throw new
|
|
620
|
+
throw new import_provider5.LoadAPIKeyError({
|
|
524
621
|
message: `${description} API key must be a string.`
|
|
525
622
|
});
|
|
526
623
|
}
|
|
527
624
|
if (typeof process === "undefined") {
|
|
528
|
-
throw new
|
|
625
|
+
throw new import_provider5.LoadAPIKeyError({
|
|
529
626
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables is not supported in this environment.`
|
|
530
627
|
});
|
|
531
628
|
}
|
|
532
629
|
apiKey = process.env[environmentVariableName];
|
|
533
630
|
if (apiKey == null) {
|
|
534
|
-
throw new
|
|
631
|
+
throw new import_provider5.LoadAPIKeyError({
|
|
535
632
|
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter or the ${environmentVariableName} environment variable.`
|
|
536
633
|
});
|
|
537
634
|
}
|
|
538
635
|
if (typeof apiKey !== "string") {
|
|
539
|
-
throw new
|
|
636
|
+
throw new import_provider5.LoadAPIKeyError({
|
|
540
637
|
message: `${description} API key must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
541
638
|
});
|
|
542
639
|
}
|
|
@@ -562,7 +659,7 @@ function loadOptionalSetting({
|
|
|
562
659
|
}
|
|
563
660
|
|
|
564
661
|
// src/load-setting.ts
|
|
565
|
-
var
|
|
662
|
+
var import_provider6 = require("@ai-sdk/provider");
|
|
566
663
|
function loadSetting({
|
|
567
664
|
settingValue,
|
|
568
665
|
environmentVariableName,
|
|
@@ -573,23 +670,23 @@ function loadSetting({
|
|
|
573
670
|
return settingValue;
|
|
574
671
|
}
|
|
575
672
|
if (settingValue != null) {
|
|
576
|
-
throw new
|
|
673
|
+
throw new import_provider6.LoadSettingError({
|
|
577
674
|
message: `${description} setting must be a string.`
|
|
578
675
|
});
|
|
579
676
|
}
|
|
580
677
|
if (typeof process === "undefined") {
|
|
581
|
-
throw new
|
|
678
|
+
throw new import_provider6.LoadSettingError({
|
|
582
679
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter. Environment variables is not supported in this environment.`
|
|
583
680
|
});
|
|
584
681
|
}
|
|
585
682
|
settingValue = process.env[environmentVariableName];
|
|
586
683
|
if (settingValue == null) {
|
|
587
|
-
throw new
|
|
684
|
+
throw new import_provider6.LoadSettingError({
|
|
588
685
|
message: `${description} setting is missing. Pass it using the '${settingName}' parameter or the ${environmentVariableName} environment variable.`
|
|
589
686
|
});
|
|
590
687
|
}
|
|
591
688
|
if (typeof settingValue !== "string") {
|
|
592
|
-
throw new
|
|
689
|
+
throw new import_provider6.LoadSettingError({
|
|
593
690
|
message: `${description} setting must be a string. The value of the ${environmentVariableName} environment variable is not a string.`
|
|
594
691
|
});
|
|
595
692
|
}
|
|
@@ -598,19 +695,19 @@ function loadSetting({
|
|
|
598
695
|
|
|
599
696
|
// src/media-type-to-extension.ts
|
|
600
697
|
function mediaTypeToExtension(mediaType) {
|
|
601
|
-
var
|
|
698
|
+
var _a2;
|
|
602
699
|
const [_type, subtype = ""] = mediaType.toLowerCase().split("/");
|
|
603
|
-
return (
|
|
700
|
+
return (_a2 = {
|
|
604
701
|
mpeg: "mp3",
|
|
605
702
|
"x-wav": "wav",
|
|
606
703
|
opus: "ogg",
|
|
607
704
|
mp4: "m4a",
|
|
608
705
|
"x-m4a": "m4a"
|
|
609
|
-
}[subtype]) != null ?
|
|
706
|
+
}[subtype]) != null ? _a2 : subtype;
|
|
610
707
|
}
|
|
611
708
|
|
|
612
709
|
// src/parse-json.ts
|
|
613
|
-
var
|
|
710
|
+
var import_provider9 = require("@ai-sdk/provider");
|
|
614
711
|
|
|
615
712
|
// src/secure-json-parse.ts
|
|
616
713
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
@@ -662,10 +759,10 @@ function secureJsonParse(text) {
|
|
|
662
759
|
}
|
|
663
760
|
|
|
664
761
|
// src/validate-types.ts
|
|
665
|
-
var
|
|
762
|
+
var import_provider8 = require("@ai-sdk/provider");
|
|
666
763
|
|
|
667
764
|
// src/schema.ts
|
|
668
|
-
var
|
|
765
|
+
var import_provider7 = require("@ai-sdk/provider");
|
|
669
766
|
var z4 = __toESM(require("zod/v4"));
|
|
670
767
|
|
|
671
768
|
// src/add-additional-properties-to-json-schema.ts
|
|
@@ -739,11 +836,11 @@ function parseAnyDef() {
|
|
|
739
836
|
// src/to-json-schema/zod3-to-json-schema/parsers/array.ts
|
|
740
837
|
var import_v3 = require("zod/v3");
|
|
741
838
|
function parseArrayDef(def, refs) {
|
|
742
|
-
var
|
|
839
|
+
var _a2, _b2, _c;
|
|
743
840
|
const res = {
|
|
744
841
|
type: "array"
|
|
745
842
|
};
|
|
746
|
-
if (((
|
|
843
|
+
if (((_a2 = def.type) == null ? void 0 : _a2._def) && ((_c = (_b2 = def.type) == null ? void 0 : _b2._def) == null ? void 0 : _c.typeName) !== import_v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
747
844
|
res.items = parseDef(def.type._def, {
|
|
748
845
|
...refs,
|
|
749
846
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1134,8 +1231,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
1134
1231
|
return result;
|
|
1135
1232
|
}
|
|
1136
1233
|
function addFormat(schema, value, message, refs) {
|
|
1137
|
-
var
|
|
1138
|
-
if (schema.format || ((
|
|
1234
|
+
var _a2;
|
|
1235
|
+
if (schema.format || ((_a2 = schema.anyOf) == null ? void 0 : _a2.some((x) => x.format))) {
|
|
1139
1236
|
if (!schema.anyOf) {
|
|
1140
1237
|
schema.anyOf = [];
|
|
1141
1238
|
}
|
|
@@ -1154,8 +1251,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
1154
1251
|
}
|
|
1155
1252
|
}
|
|
1156
1253
|
function addPattern(schema, regex, message, refs) {
|
|
1157
|
-
var
|
|
1158
|
-
if (schema.pattern || ((
|
|
1254
|
+
var _a2;
|
|
1255
|
+
if (schema.pattern || ((_a2 = schema.allOf) == null ? void 0 : _a2.some((x) => x.pattern))) {
|
|
1159
1256
|
if (!schema.allOf) {
|
|
1160
1257
|
schema.allOf = [];
|
|
1161
1258
|
}
|
|
@@ -1174,7 +1271,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
1174
1271
|
}
|
|
1175
1272
|
}
|
|
1176
1273
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
1177
|
-
var
|
|
1274
|
+
var _a2;
|
|
1178
1275
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
1179
1276
|
return regex.source;
|
|
1180
1277
|
}
|
|
@@ -1204,7 +1301,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1204
1301
|
pattern += source[i];
|
|
1205
1302
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
1206
1303
|
inCharRange = false;
|
|
1207
|
-
} else if (source[i + 1] === "-" && ((
|
|
1304
|
+
} else if (source[i + 1] === "-" && ((_a2 = source[i + 2]) == null ? void 0 : _a2.match(/[a-z]/))) {
|
|
1208
1305
|
pattern += source[i];
|
|
1209
1306
|
inCharRange = true;
|
|
1210
1307
|
} else {
|
|
@@ -1258,15 +1355,15 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1258
1355
|
|
|
1259
1356
|
// src/to-json-schema/zod3-to-json-schema/parsers/record.ts
|
|
1260
1357
|
function parseRecordDef(def, refs) {
|
|
1261
|
-
var
|
|
1358
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
1262
1359
|
const schema = {
|
|
1263
1360
|
type: "object",
|
|
1264
|
-
additionalProperties: (
|
|
1361
|
+
additionalProperties: (_a2 = parseDef(def.valueType._def, {
|
|
1265
1362
|
...refs,
|
|
1266
1363
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1267
|
-
})) != null ?
|
|
1364
|
+
})) != null ? _a2 : refs.allowedAdditionalProperties
|
|
1268
1365
|
};
|
|
1269
|
-
if (((
|
|
1366
|
+
if (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) === import_v32.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1270
1367
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1271
1368
|
return {
|
|
1272
1369
|
...schema,
|
|
@@ -1539,8 +1636,8 @@ function safeIsOptional(schema) {
|
|
|
1539
1636
|
|
|
1540
1637
|
// src/to-json-schema/zod3-to-json-schema/parsers/optional.ts
|
|
1541
1638
|
var parseOptionalDef = (def, refs) => {
|
|
1542
|
-
var
|
|
1543
|
-
if (refs.currentPath.toString() === ((
|
|
1639
|
+
var _a2;
|
|
1640
|
+
if (refs.currentPath.toString() === ((_a2 = refs.propertyPath) == null ? void 0 : _a2.toString())) {
|
|
1544
1641
|
return parseDef(def.innerType._def, refs);
|
|
1545
1642
|
}
|
|
1546
1643
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -1737,10 +1834,10 @@ var getRelativePath = (pathA, pathB) => {
|
|
|
1737
1834
|
|
|
1738
1835
|
// src/to-json-schema/zod3-to-json-schema/parse-def.ts
|
|
1739
1836
|
function parseDef(def, refs, forceResolution = false) {
|
|
1740
|
-
var
|
|
1837
|
+
var _a2;
|
|
1741
1838
|
const seenItem = refs.seen.get(def);
|
|
1742
1839
|
if (refs.override) {
|
|
1743
|
-
const overrideResult = (
|
|
1840
|
+
const overrideResult = (_a2 = refs.override) == null ? void 0 : _a2.call(
|
|
1744
1841
|
refs,
|
|
1745
1842
|
def,
|
|
1746
1843
|
refs,
|
|
@@ -1808,11 +1905,11 @@ var getRefs = (options) => {
|
|
|
1808
1905
|
currentPath,
|
|
1809
1906
|
propertyPath: void 0,
|
|
1810
1907
|
seen: new Map(
|
|
1811
|
-
Object.entries(_options.definitions).map(([
|
|
1908
|
+
Object.entries(_options.definitions).map(([name2, def]) => [
|
|
1812
1909
|
def._def,
|
|
1813
1910
|
{
|
|
1814
1911
|
def: def._def,
|
|
1815
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
1912
|
+
path: [..._options.basePath, _options.definitionPath, name2],
|
|
1816
1913
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1817
1914
|
jsonSchema: void 0
|
|
1818
1915
|
}
|
|
@@ -1823,50 +1920,50 @@ var getRefs = (options) => {
|
|
|
1823
1920
|
|
|
1824
1921
|
// src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts
|
|
1825
1922
|
var zod3ToJsonSchema = (schema, options) => {
|
|
1826
|
-
var
|
|
1923
|
+
var _a2;
|
|
1827
1924
|
const refs = getRefs(options);
|
|
1828
1925
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
1829
|
-
(acc, [
|
|
1830
|
-
var
|
|
1926
|
+
(acc, [name3, schema2]) => {
|
|
1927
|
+
var _a3;
|
|
1831
1928
|
return {
|
|
1832
1929
|
...acc,
|
|
1833
|
-
[
|
|
1930
|
+
[name3]: (_a3 = parseDef(
|
|
1834
1931
|
schema2._def,
|
|
1835
1932
|
{
|
|
1836
1933
|
...refs,
|
|
1837
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1934
|
+
currentPath: [...refs.basePath, refs.definitionPath, name3]
|
|
1838
1935
|
},
|
|
1839
1936
|
true
|
|
1840
|
-
)) != null ?
|
|
1937
|
+
)) != null ? _a3 : parseAnyDef()
|
|
1841
1938
|
};
|
|
1842
1939
|
},
|
|
1843
1940
|
{}
|
|
1844
1941
|
) : void 0;
|
|
1845
|
-
const
|
|
1846
|
-
const main = (
|
|
1942
|
+
const name2 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
1943
|
+
const main = (_a2 = parseDef(
|
|
1847
1944
|
schema._def,
|
|
1848
|
-
|
|
1945
|
+
name2 === void 0 ? refs : {
|
|
1849
1946
|
...refs,
|
|
1850
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1947
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
1851
1948
|
},
|
|
1852
1949
|
false
|
|
1853
|
-
)) != null ?
|
|
1950
|
+
)) != null ? _a2 : parseAnyDef();
|
|
1854
1951
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1855
1952
|
if (title !== void 0) {
|
|
1856
1953
|
main.title = title;
|
|
1857
1954
|
}
|
|
1858
|
-
const combined =
|
|
1955
|
+
const combined = name2 === void 0 ? definitions ? {
|
|
1859
1956
|
...main,
|
|
1860
1957
|
[refs.definitionPath]: definitions
|
|
1861
1958
|
} : main : {
|
|
1862
1959
|
$ref: [
|
|
1863
1960
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1864
1961
|
refs.definitionPath,
|
|
1865
|
-
|
|
1962
|
+
name2
|
|
1866
1963
|
].join("/"),
|
|
1867
1964
|
[refs.definitionPath]: {
|
|
1868
1965
|
...definitions,
|
|
1869
|
-
[
|
|
1966
|
+
[name2]: main
|
|
1870
1967
|
}
|
|
1871
1968
|
};
|
|
1872
1969
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -1916,7 +2013,7 @@ function standardSchema(standardSchema2) {
|
|
|
1916
2013
|
const result = await standardSchema2["~standard"].validate(value);
|
|
1917
2014
|
return "value" in result ? { success: true, value: result.value } : {
|
|
1918
2015
|
success: false,
|
|
1919
|
-
error: new
|
|
2016
|
+
error: new import_provider7.TypeValidationError({
|
|
1920
2017
|
value,
|
|
1921
2018
|
cause: result.issues
|
|
1922
2019
|
})
|
|
@@ -1926,8 +2023,8 @@ function standardSchema(standardSchema2) {
|
|
|
1926
2023
|
);
|
|
1927
2024
|
}
|
|
1928
2025
|
function zod3Schema(zodSchema2, options) {
|
|
1929
|
-
var
|
|
1930
|
-
const useReferences = (
|
|
2026
|
+
var _a2;
|
|
2027
|
+
const useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;
|
|
1931
2028
|
return jsonSchema(
|
|
1932
2029
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1933
2030
|
() => zod3ToJsonSchema(zodSchema2, {
|
|
@@ -1942,8 +2039,8 @@ function zod3Schema(zodSchema2, options) {
|
|
|
1942
2039
|
);
|
|
1943
2040
|
}
|
|
1944
2041
|
function zod4Schema(zodSchema2, options) {
|
|
1945
|
-
var
|
|
1946
|
-
const useReferences = (
|
|
2042
|
+
var _a2;
|
|
2043
|
+
const useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;
|
|
1947
2044
|
return jsonSchema(
|
|
1948
2045
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1949
2046
|
() => addAdditionalPropertiesToJsonSchema(
|
|
@@ -1979,7 +2076,7 @@ async function validateTypes({
|
|
|
1979
2076
|
}) {
|
|
1980
2077
|
const result = await safeValidateTypes({ value, schema });
|
|
1981
2078
|
if (!result.success) {
|
|
1982
|
-
throw
|
|
2079
|
+
throw import_provider8.TypeValidationError.wrap({ value, cause: result.error });
|
|
1983
2080
|
}
|
|
1984
2081
|
return result.value;
|
|
1985
2082
|
}
|
|
@@ -1998,13 +2095,13 @@ async function safeValidateTypes({
|
|
|
1998
2095
|
}
|
|
1999
2096
|
return {
|
|
2000
2097
|
success: false,
|
|
2001
|
-
error:
|
|
2098
|
+
error: import_provider8.TypeValidationError.wrap({ value, cause: result.error }),
|
|
2002
2099
|
rawValue: value
|
|
2003
2100
|
};
|
|
2004
2101
|
} catch (error) {
|
|
2005
2102
|
return {
|
|
2006
2103
|
success: false,
|
|
2007
|
-
error:
|
|
2104
|
+
error: import_provider8.TypeValidationError.wrap({ value, cause: error }),
|
|
2008
2105
|
rawValue: value
|
|
2009
2106
|
};
|
|
2010
2107
|
}
|
|
@@ -2022,10 +2119,10 @@ async function parseJSON({
|
|
|
2022
2119
|
}
|
|
2023
2120
|
return validateTypes({ value, schema });
|
|
2024
2121
|
} catch (error) {
|
|
2025
|
-
if (
|
|
2122
|
+
if (import_provider9.JSONParseError.isInstance(error) || import_provider9.TypeValidationError.isInstance(error)) {
|
|
2026
2123
|
throw error;
|
|
2027
2124
|
}
|
|
2028
|
-
throw new
|
|
2125
|
+
throw new import_provider9.JSONParseError({ text, cause: error });
|
|
2029
2126
|
}
|
|
2030
2127
|
}
|
|
2031
2128
|
async function safeParseJSON({
|
|
@@ -2041,7 +2138,7 @@ async function safeParseJSON({
|
|
|
2041
2138
|
} catch (error) {
|
|
2042
2139
|
return {
|
|
2043
2140
|
success: false,
|
|
2044
|
-
error:
|
|
2141
|
+
error: import_provider9.JSONParseError.isInstance(error) ? error : new import_provider9.JSONParseError({ text, cause: error }),
|
|
2045
2142
|
rawValue: void 0
|
|
2046
2143
|
};
|
|
2047
2144
|
}
|
|
@@ -2074,7 +2171,7 @@ function parseJsonEventStream({
|
|
|
2074
2171
|
}
|
|
2075
2172
|
|
|
2076
2173
|
// src/parse-provider-options.ts
|
|
2077
|
-
var
|
|
2174
|
+
var import_provider10 = require("@ai-sdk/provider");
|
|
2078
2175
|
async function parseProviderOptions({
|
|
2079
2176
|
provider,
|
|
2080
2177
|
providerOptions,
|
|
@@ -2088,7 +2185,7 @@ async function parseProviderOptions({
|
|
|
2088
2185
|
schema
|
|
2089
2186
|
});
|
|
2090
2187
|
if (!parsedProviderOptions.success) {
|
|
2091
|
-
throw new
|
|
2188
|
+
throw new import_provider10.InvalidArgumentError({
|
|
2092
2189
|
argument: "providerOptions",
|
|
2093
2190
|
message: `invalid ${provider} provider options`,
|
|
2094
2191
|
cause: parsedProviderOptions.error
|
|
@@ -2098,7 +2195,7 @@ async function parseProviderOptions({
|
|
|
2098
2195
|
}
|
|
2099
2196
|
|
|
2100
2197
|
// src/post-to-api.ts
|
|
2101
|
-
var
|
|
2198
|
+
var import_provider11 = require("@ai-sdk/provider");
|
|
2102
2199
|
var getOriginalFetch2 = () => globalThis.fetch;
|
|
2103
2200
|
var postJsonToApi = async ({
|
|
2104
2201
|
url,
|
|
@@ -2107,7 +2204,7 @@ var postJsonToApi = async ({
|
|
|
2107
2204
|
failedResponseHandler,
|
|
2108
2205
|
successfulResponseHandler,
|
|
2109
2206
|
abortSignal,
|
|
2110
|
-
fetch
|
|
2207
|
+
fetch: fetch2
|
|
2111
2208
|
}) => postToApi({
|
|
2112
2209
|
url,
|
|
2113
2210
|
headers: {
|
|
@@ -2121,7 +2218,7 @@ var postJsonToApi = async ({
|
|
|
2121
2218
|
failedResponseHandler,
|
|
2122
2219
|
successfulResponseHandler,
|
|
2123
2220
|
abortSignal,
|
|
2124
|
-
fetch
|
|
2221
|
+
fetch: fetch2
|
|
2125
2222
|
});
|
|
2126
2223
|
var postFormDataToApi = async ({
|
|
2127
2224
|
url,
|
|
@@ -2130,7 +2227,7 @@ var postFormDataToApi = async ({
|
|
|
2130
2227
|
failedResponseHandler,
|
|
2131
2228
|
successfulResponseHandler,
|
|
2132
2229
|
abortSignal,
|
|
2133
|
-
fetch
|
|
2230
|
+
fetch: fetch2
|
|
2134
2231
|
}) => postToApi({
|
|
2135
2232
|
url,
|
|
2136
2233
|
headers,
|
|
@@ -2141,7 +2238,7 @@ var postFormDataToApi = async ({
|
|
|
2141
2238
|
failedResponseHandler,
|
|
2142
2239
|
successfulResponseHandler,
|
|
2143
2240
|
abortSignal,
|
|
2144
|
-
fetch
|
|
2241
|
+
fetch: fetch2
|
|
2145
2242
|
});
|
|
2146
2243
|
var postToApi = async ({
|
|
2147
2244
|
url,
|
|
@@ -2150,10 +2247,10 @@ var postToApi = async ({
|
|
|
2150
2247
|
successfulResponseHandler,
|
|
2151
2248
|
failedResponseHandler,
|
|
2152
2249
|
abortSignal,
|
|
2153
|
-
fetch = getOriginalFetch2()
|
|
2250
|
+
fetch: fetch2 = getOriginalFetch2()
|
|
2154
2251
|
}) => {
|
|
2155
2252
|
try {
|
|
2156
|
-
const response = await
|
|
2253
|
+
const response = await fetch2(url, {
|
|
2157
2254
|
method: "POST",
|
|
2158
2255
|
headers: withUserAgentSuffix(
|
|
2159
2256
|
headers,
|
|
@@ -2173,10 +2270,10 @@ var postToApi = async ({
|
|
|
2173
2270
|
requestBodyValues: body.values
|
|
2174
2271
|
});
|
|
2175
2272
|
} catch (error) {
|
|
2176
|
-
if (isAbortError(error) ||
|
|
2273
|
+
if (isAbortError(error) || import_provider11.APICallError.isInstance(error)) {
|
|
2177
2274
|
throw error;
|
|
2178
2275
|
}
|
|
2179
|
-
throw new
|
|
2276
|
+
throw new import_provider11.APICallError({
|
|
2180
2277
|
message: "Failed to process error response",
|
|
2181
2278
|
cause: error,
|
|
2182
2279
|
statusCode: response.status,
|
|
@@ -2195,11 +2292,11 @@ var postToApi = async ({
|
|
|
2195
2292
|
});
|
|
2196
2293
|
} catch (error) {
|
|
2197
2294
|
if (error instanceof Error) {
|
|
2198
|
-
if (isAbortError(error) ||
|
|
2295
|
+
if (isAbortError(error) || import_provider11.APICallError.isInstance(error)) {
|
|
2199
2296
|
throw error;
|
|
2200
2297
|
}
|
|
2201
2298
|
}
|
|
2202
|
-
throw new
|
|
2299
|
+
throw new import_provider11.APICallError({
|
|
2203
2300
|
message: "Failed to process successful response",
|
|
2204
2301
|
cause: error,
|
|
2205
2302
|
statusCode: response.status,
|
|
@@ -2252,7 +2349,8 @@ function createProviderToolFactory({
|
|
|
2252
2349
|
function createProviderToolFactoryWithOutputSchema({
|
|
2253
2350
|
id,
|
|
2254
2351
|
inputSchema,
|
|
2255
|
-
outputSchema
|
|
2352
|
+
outputSchema,
|
|
2353
|
+
supportsDeferredResults
|
|
2256
2354
|
}) {
|
|
2257
2355
|
return ({
|
|
2258
2356
|
execute,
|
|
@@ -2273,7 +2371,8 @@ function createProviderToolFactoryWithOutputSchema({
|
|
|
2273
2371
|
toModelOutput,
|
|
2274
2372
|
onInputStart,
|
|
2275
2373
|
onInputDelta,
|
|
2276
|
-
onInputAvailable
|
|
2374
|
+
onInputAvailable,
|
|
2375
|
+
supportsDeferredResults
|
|
2277
2376
|
});
|
|
2278
2377
|
}
|
|
2279
2378
|
|
|
@@ -2293,7 +2392,7 @@ async function resolve(value) {
|
|
|
2293
2392
|
}
|
|
2294
2393
|
|
|
2295
2394
|
// src/response-handler.ts
|
|
2296
|
-
var
|
|
2395
|
+
var import_provider12 = require("@ai-sdk/provider");
|
|
2297
2396
|
var createJsonErrorResponseHandler = ({
|
|
2298
2397
|
errorSchema,
|
|
2299
2398
|
errorToMessage,
|
|
@@ -2304,7 +2403,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2304
2403
|
if (responseBody.trim() === "") {
|
|
2305
2404
|
return {
|
|
2306
2405
|
responseHeaders,
|
|
2307
|
-
value: new
|
|
2406
|
+
value: new import_provider12.APICallError({
|
|
2308
2407
|
message: response.statusText,
|
|
2309
2408
|
url,
|
|
2310
2409
|
requestBodyValues,
|
|
@@ -2322,7 +2421,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2322
2421
|
});
|
|
2323
2422
|
return {
|
|
2324
2423
|
responseHeaders,
|
|
2325
|
-
value: new
|
|
2424
|
+
value: new import_provider12.APICallError({
|
|
2326
2425
|
message: errorToMessage(parsedError),
|
|
2327
2426
|
url,
|
|
2328
2427
|
requestBodyValues,
|
|
@@ -2336,7 +2435,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2336
2435
|
} catch (parseError) {
|
|
2337
2436
|
return {
|
|
2338
2437
|
responseHeaders,
|
|
2339
|
-
value: new
|
|
2438
|
+
value: new import_provider12.APICallError({
|
|
2340
2439
|
message: response.statusText,
|
|
2341
2440
|
url,
|
|
2342
2441
|
requestBodyValues,
|
|
@@ -2351,7 +2450,7 @@ var createJsonErrorResponseHandler = ({
|
|
|
2351
2450
|
var createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
|
|
2352
2451
|
const responseHeaders = extractResponseHeaders(response);
|
|
2353
2452
|
if (response.body == null) {
|
|
2354
|
-
throw new
|
|
2453
|
+
throw new import_provider12.EmptyResponseBodyError({});
|
|
2355
2454
|
}
|
|
2356
2455
|
return {
|
|
2357
2456
|
responseHeaders,
|
|
@@ -2369,7 +2468,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
2369
2468
|
});
|
|
2370
2469
|
const responseHeaders = extractResponseHeaders(response);
|
|
2371
2470
|
if (!parsedResult.success) {
|
|
2372
|
-
throw new
|
|
2471
|
+
throw new import_provider12.APICallError({
|
|
2373
2472
|
message: "Invalid JSON response",
|
|
2374
2473
|
cause: parsedResult.error,
|
|
2375
2474
|
statusCode: response.status,
|
|
@@ -2388,7 +2487,7 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
|
|
|
2388
2487
|
var createBinaryResponseHandler = () => async ({ response, url, requestBodyValues }) => {
|
|
2389
2488
|
const responseHeaders = extractResponseHeaders(response);
|
|
2390
2489
|
if (!response.body) {
|
|
2391
|
-
throw new
|
|
2490
|
+
throw new import_provider12.APICallError({
|
|
2392
2491
|
message: "Response body is empty",
|
|
2393
2492
|
url,
|
|
2394
2493
|
requestBodyValues,
|
|
@@ -2404,7 +2503,7 @@ var createBinaryResponseHandler = () => async ({ response, url, requestBodyValue
|
|
|
2404
2503
|
value: new Uint8Array(buffer)
|
|
2405
2504
|
};
|
|
2406
2505
|
} catch (error) {
|
|
2407
|
-
throw new
|
|
2506
|
+
throw new import_provider12.APICallError({
|
|
2408
2507
|
message: "Failed to read response as array buffer",
|
|
2409
2508
|
url,
|
|
2410
2509
|
requestBodyValues,
|
|
@@ -2420,7 +2519,7 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2420
2519
|
const responseBody = await response.text();
|
|
2421
2520
|
return {
|
|
2422
2521
|
responseHeaders,
|
|
2423
|
-
value: new
|
|
2522
|
+
value: new import_provider12.APICallError({
|
|
2424
2523
|
message: response.statusText,
|
|
2425
2524
|
url,
|
|
2426
2525
|
requestBodyValues,
|
|
@@ -2431,24 +2530,6 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2431
2530
|
};
|
|
2432
2531
|
};
|
|
2433
2532
|
|
|
2434
|
-
// src/uint8-utils.ts
|
|
2435
|
-
var { btoa, atob } = globalThis;
|
|
2436
|
-
function convertBase64ToUint8Array(base64String) {
|
|
2437
|
-
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
2438
|
-
const latin1string = atob(base64Url);
|
|
2439
|
-
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
2440
|
-
}
|
|
2441
|
-
function convertUint8ArrayToBase64(array) {
|
|
2442
|
-
let latin1string = "";
|
|
2443
|
-
for (let i = 0; i < array.length; i++) {
|
|
2444
|
-
latin1string += String.fromCodePoint(array[i]);
|
|
2445
|
-
}
|
|
2446
|
-
return btoa(latin1string);
|
|
2447
|
-
}
|
|
2448
|
-
function convertToBase64(value) {
|
|
2449
|
-
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
2533
|
// src/without-trailing-slash.ts
|
|
2453
2534
|
function withoutTrailingSlash(url) {
|
|
2454
2535
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
@@ -2484,13 +2565,16 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2484
2565
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2485
2566
|
0 && (module.exports = {
|
|
2486
2567
|
DelayedPromise,
|
|
2568
|
+
DownloadError,
|
|
2487
2569
|
EventSourceParserStream,
|
|
2488
2570
|
VERSION,
|
|
2489
2571
|
asSchema,
|
|
2490
2572
|
combineHeaders,
|
|
2491
2573
|
convertAsyncIteratorToReadableStream,
|
|
2492
2574
|
convertBase64ToUint8Array,
|
|
2575
|
+
convertImageModelFileToDataUri,
|
|
2493
2576
|
convertToBase64,
|
|
2577
|
+
convertToFormData,
|
|
2494
2578
|
convertUint8ArrayToBase64,
|
|
2495
2579
|
createBinaryResponseHandler,
|
|
2496
2580
|
createEventSourceResponseHandler,
|
|
@@ -2502,6 +2586,7 @@ var import_stream2 = require("eventsource-parser/stream");
|
|
|
2502
2586
|
createStatusCodeErrorResponseHandler,
|
|
2503
2587
|
createToolNameMapping,
|
|
2504
2588
|
delay,
|
|
2589
|
+
downloadBlob,
|
|
2505
2590
|
dynamicTool,
|
|
2506
2591
|
executeTool,
|
|
2507
2592
|
extractResponseHeaders,
|