@ai-sdk/provider-utils 4.0.0-beta.53 → 4.0.0-beta.54
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 +8 -0
- package/dist/index.d.mts +72 -2
- package/dist/index.d.ts +72 -2
- package/dist/index.js +210 -127
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -80
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -63,12 +63,12 @@ function createToolNameMapping({
|
|
|
63
63
|
}
|
|
64
64
|
return {
|
|
65
65
|
toProviderToolName: (customToolName) => {
|
|
66
|
-
var
|
|
67
|
-
return (
|
|
66
|
+
var _a2;
|
|
67
|
+
return (_a2 = customToolNameToProviderToolName[customToolName]) != null ? _a2 : customToolName;
|
|
68
68
|
},
|
|
69
69
|
toCustomToolName: (providerToolName) => {
|
|
70
|
-
var
|
|
71
|
-
return (
|
|
70
|
+
var _a2;
|
|
71
|
+
return (_a2 = providerToolNameToCustomToolName[providerToolName]) != null ? _a2 : providerToolName;
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
}
|
|
@@ -126,17 +126,17 @@ var DelayedPromise = class {
|
|
|
126
126
|
return this._promise;
|
|
127
127
|
}
|
|
128
128
|
resolve(value) {
|
|
129
|
-
var
|
|
129
|
+
var _a2;
|
|
130
130
|
this.status = { type: "resolved", value };
|
|
131
131
|
if (this._promise) {
|
|
132
|
-
(
|
|
132
|
+
(_a2 = this._resolve) == null ? void 0 : _a2.call(this, value);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
reject(error) {
|
|
136
|
-
var
|
|
136
|
+
var _a2;
|
|
137
137
|
this.status = { type: "rejected", error };
|
|
138
138
|
if (this._promise) {
|
|
139
|
-
(
|
|
139
|
+
(_a2 = this._reject) == null ? void 0 : _a2.call(this, error);
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
isResolved() {
|
|
@@ -155,6 +155,99 @@ function extractResponseHeaders(response) {
|
|
|
155
155
|
return Object.fromEntries([...response.headers]);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
// src/uint8-utils.ts
|
|
159
|
+
var { btoa, atob } = globalThis;
|
|
160
|
+
function convertBase64ToUint8Array(base64String) {
|
|
161
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
162
|
+
const latin1string = atob(base64Url);
|
|
163
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
164
|
+
}
|
|
165
|
+
function convertUint8ArrayToBase64(array) {
|
|
166
|
+
let latin1string = "";
|
|
167
|
+
for (let i = 0; i < array.length; i++) {
|
|
168
|
+
latin1string += String.fromCodePoint(array[i]);
|
|
169
|
+
}
|
|
170
|
+
return btoa(latin1string);
|
|
171
|
+
}
|
|
172
|
+
function convertToBase64(value) {
|
|
173
|
+
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// src/convert-image-model-file-to-data-uri.ts
|
|
177
|
+
function convertImageModelFileToDataUri(file) {
|
|
178
|
+
if (file.type === "url") return file.url;
|
|
179
|
+
return `data:${file.mediaType};base64,${typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data)}`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/convert-to-form-data.ts
|
|
183
|
+
function convertToFormData(input, options = {}) {
|
|
184
|
+
const { useArrayBrackets = true } = options;
|
|
185
|
+
const formData = new FormData();
|
|
186
|
+
for (const [key, value] of Object.entries(input)) {
|
|
187
|
+
if (value == null) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (Array.isArray(value)) {
|
|
191
|
+
if (value.length === 1) {
|
|
192
|
+
formData.append(key, value[0]);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
196
|
+
for (const item of value) {
|
|
197
|
+
formData.append(arrayKey, item);
|
|
198
|
+
}
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
formData.append(key, value);
|
|
202
|
+
}
|
|
203
|
+
return formData;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/download-error.ts
|
|
207
|
+
import { AISDKError } from "@ai-sdk/provider";
|
|
208
|
+
var name = "AI_DownloadError";
|
|
209
|
+
var marker = `vercel.ai.error.${name}`;
|
|
210
|
+
var symbol = Symbol.for(marker);
|
|
211
|
+
var _a, _b;
|
|
212
|
+
var DownloadError = class extends (_b = AISDKError, _a = symbol, _b) {
|
|
213
|
+
constructor({
|
|
214
|
+
url,
|
|
215
|
+
statusCode,
|
|
216
|
+
statusText,
|
|
217
|
+
cause,
|
|
218
|
+
message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
|
|
219
|
+
}) {
|
|
220
|
+
super({ name, message, cause });
|
|
221
|
+
this[_a] = true;
|
|
222
|
+
this.url = url;
|
|
223
|
+
this.statusCode = statusCode;
|
|
224
|
+
this.statusText = statusText;
|
|
225
|
+
}
|
|
226
|
+
static isInstance(error) {
|
|
227
|
+
return AISDKError.hasMarker(error, marker);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/download-blob.ts
|
|
232
|
+
async function downloadBlob(url) {
|
|
233
|
+
try {
|
|
234
|
+
const response = await fetch(url);
|
|
235
|
+
if (!response.ok) {
|
|
236
|
+
throw new DownloadError({
|
|
237
|
+
url,
|
|
238
|
+
statusCode: response.status,
|
|
239
|
+
statusText: response.statusText
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return await response.blob();
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (DownloadError.isInstance(error)) {
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
throw new DownloadError({ url, cause: error });
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
158
251
|
// src/generate-id.ts
|
|
159
252
|
import { InvalidArgumentError } from "@ai-sdk/provider";
|
|
160
253
|
var createIdGenerator = ({
|
|
@@ -238,14 +331,14 @@ function handleFetchError({
|
|
|
238
331
|
|
|
239
332
|
// src/get-runtime-environment-user-agent.ts
|
|
240
333
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
241
|
-
var
|
|
334
|
+
var _a2, _b2, _c;
|
|
242
335
|
if (globalThisAny.window) {
|
|
243
336
|
return `runtime/browser`;
|
|
244
337
|
}
|
|
245
|
-
if ((
|
|
338
|
+
if ((_a2 = globalThisAny.navigator) == null ? void 0 : _a2.userAgent) {
|
|
246
339
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
247
340
|
}
|
|
248
|
-
if ((_c = (
|
|
341
|
+
if ((_c = (_b2 = globalThisAny.process) == null ? void 0 : _b2.versions) == null ? void 0 : _c.node) {
|
|
249
342
|
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
250
343
|
}
|
|
251
344
|
if (globalThisAny.EdgeRuntime) {
|
|
@@ -289,7 +382,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
289
382
|
}
|
|
290
383
|
|
|
291
384
|
// src/version.ts
|
|
292
|
-
var VERSION = true ? "4.0.0-beta.
|
|
385
|
+
var VERSION = true ? "4.0.0-beta.54" : "0.0.0-test";
|
|
293
386
|
|
|
294
387
|
// src/get-from-api.ts
|
|
295
388
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -299,10 +392,10 @@ var getFromApi = async ({
|
|
|
299
392
|
successfulResponseHandler,
|
|
300
393
|
failedResponseHandler,
|
|
301
394
|
abortSignal,
|
|
302
|
-
fetch = getOriginalFetch()
|
|
395
|
+
fetch: fetch2 = getOriginalFetch()
|
|
303
396
|
}) => {
|
|
304
397
|
try {
|
|
305
|
-
const response = await
|
|
398
|
+
const response = await fetch2(url, {
|
|
306
399
|
method: "GET",
|
|
307
400
|
headers: withUserAgentSuffix(
|
|
308
401
|
headers,
|
|
@@ -386,8 +479,8 @@ function injectJsonInstructionIntoMessages({
|
|
|
386
479
|
schemaPrefix,
|
|
387
480
|
schemaSuffix
|
|
388
481
|
}) {
|
|
389
|
-
var
|
|
390
|
-
const systemMessage = ((
|
|
482
|
+
var _a2, _b2;
|
|
483
|
+
const systemMessage = ((_a2 = messages[0]) == null ? void 0 : _a2.role) === "system" ? { ...messages[0] } : { role: "system", content: "" };
|
|
391
484
|
systemMessage.content = injectJsonInstruction({
|
|
392
485
|
prompt: systemMessage.content,
|
|
393
486
|
schema,
|
|
@@ -396,7 +489,7 @@ function injectJsonInstructionIntoMessages({
|
|
|
396
489
|
});
|
|
397
490
|
return [
|
|
398
491
|
systemMessage,
|
|
399
|
-
...((
|
|
492
|
+
...((_b2 = messages[0]) == null ? void 0 : _b2.role) === "system" ? messages.slice(1) : messages
|
|
400
493
|
];
|
|
401
494
|
}
|
|
402
495
|
|
|
@@ -509,15 +602,15 @@ function loadSetting({
|
|
|
509
602
|
|
|
510
603
|
// src/media-type-to-extension.ts
|
|
511
604
|
function mediaTypeToExtension(mediaType) {
|
|
512
|
-
var
|
|
605
|
+
var _a2;
|
|
513
606
|
const [_type, subtype = ""] = mediaType.toLowerCase().split("/");
|
|
514
|
-
return (
|
|
607
|
+
return (_a2 = {
|
|
515
608
|
mpeg: "mp3",
|
|
516
609
|
"x-wav": "wav",
|
|
517
610
|
opus: "ogg",
|
|
518
611
|
mp4: "m4a",
|
|
519
612
|
"x-m4a": "m4a"
|
|
520
|
-
}[subtype]) != null ?
|
|
613
|
+
}[subtype]) != null ? _a2 : subtype;
|
|
521
614
|
}
|
|
522
615
|
|
|
523
616
|
// src/parse-json.ts
|
|
@@ -653,11 +746,11 @@ function parseAnyDef() {
|
|
|
653
746
|
// src/to-json-schema/zod3-to-json-schema/parsers/array.ts
|
|
654
747
|
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
655
748
|
function parseArrayDef(def, refs) {
|
|
656
|
-
var
|
|
749
|
+
var _a2, _b2, _c;
|
|
657
750
|
const res = {
|
|
658
751
|
type: "array"
|
|
659
752
|
};
|
|
660
|
-
if (((
|
|
753
|
+
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) {
|
|
661
754
|
res.items = parseDef(def.type._def, {
|
|
662
755
|
...refs,
|
|
663
756
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1050,8 +1143,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
1050
1143
|
return result;
|
|
1051
1144
|
}
|
|
1052
1145
|
function addFormat(schema, value, message, refs) {
|
|
1053
|
-
var
|
|
1054
|
-
if (schema.format || ((
|
|
1146
|
+
var _a2;
|
|
1147
|
+
if (schema.format || ((_a2 = schema.anyOf) == null ? void 0 : _a2.some((x) => x.format))) {
|
|
1055
1148
|
if (!schema.anyOf) {
|
|
1056
1149
|
schema.anyOf = [];
|
|
1057
1150
|
}
|
|
@@ -1070,8 +1163,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
1070
1163
|
}
|
|
1071
1164
|
}
|
|
1072
1165
|
function addPattern(schema, regex, message, refs) {
|
|
1073
|
-
var
|
|
1074
|
-
if (schema.pattern || ((
|
|
1166
|
+
var _a2;
|
|
1167
|
+
if (schema.pattern || ((_a2 = schema.allOf) == null ? void 0 : _a2.some((x) => x.pattern))) {
|
|
1075
1168
|
if (!schema.allOf) {
|
|
1076
1169
|
schema.allOf = [];
|
|
1077
1170
|
}
|
|
@@ -1090,7 +1183,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
1090
1183
|
}
|
|
1091
1184
|
}
|
|
1092
1185
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
1093
|
-
var
|
|
1186
|
+
var _a2;
|
|
1094
1187
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
1095
1188
|
return regex.source;
|
|
1096
1189
|
}
|
|
@@ -1120,7 +1213,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1120
1213
|
pattern += source[i];
|
|
1121
1214
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
1122
1215
|
inCharRange = false;
|
|
1123
|
-
} else if (source[i + 1] === "-" && ((
|
|
1216
|
+
} else if (source[i + 1] === "-" && ((_a2 = source[i + 2]) == null ? void 0 : _a2.match(/[a-z]/))) {
|
|
1124
1217
|
pattern += source[i];
|
|
1125
1218
|
inCharRange = true;
|
|
1126
1219
|
} else {
|
|
@@ -1174,15 +1267,15 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
1174
1267
|
|
|
1175
1268
|
// src/to-json-schema/zod3-to-json-schema/parsers/record.ts
|
|
1176
1269
|
function parseRecordDef(def, refs) {
|
|
1177
|
-
var
|
|
1270
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
1178
1271
|
const schema = {
|
|
1179
1272
|
type: "object",
|
|
1180
|
-
additionalProperties: (
|
|
1273
|
+
additionalProperties: (_a2 = parseDef(def.valueType._def, {
|
|
1181
1274
|
...refs,
|
|
1182
1275
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
1183
|
-
})) != null ?
|
|
1276
|
+
})) != null ? _a2 : refs.allowedAdditionalProperties
|
|
1184
1277
|
};
|
|
1185
|
-
if (((
|
|
1278
|
+
if (((_b2 = def.keyType) == null ? void 0 : _b2._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
1186
1279
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1187
1280
|
return {
|
|
1188
1281
|
...schema,
|
|
@@ -1455,8 +1548,8 @@ function safeIsOptional(schema) {
|
|
|
1455
1548
|
|
|
1456
1549
|
// src/to-json-schema/zod3-to-json-schema/parsers/optional.ts
|
|
1457
1550
|
var parseOptionalDef = (def, refs) => {
|
|
1458
|
-
var
|
|
1459
|
-
if (refs.currentPath.toString() === ((
|
|
1551
|
+
var _a2;
|
|
1552
|
+
if (refs.currentPath.toString() === ((_a2 = refs.propertyPath) == null ? void 0 : _a2.toString())) {
|
|
1460
1553
|
return parseDef(def.innerType._def, refs);
|
|
1461
1554
|
}
|
|
1462
1555
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -1653,10 +1746,10 @@ var getRelativePath = (pathA, pathB) => {
|
|
|
1653
1746
|
|
|
1654
1747
|
// src/to-json-schema/zod3-to-json-schema/parse-def.ts
|
|
1655
1748
|
function parseDef(def, refs, forceResolution = false) {
|
|
1656
|
-
var
|
|
1749
|
+
var _a2;
|
|
1657
1750
|
const seenItem = refs.seen.get(def);
|
|
1658
1751
|
if (refs.override) {
|
|
1659
|
-
const overrideResult = (
|
|
1752
|
+
const overrideResult = (_a2 = refs.override) == null ? void 0 : _a2.call(
|
|
1660
1753
|
refs,
|
|
1661
1754
|
def,
|
|
1662
1755
|
refs,
|
|
@@ -1724,11 +1817,11 @@ var getRefs = (options) => {
|
|
|
1724
1817
|
currentPath,
|
|
1725
1818
|
propertyPath: void 0,
|
|
1726
1819
|
seen: new Map(
|
|
1727
|
-
Object.entries(_options.definitions).map(([
|
|
1820
|
+
Object.entries(_options.definitions).map(([name2, def]) => [
|
|
1728
1821
|
def._def,
|
|
1729
1822
|
{
|
|
1730
1823
|
def: def._def,
|
|
1731
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
1824
|
+
path: [..._options.basePath, _options.definitionPath, name2],
|
|
1732
1825
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
1733
1826
|
jsonSchema: void 0
|
|
1734
1827
|
}
|
|
@@ -1739,50 +1832,50 @@ var getRefs = (options) => {
|
|
|
1739
1832
|
|
|
1740
1833
|
// src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts
|
|
1741
1834
|
var zod3ToJsonSchema = (schema, options) => {
|
|
1742
|
-
var
|
|
1835
|
+
var _a2;
|
|
1743
1836
|
const refs = getRefs(options);
|
|
1744
1837
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
1745
|
-
(acc, [
|
|
1746
|
-
var
|
|
1838
|
+
(acc, [name3, schema2]) => {
|
|
1839
|
+
var _a3;
|
|
1747
1840
|
return {
|
|
1748
1841
|
...acc,
|
|
1749
|
-
[
|
|
1842
|
+
[name3]: (_a3 = parseDef(
|
|
1750
1843
|
schema2._def,
|
|
1751
1844
|
{
|
|
1752
1845
|
...refs,
|
|
1753
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1846
|
+
currentPath: [...refs.basePath, refs.definitionPath, name3]
|
|
1754
1847
|
},
|
|
1755
1848
|
true
|
|
1756
|
-
)) != null ?
|
|
1849
|
+
)) != null ? _a3 : parseAnyDef()
|
|
1757
1850
|
};
|
|
1758
1851
|
},
|
|
1759
1852
|
{}
|
|
1760
1853
|
) : void 0;
|
|
1761
|
-
const
|
|
1762
|
-
const main = (
|
|
1854
|
+
const name2 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
1855
|
+
const main = (_a2 = parseDef(
|
|
1763
1856
|
schema._def,
|
|
1764
|
-
|
|
1857
|
+
name2 === void 0 ? refs : {
|
|
1765
1858
|
...refs,
|
|
1766
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1859
|
+
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
1767
1860
|
},
|
|
1768
1861
|
false
|
|
1769
|
-
)) != null ?
|
|
1862
|
+
)) != null ? _a2 : parseAnyDef();
|
|
1770
1863
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1771
1864
|
if (title !== void 0) {
|
|
1772
1865
|
main.title = title;
|
|
1773
1866
|
}
|
|
1774
|
-
const combined =
|
|
1867
|
+
const combined = name2 === void 0 ? definitions ? {
|
|
1775
1868
|
...main,
|
|
1776
1869
|
[refs.definitionPath]: definitions
|
|
1777
1870
|
} : main : {
|
|
1778
1871
|
$ref: [
|
|
1779
1872
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1780
1873
|
refs.definitionPath,
|
|
1781
|
-
|
|
1874
|
+
name2
|
|
1782
1875
|
].join("/"),
|
|
1783
1876
|
[refs.definitionPath]: {
|
|
1784
1877
|
...definitions,
|
|
1785
|
-
[
|
|
1878
|
+
[name2]: main
|
|
1786
1879
|
}
|
|
1787
1880
|
};
|
|
1788
1881
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -1842,8 +1935,8 @@ function standardSchema(standardSchema2) {
|
|
|
1842
1935
|
);
|
|
1843
1936
|
}
|
|
1844
1937
|
function zod3Schema(zodSchema2, options) {
|
|
1845
|
-
var
|
|
1846
|
-
const useReferences = (
|
|
1938
|
+
var _a2;
|
|
1939
|
+
const useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;
|
|
1847
1940
|
return jsonSchema(
|
|
1848
1941
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1849
1942
|
() => zod3ToJsonSchema(zodSchema2, {
|
|
@@ -1858,8 +1951,8 @@ function zod3Schema(zodSchema2, options) {
|
|
|
1858
1951
|
);
|
|
1859
1952
|
}
|
|
1860
1953
|
function zod4Schema(zodSchema2, options) {
|
|
1861
|
-
var
|
|
1862
|
-
const useReferences = (
|
|
1954
|
+
var _a2;
|
|
1955
|
+
const useReferences = (_a2 = options == null ? void 0 : options.useReferences) != null ? _a2 : false;
|
|
1863
1956
|
return jsonSchema(
|
|
1864
1957
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1865
1958
|
() => addAdditionalPropertiesToJsonSchema(
|
|
@@ -2025,7 +2118,7 @@ var postJsonToApi = async ({
|
|
|
2025
2118
|
failedResponseHandler,
|
|
2026
2119
|
successfulResponseHandler,
|
|
2027
2120
|
abortSignal,
|
|
2028
|
-
fetch
|
|
2121
|
+
fetch: fetch2
|
|
2029
2122
|
}) => postToApi({
|
|
2030
2123
|
url,
|
|
2031
2124
|
headers: {
|
|
@@ -2039,7 +2132,7 @@ var postJsonToApi = async ({
|
|
|
2039
2132
|
failedResponseHandler,
|
|
2040
2133
|
successfulResponseHandler,
|
|
2041
2134
|
abortSignal,
|
|
2042
|
-
fetch
|
|
2135
|
+
fetch: fetch2
|
|
2043
2136
|
});
|
|
2044
2137
|
var postFormDataToApi = async ({
|
|
2045
2138
|
url,
|
|
@@ -2048,7 +2141,7 @@ var postFormDataToApi = async ({
|
|
|
2048
2141
|
failedResponseHandler,
|
|
2049
2142
|
successfulResponseHandler,
|
|
2050
2143
|
abortSignal,
|
|
2051
|
-
fetch
|
|
2144
|
+
fetch: fetch2
|
|
2052
2145
|
}) => postToApi({
|
|
2053
2146
|
url,
|
|
2054
2147
|
headers,
|
|
@@ -2059,7 +2152,7 @@ var postFormDataToApi = async ({
|
|
|
2059
2152
|
failedResponseHandler,
|
|
2060
2153
|
successfulResponseHandler,
|
|
2061
2154
|
abortSignal,
|
|
2062
|
-
fetch
|
|
2155
|
+
fetch: fetch2
|
|
2063
2156
|
});
|
|
2064
2157
|
var postToApi = async ({
|
|
2065
2158
|
url,
|
|
@@ -2068,10 +2161,10 @@ var postToApi = async ({
|
|
|
2068
2161
|
successfulResponseHandler,
|
|
2069
2162
|
failedResponseHandler,
|
|
2070
2163
|
abortSignal,
|
|
2071
|
-
fetch = getOriginalFetch2()
|
|
2164
|
+
fetch: fetch2 = getOriginalFetch2()
|
|
2072
2165
|
}) => {
|
|
2073
2166
|
try {
|
|
2074
|
-
const response = await
|
|
2167
|
+
const response = await fetch2(url, {
|
|
2075
2168
|
method: "POST",
|
|
2076
2169
|
headers: withUserAgentSuffix(
|
|
2077
2170
|
headers,
|
|
@@ -2349,24 +2442,6 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
2349
2442
|
};
|
|
2350
2443
|
};
|
|
2351
2444
|
|
|
2352
|
-
// src/uint8-utils.ts
|
|
2353
|
-
var { btoa, atob } = globalThis;
|
|
2354
|
-
function convertBase64ToUint8Array(base64String) {
|
|
2355
|
-
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
2356
|
-
const latin1string = atob(base64Url);
|
|
2357
|
-
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
2358
|
-
}
|
|
2359
|
-
function convertUint8ArrayToBase64(array) {
|
|
2360
|
-
let latin1string = "";
|
|
2361
|
-
for (let i = 0; i < array.length; i++) {
|
|
2362
|
-
latin1string += String.fromCodePoint(array[i]);
|
|
2363
|
-
}
|
|
2364
|
-
return btoa(latin1string);
|
|
2365
|
-
}
|
|
2366
|
-
function convertToBase64(value) {
|
|
2367
|
-
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
2445
|
// src/without-trailing-slash.ts
|
|
2371
2446
|
function withoutTrailingSlash(url) {
|
|
2372
2447
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
@@ -2403,13 +2478,16 @@ import {
|
|
|
2403
2478
|
} from "eventsource-parser/stream";
|
|
2404
2479
|
export {
|
|
2405
2480
|
DelayedPromise,
|
|
2481
|
+
DownloadError,
|
|
2406
2482
|
EventSourceParserStream2 as EventSourceParserStream,
|
|
2407
2483
|
VERSION,
|
|
2408
2484
|
asSchema,
|
|
2409
2485
|
combineHeaders,
|
|
2410
2486
|
convertAsyncIteratorToReadableStream,
|
|
2411
2487
|
convertBase64ToUint8Array,
|
|
2488
|
+
convertImageModelFileToDataUri,
|
|
2412
2489
|
convertToBase64,
|
|
2490
|
+
convertToFormData,
|
|
2413
2491
|
convertUint8ArrayToBase64,
|
|
2414
2492
|
createBinaryResponseHandler,
|
|
2415
2493
|
createEventSourceResponseHandler,
|
|
@@ -2421,6 +2499,7 @@ export {
|
|
|
2421
2499
|
createStatusCodeErrorResponseHandler,
|
|
2422
2500
|
createToolNameMapping,
|
|
2423
2501
|
delay,
|
|
2502
|
+
downloadBlob,
|
|
2424
2503
|
dynamicTool,
|
|
2425
2504
|
executeTool,
|
|
2426
2505
|
extractResponseHeaders,
|