@mastra/ai-sdk 1.10.6 → 1.10.7-alpha.0
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/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +536 -0
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +488 -3
- package/dist/_types/@internal_ai-v7/dist/index.d.ts +1682 -253
- package/dist/index.cjs +965 -831
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +965 -831
- package/dist/index.js.map +1 -1
- package/dist/transformers.d.ts +1 -5
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -33,12 +33,12 @@ let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
|
33
33
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
34
34
|
let _mastra_core_di = require("@mastra/core/di");
|
|
35
35
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
36
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
37
|
-
var marker$2$
|
|
38
|
-
var symbol$2$3 = Symbol.for(marker$2$
|
|
39
|
-
var _a$2$
|
|
40
|
-
var _b$2$
|
|
41
|
-
var AISDKError$1$3 = class _AISDKError extends (_b$2$
|
|
36
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-DqVGDtnX.js
|
|
37
|
+
var marker$2$5 = "vercel.ai.error";
|
|
38
|
+
var symbol$2$3 = Symbol.for(marker$2$5);
|
|
39
|
+
var _a$2$2;
|
|
40
|
+
var _b$2$5;
|
|
41
|
+
var AISDKError$1$3 = class _AISDKError extends (_b$2$5 = Error, _a$2$2 = symbol$2$3, _b$2$5) {
|
|
42
42
|
/**
|
|
43
43
|
* Creates an AI SDK Error.
|
|
44
44
|
*
|
|
@@ -49,7 +49,7 @@ var AISDKError$1$3 = class _AISDKError extends (_b$2$4 = Error, _a$2$3 = symbol$
|
|
|
49
49
|
*/
|
|
50
50
|
constructor({ name: name14, message, cause }) {
|
|
51
51
|
super(message);
|
|
52
|
-
this[_a$2$
|
|
52
|
+
this[_a$2$2] = true;
|
|
53
53
|
this.name = name14;
|
|
54
54
|
this.cause = cause;
|
|
55
55
|
}
|
|
@@ -59,26 +59,26 @@ var AISDKError$1$3 = class _AISDKError extends (_b$2$4 = Error, _a$2$3 = symbol$
|
|
|
59
59
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
60
60
|
*/
|
|
61
61
|
static isInstance(error) {
|
|
62
|
-
return _AISDKError.hasMarker(error, marker$2$
|
|
62
|
+
return _AISDKError.hasMarker(error, marker$2$5);
|
|
63
63
|
}
|
|
64
64
|
static hasMarker(error, marker15) {
|
|
65
65
|
const markerSymbol = Symbol.for(marker15);
|
|
66
66
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
var name$2$
|
|
70
|
-
var marker2$1$
|
|
71
|
-
var symbol2$1$
|
|
72
|
-
var _a2$1$
|
|
73
|
-
var _b2$1$
|
|
74
|
-
var APICallError$1$3 = class extends (_b2$1$
|
|
69
|
+
var name$2$6 = "AI_APICallError";
|
|
70
|
+
var marker2$1$3 = `vercel.ai.error.${name$2$6}`;
|
|
71
|
+
var symbol2$1$3 = Symbol.for(marker2$1$3);
|
|
72
|
+
var _a2$1$3;
|
|
73
|
+
var _b2$1$2;
|
|
74
|
+
var APICallError$1$3 = class extends (_b2$1$2 = AISDKError$1$3, _a2$1$3 = symbol2$1$3, _b2$1$2) {
|
|
75
75
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
76
76
|
super({
|
|
77
|
-
name: name$2$
|
|
77
|
+
name: name$2$6,
|
|
78
78
|
message,
|
|
79
79
|
cause
|
|
80
80
|
});
|
|
81
|
-
this[_a2$1$
|
|
81
|
+
this[_a2$1$3] = true;
|
|
82
82
|
this.url = url;
|
|
83
83
|
this.requestBodyValues = requestBodyValues;
|
|
84
84
|
this.statusCode = statusCode;
|
|
@@ -88,27 +88,27 @@ var APICallError$1$3 = class extends (_b2$1$5 = AISDKError$1$3, _a2$1$7 = symbol
|
|
|
88
88
|
this.data = data;
|
|
89
89
|
}
|
|
90
90
|
static isInstance(error) {
|
|
91
|
-
return AISDKError$1$3.hasMarker(error, marker2$1$
|
|
91
|
+
return AISDKError$1$3.hasMarker(error, marker2$1$3);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
var name2$1$
|
|
95
|
-
var marker3$1$
|
|
96
|
-
var symbol3$1$3 = Symbol.for(marker3$1$
|
|
94
|
+
var name2$1$3 = "AI_EmptyResponseBodyError";
|
|
95
|
+
var marker3$1$3 = `vercel.ai.error.${name2$1$3}`;
|
|
96
|
+
var symbol3$1$3 = Symbol.for(marker3$1$3);
|
|
97
97
|
var _a3$1$3;
|
|
98
98
|
var _b3$1$2;
|
|
99
99
|
var EmptyResponseBodyError$1$3 = class extends (_b3$1$2 = AISDKError$1$3, _a3$1$3 = symbol3$1$3, _b3$1$2) {
|
|
100
100
|
constructor({ message = "Empty response body" } = {}) {
|
|
101
101
|
super({
|
|
102
|
-
name: name2$1$
|
|
102
|
+
name: name2$1$3,
|
|
103
103
|
message
|
|
104
104
|
});
|
|
105
105
|
this[_a3$1$3] = true;
|
|
106
106
|
}
|
|
107
107
|
static isInstance(error) {
|
|
108
|
-
return AISDKError$1$3.hasMarker(error, marker3$1$
|
|
108
|
+
return AISDKError$1$3.hasMarker(error, marker3$1$3);
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
|
-
function getErrorMessage$2$
|
|
111
|
+
function getErrorMessage$2$2(error) {
|
|
112
112
|
if (error == null) return "unknown error";
|
|
113
113
|
if (typeof error === "string") return error;
|
|
114
114
|
if (error instanceof Error) return error.message;
|
|
@@ -119,7 +119,7 @@ var marker4$1$3 = `vercel.ai.error.${name3$1$3}`;
|
|
|
119
119
|
var symbol4$1$3 = Symbol.for(marker4$1$3);
|
|
120
120
|
var _a4$1$3;
|
|
121
121
|
var _b4$1$2;
|
|
122
|
-
var InvalidArgumentError$1$
|
|
122
|
+
var InvalidArgumentError$1$5 = class extends (_b4$1$2 = AISDKError$1$3, _a4$1$3 = symbol4$1$3, _b4$1$2) {
|
|
123
123
|
constructor({ message, cause, argument }) {
|
|
124
124
|
super({
|
|
125
125
|
name: name3$1$3,
|
|
@@ -180,7 +180,7 @@ var JSONParseError$1$3 = class extends (_b7$1$2 = AISDKError$1$3, _a7$1$3 = symb
|
|
|
180
180
|
super({
|
|
181
181
|
name: name6$1$3,
|
|
182
182
|
message: `JSON parsing failed: Text: ${text}.
|
|
183
|
-
Error message: ${getErrorMessage$2$
|
|
183
|
+
Error message: ${getErrorMessage$2$2(cause)}`,
|
|
184
184
|
cause
|
|
185
185
|
});
|
|
186
186
|
this[_a7$1$3] = true;
|
|
@@ -291,7 +291,7 @@ var TypeValidationError$1$3 = class _TypeValidationError extends (_b13$1$2 = AIS
|
|
|
291
291
|
super({
|
|
292
292
|
name: name12$1$2,
|
|
293
293
|
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
294
|
-
Error message: ${getErrorMessage$2$
|
|
294
|
+
Error message: ${getErrorMessage$2$2(cause)}`,
|
|
295
295
|
cause
|
|
296
296
|
});
|
|
297
297
|
this[_a13$1$2] = true;
|
|
@@ -524,31 +524,31 @@ var EventSourceParserStream$2 = class extends TransformStream {
|
|
|
524
524
|
function combineHeaders(...headers) {
|
|
525
525
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
526
526
|
...combinedHeaders,
|
|
527
|
-
...currentHeaders
|
|
527
|
+
...currentHeaders
|
|
528
528
|
}), {});
|
|
529
529
|
}
|
|
530
530
|
function extractResponseHeaders(response) {
|
|
531
531
|
return Object.fromEntries([...response.headers]);
|
|
532
532
|
}
|
|
533
|
-
var name$1$
|
|
534
|
-
var marker$1$
|
|
535
|
-
var symbol$1$7 = Symbol.for(marker$1$
|
|
536
|
-
var _a$1$
|
|
537
|
-
var _b$1$
|
|
538
|
-
var DownloadError$2 = class extends (_b$1$
|
|
533
|
+
var name$1$8 = "AI_DownloadError";
|
|
534
|
+
var marker$1$7 = `vercel.ai.error.${name$1$8}`;
|
|
535
|
+
var symbol$1$7 = Symbol.for(marker$1$7);
|
|
536
|
+
var _a$1$3;
|
|
537
|
+
var _b$1$4;
|
|
538
|
+
var DownloadError$2 = class extends (_b$1$4 = AISDKError$1$3, _a$1$3 = symbol$1$7, _b$1$4) {
|
|
539
539
|
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
540
540
|
super({
|
|
541
|
-
name: name$1$
|
|
541
|
+
name: name$1$8,
|
|
542
542
|
message,
|
|
543
543
|
cause
|
|
544
544
|
});
|
|
545
|
-
this[_a$1$
|
|
545
|
+
this[_a$1$3] = true;
|
|
546
546
|
this.url = url;
|
|
547
547
|
this.statusCode = statusCode;
|
|
548
548
|
this.statusText = statusText;
|
|
549
549
|
}
|
|
550
550
|
static isInstance(error) {
|
|
551
|
-
return AISDKError$1$3.hasMarker(error, marker$1$
|
|
551
|
+
return AISDKError$1$3.hasMarker(error, marker$1$7);
|
|
552
552
|
}
|
|
553
553
|
};
|
|
554
554
|
async function cancelResponseBody$2(response) {
|
|
@@ -630,7 +630,7 @@ var createIdGenerator$2 = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJ
|
|
|
630
630
|
return chars.join("");
|
|
631
631
|
};
|
|
632
632
|
if (prefix == null) return generator;
|
|
633
|
-
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$
|
|
633
|
+
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$5({
|
|
634
634
|
argument: "separator",
|
|
635
635
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
636
636
|
});
|
|
@@ -725,7 +725,7 @@ function withUserAgentSuffix$2(headers, ...userAgentSuffixParts) {
|
|
|
725
725
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
726
726
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
727
727
|
}
|
|
728
|
-
var VERSION$4 = "3.0.
|
|
728
|
+
var VERSION$4 = "3.0.40";
|
|
729
729
|
var getOriginalFetch = () => globalThis.fetch;
|
|
730
730
|
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch() }) => {
|
|
731
731
|
try {
|
|
@@ -1049,7 +1049,7 @@ async function resolve$2(value) {
|
|
|
1049
1049
|
if (typeof value === "function") value = value();
|
|
1050
1050
|
return Promise.resolve(value);
|
|
1051
1051
|
}
|
|
1052
|
-
var textDecoder$
|
|
1052
|
+
var textDecoder$3 = new TextDecoder();
|
|
1053
1053
|
function wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, responseHeaders }) {
|
|
1054
1054
|
const reader = stream.getReader();
|
|
1055
1055
|
let readerReleased = false;
|
|
@@ -1097,7 +1097,7 @@ function wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, re
|
|
|
1097
1097
|
});
|
|
1098
1098
|
}
|
|
1099
1099
|
async function readResponseBodyAsText({ response, url }) {
|
|
1100
|
-
return textDecoder$
|
|
1100
|
+
return textDecoder$3.decode(await readResponseWithSizeLimit$2({
|
|
1101
1101
|
response,
|
|
1102
1102
|
url
|
|
1103
1103
|
}));
|
|
@@ -1402,7 +1402,7 @@ var zodPatterns$2 = {
|
|
|
1402
1402
|
/**
|
|
1403
1403
|
* `a-z` was added to replicate /i flag
|
|
1404
1404
|
*/
|
|
1405
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
1405
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
1406
1406
|
/**
|
|
1407
1407
|
* Constructed a valid Unicode RegExp
|
|
1408
1408
|
*
|
|
@@ -2164,11 +2164,11 @@ var { btoa: btoa$3, atob: atob$3 } = globalThis;
|
|
|
2164
2164
|
function withoutTrailingSlash(url) {
|
|
2165
2165
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
2166
2166
|
}
|
|
2167
|
-
var marker$
|
|
2168
|
-
var symbol$
|
|
2169
|
-
var _a$
|
|
2170
|
-
var _b$
|
|
2171
|
-
var AISDKError$4 = class _AISDKError extends (_b$
|
|
2167
|
+
var marker$9 = "vercel.ai.error";
|
|
2168
|
+
var symbol$9 = Symbol.for(marker$9);
|
|
2169
|
+
var _a$5;
|
|
2170
|
+
var _b$5;
|
|
2171
|
+
var AISDKError$4 = class _AISDKError extends (_b$5 = Error, _a$5 = symbol$9, _b$5) {
|
|
2172
2172
|
/**
|
|
2173
2173
|
* Creates an AI SDK Error.
|
|
2174
2174
|
*
|
|
@@ -2179,7 +2179,7 @@ var AISDKError$4 = class _AISDKError extends (_b$6 = Error, _a$8 = symbol$8, _b$
|
|
|
2179
2179
|
*/
|
|
2180
2180
|
constructor({ name: name14, message, cause }) {
|
|
2181
2181
|
super(message);
|
|
2182
|
-
this[_a$
|
|
2182
|
+
this[_a$5] = true;
|
|
2183
2183
|
this.name = name14;
|
|
2184
2184
|
this.cause = cause;
|
|
2185
2185
|
}
|
|
@@ -2189,26 +2189,26 @@ var AISDKError$4 = class _AISDKError extends (_b$6 = Error, _a$8 = symbol$8, _b$
|
|
|
2189
2189
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
2190
2190
|
*/
|
|
2191
2191
|
static isInstance(error) {
|
|
2192
|
-
return _AISDKError.hasMarker(error, marker$
|
|
2192
|
+
return _AISDKError.hasMarker(error, marker$9);
|
|
2193
2193
|
}
|
|
2194
2194
|
static hasMarker(error, marker15) {
|
|
2195
2195
|
const markerSymbol = Symbol.for(marker15);
|
|
2196
2196
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
2197
2197
|
}
|
|
2198
2198
|
};
|
|
2199
|
-
var name$
|
|
2200
|
-
var marker2$
|
|
2201
|
-
var symbol2$
|
|
2202
|
-
var _a2$
|
|
2203
|
-
var _b2$
|
|
2204
|
-
var APICallError$4 = class extends (_b2$
|
|
2199
|
+
var name$9 = "AI_APICallError";
|
|
2200
|
+
var marker2$5 = `vercel.ai.error.${name$9}`;
|
|
2201
|
+
var symbol2$5 = Symbol.for(marker2$5);
|
|
2202
|
+
var _a2$5;
|
|
2203
|
+
var _b2$4;
|
|
2204
|
+
var APICallError$4 = class extends (_b2$4 = AISDKError$4, _a2$5 = symbol2$5, _b2$4) {
|
|
2205
2205
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
2206
2206
|
super({
|
|
2207
|
-
name: name$
|
|
2207
|
+
name: name$9,
|
|
2208
2208
|
message,
|
|
2209
2209
|
cause
|
|
2210
2210
|
});
|
|
2211
|
-
this[_a2$
|
|
2211
|
+
this[_a2$5] = true;
|
|
2212
2212
|
this.url = url;
|
|
2213
2213
|
this.requestBodyValues = requestBodyValues;
|
|
2214
2214
|
this.statusCode = statusCode;
|
|
@@ -2218,27 +2218,27 @@ var APICallError$4 = class extends (_b2$6 = AISDKError$4, _a2$8 = symbol2$8, _b2
|
|
|
2218
2218
|
this.data = data;
|
|
2219
2219
|
}
|
|
2220
2220
|
static isInstance(error) {
|
|
2221
|
-
return AISDKError$4.hasMarker(error, marker2$
|
|
2221
|
+
return AISDKError$4.hasMarker(error, marker2$5);
|
|
2222
2222
|
}
|
|
2223
2223
|
};
|
|
2224
|
-
var name2$
|
|
2225
|
-
var marker3$
|
|
2226
|
-
var symbol3$5 = Symbol.for(marker3$
|
|
2224
|
+
var name2$5 = "AI_EmptyResponseBodyError";
|
|
2225
|
+
var marker3$5 = `vercel.ai.error.${name2$5}`;
|
|
2226
|
+
var symbol3$5 = Symbol.for(marker3$5);
|
|
2227
2227
|
var _a3$5;
|
|
2228
2228
|
var _b3$4;
|
|
2229
2229
|
(class extends (_b3$4 = AISDKError$4, _a3$5 = symbol3$5, _b3$4) {
|
|
2230
2230
|
constructor({ message = "Empty response body" } = {}) {
|
|
2231
2231
|
super({
|
|
2232
|
-
name: name2$
|
|
2232
|
+
name: name2$5,
|
|
2233
2233
|
message
|
|
2234
2234
|
});
|
|
2235
2235
|
this[_a3$5] = true;
|
|
2236
2236
|
}
|
|
2237
2237
|
static isInstance(error) {
|
|
2238
|
-
return AISDKError$4.hasMarker(error, marker3$
|
|
2238
|
+
return AISDKError$4.hasMarker(error, marker3$5);
|
|
2239
2239
|
}
|
|
2240
2240
|
});
|
|
2241
|
-
function getErrorMessage$
|
|
2241
|
+
function getErrorMessage$4(error) {
|
|
2242
2242
|
if (error == null) return "unknown error";
|
|
2243
2243
|
if (typeof error === "string") return error;
|
|
2244
2244
|
if (error instanceof Error) return error.message;
|
|
@@ -2310,7 +2310,7 @@ var _b7$4;
|
|
|
2310
2310
|
super({
|
|
2311
2311
|
name: name6$5,
|
|
2312
2312
|
message: `JSON parsing failed: Text: ${text}.
|
|
2313
|
-
Error message: ${getErrorMessage$
|
|
2313
|
+
Error message: ${getErrorMessage$4(cause)}`,
|
|
2314
2314
|
cause
|
|
2315
2315
|
});
|
|
2316
2316
|
this[_a7$5] = true;
|
|
@@ -2421,7 +2421,7 @@ var _b13$3;
|
|
|
2421
2421
|
super({
|
|
2422
2422
|
name: name12$5,
|
|
2423
2423
|
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
2424
|
-
Error message: ${getErrorMessage$
|
|
2424
|
+
Error message: ${getErrorMessage$4(cause)}`,
|
|
2425
2425
|
cause
|
|
2426
2426
|
});
|
|
2427
2427
|
this[_a13$5] = true;
|
|
@@ -2475,12 +2475,12 @@ async function getVercelOidcToken() {
|
|
|
2475
2475
|
throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
|
|
2476
2476
|
}
|
|
2477
2477
|
var symbol$1$6 = Symbol.for("vercel.ai.gateway.error");
|
|
2478
|
-
var _a$1$
|
|
2478
|
+
var _a$1$2;
|
|
2479
2479
|
var _b$4;
|
|
2480
|
-
var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$
|
|
2480
|
+
var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$2 = symbol$1$6, _b$4) {
|
|
2481
2481
|
constructor({ message, statusCode = 500, cause }) {
|
|
2482
2482
|
super(message);
|
|
2483
|
-
this[_a$1$
|
|
2483
|
+
this[_a$1$2] = true;
|
|
2484
2484
|
this.statusCode = statusCode;
|
|
2485
2485
|
this.cause = cause;
|
|
2486
2486
|
}
|
|
@@ -2497,23 +2497,23 @@ var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$6 = symbol$1$
|
|
|
2497
2497
|
}
|
|
2498
2498
|
};
|
|
2499
2499
|
var name$1$6 = "GatewayAuthenticationError";
|
|
2500
|
-
var marker2$1$
|
|
2501
|
-
var symbol2$1$
|
|
2502
|
-
var _a2$1$
|
|
2500
|
+
var marker2$1$2 = `vercel.ai.gateway.error.${name$1$6}`;
|
|
2501
|
+
var symbol2$1$2 = Symbol.for(marker2$1$2);
|
|
2502
|
+
var _a2$1$2;
|
|
2503
2503
|
var _b2$3;
|
|
2504
|
-
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2$3 = GatewayError, _a2$1$
|
|
2504
|
+
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2$3 = GatewayError, _a2$1$2 = symbol2$1$2, _b2$3) {
|
|
2505
2505
|
constructor({ message = "Authentication failed", statusCode = 401, cause } = {}) {
|
|
2506
2506
|
super({
|
|
2507
2507
|
message,
|
|
2508
2508
|
statusCode,
|
|
2509
2509
|
cause
|
|
2510
2510
|
});
|
|
2511
|
-
this[_a2$1$
|
|
2511
|
+
this[_a2$1$2] = true;
|
|
2512
2512
|
this.name = name$1$6;
|
|
2513
2513
|
this.type = "authentication_error";
|
|
2514
2514
|
}
|
|
2515
2515
|
static isInstance(error) {
|
|
2516
|
-
return GatewayError.hasMarker(error) && symbol2$1$
|
|
2516
|
+
return GatewayError.hasMarker(error) && symbol2$1$2 in error;
|
|
2517
2517
|
}
|
|
2518
2518
|
/**
|
|
2519
2519
|
* Creates a contextual error message when authentication fails
|
|
@@ -2545,9 +2545,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
2545
2545
|
});
|
|
2546
2546
|
}
|
|
2547
2547
|
};
|
|
2548
|
-
var name2$1$
|
|
2549
|
-
var marker3$1$
|
|
2550
|
-
var symbol3$1$2 = Symbol.for(marker3$1$
|
|
2548
|
+
var name2$1$2 = "GatewayForbiddenError";
|
|
2549
|
+
var marker3$1$2 = `vercel.ai.gateway.error.${name2$1$2}`;
|
|
2550
|
+
var symbol3$1$2 = Symbol.for(marker3$1$2);
|
|
2551
2551
|
var forbiddenParamSchema = lazyValidator(() => zodSchema$2(zod_v4.z.object({ ruleId: zod_v4.z.string() })));
|
|
2552
2552
|
var _a3$1$2;
|
|
2553
2553
|
var _b3$3;
|
|
@@ -2559,7 +2559,7 @@ var GatewayForbiddenError = class extends (_b3$3 = GatewayError, _a3$1$2 = symbo
|
|
|
2559
2559
|
cause
|
|
2560
2560
|
});
|
|
2561
2561
|
this[_a3$1$2] = true;
|
|
2562
|
-
this.name = name2$1$
|
|
2562
|
+
this.name = name2$1$2;
|
|
2563
2563
|
this.type = "forbidden";
|
|
2564
2564
|
this.ruleId = ruleId;
|
|
2565
2565
|
}
|
|
@@ -5449,12 +5449,12 @@ function createUIMessageStream$2({ execute, onError = () => "An error occurred."
|
|
|
5449
5449
|
});
|
|
5450
5450
|
}
|
|
5451
5451
|
//#endregion
|
|
5452
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist-
|
|
5453
|
-
var marker$2$
|
|
5454
|
-
var symbol$2$2 = Symbol.for(marker$2$
|
|
5455
|
-
var _a$2$
|
|
5456
|
-
var _b$2
|
|
5457
|
-
var AISDKError$1 = class _AISDKError extends (_b$2
|
|
5452
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BcG-LFmj.js
|
|
5453
|
+
var marker$2$2 = "vercel.ai.error";
|
|
5454
|
+
var symbol$2$2 = Symbol.for(marker$2$2);
|
|
5455
|
+
var _a$2$1;
|
|
5456
|
+
var _b$2;
|
|
5457
|
+
var AISDKError$1$1 = class _AISDKError extends (_b$2 = Error, _a$2$1 = symbol$2$2, _b$2) {
|
|
5458
5458
|
/**
|
|
5459
5459
|
* Creates an AI SDK Error.
|
|
5460
5460
|
*
|
|
@@ -5465,7 +5465,7 @@ var AISDKError$1 = class _AISDKError extends (_b$2$1 = Error, _a$2$2 = symbol$2$
|
|
|
5465
5465
|
*/
|
|
5466
5466
|
constructor({ name: name14, message, cause }) {
|
|
5467
5467
|
super(message);
|
|
5468
|
-
this[_a$2$
|
|
5468
|
+
this[_a$2$1] = true;
|
|
5469
5469
|
this.name = name14;
|
|
5470
5470
|
this.cause = cause;
|
|
5471
5471
|
}
|
|
@@ -5475,26 +5475,26 @@ var AISDKError$1 = class _AISDKError extends (_b$2$1 = Error, _a$2$2 = symbol$2$
|
|
|
5475
5475
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
5476
5476
|
*/
|
|
5477
5477
|
static isInstance(error) {
|
|
5478
|
-
return _AISDKError.hasMarker(error, marker$2$
|
|
5478
|
+
return _AISDKError.hasMarker(error, marker$2$2);
|
|
5479
5479
|
}
|
|
5480
5480
|
static hasMarker(error, marker15) {
|
|
5481
5481
|
const markerSymbol = Symbol.for(marker15);
|
|
5482
5482
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
5483
5483
|
}
|
|
5484
5484
|
};
|
|
5485
|
-
var name$2$
|
|
5486
|
-
var marker2$1$
|
|
5487
|
-
var symbol2$1$
|
|
5488
|
-
var _a2$1$
|
|
5489
|
-
var _b2$1$
|
|
5490
|
-
(class extends (_b2$1$
|
|
5485
|
+
var name$2$4 = "AI_APICallError";
|
|
5486
|
+
var marker2$1$1 = `vercel.ai.error.${name$2$4}`;
|
|
5487
|
+
var symbol2$1$1 = Symbol.for(marker2$1$1);
|
|
5488
|
+
var _a2$1$1;
|
|
5489
|
+
var _b2$1$1;
|
|
5490
|
+
(class extends (_b2$1$1 = AISDKError$1$1, _a2$1$1 = symbol2$1$1, _b2$1$1) {
|
|
5491
5491
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
5492
5492
|
super({
|
|
5493
|
-
name: name$2$
|
|
5493
|
+
name: name$2$4,
|
|
5494
5494
|
message,
|
|
5495
5495
|
cause
|
|
5496
5496
|
});
|
|
5497
|
-
this[_a2$1$
|
|
5497
|
+
this[_a2$1$1] = true;
|
|
5498
5498
|
this.url = url;
|
|
5499
5499
|
this.requestBodyValues = requestBodyValues;
|
|
5500
5500
|
this.statusCode = statusCode;
|
|
@@ -5504,24 +5504,24 @@ var _b2$1$3;
|
|
|
5504
5504
|
this.data = data;
|
|
5505
5505
|
}
|
|
5506
5506
|
static isInstance(error) {
|
|
5507
|
-
return AISDKError$1.hasMarker(error, marker2$1$
|
|
5507
|
+
return AISDKError$1$1.hasMarker(error, marker2$1$1);
|
|
5508
5508
|
}
|
|
5509
5509
|
});
|
|
5510
|
-
var name2$1$
|
|
5511
|
-
var marker3$1$
|
|
5512
|
-
var symbol3$1$1 = Symbol.for(marker3$1$
|
|
5510
|
+
var name2$1$1 = "AI_EmptyResponseBodyError";
|
|
5511
|
+
var marker3$1$1 = `vercel.ai.error.${name2$1$1}`;
|
|
5512
|
+
var symbol3$1$1 = Symbol.for(marker3$1$1);
|
|
5513
5513
|
var _a3$1$1;
|
|
5514
5514
|
var _b3$1$1;
|
|
5515
|
-
(class extends (_b3$1$1 = AISDKError$1, _a3$1$1 = symbol3$1$1, _b3$1$1) {
|
|
5515
|
+
(class extends (_b3$1$1 = AISDKError$1$1, _a3$1$1 = symbol3$1$1, _b3$1$1) {
|
|
5516
5516
|
constructor({ message = "Empty response body" } = {}) {
|
|
5517
5517
|
super({
|
|
5518
|
-
name: name2$1$
|
|
5518
|
+
name: name2$1$1,
|
|
5519
5519
|
message
|
|
5520
5520
|
});
|
|
5521
5521
|
this[_a3$1$1] = true;
|
|
5522
5522
|
}
|
|
5523
5523
|
static isInstance(error) {
|
|
5524
|
-
return AISDKError$1.hasMarker(error, marker3$1$
|
|
5524
|
+
return AISDKError$1$1.hasMarker(error, marker3$1$1);
|
|
5525
5525
|
}
|
|
5526
5526
|
});
|
|
5527
5527
|
function getErrorMessage$2(error) {
|
|
@@ -5535,7 +5535,7 @@ var marker4$1$1 = `vercel.ai.error.${name3$1$1}`;
|
|
|
5535
5535
|
var symbol4$1$1 = Symbol.for(marker4$1$1);
|
|
5536
5536
|
var _a4$1$1;
|
|
5537
5537
|
var _b4$1$1;
|
|
5538
|
-
var InvalidArgumentError$1$
|
|
5538
|
+
var InvalidArgumentError$1$3 = class extends (_b4$1$1 = AISDKError$1$1, _a4$1$1 = symbol4$1$1, _b4$1$1) {
|
|
5539
5539
|
constructor({ message, cause, argument }) {
|
|
5540
5540
|
super({
|
|
5541
5541
|
name: name3$1$1,
|
|
@@ -5546,7 +5546,7 @@ var InvalidArgumentError$1$1 = class extends (_b4$1$1 = AISDKError$1, _a4$1$1 =
|
|
|
5546
5546
|
this.argument = argument;
|
|
5547
5547
|
}
|
|
5548
5548
|
static isInstance(error) {
|
|
5549
|
-
return AISDKError$1.hasMarker(error, marker4$1$1);
|
|
5549
|
+
return AISDKError$1$1.hasMarker(error, marker4$1$1);
|
|
5550
5550
|
}
|
|
5551
5551
|
};
|
|
5552
5552
|
var name4$1$1 = "AI_InvalidPromptError";
|
|
@@ -5554,7 +5554,7 @@ var marker5$1$1 = `vercel.ai.error.${name4$1$1}`;
|
|
|
5554
5554
|
var symbol5$1$1 = Symbol.for(marker5$1$1);
|
|
5555
5555
|
var _a5$1$1;
|
|
5556
5556
|
var _b5$1$1;
|
|
5557
|
-
(class extends (_b5$1$1 = AISDKError$1, _a5$1$1 = symbol5$1$1, _b5$1$1) {
|
|
5557
|
+
(class extends (_b5$1$1 = AISDKError$1$1, _a5$1$1 = symbol5$1$1, _b5$1$1) {
|
|
5558
5558
|
constructor({ prompt, message, cause }) {
|
|
5559
5559
|
super({
|
|
5560
5560
|
name: name4$1$1,
|
|
@@ -5565,7 +5565,7 @@ var _b5$1$1;
|
|
|
5565
5565
|
this.prompt = prompt;
|
|
5566
5566
|
}
|
|
5567
5567
|
static isInstance(error) {
|
|
5568
|
-
return AISDKError$1.hasMarker(error, marker5$1$1);
|
|
5568
|
+
return AISDKError$1$1.hasMarker(error, marker5$1$1);
|
|
5569
5569
|
}
|
|
5570
5570
|
});
|
|
5571
5571
|
var name5$1$1 = "AI_InvalidResponseDataError";
|
|
@@ -5573,7 +5573,7 @@ var marker6$1$1 = `vercel.ai.error.${name5$1$1}`;
|
|
|
5573
5573
|
var symbol6$1$1 = Symbol.for(marker6$1$1);
|
|
5574
5574
|
var _a6$1$1;
|
|
5575
5575
|
var _b6$1$1;
|
|
5576
|
-
(class extends (_b6$1$1 = AISDKError$1, _a6$1$1 = symbol6$1$1, _b6$1$1) {
|
|
5576
|
+
(class extends (_b6$1$1 = AISDKError$1$1, _a6$1$1 = symbol6$1$1, _b6$1$1) {
|
|
5577
5577
|
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
5578
5578
|
super({
|
|
5579
5579
|
name: name5$1$1,
|
|
@@ -5583,7 +5583,7 @@ var _b6$1$1;
|
|
|
5583
5583
|
this.data = data;
|
|
5584
5584
|
}
|
|
5585
5585
|
static isInstance(error) {
|
|
5586
|
-
return AISDKError$1.hasMarker(error, marker6$1$1);
|
|
5586
|
+
return AISDKError$1$1.hasMarker(error, marker6$1$1);
|
|
5587
5587
|
}
|
|
5588
5588
|
});
|
|
5589
5589
|
var name6$1$1 = "AI_JSONParseError";
|
|
@@ -5591,7 +5591,7 @@ var marker7$1$1 = `vercel.ai.error.${name6$1$1}`;
|
|
|
5591
5591
|
var symbol7$1$1 = Symbol.for(marker7$1$1);
|
|
5592
5592
|
var _a7$1$1;
|
|
5593
5593
|
var _b7$1$1;
|
|
5594
|
-
var JSONParseError$1 = class extends (_b7$1$1 = AISDKError$1, _a7$1$1 = symbol7$1$1, _b7$1$1) {
|
|
5594
|
+
var JSONParseError$1$1 = class extends (_b7$1$1 = AISDKError$1$1, _a7$1$1 = symbol7$1$1, _b7$1$1) {
|
|
5595
5595
|
constructor({ text, cause }) {
|
|
5596
5596
|
super({
|
|
5597
5597
|
name: name6$1$1,
|
|
@@ -5603,7 +5603,7 @@ Error message: ${getErrorMessage$2(cause)}`,
|
|
|
5603
5603
|
this.text = text;
|
|
5604
5604
|
}
|
|
5605
5605
|
static isInstance(error) {
|
|
5606
|
-
return AISDKError$1.hasMarker(error, marker7$1$1);
|
|
5606
|
+
return AISDKError$1$1.hasMarker(error, marker7$1$1);
|
|
5607
5607
|
}
|
|
5608
5608
|
};
|
|
5609
5609
|
var name7$1$1 = "AI_LoadAPIKeyError";
|
|
@@ -5611,7 +5611,7 @@ var marker8$1$1 = `vercel.ai.error.${name7$1$1}`;
|
|
|
5611
5611
|
var symbol8$1$1 = Symbol.for(marker8$1$1);
|
|
5612
5612
|
var _a8$1$1;
|
|
5613
5613
|
var _b8$1$1;
|
|
5614
|
-
(class extends (_b8$1$1 = AISDKError$1, _a8$1$1 = symbol8$1$1, _b8$1$1) {
|
|
5614
|
+
(class extends (_b8$1$1 = AISDKError$1$1, _a8$1$1 = symbol8$1$1, _b8$1$1) {
|
|
5615
5615
|
constructor({ message }) {
|
|
5616
5616
|
super({
|
|
5617
5617
|
name: name7$1$1,
|
|
@@ -5620,7 +5620,7 @@ var _b8$1$1;
|
|
|
5620
5620
|
this[_a8$1$1] = true;
|
|
5621
5621
|
}
|
|
5622
5622
|
static isInstance(error) {
|
|
5623
|
-
return AISDKError$1.hasMarker(error, marker8$1$1);
|
|
5623
|
+
return AISDKError$1$1.hasMarker(error, marker8$1$1);
|
|
5624
5624
|
}
|
|
5625
5625
|
});
|
|
5626
5626
|
var name8$1$1 = "AI_LoadSettingError";
|
|
@@ -5628,7 +5628,7 @@ var marker9$1$1 = `vercel.ai.error.${name8$1$1}`;
|
|
|
5628
5628
|
var symbol9$1$1 = Symbol.for(marker9$1$1);
|
|
5629
5629
|
var _a9$1$1;
|
|
5630
5630
|
var _b9$1$1;
|
|
5631
|
-
(class extends (_b9$1$1 = AISDKError$1, _a9$1$1 = symbol9$1$1, _b9$1$1) {
|
|
5631
|
+
(class extends (_b9$1$1 = AISDKError$1$1, _a9$1$1 = symbol9$1$1, _b9$1$1) {
|
|
5632
5632
|
constructor({ message }) {
|
|
5633
5633
|
super({
|
|
5634
5634
|
name: name8$1$1,
|
|
@@ -5637,7 +5637,7 @@ var _b9$1$1;
|
|
|
5637
5637
|
this[_a9$1$1] = true;
|
|
5638
5638
|
}
|
|
5639
5639
|
static isInstance(error) {
|
|
5640
|
-
return AISDKError$1.hasMarker(error, marker9$1$1);
|
|
5640
|
+
return AISDKError$1$1.hasMarker(error, marker9$1$1);
|
|
5641
5641
|
}
|
|
5642
5642
|
});
|
|
5643
5643
|
var name9$1$1 = "AI_NoContentGeneratedError";
|
|
@@ -5645,7 +5645,7 @@ var marker10$1$1 = `vercel.ai.error.${name9$1$1}`;
|
|
|
5645
5645
|
var symbol10$1$1 = Symbol.for(marker10$1$1);
|
|
5646
5646
|
var _a10$1$1;
|
|
5647
5647
|
var _b10$1$1;
|
|
5648
|
-
(class extends (_b10$1$1 = AISDKError$1, _a10$1$1 = symbol10$1$1, _b10$1$1) {
|
|
5648
|
+
(class extends (_b10$1$1 = AISDKError$1$1, _a10$1$1 = symbol10$1$1, _b10$1$1) {
|
|
5649
5649
|
constructor({ message = "No content generated." } = {}) {
|
|
5650
5650
|
super({
|
|
5651
5651
|
name: name9$1$1,
|
|
@@ -5654,7 +5654,7 @@ var _b10$1$1;
|
|
|
5654
5654
|
this[_a10$1$1] = true;
|
|
5655
5655
|
}
|
|
5656
5656
|
static isInstance(error) {
|
|
5657
|
-
return AISDKError$1.hasMarker(error, marker10$1$1);
|
|
5657
|
+
return AISDKError$1$1.hasMarker(error, marker10$1$1);
|
|
5658
5658
|
}
|
|
5659
5659
|
});
|
|
5660
5660
|
var name10$1$1 = "AI_NoSuchModelError";
|
|
@@ -5662,7 +5662,7 @@ var marker11$1$1 = `vercel.ai.error.${name10$1$1}`;
|
|
|
5662
5662
|
var symbol11$1$1 = Symbol.for(marker11$1$1);
|
|
5663
5663
|
var _a11$1$1;
|
|
5664
5664
|
var _b11$1$1;
|
|
5665
|
-
(class extends (_b11$1$1 = AISDKError$1, _a11$1$1 = symbol11$1$1, _b11$1$1) {
|
|
5665
|
+
(class extends (_b11$1$1 = AISDKError$1$1, _a11$1$1 = symbol11$1$1, _b11$1$1) {
|
|
5666
5666
|
constructor({ errorName = name10$1$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
5667
5667
|
super({
|
|
5668
5668
|
name: errorName,
|
|
@@ -5673,7 +5673,7 @@ var _b11$1$1;
|
|
|
5673
5673
|
this.modelType = modelType;
|
|
5674
5674
|
}
|
|
5675
5675
|
static isInstance(error) {
|
|
5676
|
-
return AISDKError$1.hasMarker(error, marker11$1$1);
|
|
5676
|
+
return AISDKError$1$1.hasMarker(error, marker11$1$1);
|
|
5677
5677
|
}
|
|
5678
5678
|
});
|
|
5679
5679
|
var name11$1$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
@@ -5681,7 +5681,7 @@ var marker12$1$1 = `vercel.ai.error.${name11$1$1}`;
|
|
|
5681
5681
|
var symbol12$1$1 = Symbol.for(marker12$1$1);
|
|
5682
5682
|
var _a12$1$1;
|
|
5683
5683
|
var _b12$1$1;
|
|
5684
|
-
(class extends (_b12$1$1 = AISDKError$1, _a12$1$1 = symbol12$1$1, _b12$1$1) {
|
|
5684
|
+
(class extends (_b12$1$1 = AISDKError$1$1, _a12$1$1 = symbol12$1$1, _b12$1$1) {
|
|
5685
5685
|
constructor(options) {
|
|
5686
5686
|
super({
|
|
5687
5687
|
name: name11$1$1,
|
|
@@ -5694,7 +5694,7 @@ var _b12$1$1;
|
|
|
5694
5694
|
this.values = options.values;
|
|
5695
5695
|
}
|
|
5696
5696
|
static isInstance(error) {
|
|
5697
|
-
return AISDKError$1.hasMarker(error, marker12$1$1);
|
|
5697
|
+
return AISDKError$1$1.hasMarker(error, marker12$1$1);
|
|
5698
5698
|
}
|
|
5699
5699
|
});
|
|
5700
5700
|
var name12$1$1 = "AI_TypeValidationError";
|
|
@@ -5702,7 +5702,7 @@ var marker13$1$1 = `vercel.ai.error.${name12$1$1}`;
|
|
|
5702
5702
|
var symbol13$1$1 = Symbol.for(marker13$1$1);
|
|
5703
5703
|
var _a13$1$1;
|
|
5704
5704
|
var _b13$1$1;
|
|
5705
|
-
var TypeValidationError$1 = class _TypeValidationError extends (_b13$1$1 = AISDKError$1, _a13$1$1 = symbol13$1$1, _b13$1$1) {
|
|
5705
|
+
var TypeValidationError$1$1 = class _TypeValidationError extends (_b13$1$1 = AISDKError$1$1, _a13$1$1 = symbol13$1$1, _b13$1$1) {
|
|
5706
5706
|
constructor({ value, cause, context }) {
|
|
5707
5707
|
let contextPrefix = "Type validation failed";
|
|
5708
5708
|
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
@@ -5725,7 +5725,7 @@ Error message: ${getErrorMessage$2(cause)}`,
|
|
|
5725
5725
|
this.context = context;
|
|
5726
5726
|
}
|
|
5727
5727
|
static isInstance(error) {
|
|
5728
|
-
return AISDKError$1.hasMarker(error, marker13$1$1);
|
|
5728
|
+
return AISDKError$1$1.hasMarker(error, marker13$1$1);
|
|
5729
5729
|
}
|
|
5730
5730
|
/**
|
|
5731
5731
|
* Wraps an error into a TypeValidationError.
|
|
@@ -5753,7 +5753,7 @@ var marker14$1$1 = `vercel.ai.error.${name13$1$1}`;
|
|
|
5753
5753
|
var symbol14$1$1 = Symbol.for(marker14$1$1);
|
|
5754
5754
|
var _a14$1$1;
|
|
5755
5755
|
var _b14$1$1;
|
|
5756
|
-
(class extends (_b14$1$1 = AISDKError$1, _a14$1$1 = symbol14$1$1, _b14$1$1) {
|
|
5756
|
+
(class extends (_b14$1$1 = AISDKError$1$1, _a14$1$1 = symbol14$1$1, _b14$1$1) {
|
|
5757
5757
|
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
5758
5758
|
super({
|
|
5759
5759
|
name: name13$1$1,
|
|
@@ -5763,30 +5763,30 @@ var _b14$1$1;
|
|
|
5763
5763
|
this.functionality = functionality;
|
|
5764
5764
|
}
|
|
5765
5765
|
static isInstance(error) {
|
|
5766
|
-
return AISDKError$1.hasMarker(error, marker14$1$1);
|
|
5766
|
+
return AISDKError$1$1.hasMarker(error, marker14$1$1);
|
|
5767
5767
|
}
|
|
5768
5768
|
});
|
|
5769
5769
|
TransformStream;
|
|
5770
5770
|
var { btoa: btoa$2, atob: atob$2 } = globalThis;
|
|
5771
|
-
var name$1$
|
|
5772
|
-
var marker$1$
|
|
5773
|
-
var symbol$1$4 = Symbol.for(marker$1$
|
|
5774
|
-
var _a$1$
|
|
5775
|
-
var _b$1$
|
|
5776
|
-
(class extends (_b$1$
|
|
5771
|
+
var name$1$5 = "AI_DownloadError";
|
|
5772
|
+
var marker$1$5 = `vercel.ai.error.${name$1$5}`;
|
|
5773
|
+
var symbol$1$4 = Symbol.for(marker$1$5);
|
|
5774
|
+
var _a$1$1;
|
|
5775
|
+
var _b$1$1;
|
|
5776
|
+
(class extends (_b$1$1 = AISDKError$1$1, _a$1$1 = symbol$1$4, _b$1$1) {
|
|
5777
5777
|
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
5778
5778
|
super({
|
|
5779
|
-
name: name$1$
|
|
5779
|
+
name: name$1$5,
|
|
5780
5780
|
message,
|
|
5781
5781
|
cause
|
|
5782
5782
|
});
|
|
5783
|
-
this[_a$1$
|
|
5783
|
+
this[_a$1$1] = true;
|
|
5784
5784
|
this.url = url;
|
|
5785
5785
|
this.statusCode = statusCode;
|
|
5786
5786
|
this.statusText = statusText;
|
|
5787
5787
|
}
|
|
5788
5788
|
static isInstance(error) {
|
|
5789
|
-
return AISDKError$1.hasMarker(error, marker$1$
|
|
5789
|
+
return AISDKError$1$1.hasMarker(error, marker$1$5);
|
|
5790
5790
|
}
|
|
5791
5791
|
});
|
|
5792
5792
|
var initialGlobalFetch = globalThis.fetch;
|
|
@@ -5818,7 +5818,7 @@ var createIdGenerator$1 = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJ
|
|
|
5818
5818
|
return chars.join("");
|
|
5819
5819
|
};
|
|
5820
5820
|
if (prefix == null) return generator;
|
|
5821
|
-
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$
|
|
5821
|
+
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$3({
|
|
5822
5822
|
argument: "separator",
|
|
5823
5823
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
5824
5824
|
});
|
|
@@ -6057,7 +6057,7 @@ var zodPatterns$1 = {
|
|
|
6057
6057
|
/**
|
|
6058
6058
|
* `a-z` was added to replicate /i flag
|
|
6059
6059
|
*/
|
|
6060
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
6060
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
6061
6061
|
/**
|
|
6062
6062
|
* Constructed a valid Unicode RegExp
|
|
6063
6063
|
*
|
|
@@ -6799,7 +6799,7 @@ function standardSchema$1(standardSchema2) {
|
|
|
6799
6799
|
value: result.value
|
|
6800
6800
|
} : {
|
|
6801
6801
|
success: false,
|
|
6802
|
-
error: new TypeValidationError$1({
|
|
6802
|
+
error: new TypeValidationError$1$1({
|
|
6803
6803
|
value,
|
|
6804
6804
|
cause: result.issues
|
|
6805
6805
|
})
|
|
@@ -6854,7 +6854,7 @@ async function validateTypes$1({ value, schema, context }) {
|
|
|
6854
6854
|
schema,
|
|
6855
6855
|
context
|
|
6856
6856
|
});
|
|
6857
|
-
if (!result.success) throw TypeValidationError$1.wrap({
|
|
6857
|
+
if (!result.success) throw TypeValidationError$1$1.wrap({
|
|
6858
6858
|
value,
|
|
6859
6859
|
cause: result.error,
|
|
6860
6860
|
context
|
|
@@ -6877,7 +6877,7 @@ async function safeValidateTypes$1({ value, schema, context }) {
|
|
|
6877
6877
|
};
|
|
6878
6878
|
return {
|
|
6879
6879
|
success: false,
|
|
6880
|
-
error: TypeValidationError$1.wrap({
|
|
6880
|
+
error: TypeValidationError$1$1.wrap({
|
|
6881
6881
|
value,
|
|
6882
6882
|
cause: result.error,
|
|
6883
6883
|
context
|
|
@@ -6887,7 +6887,7 @@ async function safeValidateTypes$1({ value, schema, context }) {
|
|
|
6887
6887
|
} catch (error) {
|
|
6888
6888
|
return {
|
|
6889
6889
|
success: false,
|
|
6890
|
-
error: TypeValidationError$1.wrap({
|
|
6890
|
+
error: TypeValidationError$1$1.wrap({
|
|
6891
6891
|
value,
|
|
6892
6892
|
cause: error,
|
|
6893
6893
|
context
|
|
@@ -6911,7 +6911,7 @@ async function safeParseJSON$1({ text, schema }) {
|
|
|
6911
6911
|
} catch (error) {
|
|
6912
6912
|
return {
|
|
6913
6913
|
success: false,
|
|
6914
|
-
error: JSONParseError$1.isInstance(error) ? error : new JSONParseError$1({
|
|
6914
|
+
error: JSONParseError$1$1.isInstance(error) ? error : new JSONParseError$1$1({
|
|
6915
6915
|
text,
|
|
6916
6916
|
cause: error
|
|
6917
6917
|
}),
|
|
@@ -6921,14 +6921,14 @@ async function safeParseJSON$1({ text, schema }) {
|
|
|
6921
6921
|
}
|
|
6922
6922
|
async function resolve$1(value) {
|
|
6923
6923
|
if (typeof value === "function") value = value();
|
|
6924
|
-
return
|
|
6924
|
+
return value;
|
|
6925
6925
|
}
|
|
6926
6926
|
new TextDecoder();
|
|
6927
|
-
var marker$
|
|
6928
|
-
var symbol$5 = Symbol.for(marker$
|
|
6929
|
-
var _a$
|
|
6927
|
+
var marker$6 = "vercel.ai.error";
|
|
6928
|
+
var symbol$5 = Symbol.for(marker$6);
|
|
6929
|
+
var _a$3;
|
|
6930
6930
|
var _b$3;
|
|
6931
|
-
var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$
|
|
6931
|
+
var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$3 = symbol$5, _b$3) {
|
|
6932
6932
|
/**
|
|
6933
6933
|
* Creates an AI SDK Error.
|
|
6934
6934
|
*
|
|
@@ -6939,7 +6939,7 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6939
6939
|
*/
|
|
6940
6940
|
constructor({ name: name14, message, cause }) {
|
|
6941
6941
|
super(message);
|
|
6942
|
-
this[_a$
|
|
6942
|
+
this[_a$3] = true;
|
|
6943
6943
|
this.name = name14;
|
|
6944
6944
|
this.cause = cause;
|
|
6945
6945
|
}
|
|
@@ -6949,7 +6949,7 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6949
6949
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
6950
6950
|
*/
|
|
6951
6951
|
static isInstance(error) {
|
|
6952
|
-
return _AISDKError.hasMarker(error, marker$
|
|
6952
|
+
return _AISDKError.hasMarker(error, marker$6);
|
|
6953
6953
|
}
|
|
6954
6954
|
static hasMarker(error, marker15) {
|
|
6955
6955
|
const markerSymbol = Symbol.for(marker15);
|
|
@@ -6957,18 +6957,18 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6957
6957
|
}
|
|
6958
6958
|
};
|
|
6959
6959
|
var name$5 = "AI_APICallError";
|
|
6960
|
-
var marker2$
|
|
6961
|
-
var symbol2$
|
|
6962
|
-
var _a2$
|
|
6963
|
-
var _b2$
|
|
6964
|
-
(class extends (_b2$
|
|
6960
|
+
var marker2$3 = `vercel.ai.error.${name$5}`;
|
|
6961
|
+
var symbol2$3 = Symbol.for(marker2$3);
|
|
6962
|
+
var _a2$3;
|
|
6963
|
+
var _b2$2;
|
|
6964
|
+
(class extends (_b2$2 = AISDKError$2, _a2$3 = symbol2$3, _b2$2) {
|
|
6965
6965
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
6966
6966
|
super({
|
|
6967
6967
|
name: name$5,
|
|
6968
6968
|
message,
|
|
6969
6969
|
cause
|
|
6970
6970
|
});
|
|
6971
|
-
this[_a2$
|
|
6971
|
+
this[_a2$3] = true;
|
|
6972
6972
|
this.url = url;
|
|
6973
6973
|
this.requestBodyValues = requestBodyValues;
|
|
6974
6974
|
this.statusCode = statusCode;
|
|
@@ -6978,27 +6978,27 @@ var _b2$4;
|
|
|
6978
6978
|
this.data = data;
|
|
6979
6979
|
}
|
|
6980
6980
|
static isInstance(error) {
|
|
6981
|
-
return AISDKError$2.hasMarker(error, marker2$
|
|
6981
|
+
return AISDKError$2.hasMarker(error, marker2$3);
|
|
6982
6982
|
}
|
|
6983
6983
|
});
|
|
6984
|
-
var name2$
|
|
6985
|
-
var marker3$
|
|
6986
|
-
var symbol3$3 = Symbol.for(marker3$
|
|
6984
|
+
var name2$3 = "AI_EmptyResponseBodyError";
|
|
6985
|
+
var marker3$3 = `vercel.ai.error.${name2$3}`;
|
|
6986
|
+
var symbol3$3 = Symbol.for(marker3$3);
|
|
6987
6987
|
var _a3$3;
|
|
6988
6988
|
var _b3$2;
|
|
6989
6989
|
(class extends (_b3$2 = AISDKError$2, _a3$3 = symbol3$3, _b3$2) {
|
|
6990
6990
|
constructor({ message = "Empty response body" } = {}) {
|
|
6991
6991
|
super({
|
|
6992
|
-
name: name2$
|
|
6992
|
+
name: name2$3,
|
|
6993
6993
|
message
|
|
6994
6994
|
});
|
|
6995
6995
|
this[_a3$3] = true;
|
|
6996
6996
|
}
|
|
6997
6997
|
static isInstance(error) {
|
|
6998
|
-
return AISDKError$2.hasMarker(error, marker3$
|
|
6998
|
+
return AISDKError$2.hasMarker(error, marker3$3);
|
|
6999
6999
|
}
|
|
7000
7000
|
});
|
|
7001
|
-
function getErrorMessage$
|
|
7001
|
+
function getErrorMessage$3(error) {
|
|
7002
7002
|
if (error == null) return "unknown error";
|
|
7003
7003
|
if (typeof error === "string") return error;
|
|
7004
7004
|
if (error instanceof Error) return error.message;
|
|
@@ -7070,7 +7070,7 @@ var _b7$2;
|
|
|
7070
7070
|
super({
|
|
7071
7071
|
name: name6$3,
|
|
7072
7072
|
message: `JSON parsing failed: Text: ${text}.
|
|
7073
|
-
Error message: ${getErrorMessage$
|
|
7073
|
+
Error message: ${getErrorMessage$3(cause)}`,
|
|
7074
7074
|
cause
|
|
7075
7075
|
});
|
|
7076
7076
|
this[_a7$3] = true;
|
|
@@ -7191,7 +7191,7 @@ var TypeValidationError$2 = class _TypeValidationError extends (_b13$2 = AISDKEr
|
|
|
7191
7191
|
super({
|
|
7192
7192
|
name: name12$3,
|
|
7193
7193
|
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
7194
|
-
Error message: ${getErrorMessage$
|
|
7194
|
+
Error message: ${getErrorMessage$3(cause)}`,
|
|
7195
7195
|
cause
|
|
7196
7196
|
});
|
|
7197
7197
|
this[_a13$3] = true;
|
|
@@ -9545,12 +9545,18 @@ var doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream,
|
|
|
9545
9545
|
};
|
|
9546
9546
|
};
|
|
9547
9547
|
//#endregion
|
|
9548
|
-
//#region ../../packages/_vendored/ai_v7/dist/dist-
|
|
9549
|
-
|
|
9550
|
-
|
|
9551
|
-
|
|
9552
|
-
|
|
9553
|
-
|
|
9548
|
+
//#region ../../packages/_vendored/ai_v7/dist/dist-Bwf3DREZ.js
|
|
9549
|
+
/**
|
|
9550
|
+
* Symbol used for identifying AI SDK Error instances.
|
|
9551
|
+
* Enables checking if an error is an instance of AISDKError across package versions.
|
|
9552
|
+
*/
|
|
9553
|
+
const marker$15 = "vercel.ai.error";
|
|
9554
|
+
const symbol$15 = Symbol.for(marker$15);
|
|
9555
|
+
/**
|
|
9556
|
+
* Custom error class for AI SDK related errors.
|
|
9557
|
+
* @extends Error
|
|
9558
|
+
*/
|
|
9559
|
+
var AISDKError$1 = class AISDKError extends Error {
|
|
9554
9560
|
/**
|
|
9555
9561
|
* Creates an AI SDK Error.
|
|
9556
9562
|
*
|
|
@@ -9559,10 +9565,10 @@ var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1)
|
|
|
9559
9565
|
* @param {string} params.message - The error message.
|
|
9560
9566
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
9561
9567
|
*/
|
|
9562
|
-
constructor({ name
|
|
9568
|
+
constructor({ name, message, cause }) {
|
|
9563
9569
|
super(message);
|
|
9564
|
-
this[
|
|
9565
|
-
this.name =
|
|
9570
|
+
this[symbol$15] = true;
|
|
9571
|
+
this.name = name;
|
|
9566
9572
|
this.cause = cause;
|
|
9567
9573
|
}
|
|
9568
9574
|
/**
|
|
@@ -9571,359 +9577,123 @@ var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1)
|
|
|
9571
9577
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
9572
9578
|
*/
|
|
9573
9579
|
static isInstance(error) {
|
|
9574
|
-
return
|
|
9580
|
+
return AISDKError.hasMarker(error, marker$15);
|
|
9575
9581
|
}
|
|
9576
|
-
static hasMarker(error,
|
|
9577
|
-
const markerSymbol = Symbol.for(
|
|
9582
|
+
static hasMarker(error, marker) {
|
|
9583
|
+
const markerSymbol = Symbol.for(marker);
|
|
9578
9584
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
9579
9585
|
}
|
|
9580
9586
|
};
|
|
9581
|
-
|
|
9582
|
-
var marker2$1 = `vercel.ai.error.${name$1}`;
|
|
9583
|
-
var symbol2$1 = Symbol.for(marker2$1);
|
|
9584
|
-
var _a2$1;
|
|
9585
|
-
var _b2$1;
|
|
9586
|
-
(class extends (_b2$1 = AISDKError, _a2$1 = symbol2$1, _b2$1) {
|
|
9587
|
-
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
9588
|
-
super({
|
|
9589
|
-
name: name$1,
|
|
9590
|
-
message,
|
|
9591
|
-
cause
|
|
9592
|
-
});
|
|
9593
|
-
this[_a2$1] = true;
|
|
9594
|
-
this.url = url;
|
|
9595
|
-
this.requestBodyValues = requestBodyValues;
|
|
9596
|
-
this.statusCode = statusCode;
|
|
9597
|
-
this.responseHeaders = responseHeaders;
|
|
9598
|
-
this.responseBody = responseBody;
|
|
9599
|
-
this.isRetryable = isRetryable;
|
|
9600
|
-
this.data = data;
|
|
9601
|
-
}
|
|
9602
|
-
static isInstance(error) {
|
|
9603
|
-
return AISDKError.hasMarker(error, marker2$1);
|
|
9604
|
-
}
|
|
9605
|
-
});
|
|
9606
|
-
var name2$1 = "AI_EmptyResponseBodyError";
|
|
9607
|
-
var marker3$1 = `vercel.ai.error.${name2$1}`;
|
|
9608
|
-
var symbol3$1 = Symbol.for(marker3$1);
|
|
9609
|
-
var _a3$1;
|
|
9610
|
-
var _b3$1;
|
|
9611
|
-
(class extends (_b3$1 = AISDKError, _a3$1 = symbol3$1, _b3$1) {
|
|
9612
|
-
constructor({ message = "Empty response body" } = {}) {
|
|
9613
|
-
super({
|
|
9614
|
-
name: name2$1,
|
|
9615
|
-
message
|
|
9616
|
-
});
|
|
9617
|
-
this[_a3$1] = true;
|
|
9618
|
-
}
|
|
9619
|
-
static isInstance(error) {
|
|
9620
|
-
return AISDKError.hasMarker(error, marker3$1);
|
|
9621
|
-
}
|
|
9622
|
-
});
|
|
9623
|
-
var name3$1 = "AI_EvaluationUnsupportedQuestionTypeError";
|
|
9624
|
-
var marker4$1 = `vercel.ai.error.${name3$1}`;
|
|
9625
|
-
var symbol4$1 = Symbol.for(marker4$1);
|
|
9626
|
-
var _a4$1;
|
|
9627
|
-
var _b4$1;
|
|
9628
|
-
(class extends (_b4$1 = AISDKError, _a4$1 = symbol4$1, _b4$1) {
|
|
9629
|
-
constructor({ questionId, questionType, provider, modelId, message = `Question "${questionId}" has type "${questionType}", which is not supported by provider "${provider}" and model "${modelId}".` }) {
|
|
9630
|
-
super({
|
|
9631
|
-
name: name3$1,
|
|
9632
|
-
message
|
|
9633
|
-
});
|
|
9634
|
-
this[_a4$1] = true;
|
|
9635
|
-
this.questionId = questionId;
|
|
9636
|
-
this.questionType = questionType;
|
|
9637
|
-
this.provider = provider;
|
|
9638
|
-
this.modelId = modelId;
|
|
9639
|
-
}
|
|
9640
|
-
static isInstance(error) {
|
|
9641
|
-
return AISDKError.hasMarker(error, marker4$1);
|
|
9642
|
-
}
|
|
9643
|
-
});
|
|
9644
|
-
function getErrorMessage(error) {
|
|
9587
|
+
function getErrorMessage$1(error) {
|
|
9645
9588
|
if (error == null) return "unknown error";
|
|
9646
9589
|
if (typeof error === "string") return error;
|
|
9647
9590
|
if (error instanceof Error) return error.toString();
|
|
9648
9591
|
return JSON.stringify(error);
|
|
9649
9592
|
}
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9593
|
+
const name$11 = "AI_InvalidArgumentError";
|
|
9594
|
+
const marker$11 = `vercel.ai.error.${name$11}`;
|
|
9595
|
+
const symbol$11 = Symbol.for(marker$11);
|
|
9596
|
+
/**
|
|
9597
|
+
* A function argument is invalid.
|
|
9598
|
+
*/
|
|
9599
|
+
var InvalidArgumentError$1 = class extends AISDKError$1 {
|
|
9656
9600
|
constructor({ message, cause, argument }) {
|
|
9657
9601
|
super({
|
|
9658
|
-
name:
|
|
9602
|
+
name: name$11,
|
|
9659
9603
|
message,
|
|
9660
9604
|
cause
|
|
9661
9605
|
});
|
|
9662
|
-
this[
|
|
9606
|
+
this[symbol$11] = true;
|
|
9663
9607
|
this.argument = argument;
|
|
9664
9608
|
}
|
|
9665
9609
|
static isInstance(error) {
|
|
9666
|
-
return AISDKError.hasMarker(error,
|
|
9610
|
+
return AISDKError$1.hasMarker(error, marker$11);
|
|
9667
9611
|
}
|
|
9668
9612
|
};
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
var
|
|
9673
|
-
var _b6$1;
|
|
9674
|
-
(class extends (_b6$1 = AISDKError, _a6$1 = symbol6$1, _b6$1) {
|
|
9675
|
-
constructor({ prompt, message, cause }) {
|
|
9676
|
-
super({
|
|
9677
|
-
name: name5$1,
|
|
9678
|
-
message: `Invalid prompt: ${message}`,
|
|
9679
|
-
cause
|
|
9680
|
-
});
|
|
9681
|
-
this[_a6$1] = true;
|
|
9682
|
-
this.prompt = prompt;
|
|
9683
|
-
}
|
|
9684
|
-
static isInstance(error) {
|
|
9685
|
-
return AISDKError.hasMarker(error, marker6$1);
|
|
9686
|
-
}
|
|
9687
|
-
});
|
|
9688
|
-
var name6$1 = "AI_InvalidResponseDataError";
|
|
9689
|
-
var marker7$1 = `vercel.ai.error.${name6$1}`;
|
|
9690
|
-
var symbol7$1 = Symbol.for(marker7$1);
|
|
9691
|
-
var _a7$1;
|
|
9692
|
-
var _b7$1;
|
|
9693
|
-
(class extends (_b7$1 = AISDKError, _a7$1 = symbol7$1, _b7$1) {
|
|
9694
|
-
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
9695
|
-
super({
|
|
9696
|
-
name: name6$1,
|
|
9697
|
-
message
|
|
9698
|
-
});
|
|
9699
|
-
this[_a7$1] = true;
|
|
9700
|
-
this.data = data;
|
|
9701
|
-
}
|
|
9702
|
-
static isInstance(error) {
|
|
9703
|
-
return AISDKError.hasMarker(error, marker7$1);
|
|
9704
|
-
}
|
|
9705
|
-
});
|
|
9706
|
-
var name7$1 = "AI_JSONParseError";
|
|
9707
|
-
var marker8$1 = `vercel.ai.error.${name7$1}`;
|
|
9708
|
-
var symbol8$1 = Symbol.for(marker8$1);
|
|
9709
|
-
var _a8$1;
|
|
9710
|
-
var _b8$1;
|
|
9711
|
-
var JSONParseError = class extends (_b8$1 = AISDKError, _a8$1 = symbol8$1, _b8$1) {
|
|
9613
|
+
const name$8 = "AI_JSONParseError";
|
|
9614
|
+
const marker$8 = `vercel.ai.error.${name$8}`;
|
|
9615
|
+
const symbol$8 = Symbol.for(marker$8);
|
|
9616
|
+
var JSONParseError$1 = class extends AISDKError$1 {
|
|
9712
9617
|
constructor({ text, cause }) {
|
|
9713
9618
|
super({
|
|
9714
|
-
name:
|
|
9715
|
-
message: `JSON parsing failed: Text: ${text}
|
|
9716
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
9619
|
+
name: name$8,
|
|
9620
|
+
message: `JSON parsing failed: Text: ${text}.\nError message: ${getErrorMessage$1(cause)}`,
|
|
9717
9621
|
cause
|
|
9718
9622
|
});
|
|
9719
|
-
this[
|
|
9623
|
+
this[symbol$8] = true;
|
|
9720
9624
|
this.text = text;
|
|
9721
9625
|
}
|
|
9722
9626
|
static isInstance(error) {
|
|
9723
|
-
return AISDKError.hasMarker(error,
|
|
9627
|
+
return AISDKError$1.hasMarker(error, marker$8);
|
|
9724
9628
|
}
|
|
9725
9629
|
};
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
var
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9630
|
+
const name$1$3 = "AI_TypeValidationError";
|
|
9631
|
+
const marker$1$4 = `vercel.ai.error.${name$1$3}`;
|
|
9632
|
+
const symbol$1$3 = Symbol.for(marker$1$4);
|
|
9633
|
+
var TypeValidationError$1 = class TypeValidationError extends AISDKError$1 {
|
|
9634
|
+
constructor({ value, cause, context }) {
|
|
9635
|
+
let contextPrefix = "Type validation failed";
|
|
9636
|
+
if (context?.field) contextPrefix += ` for ${context.field}`;
|
|
9637
|
+
if (context?.entityName || context?.entityId) {
|
|
9638
|
+
contextPrefix += " (";
|
|
9639
|
+
const parts = [];
|
|
9640
|
+
if (context.entityName) parts.push(context.entityName);
|
|
9641
|
+
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
9642
|
+
contextPrefix += parts.join(", ");
|
|
9643
|
+
contextPrefix += ")";
|
|
9644
|
+
}
|
|
9733
9645
|
super({
|
|
9734
|
-
name:
|
|
9735
|
-
message
|
|
9646
|
+
name: name$1$3,
|
|
9647
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.\nError message: ${getErrorMessage$1(cause)}`,
|
|
9648
|
+
cause
|
|
9736
9649
|
});
|
|
9737
|
-
this[
|
|
9650
|
+
this[symbol$1$3] = true;
|
|
9651
|
+
this.value = value;
|
|
9652
|
+
this.context = context;
|
|
9738
9653
|
}
|
|
9739
9654
|
static isInstance(error) {
|
|
9740
|
-
return AISDKError.hasMarker(error,
|
|
9655
|
+
return AISDKError$1.hasMarker(error, marker$1$4);
|
|
9741
9656
|
}
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9657
|
+
/**
|
|
9658
|
+
* Wraps an error into a TypeValidationError.
|
|
9659
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
9660
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
9661
|
+
*
|
|
9662
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
9663
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
9664
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9665
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
9666
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9667
|
+
*/
|
|
9668
|
+
static wrap({ value, cause, context }) {
|
|
9669
|
+
if (TypeValidationError.isInstance(cause) && cause.value === value && cause.context?.field === context?.field && cause.context?.entityName === context?.entityName && cause.context?.entityId === context?.entityId) return cause;
|
|
9670
|
+
return new TypeValidationError({
|
|
9671
|
+
value,
|
|
9672
|
+
cause,
|
|
9673
|
+
context
|
|
9753
9674
|
});
|
|
9754
|
-
this[_a10$1] = true;
|
|
9755
|
-
}
|
|
9756
|
-
static isInstance(error) {
|
|
9757
|
-
return AISDKError.hasMarker(error, marker10$1);
|
|
9758
9675
|
}
|
|
9759
|
-
}
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9676
|
+
};
|
|
9677
|
+
TransformStream;
|
|
9678
|
+
new TextDecoder();
|
|
9679
|
+
const { btoa: btoa$1, atob: atob$1 } = globalThis;
|
|
9680
|
+
const name$1 = "AI_DownloadError";
|
|
9681
|
+
const marker$1 = `vercel.ai.error.${name$1}`;
|
|
9682
|
+
const symbol$1 = Symbol.for(marker$1);
|
|
9683
|
+
(class extends AISDKError$1 {
|
|
9684
|
+
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
9767
9685
|
super({
|
|
9768
|
-
name:
|
|
9769
|
-
message
|
|
9686
|
+
name: name$1,
|
|
9687
|
+
message,
|
|
9688
|
+
cause
|
|
9770
9689
|
});
|
|
9771
|
-
this[
|
|
9690
|
+
this[symbol$1] = true;
|
|
9691
|
+
this.url = url;
|
|
9692
|
+
this.statusCode = statusCode;
|
|
9693
|
+
this.statusText = statusText;
|
|
9772
9694
|
}
|
|
9773
9695
|
static isInstance(error) {
|
|
9774
|
-
return AISDKError.hasMarker(error,
|
|
9775
|
-
}
|
|
9776
|
-
});
|
|
9777
|
-
var name11$1 = "AI_NoSuchModelError";
|
|
9778
|
-
var marker12$1 = `vercel.ai.error.${name11$1}`;
|
|
9779
|
-
var symbol12$1 = Symbol.for(marker12$1);
|
|
9780
|
-
var _a12$1;
|
|
9781
|
-
var _b12$1;
|
|
9782
|
-
var NoSuchModelError = class extends (_b12$1 = AISDKError, _a12$1 = symbol12$1, _b12$1) {
|
|
9783
|
-
constructor({ errorName = name11$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
9784
|
-
super({
|
|
9785
|
-
name: errorName,
|
|
9786
|
-
message
|
|
9787
|
-
});
|
|
9788
|
-
this[_a12$1] = true;
|
|
9789
|
-
this.modelId = modelId;
|
|
9790
|
-
this.modelType = modelType;
|
|
9791
|
-
}
|
|
9792
|
-
static isInstance(error) {
|
|
9793
|
-
return AISDKError.hasMarker(error, marker12$1);
|
|
9794
|
-
}
|
|
9795
|
-
};
|
|
9796
|
-
var name12$1 = "AI_NoSuchProviderReferenceError";
|
|
9797
|
-
var marker13$1 = `vercel.ai.error.${name12$1}`;
|
|
9798
|
-
var symbol13$1 = Symbol.for(marker13$1);
|
|
9799
|
-
var _a13$1;
|
|
9800
|
-
var _b13$1;
|
|
9801
|
-
(class extends (_b13$1 = AISDKError, _a13$1 = symbol13$1, _b13$1) {
|
|
9802
|
-
constructor({ provider, reference, message = `No provider reference found for provider '${provider}'. Available providers: ${Object.keys(reference).join(", ")}` }) {
|
|
9803
|
-
super({
|
|
9804
|
-
name: name12$1,
|
|
9805
|
-
message
|
|
9806
|
-
});
|
|
9807
|
-
this[_a13$1] = true;
|
|
9808
|
-
this.provider = provider;
|
|
9809
|
-
this.reference = reference;
|
|
9810
|
-
}
|
|
9811
|
-
static isInstance(error) {
|
|
9812
|
-
return AISDKError.hasMarker(error, marker13$1);
|
|
9813
|
-
}
|
|
9814
|
-
});
|
|
9815
|
-
var name13$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
9816
|
-
var marker14$1 = `vercel.ai.error.${name13$1}`;
|
|
9817
|
-
var symbol14$1 = Symbol.for(marker14$1);
|
|
9818
|
-
var _a14$1;
|
|
9819
|
-
var _b14$1;
|
|
9820
|
-
(class extends (_b14$1 = AISDKError, _a14$1 = symbol14$1, _b14$1) {
|
|
9821
|
-
constructor(options) {
|
|
9822
|
-
super({
|
|
9823
|
-
name: name13$1,
|
|
9824
|
-
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
9825
|
-
});
|
|
9826
|
-
this[_a14$1] = true;
|
|
9827
|
-
this.provider = options.provider;
|
|
9828
|
-
this.modelId = options.modelId;
|
|
9829
|
-
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
9830
|
-
this.values = options.values;
|
|
9831
|
-
}
|
|
9832
|
-
static isInstance(error) {
|
|
9833
|
-
return AISDKError.hasMarker(error, marker14$1);
|
|
9834
|
-
}
|
|
9835
|
-
});
|
|
9836
|
-
var name14$1 = "AI_TypeValidationError";
|
|
9837
|
-
var marker15$1 = `vercel.ai.error.${name14$1}`;
|
|
9838
|
-
var symbol15$1 = Symbol.for(marker15$1);
|
|
9839
|
-
var _a15$1;
|
|
9840
|
-
var _b15$1;
|
|
9841
|
-
var TypeValidationError = class _TypeValidationError extends (_b15$1 = AISDKError, _a15$1 = symbol15$1, _b15$1) {
|
|
9842
|
-
constructor({ value, cause, context }) {
|
|
9843
|
-
let contextPrefix = "Type validation failed";
|
|
9844
|
-
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
9845
|
-
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
|
9846
|
-
contextPrefix += " (";
|
|
9847
|
-
const parts = [];
|
|
9848
|
-
if (context.entityName) parts.push(context.entityName);
|
|
9849
|
-
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
9850
|
-
contextPrefix += parts.join(", ");
|
|
9851
|
-
contextPrefix += ")";
|
|
9852
|
-
}
|
|
9853
|
-
super({
|
|
9854
|
-
name: name14$1,
|
|
9855
|
-
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
9856
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
9857
|
-
cause
|
|
9858
|
-
});
|
|
9859
|
-
this[_a15$1] = true;
|
|
9860
|
-
this.value = value;
|
|
9861
|
-
this.context = context;
|
|
9862
|
-
}
|
|
9863
|
-
static isInstance(error) {
|
|
9864
|
-
return AISDKError.hasMarker(error, marker15$1);
|
|
9865
|
-
}
|
|
9866
|
-
/**
|
|
9867
|
-
* Wraps an error into a TypeValidationError.
|
|
9868
|
-
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
9869
|
-
* Otherwise, it creates a new TypeValidationError.
|
|
9870
|
-
*
|
|
9871
|
-
* @param {Object} params - The parameters for wrapping the error.
|
|
9872
|
-
* @param {unknown} params.value - The value that failed validation.
|
|
9873
|
-
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9874
|
-
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
9875
|
-
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9876
|
-
*/
|
|
9877
|
-
static wrap({ value, cause, context }) {
|
|
9878
|
-
var _a17, _b17, _c;
|
|
9879
|
-
if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a17 = cause.context) == null ? void 0 : _a17.field) === (context == null ? void 0 : context.field) && ((_b17 = cause.context) == null ? void 0 : _b17.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) return cause;
|
|
9880
|
-
return new _TypeValidationError({
|
|
9881
|
-
value,
|
|
9882
|
-
cause,
|
|
9883
|
-
context
|
|
9884
|
-
});
|
|
9885
|
-
}
|
|
9886
|
-
};
|
|
9887
|
-
var name15$1 = "AI_UnsupportedFunctionalityError";
|
|
9888
|
-
var marker16$1 = `vercel.ai.error.${name15$1}`;
|
|
9889
|
-
var symbol16$1 = Symbol.for(marker16$1);
|
|
9890
|
-
var _a16$1;
|
|
9891
|
-
var _b16$1;
|
|
9892
|
-
(class extends (_b16$1 = AISDKError, _a16$1 = symbol16$1, _b16$1) {
|
|
9893
|
-
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
9894
|
-
super({
|
|
9895
|
-
name: name15$1,
|
|
9896
|
-
message
|
|
9897
|
-
});
|
|
9898
|
-
this[_a16$1] = true;
|
|
9899
|
-
this.functionality = functionality;
|
|
9900
|
-
}
|
|
9901
|
-
static isInstance(error) {
|
|
9902
|
-
return AISDKError.hasMarker(error, marker16$1);
|
|
9903
|
-
}
|
|
9904
|
-
});
|
|
9905
|
-
TransformStream;
|
|
9906
|
-
new TextDecoder();
|
|
9907
|
-
var { btoa: btoa$1, atob: atob$1 } = globalThis;
|
|
9908
|
-
var name$2 = "AI_DownloadError";
|
|
9909
|
-
var marker2$2 = `vercel.ai.error.${name$2}`;
|
|
9910
|
-
var symbol$2 = Symbol.for(marker2$2);
|
|
9911
|
-
var _a$2;
|
|
9912
|
-
var _b$2;
|
|
9913
|
-
(class extends (_b$2 = AISDKError, _a$2 = symbol$2, _b$2) {
|
|
9914
|
-
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
9915
|
-
super({
|
|
9916
|
-
name: name$2,
|
|
9917
|
-
message,
|
|
9918
|
-
cause
|
|
9919
|
-
});
|
|
9920
|
-
this[_a$2] = true;
|
|
9921
|
-
this.url = url;
|
|
9922
|
-
this.statusCode = statusCode;
|
|
9923
|
-
this.statusText = statusText;
|
|
9924
|
-
}
|
|
9925
|
-
static isInstance(error) {
|
|
9926
|
-
return AISDKError.hasMarker(error, marker2$2);
|
|
9696
|
+
return AISDKError$1.hasMarker(error, marker$1);
|
|
9927
9697
|
}
|
|
9928
9698
|
});
|
|
9929
9699
|
function getCurrentModulePath() {
|
|
@@ -9933,14 +9703,24 @@ function getCurrentModulePath() {
|
|
|
9933
9703
|
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
9934
9704
|
Error.captureStackTrace(error, getCurrentModulePath);
|
|
9935
9705
|
const [caller] = error.stack;
|
|
9936
|
-
const fileName = caller
|
|
9706
|
+
const fileName = caller?.getFileName();
|
|
9937
9707
|
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
9938
9708
|
return fileName;
|
|
9939
9709
|
} finally {
|
|
9940
9710
|
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
9941
9711
|
}
|
|
9942
9712
|
}
|
|
9943
|
-
|
|
9713
|
+
/**
|
|
9714
|
+
* Creates an ID generator.
|
|
9715
|
+
* The total length of the ID is the sum of the prefix, separator, and random part length.
|
|
9716
|
+
* Not cryptographically secure.
|
|
9717
|
+
*
|
|
9718
|
+
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
|
|
9719
|
+
* @param prefix - The prefix of the ID to generate. Optional.
|
|
9720
|
+
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
|
|
9721
|
+
* @param size - The size of the random part of the ID to generate. Default: 16.
|
|
9722
|
+
*/
|
|
9723
|
+
const createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator = "-" } = {}) => {
|
|
9944
9724
|
const generator = () => {
|
|
9945
9725
|
const alphabetLength = alphabet.length;
|
|
9946
9726
|
const chars = new Array(size);
|
|
@@ -9954,13 +9734,22 @@ var createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKL
|
|
|
9954
9734
|
});
|
|
9955
9735
|
return () => `${prefix}${separator}${generator()}`;
|
|
9956
9736
|
};
|
|
9957
|
-
|
|
9737
|
+
/**
|
|
9738
|
+
* Generates a 16-character random string to use for IDs.
|
|
9739
|
+
* Not cryptographically secure.
|
|
9740
|
+
*/
|
|
9741
|
+
const generateId = createIdGenerator();
|
|
9742
|
+
/**
|
|
9743
|
+
* Type-guard for Node.js `Buffer` instances.
|
|
9744
|
+
*
|
|
9745
|
+
* Uses optional chaining on `globalThis.Buffer` so it returns `false` in
|
|
9746
|
+
* runtimes where `Buffer` is not available (e.g. CloudFlare Workers).
|
|
9747
|
+
*/
|
|
9958
9748
|
function isBuffer(value) {
|
|
9959
|
-
|
|
9960
|
-
return (_b3 = (_a3 = globalThis.Buffer) == null ? void 0 : _a3.isBuffer(value)) != null ? _b3 : false;
|
|
9749
|
+
return globalThis.Buffer?.isBuffer(value) ?? false;
|
|
9961
9750
|
}
|
|
9962
|
-
|
|
9963
|
-
|
|
9751
|
+
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
9752
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
9964
9753
|
function _parse(text) {
|
|
9965
9754
|
const obj = JSON.parse(text);
|
|
9966
9755
|
if (obj === null || typeof obj !== "object") return obj;
|
|
@@ -9987,7 +9776,7 @@ function secureJsonParse(text) {
|
|
|
9987
9776
|
const { stackTraceLimit } = Error;
|
|
9988
9777
|
try {
|
|
9989
9778
|
Error.stackTraceLimit = 0;
|
|
9990
|
-
} catch
|
|
9779
|
+
} catch {
|
|
9991
9780
|
return _parse(text);
|
|
9992
9781
|
}
|
|
9993
9782
|
try {
|
|
@@ -9996,27 +9785,32 @@ function secureJsonParse(text) {
|
|
|
9996
9785
|
Error.stackTraceLimit = stackTraceLimit;
|
|
9997
9786
|
}
|
|
9998
9787
|
}
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
|
|
9788
|
+
/**
|
|
9789
|
+
* Recursively adds additionalProperties: false to object schemas that do not
|
|
9790
|
+
* define a schema for their additional properties. This is necessary because
|
|
9791
|
+
* some providers (e.g. OpenAI) do not support additionalProperties: true.
|
|
9792
|
+
*/
|
|
9793
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema) {
|
|
9794
|
+
if (jsonSchema.type === "object" || Array.isArray(jsonSchema.type) && jsonSchema.type.includes("object")) {
|
|
9795
|
+
const { additionalProperties } = jsonSchema;
|
|
9796
|
+
jsonSchema.additionalProperties = additionalProperties != null && typeof additionalProperties !== "boolean" ? visit(additionalProperties) : false;
|
|
9797
|
+
const { properties } = jsonSchema;
|
|
10004
9798
|
if (properties != null) for (const key of Object.keys(properties)) properties[key] = visit(properties[key]);
|
|
10005
9799
|
}
|
|
10006
|
-
if (
|
|
10007
|
-
if (
|
|
10008
|
-
if (
|
|
10009
|
-
if (
|
|
10010
|
-
const { definitions } =
|
|
9800
|
+
if (jsonSchema.items != null) jsonSchema.items = Array.isArray(jsonSchema.items) ? jsonSchema.items.map(visit) : visit(jsonSchema.items);
|
|
9801
|
+
if (jsonSchema.anyOf != null) jsonSchema.anyOf = jsonSchema.anyOf.map(visit);
|
|
9802
|
+
if (jsonSchema.allOf != null) jsonSchema.allOf = jsonSchema.allOf.map(visit);
|
|
9803
|
+
if (jsonSchema.oneOf != null) jsonSchema.oneOf = jsonSchema.oneOf.map(visit);
|
|
9804
|
+
const { definitions } = jsonSchema;
|
|
10011
9805
|
if (definitions != null) for (const key of Object.keys(definitions)) definitions[key] = visit(definitions[key]);
|
|
10012
|
-
return
|
|
9806
|
+
return jsonSchema;
|
|
10013
9807
|
}
|
|
10014
9808
|
function visit(def) {
|
|
10015
9809
|
if (typeof def === "boolean") return def;
|
|
10016
9810
|
return addAdditionalPropertiesToJsonSchema(def);
|
|
10017
9811
|
}
|
|
10018
|
-
|
|
10019
|
-
|
|
9812
|
+
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
9813
|
+
const defaultOptions = {
|
|
10020
9814
|
name: void 0,
|
|
10021
9815
|
$refStrategy: "root",
|
|
10022
9816
|
basePath: ["#"],
|
|
@@ -10037,7 +9831,7 @@ var defaultOptions = {
|
|
|
10037
9831
|
base64Strategy: "contentEncoding:base64",
|
|
10038
9832
|
nameStrategy: "ref"
|
|
10039
9833
|
};
|
|
10040
|
-
|
|
9834
|
+
const getDefaultOptions = (options) => typeof options === "string" ? {
|
|
10041
9835
|
...defaultOptions,
|
|
10042
9836
|
name: options
|
|
10043
9837
|
} : {
|
|
@@ -10048,9 +9842,8 @@ function parseAnyDef() {
|
|
|
10048
9842
|
return {};
|
|
10049
9843
|
}
|
|
10050
9844
|
function parseArrayDef(def, refs) {
|
|
10051
|
-
var _a3, _b3, _c;
|
|
10052
9845
|
const res = { type: "array" };
|
|
10053
|
-
if (
|
|
9846
|
+
if (def.type?._def && def.type?._def?.typeName !== "ZodAny") res.items = parseDef(def.type._def, {
|
|
10054
9847
|
...refs,
|
|
10055
9848
|
currentPath: [...refs.currentPath, "items"]
|
|
10056
9849
|
});
|
|
@@ -10077,9 +9870,7 @@ function parseBigintDef(def) {
|
|
|
10077
9870
|
if (check.inclusive) res.maximum = check.value;
|
|
10078
9871
|
else res.exclusiveMaximum = check.value;
|
|
10079
9872
|
break;
|
|
10080
|
-
case "multipleOf":
|
|
10081
|
-
res.multipleOf = check.value;
|
|
10082
|
-
break;
|
|
9873
|
+
case "multipleOf": res.multipleOf = check.value;
|
|
10083
9874
|
}
|
|
10084
9875
|
return res;
|
|
10085
9876
|
}
|
|
@@ -10089,11 +9880,11 @@ function parseBooleanDef() {
|
|
|
10089
9880
|
function parseBrandedDef(_def, refs) {
|
|
10090
9881
|
return parseDef(_def.type._def, refs);
|
|
10091
9882
|
}
|
|
10092
|
-
|
|
9883
|
+
const parseCatchDef = (def, refs) => {
|
|
10093
9884
|
return parseDef(def.innerType._def, refs);
|
|
10094
9885
|
};
|
|
10095
9886
|
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
10096
|
-
const strategy = overrideDateStrategy
|
|
9887
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
10097
9888
|
if (Array.isArray(strategy)) return { anyOf: strategy.map((item) => parseDateDef(def, refs, item)) };
|
|
10098
9889
|
switch (strategy) {
|
|
10099
9890
|
case "string":
|
|
@@ -10108,7 +9899,7 @@ function parseDateDef(def, refs, overrideDateStrategy) {
|
|
|
10108
9899
|
case "integer": return integerDateParser(def);
|
|
10109
9900
|
}
|
|
10110
9901
|
}
|
|
10111
|
-
|
|
9902
|
+
const integerDateParser = (def) => {
|
|
10112
9903
|
const res = {
|
|
10113
9904
|
type: "integer",
|
|
10114
9905
|
format: "unix-time"
|
|
@@ -10117,9 +9908,7 @@ var integerDateParser = (def) => {
|
|
|
10117
9908
|
case "min":
|
|
10118
9909
|
res.minimum = check.value;
|
|
10119
9910
|
break;
|
|
10120
|
-
case "max":
|
|
10121
|
-
res.maximum = check.value;
|
|
10122
|
-
break;
|
|
9911
|
+
case "max": res.maximum = check.value;
|
|
10123
9912
|
}
|
|
10124
9913
|
return res;
|
|
10125
9914
|
};
|
|
@@ -10138,7 +9927,7 @@ function parseEnumDef(def) {
|
|
|
10138
9927
|
enum: Array.from(def.values)
|
|
10139
9928
|
};
|
|
10140
9929
|
}
|
|
10141
|
-
|
|
9930
|
+
const isJsonSchema7AllOfType = (type) => {
|
|
10142
9931
|
if ("type" in type && type.type === "string") return false;
|
|
10143
9932
|
return "allOf" in type;
|
|
10144
9933
|
};
|
|
@@ -10180,8 +9969,14 @@ function parseLiteralDef(def) {
|
|
|
10180
9969
|
const: def.value
|
|
10181
9970
|
};
|
|
10182
9971
|
}
|
|
10183
|
-
|
|
10184
|
-
|
|
9972
|
+
let emojiRegex = void 0;
|
|
9973
|
+
/**
|
|
9974
|
+
* Generated from the regular expressions found here as of 2024-05-22:
|
|
9975
|
+
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
|
9976
|
+
*
|
|
9977
|
+
* Expressions with /i flag have been changed accordingly.
|
|
9978
|
+
*/
|
|
9979
|
+
const zodPatterns = {
|
|
10185
9980
|
/**
|
|
10186
9981
|
* `c` was changed to `[cC]` to replicate /i flag
|
|
10187
9982
|
*/
|
|
@@ -10191,7 +9986,7 @@ var zodPatterns = {
|
|
|
10191
9986
|
/**
|
|
10192
9987
|
* `a-z` was added to replicate /i flag
|
|
10193
9988
|
*/
|
|
10194
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
9989
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
10195
9990
|
/**
|
|
10196
9991
|
* Constructed a valid Unicode RegExp
|
|
10197
9992
|
*
|
|
@@ -10243,9 +10038,7 @@ function parseStringDef(def, refs) {
|
|
|
10243
10038
|
case "format:idn-email":
|
|
10244
10039
|
addFormat(res, "idn-email", check.message, refs);
|
|
10245
10040
|
break;
|
|
10246
|
-
case "pattern:zod":
|
|
10247
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
10248
|
-
break;
|
|
10041
|
+
case "pattern:zod": addPattern(res, zodPatterns.email, check.message, refs);
|
|
10249
10042
|
}
|
|
10250
10043
|
break;
|
|
10251
10044
|
case "url":
|
|
@@ -10316,23 +10109,17 @@ function parseStringDef(def, refs) {
|
|
|
10316
10109
|
case "contentEncoding:base64":
|
|
10317
10110
|
res.contentEncoding = "base64";
|
|
10318
10111
|
break;
|
|
10319
|
-
case "pattern:zod":
|
|
10320
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
10321
|
-
break;
|
|
10112
|
+
case "pattern:zod": addPattern(res, zodPatterns.base64, check.message, refs);
|
|
10322
10113
|
}
|
|
10323
10114
|
break;
|
|
10324
10115
|
case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
10325
|
-
case "toLowerCase":
|
|
10326
|
-
case "toUpperCase":
|
|
10327
|
-
case "trim": break;
|
|
10328
|
-
default:
|
|
10329
10116
|
}
|
|
10330
10117
|
return res;
|
|
10331
10118
|
}
|
|
10332
10119
|
function escapeLiteralCheckValue(literal, refs) {
|
|
10333
10120
|
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
10334
10121
|
}
|
|
10335
|
-
|
|
10122
|
+
const ALPHA_NUMERIC = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
10336
10123
|
function escapeNonAlphaNumeric(source) {
|
|
10337
10124
|
let result = "";
|
|
10338
10125
|
for (let i = 0; i < source.length; i++) {
|
|
@@ -10342,8 +10129,7 @@ function escapeNonAlphaNumeric(source) {
|
|
|
10342
10129
|
return result;
|
|
10343
10130
|
}
|
|
10344
10131
|
function addFormat(schema, value, message, refs) {
|
|
10345
|
-
|
|
10346
|
-
if (schema.format || ((_a3 = schema.anyOf) == null ? void 0 : _a3.some((x) => x.format))) {
|
|
10132
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
10347
10133
|
if (!schema.anyOf) schema.anyOf = [];
|
|
10348
10134
|
if (schema.format) {
|
|
10349
10135
|
schema.anyOf.push({ format: schema.format });
|
|
@@ -10356,8 +10142,7 @@ function addFormat(schema, value, message, refs) {
|
|
|
10356
10142
|
} else schema.format = value;
|
|
10357
10143
|
}
|
|
10358
10144
|
function addPattern(schema, regex, message, refs) {
|
|
10359
|
-
|
|
10360
|
-
if (schema.pattern || ((_a3 = schema.allOf) == null ? void 0 : _a3.some((x) => x.pattern))) {
|
|
10145
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
10361
10146
|
if (!schema.allOf) schema.allOf = [];
|
|
10362
10147
|
if (schema.pattern) {
|
|
10363
10148
|
schema.allOf.push({ pattern: schema.pattern });
|
|
@@ -10370,7 +10155,6 @@ function addPattern(schema, regex, message, refs) {
|
|
|
10370
10155
|
} else schema.pattern = stringifyRegExpWithFlags(regex, refs);
|
|
10371
10156
|
}
|
|
10372
10157
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
10373
|
-
var _a3;
|
|
10374
10158
|
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
10375
10159
|
const flags = {
|
|
10376
10160
|
i: regex.flags.includes("i"),
|
|
@@ -10395,7 +10179,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10395
10179
|
pattern += source[i];
|
|
10396
10180
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10397
10181
|
inCharRange = false;
|
|
10398
|
-
} else if (source[i + 1] === "-" &&
|
|
10182
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
10399
10183
|
pattern += source[i];
|
|
10400
10184
|
inCharRange = true;
|
|
10401
10185
|
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
@@ -10408,19 +10192,15 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10408
10192
|
}
|
|
10409
10193
|
if (flags.m) {
|
|
10410
10194
|
if (source[i] === "^") {
|
|
10411
|
-
pattern += `(^|(?<=[\r
|
|
10412
|
-
]))`;
|
|
10195
|
+
pattern += `(^|(?<=[\r\n]))`;
|
|
10413
10196
|
continue;
|
|
10414
10197
|
} else if (source[i] === "$") {
|
|
10415
|
-
pattern += `($|(?=[\r
|
|
10416
|
-
]))`;
|
|
10198
|
+
pattern += `($|(?=[\r\n]))`;
|
|
10417
10199
|
continue;
|
|
10418
10200
|
}
|
|
10419
10201
|
}
|
|
10420
10202
|
if (flags.s && source[i] === ".") {
|
|
10421
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
10422
|
-
` : `[${source[i]}\r
|
|
10423
|
-
]`;
|
|
10203
|
+
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
10424
10204
|
continue;
|
|
10425
10205
|
}
|
|
10426
10206
|
pattern += source[i];
|
|
@@ -10430,32 +10210,31 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10430
10210
|
}
|
|
10431
10211
|
try {
|
|
10432
10212
|
new RegExp(pattern);
|
|
10433
|
-
} catch
|
|
10213
|
+
} catch {
|
|
10434
10214
|
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
10435
10215
|
return regex.source;
|
|
10436
10216
|
}
|
|
10437
10217
|
return pattern;
|
|
10438
10218
|
}
|
|
10439
10219
|
function parseRecordDef(def, refs) {
|
|
10440
|
-
var _a3, _b3, _c, _d, _e, _f;
|
|
10441
10220
|
const schema = {
|
|
10442
10221
|
type: "object",
|
|
10443
|
-
additionalProperties:
|
|
10222
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
10444
10223
|
...refs,
|
|
10445
10224
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10446
|
-
})
|
|
10225
|
+
}) ?? refs.allowedAdditionalProperties
|
|
10447
10226
|
};
|
|
10448
|
-
if (
|
|
10227
|
+
if (def.keyType?._def.typeName === "ZodString" && def.keyType._def.checks?.length) {
|
|
10449
10228
|
const { type: _type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
10450
10229
|
return {
|
|
10451
10230
|
...schema,
|
|
10452
10231
|
propertyNames: keyType
|
|
10453
10232
|
};
|
|
10454
|
-
} else if (
|
|
10233
|
+
} else if (def.keyType?._def.typeName === "ZodEnum") return {
|
|
10455
10234
|
...schema,
|
|
10456
10235
|
propertyNames: { enum: def.keyType._def.values }
|
|
10457
10236
|
};
|
|
10458
|
-
else if (
|
|
10237
|
+
else if (def.keyType?._def.typeName === "ZodBranded" && def.keyType._def.type._def.typeName === "ZodString" && def.keyType._def.type._def.checks?.length) {
|
|
10459
10238
|
const { type: _type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
10460
10239
|
return {
|
|
10461
10240
|
...schema,
|
|
@@ -10510,7 +10289,7 @@ function parseNeverDef() {
|
|
|
10510
10289
|
function parseNullDef() {
|
|
10511
10290
|
return { type: "null" };
|
|
10512
10291
|
}
|
|
10513
|
-
|
|
10292
|
+
const primitiveMappings = {
|
|
10514
10293
|
ZodString: "string",
|
|
10515
10294
|
ZodNumber: "number",
|
|
10516
10295
|
ZodBigInt: "integer",
|
|
@@ -10520,9 +10299,9 @@ var primitiveMappings = {
|
|
|
10520
10299
|
function parseUnionDef(def, refs) {
|
|
10521
10300
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10522
10301
|
if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
10523
|
-
const types = options.reduce((
|
|
10302
|
+
const types = options.reduce((types, x) => {
|
|
10524
10303
|
const type = primitiveMappings[x._def.typeName];
|
|
10525
|
-
return type && !
|
|
10304
|
+
return type && !types.includes(type) ? [...types, type] : types;
|
|
10526
10305
|
}, []);
|
|
10527
10306
|
return { type: types.length > 1 ? types : types[0] };
|
|
10528
10307
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
@@ -10548,11 +10327,11 @@ function parseUnionDef(def, refs) {
|
|
|
10548
10327
|
}
|
|
10549
10328
|
} else if (options.every((x) => x._def.typeName === "ZodEnum")) return {
|
|
10550
10329
|
type: "string",
|
|
10551
|
-
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((
|
|
10330
|
+
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x) => !acc.includes(x))], [])
|
|
10552
10331
|
};
|
|
10553
10332
|
return asAnyOf(def, refs);
|
|
10554
10333
|
}
|
|
10555
|
-
|
|
10334
|
+
const asAnyOf = (def, refs) => {
|
|
10556
10335
|
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
10557
10336
|
...refs,
|
|
10558
10337
|
currentPath: [
|
|
@@ -10596,9 +10375,7 @@ function parseNumberDef(def) {
|
|
|
10596
10375
|
if (check.inclusive) res.maximum = check.value;
|
|
10597
10376
|
else res.exclusiveMaximum = check.value;
|
|
10598
10377
|
break;
|
|
10599
|
-
case "multipleOf":
|
|
10600
|
-
res.multipleOf = check.value;
|
|
10601
|
-
break;
|
|
10378
|
+
case "multipleOf": res.multipleOf = check.value;
|
|
10602
10379
|
}
|
|
10603
10380
|
return res;
|
|
10604
10381
|
}
|
|
@@ -10649,13 +10426,12 @@ function decideAdditionalProperties(def, refs) {
|
|
|
10649
10426
|
function safeIsOptional(schema) {
|
|
10650
10427
|
try {
|
|
10651
10428
|
return schema.isOptional();
|
|
10652
|
-
} catch
|
|
10429
|
+
} catch {
|
|
10653
10430
|
return true;
|
|
10654
10431
|
}
|
|
10655
10432
|
}
|
|
10656
|
-
|
|
10657
|
-
|
|
10658
|
-
if (refs.currentPath.toString() === ((_a3 = refs.propertyPath) == null ? void 0 : _a3.toString())) return parseDef(def.innerType._def, refs);
|
|
10433
|
+
const parseOptionalDef = (def, refs) => {
|
|
10434
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
|
|
10659
10435
|
const innerSchema = parseDef(def.innerType._def, {
|
|
10660
10436
|
...refs,
|
|
10661
10437
|
currentPath: [
|
|
@@ -10666,7 +10442,7 @@ var parseOptionalDef = (def, refs) => {
|
|
|
10666
10442
|
});
|
|
10667
10443
|
return innerSchema ? { anyOf: [{ not: parseAnyDef() }, innerSchema] } : parseAnyDef();
|
|
10668
10444
|
};
|
|
10669
|
-
|
|
10445
|
+
const parsePipelineDef = (def, refs) => {
|
|
10670
10446
|
if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
|
|
10671
10447
|
else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
|
|
10672
10448
|
const inputSchema = parseDef(def.in._def, {
|
|
@@ -10739,10 +10515,10 @@ function parseUndefinedDef() {
|
|
|
10739
10515
|
function parseUnknownDef() {
|
|
10740
10516
|
return parseAnyDef();
|
|
10741
10517
|
}
|
|
10742
|
-
|
|
10518
|
+
const parseReadonlyDef = (def, refs) => {
|
|
10743
10519
|
return parseDef(def.innerType._def, refs);
|
|
10744
10520
|
};
|
|
10745
|
-
|
|
10521
|
+
const selectParser = (def, typeName, refs) => {
|
|
10746
10522
|
switch (typeName) {
|
|
10747
10523
|
case "ZodString": return parseStringDef(def, refs);
|
|
10748
10524
|
case "ZodNumber": return parseNumberDef(def);
|
|
@@ -10780,19 +10556,20 @@ var selectParser = (def, typeName, refs) => {
|
|
|
10780
10556
|
case "ZodFunction":
|
|
10781
10557
|
case "ZodVoid":
|
|
10782
10558
|
case "ZodSymbol": return;
|
|
10783
|
-
default:
|
|
10559
|
+
default:
|
|
10560
|
+
/* c8 ignore next */
|
|
10561
|
+
return ((_) => void 0)(typeName);
|
|
10784
10562
|
}
|
|
10785
10563
|
};
|
|
10786
|
-
|
|
10564
|
+
const getRelativePath = (pathA, pathB) => {
|
|
10787
10565
|
let i = 0;
|
|
10788
10566
|
for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
|
|
10789
10567
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
10790
10568
|
};
|
|
10791
10569
|
function parseDef(def, refs, forceResolution = false) {
|
|
10792
|
-
var _a3;
|
|
10793
10570
|
const seenItem = refs.seen.get(def);
|
|
10794
10571
|
if (refs.override) {
|
|
10795
|
-
const overrideResult =
|
|
10572
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
10796
10573
|
if (overrideResult !== ignoreOverride) return overrideResult;
|
|
10797
10574
|
}
|
|
10798
10575
|
if (seenItem && !forceResolution) {
|
|
@@ -10806,17 +10583,17 @@ function parseDef(def, refs, forceResolution = false) {
|
|
|
10806
10583
|
};
|
|
10807
10584
|
refs.seen.set(def, newItem);
|
|
10808
10585
|
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
10809
|
-
const
|
|
10810
|
-
if (
|
|
10586
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10587
|
+
if (jsonSchema) addMeta(def, refs, jsonSchema);
|
|
10811
10588
|
if (refs.postProcess) {
|
|
10812
|
-
const postProcessResult = refs.postProcess(
|
|
10813
|
-
newItem.jsonSchema =
|
|
10589
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
10590
|
+
newItem.jsonSchema = jsonSchema;
|
|
10814
10591
|
return postProcessResult;
|
|
10815
10592
|
}
|
|
10816
|
-
newItem.jsonSchema =
|
|
10817
|
-
return
|
|
10593
|
+
newItem.jsonSchema = jsonSchema;
|
|
10594
|
+
return jsonSchema;
|
|
10818
10595
|
}
|
|
10819
|
-
|
|
10596
|
+
const get$ref = (item, refs) => {
|
|
10820
10597
|
switch (refs.$refStrategy) {
|
|
10821
10598
|
case "root": return { $ref: item.path.join("/") };
|
|
10822
10599
|
case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
@@ -10828,252 +10605,617 @@ var get$ref = (item, refs) => {
|
|
|
10828
10605
|
}
|
|
10829
10606
|
return refs.$refStrategy === "seen" ? parseAnyDef() : void 0;
|
|
10830
10607
|
}
|
|
10831
|
-
};
|
|
10832
|
-
|
|
10833
|
-
if (def.description)
|
|
10834
|
-
return
|
|
10835
|
-
};
|
|
10836
|
-
|
|
10837
|
-
const _options = getDefaultOptions(options);
|
|
10838
|
-
const currentPath = _options.name !== void 0 ? [
|
|
10839
|
-
..._options.basePath,
|
|
10840
|
-
_options.definitionPath,
|
|
10841
|
-
_options.name
|
|
10842
|
-
] : _options.basePath;
|
|
10843
|
-
return {
|
|
10844
|
-
..._options,
|
|
10845
|
-
currentPath,
|
|
10846
|
-
propertyPath: void 0,
|
|
10847
|
-
seen: new Map(Object.entries(_options.definitions).map(([
|
|
10848
|
-
def: def._def,
|
|
10849
|
-
path: [
|
|
10850
|
-
..._options.basePath,
|
|
10851
|
-
_options.definitionPath,
|
|
10852
|
-
|
|
10853
|
-
],
|
|
10854
|
-
jsonSchema: void 0
|
|
10855
|
-
}]))
|
|
10856
|
-
};
|
|
10857
|
-
};
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10608
|
+
};
|
|
10609
|
+
const addMeta = (def, refs, jsonSchema) => {
|
|
10610
|
+
if (def.description) jsonSchema.description = def.description;
|
|
10611
|
+
return jsonSchema;
|
|
10612
|
+
};
|
|
10613
|
+
const getRefs = (options) => {
|
|
10614
|
+
const _options = getDefaultOptions(options);
|
|
10615
|
+
const currentPath = _options.name !== void 0 ? [
|
|
10616
|
+
..._options.basePath,
|
|
10617
|
+
_options.definitionPath,
|
|
10618
|
+
_options.name
|
|
10619
|
+
] : _options.basePath;
|
|
10620
|
+
return {
|
|
10621
|
+
..._options,
|
|
10622
|
+
currentPath,
|
|
10623
|
+
propertyPath: void 0,
|
|
10624
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
|
|
10625
|
+
def: def._def,
|
|
10626
|
+
path: [
|
|
10627
|
+
..._options.basePath,
|
|
10628
|
+
_options.definitionPath,
|
|
10629
|
+
name
|
|
10630
|
+
],
|
|
10631
|
+
jsonSchema: void 0
|
|
10632
|
+
}]))
|
|
10633
|
+
};
|
|
10634
|
+
};
|
|
10635
|
+
const zod3ToJsonSchema = (schema, options) => {
|
|
10636
|
+
const refs = getRefs(options);
|
|
10637
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
|
|
10638
|
+
...acc,
|
|
10639
|
+
[name]: parseDef(schema._def, {
|
|
10640
|
+
...refs,
|
|
10641
|
+
currentPath: [
|
|
10642
|
+
...refs.basePath,
|
|
10643
|
+
refs.definitionPath,
|
|
10644
|
+
name
|
|
10645
|
+
]
|
|
10646
|
+
}, true) ?? parseAnyDef()
|
|
10647
|
+
}), {}) : void 0;
|
|
10648
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
10649
|
+
const main = parseDef(schema._def, name === void 0 ? refs : {
|
|
10650
|
+
...refs,
|
|
10651
|
+
currentPath: [
|
|
10652
|
+
...refs.basePath,
|
|
10653
|
+
refs.definitionPath,
|
|
10654
|
+
name
|
|
10655
|
+
]
|
|
10656
|
+
}, false) ?? parseAnyDef();
|
|
10657
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10658
|
+
if (title !== void 0) main.title = title;
|
|
10659
|
+
const combined = name === void 0 ? definitions ? {
|
|
10660
|
+
...main,
|
|
10661
|
+
[refs.definitionPath]: definitions
|
|
10662
|
+
} : main : {
|
|
10663
|
+
$ref: [
|
|
10664
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10665
|
+
refs.definitionPath,
|
|
10666
|
+
name
|
|
10667
|
+
].join("/"),
|
|
10668
|
+
[refs.definitionPath]: {
|
|
10669
|
+
...definitions,
|
|
10670
|
+
[name]: main
|
|
10671
|
+
}
|
|
10672
|
+
};
|
|
10673
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10674
|
+
return combined;
|
|
10675
|
+
};
|
|
10676
|
+
/**
|
|
10677
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
|
10678
|
+
*/
|
|
10679
|
+
const schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
10680
|
+
/**
|
|
10681
|
+
* Create a schema using a JSON Schema.
|
|
10682
|
+
*
|
|
10683
|
+
* @param jsonSchema The JSON Schema for the schema.
|
|
10684
|
+
* @param options.validate Optional. A validation function for the schema.
|
|
10685
|
+
*/
|
|
10686
|
+
function jsonSchema(jsonSchema, { validate } = {}) {
|
|
10687
|
+
return {
|
|
10688
|
+
[schemaSymbol]: true,
|
|
10689
|
+
_type: void 0,
|
|
10690
|
+
get jsonSchema() {
|
|
10691
|
+
if (typeof jsonSchema === "function") jsonSchema = jsonSchema();
|
|
10692
|
+
return jsonSchema;
|
|
10693
|
+
},
|
|
10694
|
+
validate
|
|
10695
|
+
};
|
|
10696
|
+
}
|
|
10697
|
+
function isSchema(value) {
|
|
10698
|
+
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
10699
|
+
}
|
|
10700
|
+
function asSchema(schema) {
|
|
10701
|
+
return schema == null ? jsonSchema({
|
|
10702
|
+
type: "object",
|
|
10703
|
+
properties: {},
|
|
10704
|
+
additionalProperties: false
|
|
10705
|
+
}) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
10706
|
+
}
|
|
10707
|
+
function standardSchema(standardSchema) {
|
|
10708
|
+
return jsonSchema(() => {
|
|
10709
|
+
if (!hasStandardJsonSchema(standardSchema)) throw new Error(`Standard schema vendor '${standardSchema["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
10710
|
+
return addAdditionalPropertiesToJsonSchema(standardSchema["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
10711
|
+
}, { validate: async (value) => {
|
|
10712
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
10713
|
+
return "value" in result ? {
|
|
10714
|
+
success: true,
|
|
10715
|
+
value: result.value
|
|
10716
|
+
} : {
|
|
10717
|
+
success: false,
|
|
10718
|
+
error: new TypeValidationError$1({
|
|
10719
|
+
value,
|
|
10720
|
+
cause: result.issues
|
|
10721
|
+
})
|
|
10722
|
+
};
|
|
10723
|
+
} });
|
|
10724
|
+
}
|
|
10725
|
+
function hasStandardJsonSchema(schema) {
|
|
10726
|
+
return schema["~standard"].jsonSchema != null;
|
|
10727
|
+
}
|
|
10728
|
+
function zod3Schema(zodSchema, options) {
|
|
10729
|
+
const useReferences = options?.useReferences ?? false;
|
|
10730
|
+
return jsonSchema(() => zod3ToJsonSchema(zodSchema, { $refStrategy: useReferences ? "root" : "none" }), { validate: async (value) => {
|
|
10731
|
+
const result = await zodSchema.safeParseAsync(value);
|
|
10732
|
+
return result.success ? {
|
|
10733
|
+
success: true,
|
|
10734
|
+
value: result.data
|
|
10735
|
+
} : {
|
|
10736
|
+
success: false,
|
|
10737
|
+
error: result.error
|
|
10738
|
+
};
|
|
10739
|
+
} });
|
|
10740
|
+
}
|
|
10741
|
+
function zod4Schema(zodSchema, options) {
|
|
10742
|
+
const useReferences = options?.useReferences ?? false;
|
|
10743
|
+
return jsonSchema(() => addAdditionalPropertiesToJsonSchema((0, zod_v4_core.toJSONSchema)(zodSchema, {
|
|
10744
|
+
target: "draft-7",
|
|
10745
|
+
io: "input",
|
|
10746
|
+
reused: useReferences ? "ref" : "inline"
|
|
10747
|
+
})), { validate: async (value) => {
|
|
10748
|
+
const result = await (0, zod_v4.safeParseAsync)(zodSchema, value);
|
|
10749
|
+
return result.success ? {
|
|
10750
|
+
success: true,
|
|
10751
|
+
value: result.data
|
|
10752
|
+
} : {
|
|
10753
|
+
success: false,
|
|
10754
|
+
error: result.error
|
|
10755
|
+
};
|
|
10756
|
+
} });
|
|
10757
|
+
}
|
|
10758
|
+
function isZod4Schema(zodSchema) {
|
|
10759
|
+
return "_zod" in zodSchema;
|
|
10760
|
+
}
|
|
10761
|
+
function zodSchema(zodSchema, options) {
|
|
10762
|
+
if (isZod4Schema(zodSchema)) return zod4Schema(zodSchema, options);
|
|
10763
|
+
else return zod3Schema(zodSchema, options);
|
|
10764
|
+
}
|
|
10765
|
+
/**
|
|
10766
|
+
* Validates the types of an unknown object using a schema and
|
|
10767
|
+
* return a strongly-typed object.
|
|
10768
|
+
*
|
|
10769
|
+
* @template T - The type of the object to validate.
|
|
10770
|
+
* @param {string} options.value - The object to validate.
|
|
10771
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
10772
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
10773
|
+
* @returns {Promise<T>} - The typed object.
|
|
10774
|
+
*/
|
|
10775
|
+
async function validateTypes({ value, schema, context }) {
|
|
10776
|
+
const result = await safeValidateTypes({
|
|
10777
|
+
value,
|
|
10778
|
+
schema,
|
|
10779
|
+
context
|
|
10780
|
+
});
|
|
10781
|
+
if (!result.success) throw TypeValidationError$1.wrap({
|
|
10782
|
+
value,
|
|
10783
|
+
cause: result.error,
|
|
10784
|
+
context
|
|
10785
|
+
});
|
|
10786
|
+
return result.value;
|
|
10787
|
+
}
|
|
10788
|
+
/**
|
|
10789
|
+
* Safely validates the types of an unknown object using a schema and
|
|
10790
|
+
* return a strongly-typed object.
|
|
10791
|
+
*
|
|
10792
|
+
* @template T - The type of the object to validate.
|
|
10793
|
+
* @param {string} options.value - The JSON object to validate.
|
|
10794
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
10795
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
10796
|
+
* @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
10797
|
+
*/
|
|
10798
|
+
async function safeValidateTypes({ value, schema, context }) {
|
|
10799
|
+
const actualSchema = asSchema(schema);
|
|
10800
|
+
try {
|
|
10801
|
+
if (actualSchema.validate == null) return {
|
|
10802
|
+
success: true,
|
|
10803
|
+
value,
|
|
10804
|
+
rawValue: value
|
|
10805
|
+
};
|
|
10806
|
+
const result = await actualSchema.validate(value);
|
|
10807
|
+
if (result.success) return {
|
|
10808
|
+
success: true,
|
|
10809
|
+
value: result.value,
|
|
10810
|
+
rawValue: value
|
|
10811
|
+
};
|
|
10812
|
+
return {
|
|
10813
|
+
success: false,
|
|
10814
|
+
error: TypeValidationError$1.wrap({
|
|
10815
|
+
value,
|
|
10816
|
+
cause: result.error,
|
|
10817
|
+
context
|
|
10818
|
+
}),
|
|
10819
|
+
rawValue: value
|
|
10820
|
+
};
|
|
10821
|
+
} catch (error) {
|
|
10822
|
+
return {
|
|
10823
|
+
success: false,
|
|
10824
|
+
error: TypeValidationError$1.wrap({
|
|
10825
|
+
value,
|
|
10826
|
+
cause: error,
|
|
10827
|
+
context
|
|
10828
|
+
}),
|
|
10829
|
+
rawValue: value
|
|
10830
|
+
};
|
|
10831
|
+
}
|
|
10832
|
+
}
|
|
10833
|
+
async function safeParseJSON({ text, schema }) {
|
|
10834
|
+
try {
|
|
10835
|
+
const value = secureJsonParse(text);
|
|
10836
|
+
if (schema == null) return {
|
|
10837
|
+
success: true,
|
|
10838
|
+
value,
|
|
10839
|
+
rawValue: value
|
|
10840
|
+
};
|
|
10841
|
+
return await safeValidateTypes({
|
|
10842
|
+
value,
|
|
10843
|
+
schema
|
|
10844
|
+
});
|
|
10845
|
+
} catch (error) {
|
|
10846
|
+
return {
|
|
10847
|
+
success: false,
|
|
10848
|
+
error: JSONParseError$1.isInstance(error) ? error : new JSONParseError$1({
|
|
10849
|
+
text,
|
|
10850
|
+
cause: error
|
|
10851
|
+
}),
|
|
10852
|
+
rawValue: void 0
|
|
10853
|
+
};
|
|
10854
|
+
}
|
|
10855
|
+
}
|
|
10856
|
+
/**
|
|
10857
|
+
* Resolves a value that could be a raw value, a Promise, a function returning a value,
|
|
10858
|
+
* or a function returning a Promise.
|
|
10859
|
+
*/
|
|
10860
|
+
async function resolve(value) {
|
|
10861
|
+
if (typeof value === "function") value = value();
|
|
10862
|
+
return value;
|
|
10863
|
+
}
|
|
10864
|
+
new TextDecoder();
|
|
10865
|
+
var marker$2 = "vercel.ai.error";
|
|
10866
|
+
var symbol$2 = Symbol.for(marker$2);
|
|
10867
|
+
var _a$1;
|
|
10868
|
+
var _b$1;
|
|
10869
|
+
var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$2, _b$1) {
|
|
10870
|
+
/**
|
|
10871
|
+
* Creates an AI SDK Error.
|
|
10872
|
+
*
|
|
10873
|
+
* @param {Object} params - The parameters for creating the error.
|
|
10874
|
+
* @param {string} params.name - The name of the error.
|
|
10875
|
+
* @param {string} params.message - The error message.
|
|
10876
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
10877
|
+
*/
|
|
10878
|
+
constructor({ name: name16, message, cause }) {
|
|
10879
|
+
super(message);
|
|
10880
|
+
this[_a$1] = true;
|
|
10881
|
+
this.name = name16;
|
|
10882
|
+
this.cause = cause;
|
|
10883
|
+
}
|
|
10884
|
+
/**
|
|
10885
|
+
* Checks if the given error is an AI SDK Error.
|
|
10886
|
+
* @param {unknown} error - The error to check.
|
|
10887
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
10888
|
+
*/
|
|
10889
|
+
static isInstance(error) {
|
|
10890
|
+
return _AISDKError.hasMarker(error, marker$2);
|
|
10891
|
+
}
|
|
10892
|
+
static hasMarker(error, marker17) {
|
|
10893
|
+
const markerSymbol = Symbol.for(marker17);
|
|
10894
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
10895
|
+
}
|
|
10896
|
+
};
|
|
10897
|
+
var name$3 = "AI_APICallError";
|
|
10898
|
+
var marker2$1 = `vercel.ai.error.${name$3}`;
|
|
10899
|
+
var symbol2$1 = Symbol.for(marker2$1);
|
|
10900
|
+
var _a2$1;
|
|
10901
|
+
var _b2$1;
|
|
10902
|
+
(class extends (_b2$1 = AISDKError, _a2$1 = symbol2$1, _b2$1) {
|
|
10903
|
+
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
10904
|
+
super({
|
|
10905
|
+
name: name$3,
|
|
10906
|
+
message,
|
|
10907
|
+
cause
|
|
10908
|
+
});
|
|
10909
|
+
this[_a2$1] = true;
|
|
10910
|
+
this.url = url;
|
|
10911
|
+
this.requestBodyValues = requestBodyValues;
|
|
10912
|
+
this.statusCode = statusCode;
|
|
10913
|
+
this.responseHeaders = responseHeaders;
|
|
10914
|
+
this.responseBody = responseBody;
|
|
10915
|
+
this.isRetryable = isRetryable;
|
|
10916
|
+
this.data = data;
|
|
10917
|
+
}
|
|
10918
|
+
static isInstance(error) {
|
|
10919
|
+
return AISDKError.hasMarker(error, marker2$1);
|
|
10920
|
+
}
|
|
10921
|
+
});
|
|
10922
|
+
var name2$1 = "AI_EmptyResponseBodyError";
|
|
10923
|
+
var marker3$1 = `vercel.ai.error.${name2$1}`;
|
|
10924
|
+
var symbol3$1 = Symbol.for(marker3$1);
|
|
10925
|
+
var _a3$1;
|
|
10926
|
+
var _b3$1;
|
|
10927
|
+
(class extends (_b3$1 = AISDKError, _a3$1 = symbol3$1, _b3$1) {
|
|
10928
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
10929
|
+
super({
|
|
10930
|
+
name: name2$1,
|
|
10931
|
+
message
|
|
10932
|
+
});
|
|
10933
|
+
this[_a3$1] = true;
|
|
10934
|
+
}
|
|
10935
|
+
static isInstance(error) {
|
|
10936
|
+
return AISDKError.hasMarker(error, marker3$1);
|
|
10937
|
+
}
|
|
10938
|
+
});
|
|
10939
|
+
var name3$1 = "AI_EvaluationUnsupportedQuestionTypeError";
|
|
10940
|
+
var marker4$1 = `vercel.ai.error.${name3$1}`;
|
|
10941
|
+
var symbol4$1 = Symbol.for(marker4$1);
|
|
10942
|
+
var _a4$1;
|
|
10943
|
+
var _b4$1;
|
|
10944
|
+
(class extends (_b4$1 = AISDKError, _a4$1 = symbol4$1, _b4$1) {
|
|
10945
|
+
constructor({ questionId, questionType, provider, modelId, message = `Question "${questionId}" has type "${questionType}", which is not supported by provider "${provider}" and model "${modelId}".` }) {
|
|
10946
|
+
super({
|
|
10947
|
+
name: name3$1,
|
|
10948
|
+
message
|
|
10949
|
+
});
|
|
10950
|
+
this[_a4$1] = true;
|
|
10951
|
+
this.questionId = questionId;
|
|
10952
|
+
this.questionType = questionType;
|
|
10953
|
+
this.provider = provider;
|
|
10954
|
+
this.modelId = modelId;
|
|
10955
|
+
}
|
|
10956
|
+
static isInstance(error) {
|
|
10957
|
+
return AISDKError.hasMarker(error, marker4$1);
|
|
10958
|
+
}
|
|
10959
|
+
});
|
|
10960
|
+
function getErrorMessage(error) {
|
|
10961
|
+
if (error == null) return "unknown error";
|
|
10962
|
+
if (typeof error === "string") return error;
|
|
10963
|
+
if (error instanceof Error) return error.toString();
|
|
10964
|
+
return JSON.stringify(error);
|
|
10965
|
+
}
|
|
10966
|
+
var name4$1 = "AI_InvalidArgumentError";
|
|
10967
|
+
var marker5$1 = `vercel.ai.error.${name4$1}`;
|
|
10968
|
+
var symbol5$1 = Symbol.for(marker5$1);
|
|
10969
|
+
var _a5$1;
|
|
10970
|
+
var _b5$1;
|
|
10971
|
+
(class extends (_b5$1 = AISDKError, _a5$1 = symbol5$1, _b5$1) {
|
|
10972
|
+
constructor({ message, cause, argument }) {
|
|
10973
|
+
super({
|
|
10974
|
+
name: name4$1,
|
|
10975
|
+
message,
|
|
10976
|
+
cause
|
|
10977
|
+
});
|
|
10978
|
+
this[_a5$1] = true;
|
|
10979
|
+
this.argument = argument;
|
|
10980
|
+
}
|
|
10981
|
+
static isInstance(error) {
|
|
10982
|
+
return AISDKError.hasMarker(error, marker5$1);
|
|
10983
|
+
}
|
|
10984
|
+
});
|
|
10985
|
+
var name5$1 = "AI_InvalidPromptError";
|
|
10986
|
+
var marker6$1 = `vercel.ai.error.${name5$1}`;
|
|
10987
|
+
var symbol6$1 = Symbol.for(marker6$1);
|
|
10988
|
+
var _a6$1;
|
|
10989
|
+
var _b6$1;
|
|
10990
|
+
(class extends (_b6$1 = AISDKError, _a6$1 = symbol6$1, _b6$1) {
|
|
10991
|
+
constructor({ prompt, message, cause }) {
|
|
10992
|
+
super({
|
|
10993
|
+
name: name5$1,
|
|
10994
|
+
message: `Invalid prompt: ${message}`,
|
|
10995
|
+
cause
|
|
10996
|
+
});
|
|
10997
|
+
this[_a6$1] = true;
|
|
10998
|
+
this.prompt = prompt;
|
|
10999
|
+
}
|
|
11000
|
+
static isInstance(error) {
|
|
11001
|
+
return AISDKError.hasMarker(error, marker6$1);
|
|
11002
|
+
}
|
|
11003
|
+
});
|
|
11004
|
+
var name6$1 = "AI_InvalidResponseDataError";
|
|
11005
|
+
var marker7$1 = `vercel.ai.error.${name6$1}`;
|
|
11006
|
+
var symbol7$1 = Symbol.for(marker7$1);
|
|
11007
|
+
var _a7$1;
|
|
11008
|
+
var _b7$1;
|
|
11009
|
+
(class extends (_b7$1 = AISDKError, _a7$1 = symbol7$1, _b7$1) {
|
|
11010
|
+
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
11011
|
+
super({
|
|
11012
|
+
name: name6$1,
|
|
11013
|
+
message
|
|
11014
|
+
});
|
|
11015
|
+
this[_a7$1] = true;
|
|
11016
|
+
this.data = data;
|
|
11017
|
+
}
|
|
11018
|
+
static isInstance(error) {
|
|
11019
|
+
return AISDKError.hasMarker(error, marker7$1);
|
|
11020
|
+
}
|
|
11021
|
+
});
|
|
11022
|
+
var name7$1 = "AI_JSONParseError";
|
|
11023
|
+
var marker8$1 = `vercel.ai.error.${name7$1}`;
|
|
11024
|
+
var symbol8$1 = Symbol.for(marker8$1);
|
|
11025
|
+
var _a8$1;
|
|
11026
|
+
var _b8$1;
|
|
11027
|
+
(class extends (_b8$1 = AISDKError, _a8$1 = symbol8$1, _b8$1) {
|
|
11028
|
+
constructor({ text, cause }) {
|
|
11029
|
+
super({
|
|
11030
|
+
name: name7$1,
|
|
11031
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
11032
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
11033
|
+
cause
|
|
11034
|
+
});
|
|
11035
|
+
this[_a8$1] = true;
|
|
11036
|
+
this.text = text;
|
|
11037
|
+
}
|
|
11038
|
+
static isInstance(error) {
|
|
11039
|
+
return AISDKError.hasMarker(error, marker8$1);
|
|
11040
|
+
}
|
|
11041
|
+
});
|
|
11042
|
+
var name8$1 = "AI_LoadAPIKeyError";
|
|
11043
|
+
var marker9$1 = `vercel.ai.error.${name8$1}`;
|
|
11044
|
+
var symbol9$1 = Symbol.for(marker9$1);
|
|
11045
|
+
var _a9$1;
|
|
11046
|
+
var _b9$1;
|
|
11047
|
+
(class extends (_b9$1 = AISDKError, _a9$1 = symbol9$1, _b9$1) {
|
|
11048
|
+
constructor({ message }) {
|
|
11049
|
+
super({
|
|
11050
|
+
name: name8$1,
|
|
11051
|
+
message
|
|
11052
|
+
});
|
|
11053
|
+
this[_a9$1] = true;
|
|
11054
|
+
}
|
|
11055
|
+
static isInstance(error) {
|
|
11056
|
+
return AISDKError.hasMarker(error, marker9$1);
|
|
11057
|
+
}
|
|
11058
|
+
});
|
|
11059
|
+
var name9$1 = "AI_LoadSettingError";
|
|
11060
|
+
var marker10$1 = `vercel.ai.error.${name9$1}`;
|
|
11061
|
+
var symbol10$1 = Symbol.for(marker10$1);
|
|
11062
|
+
var _a10$1;
|
|
11063
|
+
var _b10$1;
|
|
11064
|
+
(class extends (_b10$1 = AISDKError, _a10$1 = symbol10$1, _b10$1) {
|
|
11065
|
+
constructor({ message }) {
|
|
11066
|
+
super({
|
|
11067
|
+
name: name9$1,
|
|
11068
|
+
message
|
|
11069
|
+
});
|
|
11070
|
+
this[_a10$1] = true;
|
|
11071
|
+
}
|
|
11072
|
+
static isInstance(error) {
|
|
11073
|
+
return AISDKError.hasMarker(error, marker10$1);
|
|
11074
|
+
}
|
|
11075
|
+
});
|
|
11076
|
+
var name10$1 = "AI_NoContentGeneratedError";
|
|
11077
|
+
var marker11$1 = `vercel.ai.error.${name10$1}`;
|
|
11078
|
+
var symbol11$1 = Symbol.for(marker11$1);
|
|
11079
|
+
var _a11$1;
|
|
11080
|
+
var _b11$1;
|
|
11081
|
+
(class extends (_b11$1 = AISDKError, _a11$1 = symbol11$1, _b11$1) {
|
|
11082
|
+
constructor({ message = "No content generated." } = {}) {
|
|
11083
|
+
super({
|
|
11084
|
+
name: name10$1,
|
|
11085
|
+
message
|
|
11086
|
+
});
|
|
11087
|
+
this[_a11$1] = true;
|
|
11088
|
+
}
|
|
11089
|
+
static isInstance(error) {
|
|
11090
|
+
return AISDKError.hasMarker(error, marker11$1);
|
|
11091
|
+
}
|
|
11092
|
+
});
|
|
11093
|
+
var name11$1 = "AI_NoSuchModelError";
|
|
11094
|
+
var marker12$1 = `vercel.ai.error.${name11$1}`;
|
|
11095
|
+
var symbol12$1 = Symbol.for(marker12$1);
|
|
11096
|
+
var _a12$1;
|
|
11097
|
+
var _b12$1;
|
|
11098
|
+
var NoSuchModelError = class extends (_b12$1 = AISDKError, _a12$1 = symbol12$1, _b12$1) {
|
|
11099
|
+
constructor({ errorName = name11$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
11100
|
+
super({
|
|
11101
|
+
name: errorName,
|
|
11102
|
+
message
|
|
11103
|
+
});
|
|
11104
|
+
this[_a12$1] = true;
|
|
11105
|
+
this.modelId = modelId;
|
|
11106
|
+
this.modelType = modelType;
|
|
11107
|
+
}
|
|
11108
|
+
static isInstance(error) {
|
|
11109
|
+
return AISDKError.hasMarker(error, marker12$1);
|
|
11110
|
+
}
|
|
11111
|
+
};
|
|
11112
|
+
var name12$1 = "AI_NoSuchProviderReferenceError";
|
|
11113
|
+
var marker13$1 = `vercel.ai.error.${name12$1}`;
|
|
11114
|
+
var symbol13$1 = Symbol.for(marker13$1);
|
|
11115
|
+
var _a13$1;
|
|
11116
|
+
var _b13$1;
|
|
11117
|
+
(class extends (_b13$1 = AISDKError, _a13$1 = symbol13$1, _b13$1) {
|
|
11118
|
+
constructor({ provider, reference, message = `No provider reference found for provider '${provider}'. Available providers: ${Object.keys(reference).join(", ")}` }) {
|
|
11119
|
+
super({
|
|
11120
|
+
name: name12$1,
|
|
11121
|
+
message
|
|
11122
|
+
});
|
|
11123
|
+
this[_a13$1] = true;
|
|
11124
|
+
this.provider = provider;
|
|
11125
|
+
this.reference = reference;
|
|
11126
|
+
}
|
|
11127
|
+
static isInstance(error) {
|
|
11128
|
+
return AISDKError.hasMarker(error, marker13$1);
|
|
11129
|
+
}
|
|
11130
|
+
});
|
|
11131
|
+
var name13$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
11132
|
+
var marker14$1 = `vercel.ai.error.${name13$1}`;
|
|
11133
|
+
var symbol14$1 = Symbol.for(marker14$1);
|
|
11134
|
+
var _a14$1;
|
|
11135
|
+
var _b14$1;
|
|
11136
|
+
(class extends (_b14$1 = AISDKError, _a14$1 = symbol14$1, _b14$1) {
|
|
11137
|
+
constructor(options) {
|
|
11138
|
+
super({
|
|
11139
|
+
name: name13$1,
|
|
11140
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
|
11141
|
+
});
|
|
11142
|
+
this[_a14$1] = true;
|
|
11143
|
+
this.provider = options.provider;
|
|
11144
|
+
this.modelId = options.modelId;
|
|
11145
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
11146
|
+
this.values = options.values;
|
|
11147
|
+
}
|
|
11148
|
+
static isInstance(error) {
|
|
11149
|
+
return AISDKError.hasMarker(error, marker14$1);
|
|
11150
|
+
}
|
|
11151
|
+
});
|
|
11152
|
+
var name14$1 = "AI_TypeValidationError";
|
|
11153
|
+
var marker15$1 = `vercel.ai.error.${name14$1}`;
|
|
11154
|
+
var symbol15$1 = Symbol.for(marker15$1);
|
|
11155
|
+
var _a15$1;
|
|
11156
|
+
var _b15$1;
|
|
11157
|
+
var TypeValidationError = class _TypeValidationError extends (_b15$1 = AISDKError, _a15$1 = symbol15$1, _b15$1) {
|
|
11158
|
+
constructor({ value, cause, context }) {
|
|
11159
|
+
let contextPrefix = "Type validation failed";
|
|
11160
|
+
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
11161
|
+
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
|
11162
|
+
contextPrefix += " (";
|
|
11163
|
+
const parts = [];
|
|
11164
|
+
if (context.entityName) parts.push(context.entityName);
|
|
11165
|
+
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
11166
|
+
contextPrefix += parts.join(", ");
|
|
11167
|
+
contextPrefix += ")";
|
|
10898
11168
|
}
|
|
10899
|
-
|
|
10900
|
-
|
|
10901
|
-
|
|
10902
|
-
}
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
get jsonSchema() {
|
|
10909
|
-
if (typeof jsonSchema2 === "function") jsonSchema2 = jsonSchema2();
|
|
10910
|
-
return jsonSchema2;
|
|
10911
|
-
},
|
|
10912
|
-
validate
|
|
10913
|
-
};
|
|
10914
|
-
}
|
|
10915
|
-
function isSchema(value) {
|
|
10916
|
-
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
10917
|
-
}
|
|
10918
|
-
function asSchema(schema) {
|
|
10919
|
-
return schema == null ? jsonSchema({
|
|
10920
|
-
type: "object",
|
|
10921
|
-
properties: {},
|
|
10922
|
-
additionalProperties: false
|
|
10923
|
-
}) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
10924
|
-
}
|
|
10925
|
-
function standardSchema(standardSchema2) {
|
|
10926
|
-
return jsonSchema(() => {
|
|
10927
|
-
if (!hasStandardJsonSchema(standardSchema2)) throw new Error(`Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
10928
|
-
return addAdditionalPropertiesToJsonSchema(standardSchema2["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
10929
|
-
}, { validate: async (value) => {
|
|
10930
|
-
const result = await standardSchema2["~standard"].validate(value);
|
|
10931
|
-
return "value" in result ? {
|
|
10932
|
-
success: true,
|
|
10933
|
-
value: result.value
|
|
10934
|
-
} : {
|
|
10935
|
-
success: false,
|
|
10936
|
-
error: new TypeValidationError({
|
|
10937
|
-
value,
|
|
10938
|
-
cause: result.issues
|
|
10939
|
-
})
|
|
10940
|
-
};
|
|
10941
|
-
} });
|
|
10942
|
-
}
|
|
10943
|
-
function hasStandardJsonSchema(schema) {
|
|
10944
|
-
return schema["~standard"].jsonSchema != null;
|
|
10945
|
-
}
|
|
10946
|
-
function zod3Schema(zodSchema2, options) {
|
|
10947
|
-
var _a3;
|
|
10948
|
-
const useReferences = (_a3 = options == null ? void 0 : options.useReferences) != null ? _a3 : false;
|
|
10949
|
-
return jsonSchema(() => zod3ToJsonSchema(zodSchema2, { $refStrategy: useReferences ? "root" : "none" }), { validate: async (value) => {
|
|
10950
|
-
const result = await zodSchema2.safeParseAsync(value);
|
|
10951
|
-
return result.success ? {
|
|
10952
|
-
success: true,
|
|
10953
|
-
value: result.data
|
|
10954
|
-
} : {
|
|
10955
|
-
success: false,
|
|
10956
|
-
error: result.error
|
|
10957
|
-
};
|
|
10958
|
-
} });
|
|
10959
|
-
}
|
|
10960
|
-
function zod4Schema(zodSchema2, options) {
|
|
10961
|
-
var _a3;
|
|
10962
|
-
const useReferences = (_a3 = options == null ? void 0 : options.useReferences) != null ? _a3 : false;
|
|
10963
|
-
return jsonSchema(() => addAdditionalPropertiesToJsonSchema((0, zod_v4_core.toJSONSchema)(zodSchema2, {
|
|
10964
|
-
target: "draft-7",
|
|
10965
|
-
io: "input",
|
|
10966
|
-
reused: useReferences ? "ref" : "inline"
|
|
10967
|
-
})), { validate: async (value) => {
|
|
10968
|
-
const result = await (0, zod_v4.safeParseAsync)(zodSchema2, value);
|
|
10969
|
-
return result.success ? {
|
|
10970
|
-
success: true,
|
|
10971
|
-
value: result.data
|
|
10972
|
-
} : {
|
|
10973
|
-
success: false,
|
|
10974
|
-
error: result.error
|
|
10975
|
-
};
|
|
10976
|
-
} });
|
|
10977
|
-
}
|
|
10978
|
-
function isZod4Schema(zodSchema2) {
|
|
10979
|
-
return "_zod" in zodSchema2;
|
|
10980
|
-
}
|
|
10981
|
-
function zodSchema(zodSchema2, options) {
|
|
10982
|
-
if (isZod4Schema(zodSchema2)) return zod4Schema(zodSchema2, options);
|
|
10983
|
-
else return zod3Schema(zodSchema2, options);
|
|
10984
|
-
}
|
|
10985
|
-
async function validateTypes({ value, schema, context }) {
|
|
10986
|
-
const result = await safeValidateTypes({
|
|
10987
|
-
value,
|
|
10988
|
-
schema,
|
|
10989
|
-
context
|
|
10990
|
-
});
|
|
10991
|
-
if (!result.success) throw TypeValidationError.wrap({
|
|
10992
|
-
value,
|
|
10993
|
-
cause: result.error,
|
|
10994
|
-
context
|
|
10995
|
-
});
|
|
10996
|
-
return result.value;
|
|
10997
|
-
}
|
|
10998
|
-
async function safeValidateTypes({ value, schema, context }) {
|
|
10999
|
-
const actualSchema = asSchema(schema);
|
|
11000
|
-
try {
|
|
11001
|
-
if (actualSchema.validate == null) return {
|
|
11002
|
-
success: true,
|
|
11003
|
-
value,
|
|
11004
|
-
rawValue: value
|
|
11005
|
-
};
|
|
11006
|
-
const result = await actualSchema.validate(value);
|
|
11007
|
-
if (result.success) return {
|
|
11008
|
-
success: true,
|
|
11009
|
-
value: result.value,
|
|
11010
|
-
rawValue: value
|
|
11011
|
-
};
|
|
11012
|
-
return {
|
|
11013
|
-
success: false,
|
|
11014
|
-
error: TypeValidationError.wrap({
|
|
11015
|
-
value,
|
|
11016
|
-
cause: result.error,
|
|
11017
|
-
context
|
|
11018
|
-
}),
|
|
11019
|
-
rawValue: value
|
|
11020
|
-
};
|
|
11021
|
-
} catch (error) {
|
|
11022
|
-
return {
|
|
11023
|
-
success: false,
|
|
11024
|
-
error: TypeValidationError.wrap({
|
|
11025
|
-
value,
|
|
11026
|
-
cause: error,
|
|
11027
|
-
context
|
|
11028
|
-
}),
|
|
11029
|
-
rawValue: value
|
|
11030
|
-
};
|
|
11169
|
+
super({
|
|
11170
|
+
name: name14$1,
|
|
11171
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
11172
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
11173
|
+
cause
|
|
11174
|
+
});
|
|
11175
|
+
this[_a15$1] = true;
|
|
11176
|
+
this.value = value;
|
|
11177
|
+
this.context = context;
|
|
11031
11178
|
}
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11179
|
+
static isInstance(error) {
|
|
11180
|
+
return AISDKError.hasMarker(error, marker15$1);
|
|
11181
|
+
}
|
|
11182
|
+
/**
|
|
11183
|
+
* Wraps an error into a TypeValidationError.
|
|
11184
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
11185
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
11186
|
+
*
|
|
11187
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
11188
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
11189
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
11190
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
11191
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
11192
|
+
*/
|
|
11193
|
+
static wrap({ value, cause, context }) {
|
|
11194
|
+
var _a17, _b17, _c;
|
|
11195
|
+
if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a17 = cause.context) == null ? void 0 : _a17.field) === (context == null ? void 0 : context.field) && ((_b17 = cause.context) == null ? void 0 : _b17.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) return cause;
|
|
11196
|
+
return new _TypeValidationError({
|
|
11042
11197
|
value,
|
|
11043
|
-
|
|
11198
|
+
cause,
|
|
11199
|
+
context
|
|
11044
11200
|
});
|
|
11045
|
-
} catch (error) {
|
|
11046
|
-
return {
|
|
11047
|
-
success: false,
|
|
11048
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({
|
|
11049
|
-
text,
|
|
11050
|
-
cause: error
|
|
11051
|
-
}),
|
|
11052
|
-
rawValue: void 0
|
|
11053
|
-
};
|
|
11054
11201
|
}
|
|
11055
|
-
}
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
var symbol2$2 = Symbol.for(marker3$2);
|
|
11064
|
-
var _a2$2;
|
|
11065
|
-
var _b2$2;
|
|
11066
|
-
(class extends (_b2$2 = AISDKError, _a2$2 = symbol2$2, _b2$2) {
|
|
11067
|
-
constructor({ message = "Failed to serialize value.", cause } = {}) {
|
|
11202
|
+
};
|
|
11203
|
+
var name15$1 = "AI_UnsupportedFunctionalityError";
|
|
11204
|
+
var marker16$1 = `vercel.ai.error.${name15$1}`;
|
|
11205
|
+
var symbol16$1 = Symbol.for(marker16$1);
|
|
11206
|
+
var _a16$1;
|
|
11207
|
+
var _b16$1;
|
|
11208
|
+
(class extends (_b16$1 = AISDKError, _a16$1 = symbol16$1, _b16$1) {
|
|
11209
|
+
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
11068
11210
|
super({
|
|
11069
|
-
name:
|
|
11070
|
-
message
|
|
11071
|
-
cause
|
|
11211
|
+
name: name15$1,
|
|
11212
|
+
message
|
|
11072
11213
|
});
|
|
11073
|
-
this[
|
|
11214
|
+
this[_a16$1] = true;
|
|
11215
|
+
this.functionality = functionality;
|
|
11074
11216
|
}
|
|
11075
11217
|
static isInstance(error) {
|
|
11076
|
-
return AISDKError.hasMarker(error,
|
|
11218
|
+
return AISDKError.hasMarker(error, marker16$1);
|
|
11077
11219
|
}
|
|
11078
11220
|
});
|
|
11079
11221
|
//#endregion
|
|
@@ -16401,11 +16543,7 @@ function createProcessorMiddleware(options) {
|
|
|
16401
16543
|
state: {},
|
|
16402
16544
|
result: {
|
|
16403
16545
|
text: "",
|
|
16404
|
-
usage:
|
|
16405
|
-
inputTokens: 0,
|
|
16406
|
-
outputTokens: 0,
|
|
16407
|
-
totalTokens: 0
|
|
16408
|
-
},
|
|
16546
|
+
usage: result.usage,
|
|
16409
16547
|
finishReason: "unknown",
|
|
16410
16548
|
steps: []
|
|
16411
16549
|
},
|
|
@@ -16529,9 +16667,9 @@ function createProcessorMiddleware(options) {
|
|
|
16529
16667
|
const outputResult = {
|
|
16530
16668
|
text: (procState?.streamParts ?? []).filter((p) => p.type === "text-delta").map((p) => p.payload?.text ?? "").join(""),
|
|
16531
16669
|
usage: finishChunk?.payload?.output?.usage ?? {
|
|
16532
|
-
inputTokens: 0,
|
|
16533
|
-
outputTokens: 0,
|
|
16534
|
-
totalTokens: 0
|
|
16670
|
+
inputTokens: void 0,
|
|
16671
|
+
outputTokens: void 0,
|
|
16672
|
+
totalTokens: void 0
|
|
16535
16673
|
},
|
|
16536
16674
|
finishReason: finishChunk?.payload?.stepResult?.reason ?? "unknown",
|
|
16537
16675
|
steps: []
|
|
@@ -16715,14 +16853,10 @@ function convertMastraChunkToAISDKStreamPart(chunk) {
|
|
|
16715
16853
|
return {
|
|
16716
16854
|
type: "finish",
|
|
16717
16855
|
finishReason: toAISDKFinishReason(chunk.payload.stepResult?.reason || "stop"),
|
|
16718
|
-
usage:
|
|
16719
|
-
inputTokens: usage
|
|
16720
|
-
outputTokens: usage
|
|
16721
|
-
totalTokens: usage
|
|
16722
|
-
} : {
|
|
16723
|
-
inputTokens: 0,
|
|
16724
|
-
outputTokens: 0,
|
|
16725
|
-
totalTokens: 0
|
|
16856
|
+
usage: {
|
|
16857
|
+
inputTokens: usage?.inputTokens,
|
|
16858
|
+
outputTokens: usage?.outputTokens,
|
|
16859
|
+
totalTokens: usage?.totalTokens
|
|
16726
16860
|
},
|
|
16727
16861
|
providerMetadata: chunk.payload.metadata?.providerMetadata
|
|
16728
16862
|
};
|