@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.js
CHANGED
|
@@ -10,12 +10,12 @@ import { MASTRA_RESOURCE_ID_KEY } from "@mastra/core/request-context";
|
|
|
10
10
|
import { MessageList, TripWire, aiV5ModelMessageToV2PromptMessage } from "@mastra/core/agent";
|
|
11
11
|
import { RequestContext } from "@mastra/core/di";
|
|
12
12
|
import { MessageHistory, SemanticRecall, WorkingMemory } from "@mastra/core/processors";
|
|
13
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
14
|
-
var marker$2$
|
|
15
|
-
var symbol$2$3 = Symbol.for(marker$2$
|
|
16
|
-
var _a$2$
|
|
17
|
-
var _b$2$
|
|
18
|
-
var AISDKError$1$3 = class _AISDKError extends (_b$2$
|
|
13
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-DqVGDtnX.js
|
|
14
|
+
var marker$2$5 = "vercel.ai.error";
|
|
15
|
+
var symbol$2$3 = Symbol.for(marker$2$5);
|
|
16
|
+
var _a$2$2;
|
|
17
|
+
var _b$2$5;
|
|
18
|
+
var AISDKError$1$3 = class _AISDKError extends (_b$2$5 = Error, _a$2$2 = symbol$2$3, _b$2$5) {
|
|
19
19
|
/**
|
|
20
20
|
* Creates an AI SDK Error.
|
|
21
21
|
*
|
|
@@ -26,7 +26,7 @@ var AISDKError$1$3 = class _AISDKError extends (_b$2$4 = Error, _a$2$3 = symbol$
|
|
|
26
26
|
*/
|
|
27
27
|
constructor({ name: name14, message, cause }) {
|
|
28
28
|
super(message);
|
|
29
|
-
this[_a$2$
|
|
29
|
+
this[_a$2$2] = true;
|
|
30
30
|
this.name = name14;
|
|
31
31
|
this.cause = cause;
|
|
32
32
|
}
|
|
@@ -36,26 +36,26 @@ var AISDKError$1$3 = class _AISDKError extends (_b$2$4 = Error, _a$2$3 = symbol$
|
|
|
36
36
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
37
37
|
*/
|
|
38
38
|
static isInstance(error) {
|
|
39
|
-
return _AISDKError.hasMarker(error, marker$2$
|
|
39
|
+
return _AISDKError.hasMarker(error, marker$2$5);
|
|
40
40
|
}
|
|
41
41
|
static hasMarker(error, marker15) {
|
|
42
42
|
const markerSymbol = Symbol.for(marker15);
|
|
43
43
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
var name$2$
|
|
47
|
-
var marker2$1$
|
|
48
|
-
var symbol2$1$
|
|
49
|
-
var _a2$1$
|
|
50
|
-
var _b2$1$
|
|
51
|
-
var APICallError$1$3 = class extends (_b2$1$
|
|
46
|
+
var name$2$6 = "AI_APICallError";
|
|
47
|
+
var marker2$1$3 = `vercel.ai.error.${name$2$6}`;
|
|
48
|
+
var symbol2$1$3 = Symbol.for(marker2$1$3);
|
|
49
|
+
var _a2$1$3;
|
|
50
|
+
var _b2$1$2;
|
|
51
|
+
var APICallError$1$3 = class extends (_b2$1$2 = AISDKError$1$3, _a2$1$3 = symbol2$1$3, _b2$1$2) {
|
|
52
52
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
53
53
|
super({
|
|
54
|
-
name: name$2$
|
|
54
|
+
name: name$2$6,
|
|
55
55
|
message,
|
|
56
56
|
cause
|
|
57
57
|
});
|
|
58
|
-
this[_a2$1$
|
|
58
|
+
this[_a2$1$3] = true;
|
|
59
59
|
this.url = url;
|
|
60
60
|
this.requestBodyValues = requestBodyValues;
|
|
61
61
|
this.statusCode = statusCode;
|
|
@@ -65,27 +65,27 @@ var APICallError$1$3 = class extends (_b2$1$5 = AISDKError$1$3, _a2$1$7 = symbol
|
|
|
65
65
|
this.data = data;
|
|
66
66
|
}
|
|
67
67
|
static isInstance(error) {
|
|
68
|
-
return AISDKError$1$3.hasMarker(error, marker2$1$
|
|
68
|
+
return AISDKError$1$3.hasMarker(error, marker2$1$3);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
var name2$1$
|
|
72
|
-
var marker3$1$
|
|
73
|
-
var symbol3$1$3 = Symbol.for(marker3$1$
|
|
71
|
+
var name2$1$3 = "AI_EmptyResponseBodyError";
|
|
72
|
+
var marker3$1$3 = `vercel.ai.error.${name2$1$3}`;
|
|
73
|
+
var symbol3$1$3 = Symbol.for(marker3$1$3);
|
|
74
74
|
var _a3$1$3;
|
|
75
75
|
var _b3$1$2;
|
|
76
76
|
var EmptyResponseBodyError$1$3 = class extends (_b3$1$2 = AISDKError$1$3, _a3$1$3 = symbol3$1$3, _b3$1$2) {
|
|
77
77
|
constructor({ message = "Empty response body" } = {}) {
|
|
78
78
|
super({
|
|
79
|
-
name: name2$1$
|
|
79
|
+
name: name2$1$3,
|
|
80
80
|
message
|
|
81
81
|
});
|
|
82
82
|
this[_a3$1$3] = true;
|
|
83
83
|
}
|
|
84
84
|
static isInstance(error) {
|
|
85
|
-
return AISDKError$1$3.hasMarker(error, marker3$1$
|
|
85
|
+
return AISDKError$1$3.hasMarker(error, marker3$1$3);
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
function getErrorMessage$2$
|
|
88
|
+
function getErrorMessage$2$2(error) {
|
|
89
89
|
if (error == null) return "unknown error";
|
|
90
90
|
if (typeof error === "string") return error;
|
|
91
91
|
if (error instanceof Error) return error.message;
|
|
@@ -96,7 +96,7 @@ var marker4$1$3 = `vercel.ai.error.${name3$1$3}`;
|
|
|
96
96
|
var symbol4$1$3 = Symbol.for(marker4$1$3);
|
|
97
97
|
var _a4$1$3;
|
|
98
98
|
var _b4$1$2;
|
|
99
|
-
var InvalidArgumentError$1$
|
|
99
|
+
var InvalidArgumentError$1$5 = class extends (_b4$1$2 = AISDKError$1$3, _a4$1$3 = symbol4$1$3, _b4$1$2) {
|
|
100
100
|
constructor({ message, cause, argument }) {
|
|
101
101
|
super({
|
|
102
102
|
name: name3$1$3,
|
|
@@ -157,7 +157,7 @@ var JSONParseError$1$3 = class extends (_b7$1$2 = AISDKError$1$3, _a7$1$3 = symb
|
|
|
157
157
|
super({
|
|
158
158
|
name: name6$1$3,
|
|
159
159
|
message: `JSON parsing failed: Text: ${text}.
|
|
160
|
-
Error message: ${getErrorMessage$2$
|
|
160
|
+
Error message: ${getErrorMessage$2$2(cause)}`,
|
|
161
161
|
cause
|
|
162
162
|
});
|
|
163
163
|
this[_a7$1$3] = true;
|
|
@@ -268,7 +268,7 @@ var TypeValidationError$1$3 = class _TypeValidationError extends (_b13$1$2 = AIS
|
|
|
268
268
|
super({
|
|
269
269
|
name: name12$1$2,
|
|
270
270
|
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
271
|
-
Error message: ${getErrorMessage$2$
|
|
271
|
+
Error message: ${getErrorMessage$2$2(cause)}`,
|
|
272
272
|
cause
|
|
273
273
|
});
|
|
274
274
|
this[_a13$1$2] = true;
|
|
@@ -501,31 +501,31 @@ var EventSourceParserStream$2 = class extends TransformStream {
|
|
|
501
501
|
function combineHeaders(...headers) {
|
|
502
502
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
503
503
|
...combinedHeaders,
|
|
504
|
-
...currentHeaders
|
|
504
|
+
...currentHeaders
|
|
505
505
|
}), {});
|
|
506
506
|
}
|
|
507
507
|
function extractResponseHeaders(response) {
|
|
508
508
|
return Object.fromEntries([...response.headers]);
|
|
509
509
|
}
|
|
510
|
-
var name$1$
|
|
511
|
-
var marker$1$
|
|
512
|
-
var symbol$1$7 = Symbol.for(marker$1$
|
|
513
|
-
var _a$1$
|
|
514
|
-
var _b$1$
|
|
515
|
-
var DownloadError$2 = class extends (_b$1$
|
|
510
|
+
var name$1$8 = "AI_DownloadError";
|
|
511
|
+
var marker$1$7 = `vercel.ai.error.${name$1$8}`;
|
|
512
|
+
var symbol$1$7 = Symbol.for(marker$1$7);
|
|
513
|
+
var _a$1$3;
|
|
514
|
+
var _b$1$4;
|
|
515
|
+
var DownloadError$2 = class extends (_b$1$4 = AISDKError$1$3, _a$1$3 = symbol$1$7, _b$1$4) {
|
|
516
516
|
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
517
517
|
super({
|
|
518
|
-
name: name$1$
|
|
518
|
+
name: name$1$8,
|
|
519
519
|
message,
|
|
520
520
|
cause
|
|
521
521
|
});
|
|
522
|
-
this[_a$1$
|
|
522
|
+
this[_a$1$3] = true;
|
|
523
523
|
this.url = url;
|
|
524
524
|
this.statusCode = statusCode;
|
|
525
525
|
this.statusText = statusText;
|
|
526
526
|
}
|
|
527
527
|
static isInstance(error) {
|
|
528
|
-
return AISDKError$1$3.hasMarker(error, marker$1$
|
|
528
|
+
return AISDKError$1$3.hasMarker(error, marker$1$7);
|
|
529
529
|
}
|
|
530
530
|
};
|
|
531
531
|
async function cancelResponseBody$2(response) {
|
|
@@ -607,7 +607,7 @@ var createIdGenerator$2 = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJ
|
|
|
607
607
|
return chars.join("");
|
|
608
608
|
};
|
|
609
609
|
if (prefix == null) return generator;
|
|
610
|
-
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$
|
|
610
|
+
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$5({
|
|
611
611
|
argument: "separator",
|
|
612
612
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
613
613
|
});
|
|
@@ -702,7 +702,7 @@ function withUserAgentSuffix$2(headers, ...userAgentSuffixParts) {
|
|
|
702
702
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
703
703
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
704
704
|
}
|
|
705
|
-
var VERSION$4 = "3.0.
|
|
705
|
+
var VERSION$4 = "3.0.40";
|
|
706
706
|
var getOriginalFetch = () => globalThis.fetch;
|
|
707
707
|
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch() }) => {
|
|
708
708
|
try {
|
|
@@ -1026,7 +1026,7 @@ async function resolve$2(value) {
|
|
|
1026
1026
|
if (typeof value === "function") value = value();
|
|
1027
1027
|
return Promise.resolve(value);
|
|
1028
1028
|
}
|
|
1029
|
-
var textDecoder$
|
|
1029
|
+
var textDecoder$3 = new TextDecoder();
|
|
1030
1030
|
function wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, responseHeaders }) {
|
|
1031
1031
|
const reader = stream.getReader();
|
|
1032
1032
|
let readerReleased = false;
|
|
@@ -1074,7 +1074,7 @@ function wrapResponseBodyStream({ stream, url, requestBodyValues, statusCode, re
|
|
|
1074
1074
|
});
|
|
1075
1075
|
}
|
|
1076
1076
|
async function readResponseBodyAsText({ response, url }) {
|
|
1077
|
-
return textDecoder$
|
|
1077
|
+
return textDecoder$3.decode(await readResponseWithSizeLimit$2({
|
|
1078
1078
|
response,
|
|
1079
1079
|
url
|
|
1080
1080
|
}));
|
|
@@ -1379,7 +1379,7 @@ var zodPatterns$2 = {
|
|
|
1379
1379
|
/**
|
|
1380
1380
|
* `a-z` was added to replicate /i flag
|
|
1381
1381
|
*/
|
|
1382
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
1382
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
1383
1383
|
/**
|
|
1384
1384
|
* Constructed a valid Unicode RegExp
|
|
1385
1385
|
*
|
|
@@ -2141,11 +2141,11 @@ var { btoa: btoa$3, atob: atob$3 } = globalThis;
|
|
|
2141
2141
|
function withoutTrailingSlash(url) {
|
|
2142
2142
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
2143
2143
|
}
|
|
2144
|
-
var marker$
|
|
2145
|
-
var symbol$
|
|
2146
|
-
var _a$
|
|
2147
|
-
var _b$
|
|
2148
|
-
var AISDKError$4 = class _AISDKError extends (_b$
|
|
2144
|
+
var marker$9 = "vercel.ai.error";
|
|
2145
|
+
var symbol$9 = Symbol.for(marker$9);
|
|
2146
|
+
var _a$5;
|
|
2147
|
+
var _b$5;
|
|
2148
|
+
var AISDKError$4 = class _AISDKError extends (_b$5 = Error, _a$5 = symbol$9, _b$5) {
|
|
2149
2149
|
/**
|
|
2150
2150
|
* Creates an AI SDK Error.
|
|
2151
2151
|
*
|
|
@@ -2156,7 +2156,7 @@ var AISDKError$4 = class _AISDKError extends (_b$6 = Error, _a$8 = symbol$8, _b$
|
|
|
2156
2156
|
*/
|
|
2157
2157
|
constructor({ name: name14, message, cause }) {
|
|
2158
2158
|
super(message);
|
|
2159
|
-
this[_a$
|
|
2159
|
+
this[_a$5] = true;
|
|
2160
2160
|
this.name = name14;
|
|
2161
2161
|
this.cause = cause;
|
|
2162
2162
|
}
|
|
@@ -2166,26 +2166,26 @@ var AISDKError$4 = class _AISDKError extends (_b$6 = Error, _a$8 = symbol$8, _b$
|
|
|
2166
2166
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
2167
2167
|
*/
|
|
2168
2168
|
static isInstance(error) {
|
|
2169
|
-
return _AISDKError.hasMarker(error, marker$
|
|
2169
|
+
return _AISDKError.hasMarker(error, marker$9);
|
|
2170
2170
|
}
|
|
2171
2171
|
static hasMarker(error, marker15) {
|
|
2172
2172
|
const markerSymbol = Symbol.for(marker15);
|
|
2173
2173
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
2174
2174
|
}
|
|
2175
2175
|
};
|
|
2176
|
-
var name$
|
|
2177
|
-
var marker2$
|
|
2178
|
-
var symbol2$
|
|
2179
|
-
var _a2$
|
|
2180
|
-
var _b2$
|
|
2181
|
-
var APICallError$4 = class extends (_b2$
|
|
2176
|
+
var name$9 = "AI_APICallError";
|
|
2177
|
+
var marker2$5 = `vercel.ai.error.${name$9}`;
|
|
2178
|
+
var symbol2$5 = Symbol.for(marker2$5);
|
|
2179
|
+
var _a2$5;
|
|
2180
|
+
var _b2$4;
|
|
2181
|
+
var APICallError$4 = class extends (_b2$4 = AISDKError$4, _a2$5 = symbol2$5, _b2$4) {
|
|
2182
2182
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
2183
2183
|
super({
|
|
2184
|
-
name: name$
|
|
2184
|
+
name: name$9,
|
|
2185
2185
|
message,
|
|
2186
2186
|
cause
|
|
2187
2187
|
});
|
|
2188
|
-
this[_a2$
|
|
2188
|
+
this[_a2$5] = true;
|
|
2189
2189
|
this.url = url;
|
|
2190
2190
|
this.requestBodyValues = requestBodyValues;
|
|
2191
2191
|
this.statusCode = statusCode;
|
|
@@ -2195,27 +2195,27 @@ var APICallError$4 = class extends (_b2$6 = AISDKError$4, _a2$8 = symbol2$8, _b2
|
|
|
2195
2195
|
this.data = data;
|
|
2196
2196
|
}
|
|
2197
2197
|
static isInstance(error) {
|
|
2198
|
-
return AISDKError$4.hasMarker(error, marker2$
|
|
2198
|
+
return AISDKError$4.hasMarker(error, marker2$5);
|
|
2199
2199
|
}
|
|
2200
2200
|
};
|
|
2201
|
-
var name2$
|
|
2202
|
-
var marker3$
|
|
2203
|
-
var symbol3$5 = Symbol.for(marker3$
|
|
2201
|
+
var name2$5 = "AI_EmptyResponseBodyError";
|
|
2202
|
+
var marker3$5 = `vercel.ai.error.${name2$5}`;
|
|
2203
|
+
var symbol3$5 = Symbol.for(marker3$5);
|
|
2204
2204
|
var _a3$5;
|
|
2205
2205
|
var _b3$4;
|
|
2206
2206
|
(class extends (_b3$4 = AISDKError$4, _a3$5 = symbol3$5, _b3$4) {
|
|
2207
2207
|
constructor({ message = "Empty response body" } = {}) {
|
|
2208
2208
|
super({
|
|
2209
|
-
name: name2$
|
|
2209
|
+
name: name2$5,
|
|
2210
2210
|
message
|
|
2211
2211
|
});
|
|
2212
2212
|
this[_a3$5] = true;
|
|
2213
2213
|
}
|
|
2214
2214
|
static isInstance(error) {
|
|
2215
|
-
return AISDKError$4.hasMarker(error, marker3$
|
|
2215
|
+
return AISDKError$4.hasMarker(error, marker3$5);
|
|
2216
2216
|
}
|
|
2217
2217
|
});
|
|
2218
|
-
function getErrorMessage$
|
|
2218
|
+
function getErrorMessage$4(error) {
|
|
2219
2219
|
if (error == null) return "unknown error";
|
|
2220
2220
|
if (typeof error === "string") return error;
|
|
2221
2221
|
if (error instanceof Error) return error.message;
|
|
@@ -2287,7 +2287,7 @@ var _b7$4;
|
|
|
2287
2287
|
super({
|
|
2288
2288
|
name: name6$5,
|
|
2289
2289
|
message: `JSON parsing failed: Text: ${text}.
|
|
2290
|
-
Error message: ${getErrorMessage$
|
|
2290
|
+
Error message: ${getErrorMessage$4(cause)}`,
|
|
2291
2291
|
cause
|
|
2292
2292
|
});
|
|
2293
2293
|
this[_a7$5] = true;
|
|
@@ -2398,7 +2398,7 @@ var _b13$3;
|
|
|
2398
2398
|
super({
|
|
2399
2399
|
name: name12$5,
|
|
2400
2400
|
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
|
2401
|
-
Error message: ${getErrorMessage$
|
|
2401
|
+
Error message: ${getErrorMessage$4(cause)}`,
|
|
2402
2402
|
cause
|
|
2403
2403
|
});
|
|
2404
2404
|
this[_a13$5] = true;
|
|
@@ -2452,12 +2452,12 @@ async function getVercelOidcToken() {
|
|
|
2452
2452
|
throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
|
|
2453
2453
|
}
|
|
2454
2454
|
var symbol$1$6 = Symbol.for("vercel.ai.gateway.error");
|
|
2455
|
-
var _a$1$
|
|
2455
|
+
var _a$1$2;
|
|
2456
2456
|
var _b$4;
|
|
2457
|
-
var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$
|
|
2457
|
+
var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$2 = symbol$1$6, _b$4) {
|
|
2458
2458
|
constructor({ message, statusCode = 500, cause }) {
|
|
2459
2459
|
super(message);
|
|
2460
|
-
this[_a$1$
|
|
2460
|
+
this[_a$1$2] = true;
|
|
2461
2461
|
this.statusCode = statusCode;
|
|
2462
2462
|
this.cause = cause;
|
|
2463
2463
|
}
|
|
@@ -2474,23 +2474,23 @@ var GatewayError = class _GatewayError extends (_b$4 = Error, _a$1$6 = symbol$1$
|
|
|
2474
2474
|
}
|
|
2475
2475
|
};
|
|
2476
2476
|
var name$1$6 = "GatewayAuthenticationError";
|
|
2477
|
-
var marker2$1$
|
|
2478
|
-
var symbol2$1$
|
|
2479
|
-
var _a2$1$
|
|
2477
|
+
var marker2$1$2 = `vercel.ai.gateway.error.${name$1$6}`;
|
|
2478
|
+
var symbol2$1$2 = Symbol.for(marker2$1$2);
|
|
2479
|
+
var _a2$1$2;
|
|
2480
2480
|
var _b2$3;
|
|
2481
|
-
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2$3 = GatewayError, _a2$1$
|
|
2481
|
+
var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2$3 = GatewayError, _a2$1$2 = symbol2$1$2, _b2$3) {
|
|
2482
2482
|
constructor({ message = "Authentication failed", statusCode = 401, cause } = {}) {
|
|
2483
2483
|
super({
|
|
2484
2484
|
message,
|
|
2485
2485
|
statusCode,
|
|
2486
2486
|
cause
|
|
2487
2487
|
});
|
|
2488
|
-
this[_a2$1$
|
|
2488
|
+
this[_a2$1$2] = true;
|
|
2489
2489
|
this.name = name$1$6;
|
|
2490
2490
|
this.type = "authentication_error";
|
|
2491
2491
|
}
|
|
2492
2492
|
static isInstance(error) {
|
|
2493
|
-
return GatewayError.hasMarker(error) && symbol2$1$
|
|
2493
|
+
return GatewayError.hasMarker(error) && symbol2$1$2 in error;
|
|
2494
2494
|
}
|
|
2495
2495
|
/**
|
|
2496
2496
|
* Creates a contextual error message when authentication fails
|
|
@@ -2522,9 +2522,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
2522
2522
|
});
|
|
2523
2523
|
}
|
|
2524
2524
|
};
|
|
2525
|
-
var name2$1$
|
|
2526
|
-
var marker3$1$
|
|
2527
|
-
var symbol3$1$2 = Symbol.for(marker3$1$
|
|
2525
|
+
var name2$1$2 = "GatewayForbiddenError";
|
|
2526
|
+
var marker3$1$2 = `vercel.ai.gateway.error.${name2$1$2}`;
|
|
2527
|
+
var symbol3$1$2 = Symbol.for(marker3$1$2);
|
|
2528
2528
|
var forbiddenParamSchema = lazyValidator(() => zodSchema$2(z.object({ ruleId: z.string() })));
|
|
2529
2529
|
var _a3$1$2;
|
|
2530
2530
|
var _b3$3;
|
|
@@ -2536,7 +2536,7 @@ var GatewayForbiddenError = class extends (_b3$3 = GatewayError, _a3$1$2 = symbo
|
|
|
2536
2536
|
cause
|
|
2537
2537
|
});
|
|
2538
2538
|
this[_a3$1$2] = true;
|
|
2539
|
-
this.name = name2$1$
|
|
2539
|
+
this.name = name2$1$2;
|
|
2540
2540
|
this.type = "forbidden";
|
|
2541
2541
|
this.ruleId = ruleId;
|
|
2542
2542
|
}
|
|
@@ -5426,12 +5426,12 @@ function createUIMessageStream$2({ execute, onError = () => "An error occurred."
|
|
|
5426
5426
|
});
|
|
5427
5427
|
}
|
|
5428
5428
|
//#endregion
|
|
5429
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist-
|
|
5430
|
-
var marker$2$
|
|
5431
|
-
var symbol$2$2 = Symbol.for(marker$2$
|
|
5432
|
-
var _a$2$
|
|
5433
|
-
var _b$2
|
|
5434
|
-
var AISDKError$1 = class _AISDKError extends (_b$2
|
|
5429
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BcG-LFmj.js
|
|
5430
|
+
var marker$2$2 = "vercel.ai.error";
|
|
5431
|
+
var symbol$2$2 = Symbol.for(marker$2$2);
|
|
5432
|
+
var _a$2$1;
|
|
5433
|
+
var _b$2;
|
|
5434
|
+
var AISDKError$1$1 = class _AISDKError extends (_b$2 = Error, _a$2$1 = symbol$2$2, _b$2) {
|
|
5435
5435
|
/**
|
|
5436
5436
|
* Creates an AI SDK Error.
|
|
5437
5437
|
*
|
|
@@ -5442,7 +5442,7 @@ var AISDKError$1 = class _AISDKError extends (_b$2$1 = Error, _a$2$2 = symbol$2$
|
|
|
5442
5442
|
*/
|
|
5443
5443
|
constructor({ name: name14, message, cause }) {
|
|
5444
5444
|
super(message);
|
|
5445
|
-
this[_a$2$
|
|
5445
|
+
this[_a$2$1] = true;
|
|
5446
5446
|
this.name = name14;
|
|
5447
5447
|
this.cause = cause;
|
|
5448
5448
|
}
|
|
@@ -5452,26 +5452,26 @@ var AISDKError$1 = class _AISDKError extends (_b$2$1 = Error, _a$2$2 = symbol$2$
|
|
|
5452
5452
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
5453
5453
|
*/
|
|
5454
5454
|
static isInstance(error) {
|
|
5455
|
-
return _AISDKError.hasMarker(error, marker$2$
|
|
5455
|
+
return _AISDKError.hasMarker(error, marker$2$2);
|
|
5456
5456
|
}
|
|
5457
5457
|
static hasMarker(error, marker15) {
|
|
5458
5458
|
const markerSymbol = Symbol.for(marker15);
|
|
5459
5459
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
5460
5460
|
}
|
|
5461
5461
|
};
|
|
5462
|
-
var name$2$
|
|
5463
|
-
var marker2$1$
|
|
5464
|
-
var symbol2$1$
|
|
5465
|
-
var _a2$1$
|
|
5466
|
-
var _b2$1$
|
|
5467
|
-
(class extends (_b2$1$
|
|
5462
|
+
var name$2$4 = "AI_APICallError";
|
|
5463
|
+
var marker2$1$1 = `vercel.ai.error.${name$2$4}`;
|
|
5464
|
+
var symbol2$1$1 = Symbol.for(marker2$1$1);
|
|
5465
|
+
var _a2$1$1;
|
|
5466
|
+
var _b2$1$1;
|
|
5467
|
+
(class extends (_b2$1$1 = AISDKError$1$1, _a2$1$1 = symbol2$1$1, _b2$1$1) {
|
|
5468
5468
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
5469
5469
|
super({
|
|
5470
|
-
name: name$2$
|
|
5470
|
+
name: name$2$4,
|
|
5471
5471
|
message,
|
|
5472
5472
|
cause
|
|
5473
5473
|
});
|
|
5474
|
-
this[_a2$1$
|
|
5474
|
+
this[_a2$1$1] = true;
|
|
5475
5475
|
this.url = url;
|
|
5476
5476
|
this.requestBodyValues = requestBodyValues;
|
|
5477
5477
|
this.statusCode = statusCode;
|
|
@@ -5481,24 +5481,24 @@ var _b2$1$3;
|
|
|
5481
5481
|
this.data = data;
|
|
5482
5482
|
}
|
|
5483
5483
|
static isInstance(error) {
|
|
5484
|
-
return AISDKError$1.hasMarker(error, marker2$1$
|
|
5484
|
+
return AISDKError$1$1.hasMarker(error, marker2$1$1);
|
|
5485
5485
|
}
|
|
5486
5486
|
});
|
|
5487
|
-
var name2$1$
|
|
5488
|
-
var marker3$1$
|
|
5489
|
-
var symbol3$1$1 = Symbol.for(marker3$1$
|
|
5487
|
+
var name2$1$1 = "AI_EmptyResponseBodyError";
|
|
5488
|
+
var marker3$1$1 = `vercel.ai.error.${name2$1$1}`;
|
|
5489
|
+
var symbol3$1$1 = Symbol.for(marker3$1$1);
|
|
5490
5490
|
var _a3$1$1;
|
|
5491
5491
|
var _b3$1$1;
|
|
5492
|
-
(class extends (_b3$1$1 = AISDKError$1, _a3$1$1 = symbol3$1$1, _b3$1$1) {
|
|
5492
|
+
(class extends (_b3$1$1 = AISDKError$1$1, _a3$1$1 = symbol3$1$1, _b3$1$1) {
|
|
5493
5493
|
constructor({ message = "Empty response body" } = {}) {
|
|
5494
5494
|
super({
|
|
5495
|
-
name: name2$1$
|
|
5495
|
+
name: name2$1$1,
|
|
5496
5496
|
message
|
|
5497
5497
|
});
|
|
5498
5498
|
this[_a3$1$1] = true;
|
|
5499
5499
|
}
|
|
5500
5500
|
static isInstance(error) {
|
|
5501
|
-
return AISDKError$1.hasMarker(error, marker3$1$
|
|
5501
|
+
return AISDKError$1$1.hasMarker(error, marker3$1$1);
|
|
5502
5502
|
}
|
|
5503
5503
|
});
|
|
5504
5504
|
function getErrorMessage$2(error) {
|
|
@@ -5512,7 +5512,7 @@ var marker4$1$1 = `vercel.ai.error.${name3$1$1}`;
|
|
|
5512
5512
|
var symbol4$1$1 = Symbol.for(marker4$1$1);
|
|
5513
5513
|
var _a4$1$1;
|
|
5514
5514
|
var _b4$1$1;
|
|
5515
|
-
var InvalidArgumentError$1$
|
|
5515
|
+
var InvalidArgumentError$1$3 = class extends (_b4$1$1 = AISDKError$1$1, _a4$1$1 = symbol4$1$1, _b4$1$1) {
|
|
5516
5516
|
constructor({ message, cause, argument }) {
|
|
5517
5517
|
super({
|
|
5518
5518
|
name: name3$1$1,
|
|
@@ -5523,7 +5523,7 @@ var InvalidArgumentError$1$1 = class extends (_b4$1$1 = AISDKError$1, _a4$1$1 =
|
|
|
5523
5523
|
this.argument = argument;
|
|
5524
5524
|
}
|
|
5525
5525
|
static isInstance(error) {
|
|
5526
|
-
return AISDKError$1.hasMarker(error, marker4$1$1);
|
|
5526
|
+
return AISDKError$1$1.hasMarker(error, marker4$1$1);
|
|
5527
5527
|
}
|
|
5528
5528
|
};
|
|
5529
5529
|
var name4$1$1 = "AI_InvalidPromptError";
|
|
@@ -5531,7 +5531,7 @@ var marker5$1$1 = `vercel.ai.error.${name4$1$1}`;
|
|
|
5531
5531
|
var symbol5$1$1 = Symbol.for(marker5$1$1);
|
|
5532
5532
|
var _a5$1$1;
|
|
5533
5533
|
var _b5$1$1;
|
|
5534
|
-
(class extends (_b5$1$1 = AISDKError$1, _a5$1$1 = symbol5$1$1, _b5$1$1) {
|
|
5534
|
+
(class extends (_b5$1$1 = AISDKError$1$1, _a5$1$1 = symbol5$1$1, _b5$1$1) {
|
|
5535
5535
|
constructor({ prompt, message, cause }) {
|
|
5536
5536
|
super({
|
|
5537
5537
|
name: name4$1$1,
|
|
@@ -5542,7 +5542,7 @@ var _b5$1$1;
|
|
|
5542
5542
|
this.prompt = prompt;
|
|
5543
5543
|
}
|
|
5544
5544
|
static isInstance(error) {
|
|
5545
|
-
return AISDKError$1.hasMarker(error, marker5$1$1);
|
|
5545
|
+
return AISDKError$1$1.hasMarker(error, marker5$1$1);
|
|
5546
5546
|
}
|
|
5547
5547
|
});
|
|
5548
5548
|
var name5$1$1 = "AI_InvalidResponseDataError";
|
|
@@ -5550,7 +5550,7 @@ var marker6$1$1 = `vercel.ai.error.${name5$1$1}`;
|
|
|
5550
5550
|
var symbol6$1$1 = Symbol.for(marker6$1$1);
|
|
5551
5551
|
var _a6$1$1;
|
|
5552
5552
|
var _b6$1$1;
|
|
5553
|
-
(class extends (_b6$1$1 = AISDKError$1, _a6$1$1 = symbol6$1$1, _b6$1$1) {
|
|
5553
|
+
(class extends (_b6$1$1 = AISDKError$1$1, _a6$1$1 = symbol6$1$1, _b6$1$1) {
|
|
5554
5554
|
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
5555
5555
|
super({
|
|
5556
5556
|
name: name5$1$1,
|
|
@@ -5560,7 +5560,7 @@ var _b6$1$1;
|
|
|
5560
5560
|
this.data = data;
|
|
5561
5561
|
}
|
|
5562
5562
|
static isInstance(error) {
|
|
5563
|
-
return AISDKError$1.hasMarker(error, marker6$1$1);
|
|
5563
|
+
return AISDKError$1$1.hasMarker(error, marker6$1$1);
|
|
5564
5564
|
}
|
|
5565
5565
|
});
|
|
5566
5566
|
var name6$1$1 = "AI_JSONParseError";
|
|
@@ -5568,7 +5568,7 @@ var marker7$1$1 = `vercel.ai.error.${name6$1$1}`;
|
|
|
5568
5568
|
var symbol7$1$1 = Symbol.for(marker7$1$1);
|
|
5569
5569
|
var _a7$1$1;
|
|
5570
5570
|
var _b7$1$1;
|
|
5571
|
-
var JSONParseError$1 = class extends (_b7$1$1 = AISDKError$1, _a7$1$1 = symbol7$1$1, _b7$1$1) {
|
|
5571
|
+
var JSONParseError$1$1 = class extends (_b7$1$1 = AISDKError$1$1, _a7$1$1 = symbol7$1$1, _b7$1$1) {
|
|
5572
5572
|
constructor({ text, cause }) {
|
|
5573
5573
|
super({
|
|
5574
5574
|
name: name6$1$1,
|
|
@@ -5580,7 +5580,7 @@ Error message: ${getErrorMessage$2(cause)}`,
|
|
|
5580
5580
|
this.text = text;
|
|
5581
5581
|
}
|
|
5582
5582
|
static isInstance(error) {
|
|
5583
|
-
return AISDKError$1.hasMarker(error, marker7$1$1);
|
|
5583
|
+
return AISDKError$1$1.hasMarker(error, marker7$1$1);
|
|
5584
5584
|
}
|
|
5585
5585
|
};
|
|
5586
5586
|
var name7$1$1 = "AI_LoadAPIKeyError";
|
|
@@ -5588,7 +5588,7 @@ var marker8$1$1 = `vercel.ai.error.${name7$1$1}`;
|
|
|
5588
5588
|
var symbol8$1$1 = Symbol.for(marker8$1$1);
|
|
5589
5589
|
var _a8$1$1;
|
|
5590
5590
|
var _b8$1$1;
|
|
5591
|
-
(class extends (_b8$1$1 = AISDKError$1, _a8$1$1 = symbol8$1$1, _b8$1$1) {
|
|
5591
|
+
(class extends (_b8$1$1 = AISDKError$1$1, _a8$1$1 = symbol8$1$1, _b8$1$1) {
|
|
5592
5592
|
constructor({ message }) {
|
|
5593
5593
|
super({
|
|
5594
5594
|
name: name7$1$1,
|
|
@@ -5597,7 +5597,7 @@ var _b8$1$1;
|
|
|
5597
5597
|
this[_a8$1$1] = true;
|
|
5598
5598
|
}
|
|
5599
5599
|
static isInstance(error) {
|
|
5600
|
-
return AISDKError$1.hasMarker(error, marker8$1$1);
|
|
5600
|
+
return AISDKError$1$1.hasMarker(error, marker8$1$1);
|
|
5601
5601
|
}
|
|
5602
5602
|
});
|
|
5603
5603
|
var name8$1$1 = "AI_LoadSettingError";
|
|
@@ -5605,7 +5605,7 @@ var marker9$1$1 = `vercel.ai.error.${name8$1$1}`;
|
|
|
5605
5605
|
var symbol9$1$1 = Symbol.for(marker9$1$1);
|
|
5606
5606
|
var _a9$1$1;
|
|
5607
5607
|
var _b9$1$1;
|
|
5608
|
-
(class extends (_b9$1$1 = AISDKError$1, _a9$1$1 = symbol9$1$1, _b9$1$1) {
|
|
5608
|
+
(class extends (_b9$1$1 = AISDKError$1$1, _a9$1$1 = symbol9$1$1, _b9$1$1) {
|
|
5609
5609
|
constructor({ message }) {
|
|
5610
5610
|
super({
|
|
5611
5611
|
name: name8$1$1,
|
|
@@ -5614,7 +5614,7 @@ var _b9$1$1;
|
|
|
5614
5614
|
this[_a9$1$1] = true;
|
|
5615
5615
|
}
|
|
5616
5616
|
static isInstance(error) {
|
|
5617
|
-
return AISDKError$1.hasMarker(error, marker9$1$1);
|
|
5617
|
+
return AISDKError$1$1.hasMarker(error, marker9$1$1);
|
|
5618
5618
|
}
|
|
5619
5619
|
});
|
|
5620
5620
|
var name9$1$1 = "AI_NoContentGeneratedError";
|
|
@@ -5622,7 +5622,7 @@ var marker10$1$1 = `vercel.ai.error.${name9$1$1}`;
|
|
|
5622
5622
|
var symbol10$1$1 = Symbol.for(marker10$1$1);
|
|
5623
5623
|
var _a10$1$1;
|
|
5624
5624
|
var _b10$1$1;
|
|
5625
|
-
(class extends (_b10$1$1 = AISDKError$1, _a10$1$1 = symbol10$1$1, _b10$1$1) {
|
|
5625
|
+
(class extends (_b10$1$1 = AISDKError$1$1, _a10$1$1 = symbol10$1$1, _b10$1$1) {
|
|
5626
5626
|
constructor({ message = "No content generated." } = {}) {
|
|
5627
5627
|
super({
|
|
5628
5628
|
name: name9$1$1,
|
|
@@ -5631,7 +5631,7 @@ var _b10$1$1;
|
|
|
5631
5631
|
this[_a10$1$1] = true;
|
|
5632
5632
|
}
|
|
5633
5633
|
static isInstance(error) {
|
|
5634
|
-
return AISDKError$1.hasMarker(error, marker10$1$1);
|
|
5634
|
+
return AISDKError$1$1.hasMarker(error, marker10$1$1);
|
|
5635
5635
|
}
|
|
5636
5636
|
});
|
|
5637
5637
|
var name10$1$1 = "AI_NoSuchModelError";
|
|
@@ -5639,7 +5639,7 @@ var marker11$1$1 = `vercel.ai.error.${name10$1$1}`;
|
|
|
5639
5639
|
var symbol11$1$1 = Symbol.for(marker11$1$1);
|
|
5640
5640
|
var _a11$1$1;
|
|
5641
5641
|
var _b11$1$1;
|
|
5642
|
-
(class extends (_b11$1$1 = AISDKError$1, _a11$1$1 = symbol11$1$1, _b11$1$1) {
|
|
5642
|
+
(class extends (_b11$1$1 = AISDKError$1$1, _a11$1$1 = symbol11$1$1, _b11$1$1) {
|
|
5643
5643
|
constructor({ errorName = name10$1$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
5644
5644
|
super({
|
|
5645
5645
|
name: errorName,
|
|
@@ -5650,7 +5650,7 @@ var _b11$1$1;
|
|
|
5650
5650
|
this.modelType = modelType;
|
|
5651
5651
|
}
|
|
5652
5652
|
static isInstance(error) {
|
|
5653
|
-
return AISDKError$1.hasMarker(error, marker11$1$1);
|
|
5653
|
+
return AISDKError$1$1.hasMarker(error, marker11$1$1);
|
|
5654
5654
|
}
|
|
5655
5655
|
});
|
|
5656
5656
|
var name11$1$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
@@ -5658,7 +5658,7 @@ var marker12$1$1 = `vercel.ai.error.${name11$1$1}`;
|
|
|
5658
5658
|
var symbol12$1$1 = Symbol.for(marker12$1$1);
|
|
5659
5659
|
var _a12$1$1;
|
|
5660
5660
|
var _b12$1$1;
|
|
5661
|
-
(class extends (_b12$1$1 = AISDKError$1, _a12$1$1 = symbol12$1$1, _b12$1$1) {
|
|
5661
|
+
(class extends (_b12$1$1 = AISDKError$1$1, _a12$1$1 = symbol12$1$1, _b12$1$1) {
|
|
5662
5662
|
constructor(options) {
|
|
5663
5663
|
super({
|
|
5664
5664
|
name: name11$1$1,
|
|
@@ -5671,7 +5671,7 @@ var _b12$1$1;
|
|
|
5671
5671
|
this.values = options.values;
|
|
5672
5672
|
}
|
|
5673
5673
|
static isInstance(error) {
|
|
5674
|
-
return AISDKError$1.hasMarker(error, marker12$1$1);
|
|
5674
|
+
return AISDKError$1$1.hasMarker(error, marker12$1$1);
|
|
5675
5675
|
}
|
|
5676
5676
|
});
|
|
5677
5677
|
var name12$1$1 = "AI_TypeValidationError";
|
|
@@ -5679,7 +5679,7 @@ var marker13$1$1 = `vercel.ai.error.${name12$1$1}`;
|
|
|
5679
5679
|
var symbol13$1$1 = Symbol.for(marker13$1$1);
|
|
5680
5680
|
var _a13$1$1;
|
|
5681
5681
|
var _b13$1$1;
|
|
5682
|
-
var TypeValidationError$1 = class _TypeValidationError extends (_b13$1$1 = AISDKError$1, _a13$1$1 = symbol13$1$1, _b13$1$1) {
|
|
5682
|
+
var TypeValidationError$1$1 = class _TypeValidationError extends (_b13$1$1 = AISDKError$1$1, _a13$1$1 = symbol13$1$1, _b13$1$1) {
|
|
5683
5683
|
constructor({ value, cause, context }) {
|
|
5684
5684
|
let contextPrefix = "Type validation failed";
|
|
5685
5685
|
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
@@ -5702,7 +5702,7 @@ Error message: ${getErrorMessage$2(cause)}`,
|
|
|
5702
5702
|
this.context = context;
|
|
5703
5703
|
}
|
|
5704
5704
|
static isInstance(error) {
|
|
5705
|
-
return AISDKError$1.hasMarker(error, marker13$1$1);
|
|
5705
|
+
return AISDKError$1$1.hasMarker(error, marker13$1$1);
|
|
5706
5706
|
}
|
|
5707
5707
|
/**
|
|
5708
5708
|
* Wraps an error into a TypeValidationError.
|
|
@@ -5730,7 +5730,7 @@ var marker14$1$1 = `vercel.ai.error.${name13$1$1}`;
|
|
|
5730
5730
|
var symbol14$1$1 = Symbol.for(marker14$1$1);
|
|
5731
5731
|
var _a14$1$1;
|
|
5732
5732
|
var _b14$1$1;
|
|
5733
|
-
(class extends (_b14$1$1 = AISDKError$1, _a14$1$1 = symbol14$1$1, _b14$1$1) {
|
|
5733
|
+
(class extends (_b14$1$1 = AISDKError$1$1, _a14$1$1 = symbol14$1$1, _b14$1$1) {
|
|
5734
5734
|
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
5735
5735
|
super({
|
|
5736
5736
|
name: name13$1$1,
|
|
@@ -5740,30 +5740,30 @@ var _b14$1$1;
|
|
|
5740
5740
|
this.functionality = functionality;
|
|
5741
5741
|
}
|
|
5742
5742
|
static isInstance(error) {
|
|
5743
|
-
return AISDKError$1.hasMarker(error, marker14$1$1);
|
|
5743
|
+
return AISDKError$1$1.hasMarker(error, marker14$1$1);
|
|
5744
5744
|
}
|
|
5745
5745
|
});
|
|
5746
5746
|
TransformStream;
|
|
5747
5747
|
var { btoa: btoa$2, atob: atob$2 } = globalThis;
|
|
5748
|
-
var name$1$
|
|
5749
|
-
var marker$1$
|
|
5750
|
-
var symbol$1$4 = Symbol.for(marker$1$
|
|
5751
|
-
var _a$1$
|
|
5752
|
-
var _b$1$
|
|
5753
|
-
(class extends (_b$1$
|
|
5748
|
+
var name$1$5 = "AI_DownloadError";
|
|
5749
|
+
var marker$1$5 = `vercel.ai.error.${name$1$5}`;
|
|
5750
|
+
var symbol$1$4 = Symbol.for(marker$1$5);
|
|
5751
|
+
var _a$1$1;
|
|
5752
|
+
var _b$1$1;
|
|
5753
|
+
(class extends (_b$1$1 = AISDKError$1$1, _a$1$1 = symbol$1$4, _b$1$1) {
|
|
5754
5754
|
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
5755
5755
|
super({
|
|
5756
|
-
name: name$1$
|
|
5756
|
+
name: name$1$5,
|
|
5757
5757
|
message,
|
|
5758
5758
|
cause
|
|
5759
5759
|
});
|
|
5760
|
-
this[_a$1$
|
|
5760
|
+
this[_a$1$1] = true;
|
|
5761
5761
|
this.url = url;
|
|
5762
5762
|
this.statusCode = statusCode;
|
|
5763
5763
|
this.statusText = statusText;
|
|
5764
5764
|
}
|
|
5765
5765
|
static isInstance(error) {
|
|
5766
|
-
return AISDKError$1.hasMarker(error, marker$1$
|
|
5766
|
+
return AISDKError$1$1.hasMarker(error, marker$1$5);
|
|
5767
5767
|
}
|
|
5768
5768
|
});
|
|
5769
5769
|
var initialGlobalFetch = globalThis.fetch;
|
|
@@ -5795,7 +5795,7 @@ var createIdGenerator$1 = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJ
|
|
|
5795
5795
|
return chars.join("");
|
|
5796
5796
|
};
|
|
5797
5797
|
if (prefix == null) return generator;
|
|
5798
|
-
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$
|
|
5798
|
+
if (alphabet.includes(separator)) throw new InvalidArgumentError$1$3({
|
|
5799
5799
|
argument: "separator",
|
|
5800
5800
|
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
5801
5801
|
});
|
|
@@ -6034,7 +6034,7 @@ var zodPatterns$1 = {
|
|
|
6034
6034
|
/**
|
|
6035
6035
|
* `a-z` was added to replicate /i flag
|
|
6036
6036
|
*/
|
|
6037
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
6037
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
6038
6038
|
/**
|
|
6039
6039
|
* Constructed a valid Unicode RegExp
|
|
6040
6040
|
*
|
|
@@ -6776,7 +6776,7 @@ function standardSchema$1(standardSchema2) {
|
|
|
6776
6776
|
value: result.value
|
|
6777
6777
|
} : {
|
|
6778
6778
|
success: false,
|
|
6779
|
-
error: new TypeValidationError$1({
|
|
6779
|
+
error: new TypeValidationError$1$1({
|
|
6780
6780
|
value,
|
|
6781
6781
|
cause: result.issues
|
|
6782
6782
|
})
|
|
@@ -6831,7 +6831,7 @@ async function validateTypes$1({ value, schema, context }) {
|
|
|
6831
6831
|
schema,
|
|
6832
6832
|
context
|
|
6833
6833
|
});
|
|
6834
|
-
if (!result.success) throw TypeValidationError$1.wrap({
|
|
6834
|
+
if (!result.success) throw TypeValidationError$1$1.wrap({
|
|
6835
6835
|
value,
|
|
6836
6836
|
cause: result.error,
|
|
6837
6837
|
context
|
|
@@ -6854,7 +6854,7 @@ async function safeValidateTypes$1({ value, schema, context }) {
|
|
|
6854
6854
|
};
|
|
6855
6855
|
return {
|
|
6856
6856
|
success: false,
|
|
6857
|
-
error: TypeValidationError$1.wrap({
|
|
6857
|
+
error: TypeValidationError$1$1.wrap({
|
|
6858
6858
|
value,
|
|
6859
6859
|
cause: result.error,
|
|
6860
6860
|
context
|
|
@@ -6864,7 +6864,7 @@ async function safeValidateTypes$1({ value, schema, context }) {
|
|
|
6864
6864
|
} catch (error) {
|
|
6865
6865
|
return {
|
|
6866
6866
|
success: false,
|
|
6867
|
-
error: TypeValidationError$1.wrap({
|
|
6867
|
+
error: TypeValidationError$1$1.wrap({
|
|
6868
6868
|
value,
|
|
6869
6869
|
cause: error,
|
|
6870
6870
|
context
|
|
@@ -6888,7 +6888,7 @@ async function safeParseJSON$1({ text, schema }) {
|
|
|
6888
6888
|
} catch (error) {
|
|
6889
6889
|
return {
|
|
6890
6890
|
success: false,
|
|
6891
|
-
error: JSONParseError$1.isInstance(error) ? error : new JSONParseError$1({
|
|
6891
|
+
error: JSONParseError$1$1.isInstance(error) ? error : new JSONParseError$1$1({
|
|
6892
6892
|
text,
|
|
6893
6893
|
cause: error
|
|
6894
6894
|
}),
|
|
@@ -6898,14 +6898,14 @@ async function safeParseJSON$1({ text, schema }) {
|
|
|
6898
6898
|
}
|
|
6899
6899
|
async function resolve$1(value) {
|
|
6900
6900
|
if (typeof value === "function") value = value();
|
|
6901
|
-
return
|
|
6901
|
+
return value;
|
|
6902
6902
|
}
|
|
6903
6903
|
new TextDecoder();
|
|
6904
|
-
var marker$
|
|
6905
|
-
var symbol$5 = Symbol.for(marker$
|
|
6906
|
-
var _a$
|
|
6904
|
+
var marker$6 = "vercel.ai.error";
|
|
6905
|
+
var symbol$5 = Symbol.for(marker$6);
|
|
6906
|
+
var _a$3;
|
|
6907
6907
|
var _b$3;
|
|
6908
|
-
var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$
|
|
6908
|
+
var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$3 = symbol$5, _b$3) {
|
|
6909
6909
|
/**
|
|
6910
6910
|
* Creates an AI SDK Error.
|
|
6911
6911
|
*
|
|
@@ -6916,7 +6916,7 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6916
6916
|
*/
|
|
6917
6917
|
constructor({ name: name14, message, cause }) {
|
|
6918
6918
|
super(message);
|
|
6919
|
-
this[_a$
|
|
6919
|
+
this[_a$3] = true;
|
|
6920
6920
|
this.name = name14;
|
|
6921
6921
|
this.cause = cause;
|
|
6922
6922
|
}
|
|
@@ -6926,7 +6926,7 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6926
6926
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
6927
6927
|
*/
|
|
6928
6928
|
static isInstance(error) {
|
|
6929
|
-
return _AISDKError.hasMarker(error, marker$
|
|
6929
|
+
return _AISDKError.hasMarker(error, marker$6);
|
|
6930
6930
|
}
|
|
6931
6931
|
static hasMarker(error, marker15) {
|
|
6932
6932
|
const markerSymbol = Symbol.for(marker15);
|
|
@@ -6934,18 +6934,18 @@ var AISDKError$2 = class _AISDKError extends (_b$3 = Error, _a$5 = symbol$5, _b$
|
|
|
6934
6934
|
}
|
|
6935
6935
|
};
|
|
6936
6936
|
var name$5 = "AI_APICallError";
|
|
6937
|
-
var marker2$
|
|
6938
|
-
var symbol2$
|
|
6939
|
-
var _a2$
|
|
6940
|
-
var _b2$
|
|
6941
|
-
(class extends (_b2$
|
|
6937
|
+
var marker2$3 = `vercel.ai.error.${name$5}`;
|
|
6938
|
+
var symbol2$3 = Symbol.for(marker2$3);
|
|
6939
|
+
var _a2$3;
|
|
6940
|
+
var _b2$2;
|
|
6941
|
+
(class extends (_b2$2 = AISDKError$2, _a2$3 = symbol2$3, _b2$2) {
|
|
6942
6942
|
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
6943
6943
|
super({
|
|
6944
6944
|
name: name$5,
|
|
6945
6945
|
message,
|
|
6946
6946
|
cause
|
|
6947
6947
|
});
|
|
6948
|
-
this[_a2$
|
|
6948
|
+
this[_a2$3] = true;
|
|
6949
6949
|
this.url = url;
|
|
6950
6950
|
this.requestBodyValues = requestBodyValues;
|
|
6951
6951
|
this.statusCode = statusCode;
|
|
@@ -6955,27 +6955,27 @@ var _b2$4;
|
|
|
6955
6955
|
this.data = data;
|
|
6956
6956
|
}
|
|
6957
6957
|
static isInstance(error) {
|
|
6958
|
-
return AISDKError$2.hasMarker(error, marker2$
|
|
6958
|
+
return AISDKError$2.hasMarker(error, marker2$3);
|
|
6959
6959
|
}
|
|
6960
6960
|
});
|
|
6961
|
-
var name2$
|
|
6962
|
-
var marker3$
|
|
6963
|
-
var symbol3$3 = Symbol.for(marker3$
|
|
6961
|
+
var name2$3 = "AI_EmptyResponseBodyError";
|
|
6962
|
+
var marker3$3 = `vercel.ai.error.${name2$3}`;
|
|
6963
|
+
var symbol3$3 = Symbol.for(marker3$3);
|
|
6964
6964
|
var _a3$3;
|
|
6965
6965
|
var _b3$2;
|
|
6966
6966
|
(class extends (_b3$2 = AISDKError$2, _a3$3 = symbol3$3, _b3$2) {
|
|
6967
6967
|
constructor({ message = "Empty response body" } = {}) {
|
|
6968
6968
|
super({
|
|
6969
|
-
name: name2$
|
|
6969
|
+
name: name2$3,
|
|
6970
6970
|
message
|
|
6971
6971
|
});
|
|
6972
6972
|
this[_a3$3] = true;
|
|
6973
6973
|
}
|
|
6974
6974
|
static isInstance(error) {
|
|
6975
|
-
return AISDKError$2.hasMarker(error, marker3$
|
|
6975
|
+
return AISDKError$2.hasMarker(error, marker3$3);
|
|
6976
6976
|
}
|
|
6977
6977
|
});
|
|
6978
|
-
function getErrorMessage$
|
|
6978
|
+
function getErrorMessage$3(error) {
|
|
6979
6979
|
if (error == null) return "unknown error";
|
|
6980
6980
|
if (typeof error === "string") return error;
|
|
6981
6981
|
if (error instanceof Error) return error.message;
|
|
@@ -7047,7 +7047,7 @@ var _b7$2;
|
|
|
7047
7047
|
super({
|
|
7048
7048
|
name: name6$3,
|
|
7049
7049
|
message: `JSON parsing failed: Text: ${text}.
|
|
7050
|
-
Error message: ${getErrorMessage$
|
|
7050
|
+
Error message: ${getErrorMessage$3(cause)}`,
|
|
7051
7051
|
cause
|
|
7052
7052
|
});
|
|
7053
7053
|
this[_a7$3] = true;
|
|
@@ -7168,7 +7168,7 @@ var TypeValidationError$2 = class _TypeValidationError extends (_b13$2 = AISDKEr
|
|
|
7168
7168
|
super({
|
|
7169
7169
|
name: name12$3,
|
|
7170
7170
|
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
7171
|
-
Error message: ${getErrorMessage$
|
|
7171
|
+
Error message: ${getErrorMessage$3(cause)}`,
|
|
7172
7172
|
cause
|
|
7173
7173
|
});
|
|
7174
7174
|
this[_a13$3] = true;
|
|
@@ -9522,12 +9522,18 @@ var doWrap = ({ model, middleware: { transformParams, wrapGenerate, wrapStream,
|
|
|
9522
9522
|
};
|
|
9523
9523
|
};
|
|
9524
9524
|
//#endregion
|
|
9525
|
-
//#region ../../packages/_vendored/ai_v7/dist/dist-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9525
|
+
//#region ../../packages/_vendored/ai_v7/dist/dist-Bwf3DREZ.js
|
|
9526
|
+
/**
|
|
9527
|
+
* Symbol used for identifying AI SDK Error instances.
|
|
9528
|
+
* Enables checking if an error is an instance of AISDKError across package versions.
|
|
9529
|
+
*/
|
|
9530
|
+
const marker$15 = "vercel.ai.error";
|
|
9531
|
+
const symbol$15 = Symbol.for(marker$15);
|
|
9532
|
+
/**
|
|
9533
|
+
* Custom error class for AI SDK related errors.
|
|
9534
|
+
* @extends Error
|
|
9535
|
+
*/
|
|
9536
|
+
var AISDKError$1 = class AISDKError extends Error {
|
|
9531
9537
|
/**
|
|
9532
9538
|
* Creates an AI SDK Error.
|
|
9533
9539
|
*
|
|
@@ -9536,10 +9542,10 @@ var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1)
|
|
|
9536
9542
|
* @param {string} params.message - The error message.
|
|
9537
9543
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
9538
9544
|
*/
|
|
9539
|
-
constructor({ name
|
|
9545
|
+
constructor({ name, message, cause }) {
|
|
9540
9546
|
super(message);
|
|
9541
|
-
this[
|
|
9542
|
-
this.name =
|
|
9547
|
+
this[symbol$15] = true;
|
|
9548
|
+
this.name = name;
|
|
9543
9549
|
this.cause = cause;
|
|
9544
9550
|
}
|
|
9545
9551
|
/**
|
|
@@ -9548,359 +9554,123 @@ var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$1, _b$1)
|
|
|
9548
9554
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
9549
9555
|
*/
|
|
9550
9556
|
static isInstance(error) {
|
|
9551
|
-
return
|
|
9557
|
+
return AISDKError.hasMarker(error, marker$15);
|
|
9552
9558
|
}
|
|
9553
|
-
static hasMarker(error,
|
|
9554
|
-
const markerSymbol = Symbol.for(
|
|
9559
|
+
static hasMarker(error, marker) {
|
|
9560
|
+
const markerSymbol = Symbol.for(marker);
|
|
9555
9561
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
9556
9562
|
}
|
|
9557
9563
|
};
|
|
9558
|
-
|
|
9559
|
-
var marker2$1 = `vercel.ai.error.${name$1}`;
|
|
9560
|
-
var symbol2$1 = Symbol.for(marker2$1);
|
|
9561
|
-
var _a2$1;
|
|
9562
|
-
var _b2$1;
|
|
9563
|
-
(class extends (_b2$1 = AISDKError, _a2$1 = symbol2$1, _b2$1) {
|
|
9564
|
-
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
9565
|
-
super({
|
|
9566
|
-
name: name$1,
|
|
9567
|
-
message,
|
|
9568
|
-
cause
|
|
9569
|
-
});
|
|
9570
|
-
this[_a2$1] = true;
|
|
9571
|
-
this.url = url;
|
|
9572
|
-
this.requestBodyValues = requestBodyValues;
|
|
9573
|
-
this.statusCode = statusCode;
|
|
9574
|
-
this.responseHeaders = responseHeaders;
|
|
9575
|
-
this.responseBody = responseBody;
|
|
9576
|
-
this.isRetryable = isRetryable;
|
|
9577
|
-
this.data = data;
|
|
9578
|
-
}
|
|
9579
|
-
static isInstance(error) {
|
|
9580
|
-
return AISDKError.hasMarker(error, marker2$1);
|
|
9581
|
-
}
|
|
9582
|
-
});
|
|
9583
|
-
var name2$1 = "AI_EmptyResponseBodyError";
|
|
9584
|
-
var marker3$1 = `vercel.ai.error.${name2$1}`;
|
|
9585
|
-
var symbol3$1 = Symbol.for(marker3$1);
|
|
9586
|
-
var _a3$1;
|
|
9587
|
-
var _b3$1;
|
|
9588
|
-
(class extends (_b3$1 = AISDKError, _a3$1 = symbol3$1, _b3$1) {
|
|
9589
|
-
constructor({ message = "Empty response body" } = {}) {
|
|
9590
|
-
super({
|
|
9591
|
-
name: name2$1,
|
|
9592
|
-
message
|
|
9593
|
-
});
|
|
9594
|
-
this[_a3$1] = true;
|
|
9595
|
-
}
|
|
9596
|
-
static isInstance(error) {
|
|
9597
|
-
return AISDKError.hasMarker(error, marker3$1);
|
|
9598
|
-
}
|
|
9599
|
-
});
|
|
9600
|
-
var name3$1 = "AI_EvaluationUnsupportedQuestionTypeError";
|
|
9601
|
-
var marker4$1 = `vercel.ai.error.${name3$1}`;
|
|
9602
|
-
var symbol4$1 = Symbol.for(marker4$1);
|
|
9603
|
-
var _a4$1;
|
|
9604
|
-
var _b4$1;
|
|
9605
|
-
(class extends (_b4$1 = AISDKError, _a4$1 = symbol4$1, _b4$1) {
|
|
9606
|
-
constructor({ questionId, questionType, provider, modelId, message = `Question "${questionId}" has type "${questionType}", which is not supported by provider "${provider}" and model "${modelId}".` }) {
|
|
9607
|
-
super({
|
|
9608
|
-
name: name3$1,
|
|
9609
|
-
message
|
|
9610
|
-
});
|
|
9611
|
-
this[_a4$1] = true;
|
|
9612
|
-
this.questionId = questionId;
|
|
9613
|
-
this.questionType = questionType;
|
|
9614
|
-
this.provider = provider;
|
|
9615
|
-
this.modelId = modelId;
|
|
9616
|
-
}
|
|
9617
|
-
static isInstance(error) {
|
|
9618
|
-
return AISDKError.hasMarker(error, marker4$1);
|
|
9619
|
-
}
|
|
9620
|
-
});
|
|
9621
|
-
function getErrorMessage(error) {
|
|
9564
|
+
function getErrorMessage$1(error) {
|
|
9622
9565
|
if (error == null) return "unknown error";
|
|
9623
9566
|
if (typeof error === "string") return error;
|
|
9624
9567
|
if (error instanceof Error) return error.toString();
|
|
9625
9568
|
return JSON.stringify(error);
|
|
9626
9569
|
}
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9632
|
-
|
|
9570
|
+
const name$11 = "AI_InvalidArgumentError";
|
|
9571
|
+
const marker$11 = `vercel.ai.error.${name$11}`;
|
|
9572
|
+
const symbol$11 = Symbol.for(marker$11);
|
|
9573
|
+
/**
|
|
9574
|
+
* A function argument is invalid.
|
|
9575
|
+
*/
|
|
9576
|
+
var InvalidArgumentError$1 = class extends AISDKError$1 {
|
|
9633
9577
|
constructor({ message, cause, argument }) {
|
|
9634
9578
|
super({
|
|
9635
|
-
name:
|
|
9579
|
+
name: name$11,
|
|
9636
9580
|
message,
|
|
9637
9581
|
cause
|
|
9638
9582
|
});
|
|
9639
|
-
this[
|
|
9583
|
+
this[symbol$11] = true;
|
|
9640
9584
|
this.argument = argument;
|
|
9641
9585
|
}
|
|
9642
9586
|
static isInstance(error) {
|
|
9643
|
-
return AISDKError.hasMarker(error,
|
|
9587
|
+
return AISDKError$1.hasMarker(error, marker$11);
|
|
9644
9588
|
}
|
|
9645
9589
|
};
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
var
|
|
9650
|
-
var _b6$1;
|
|
9651
|
-
(class extends (_b6$1 = AISDKError, _a6$1 = symbol6$1, _b6$1) {
|
|
9652
|
-
constructor({ prompt, message, cause }) {
|
|
9653
|
-
super({
|
|
9654
|
-
name: name5$1,
|
|
9655
|
-
message: `Invalid prompt: ${message}`,
|
|
9656
|
-
cause
|
|
9657
|
-
});
|
|
9658
|
-
this[_a6$1] = true;
|
|
9659
|
-
this.prompt = prompt;
|
|
9660
|
-
}
|
|
9661
|
-
static isInstance(error) {
|
|
9662
|
-
return AISDKError.hasMarker(error, marker6$1);
|
|
9663
|
-
}
|
|
9664
|
-
});
|
|
9665
|
-
var name6$1 = "AI_InvalidResponseDataError";
|
|
9666
|
-
var marker7$1 = `vercel.ai.error.${name6$1}`;
|
|
9667
|
-
var symbol7$1 = Symbol.for(marker7$1);
|
|
9668
|
-
var _a7$1;
|
|
9669
|
-
var _b7$1;
|
|
9670
|
-
(class extends (_b7$1 = AISDKError, _a7$1 = symbol7$1, _b7$1) {
|
|
9671
|
-
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
9672
|
-
super({
|
|
9673
|
-
name: name6$1,
|
|
9674
|
-
message
|
|
9675
|
-
});
|
|
9676
|
-
this[_a7$1] = true;
|
|
9677
|
-
this.data = data;
|
|
9678
|
-
}
|
|
9679
|
-
static isInstance(error) {
|
|
9680
|
-
return AISDKError.hasMarker(error, marker7$1);
|
|
9681
|
-
}
|
|
9682
|
-
});
|
|
9683
|
-
var name7$1 = "AI_JSONParseError";
|
|
9684
|
-
var marker8$1 = `vercel.ai.error.${name7$1}`;
|
|
9685
|
-
var symbol8$1 = Symbol.for(marker8$1);
|
|
9686
|
-
var _a8$1;
|
|
9687
|
-
var _b8$1;
|
|
9688
|
-
var JSONParseError = class extends (_b8$1 = AISDKError, _a8$1 = symbol8$1, _b8$1) {
|
|
9590
|
+
const name$8 = "AI_JSONParseError";
|
|
9591
|
+
const marker$8 = `vercel.ai.error.${name$8}`;
|
|
9592
|
+
const symbol$8 = Symbol.for(marker$8);
|
|
9593
|
+
var JSONParseError$1 = class extends AISDKError$1 {
|
|
9689
9594
|
constructor({ text, cause }) {
|
|
9690
9595
|
super({
|
|
9691
|
-
name:
|
|
9692
|
-
message: `JSON parsing failed: Text: ${text}
|
|
9693
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
9596
|
+
name: name$8,
|
|
9597
|
+
message: `JSON parsing failed: Text: ${text}.\nError message: ${getErrorMessage$1(cause)}`,
|
|
9694
9598
|
cause
|
|
9695
9599
|
});
|
|
9696
|
-
this[
|
|
9600
|
+
this[symbol$8] = true;
|
|
9697
9601
|
this.text = text;
|
|
9698
9602
|
}
|
|
9699
9603
|
static isInstance(error) {
|
|
9700
|
-
return AISDKError.hasMarker(error,
|
|
9604
|
+
return AISDKError$1.hasMarker(error, marker$8);
|
|
9701
9605
|
}
|
|
9702
9606
|
};
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
var
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9607
|
+
const name$1$3 = "AI_TypeValidationError";
|
|
9608
|
+
const marker$1$4 = `vercel.ai.error.${name$1$3}`;
|
|
9609
|
+
const symbol$1$3 = Symbol.for(marker$1$4);
|
|
9610
|
+
var TypeValidationError$1 = class TypeValidationError extends AISDKError$1 {
|
|
9611
|
+
constructor({ value, cause, context }) {
|
|
9612
|
+
let contextPrefix = "Type validation failed";
|
|
9613
|
+
if (context?.field) contextPrefix += ` for ${context.field}`;
|
|
9614
|
+
if (context?.entityName || context?.entityId) {
|
|
9615
|
+
contextPrefix += " (";
|
|
9616
|
+
const parts = [];
|
|
9617
|
+
if (context.entityName) parts.push(context.entityName);
|
|
9618
|
+
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
9619
|
+
contextPrefix += parts.join(", ");
|
|
9620
|
+
contextPrefix += ")";
|
|
9621
|
+
}
|
|
9710
9622
|
super({
|
|
9711
|
-
name:
|
|
9712
|
-
message
|
|
9623
|
+
name: name$1$3,
|
|
9624
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.\nError message: ${getErrorMessage$1(cause)}`,
|
|
9625
|
+
cause
|
|
9713
9626
|
});
|
|
9714
|
-
this[
|
|
9627
|
+
this[symbol$1$3] = true;
|
|
9628
|
+
this.value = value;
|
|
9629
|
+
this.context = context;
|
|
9715
9630
|
}
|
|
9716
9631
|
static isInstance(error) {
|
|
9717
|
-
return AISDKError.hasMarker(error,
|
|
9632
|
+
return AISDKError$1.hasMarker(error, marker$1$4);
|
|
9718
9633
|
}
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9634
|
+
/**
|
|
9635
|
+
* Wraps an error into a TypeValidationError.
|
|
9636
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
9637
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
9638
|
+
*
|
|
9639
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
9640
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
9641
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9642
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
9643
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9644
|
+
*/
|
|
9645
|
+
static wrap({ value, cause, context }) {
|
|
9646
|
+
if (TypeValidationError.isInstance(cause) && cause.value === value && cause.context?.field === context?.field && cause.context?.entityName === context?.entityName && cause.context?.entityId === context?.entityId) return cause;
|
|
9647
|
+
return new TypeValidationError({
|
|
9648
|
+
value,
|
|
9649
|
+
cause,
|
|
9650
|
+
context
|
|
9730
9651
|
});
|
|
9731
|
-
this[_a10$1] = true;
|
|
9732
|
-
}
|
|
9733
|
-
static isInstance(error) {
|
|
9734
|
-
return AISDKError.hasMarker(error, marker10$1);
|
|
9735
9652
|
}
|
|
9736
|
-
}
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9653
|
+
};
|
|
9654
|
+
TransformStream;
|
|
9655
|
+
new TextDecoder();
|
|
9656
|
+
const { btoa: btoa$1, atob: atob$1 } = globalThis;
|
|
9657
|
+
const name$1 = "AI_DownloadError";
|
|
9658
|
+
const marker$1 = `vercel.ai.error.${name$1}`;
|
|
9659
|
+
const symbol$1 = Symbol.for(marker$1);
|
|
9660
|
+
(class extends AISDKError$1 {
|
|
9661
|
+
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
9744
9662
|
super({
|
|
9745
|
-
name:
|
|
9746
|
-
message
|
|
9663
|
+
name: name$1,
|
|
9664
|
+
message,
|
|
9665
|
+
cause
|
|
9747
9666
|
});
|
|
9748
|
-
this[
|
|
9667
|
+
this[symbol$1] = true;
|
|
9668
|
+
this.url = url;
|
|
9669
|
+
this.statusCode = statusCode;
|
|
9670
|
+
this.statusText = statusText;
|
|
9749
9671
|
}
|
|
9750
9672
|
static isInstance(error) {
|
|
9751
|
-
return AISDKError.hasMarker(error,
|
|
9752
|
-
}
|
|
9753
|
-
});
|
|
9754
|
-
var name11$1 = "AI_NoSuchModelError";
|
|
9755
|
-
var marker12$1 = `vercel.ai.error.${name11$1}`;
|
|
9756
|
-
var symbol12$1 = Symbol.for(marker12$1);
|
|
9757
|
-
var _a12$1;
|
|
9758
|
-
var _b12$1;
|
|
9759
|
-
var NoSuchModelError = class extends (_b12$1 = AISDKError, _a12$1 = symbol12$1, _b12$1) {
|
|
9760
|
-
constructor({ errorName = name11$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
9761
|
-
super({
|
|
9762
|
-
name: errorName,
|
|
9763
|
-
message
|
|
9764
|
-
});
|
|
9765
|
-
this[_a12$1] = true;
|
|
9766
|
-
this.modelId = modelId;
|
|
9767
|
-
this.modelType = modelType;
|
|
9768
|
-
}
|
|
9769
|
-
static isInstance(error) {
|
|
9770
|
-
return AISDKError.hasMarker(error, marker12$1);
|
|
9771
|
-
}
|
|
9772
|
-
};
|
|
9773
|
-
var name12$1 = "AI_NoSuchProviderReferenceError";
|
|
9774
|
-
var marker13$1 = `vercel.ai.error.${name12$1}`;
|
|
9775
|
-
var symbol13$1 = Symbol.for(marker13$1);
|
|
9776
|
-
var _a13$1;
|
|
9777
|
-
var _b13$1;
|
|
9778
|
-
(class extends (_b13$1 = AISDKError, _a13$1 = symbol13$1, _b13$1) {
|
|
9779
|
-
constructor({ provider, reference, message = `No provider reference found for provider '${provider}'. Available providers: ${Object.keys(reference).join(", ")}` }) {
|
|
9780
|
-
super({
|
|
9781
|
-
name: name12$1,
|
|
9782
|
-
message
|
|
9783
|
-
});
|
|
9784
|
-
this[_a13$1] = true;
|
|
9785
|
-
this.provider = provider;
|
|
9786
|
-
this.reference = reference;
|
|
9787
|
-
}
|
|
9788
|
-
static isInstance(error) {
|
|
9789
|
-
return AISDKError.hasMarker(error, marker13$1);
|
|
9790
|
-
}
|
|
9791
|
-
});
|
|
9792
|
-
var name13$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
9793
|
-
var marker14$1 = `vercel.ai.error.${name13$1}`;
|
|
9794
|
-
var symbol14$1 = Symbol.for(marker14$1);
|
|
9795
|
-
var _a14$1;
|
|
9796
|
-
var _b14$1;
|
|
9797
|
-
(class extends (_b14$1 = AISDKError, _a14$1 = symbol14$1, _b14$1) {
|
|
9798
|
-
constructor(options) {
|
|
9799
|
-
super({
|
|
9800
|
-
name: name13$1,
|
|
9801
|
-
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.`
|
|
9802
|
-
});
|
|
9803
|
-
this[_a14$1] = true;
|
|
9804
|
-
this.provider = options.provider;
|
|
9805
|
-
this.modelId = options.modelId;
|
|
9806
|
-
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
9807
|
-
this.values = options.values;
|
|
9808
|
-
}
|
|
9809
|
-
static isInstance(error) {
|
|
9810
|
-
return AISDKError.hasMarker(error, marker14$1);
|
|
9811
|
-
}
|
|
9812
|
-
});
|
|
9813
|
-
var name14$1 = "AI_TypeValidationError";
|
|
9814
|
-
var marker15$1 = `vercel.ai.error.${name14$1}`;
|
|
9815
|
-
var symbol15$1 = Symbol.for(marker15$1);
|
|
9816
|
-
var _a15$1;
|
|
9817
|
-
var _b15$1;
|
|
9818
|
-
var TypeValidationError = class _TypeValidationError extends (_b15$1 = AISDKError, _a15$1 = symbol15$1, _b15$1) {
|
|
9819
|
-
constructor({ value, cause, context }) {
|
|
9820
|
-
let contextPrefix = "Type validation failed";
|
|
9821
|
-
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
9822
|
-
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
|
9823
|
-
contextPrefix += " (";
|
|
9824
|
-
const parts = [];
|
|
9825
|
-
if (context.entityName) parts.push(context.entityName);
|
|
9826
|
-
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
9827
|
-
contextPrefix += parts.join(", ");
|
|
9828
|
-
contextPrefix += ")";
|
|
9829
|
-
}
|
|
9830
|
-
super({
|
|
9831
|
-
name: name14$1,
|
|
9832
|
-
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
9833
|
-
Error message: ${getErrorMessage(cause)}`,
|
|
9834
|
-
cause
|
|
9835
|
-
});
|
|
9836
|
-
this[_a15$1] = true;
|
|
9837
|
-
this.value = value;
|
|
9838
|
-
this.context = context;
|
|
9839
|
-
}
|
|
9840
|
-
static isInstance(error) {
|
|
9841
|
-
return AISDKError.hasMarker(error, marker15$1);
|
|
9842
|
-
}
|
|
9843
|
-
/**
|
|
9844
|
-
* Wraps an error into a TypeValidationError.
|
|
9845
|
-
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
9846
|
-
* Otherwise, it creates a new TypeValidationError.
|
|
9847
|
-
*
|
|
9848
|
-
* @param {Object} params - The parameters for wrapping the error.
|
|
9849
|
-
* @param {unknown} params.value - The value that failed validation.
|
|
9850
|
-
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9851
|
-
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
9852
|
-
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9853
|
-
*/
|
|
9854
|
-
static wrap({ value, cause, context }) {
|
|
9855
|
-
var _a17, _b17, _c;
|
|
9856
|
-
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;
|
|
9857
|
-
return new _TypeValidationError({
|
|
9858
|
-
value,
|
|
9859
|
-
cause,
|
|
9860
|
-
context
|
|
9861
|
-
});
|
|
9862
|
-
}
|
|
9863
|
-
};
|
|
9864
|
-
var name15$1 = "AI_UnsupportedFunctionalityError";
|
|
9865
|
-
var marker16$1 = `vercel.ai.error.${name15$1}`;
|
|
9866
|
-
var symbol16$1 = Symbol.for(marker16$1);
|
|
9867
|
-
var _a16$1;
|
|
9868
|
-
var _b16$1;
|
|
9869
|
-
(class extends (_b16$1 = AISDKError, _a16$1 = symbol16$1, _b16$1) {
|
|
9870
|
-
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
9871
|
-
super({
|
|
9872
|
-
name: name15$1,
|
|
9873
|
-
message
|
|
9874
|
-
});
|
|
9875
|
-
this[_a16$1] = true;
|
|
9876
|
-
this.functionality = functionality;
|
|
9877
|
-
}
|
|
9878
|
-
static isInstance(error) {
|
|
9879
|
-
return AISDKError.hasMarker(error, marker16$1);
|
|
9880
|
-
}
|
|
9881
|
-
});
|
|
9882
|
-
TransformStream;
|
|
9883
|
-
new TextDecoder();
|
|
9884
|
-
var { btoa: btoa$1, atob: atob$1 } = globalThis;
|
|
9885
|
-
var name$2 = "AI_DownloadError";
|
|
9886
|
-
var marker2$2 = `vercel.ai.error.${name$2}`;
|
|
9887
|
-
var symbol$2 = Symbol.for(marker2$2);
|
|
9888
|
-
var _a$2;
|
|
9889
|
-
var _b$2;
|
|
9890
|
-
(class extends (_b$2 = AISDKError, _a$2 = symbol$2, _b$2) {
|
|
9891
|
-
constructor({ url, statusCode, statusText, cause, message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}` }) {
|
|
9892
|
-
super({
|
|
9893
|
-
name: name$2,
|
|
9894
|
-
message,
|
|
9895
|
-
cause
|
|
9896
|
-
});
|
|
9897
|
-
this[_a$2] = true;
|
|
9898
|
-
this.url = url;
|
|
9899
|
-
this.statusCode = statusCode;
|
|
9900
|
-
this.statusText = statusText;
|
|
9901
|
-
}
|
|
9902
|
-
static isInstance(error) {
|
|
9903
|
-
return AISDKError.hasMarker(error, marker2$2);
|
|
9673
|
+
return AISDKError$1.hasMarker(error, marker$1);
|
|
9904
9674
|
}
|
|
9905
9675
|
});
|
|
9906
9676
|
function getCurrentModulePath() {
|
|
@@ -9910,14 +9680,24 @@ function getCurrentModulePath() {
|
|
|
9910
9680
|
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
9911
9681
|
Error.captureStackTrace(error, getCurrentModulePath);
|
|
9912
9682
|
const [caller] = error.stack;
|
|
9913
|
-
const fileName = caller
|
|
9683
|
+
const fileName = caller?.getFileName();
|
|
9914
9684
|
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
9915
9685
|
return fileName;
|
|
9916
9686
|
} finally {
|
|
9917
9687
|
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
9918
9688
|
}
|
|
9919
9689
|
}
|
|
9920
|
-
|
|
9690
|
+
/**
|
|
9691
|
+
* Creates an ID generator.
|
|
9692
|
+
* The total length of the ID is the sum of the prefix, separator, and random part length.
|
|
9693
|
+
* Not cryptographically secure.
|
|
9694
|
+
*
|
|
9695
|
+
* @param alphabet - The alphabet to use for the ID. Default: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
|
|
9696
|
+
* @param prefix - The prefix of the ID to generate. Optional.
|
|
9697
|
+
* @param separator - The separator between the prefix and the random part of the ID. Default: '-'.
|
|
9698
|
+
* @param size - The size of the random part of the ID to generate. Default: 16.
|
|
9699
|
+
*/
|
|
9700
|
+
const createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator = "-" } = {}) => {
|
|
9921
9701
|
const generator = () => {
|
|
9922
9702
|
const alphabetLength = alphabet.length;
|
|
9923
9703
|
const chars = new Array(size);
|
|
@@ -9931,13 +9711,22 @@ var createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKL
|
|
|
9931
9711
|
});
|
|
9932
9712
|
return () => `${prefix}${separator}${generator()}`;
|
|
9933
9713
|
};
|
|
9934
|
-
|
|
9714
|
+
/**
|
|
9715
|
+
* Generates a 16-character random string to use for IDs.
|
|
9716
|
+
* Not cryptographically secure.
|
|
9717
|
+
*/
|
|
9718
|
+
const generateId = createIdGenerator();
|
|
9719
|
+
/**
|
|
9720
|
+
* Type-guard for Node.js `Buffer` instances.
|
|
9721
|
+
*
|
|
9722
|
+
* Uses optional chaining on `globalThis.Buffer` so it returns `false` in
|
|
9723
|
+
* runtimes where `Buffer` is not available (e.g. CloudFlare Workers).
|
|
9724
|
+
*/
|
|
9935
9725
|
function isBuffer(value) {
|
|
9936
|
-
|
|
9937
|
-
return (_b3 = (_a3 = globalThis.Buffer) == null ? void 0 : _a3.isBuffer(value)) != null ? _b3 : false;
|
|
9726
|
+
return globalThis.Buffer?.isBuffer(value) ?? false;
|
|
9938
9727
|
}
|
|
9939
|
-
|
|
9940
|
-
|
|
9728
|
+
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
9729
|
+
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*:/;
|
|
9941
9730
|
function _parse(text) {
|
|
9942
9731
|
const obj = JSON.parse(text);
|
|
9943
9732
|
if (obj === null || typeof obj !== "object") return obj;
|
|
@@ -9964,7 +9753,7 @@ function secureJsonParse(text) {
|
|
|
9964
9753
|
const { stackTraceLimit } = Error;
|
|
9965
9754
|
try {
|
|
9966
9755
|
Error.stackTraceLimit = 0;
|
|
9967
|
-
} catch
|
|
9756
|
+
} catch {
|
|
9968
9757
|
return _parse(text);
|
|
9969
9758
|
}
|
|
9970
9759
|
try {
|
|
@@ -9973,27 +9762,32 @@ function secureJsonParse(text) {
|
|
|
9973
9762
|
Error.stackTraceLimit = stackTraceLimit;
|
|
9974
9763
|
}
|
|
9975
9764
|
}
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9765
|
+
/**
|
|
9766
|
+
* Recursively adds additionalProperties: false to object schemas that do not
|
|
9767
|
+
* define a schema for their additional properties. This is necessary because
|
|
9768
|
+
* some providers (e.g. OpenAI) do not support additionalProperties: true.
|
|
9769
|
+
*/
|
|
9770
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema) {
|
|
9771
|
+
if (jsonSchema.type === "object" || Array.isArray(jsonSchema.type) && jsonSchema.type.includes("object")) {
|
|
9772
|
+
const { additionalProperties } = jsonSchema;
|
|
9773
|
+
jsonSchema.additionalProperties = additionalProperties != null && typeof additionalProperties !== "boolean" ? visit(additionalProperties) : false;
|
|
9774
|
+
const { properties } = jsonSchema;
|
|
9981
9775
|
if (properties != null) for (const key of Object.keys(properties)) properties[key] = visit(properties[key]);
|
|
9982
9776
|
}
|
|
9983
|
-
if (
|
|
9984
|
-
if (
|
|
9985
|
-
if (
|
|
9986
|
-
if (
|
|
9987
|
-
const { definitions } =
|
|
9777
|
+
if (jsonSchema.items != null) jsonSchema.items = Array.isArray(jsonSchema.items) ? jsonSchema.items.map(visit) : visit(jsonSchema.items);
|
|
9778
|
+
if (jsonSchema.anyOf != null) jsonSchema.anyOf = jsonSchema.anyOf.map(visit);
|
|
9779
|
+
if (jsonSchema.allOf != null) jsonSchema.allOf = jsonSchema.allOf.map(visit);
|
|
9780
|
+
if (jsonSchema.oneOf != null) jsonSchema.oneOf = jsonSchema.oneOf.map(visit);
|
|
9781
|
+
const { definitions } = jsonSchema;
|
|
9988
9782
|
if (definitions != null) for (const key of Object.keys(definitions)) definitions[key] = visit(definitions[key]);
|
|
9989
|
-
return
|
|
9783
|
+
return jsonSchema;
|
|
9990
9784
|
}
|
|
9991
9785
|
function visit(def) {
|
|
9992
9786
|
if (typeof def === "boolean") return def;
|
|
9993
9787
|
return addAdditionalPropertiesToJsonSchema(def);
|
|
9994
9788
|
}
|
|
9995
|
-
|
|
9996
|
-
|
|
9789
|
+
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
9790
|
+
const defaultOptions = {
|
|
9997
9791
|
name: void 0,
|
|
9998
9792
|
$refStrategy: "root",
|
|
9999
9793
|
basePath: ["#"],
|
|
@@ -10014,7 +9808,7 @@ var defaultOptions = {
|
|
|
10014
9808
|
base64Strategy: "contentEncoding:base64",
|
|
10015
9809
|
nameStrategy: "ref"
|
|
10016
9810
|
};
|
|
10017
|
-
|
|
9811
|
+
const getDefaultOptions = (options) => typeof options === "string" ? {
|
|
10018
9812
|
...defaultOptions,
|
|
10019
9813
|
name: options
|
|
10020
9814
|
} : {
|
|
@@ -10025,9 +9819,8 @@ function parseAnyDef() {
|
|
|
10025
9819
|
return {};
|
|
10026
9820
|
}
|
|
10027
9821
|
function parseArrayDef(def, refs) {
|
|
10028
|
-
var _a3, _b3, _c;
|
|
10029
9822
|
const res = { type: "array" };
|
|
10030
|
-
if (
|
|
9823
|
+
if (def.type?._def && def.type?._def?.typeName !== "ZodAny") res.items = parseDef(def.type._def, {
|
|
10031
9824
|
...refs,
|
|
10032
9825
|
currentPath: [...refs.currentPath, "items"]
|
|
10033
9826
|
});
|
|
@@ -10054,9 +9847,7 @@ function parseBigintDef(def) {
|
|
|
10054
9847
|
if (check.inclusive) res.maximum = check.value;
|
|
10055
9848
|
else res.exclusiveMaximum = check.value;
|
|
10056
9849
|
break;
|
|
10057
|
-
case "multipleOf":
|
|
10058
|
-
res.multipleOf = check.value;
|
|
10059
|
-
break;
|
|
9850
|
+
case "multipleOf": res.multipleOf = check.value;
|
|
10060
9851
|
}
|
|
10061
9852
|
return res;
|
|
10062
9853
|
}
|
|
@@ -10066,11 +9857,11 @@ function parseBooleanDef() {
|
|
|
10066
9857
|
function parseBrandedDef(_def, refs) {
|
|
10067
9858
|
return parseDef(_def.type._def, refs);
|
|
10068
9859
|
}
|
|
10069
|
-
|
|
9860
|
+
const parseCatchDef = (def, refs) => {
|
|
10070
9861
|
return parseDef(def.innerType._def, refs);
|
|
10071
9862
|
};
|
|
10072
9863
|
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
10073
|
-
const strategy = overrideDateStrategy
|
|
9864
|
+
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
10074
9865
|
if (Array.isArray(strategy)) return { anyOf: strategy.map((item) => parseDateDef(def, refs, item)) };
|
|
10075
9866
|
switch (strategy) {
|
|
10076
9867
|
case "string":
|
|
@@ -10085,7 +9876,7 @@ function parseDateDef(def, refs, overrideDateStrategy) {
|
|
|
10085
9876
|
case "integer": return integerDateParser(def);
|
|
10086
9877
|
}
|
|
10087
9878
|
}
|
|
10088
|
-
|
|
9879
|
+
const integerDateParser = (def) => {
|
|
10089
9880
|
const res = {
|
|
10090
9881
|
type: "integer",
|
|
10091
9882
|
format: "unix-time"
|
|
@@ -10094,9 +9885,7 @@ var integerDateParser = (def) => {
|
|
|
10094
9885
|
case "min":
|
|
10095
9886
|
res.minimum = check.value;
|
|
10096
9887
|
break;
|
|
10097
|
-
case "max":
|
|
10098
|
-
res.maximum = check.value;
|
|
10099
|
-
break;
|
|
9888
|
+
case "max": res.maximum = check.value;
|
|
10100
9889
|
}
|
|
10101
9890
|
return res;
|
|
10102
9891
|
};
|
|
@@ -10115,7 +9904,7 @@ function parseEnumDef(def) {
|
|
|
10115
9904
|
enum: Array.from(def.values)
|
|
10116
9905
|
};
|
|
10117
9906
|
}
|
|
10118
|
-
|
|
9907
|
+
const isJsonSchema7AllOfType = (type) => {
|
|
10119
9908
|
if ("type" in type && type.type === "string") return false;
|
|
10120
9909
|
return "allOf" in type;
|
|
10121
9910
|
};
|
|
@@ -10157,8 +9946,14 @@ function parseLiteralDef(def) {
|
|
|
10157
9946
|
const: def.value
|
|
10158
9947
|
};
|
|
10159
9948
|
}
|
|
10160
|
-
|
|
10161
|
-
|
|
9949
|
+
let emojiRegex = void 0;
|
|
9950
|
+
/**
|
|
9951
|
+
* Generated from the regular expressions found here as of 2024-05-22:
|
|
9952
|
+
* https://github.com/colinhacks/zod/blob/master/src/types.ts.
|
|
9953
|
+
*
|
|
9954
|
+
* Expressions with /i flag have been changed accordingly.
|
|
9955
|
+
*/
|
|
9956
|
+
const zodPatterns = {
|
|
10162
9957
|
/**
|
|
10163
9958
|
* `c` was changed to `[cC]` to replicate /i flag
|
|
10164
9959
|
*/
|
|
@@ -10168,7 +9963,7 @@ var zodPatterns = {
|
|
|
10168
9963
|
/**
|
|
10169
9964
|
* `a-z` was added to replicate /i flag
|
|
10170
9965
|
*/
|
|
10171
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
9966
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
10172
9967
|
/**
|
|
10173
9968
|
* Constructed a valid Unicode RegExp
|
|
10174
9969
|
*
|
|
@@ -10220,9 +10015,7 @@ function parseStringDef(def, refs) {
|
|
|
10220
10015
|
case "format:idn-email":
|
|
10221
10016
|
addFormat(res, "idn-email", check.message, refs);
|
|
10222
10017
|
break;
|
|
10223
|
-
case "pattern:zod":
|
|
10224
|
-
addPattern(res, zodPatterns.email, check.message, refs);
|
|
10225
|
-
break;
|
|
10018
|
+
case "pattern:zod": addPattern(res, zodPatterns.email, check.message, refs);
|
|
10226
10019
|
}
|
|
10227
10020
|
break;
|
|
10228
10021
|
case "url":
|
|
@@ -10293,23 +10086,17 @@ function parseStringDef(def, refs) {
|
|
|
10293
10086
|
case "contentEncoding:base64":
|
|
10294
10087
|
res.contentEncoding = "base64";
|
|
10295
10088
|
break;
|
|
10296
|
-
case "pattern:zod":
|
|
10297
|
-
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
10298
|
-
break;
|
|
10089
|
+
case "pattern:zod": addPattern(res, zodPatterns.base64, check.message, refs);
|
|
10299
10090
|
}
|
|
10300
10091
|
break;
|
|
10301
10092
|
case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
10302
|
-
case "toLowerCase":
|
|
10303
|
-
case "toUpperCase":
|
|
10304
|
-
case "trim": break;
|
|
10305
|
-
default:
|
|
10306
10093
|
}
|
|
10307
10094
|
return res;
|
|
10308
10095
|
}
|
|
10309
10096
|
function escapeLiteralCheckValue(literal, refs) {
|
|
10310
10097
|
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
10311
10098
|
}
|
|
10312
|
-
|
|
10099
|
+
const ALPHA_NUMERIC = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
10313
10100
|
function escapeNonAlphaNumeric(source) {
|
|
10314
10101
|
let result = "";
|
|
10315
10102
|
for (let i = 0; i < source.length; i++) {
|
|
@@ -10319,8 +10106,7 @@ function escapeNonAlphaNumeric(source) {
|
|
|
10319
10106
|
return result;
|
|
10320
10107
|
}
|
|
10321
10108
|
function addFormat(schema, value, message, refs) {
|
|
10322
|
-
|
|
10323
|
-
if (schema.format || ((_a3 = schema.anyOf) == null ? void 0 : _a3.some((x) => x.format))) {
|
|
10109
|
+
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
10324
10110
|
if (!schema.anyOf) schema.anyOf = [];
|
|
10325
10111
|
if (schema.format) {
|
|
10326
10112
|
schema.anyOf.push({ format: schema.format });
|
|
@@ -10333,8 +10119,7 @@ function addFormat(schema, value, message, refs) {
|
|
|
10333
10119
|
} else schema.format = value;
|
|
10334
10120
|
}
|
|
10335
10121
|
function addPattern(schema, regex, message, refs) {
|
|
10336
|
-
|
|
10337
|
-
if (schema.pattern || ((_a3 = schema.allOf) == null ? void 0 : _a3.some((x) => x.pattern))) {
|
|
10122
|
+
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
10338
10123
|
if (!schema.allOf) schema.allOf = [];
|
|
10339
10124
|
if (schema.pattern) {
|
|
10340
10125
|
schema.allOf.push({ pattern: schema.pattern });
|
|
@@ -10347,7 +10132,6 @@ function addPattern(schema, regex, message, refs) {
|
|
|
10347
10132
|
} else schema.pattern = stringifyRegExpWithFlags(regex, refs);
|
|
10348
10133
|
}
|
|
10349
10134
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
10350
|
-
var _a3;
|
|
10351
10135
|
if (!refs.applyRegexFlags || !regex.flags) return regex.source;
|
|
10352
10136
|
const flags = {
|
|
10353
10137
|
i: regex.flags.includes("i"),
|
|
@@ -10372,7 +10156,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10372
10156
|
pattern += source[i];
|
|
10373
10157
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10374
10158
|
inCharRange = false;
|
|
10375
|
-
} else if (source[i + 1] === "-" &&
|
|
10159
|
+
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
10376
10160
|
pattern += source[i];
|
|
10377
10161
|
inCharRange = true;
|
|
10378
10162
|
} else pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
@@ -10385,19 +10169,15 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10385
10169
|
}
|
|
10386
10170
|
if (flags.m) {
|
|
10387
10171
|
if (source[i] === "^") {
|
|
10388
|
-
pattern += `(^|(?<=[\r
|
|
10389
|
-
]))`;
|
|
10172
|
+
pattern += `(^|(?<=[\r\n]))`;
|
|
10390
10173
|
continue;
|
|
10391
10174
|
} else if (source[i] === "$") {
|
|
10392
|
-
pattern += `($|(?=[\r
|
|
10393
|
-
]))`;
|
|
10175
|
+
pattern += `($|(?=[\r\n]))`;
|
|
10394
10176
|
continue;
|
|
10395
10177
|
}
|
|
10396
10178
|
}
|
|
10397
10179
|
if (flags.s && source[i] === ".") {
|
|
10398
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
10399
|
-
` : `[${source[i]}\r
|
|
10400
|
-
]`;
|
|
10180
|
+
pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
|
|
10401
10181
|
continue;
|
|
10402
10182
|
}
|
|
10403
10183
|
pattern += source[i];
|
|
@@ -10407,32 +10187,31 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
10407
10187
|
}
|
|
10408
10188
|
try {
|
|
10409
10189
|
new RegExp(pattern);
|
|
10410
|
-
} catch
|
|
10190
|
+
} catch {
|
|
10411
10191
|
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
10412
10192
|
return regex.source;
|
|
10413
10193
|
}
|
|
10414
10194
|
return pattern;
|
|
10415
10195
|
}
|
|
10416
10196
|
function parseRecordDef(def, refs) {
|
|
10417
|
-
var _a3, _b3, _c, _d, _e, _f;
|
|
10418
10197
|
const schema = {
|
|
10419
10198
|
type: "object",
|
|
10420
|
-
additionalProperties:
|
|
10199
|
+
additionalProperties: parseDef(def.valueType._def, {
|
|
10421
10200
|
...refs,
|
|
10422
10201
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10423
|
-
})
|
|
10202
|
+
}) ?? refs.allowedAdditionalProperties
|
|
10424
10203
|
};
|
|
10425
|
-
if (
|
|
10204
|
+
if (def.keyType?._def.typeName === "ZodString" && def.keyType._def.checks?.length) {
|
|
10426
10205
|
const { type: _type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
10427
10206
|
return {
|
|
10428
10207
|
...schema,
|
|
10429
10208
|
propertyNames: keyType
|
|
10430
10209
|
};
|
|
10431
|
-
} else if (
|
|
10210
|
+
} else if (def.keyType?._def.typeName === "ZodEnum") return {
|
|
10432
10211
|
...schema,
|
|
10433
10212
|
propertyNames: { enum: def.keyType._def.values }
|
|
10434
10213
|
};
|
|
10435
|
-
else if (
|
|
10214
|
+
else if (def.keyType?._def.typeName === "ZodBranded" && def.keyType._def.type._def.typeName === "ZodString" && def.keyType._def.type._def.checks?.length) {
|
|
10436
10215
|
const { type: _type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
10437
10216
|
return {
|
|
10438
10217
|
...schema,
|
|
@@ -10487,7 +10266,7 @@ function parseNeverDef() {
|
|
|
10487
10266
|
function parseNullDef() {
|
|
10488
10267
|
return { type: "null" };
|
|
10489
10268
|
}
|
|
10490
|
-
|
|
10269
|
+
const primitiveMappings = {
|
|
10491
10270
|
ZodString: "string",
|
|
10492
10271
|
ZodNumber: "number",
|
|
10493
10272
|
ZodBigInt: "integer",
|
|
@@ -10497,9 +10276,9 @@ var primitiveMappings = {
|
|
|
10497
10276
|
function parseUnionDef(def, refs) {
|
|
10498
10277
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10499
10278
|
if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
|
|
10500
|
-
const types = options.reduce((
|
|
10279
|
+
const types = options.reduce((types, x) => {
|
|
10501
10280
|
const type = primitiveMappings[x._def.typeName];
|
|
10502
|
-
return type && !
|
|
10281
|
+
return type && !types.includes(type) ? [...types, type] : types;
|
|
10503
10282
|
}, []);
|
|
10504
10283
|
return { type: types.length > 1 ? types : types[0] };
|
|
10505
10284
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
@@ -10525,11 +10304,11 @@ function parseUnionDef(def, refs) {
|
|
|
10525
10304
|
}
|
|
10526
10305
|
} else if (options.every((x) => x._def.typeName === "ZodEnum")) return {
|
|
10527
10306
|
type: "string",
|
|
10528
|
-
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((
|
|
10307
|
+
enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x) => !acc.includes(x))], [])
|
|
10529
10308
|
};
|
|
10530
10309
|
return asAnyOf(def, refs);
|
|
10531
10310
|
}
|
|
10532
|
-
|
|
10311
|
+
const asAnyOf = (def, refs) => {
|
|
10533
10312
|
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
10534
10313
|
...refs,
|
|
10535
10314
|
currentPath: [
|
|
@@ -10573,9 +10352,7 @@ function parseNumberDef(def) {
|
|
|
10573
10352
|
if (check.inclusive) res.maximum = check.value;
|
|
10574
10353
|
else res.exclusiveMaximum = check.value;
|
|
10575
10354
|
break;
|
|
10576
|
-
case "multipleOf":
|
|
10577
|
-
res.multipleOf = check.value;
|
|
10578
|
-
break;
|
|
10355
|
+
case "multipleOf": res.multipleOf = check.value;
|
|
10579
10356
|
}
|
|
10580
10357
|
return res;
|
|
10581
10358
|
}
|
|
@@ -10626,13 +10403,12 @@ function decideAdditionalProperties(def, refs) {
|
|
|
10626
10403
|
function safeIsOptional(schema) {
|
|
10627
10404
|
try {
|
|
10628
10405
|
return schema.isOptional();
|
|
10629
|
-
} catch
|
|
10406
|
+
} catch {
|
|
10630
10407
|
return true;
|
|
10631
10408
|
}
|
|
10632
10409
|
}
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
if (refs.currentPath.toString() === ((_a3 = refs.propertyPath) == null ? void 0 : _a3.toString())) return parseDef(def.innerType._def, refs);
|
|
10410
|
+
const parseOptionalDef = (def, refs) => {
|
|
10411
|
+
if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
|
|
10636
10412
|
const innerSchema = parseDef(def.innerType._def, {
|
|
10637
10413
|
...refs,
|
|
10638
10414
|
currentPath: [
|
|
@@ -10643,7 +10419,7 @@ var parseOptionalDef = (def, refs) => {
|
|
|
10643
10419
|
});
|
|
10644
10420
|
return innerSchema ? { anyOf: [{ not: parseAnyDef() }, innerSchema] } : parseAnyDef();
|
|
10645
10421
|
};
|
|
10646
|
-
|
|
10422
|
+
const parsePipelineDef = (def, refs) => {
|
|
10647
10423
|
if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
|
|
10648
10424
|
else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
|
|
10649
10425
|
const inputSchema = parseDef(def.in._def, {
|
|
@@ -10716,10 +10492,10 @@ function parseUndefinedDef() {
|
|
|
10716
10492
|
function parseUnknownDef() {
|
|
10717
10493
|
return parseAnyDef();
|
|
10718
10494
|
}
|
|
10719
|
-
|
|
10495
|
+
const parseReadonlyDef = (def, refs) => {
|
|
10720
10496
|
return parseDef(def.innerType._def, refs);
|
|
10721
10497
|
};
|
|
10722
|
-
|
|
10498
|
+
const selectParser = (def, typeName, refs) => {
|
|
10723
10499
|
switch (typeName) {
|
|
10724
10500
|
case "ZodString": return parseStringDef(def, refs);
|
|
10725
10501
|
case "ZodNumber": return parseNumberDef(def);
|
|
@@ -10757,19 +10533,20 @@ var selectParser = (def, typeName, refs) => {
|
|
|
10757
10533
|
case "ZodFunction":
|
|
10758
10534
|
case "ZodVoid":
|
|
10759
10535
|
case "ZodSymbol": return;
|
|
10760
|
-
default:
|
|
10536
|
+
default:
|
|
10537
|
+
/* c8 ignore next */
|
|
10538
|
+
return ((_) => void 0)(typeName);
|
|
10761
10539
|
}
|
|
10762
10540
|
};
|
|
10763
|
-
|
|
10541
|
+
const getRelativePath = (pathA, pathB) => {
|
|
10764
10542
|
let i = 0;
|
|
10765
10543
|
for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
|
|
10766
10544
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
10767
10545
|
};
|
|
10768
10546
|
function parseDef(def, refs, forceResolution = false) {
|
|
10769
|
-
var _a3;
|
|
10770
10547
|
const seenItem = refs.seen.get(def);
|
|
10771
10548
|
if (refs.override) {
|
|
10772
|
-
const overrideResult =
|
|
10549
|
+
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
10773
10550
|
if (overrideResult !== ignoreOverride) return overrideResult;
|
|
10774
10551
|
}
|
|
10775
10552
|
if (seenItem && !forceResolution) {
|
|
@@ -10783,17 +10560,17 @@ function parseDef(def, refs, forceResolution = false) {
|
|
|
10783
10560
|
};
|
|
10784
10561
|
refs.seen.set(def, newItem);
|
|
10785
10562
|
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
10786
|
-
const
|
|
10787
|
-
if (
|
|
10563
|
+
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10564
|
+
if (jsonSchema) addMeta(def, refs, jsonSchema);
|
|
10788
10565
|
if (refs.postProcess) {
|
|
10789
|
-
const postProcessResult = refs.postProcess(
|
|
10790
|
-
newItem.jsonSchema =
|
|
10566
|
+
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
10567
|
+
newItem.jsonSchema = jsonSchema;
|
|
10791
10568
|
return postProcessResult;
|
|
10792
10569
|
}
|
|
10793
|
-
newItem.jsonSchema =
|
|
10794
|
-
return
|
|
10570
|
+
newItem.jsonSchema = jsonSchema;
|
|
10571
|
+
return jsonSchema;
|
|
10795
10572
|
}
|
|
10796
|
-
|
|
10573
|
+
const get$ref = (item, refs) => {
|
|
10797
10574
|
switch (refs.$refStrategy) {
|
|
10798
10575
|
case "root": return { $ref: item.path.join("/") };
|
|
10799
10576
|
case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
@@ -10805,252 +10582,617 @@ var get$ref = (item, refs) => {
|
|
|
10805
10582
|
}
|
|
10806
10583
|
return refs.$refStrategy === "seen" ? parseAnyDef() : void 0;
|
|
10807
10584
|
}
|
|
10808
|
-
};
|
|
10809
|
-
|
|
10810
|
-
if (def.description)
|
|
10811
|
-
return
|
|
10812
|
-
};
|
|
10813
|
-
|
|
10814
|
-
const _options = getDefaultOptions(options);
|
|
10815
|
-
const currentPath = _options.name !== void 0 ? [
|
|
10816
|
-
..._options.basePath,
|
|
10817
|
-
_options.definitionPath,
|
|
10818
|
-
_options.name
|
|
10819
|
-
] : _options.basePath;
|
|
10820
|
-
return {
|
|
10821
|
-
..._options,
|
|
10822
|
-
currentPath,
|
|
10823
|
-
propertyPath: void 0,
|
|
10824
|
-
seen: new Map(Object.entries(_options.definitions).map(([
|
|
10825
|
-
def: def._def,
|
|
10826
|
-
path: [
|
|
10827
|
-
..._options.basePath,
|
|
10828
|
-
_options.definitionPath,
|
|
10829
|
-
|
|
10830
|
-
],
|
|
10831
|
-
jsonSchema: void 0
|
|
10832
|
-
}]))
|
|
10833
|
-
};
|
|
10834
|
-
};
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10585
|
+
};
|
|
10586
|
+
const addMeta = (def, refs, jsonSchema) => {
|
|
10587
|
+
if (def.description) jsonSchema.description = def.description;
|
|
10588
|
+
return jsonSchema;
|
|
10589
|
+
};
|
|
10590
|
+
const getRefs = (options) => {
|
|
10591
|
+
const _options = getDefaultOptions(options);
|
|
10592
|
+
const currentPath = _options.name !== void 0 ? [
|
|
10593
|
+
..._options.basePath,
|
|
10594
|
+
_options.definitionPath,
|
|
10595
|
+
_options.name
|
|
10596
|
+
] : _options.basePath;
|
|
10597
|
+
return {
|
|
10598
|
+
..._options,
|
|
10599
|
+
currentPath,
|
|
10600
|
+
propertyPath: void 0,
|
|
10601
|
+
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
|
|
10602
|
+
def: def._def,
|
|
10603
|
+
path: [
|
|
10604
|
+
..._options.basePath,
|
|
10605
|
+
_options.definitionPath,
|
|
10606
|
+
name
|
|
10607
|
+
],
|
|
10608
|
+
jsonSchema: void 0
|
|
10609
|
+
}]))
|
|
10610
|
+
};
|
|
10611
|
+
};
|
|
10612
|
+
const zod3ToJsonSchema = (schema, options) => {
|
|
10613
|
+
const refs = getRefs(options);
|
|
10614
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
|
|
10615
|
+
...acc,
|
|
10616
|
+
[name]: parseDef(schema._def, {
|
|
10617
|
+
...refs,
|
|
10618
|
+
currentPath: [
|
|
10619
|
+
...refs.basePath,
|
|
10620
|
+
refs.definitionPath,
|
|
10621
|
+
name
|
|
10622
|
+
]
|
|
10623
|
+
}, true) ?? parseAnyDef()
|
|
10624
|
+
}), {}) : void 0;
|
|
10625
|
+
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
10626
|
+
const main = parseDef(schema._def, name === void 0 ? refs : {
|
|
10627
|
+
...refs,
|
|
10628
|
+
currentPath: [
|
|
10629
|
+
...refs.basePath,
|
|
10630
|
+
refs.definitionPath,
|
|
10631
|
+
name
|
|
10632
|
+
]
|
|
10633
|
+
}, false) ?? parseAnyDef();
|
|
10634
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10635
|
+
if (title !== void 0) main.title = title;
|
|
10636
|
+
const combined = name === void 0 ? definitions ? {
|
|
10637
|
+
...main,
|
|
10638
|
+
[refs.definitionPath]: definitions
|
|
10639
|
+
} : main : {
|
|
10640
|
+
$ref: [
|
|
10641
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10642
|
+
refs.definitionPath,
|
|
10643
|
+
name
|
|
10644
|
+
].join("/"),
|
|
10645
|
+
[refs.definitionPath]: {
|
|
10646
|
+
...definitions,
|
|
10647
|
+
[name]: main
|
|
10648
|
+
}
|
|
10649
|
+
};
|
|
10650
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10651
|
+
return combined;
|
|
10652
|
+
};
|
|
10653
|
+
/**
|
|
10654
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
|
10655
|
+
*/
|
|
10656
|
+
const schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
10657
|
+
/**
|
|
10658
|
+
* Create a schema using a JSON Schema.
|
|
10659
|
+
*
|
|
10660
|
+
* @param jsonSchema The JSON Schema for the schema.
|
|
10661
|
+
* @param options.validate Optional. A validation function for the schema.
|
|
10662
|
+
*/
|
|
10663
|
+
function jsonSchema(jsonSchema, { validate } = {}) {
|
|
10664
|
+
return {
|
|
10665
|
+
[schemaSymbol]: true,
|
|
10666
|
+
_type: void 0,
|
|
10667
|
+
get jsonSchema() {
|
|
10668
|
+
if (typeof jsonSchema === "function") jsonSchema = jsonSchema();
|
|
10669
|
+
return jsonSchema;
|
|
10670
|
+
},
|
|
10671
|
+
validate
|
|
10672
|
+
};
|
|
10673
|
+
}
|
|
10674
|
+
function isSchema(value) {
|
|
10675
|
+
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
10676
|
+
}
|
|
10677
|
+
function asSchema(schema) {
|
|
10678
|
+
return schema == null ? jsonSchema({
|
|
10679
|
+
type: "object",
|
|
10680
|
+
properties: {},
|
|
10681
|
+
additionalProperties: false
|
|
10682
|
+
}) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
10683
|
+
}
|
|
10684
|
+
function standardSchema(standardSchema) {
|
|
10685
|
+
return jsonSchema(() => {
|
|
10686
|
+
if (!hasStandardJsonSchema(standardSchema)) throw new Error(`Standard schema vendor '${standardSchema["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
10687
|
+
return addAdditionalPropertiesToJsonSchema(standardSchema["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
10688
|
+
}, { validate: async (value) => {
|
|
10689
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
10690
|
+
return "value" in result ? {
|
|
10691
|
+
success: true,
|
|
10692
|
+
value: result.value
|
|
10693
|
+
} : {
|
|
10694
|
+
success: false,
|
|
10695
|
+
error: new TypeValidationError$1({
|
|
10696
|
+
value,
|
|
10697
|
+
cause: result.issues
|
|
10698
|
+
})
|
|
10699
|
+
};
|
|
10700
|
+
} });
|
|
10701
|
+
}
|
|
10702
|
+
function hasStandardJsonSchema(schema) {
|
|
10703
|
+
return schema["~standard"].jsonSchema != null;
|
|
10704
|
+
}
|
|
10705
|
+
function zod3Schema(zodSchema, options) {
|
|
10706
|
+
const useReferences = options?.useReferences ?? false;
|
|
10707
|
+
return jsonSchema(() => zod3ToJsonSchema(zodSchema, { $refStrategy: useReferences ? "root" : "none" }), { validate: async (value) => {
|
|
10708
|
+
const result = await zodSchema.safeParseAsync(value);
|
|
10709
|
+
return result.success ? {
|
|
10710
|
+
success: true,
|
|
10711
|
+
value: result.data
|
|
10712
|
+
} : {
|
|
10713
|
+
success: false,
|
|
10714
|
+
error: result.error
|
|
10715
|
+
};
|
|
10716
|
+
} });
|
|
10717
|
+
}
|
|
10718
|
+
function zod4Schema(zodSchema, options) {
|
|
10719
|
+
const useReferences = options?.useReferences ?? false;
|
|
10720
|
+
return jsonSchema(() => addAdditionalPropertiesToJsonSchema(toJSONSchema(zodSchema, {
|
|
10721
|
+
target: "draft-7",
|
|
10722
|
+
io: "input",
|
|
10723
|
+
reused: useReferences ? "ref" : "inline"
|
|
10724
|
+
})), { validate: async (value) => {
|
|
10725
|
+
const result = await safeParseAsync(zodSchema, value);
|
|
10726
|
+
return result.success ? {
|
|
10727
|
+
success: true,
|
|
10728
|
+
value: result.data
|
|
10729
|
+
} : {
|
|
10730
|
+
success: false,
|
|
10731
|
+
error: result.error
|
|
10732
|
+
};
|
|
10733
|
+
} });
|
|
10734
|
+
}
|
|
10735
|
+
function isZod4Schema(zodSchema) {
|
|
10736
|
+
return "_zod" in zodSchema;
|
|
10737
|
+
}
|
|
10738
|
+
function zodSchema(zodSchema, options) {
|
|
10739
|
+
if (isZod4Schema(zodSchema)) return zod4Schema(zodSchema, options);
|
|
10740
|
+
else return zod3Schema(zodSchema, options);
|
|
10741
|
+
}
|
|
10742
|
+
/**
|
|
10743
|
+
* Validates the types of an unknown object using a schema and
|
|
10744
|
+
* return a strongly-typed object.
|
|
10745
|
+
*
|
|
10746
|
+
* @template T - The type of the object to validate.
|
|
10747
|
+
* @param {string} options.value - The object to validate.
|
|
10748
|
+
* @param {Validator<T>} options.schema - The schema to use for validating the JSON.
|
|
10749
|
+
* @param {TypeValidationContext} options.context - Optional context about what is being validated.
|
|
10750
|
+
* @returns {Promise<T>} - The typed object.
|
|
10751
|
+
*/
|
|
10752
|
+
async function validateTypes({ value, schema, context }) {
|
|
10753
|
+
const result = await safeValidateTypes({
|
|
10754
|
+
value,
|
|
10755
|
+
schema,
|
|
10756
|
+
context
|
|
10757
|
+
});
|
|
10758
|
+
if (!result.success) throw TypeValidationError$1.wrap({
|
|
10759
|
+
value,
|
|
10760
|
+
cause: result.error,
|
|
10761
|
+
context
|
|
10762
|
+
});
|
|
10763
|
+
return result.value;
|
|
10764
|
+
}
|
|
10765
|
+
/**
|
|
10766
|
+
* Safely 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 JSON 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 An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
|
|
10774
|
+
*/
|
|
10775
|
+
async function safeValidateTypes({ value, schema, context }) {
|
|
10776
|
+
const actualSchema = asSchema(schema);
|
|
10777
|
+
try {
|
|
10778
|
+
if (actualSchema.validate == null) return {
|
|
10779
|
+
success: true,
|
|
10780
|
+
value,
|
|
10781
|
+
rawValue: value
|
|
10782
|
+
};
|
|
10783
|
+
const result = await actualSchema.validate(value);
|
|
10784
|
+
if (result.success) return {
|
|
10785
|
+
success: true,
|
|
10786
|
+
value: result.value,
|
|
10787
|
+
rawValue: value
|
|
10788
|
+
};
|
|
10789
|
+
return {
|
|
10790
|
+
success: false,
|
|
10791
|
+
error: TypeValidationError$1.wrap({
|
|
10792
|
+
value,
|
|
10793
|
+
cause: result.error,
|
|
10794
|
+
context
|
|
10795
|
+
}),
|
|
10796
|
+
rawValue: value
|
|
10797
|
+
};
|
|
10798
|
+
} catch (error) {
|
|
10799
|
+
return {
|
|
10800
|
+
success: false,
|
|
10801
|
+
error: TypeValidationError$1.wrap({
|
|
10802
|
+
value,
|
|
10803
|
+
cause: error,
|
|
10804
|
+
context
|
|
10805
|
+
}),
|
|
10806
|
+
rawValue: value
|
|
10807
|
+
};
|
|
10808
|
+
}
|
|
10809
|
+
}
|
|
10810
|
+
async function safeParseJSON({ text, schema }) {
|
|
10811
|
+
try {
|
|
10812
|
+
const value = secureJsonParse(text);
|
|
10813
|
+
if (schema == null) return {
|
|
10814
|
+
success: true,
|
|
10815
|
+
value,
|
|
10816
|
+
rawValue: value
|
|
10817
|
+
};
|
|
10818
|
+
return await safeValidateTypes({
|
|
10819
|
+
value,
|
|
10820
|
+
schema
|
|
10821
|
+
});
|
|
10822
|
+
} catch (error) {
|
|
10823
|
+
return {
|
|
10824
|
+
success: false,
|
|
10825
|
+
error: JSONParseError$1.isInstance(error) ? error : new JSONParseError$1({
|
|
10826
|
+
text,
|
|
10827
|
+
cause: error
|
|
10828
|
+
}),
|
|
10829
|
+
rawValue: void 0
|
|
10830
|
+
};
|
|
10831
|
+
}
|
|
10832
|
+
}
|
|
10833
|
+
/**
|
|
10834
|
+
* Resolves a value that could be a raw value, a Promise, a function returning a value,
|
|
10835
|
+
* or a function returning a Promise.
|
|
10836
|
+
*/
|
|
10837
|
+
async function resolve(value) {
|
|
10838
|
+
if (typeof value === "function") value = value();
|
|
10839
|
+
return value;
|
|
10840
|
+
}
|
|
10841
|
+
new TextDecoder();
|
|
10842
|
+
var marker$2 = "vercel.ai.error";
|
|
10843
|
+
var symbol$2 = Symbol.for(marker$2);
|
|
10844
|
+
var _a$1;
|
|
10845
|
+
var _b$1;
|
|
10846
|
+
var AISDKError = class _AISDKError extends (_b$1 = Error, _a$1 = symbol$2, _b$1) {
|
|
10847
|
+
/**
|
|
10848
|
+
* Creates an AI SDK Error.
|
|
10849
|
+
*
|
|
10850
|
+
* @param {Object} params - The parameters for creating the error.
|
|
10851
|
+
* @param {string} params.name - The name of the error.
|
|
10852
|
+
* @param {string} params.message - The error message.
|
|
10853
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
10854
|
+
*/
|
|
10855
|
+
constructor({ name: name16, message, cause }) {
|
|
10856
|
+
super(message);
|
|
10857
|
+
this[_a$1] = true;
|
|
10858
|
+
this.name = name16;
|
|
10859
|
+
this.cause = cause;
|
|
10860
|
+
}
|
|
10861
|
+
/**
|
|
10862
|
+
* Checks if the given error is an AI SDK Error.
|
|
10863
|
+
* @param {unknown} error - The error to check.
|
|
10864
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
10865
|
+
*/
|
|
10866
|
+
static isInstance(error) {
|
|
10867
|
+
return _AISDKError.hasMarker(error, marker$2);
|
|
10868
|
+
}
|
|
10869
|
+
static hasMarker(error, marker17) {
|
|
10870
|
+
const markerSymbol = Symbol.for(marker17);
|
|
10871
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
10872
|
+
}
|
|
10873
|
+
};
|
|
10874
|
+
var name$3 = "AI_APICallError";
|
|
10875
|
+
var marker2$1 = `vercel.ai.error.${name$3}`;
|
|
10876
|
+
var symbol2$1 = Symbol.for(marker2$1);
|
|
10877
|
+
var _a2$1;
|
|
10878
|
+
var _b2$1;
|
|
10879
|
+
(class extends (_b2$1 = AISDKError, _a2$1 = symbol2$1, _b2$1) {
|
|
10880
|
+
constructor({ message, url, requestBodyValues, statusCode, responseHeaders, responseBody, cause, isRetryable = statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500), data }) {
|
|
10881
|
+
super({
|
|
10882
|
+
name: name$3,
|
|
10883
|
+
message,
|
|
10884
|
+
cause
|
|
10885
|
+
});
|
|
10886
|
+
this[_a2$1] = true;
|
|
10887
|
+
this.url = url;
|
|
10888
|
+
this.requestBodyValues = requestBodyValues;
|
|
10889
|
+
this.statusCode = statusCode;
|
|
10890
|
+
this.responseHeaders = responseHeaders;
|
|
10891
|
+
this.responseBody = responseBody;
|
|
10892
|
+
this.isRetryable = isRetryable;
|
|
10893
|
+
this.data = data;
|
|
10894
|
+
}
|
|
10895
|
+
static isInstance(error) {
|
|
10896
|
+
return AISDKError.hasMarker(error, marker2$1);
|
|
10897
|
+
}
|
|
10898
|
+
});
|
|
10899
|
+
var name2$1 = "AI_EmptyResponseBodyError";
|
|
10900
|
+
var marker3$1 = `vercel.ai.error.${name2$1}`;
|
|
10901
|
+
var symbol3$1 = Symbol.for(marker3$1);
|
|
10902
|
+
var _a3$1;
|
|
10903
|
+
var _b3$1;
|
|
10904
|
+
(class extends (_b3$1 = AISDKError, _a3$1 = symbol3$1, _b3$1) {
|
|
10905
|
+
constructor({ message = "Empty response body" } = {}) {
|
|
10906
|
+
super({
|
|
10907
|
+
name: name2$1,
|
|
10908
|
+
message
|
|
10909
|
+
});
|
|
10910
|
+
this[_a3$1] = true;
|
|
10911
|
+
}
|
|
10912
|
+
static isInstance(error) {
|
|
10913
|
+
return AISDKError.hasMarker(error, marker3$1);
|
|
10914
|
+
}
|
|
10915
|
+
});
|
|
10916
|
+
var name3$1 = "AI_EvaluationUnsupportedQuestionTypeError";
|
|
10917
|
+
var marker4$1 = `vercel.ai.error.${name3$1}`;
|
|
10918
|
+
var symbol4$1 = Symbol.for(marker4$1);
|
|
10919
|
+
var _a4$1;
|
|
10920
|
+
var _b4$1;
|
|
10921
|
+
(class extends (_b4$1 = AISDKError, _a4$1 = symbol4$1, _b4$1) {
|
|
10922
|
+
constructor({ questionId, questionType, provider, modelId, message = `Question "${questionId}" has type "${questionType}", which is not supported by provider "${provider}" and model "${modelId}".` }) {
|
|
10923
|
+
super({
|
|
10924
|
+
name: name3$1,
|
|
10925
|
+
message
|
|
10926
|
+
});
|
|
10927
|
+
this[_a4$1] = true;
|
|
10928
|
+
this.questionId = questionId;
|
|
10929
|
+
this.questionType = questionType;
|
|
10930
|
+
this.provider = provider;
|
|
10931
|
+
this.modelId = modelId;
|
|
10932
|
+
}
|
|
10933
|
+
static isInstance(error) {
|
|
10934
|
+
return AISDKError.hasMarker(error, marker4$1);
|
|
10935
|
+
}
|
|
10936
|
+
});
|
|
10937
|
+
function getErrorMessage(error) {
|
|
10938
|
+
if (error == null) return "unknown error";
|
|
10939
|
+
if (typeof error === "string") return error;
|
|
10940
|
+
if (error instanceof Error) return error.toString();
|
|
10941
|
+
return JSON.stringify(error);
|
|
10942
|
+
}
|
|
10943
|
+
var name4$1 = "AI_InvalidArgumentError";
|
|
10944
|
+
var marker5$1 = `vercel.ai.error.${name4$1}`;
|
|
10945
|
+
var symbol5$1 = Symbol.for(marker5$1);
|
|
10946
|
+
var _a5$1;
|
|
10947
|
+
var _b5$1;
|
|
10948
|
+
(class extends (_b5$1 = AISDKError, _a5$1 = symbol5$1, _b5$1) {
|
|
10949
|
+
constructor({ message, cause, argument }) {
|
|
10950
|
+
super({
|
|
10951
|
+
name: name4$1,
|
|
10952
|
+
message,
|
|
10953
|
+
cause
|
|
10954
|
+
});
|
|
10955
|
+
this[_a5$1] = true;
|
|
10956
|
+
this.argument = argument;
|
|
10957
|
+
}
|
|
10958
|
+
static isInstance(error) {
|
|
10959
|
+
return AISDKError.hasMarker(error, marker5$1);
|
|
10960
|
+
}
|
|
10961
|
+
});
|
|
10962
|
+
var name5$1 = "AI_InvalidPromptError";
|
|
10963
|
+
var marker6$1 = `vercel.ai.error.${name5$1}`;
|
|
10964
|
+
var symbol6$1 = Symbol.for(marker6$1);
|
|
10965
|
+
var _a6$1;
|
|
10966
|
+
var _b6$1;
|
|
10967
|
+
(class extends (_b6$1 = AISDKError, _a6$1 = symbol6$1, _b6$1) {
|
|
10968
|
+
constructor({ prompt, message, cause }) {
|
|
10969
|
+
super({
|
|
10970
|
+
name: name5$1,
|
|
10971
|
+
message: `Invalid prompt: ${message}`,
|
|
10972
|
+
cause
|
|
10973
|
+
});
|
|
10974
|
+
this[_a6$1] = true;
|
|
10975
|
+
this.prompt = prompt;
|
|
10976
|
+
}
|
|
10977
|
+
static isInstance(error) {
|
|
10978
|
+
return AISDKError.hasMarker(error, marker6$1);
|
|
10979
|
+
}
|
|
10980
|
+
});
|
|
10981
|
+
var name6$1 = "AI_InvalidResponseDataError";
|
|
10982
|
+
var marker7$1 = `vercel.ai.error.${name6$1}`;
|
|
10983
|
+
var symbol7$1 = Symbol.for(marker7$1);
|
|
10984
|
+
var _a7$1;
|
|
10985
|
+
var _b7$1;
|
|
10986
|
+
(class extends (_b7$1 = AISDKError, _a7$1 = symbol7$1, _b7$1) {
|
|
10987
|
+
constructor({ data, message = `Invalid response data: ${JSON.stringify(data)}.` }) {
|
|
10988
|
+
super({
|
|
10989
|
+
name: name6$1,
|
|
10990
|
+
message
|
|
10991
|
+
});
|
|
10992
|
+
this[_a7$1] = true;
|
|
10993
|
+
this.data = data;
|
|
10994
|
+
}
|
|
10995
|
+
static isInstance(error) {
|
|
10996
|
+
return AISDKError.hasMarker(error, marker7$1);
|
|
10997
|
+
}
|
|
10998
|
+
});
|
|
10999
|
+
var name7$1 = "AI_JSONParseError";
|
|
11000
|
+
var marker8$1 = `vercel.ai.error.${name7$1}`;
|
|
11001
|
+
var symbol8$1 = Symbol.for(marker8$1);
|
|
11002
|
+
var _a8$1;
|
|
11003
|
+
var _b8$1;
|
|
11004
|
+
(class extends (_b8$1 = AISDKError, _a8$1 = symbol8$1, _b8$1) {
|
|
11005
|
+
constructor({ text, cause }) {
|
|
11006
|
+
super({
|
|
11007
|
+
name: name7$1,
|
|
11008
|
+
message: `JSON parsing failed: Text: ${text}.
|
|
11009
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
11010
|
+
cause
|
|
11011
|
+
});
|
|
11012
|
+
this[_a8$1] = true;
|
|
11013
|
+
this.text = text;
|
|
11014
|
+
}
|
|
11015
|
+
static isInstance(error) {
|
|
11016
|
+
return AISDKError.hasMarker(error, marker8$1);
|
|
11017
|
+
}
|
|
11018
|
+
});
|
|
11019
|
+
var name8$1 = "AI_LoadAPIKeyError";
|
|
11020
|
+
var marker9$1 = `vercel.ai.error.${name8$1}`;
|
|
11021
|
+
var symbol9$1 = Symbol.for(marker9$1);
|
|
11022
|
+
var _a9$1;
|
|
11023
|
+
var _b9$1;
|
|
11024
|
+
(class extends (_b9$1 = AISDKError, _a9$1 = symbol9$1, _b9$1) {
|
|
11025
|
+
constructor({ message }) {
|
|
11026
|
+
super({
|
|
11027
|
+
name: name8$1,
|
|
11028
|
+
message
|
|
11029
|
+
});
|
|
11030
|
+
this[_a9$1] = true;
|
|
11031
|
+
}
|
|
11032
|
+
static isInstance(error) {
|
|
11033
|
+
return AISDKError.hasMarker(error, marker9$1);
|
|
11034
|
+
}
|
|
11035
|
+
});
|
|
11036
|
+
var name9$1 = "AI_LoadSettingError";
|
|
11037
|
+
var marker10$1 = `vercel.ai.error.${name9$1}`;
|
|
11038
|
+
var symbol10$1 = Symbol.for(marker10$1);
|
|
11039
|
+
var _a10$1;
|
|
11040
|
+
var _b10$1;
|
|
11041
|
+
(class extends (_b10$1 = AISDKError, _a10$1 = symbol10$1, _b10$1) {
|
|
11042
|
+
constructor({ message }) {
|
|
11043
|
+
super({
|
|
11044
|
+
name: name9$1,
|
|
11045
|
+
message
|
|
11046
|
+
});
|
|
11047
|
+
this[_a10$1] = true;
|
|
11048
|
+
}
|
|
11049
|
+
static isInstance(error) {
|
|
11050
|
+
return AISDKError.hasMarker(error, marker10$1);
|
|
11051
|
+
}
|
|
11052
|
+
});
|
|
11053
|
+
var name10$1 = "AI_NoContentGeneratedError";
|
|
11054
|
+
var marker11$1 = `vercel.ai.error.${name10$1}`;
|
|
11055
|
+
var symbol11$1 = Symbol.for(marker11$1);
|
|
11056
|
+
var _a11$1;
|
|
11057
|
+
var _b11$1;
|
|
11058
|
+
(class extends (_b11$1 = AISDKError, _a11$1 = symbol11$1, _b11$1) {
|
|
11059
|
+
constructor({ message = "No content generated." } = {}) {
|
|
11060
|
+
super({
|
|
11061
|
+
name: name10$1,
|
|
11062
|
+
message
|
|
11063
|
+
});
|
|
11064
|
+
this[_a11$1] = true;
|
|
11065
|
+
}
|
|
11066
|
+
static isInstance(error) {
|
|
11067
|
+
return AISDKError.hasMarker(error, marker11$1);
|
|
11068
|
+
}
|
|
11069
|
+
});
|
|
11070
|
+
var name11$1 = "AI_NoSuchModelError";
|
|
11071
|
+
var marker12$1 = `vercel.ai.error.${name11$1}`;
|
|
11072
|
+
var symbol12$1 = Symbol.for(marker12$1);
|
|
11073
|
+
var _a12$1;
|
|
11074
|
+
var _b12$1;
|
|
11075
|
+
var NoSuchModelError = class extends (_b12$1 = AISDKError, _a12$1 = symbol12$1, _b12$1) {
|
|
11076
|
+
constructor({ errorName = name11$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
|
|
11077
|
+
super({
|
|
11078
|
+
name: errorName,
|
|
11079
|
+
message
|
|
11080
|
+
});
|
|
11081
|
+
this[_a12$1] = true;
|
|
11082
|
+
this.modelId = modelId;
|
|
11083
|
+
this.modelType = modelType;
|
|
11084
|
+
}
|
|
11085
|
+
static isInstance(error) {
|
|
11086
|
+
return AISDKError.hasMarker(error, marker12$1);
|
|
11087
|
+
}
|
|
11088
|
+
};
|
|
11089
|
+
var name12$1 = "AI_NoSuchProviderReferenceError";
|
|
11090
|
+
var marker13$1 = `vercel.ai.error.${name12$1}`;
|
|
11091
|
+
var symbol13$1 = Symbol.for(marker13$1);
|
|
11092
|
+
var _a13$1;
|
|
11093
|
+
var _b13$1;
|
|
11094
|
+
(class extends (_b13$1 = AISDKError, _a13$1 = symbol13$1, _b13$1) {
|
|
11095
|
+
constructor({ provider, reference, message = `No provider reference found for provider '${provider}'. Available providers: ${Object.keys(reference).join(", ")}` }) {
|
|
11096
|
+
super({
|
|
11097
|
+
name: name12$1,
|
|
11098
|
+
message
|
|
11099
|
+
});
|
|
11100
|
+
this[_a13$1] = true;
|
|
11101
|
+
this.provider = provider;
|
|
11102
|
+
this.reference = reference;
|
|
11103
|
+
}
|
|
11104
|
+
static isInstance(error) {
|
|
11105
|
+
return AISDKError.hasMarker(error, marker13$1);
|
|
11106
|
+
}
|
|
11107
|
+
});
|
|
11108
|
+
var name13$1 = "AI_TooManyEmbeddingValuesForCallError";
|
|
11109
|
+
var marker14$1 = `vercel.ai.error.${name13$1}`;
|
|
11110
|
+
var symbol14$1 = Symbol.for(marker14$1);
|
|
11111
|
+
var _a14$1;
|
|
11112
|
+
var _b14$1;
|
|
11113
|
+
(class extends (_b14$1 = AISDKError, _a14$1 = symbol14$1, _b14$1) {
|
|
11114
|
+
constructor(options) {
|
|
11115
|
+
super({
|
|
11116
|
+
name: name13$1,
|
|
11117
|
+
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.`
|
|
11118
|
+
});
|
|
11119
|
+
this[_a14$1] = true;
|
|
11120
|
+
this.provider = options.provider;
|
|
11121
|
+
this.modelId = options.modelId;
|
|
11122
|
+
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
|
11123
|
+
this.values = options.values;
|
|
11124
|
+
}
|
|
11125
|
+
static isInstance(error) {
|
|
11126
|
+
return AISDKError.hasMarker(error, marker14$1);
|
|
11127
|
+
}
|
|
11128
|
+
});
|
|
11129
|
+
var name14$1 = "AI_TypeValidationError";
|
|
11130
|
+
var marker15$1 = `vercel.ai.error.${name14$1}`;
|
|
11131
|
+
var symbol15$1 = Symbol.for(marker15$1);
|
|
11132
|
+
var _a15$1;
|
|
11133
|
+
var _b15$1;
|
|
11134
|
+
var TypeValidationError = class _TypeValidationError extends (_b15$1 = AISDKError, _a15$1 = symbol15$1, _b15$1) {
|
|
11135
|
+
constructor({ value, cause, context }) {
|
|
11136
|
+
let contextPrefix = "Type validation failed";
|
|
11137
|
+
if (context == null ? void 0 : context.field) contextPrefix += ` for ${context.field}`;
|
|
11138
|
+
if ((context == null ? void 0 : context.entityName) || (context == null ? void 0 : context.entityId)) {
|
|
11139
|
+
contextPrefix += " (";
|
|
11140
|
+
const parts = [];
|
|
11141
|
+
if (context.entityName) parts.push(context.entityName);
|
|
11142
|
+
if (context.entityId) parts.push(`id: "${context.entityId}"`);
|
|
11143
|
+
contextPrefix += parts.join(", ");
|
|
11144
|
+
contextPrefix += ")";
|
|
10875
11145
|
}
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
}
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
get jsonSchema() {
|
|
10886
|
-
if (typeof jsonSchema2 === "function") jsonSchema2 = jsonSchema2();
|
|
10887
|
-
return jsonSchema2;
|
|
10888
|
-
},
|
|
10889
|
-
validate
|
|
10890
|
-
};
|
|
10891
|
-
}
|
|
10892
|
-
function isSchema(value) {
|
|
10893
|
-
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
10894
|
-
}
|
|
10895
|
-
function asSchema(schema) {
|
|
10896
|
-
return schema == null ? jsonSchema({
|
|
10897
|
-
type: "object",
|
|
10898
|
-
properties: {},
|
|
10899
|
-
additionalProperties: false
|
|
10900
|
-
}) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
10901
|
-
}
|
|
10902
|
-
function standardSchema(standardSchema2) {
|
|
10903
|
-
return jsonSchema(() => {
|
|
10904
|
-
if (!hasStandardJsonSchema(standardSchema2)) throw new Error(`Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
10905
|
-
return addAdditionalPropertiesToJsonSchema(standardSchema2["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
10906
|
-
}, { validate: async (value) => {
|
|
10907
|
-
const result = await standardSchema2["~standard"].validate(value);
|
|
10908
|
-
return "value" in result ? {
|
|
10909
|
-
success: true,
|
|
10910
|
-
value: result.value
|
|
10911
|
-
} : {
|
|
10912
|
-
success: false,
|
|
10913
|
-
error: new TypeValidationError({
|
|
10914
|
-
value,
|
|
10915
|
-
cause: result.issues
|
|
10916
|
-
})
|
|
10917
|
-
};
|
|
10918
|
-
} });
|
|
10919
|
-
}
|
|
10920
|
-
function hasStandardJsonSchema(schema) {
|
|
10921
|
-
return schema["~standard"].jsonSchema != null;
|
|
10922
|
-
}
|
|
10923
|
-
function zod3Schema(zodSchema2, options) {
|
|
10924
|
-
var _a3;
|
|
10925
|
-
const useReferences = (_a3 = options == null ? void 0 : options.useReferences) != null ? _a3 : false;
|
|
10926
|
-
return jsonSchema(() => zod3ToJsonSchema(zodSchema2, { $refStrategy: useReferences ? "root" : "none" }), { validate: async (value) => {
|
|
10927
|
-
const result = await zodSchema2.safeParseAsync(value);
|
|
10928
|
-
return result.success ? {
|
|
10929
|
-
success: true,
|
|
10930
|
-
value: result.data
|
|
10931
|
-
} : {
|
|
10932
|
-
success: false,
|
|
10933
|
-
error: result.error
|
|
10934
|
-
};
|
|
10935
|
-
} });
|
|
10936
|
-
}
|
|
10937
|
-
function zod4Schema(zodSchema2, options) {
|
|
10938
|
-
var _a3;
|
|
10939
|
-
const useReferences = (_a3 = options == null ? void 0 : options.useReferences) != null ? _a3 : false;
|
|
10940
|
-
return jsonSchema(() => addAdditionalPropertiesToJsonSchema(toJSONSchema(zodSchema2, {
|
|
10941
|
-
target: "draft-7",
|
|
10942
|
-
io: "input",
|
|
10943
|
-
reused: useReferences ? "ref" : "inline"
|
|
10944
|
-
})), { validate: async (value) => {
|
|
10945
|
-
const result = await safeParseAsync(zodSchema2, value);
|
|
10946
|
-
return result.success ? {
|
|
10947
|
-
success: true,
|
|
10948
|
-
value: result.data
|
|
10949
|
-
} : {
|
|
10950
|
-
success: false,
|
|
10951
|
-
error: result.error
|
|
10952
|
-
};
|
|
10953
|
-
} });
|
|
10954
|
-
}
|
|
10955
|
-
function isZod4Schema(zodSchema2) {
|
|
10956
|
-
return "_zod" in zodSchema2;
|
|
10957
|
-
}
|
|
10958
|
-
function zodSchema(zodSchema2, options) {
|
|
10959
|
-
if (isZod4Schema(zodSchema2)) return zod4Schema(zodSchema2, options);
|
|
10960
|
-
else return zod3Schema(zodSchema2, options);
|
|
10961
|
-
}
|
|
10962
|
-
async function validateTypes({ value, schema, context }) {
|
|
10963
|
-
const result = await safeValidateTypes({
|
|
10964
|
-
value,
|
|
10965
|
-
schema,
|
|
10966
|
-
context
|
|
10967
|
-
});
|
|
10968
|
-
if (!result.success) throw TypeValidationError.wrap({
|
|
10969
|
-
value,
|
|
10970
|
-
cause: result.error,
|
|
10971
|
-
context
|
|
10972
|
-
});
|
|
10973
|
-
return result.value;
|
|
10974
|
-
}
|
|
10975
|
-
async function safeValidateTypes({ value, schema, context }) {
|
|
10976
|
-
const actualSchema = asSchema(schema);
|
|
10977
|
-
try {
|
|
10978
|
-
if (actualSchema.validate == null) return {
|
|
10979
|
-
success: true,
|
|
10980
|
-
value,
|
|
10981
|
-
rawValue: value
|
|
10982
|
-
};
|
|
10983
|
-
const result = await actualSchema.validate(value);
|
|
10984
|
-
if (result.success) return {
|
|
10985
|
-
success: true,
|
|
10986
|
-
value: result.value,
|
|
10987
|
-
rawValue: value
|
|
10988
|
-
};
|
|
10989
|
-
return {
|
|
10990
|
-
success: false,
|
|
10991
|
-
error: TypeValidationError.wrap({
|
|
10992
|
-
value,
|
|
10993
|
-
cause: result.error,
|
|
10994
|
-
context
|
|
10995
|
-
}),
|
|
10996
|
-
rawValue: value
|
|
10997
|
-
};
|
|
10998
|
-
} catch (error) {
|
|
10999
|
-
return {
|
|
11000
|
-
success: false,
|
|
11001
|
-
error: TypeValidationError.wrap({
|
|
11002
|
-
value,
|
|
11003
|
-
cause: error,
|
|
11004
|
-
context
|
|
11005
|
-
}),
|
|
11006
|
-
rawValue: value
|
|
11007
|
-
};
|
|
11146
|
+
super({
|
|
11147
|
+
name: name14$1,
|
|
11148
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
11149
|
+
Error message: ${getErrorMessage(cause)}`,
|
|
11150
|
+
cause
|
|
11151
|
+
});
|
|
11152
|
+
this[_a15$1] = true;
|
|
11153
|
+
this.value = value;
|
|
11154
|
+
this.context = context;
|
|
11008
11155
|
}
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11156
|
+
static isInstance(error) {
|
|
11157
|
+
return AISDKError.hasMarker(error, marker15$1);
|
|
11158
|
+
}
|
|
11159
|
+
/**
|
|
11160
|
+
* Wraps an error into a TypeValidationError.
|
|
11161
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
11162
|
+
* Otherwise, it creates a new TypeValidationError.
|
|
11163
|
+
*
|
|
11164
|
+
* @param {Object} params - The parameters for wrapping the error.
|
|
11165
|
+
* @param {unknown} params.value - The value that failed validation.
|
|
11166
|
+
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
11167
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
11168
|
+
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
11169
|
+
*/
|
|
11170
|
+
static wrap({ value, cause, context }) {
|
|
11171
|
+
var _a17, _b17, _c;
|
|
11172
|
+
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;
|
|
11173
|
+
return new _TypeValidationError({
|
|
11019
11174
|
value,
|
|
11020
|
-
|
|
11175
|
+
cause,
|
|
11176
|
+
context
|
|
11021
11177
|
});
|
|
11022
|
-
} catch (error) {
|
|
11023
|
-
return {
|
|
11024
|
-
success: false,
|
|
11025
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({
|
|
11026
|
-
text,
|
|
11027
|
-
cause: error
|
|
11028
|
-
}),
|
|
11029
|
-
rawValue: void 0
|
|
11030
|
-
};
|
|
11031
11178
|
}
|
|
11032
|
-
}
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
var symbol2$2 = Symbol.for(marker3$2);
|
|
11041
|
-
var _a2$2;
|
|
11042
|
-
var _b2$2;
|
|
11043
|
-
(class extends (_b2$2 = AISDKError, _a2$2 = symbol2$2, _b2$2) {
|
|
11044
|
-
constructor({ message = "Failed to serialize value.", cause } = {}) {
|
|
11179
|
+
};
|
|
11180
|
+
var name15$1 = "AI_UnsupportedFunctionalityError";
|
|
11181
|
+
var marker16$1 = `vercel.ai.error.${name15$1}`;
|
|
11182
|
+
var symbol16$1 = Symbol.for(marker16$1);
|
|
11183
|
+
var _a16$1;
|
|
11184
|
+
var _b16$1;
|
|
11185
|
+
(class extends (_b16$1 = AISDKError, _a16$1 = symbol16$1, _b16$1) {
|
|
11186
|
+
constructor({ functionality, message = `'${functionality}' functionality not supported.` }) {
|
|
11045
11187
|
super({
|
|
11046
|
-
name:
|
|
11047
|
-
message
|
|
11048
|
-
cause
|
|
11188
|
+
name: name15$1,
|
|
11189
|
+
message
|
|
11049
11190
|
});
|
|
11050
|
-
this[
|
|
11191
|
+
this[_a16$1] = true;
|
|
11192
|
+
this.functionality = functionality;
|
|
11051
11193
|
}
|
|
11052
11194
|
static isInstance(error) {
|
|
11053
|
-
return AISDKError.hasMarker(error,
|
|
11195
|
+
return AISDKError.hasMarker(error, marker16$1);
|
|
11054
11196
|
}
|
|
11055
11197
|
});
|
|
11056
11198
|
//#endregion
|
|
@@ -16378,11 +16520,7 @@ function createProcessorMiddleware(options) {
|
|
|
16378
16520
|
state: {},
|
|
16379
16521
|
result: {
|
|
16380
16522
|
text: "",
|
|
16381
|
-
usage:
|
|
16382
|
-
inputTokens: 0,
|
|
16383
|
-
outputTokens: 0,
|
|
16384
|
-
totalTokens: 0
|
|
16385
|
-
},
|
|
16523
|
+
usage: result.usage,
|
|
16386
16524
|
finishReason: "unknown",
|
|
16387
16525
|
steps: []
|
|
16388
16526
|
},
|
|
@@ -16506,9 +16644,9 @@ function createProcessorMiddleware(options) {
|
|
|
16506
16644
|
const outputResult = {
|
|
16507
16645
|
text: (procState?.streamParts ?? []).filter((p) => p.type === "text-delta").map((p) => p.payload?.text ?? "").join(""),
|
|
16508
16646
|
usage: finishChunk?.payload?.output?.usage ?? {
|
|
16509
|
-
inputTokens: 0,
|
|
16510
|
-
outputTokens: 0,
|
|
16511
|
-
totalTokens: 0
|
|
16647
|
+
inputTokens: void 0,
|
|
16648
|
+
outputTokens: void 0,
|
|
16649
|
+
totalTokens: void 0
|
|
16512
16650
|
},
|
|
16513
16651
|
finishReason: finishChunk?.payload?.stepResult?.reason ?? "unknown",
|
|
16514
16652
|
steps: []
|
|
@@ -16692,14 +16830,10 @@ function convertMastraChunkToAISDKStreamPart(chunk) {
|
|
|
16692
16830
|
return {
|
|
16693
16831
|
type: "finish",
|
|
16694
16832
|
finishReason: toAISDKFinishReason(chunk.payload.stepResult?.reason || "stop"),
|
|
16695
|
-
usage:
|
|
16696
|
-
inputTokens: usage
|
|
16697
|
-
outputTokens: usage
|
|
16698
|
-
totalTokens: usage
|
|
16699
|
-
} : {
|
|
16700
|
-
inputTokens: 0,
|
|
16701
|
-
outputTokens: 0,
|
|
16702
|
-
totalTokens: 0
|
|
16833
|
+
usage: {
|
|
16834
|
+
inputTokens: usage?.inputTokens,
|
|
16835
|
+
outputTokens: usage?.outputTokens,
|
|
16836
|
+
totalTokens: usage?.totalTokens
|
|
16703
16837
|
},
|
|
16704
16838
|
providerMetadata: chunk.payload.metadata?.providerMetadata
|
|
16705
16839
|
};
|