@mastra/server 0.16.4-alpha.1 → 0.17.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-OTU37YZO.js → chunk-7XNKAVVA.js} +2526 -204
- package/dist/chunk-7XNKAVVA.js.map +1 -0
- package/dist/{chunk-2JEDATG5.cjs → chunk-JJBXJYMY.cjs} +2526 -204
- package/dist/{chunk-OTU37YZO.js.map → chunk-JJBXJYMY.cjs.map} +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2JEDATG5.cjs.map +0 -1
|
@@ -146,8 +146,8 @@ var require_ignore = __commonJS({
|
|
|
146
146
|
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
147
147
|
}
|
|
148
148
|
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
149
|
-
var define = (
|
|
150
|
-
Object.defineProperty(
|
|
149
|
+
var define = (object4, key, value) => {
|
|
150
|
+
Object.defineProperty(object4, key, { value });
|
|
151
151
|
return value;
|
|
152
152
|
};
|
|
153
153
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
@@ -599,10 +599,10 @@ __export(agent_builder_exports, {
|
|
|
599
599
|
streamVNextAgentBuilderActionHandler: () => streamVNextAgentBuilderActionHandler,
|
|
600
600
|
watchAgentBuilderActionHandler: () => watchAgentBuilderActionHandler
|
|
601
601
|
});
|
|
602
|
-
function zodToJsonSchema(
|
|
602
|
+
function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relative") {
|
|
603
603
|
const fn = "toJSONSchema";
|
|
604
604
|
if (fn in z) {
|
|
605
|
-
return z[fn](
|
|
605
|
+
return z[fn](zodSchema4, {
|
|
606
606
|
unrepresentable: "any",
|
|
607
607
|
override: (ctx) => {
|
|
608
608
|
const def = ctx.zodSchema?._zod?.def;
|
|
@@ -613,7 +613,7 @@ function zodToJsonSchema(zodSchema3, target = "jsonSchema7", strategy = "relativ
|
|
|
613
613
|
}
|
|
614
614
|
});
|
|
615
615
|
} else {
|
|
616
|
-
return esm_default(
|
|
616
|
+
return esm_default(zodSchema4, {
|
|
617
617
|
$refStrategy: strategy,
|
|
618
618
|
target
|
|
619
619
|
});
|
|
@@ -1213,8 +1213,8 @@ function formatDataStreamPart(type, value) {
|
|
|
1213
1213
|
`;
|
|
1214
1214
|
}
|
|
1215
1215
|
function zodSchema(zodSchema22, options) {
|
|
1216
|
-
var
|
|
1217
|
-
const useReferences = (
|
|
1216
|
+
var _a20;
|
|
1217
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
1218
1218
|
return jsonSchema(
|
|
1219
1219
|
esm_default(zodSchema22, {
|
|
1220
1220
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -1327,11 +1327,11 @@ var major = VERSION.split(".")[0];
|
|
|
1327
1327
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
1328
1328
|
var _global = _globalThis;
|
|
1329
1329
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
1330
|
-
var
|
|
1330
|
+
var _a20;
|
|
1331
1331
|
if (allowOverride === void 0) {
|
|
1332
1332
|
allowOverride = false;
|
|
1333
1333
|
}
|
|
1334
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
1334
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a20 !== void 0 ? _a20 : {
|
|
1335
1335
|
version: VERSION
|
|
1336
1336
|
};
|
|
1337
1337
|
if (!allowOverride && api[type]) {
|
|
@@ -1349,8 +1349,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
1349
1349
|
return true;
|
|
1350
1350
|
}
|
|
1351
1351
|
function getGlobal(type) {
|
|
1352
|
-
var
|
|
1353
|
-
var globalVersion = (
|
|
1352
|
+
var _a20, _b8;
|
|
1353
|
+
var globalVersion = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a20 === void 0 ? void 0 : _a20.version;
|
|
1354
1354
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1355
1355
|
return;
|
|
1356
1356
|
}
|
|
@@ -1527,13 +1527,13 @@ var DiagAPI = (
|
|
|
1527
1527
|
}
|
|
1528
1528
|
var self = this;
|
|
1529
1529
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1530
|
-
var
|
|
1530
|
+
var _a20, _b8, _c;
|
|
1531
1531
|
if (optionsOrLogLevel === void 0) {
|
|
1532
1532
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1533
1533
|
}
|
|
1534
1534
|
if (logger === self) {
|
|
1535
1535
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
1536
|
-
self.error((
|
|
1536
|
+
self.error((_a20 = err.stack) !== null && _a20 !== void 0 ? _a20 : err.message);
|
|
1537
1537
|
return false;
|
|
1538
1538
|
}
|
|
1539
1539
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -1704,12 +1704,12 @@ var ContextAPI = (
|
|
|
1704
1704
|
return this._getContextManager().active();
|
|
1705
1705
|
};
|
|
1706
1706
|
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
1707
|
-
var
|
|
1707
|
+
var _a20;
|
|
1708
1708
|
var args = [];
|
|
1709
1709
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1710
1710
|
args[_i - 3] = arguments[_i];
|
|
1711
1711
|
}
|
|
1712
|
-
return (
|
|
1712
|
+
return (_a20 = this._getContextManager()).with.apply(_a20, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
1713
1713
|
};
|
|
1714
1714
|
ContextAPI2.prototype.bind = function(context, target) {
|
|
1715
1715
|
return this._getContextManager().bind(context, target);
|
|
@@ -1804,8 +1804,8 @@ function setSpanContext(context, spanContext) {
|
|
|
1804
1804
|
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
1805
1805
|
}
|
|
1806
1806
|
function getSpanContext(context) {
|
|
1807
|
-
var
|
|
1808
|
-
return (
|
|
1807
|
+
var _a20;
|
|
1808
|
+
return (_a20 = getSpan(context)) === null || _a20 === void 0 ? void 0 : _a20.spanContext();
|
|
1809
1809
|
}
|
|
1810
1810
|
|
|
1811
1811
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
@@ -1831,7 +1831,7 @@ var NoopTracer = (
|
|
|
1831
1831
|
(function() {
|
|
1832
1832
|
function NoopTracer2() {
|
|
1833
1833
|
}
|
|
1834
|
-
NoopTracer2.prototype.startSpan = function(
|
|
1834
|
+
NoopTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1835
1835
|
if (context === void 0) {
|
|
1836
1836
|
context = contextApi.active();
|
|
1837
1837
|
}
|
|
@@ -1846,7 +1846,7 @@ var NoopTracer = (
|
|
|
1846
1846
|
return new NonRecordingSpan();
|
|
1847
1847
|
}
|
|
1848
1848
|
};
|
|
1849
|
-
NoopTracer2.prototype.startActiveSpan = function(
|
|
1849
|
+
NoopTracer2.prototype.startActiveSpan = function(name20, arg2, arg3, arg4) {
|
|
1850
1850
|
var opts;
|
|
1851
1851
|
var ctx;
|
|
1852
1852
|
var fn;
|
|
@@ -1863,7 +1863,7 @@ var NoopTracer = (
|
|
|
1863
1863
|
fn = arg4;
|
|
1864
1864
|
}
|
|
1865
1865
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1866
|
-
var span = this.startSpan(
|
|
1866
|
+
var span = this.startSpan(name20, opts, parentContext);
|
|
1867
1867
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1868
1868
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1869
1869
|
};
|
|
@@ -1879,14 +1879,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
1879
1879
|
var ProxyTracer = (
|
|
1880
1880
|
/** @class */
|
|
1881
1881
|
(function() {
|
|
1882
|
-
function ProxyTracer2(_provider,
|
|
1882
|
+
function ProxyTracer2(_provider, name20, version, options) {
|
|
1883
1883
|
this._provider = _provider;
|
|
1884
|
-
this.name =
|
|
1884
|
+
this.name = name20;
|
|
1885
1885
|
this.version = version;
|
|
1886
1886
|
this.options = options;
|
|
1887
1887
|
}
|
|
1888
|
-
ProxyTracer2.prototype.startSpan = function(
|
|
1889
|
-
return this._getTracer().startSpan(
|
|
1888
|
+
ProxyTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1889
|
+
return this._getTracer().startSpan(name20, options, context);
|
|
1890
1890
|
};
|
|
1891
1891
|
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1892
1892
|
var tracer = this._getTracer();
|
|
@@ -1927,20 +1927,20 @@ var ProxyTracerProvider = (
|
|
|
1927
1927
|
(function() {
|
|
1928
1928
|
function ProxyTracerProvider2() {
|
|
1929
1929
|
}
|
|
1930
|
-
ProxyTracerProvider2.prototype.getTracer = function(
|
|
1931
|
-
var
|
|
1932
|
-
return (
|
|
1930
|
+
ProxyTracerProvider2.prototype.getTracer = function(name20, version, options) {
|
|
1931
|
+
var _a20;
|
|
1932
|
+
return (_a20 = this.getDelegateTracer(name20, version, options)) !== null && _a20 !== void 0 ? _a20 : new ProxyTracer(this, name20, version, options);
|
|
1933
1933
|
};
|
|
1934
1934
|
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1935
|
-
var
|
|
1936
|
-
return (
|
|
1935
|
+
var _a20;
|
|
1936
|
+
return (_a20 = this._delegate) !== null && _a20 !== void 0 ? _a20 : NOOP_TRACER_PROVIDER;
|
|
1937
1937
|
};
|
|
1938
1938
|
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1939
1939
|
this._delegate = delegate;
|
|
1940
1940
|
};
|
|
1941
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(
|
|
1942
|
-
var
|
|
1943
|
-
return (
|
|
1941
|
+
ProxyTracerProvider2.prototype.getDelegateTracer = function(name20, version, options) {
|
|
1942
|
+
var _a20;
|
|
1943
|
+
return (_a20 = this._delegate) === null || _a20 === void 0 ? void 0 : _a20.getTracer(name20, version, options);
|
|
1944
1944
|
};
|
|
1945
1945
|
return ProxyTracerProvider2;
|
|
1946
1946
|
})()
|
|
@@ -1986,8 +1986,8 @@ var TraceAPI = (
|
|
|
1986
1986
|
TraceAPI2.prototype.getTracerProvider = function() {
|
|
1987
1987
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
1988
1988
|
};
|
|
1989
|
-
TraceAPI2.prototype.getTracer = function(
|
|
1990
|
-
return this.getTracerProvider().getTracer(
|
|
1989
|
+
TraceAPI2.prototype.getTracer = function(name20, version) {
|
|
1990
|
+
return this.getTracerProvider().getTracer(name20, version);
|
|
1991
1991
|
};
|
|
1992
1992
|
TraceAPI2.prototype.disable = function() {
|
|
1993
1993
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -3183,6 +3183,39 @@ function createAbortError() {
|
|
|
3183
3183
|
function extractResponseHeaders(response) {
|
|
3184
3184
|
return Object.fromEntries([...response.headers]);
|
|
3185
3185
|
}
|
|
3186
|
+
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
3187
|
+
var _a20, _b8, _c;
|
|
3188
|
+
if (globalThisAny.window) {
|
|
3189
|
+
return `runtime/browser`;
|
|
3190
|
+
}
|
|
3191
|
+
if ((_a20 = globalThisAny.navigator) == null ? void 0 : _a20.userAgent) {
|
|
3192
|
+
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
3193
|
+
}
|
|
3194
|
+
if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
|
|
3195
|
+
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
3196
|
+
}
|
|
3197
|
+
if (globalThisAny.EdgeRuntime) {
|
|
3198
|
+
return `runtime/vercel-edge`;
|
|
3199
|
+
}
|
|
3200
|
+
return "runtime/unknown";
|
|
3201
|
+
}
|
|
3202
|
+
function removeUndefinedEntries(record) {
|
|
3203
|
+
return Object.fromEntries(
|
|
3204
|
+
Object.entries(record).filter(([_key, value]) => value != null)
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
3208
|
+
const cleanedHeaders = removeUndefinedEntries(
|
|
3209
|
+
headers != null ? headers : {}
|
|
3210
|
+
);
|
|
3211
|
+
const normalizedHeaders = new Headers(cleanedHeaders);
|
|
3212
|
+
const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
|
|
3213
|
+
normalizedHeaders.set(
|
|
3214
|
+
"user-agent",
|
|
3215
|
+
[currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
|
|
3216
|
+
);
|
|
3217
|
+
return Object.fromEntries(normalizedHeaders);
|
|
3218
|
+
}
|
|
3186
3219
|
var createIdGenerator2 = ({
|
|
3187
3220
|
prefix,
|
|
3188
3221
|
size = 16,
|
|
@@ -3249,11 +3282,7 @@ function handleFetchError({
|
|
|
3249
3282
|
}
|
|
3250
3283
|
return error;
|
|
3251
3284
|
}
|
|
3252
|
-
|
|
3253
|
-
return Object.fromEntries(
|
|
3254
|
-
Object.entries(record).filter(([_key, value]) => value != null)
|
|
3255
|
-
);
|
|
3256
|
-
}
|
|
3285
|
+
var VERSION2 = "3.0.9" ;
|
|
3257
3286
|
var getOriginalFetch = () => globalThis.fetch;
|
|
3258
3287
|
var getFromApi = async ({
|
|
3259
3288
|
url,
|
|
@@ -3266,7 +3295,11 @@ var getFromApi = async ({
|
|
|
3266
3295
|
try {
|
|
3267
3296
|
const response = await fetch2(url, {
|
|
3268
3297
|
method: "GET",
|
|
3269
|
-
headers:
|
|
3298
|
+
headers: withUserAgentSuffix(
|
|
3299
|
+
headers,
|
|
3300
|
+
`ai-sdk/provider-utils/${VERSION2}`,
|
|
3301
|
+
getRuntimeEnvironmentUserAgent()
|
|
3302
|
+
),
|
|
3270
3303
|
signal: abortSignal
|
|
3271
3304
|
});
|
|
3272
3305
|
const responseHeaders = extractResponseHeaders(response);
|
|
@@ -3336,12 +3369,12 @@ function loadOptionalSetting({
|
|
|
3336
3369
|
}
|
|
3337
3370
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
3338
3371
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
3339
|
-
function _parse(
|
|
3340
|
-
const obj = JSON.parse(
|
|
3372
|
+
function _parse(text4) {
|
|
3373
|
+
const obj = JSON.parse(text4);
|
|
3341
3374
|
if (obj === null || typeof obj !== "object") {
|
|
3342
3375
|
return obj;
|
|
3343
3376
|
}
|
|
3344
|
-
if (suspectProtoRx.test(
|
|
3377
|
+
if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
|
|
3345
3378
|
return obj;
|
|
3346
3379
|
}
|
|
3347
3380
|
return filter(obj);
|
|
@@ -3368,11 +3401,11 @@ function filter(obj) {
|
|
|
3368
3401
|
}
|
|
3369
3402
|
return obj;
|
|
3370
3403
|
}
|
|
3371
|
-
function secureJsonParse(
|
|
3404
|
+
function secureJsonParse(text4) {
|
|
3372
3405
|
const { stackTraceLimit } = Error;
|
|
3373
3406
|
Error.stackTraceLimit = 0;
|
|
3374
3407
|
try {
|
|
3375
|
-
return _parse(
|
|
3408
|
+
return _parse(text4);
|
|
3376
3409
|
} finally {
|
|
3377
3410
|
Error.stackTraceLimit = stackTraceLimit;
|
|
3378
3411
|
}
|
|
@@ -3413,12 +3446,12 @@ async function safeValidateTypes2({
|
|
|
3413
3446
|
value,
|
|
3414
3447
|
schema
|
|
3415
3448
|
}) {
|
|
3416
|
-
const
|
|
3449
|
+
const validator22 = asValidator(schema);
|
|
3417
3450
|
try {
|
|
3418
|
-
if (
|
|
3451
|
+
if (validator22.validate == null) {
|
|
3419
3452
|
return { success: true, value, rawValue: value };
|
|
3420
3453
|
}
|
|
3421
|
-
const result = await
|
|
3454
|
+
const result = await validator22.validate(value);
|
|
3422
3455
|
if (result.success) {
|
|
3423
3456
|
return { success: true, value: result.value, rawValue: value };
|
|
3424
3457
|
}
|
|
@@ -3436,11 +3469,11 @@ async function safeValidateTypes2({
|
|
|
3436
3469
|
}
|
|
3437
3470
|
}
|
|
3438
3471
|
async function parseJSON({
|
|
3439
|
-
text:
|
|
3472
|
+
text: text4,
|
|
3440
3473
|
schema
|
|
3441
3474
|
}) {
|
|
3442
3475
|
try {
|
|
3443
|
-
const value = secureJsonParse(
|
|
3476
|
+
const value = secureJsonParse(text4);
|
|
3444
3477
|
if (schema == null) {
|
|
3445
3478
|
return value;
|
|
3446
3479
|
}
|
|
@@ -3449,15 +3482,15 @@ async function parseJSON({
|
|
|
3449
3482
|
if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
|
|
3450
3483
|
throw error;
|
|
3451
3484
|
}
|
|
3452
|
-
throw new JSONParseError({ text:
|
|
3485
|
+
throw new JSONParseError({ text: text4, cause: error });
|
|
3453
3486
|
}
|
|
3454
3487
|
}
|
|
3455
3488
|
async function safeParseJSON2({
|
|
3456
|
-
text:
|
|
3489
|
+
text: text4,
|
|
3457
3490
|
schema
|
|
3458
3491
|
}) {
|
|
3459
3492
|
try {
|
|
3460
|
-
const value = secureJsonParse(
|
|
3493
|
+
const value = secureJsonParse(text4);
|
|
3461
3494
|
if (schema == null) {
|
|
3462
3495
|
return { success: true, value, rawValue: value };
|
|
3463
3496
|
}
|
|
@@ -3465,7 +3498,7 @@ async function safeParseJSON2({
|
|
|
3465
3498
|
} catch (error) {
|
|
3466
3499
|
return {
|
|
3467
3500
|
success: false,
|
|
3468
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text:
|
|
3501
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
|
|
3469
3502
|
rawValue: void 0
|
|
3470
3503
|
};
|
|
3471
3504
|
}
|
|
@@ -3521,7 +3554,11 @@ var postToApi = async ({
|
|
|
3521
3554
|
try {
|
|
3522
3555
|
const response = await fetch2(url, {
|
|
3523
3556
|
method: "POST",
|
|
3524
|
-
headers:
|
|
3557
|
+
headers: withUserAgentSuffix(
|
|
3558
|
+
headers,
|
|
3559
|
+
`ai-sdk/provider-utils/${VERSION2}`,
|
|
3560
|
+
getRuntimeEnvironmentUserAgent()
|
|
3561
|
+
),
|
|
3525
3562
|
body: body.content,
|
|
3526
3563
|
signal: abortSignal
|
|
3527
3564
|
});
|
|
@@ -3714,11 +3751,11 @@ function parseAnyDef() {
|
|
|
3714
3751
|
return {};
|
|
3715
3752
|
}
|
|
3716
3753
|
function parseArrayDef(def, refs) {
|
|
3717
|
-
var
|
|
3754
|
+
var _a20, _b8, _c;
|
|
3718
3755
|
const res = {
|
|
3719
3756
|
type: "array"
|
|
3720
3757
|
};
|
|
3721
|
-
if (((
|
|
3758
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
|
|
3722
3759
|
res.items = parseDef(def.type._def, {
|
|
3723
3760
|
...refs,
|
|
3724
3761
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -4079,8 +4116,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
4079
4116
|
return result;
|
|
4080
4117
|
}
|
|
4081
4118
|
function addFormat(schema, value, message, refs) {
|
|
4082
|
-
var
|
|
4083
|
-
if (schema.format || ((
|
|
4119
|
+
var _a20;
|
|
4120
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
4084
4121
|
if (!schema.anyOf) {
|
|
4085
4122
|
schema.anyOf = [];
|
|
4086
4123
|
}
|
|
@@ -4099,8 +4136,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
4099
4136
|
}
|
|
4100
4137
|
}
|
|
4101
4138
|
function addPattern(schema, regex, message, refs) {
|
|
4102
|
-
var
|
|
4103
|
-
if (schema.pattern || ((
|
|
4139
|
+
var _a20;
|
|
4140
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
4104
4141
|
if (!schema.allOf) {
|
|
4105
4142
|
schema.allOf = [];
|
|
4106
4143
|
}
|
|
@@ -4119,7 +4156,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
4119
4156
|
}
|
|
4120
4157
|
}
|
|
4121
4158
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
4122
|
-
var
|
|
4159
|
+
var _a20;
|
|
4123
4160
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
4124
4161
|
return regex.source;
|
|
4125
4162
|
}
|
|
@@ -4149,7 +4186,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4149
4186
|
pattern += source[i];
|
|
4150
4187
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
4151
4188
|
inCharRange = false;
|
|
4152
|
-
} else if (source[i + 1] === "-" && ((
|
|
4189
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
4153
4190
|
pattern += source[i];
|
|
4154
4191
|
inCharRange = true;
|
|
4155
4192
|
} else {
|
|
@@ -4191,13 +4228,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4191
4228
|
return pattern;
|
|
4192
4229
|
}
|
|
4193
4230
|
function parseRecordDef(def, refs) {
|
|
4194
|
-
var
|
|
4231
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
4195
4232
|
const schema = {
|
|
4196
4233
|
type: "object",
|
|
4197
|
-
additionalProperties: (
|
|
4234
|
+
additionalProperties: (_a20 = parseDef(def.valueType._def, {
|
|
4198
4235
|
...refs,
|
|
4199
4236
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
4200
|
-
})) != null ?
|
|
4237
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
4201
4238
|
};
|
|
4202
4239
|
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
4203
4240
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -4248,11 +4285,11 @@ function parseMapDef(def, refs) {
|
|
|
4248
4285
|
};
|
|
4249
4286
|
}
|
|
4250
4287
|
function parseNativeEnumDef(def) {
|
|
4251
|
-
const
|
|
4288
|
+
const object4 = def.values;
|
|
4252
4289
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
4253
|
-
return typeof
|
|
4290
|
+
return typeof object4[object4[key]] !== "number";
|
|
4254
4291
|
});
|
|
4255
|
-
const actualValues = actualKeys.map((key) =>
|
|
4292
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
4256
4293
|
const parsedTypes = Array.from(
|
|
4257
4294
|
new Set(actualValues.map((values) => typeof values))
|
|
4258
4295
|
);
|
|
@@ -4456,8 +4493,8 @@ function safeIsOptional(schema) {
|
|
|
4456
4493
|
}
|
|
4457
4494
|
}
|
|
4458
4495
|
var parseOptionalDef = (def, refs) => {
|
|
4459
|
-
var
|
|
4460
|
-
if (refs.currentPath.toString() === ((
|
|
4496
|
+
var _a20;
|
|
4497
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
4461
4498
|
return parseDef(def.innerType._def, refs);
|
|
4462
4499
|
}
|
|
4463
4500
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -4627,10 +4664,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
4627
4664
|
}
|
|
4628
4665
|
};
|
|
4629
4666
|
function parseDef(def, refs, forceResolution = false) {
|
|
4630
|
-
var
|
|
4667
|
+
var _a20;
|
|
4631
4668
|
const seenItem = refs.seen.get(def);
|
|
4632
4669
|
if (refs.override) {
|
|
4633
|
-
const overrideResult = (
|
|
4670
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
4634
4671
|
refs,
|
|
4635
4672
|
def,
|
|
4636
4673
|
refs,
|
|
@@ -4696,11 +4733,11 @@ var getRefs = (options) => {
|
|
|
4696
4733
|
currentPath,
|
|
4697
4734
|
propertyPath: void 0,
|
|
4698
4735
|
seen: new Map(
|
|
4699
|
-
Object.entries(_options.definitions).map(([
|
|
4736
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
4700
4737
|
def._def,
|
|
4701
4738
|
{
|
|
4702
4739
|
def: def._def,
|
|
4703
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
4740
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
4704
4741
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
4705
4742
|
jsonSchema: void 0
|
|
4706
4743
|
}
|
|
@@ -4709,50 +4746,50 @@ var getRefs = (options) => {
|
|
|
4709
4746
|
};
|
|
4710
4747
|
};
|
|
4711
4748
|
var zodToJsonSchema2 = (schema, options) => {
|
|
4712
|
-
var
|
|
4749
|
+
var _a20;
|
|
4713
4750
|
const refs = getRefs(options);
|
|
4714
4751
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
4715
|
-
(acc, [
|
|
4716
|
-
var
|
|
4752
|
+
(acc, [name25, schema2]) => {
|
|
4753
|
+
var _a25;
|
|
4717
4754
|
return {
|
|
4718
4755
|
...acc,
|
|
4719
|
-
[
|
|
4756
|
+
[name25]: (_a25 = parseDef(
|
|
4720
4757
|
schema2._def,
|
|
4721
4758
|
{
|
|
4722
4759
|
...refs,
|
|
4723
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4760
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
4724
4761
|
},
|
|
4725
4762
|
true
|
|
4726
|
-
)) != null ?
|
|
4763
|
+
)) != null ? _a25 : parseAnyDef()
|
|
4727
4764
|
};
|
|
4728
4765
|
},
|
|
4729
4766
|
{}
|
|
4730
4767
|
) : void 0;
|
|
4731
|
-
const
|
|
4732
|
-
const main = (
|
|
4768
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
4769
|
+
const main = (_a20 = parseDef(
|
|
4733
4770
|
schema._def,
|
|
4734
|
-
|
|
4771
|
+
name20 === void 0 ? refs : {
|
|
4735
4772
|
...refs,
|
|
4736
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4773
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
4737
4774
|
},
|
|
4738
4775
|
false
|
|
4739
|
-
)) != null ?
|
|
4776
|
+
)) != null ? _a20 : parseAnyDef();
|
|
4740
4777
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
4741
4778
|
if (title !== void 0) {
|
|
4742
4779
|
main.title = title;
|
|
4743
4780
|
}
|
|
4744
|
-
const combined =
|
|
4781
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
4745
4782
|
...main,
|
|
4746
4783
|
[refs.definitionPath]: definitions
|
|
4747
4784
|
} : main : {
|
|
4748
4785
|
$ref: [
|
|
4749
4786
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
4750
4787
|
refs.definitionPath,
|
|
4751
|
-
|
|
4788
|
+
name20
|
|
4752
4789
|
].join("/"),
|
|
4753
4790
|
[refs.definitionPath]: {
|
|
4754
4791
|
...definitions,
|
|
4755
|
-
[
|
|
4792
|
+
[name20]: main
|
|
4756
4793
|
}
|
|
4757
4794
|
};
|
|
4758
4795
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -4760,8 +4797,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
4760
4797
|
};
|
|
4761
4798
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
4762
4799
|
function zod3Schema(zodSchema22, options) {
|
|
4763
|
-
var
|
|
4764
|
-
const useReferences = (
|
|
4800
|
+
var _a20;
|
|
4801
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4765
4802
|
return jsonSchema2(
|
|
4766
4803
|
zod_to_json_schema_default(zodSchema22, {
|
|
4767
4804
|
$refStrategy: useReferences ? "root" : "none"
|
|
@@ -4775,8 +4812,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
4775
4812
|
);
|
|
4776
4813
|
}
|
|
4777
4814
|
function zod4Schema(zodSchema22, options) {
|
|
4778
|
-
var
|
|
4779
|
-
const useReferences = (
|
|
4815
|
+
var _a20;
|
|
4816
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4780
4817
|
const z4JSONSchema = z42.toJSONSchema(zodSchema22, {
|
|
4781
4818
|
target: "draft-7",
|
|
4782
4819
|
io: "output",
|
|
@@ -5086,14 +5123,14 @@ var gatewayErrorResponseSchema = z$1.object({
|
|
|
5086
5123
|
})
|
|
5087
5124
|
});
|
|
5088
5125
|
function asGatewayError(error, authMethod) {
|
|
5089
|
-
var
|
|
5126
|
+
var _a84;
|
|
5090
5127
|
if (GatewayError.isInstance(error)) {
|
|
5091
5128
|
return error;
|
|
5092
5129
|
}
|
|
5093
5130
|
if (APICallError.isInstance(error)) {
|
|
5094
5131
|
return createGatewayErrorFromResponse({
|
|
5095
5132
|
response: extractApiCallResponse(error),
|
|
5096
|
-
statusCode: (
|
|
5133
|
+
statusCode: (_a84 = error.statusCode) != null ? _a84 : 500,
|
|
5097
5134
|
defaultMessage: "Gateway request failed",
|
|
5098
5135
|
cause: error,
|
|
5099
5136
|
authMethod
|
|
@@ -5344,7 +5381,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5344
5381
|
abortSignal,
|
|
5345
5382
|
providerOptions
|
|
5346
5383
|
}) {
|
|
5347
|
-
var
|
|
5384
|
+
var _a84;
|
|
5348
5385
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
5349
5386
|
try {
|
|
5350
5387
|
const {
|
|
@@ -5361,7 +5398,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5361
5398
|
),
|
|
5362
5399
|
body: {
|
|
5363
5400
|
input: values.length === 1 ? values[0] : values,
|
|
5364
|
-
...providerOptions
|
|
5401
|
+
...providerOptions ? { providerOptions } : {}
|
|
5365
5402
|
},
|
|
5366
5403
|
successfulResponseHandler: createJsonResponseHandler(
|
|
5367
5404
|
gatewayEmbeddingResponseSchema
|
|
@@ -5375,7 +5412,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5375
5412
|
});
|
|
5376
5413
|
return {
|
|
5377
5414
|
embeddings: responseBody.embeddings,
|
|
5378
|
-
usage: (
|
|
5415
|
+
usage: (_a84 = responseBody.usage) != null ? _a84 : void 0,
|
|
5379
5416
|
providerMetadata: responseBody.providerMetadata,
|
|
5380
5417
|
response: { headers: responseHeaders, body: rawValue }
|
|
5381
5418
|
};
|
|
@@ -5399,8 +5436,8 @@ var gatewayEmbeddingResponseSchema = z$1.object({
|
|
|
5399
5436
|
providerMetadata: z$1.record(z$1.string(), z$1.record(z$1.string(), z$1.unknown())).optional()
|
|
5400
5437
|
});
|
|
5401
5438
|
async function getVercelOidcToken() {
|
|
5402
|
-
var
|
|
5403
|
-
const token = (_b8 = (
|
|
5439
|
+
var _a84, _b8;
|
|
5440
|
+
const token = (_b8 = (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
5404
5441
|
if (!token) {
|
|
5405
5442
|
throw new GatewayAuthenticationError({
|
|
5406
5443
|
message: "OIDC token not available",
|
|
@@ -5410,21 +5447,21 @@ async function getVercelOidcToken() {
|
|
|
5410
5447
|
return token;
|
|
5411
5448
|
}
|
|
5412
5449
|
async function getVercelRequestId() {
|
|
5413
|
-
var
|
|
5414
|
-
return (
|
|
5450
|
+
var _a84;
|
|
5451
|
+
return (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-id"];
|
|
5415
5452
|
}
|
|
5416
5453
|
var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
|
|
5417
5454
|
function getContext() {
|
|
5418
|
-
var
|
|
5455
|
+
var _a84, _b8, _c;
|
|
5419
5456
|
const fromSymbol = globalThis;
|
|
5420
|
-
return (_c = (_b8 = (
|
|
5457
|
+
return (_c = (_b8 = (_a84 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a84.get) == null ? void 0 : _b8.call(_a84)) != null ? _c : {};
|
|
5421
5458
|
}
|
|
5422
5459
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
5423
5460
|
function createGatewayProvider(options = {}) {
|
|
5424
|
-
var
|
|
5461
|
+
var _a84, _b8;
|
|
5425
5462
|
let pendingMetadata = null;
|
|
5426
5463
|
let metadataCache = null;
|
|
5427
|
-
const cacheRefreshMillis = (
|
|
5464
|
+
const cacheRefreshMillis = (_a84 = options.metadataCacheRefreshMillis) != null ? _a84 : 1e3 * 60 * 5;
|
|
5428
5465
|
let lastFetchTime = 0;
|
|
5429
5466
|
const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
5430
5467
|
const getHeaders = async () => {
|
|
@@ -5476,8 +5513,8 @@ function createGatewayProvider(options = {}) {
|
|
|
5476
5513
|
});
|
|
5477
5514
|
};
|
|
5478
5515
|
const getAvailableModels = async () => {
|
|
5479
|
-
var
|
|
5480
|
-
const now = (_c = (_b9 = (
|
|
5516
|
+
var _a94, _b9, _c;
|
|
5517
|
+
const now = (_c = (_b9 = (_a94 = options._internal) == null ? void 0 : _a94.currentDate) == null ? void 0 : _b9.call(_a94).getTime()) != null ? _c : Date.now();
|
|
5481
5518
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
5482
5519
|
lastFetchTime = now;
|
|
5483
5520
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -6087,9 +6124,7 @@ function prepareRetries2({
|
|
|
6087
6124
|
})
|
|
6088
6125
|
};
|
|
6089
6126
|
}
|
|
6090
|
-
|
|
6091
|
-
return ({ steps }) => steps.length === stepCount;
|
|
6092
|
-
}
|
|
6127
|
+
var VERSION3 = "5.0.44" ;
|
|
6093
6128
|
createIdGenerator2({
|
|
6094
6129
|
prefix: "aitxt",
|
|
6095
6130
|
size: 24
|
|
@@ -6594,10 +6629,14 @@ async function embedMany2({
|
|
|
6594
6629
|
maxRetries: maxRetriesArg,
|
|
6595
6630
|
abortSignal
|
|
6596
6631
|
});
|
|
6632
|
+
const headersWithUserAgent = withUserAgentSuffix(
|
|
6633
|
+
headers != null ? headers : {},
|
|
6634
|
+
`ai/${VERSION3}`
|
|
6635
|
+
);
|
|
6597
6636
|
const baseTelemetryAttributes = getBaseTelemetryAttributes2({
|
|
6598
6637
|
model,
|
|
6599
6638
|
telemetry,
|
|
6600
|
-
headers,
|
|
6639
|
+
headers: headersWithUserAgent,
|
|
6601
6640
|
settings: { maxRetries }
|
|
6602
6641
|
});
|
|
6603
6642
|
const tracer = getTracer2(telemetry);
|
|
@@ -6646,7 +6685,7 @@ async function embedMany2({
|
|
|
6646
6685
|
const modelResponse = await model.doEmbed({
|
|
6647
6686
|
values,
|
|
6648
6687
|
abortSignal,
|
|
6649
|
-
headers,
|
|
6688
|
+
headers: headersWithUserAgent,
|
|
6650
6689
|
providerOptions
|
|
6651
6690
|
});
|
|
6652
6691
|
const embeddings3 = modelResponse.embeddings;
|
|
@@ -6728,7 +6767,7 @@ async function embedMany2({
|
|
|
6728
6767
|
const modelResponse = await model.doEmbed({
|
|
6729
6768
|
values: chunk,
|
|
6730
6769
|
abortSignal,
|
|
6731
|
-
headers,
|
|
6770
|
+
headers: headersWithUserAgent,
|
|
6732
6771
|
providerOptions
|
|
6733
6772
|
});
|
|
6734
6773
|
const embeddings2 = modelResponse.embeddings;
|
|
@@ -7095,6 +7134,7 @@ var toolUIPartSchemas = [
|
|
|
7095
7134
|
type: z$1.string().startsWith("tool-"),
|
|
7096
7135
|
toolCallId: z$1.string(),
|
|
7097
7136
|
state: z$1.literal("input-streaming"),
|
|
7137
|
+
providerExecuted: z$1.boolean().optional(),
|
|
7098
7138
|
input: z$1.unknown().optional(),
|
|
7099
7139
|
output: z$1.never().optional(),
|
|
7100
7140
|
errorText: z$1.never().optional()
|
|
@@ -7103,6 +7143,7 @@ var toolUIPartSchemas = [
|
|
|
7103
7143
|
type: z$1.string().startsWith("tool-"),
|
|
7104
7144
|
toolCallId: z$1.string(),
|
|
7105
7145
|
state: z$1.literal("input-available"),
|
|
7146
|
+
providerExecuted: z$1.boolean().optional(),
|
|
7106
7147
|
input: z$1.unknown(),
|
|
7107
7148
|
output: z$1.never().optional(),
|
|
7108
7149
|
errorText: z$1.never().optional(),
|
|
@@ -7112,6 +7153,7 @@ var toolUIPartSchemas = [
|
|
|
7112
7153
|
type: z$1.string().startsWith("tool-"),
|
|
7113
7154
|
toolCallId: z$1.string(),
|
|
7114
7155
|
state: z$1.literal("output-available"),
|
|
7156
|
+
providerExecuted: z$1.boolean().optional(),
|
|
7115
7157
|
input: z$1.unknown(),
|
|
7116
7158
|
output: z$1.unknown(),
|
|
7117
7159
|
errorText: z$1.never().optional(),
|
|
@@ -7122,6 +7164,7 @@ var toolUIPartSchemas = [
|
|
|
7122
7164
|
type: z$1.string().startsWith("tool-"),
|
|
7123
7165
|
toolCallId: z$1.string(),
|
|
7124
7166
|
state: z$1.literal("output-error"),
|
|
7167
|
+
providerExecuted: z$1.boolean().optional(),
|
|
7125
7168
|
input: z$1.unknown(),
|
|
7126
7169
|
output: z$1.never().optional(),
|
|
7127
7170
|
errorText: z$1.string(),
|
|
@@ -7798,50 +7841,50 @@ function isValidWithSchema(schema, value) {
|
|
|
7798
7841
|
return schema.safeParse(value).success;
|
|
7799
7842
|
}
|
|
7800
7843
|
var NotHandler = class {
|
|
7801
|
-
apply(
|
|
7802
|
-
if (!schema.not) return
|
|
7844
|
+
apply(zodSchema4, schema) {
|
|
7845
|
+
if (!schema.not) return zodSchema4;
|
|
7803
7846
|
const notSchema = convertJsonSchemaToZod(schema.not);
|
|
7804
|
-
return
|
|
7847
|
+
return zodSchema4.refine(
|
|
7805
7848
|
(value) => !isValidWithSchema(notSchema, value),
|
|
7806
7849
|
{ message: "Value must not match the 'not' schema" }
|
|
7807
7850
|
);
|
|
7808
7851
|
}
|
|
7809
7852
|
};
|
|
7810
7853
|
var UniqueItemsHandler = class {
|
|
7811
|
-
apply(
|
|
7854
|
+
apply(zodSchema4, schema) {
|
|
7812
7855
|
const arraySchema = schema;
|
|
7813
|
-
if (arraySchema.uniqueItems !== true) return
|
|
7814
|
-
return
|
|
7856
|
+
if (arraySchema.uniqueItems !== true) return zodSchema4;
|
|
7857
|
+
return zodSchema4.refine(createUniqueItemsValidator(), {
|
|
7815
7858
|
message: "Array items must be unique"
|
|
7816
7859
|
});
|
|
7817
7860
|
}
|
|
7818
7861
|
};
|
|
7819
7862
|
var AllOfHandler = class {
|
|
7820
|
-
apply(
|
|
7821
|
-
if (!schema.allOf || schema.allOf.length === 0) return
|
|
7863
|
+
apply(zodSchema4, schema) {
|
|
7864
|
+
if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
|
|
7822
7865
|
const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
|
|
7823
7866
|
return allOfSchemas.reduce(
|
|
7824
7867
|
(acc, s) => z$1.intersection(acc, s),
|
|
7825
|
-
|
|
7868
|
+
zodSchema4
|
|
7826
7869
|
);
|
|
7827
7870
|
}
|
|
7828
7871
|
};
|
|
7829
7872
|
var AnyOfHandler = class {
|
|
7830
|
-
apply(
|
|
7831
|
-
if (!schema.anyOf || schema.anyOf.length === 0) return
|
|
7873
|
+
apply(zodSchema4, schema) {
|
|
7874
|
+
if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
|
|
7832
7875
|
const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z$1.union([
|
|
7833
7876
|
convertJsonSchemaToZod(schema.anyOf[0]),
|
|
7834
7877
|
convertJsonSchemaToZod(schema.anyOf[1]),
|
|
7835
7878
|
...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
|
|
7836
7879
|
]);
|
|
7837
|
-
return z$1.intersection(
|
|
7880
|
+
return z$1.intersection(zodSchema4, anyOfSchema);
|
|
7838
7881
|
}
|
|
7839
7882
|
};
|
|
7840
7883
|
var OneOfHandler = class {
|
|
7841
|
-
apply(
|
|
7842
|
-
if (!schema.oneOf || schema.oneOf.length === 0) return
|
|
7884
|
+
apply(zodSchema4, schema) {
|
|
7885
|
+
if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
|
|
7843
7886
|
const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
|
|
7844
|
-
return
|
|
7887
|
+
return zodSchema4.refine(
|
|
7845
7888
|
(value) => {
|
|
7846
7889
|
let validCount = 0;
|
|
7847
7890
|
for (const oneOfSchema of oneOfSchemas) {
|
|
@@ -7858,12 +7901,12 @@ var OneOfHandler = class {
|
|
|
7858
7901
|
}
|
|
7859
7902
|
};
|
|
7860
7903
|
var PrefixItemsHandler = class {
|
|
7861
|
-
apply(
|
|
7904
|
+
apply(zodSchema4, schema) {
|
|
7862
7905
|
const arraySchema = schema;
|
|
7863
7906
|
if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
|
|
7864
7907
|
const prefixItems = arraySchema.prefixItems;
|
|
7865
7908
|
const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
|
|
7866
|
-
return
|
|
7909
|
+
return zodSchema4.refine(
|
|
7867
7910
|
(value) => {
|
|
7868
7911
|
if (!Array.isArray(value)) return true;
|
|
7869
7912
|
for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
|
|
@@ -7888,16 +7931,16 @@ var PrefixItemsHandler = class {
|
|
|
7888
7931
|
{ message: "Array does not match prefixItems schema" }
|
|
7889
7932
|
);
|
|
7890
7933
|
}
|
|
7891
|
-
return
|
|
7934
|
+
return zodSchema4;
|
|
7892
7935
|
}
|
|
7893
7936
|
};
|
|
7894
7937
|
var ObjectPropertiesHandler = class {
|
|
7895
|
-
apply(
|
|
7938
|
+
apply(zodSchema4, schema) {
|
|
7896
7939
|
const objectSchema = schema;
|
|
7897
7940
|
if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
|
|
7898
|
-
return
|
|
7941
|
+
return zodSchema4;
|
|
7899
7942
|
}
|
|
7900
|
-
if (
|
|
7943
|
+
if (zodSchema4 instanceof z$1.ZodObject || zodSchema4 instanceof z$1.ZodRecord) {
|
|
7901
7944
|
const shape = {};
|
|
7902
7945
|
if (objectSchema.properties) {
|
|
7903
7946
|
for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
|
|
@@ -7924,7 +7967,7 @@ var ObjectPropertiesHandler = class {
|
|
|
7924
7967
|
return z$1.object(shape).passthrough();
|
|
7925
7968
|
}
|
|
7926
7969
|
}
|
|
7927
|
-
return
|
|
7970
|
+
return zodSchema4.refine(
|
|
7928
7971
|
(value) => {
|
|
7929
7972
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7930
7973
|
return true;
|
|
@@ -7966,13 +8009,13 @@ var ObjectPropertiesHandler = class {
|
|
|
7966
8009
|
}
|
|
7967
8010
|
};
|
|
7968
8011
|
var EnumComplexHandler = class {
|
|
7969
|
-
apply(
|
|
7970
|
-
if (!schema.enum || schema.enum.length === 0) return
|
|
8012
|
+
apply(zodSchema4, schema) {
|
|
8013
|
+
if (!schema.enum || schema.enum.length === 0) return zodSchema4;
|
|
7971
8014
|
const complexValues = schema.enum.filter(
|
|
7972
8015
|
(v) => Array.isArray(v) || typeof v === "object" && v !== null
|
|
7973
8016
|
);
|
|
7974
|
-
if (complexValues.length === 0) return
|
|
7975
|
-
return
|
|
8017
|
+
if (complexValues.length === 0) return zodSchema4;
|
|
8018
|
+
return zodSchema4.refine(
|
|
7976
8019
|
(value) => {
|
|
7977
8020
|
if (typeof value !== "object" || value === null) return true;
|
|
7978
8021
|
return complexValues.some(
|
|
@@ -7984,32 +8027,32 @@ var EnumComplexHandler = class {
|
|
|
7984
8027
|
}
|
|
7985
8028
|
};
|
|
7986
8029
|
var ConstComplexHandler = class {
|
|
7987
|
-
apply(
|
|
7988
|
-
if (schema.const === void 0) return
|
|
8030
|
+
apply(zodSchema4, schema) {
|
|
8031
|
+
if (schema.const === void 0) return zodSchema4;
|
|
7989
8032
|
const constValue = schema.const;
|
|
7990
8033
|
if (typeof constValue !== "object" || constValue === null) {
|
|
7991
|
-
return
|
|
8034
|
+
return zodSchema4;
|
|
7992
8035
|
}
|
|
7993
|
-
return
|
|
8036
|
+
return zodSchema4.refine(
|
|
7994
8037
|
(value) => deepEqual(value, constValue),
|
|
7995
8038
|
{ message: "Value must equal the const value" }
|
|
7996
8039
|
);
|
|
7997
8040
|
}
|
|
7998
8041
|
};
|
|
7999
8042
|
var MetadataHandler = class {
|
|
8000
|
-
apply(
|
|
8043
|
+
apply(zodSchema4, schema) {
|
|
8001
8044
|
if (schema.description) {
|
|
8002
|
-
|
|
8045
|
+
zodSchema4 = zodSchema4.describe(schema.description);
|
|
8003
8046
|
}
|
|
8004
|
-
return
|
|
8047
|
+
return zodSchema4;
|
|
8005
8048
|
}
|
|
8006
8049
|
};
|
|
8007
8050
|
var ProtoRequiredHandler = class {
|
|
8008
|
-
apply(
|
|
8009
|
-
var
|
|
8051
|
+
apply(zodSchema4, schema) {
|
|
8052
|
+
var _a20;
|
|
8010
8053
|
const objectSchema = schema;
|
|
8011
|
-
if (!((
|
|
8012
|
-
return
|
|
8054
|
+
if (!((_a20 = objectSchema.required) == null ? void 0 : _a20.includes("__proto__")) || schema.type !== void 0) {
|
|
8055
|
+
return zodSchema4;
|
|
8013
8056
|
}
|
|
8014
8057
|
return z$1.any().refine(
|
|
8015
8058
|
(value) => this.validateRequired(value, objectSchema.required),
|
|
@@ -8026,14 +8069,14 @@ var ProtoRequiredHandler = class {
|
|
|
8026
8069
|
}
|
|
8027
8070
|
};
|
|
8028
8071
|
var ContainsHandler = class {
|
|
8029
|
-
apply(
|
|
8030
|
-
var
|
|
8072
|
+
apply(zodSchema4, schema) {
|
|
8073
|
+
var _a20;
|
|
8031
8074
|
const arraySchema = schema;
|
|
8032
|
-
if (arraySchema.contains === void 0) return
|
|
8075
|
+
if (arraySchema.contains === void 0) return zodSchema4;
|
|
8033
8076
|
const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
|
|
8034
|
-
const minContains = (
|
|
8077
|
+
const minContains = (_a20 = arraySchema.minContains) != null ? _a20 : 1;
|
|
8035
8078
|
const maxContains = arraySchema.maxContains;
|
|
8036
|
-
return
|
|
8079
|
+
return zodSchema4.refine(
|
|
8037
8080
|
(value) => {
|
|
8038
8081
|
if (!Array.isArray(value)) {
|
|
8039
8082
|
return true;
|
|
@@ -8142,32 +8185,32 @@ function convertJsonSchemaToZod(schema) {
|
|
|
8142
8185
|
allowedSchemas.push(objectSchema);
|
|
8143
8186
|
}
|
|
8144
8187
|
}
|
|
8145
|
-
let
|
|
8188
|
+
let zodSchema4;
|
|
8146
8189
|
if (allowedSchemas.length === 0) {
|
|
8147
|
-
|
|
8190
|
+
zodSchema4 = z$1.never();
|
|
8148
8191
|
} else if (allowedSchemas.length === 1) {
|
|
8149
|
-
|
|
8192
|
+
zodSchema4 = allowedSchemas[0];
|
|
8150
8193
|
} else {
|
|
8151
8194
|
const hasConstraints = Object.keys(schema).some(
|
|
8152
8195
|
(key) => key !== "$schema" && key !== "title" && key !== "description"
|
|
8153
8196
|
);
|
|
8154
8197
|
if (!hasConstraints) {
|
|
8155
|
-
|
|
8198
|
+
zodSchema4 = z$1.any();
|
|
8156
8199
|
} else {
|
|
8157
|
-
|
|
8200
|
+
zodSchema4 = z$1.union(allowedSchemas);
|
|
8158
8201
|
}
|
|
8159
8202
|
}
|
|
8160
8203
|
for (const handler of refinementHandlers) {
|
|
8161
|
-
|
|
8204
|
+
zodSchema4 = handler.apply(zodSchema4, schema);
|
|
8162
8205
|
}
|
|
8163
|
-
return
|
|
8206
|
+
return zodSchema4;
|
|
8164
8207
|
}
|
|
8165
8208
|
function convertJsonSchemaToZod2(schema) {
|
|
8166
|
-
function addMetadata(
|
|
8167
|
-
if (
|
|
8168
|
-
|
|
8209
|
+
function addMetadata(zodSchema4, jsonSchema4) {
|
|
8210
|
+
if (jsonSchema4.description) {
|
|
8211
|
+
zodSchema4 = zodSchema4.describe(jsonSchema4.description);
|
|
8169
8212
|
}
|
|
8170
|
-
return
|
|
8213
|
+
return zodSchema4;
|
|
8171
8214
|
}
|
|
8172
8215
|
if (schema.const !== void 0) {
|
|
8173
8216
|
if (typeof schema.const === "string") {
|
|
@@ -8273,13 +8316,13 @@ function convertJsonSchemaToZod2(schema) {
|
|
|
8273
8316
|
shape[key] = shape[key].optional();
|
|
8274
8317
|
}
|
|
8275
8318
|
}
|
|
8276
|
-
let
|
|
8319
|
+
let zodSchema4;
|
|
8277
8320
|
if (schema.additionalProperties !== false) {
|
|
8278
|
-
|
|
8321
|
+
zodSchema4 = z.object(shape).passthrough();
|
|
8279
8322
|
} else {
|
|
8280
|
-
|
|
8323
|
+
zodSchema4 = z.object(shape);
|
|
8281
8324
|
}
|
|
8282
|
-
return addMetadata(
|
|
8325
|
+
return addMetadata(zodSchema4, schema);
|
|
8283
8326
|
}
|
|
8284
8327
|
return addMetadata(z.object({}), schema);
|
|
8285
8328
|
case "array": {
|
|
@@ -8819,11 +8862,11 @@ ${workingMemory}`;
|
|
|
8819
8862
|
release();
|
|
8820
8863
|
}
|
|
8821
8864
|
}
|
|
8822
|
-
chunkText(
|
|
8865
|
+
chunkText(text4, tokenSize = 4096) {
|
|
8823
8866
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
8824
8867
|
const chunks = [];
|
|
8825
8868
|
let currentChunk = "";
|
|
8826
|
-
const words =
|
|
8869
|
+
const words = text4.split(/\s+/);
|
|
8827
8870
|
for (const word of words) {
|
|
8828
8871
|
const wordWithSpace = currentChunk ? " " + word : word;
|
|
8829
8872
|
if (currentChunk.length + wordWithSpace.length > charSize) {
|
|
@@ -8985,10 +9028,10 @@ ${workingMemory}`;
|
|
|
8985
9028
|
}
|
|
8986
9029
|
return newMessage;
|
|
8987
9030
|
}
|
|
8988
|
-
parseWorkingMemory(
|
|
9031
|
+
parseWorkingMemory(text4) {
|
|
8989
9032
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
8990
9033
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
8991
|
-
const matches =
|
|
9034
|
+
const matches = text4.match(workingMemoryRegex);
|
|
8992
9035
|
const match = matches?.[0];
|
|
8993
9036
|
if (match) {
|
|
8994
9037
|
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
@@ -9288,12 +9331,12 @@ var _Tiktoken = class {
|
|
|
9288
9331
|
this.textMap.set(rank, bytes);
|
|
9289
9332
|
}
|
|
9290
9333
|
this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
|
|
9291
|
-
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [
|
|
9292
|
-
memo[rank] = this.textEncoder.encode(
|
|
9334
|
+
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
|
|
9335
|
+
memo[rank] = this.textEncoder.encode(text4);
|
|
9293
9336
|
return memo;
|
|
9294
9337
|
}, {});
|
|
9295
9338
|
}
|
|
9296
|
-
encode(
|
|
9339
|
+
encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
|
|
9297
9340
|
const regexes = new RegExp(this.patStr, "ug");
|
|
9298
9341
|
const specialRegex = _Tiktoken.specialTokenRegex(
|
|
9299
9342
|
Object.keys(this.specialTokens)
|
|
@@ -9311,7 +9354,7 @@ var _Tiktoken = class {
|
|
|
9311
9354
|
const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
|
|
9312
9355
|
...disallowedSpecialSet
|
|
9313
9356
|
]);
|
|
9314
|
-
const specialMatch =
|
|
9357
|
+
const specialMatch = text4.match(disallowedSpecialRegex);
|
|
9315
9358
|
if (specialMatch != null) {
|
|
9316
9359
|
throw new Error(
|
|
9317
9360
|
`The text contains a special token that is not allowed: ${specialMatch[0]}`
|
|
@@ -9324,13 +9367,13 @@ var _Tiktoken = class {
|
|
|
9324
9367
|
let startFind = start;
|
|
9325
9368
|
while (true) {
|
|
9326
9369
|
specialRegex.lastIndex = startFind;
|
|
9327
|
-
nextSpecial = specialRegex.exec(
|
|
9370
|
+
nextSpecial = specialRegex.exec(text4);
|
|
9328
9371
|
if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
|
|
9329
9372
|
break;
|
|
9330
9373
|
startFind = nextSpecial.index + 1;
|
|
9331
9374
|
}
|
|
9332
|
-
const end = nextSpecial?.index ??
|
|
9333
|
-
for (const match of
|
|
9375
|
+
const end = nextSpecial?.index ?? text4.length;
|
|
9376
|
+
for (const match of text4.substring(start, end).matchAll(regexes)) {
|
|
9334
9377
|
const piece = this.textEncoder.encode(match[0]);
|
|
9335
9378
|
const token2 = this.rankMap.get(piece.join(","));
|
|
9336
9379
|
if (token2 != null) {
|
|
@@ -9478,6 +9521,2285 @@ var TokenLimiter = class extends MemoryProcessor {
|
|
|
9478
9521
|
|
|
9479
9522
|
// ../agent-builder/dist/index.js
|
|
9480
9523
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
9524
|
+
var createIdGenerator3 = ({
|
|
9525
|
+
prefix,
|
|
9526
|
+
size = 16,
|
|
9527
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
9528
|
+
separator = "-"
|
|
9529
|
+
} = {}) => {
|
|
9530
|
+
const generator = () => {
|
|
9531
|
+
const alphabetLength = alphabet.length;
|
|
9532
|
+
const chars = new Array(size);
|
|
9533
|
+
for (let i = 0; i < size; i++) {
|
|
9534
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
9535
|
+
}
|
|
9536
|
+
return chars.join("");
|
|
9537
|
+
};
|
|
9538
|
+
if (prefix == null) {
|
|
9539
|
+
return generator;
|
|
9540
|
+
}
|
|
9541
|
+
if (alphabet.includes(separator)) {
|
|
9542
|
+
throw new InvalidArgumentError({
|
|
9543
|
+
argument: "separator",
|
|
9544
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
9545
|
+
});
|
|
9546
|
+
}
|
|
9547
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
9548
|
+
};
|
|
9549
|
+
createIdGenerator3();
|
|
9550
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
9551
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
9552
|
+
function _parse2(text4) {
|
|
9553
|
+
const obj = JSON.parse(text4);
|
|
9554
|
+
if (obj === null || typeof obj !== "object") {
|
|
9555
|
+
return obj;
|
|
9556
|
+
}
|
|
9557
|
+
if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
|
|
9558
|
+
return obj;
|
|
9559
|
+
}
|
|
9560
|
+
return filter2(obj);
|
|
9561
|
+
}
|
|
9562
|
+
function filter2(obj) {
|
|
9563
|
+
let next = [obj];
|
|
9564
|
+
while (next.length) {
|
|
9565
|
+
const nodes = next;
|
|
9566
|
+
next = [];
|
|
9567
|
+
for (const node of nodes) {
|
|
9568
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9569
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9570
|
+
}
|
|
9571
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9572
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9573
|
+
}
|
|
9574
|
+
for (const key in node) {
|
|
9575
|
+
const value = node[key];
|
|
9576
|
+
if (value && typeof value === "object") {
|
|
9577
|
+
next.push(value);
|
|
9578
|
+
}
|
|
9579
|
+
}
|
|
9580
|
+
}
|
|
9581
|
+
}
|
|
9582
|
+
return obj;
|
|
9583
|
+
}
|
|
9584
|
+
function secureJsonParse2(text4) {
|
|
9585
|
+
const { stackTraceLimit } = Error;
|
|
9586
|
+
Error.stackTraceLimit = 0;
|
|
9587
|
+
try {
|
|
9588
|
+
return _parse2(text4);
|
|
9589
|
+
} finally {
|
|
9590
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
9591
|
+
}
|
|
9592
|
+
}
|
|
9593
|
+
var validatorSymbol3 = Symbol.for("vercel.ai.validator");
|
|
9594
|
+
function validator2(validate) {
|
|
9595
|
+
return { [validatorSymbol3]: true, validate };
|
|
9596
|
+
}
|
|
9597
|
+
function isValidator2(value) {
|
|
9598
|
+
return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
|
|
9599
|
+
}
|
|
9600
|
+
function asValidator2(value) {
|
|
9601
|
+
return isValidator2(value) ? value : standardSchemaValidator2(value);
|
|
9602
|
+
}
|
|
9603
|
+
function standardSchemaValidator2(standardSchema) {
|
|
9604
|
+
return validator2(async (value) => {
|
|
9605
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
9606
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
9607
|
+
success: false,
|
|
9608
|
+
error: new TypeValidationError({
|
|
9609
|
+
value,
|
|
9610
|
+
cause: result.issues
|
|
9611
|
+
})
|
|
9612
|
+
};
|
|
9613
|
+
});
|
|
9614
|
+
}
|
|
9615
|
+
async function safeValidateTypes3({
|
|
9616
|
+
value,
|
|
9617
|
+
schema
|
|
9618
|
+
}) {
|
|
9619
|
+
const validator22 = asValidator2(schema);
|
|
9620
|
+
try {
|
|
9621
|
+
if (validator22.validate == null) {
|
|
9622
|
+
return { success: true, value, rawValue: value };
|
|
9623
|
+
}
|
|
9624
|
+
const result = await validator22.validate(value);
|
|
9625
|
+
if (result.success) {
|
|
9626
|
+
return { success: true, value: result.value, rawValue: value };
|
|
9627
|
+
}
|
|
9628
|
+
return {
|
|
9629
|
+
success: false,
|
|
9630
|
+
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
9631
|
+
rawValue: value
|
|
9632
|
+
};
|
|
9633
|
+
} catch (error) {
|
|
9634
|
+
return {
|
|
9635
|
+
success: false,
|
|
9636
|
+
error: TypeValidationError.wrap({ value, cause: error }),
|
|
9637
|
+
rawValue: value
|
|
9638
|
+
};
|
|
9639
|
+
}
|
|
9640
|
+
}
|
|
9641
|
+
async function safeParseJSON3({
|
|
9642
|
+
text: text4,
|
|
9643
|
+
schema
|
|
9644
|
+
}) {
|
|
9645
|
+
try {
|
|
9646
|
+
const value = secureJsonParse2(text4);
|
|
9647
|
+
if (schema == null) {
|
|
9648
|
+
return { success: true, value, rawValue: value };
|
|
9649
|
+
}
|
|
9650
|
+
return await safeValidateTypes3({ value, schema });
|
|
9651
|
+
} catch (error) {
|
|
9652
|
+
return {
|
|
9653
|
+
success: false,
|
|
9654
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
|
|
9655
|
+
rawValue: void 0
|
|
9656
|
+
};
|
|
9657
|
+
}
|
|
9658
|
+
}
|
|
9659
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
9660
|
+
let i = 0;
|
|
9661
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
9662
|
+
if (pathA[i] !== pathB[i])
|
|
9663
|
+
break;
|
|
9664
|
+
}
|
|
9665
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
9666
|
+
};
|
|
9667
|
+
var ignoreOverride2 = Symbol(
|
|
9668
|
+
"Let zodToJsonSchema decide on which parser to use"
|
|
9669
|
+
);
|
|
9670
|
+
var defaultOptions2 = {
|
|
9671
|
+
name: void 0,
|
|
9672
|
+
$refStrategy: "root",
|
|
9673
|
+
basePath: ["#"],
|
|
9674
|
+
effectStrategy: "input",
|
|
9675
|
+
pipeStrategy: "all",
|
|
9676
|
+
dateStrategy: "format:date-time",
|
|
9677
|
+
mapStrategy: "entries",
|
|
9678
|
+
removeAdditionalStrategy: "passthrough",
|
|
9679
|
+
allowedAdditionalProperties: true,
|
|
9680
|
+
rejectedAdditionalProperties: false,
|
|
9681
|
+
definitionPath: "definitions",
|
|
9682
|
+
strictUnions: false,
|
|
9683
|
+
definitions: {},
|
|
9684
|
+
errorMessages: false,
|
|
9685
|
+
patternStrategy: "escape",
|
|
9686
|
+
applyRegexFlags: false,
|
|
9687
|
+
emailStrategy: "format:email",
|
|
9688
|
+
base64Strategy: "contentEncoding:base64",
|
|
9689
|
+
nameStrategy: "ref"
|
|
9690
|
+
};
|
|
9691
|
+
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
9692
|
+
...defaultOptions2,
|
|
9693
|
+
name: options
|
|
9694
|
+
} : {
|
|
9695
|
+
...defaultOptions2,
|
|
9696
|
+
...options
|
|
9697
|
+
};
|
|
9698
|
+
function parseAnyDef2() {
|
|
9699
|
+
return {};
|
|
9700
|
+
}
|
|
9701
|
+
function parseArrayDef2(def, refs) {
|
|
9702
|
+
var _a20, _b8, _c;
|
|
9703
|
+
const res = {
|
|
9704
|
+
type: "array"
|
|
9705
|
+
};
|
|
9706
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
|
|
9707
|
+
res.items = parseDef2(def.type._def, {
|
|
9708
|
+
...refs,
|
|
9709
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9710
|
+
});
|
|
9711
|
+
}
|
|
9712
|
+
if (def.minLength) {
|
|
9713
|
+
res.minItems = def.minLength.value;
|
|
9714
|
+
}
|
|
9715
|
+
if (def.maxLength) {
|
|
9716
|
+
res.maxItems = def.maxLength.value;
|
|
9717
|
+
}
|
|
9718
|
+
if (def.exactLength) {
|
|
9719
|
+
res.minItems = def.exactLength.value;
|
|
9720
|
+
res.maxItems = def.exactLength.value;
|
|
9721
|
+
}
|
|
9722
|
+
return res;
|
|
9723
|
+
}
|
|
9724
|
+
function parseBigintDef2(def) {
|
|
9725
|
+
const res = {
|
|
9726
|
+
type: "integer",
|
|
9727
|
+
format: "int64"
|
|
9728
|
+
};
|
|
9729
|
+
if (!def.checks)
|
|
9730
|
+
return res;
|
|
9731
|
+
for (const check of def.checks) {
|
|
9732
|
+
switch (check.kind) {
|
|
9733
|
+
case "min":
|
|
9734
|
+
if (check.inclusive) {
|
|
9735
|
+
res.minimum = check.value;
|
|
9736
|
+
} else {
|
|
9737
|
+
res.exclusiveMinimum = check.value;
|
|
9738
|
+
}
|
|
9739
|
+
break;
|
|
9740
|
+
case "max":
|
|
9741
|
+
if (check.inclusive) {
|
|
9742
|
+
res.maximum = check.value;
|
|
9743
|
+
} else {
|
|
9744
|
+
res.exclusiveMaximum = check.value;
|
|
9745
|
+
}
|
|
9746
|
+
break;
|
|
9747
|
+
case "multipleOf":
|
|
9748
|
+
res.multipleOf = check.value;
|
|
9749
|
+
break;
|
|
9750
|
+
}
|
|
9751
|
+
}
|
|
9752
|
+
return res;
|
|
9753
|
+
}
|
|
9754
|
+
function parseBooleanDef2() {
|
|
9755
|
+
return { type: "boolean" };
|
|
9756
|
+
}
|
|
9757
|
+
function parseBrandedDef2(_def, refs) {
|
|
9758
|
+
return parseDef2(_def.type._def, refs);
|
|
9759
|
+
}
|
|
9760
|
+
var parseCatchDef2 = (def, refs) => {
|
|
9761
|
+
return parseDef2(def.innerType._def, refs);
|
|
9762
|
+
};
|
|
9763
|
+
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
9764
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
9765
|
+
if (Array.isArray(strategy)) {
|
|
9766
|
+
return {
|
|
9767
|
+
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
9768
|
+
};
|
|
9769
|
+
}
|
|
9770
|
+
switch (strategy) {
|
|
9771
|
+
case "string":
|
|
9772
|
+
case "format:date-time":
|
|
9773
|
+
return {
|
|
9774
|
+
type: "string",
|
|
9775
|
+
format: "date-time"
|
|
9776
|
+
};
|
|
9777
|
+
case "format:date":
|
|
9778
|
+
return {
|
|
9779
|
+
type: "string",
|
|
9780
|
+
format: "date"
|
|
9781
|
+
};
|
|
9782
|
+
case "integer":
|
|
9783
|
+
return integerDateParser2(def);
|
|
9784
|
+
}
|
|
9785
|
+
}
|
|
9786
|
+
var integerDateParser2 = (def) => {
|
|
9787
|
+
const res = {
|
|
9788
|
+
type: "integer",
|
|
9789
|
+
format: "unix-time"
|
|
9790
|
+
};
|
|
9791
|
+
for (const check of def.checks) {
|
|
9792
|
+
switch (check.kind) {
|
|
9793
|
+
case "min":
|
|
9794
|
+
res.minimum = check.value;
|
|
9795
|
+
break;
|
|
9796
|
+
case "max":
|
|
9797
|
+
res.maximum = check.value;
|
|
9798
|
+
break;
|
|
9799
|
+
}
|
|
9800
|
+
}
|
|
9801
|
+
return res;
|
|
9802
|
+
};
|
|
9803
|
+
function parseDefaultDef2(_def, refs) {
|
|
9804
|
+
return {
|
|
9805
|
+
...parseDef2(_def.innerType._def, refs),
|
|
9806
|
+
default: _def.defaultValue()
|
|
9807
|
+
};
|
|
9808
|
+
}
|
|
9809
|
+
function parseEffectsDef2(_def, refs) {
|
|
9810
|
+
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
|
|
9811
|
+
}
|
|
9812
|
+
function parseEnumDef2(def) {
|
|
9813
|
+
return {
|
|
9814
|
+
type: "string",
|
|
9815
|
+
enum: Array.from(def.values)
|
|
9816
|
+
};
|
|
9817
|
+
}
|
|
9818
|
+
var isJsonSchema7AllOfType2 = (type) => {
|
|
9819
|
+
if ("type" in type && type.type === "string")
|
|
9820
|
+
return false;
|
|
9821
|
+
return "allOf" in type;
|
|
9822
|
+
};
|
|
9823
|
+
function parseIntersectionDef2(def, refs) {
|
|
9824
|
+
const allOf = [
|
|
9825
|
+
parseDef2(def.left._def, {
|
|
9826
|
+
...refs,
|
|
9827
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9828
|
+
}),
|
|
9829
|
+
parseDef2(def.right._def, {
|
|
9830
|
+
...refs,
|
|
9831
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
9832
|
+
})
|
|
9833
|
+
].filter((x) => !!x);
|
|
9834
|
+
const mergedAllOf = [];
|
|
9835
|
+
allOf.forEach((schema) => {
|
|
9836
|
+
if (isJsonSchema7AllOfType2(schema)) {
|
|
9837
|
+
mergedAllOf.push(...schema.allOf);
|
|
9838
|
+
} else {
|
|
9839
|
+
let nestedSchema = schema;
|
|
9840
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
9841
|
+
const { additionalProperties, ...rest } = schema;
|
|
9842
|
+
nestedSchema = rest;
|
|
9843
|
+
}
|
|
9844
|
+
mergedAllOf.push(nestedSchema);
|
|
9845
|
+
}
|
|
9846
|
+
});
|
|
9847
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
|
|
9848
|
+
}
|
|
9849
|
+
function parseLiteralDef2(def) {
|
|
9850
|
+
const parsedType = typeof def.value;
|
|
9851
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
9852
|
+
return {
|
|
9853
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
9854
|
+
};
|
|
9855
|
+
}
|
|
9856
|
+
return {
|
|
9857
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9858
|
+
const: def.value
|
|
9859
|
+
};
|
|
9860
|
+
}
|
|
9861
|
+
var emojiRegex2 = void 0;
|
|
9862
|
+
var zodPatterns2 = {
|
|
9863
|
+
/**
|
|
9864
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
9865
|
+
*/
|
|
9866
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
9867
|
+
cuid2: /^[0-9a-z]+$/,
|
|
9868
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
9869
|
+
/**
|
|
9870
|
+
* `a-z` was added to replicate /i flag
|
|
9871
|
+
*/
|
|
9872
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
9873
|
+
/**
|
|
9874
|
+
* Constructed a valid Unicode RegExp
|
|
9875
|
+
*
|
|
9876
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
9877
|
+
* in all envs (e.g. React Native).
|
|
9878
|
+
*
|
|
9879
|
+
* See:
|
|
9880
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
9881
|
+
* Fix in Zod:
|
|
9882
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
9883
|
+
*/
|
|
9884
|
+
emoji: () => {
|
|
9885
|
+
if (emojiRegex2 === void 0) {
|
|
9886
|
+
emojiRegex2 = RegExp(
|
|
9887
|
+
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
9888
|
+
"u"
|
|
9889
|
+
);
|
|
9890
|
+
}
|
|
9891
|
+
return emojiRegex2;
|
|
9892
|
+
},
|
|
9893
|
+
/**
|
|
9894
|
+
* Unused
|
|
9895
|
+
*/
|
|
9896
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
9897
|
+
/**
|
|
9898
|
+
* Unused
|
|
9899
|
+
*/
|
|
9900
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
9901
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
9902
|
+
/**
|
|
9903
|
+
* Unused
|
|
9904
|
+
*/
|
|
9905
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
9906
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
9907
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
9908
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
9909
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
9910
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
9911
|
+
};
|
|
9912
|
+
function parseStringDef2(def, refs) {
|
|
9913
|
+
const res = {
|
|
9914
|
+
type: "string"
|
|
9915
|
+
};
|
|
9916
|
+
if (def.checks) {
|
|
9917
|
+
for (const check of def.checks) {
|
|
9918
|
+
switch (check.kind) {
|
|
9919
|
+
case "min":
|
|
9920
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
9921
|
+
break;
|
|
9922
|
+
case "max":
|
|
9923
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
9924
|
+
break;
|
|
9925
|
+
case "email":
|
|
9926
|
+
switch (refs.emailStrategy) {
|
|
9927
|
+
case "format:email":
|
|
9928
|
+
addFormat2(res, "email", check.message, refs);
|
|
9929
|
+
break;
|
|
9930
|
+
case "format:idn-email":
|
|
9931
|
+
addFormat2(res, "idn-email", check.message, refs);
|
|
9932
|
+
break;
|
|
9933
|
+
case "pattern:zod":
|
|
9934
|
+
addPattern2(res, zodPatterns2.email, check.message, refs);
|
|
9935
|
+
break;
|
|
9936
|
+
}
|
|
9937
|
+
break;
|
|
9938
|
+
case "url":
|
|
9939
|
+
addFormat2(res, "uri", check.message, refs);
|
|
9940
|
+
break;
|
|
9941
|
+
case "uuid":
|
|
9942
|
+
addFormat2(res, "uuid", check.message, refs);
|
|
9943
|
+
break;
|
|
9944
|
+
case "regex":
|
|
9945
|
+
addPattern2(res, check.regex, check.message, refs);
|
|
9946
|
+
break;
|
|
9947
|
+
case "cuid":
|
|
9948
|
+
addPattern2(res, zodPatterns2.cuid, check.message, refs);
|
|
9949
|
+
break;
|
|
9950
|
+
case "cuid2":
|
|
9951
|
+
addPattern2(res, zodPatterns2.cuid2, check.message, refs);
|
|
9952
|
+
break;
|
|
9953
|
+
case "startsWith":
|
|
9954
|
+
addPattern2(
|
|
9955
|
+
res,
|
|
9956
|
+
RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`),
|
|
9957
|
+
check.message,
|
|
9958
|
+
refs
|
|
9959
|
+
);
|
|
9960
|
+
break;
|
|
9961
|
+
case "endsWith":
|
|
9962
|
+
addPattern2(
|
|
9963
|
+
res,
|
|
9964
|
+
RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`),
|
|
9965
|
+
check.message,
|
|
9966
|
+
refs
|
|
9967
|
+
);
|
|
9968
|
+
break;
|
|
9969
|
+
case "datetime":
|
|
9970
|
+
addFormat2(res, "date-time", check.message, refs);
|
|
9971
|
+
break;
|
|
9972
|
+
case "date":
|
|
9973
|
+
addFormat2(res, "date", check.message, refs);
|
|
9974
|
+
break;
|
|
9975
|
+
case "time":
|
|
9976
|
+
addFormat2(res, "time", check.message, refs);
|
|
9977
|
+
break;
|
|
9978
|
+
case "duration":
|
|
9979
|
+
addFormat2(res, "duration", check.message, refs);
|
|
9980
|
+
break;
|
|
9981
|
+
case "length":
|
|
9982
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
9983
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
9984
|
+
break;
|
|
9985
|
+
case "includes": {
|
|
9986
|
+
addPattern2(
|
|
9987
|
+
res,
|
|
9988
|
+
RegExp(escapeLiteralCheckValue2(check.value, refs)),
|
|
9989
|
+
check.message,
|
|
9990
|
+
refs
|
|
9991
|
+
);
|
|
9992
|
+
break;
|
|
9993
|
+
}
|
|
9994
|
+
case "ip": {
|
|
9995
|
+
if (check.version !== "v6") {
|
|
9996
|
+
addFormat2(res, "ipv4", check.message, refs);
|
|
9997
|
+
}
|
|
9998
|
+
if (check.version !== "v4") {
|
|
9999
|
+
addFormat2(res, "ipv6", check.message, refs);
|
|
10000
|
+
}
|
|
10001
|
+
break;
|
|
10002
|
+
}
|
|
10003
|
+
case "base64url":
|
|
10004
|
+
addPattern2(res, zodPatterns2.base64url, check.message, refs);
|
|
10005
|
+
break;
|
|
10006
|
+
case "jwt":
|
|
10007
|
+
addPattern2(res, zodPatterns2.jwt, check.message, refs);
|
|
10008
|
+
break;
|
|
10009
|
+
case "cidr": {
|
|
10010
|
+
if (check.version !== "v6") {
|
|
10011
|
+
addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
|
|
10012
|
+
}
|
|
10013
|
+
if (check.version !== "v4") {
|
|
10014
|
+
addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
|
|
10015
|
+
}
|
|
10016
|
+
break;
|
|
10017
|
+
}
|
|
10018
|
+
case "emoji":
|
|
10019
|
+
addPattern2(res, zodPatterns2.emoji(), check.message, refs);
|
|
10020
|
+
break;
|
|
10021
|
+
case "ulid": {
|
|
10022
|
+
addPattern2(res, zodPatterns2.ulid, check.message, refs);
|
|
10023
|
+
break;
|
|
10024
|
+
}
|
|
10025
|
+
case "base64": {
|
|
10026
|
+
switch (refs.base64Strategy) {
|
|
10027
|
+
case "format:binary": {
|
|
10028
|
+
addFormat2(res, "binary", check.message, refs);
|
|
10029
|
+
break;
|
|
10030
|
+
}
|
|
10031
|
+
case "contentEncoding:base64": {
|
|
10032
|
+
res.contentEncoding = "base64";
|
|
10033
|
+
break;
|
|
10034
|
+
}
|
|
10035
|
+
case "pattern:zod": {
|
|
10036
|
+
addPattern2(res, zodPatterns2.base64, check.message, refs);
|
|
10037
|
+
break;
|
|
10038
|
+
}
|
|
10039
|
+
}
|
|
10040
|
+
break;
|
|
10041
|
+
}
|
|
10042
|
+
case "nanoid": {
|
|
10043
|
+
addPattern2(res, zodPatterns2.nanoid, check.message, refs);
|
|
10044
|
+
}
|
|
10045
|
+
}
|
|
10046
|
+
}
|
|
10047
|
+
}
|
|
10048
|
+
return res;
|
|
10049
|
+
}
|
|
10050
|
+
function escapeLiteralCheckValue2(literal, refs) {
|
|
10051
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
|
|
10052
|
+
}
|
|
10053
|
+
var ALPHA_NUMERIC2 = new Set(
|
|
10054
|
+
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
10055
|
+
);
|
|
10056
|
+
function escapeNonAlphaNumeric2(source) {
|
|
10057
|
+
let result = "";
|
|
10058
|
+
for (let i = 0; i < source.length; i++) {
|
|
10059
|
+
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
10060
|
+
result += "\\";
|
|
10061
|
+
}
|
|
10062
|
+
result += source[i];
|
|
10063
|
+
}
|
|
10064
|
+
return result;
|
|
10065
|
+
}
|
|
10066
|
+
function addFormat2(schema, value, message, refs) {
|
|
10067
|
+
var _a20;
|
|
10068
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
10069
|
+
if (!schema.anyOf) {
|
|
10070
|
+
schema.anyOf = [];
|
|
10071
|
+
}
|
|
10072
|
+
if (schema.format) {
|
|
10073
|
+
schema.anyOf.push({
|
|
10074
|
+
format: schema.format
|
|
10075
|
+
});
|
|
10076
|
+
delete schema.format;
|
|
10077
|
+
}
|
|
10078
|
+
schema.anyOf.push({
|
|
10079
|
+
format: value,
|
|
10080
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
10081
|
+
});
|
|
10082
|
+
} else {
|
|
10083
|
+
schema.format = value;
|
|
10084
|
+
}
|
|
10085
|
+
}
|
|
10086
|
+
function addPattern2(schema, regex, message, refs) {
|
|
10087
|
+
var _a20;
|
|
10088
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
10089
|
+
if (!schema.allOf) {
|
|
10090
|
+
schema.allOf = [];
|
|
10091
|
+
}
|
|
10092
|
+
if (schema.pattern) {
|
|
10093
|
+
schema.allOf.push({
|
|
10094
|
+
pattern: schema.pattern
|
|
10095
|
+
});
|
|
10096
|
+
delete schema.pattern;
|
|
10097
|
+
}
|
|
10098
|
+
schema.allOf.push({
|
|
10099
|
+
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
10100
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
10101
|
+
});
|
|
10102
|
+
} else {
|
|
10103
|
+
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
10104
|
+
}
|
|
10105
|
+
}
|
|
10106
|
+
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10107
|
+
var _a20;
|
|
10108
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10109
|
+
return regex.source;
|
|
10110
|
+
}
|
|
10111
|
+
const flags = {
|
|
10112
|
+
i: regex.flags.includes("i"),
|
|
10113
|
+
// Case-insensitive
|
|
10114
|
+
m: regex.flags.includes("m"),
|
|
10115
|
+
// `^` and `$` matches adjacent to newline characters
|
|
10116
|
+
s: regex.flags.includes("s")
|
|
10117
|
+
// `.` matches newlines
|
|
10118
|
+
};
|
|
10119
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
10120
|
+
let pattern = "";
|
|
10121
|
+
let isEscaped = false;
|
|
10122
|
+
let inCharGroup = false;
|
|
10123
|
+
let inCharRange = false;
|
|
10124
|
+
for (let i = 0; i < source.length; i++) {
|
|
10125
|
+
if (isEscaped) {
|
|
10126
|
+
pattern += source[i];
|
|
10127
|
+
isEscaped = false;
|
|
10128
|
+
continue;
|
|
10129
|
+
}
|
|
10130
|
+
if (flags.i) {
|
|
10131
|
+
if (inCharGroup) {
|
|
10132
|
+
if (source[i].match(/[a-z]/)) {
|
|
10133
|
+
if (inCharRange) {
|
|
10134
|
+
pattern += source[i];
|
|
10135
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10136
|
+
inCharRange = false;
|
|
10137
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
10138
|
+
pattern += source[i];
|
|
10139
|
+
inCharRange = true;
|
|
10140
|
+
} else {
|
|
10141
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
10142
|
+
}
|
|
10143
|
+
continue;
|
|
10144
|
+
}
|
|
10145
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
10146
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
10147
|
+
continue;
|
|
10148
|
+
}
|
|
10149
|
+
}
|
|
10150
|
+
if (flags.m) {
|
|
10151
|
+
if (source[i] === "^") {
|
|
10152
|
+
pattern += `(^|(?<=[\r
|
|
10153
|
+
]))`;
|
|
10154
|
+
continue;
|
|
10155
|
+
} else if (source[i] === "$") {
|
|
10156
|
+
pattern += `($|(?=[\r
|
|
10157
|
+
]))`;
|
|
10158
|
+
continue;
|
|
10159
|
+
}
|
|
10160
|
+
}
|
|
10161
|
+
if (flags.s && source[i] === ".") {
|
|
10162
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
10163
|
+
` : `[${source[i]}\r
|
|
10164
|
+
]`;
|
|
10165
|
+
continue;
|
|
10166
|
+
}
|
|
10167
|
+
pattern += source[i];
|
|
10168
|
+
if (source[i] === "\\") {
|
|
10169
|
+
isEscaped = true;
|
|
10170
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
10171
|
+
inCharGroup = false;
|
|
10172
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
10173
|
+
inCharGroup = true;
|
|
10174
|
+
}
|
|
10175
|
+
}
|
|
10176
|
+
return pattern;
|
|
10177
|
+
}
|
|
10178
|
+
function parseRecordDef2(def, refs) {
|
|
10179
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
10180
|
+
const schema = {
|
|
10181
|
+
type: "object",
|
|
10182
|
+
additionalProperties: (_a20 = parseDef2(def.valueType._def, {
|
|
10183
|
+
...refs,
|
|
10184
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10185
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
10186
|
+
};
|
|
10187
|
+
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10188
|
+
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
10189
|
+
return {
|
|
10190
|
+
...schema,
|
|
10191
|
+
propertyNames: keyType
|
|
10192
|
+
};
|
|
10193
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
|
|
10194
|
+
return {
|
|
10195
|
+
...schema,
|
|
10196
|
+
propertyNames: {
|
|
10197
|
+
enum: def.keyType._def.values
|
|
10198
|
+
}
|
|
10199
|
+
};
|
|
10200
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
10201
|
+
const { type, ...keyType } = parseBrandedDef2(
|
|
10202
|
+
def.keyType._def,
|
|
10203
|
+
refs
|
|
10204
|
+
);
|
|
10205
|
+
return {
|
|
10206
|
+
...schema,
|
|
10207
|
+
propertyNames: keyType
|
|
10208
|
+
};
|
|
10209
|
+
}
|
|
10210
|
+
return schema;
|
|
10211
|
+
}
|
|
10212
|
+
function parseMapDef2(def, refs) {
|
|
10213
|
+
if (refs.mapStrategy === "record") {
|
|
10214
|
+
return parseRecordDef2(def, refs);
|
|
10215
|
+
}
|
|
10216
|
+
const keys = parseDef2(def.keyType._def, {
|
|
10217
|
+
...refs,
|
|
10218
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
10219
|
+
}) || parseAnyDef2();
|
|
10220
|
+
const values = parseDef2(def.valueType._def, {
|
|
10221
|
+
...refs,
|
|
10222
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
10223
|
+
}) || parseAnyDef2();
|
|
10224
|
+
return {
|
|
10225
|
+
type: "array",
|
|
10226
|
+
maxItems: 125,
|
|
10227
|
+
items: {
|
|
10228
|
+
type: "array",
|
|
10229
|
+
items: [keys, values],
|
|
10230
|
+
minItems: 2,
|
|
10231
|
+
maxItems: 2
|
|
10232
|
+
}
|
|
10233
|
+
};
|
|
10234
|
+
}
|
|
10235
|
+
function parseNativeEnumDef2(def) {
|
|
10236
|
+
const object4 = def.values;
|
|
10237
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
10238
|
+
return typeof object4[object4[key]] !== "number";
|
|
10239
|
+
});
|
|
10240
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
10241
|
+
const parsedTypes = Array.from(
|
|
10242
|
+
new Set(actualValues.map((values) => typeof values))
|
|
10243
|
+
);
|
|
10244
|
+
return {
|
|
10245
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
10246
|
+
enum: actualValues
|
|
10247
|
+
};
|
|
10248
|
+
}
|
|
10249
|
+
function parseNeverDef2() {
|
|
10250
|
+
return { not: parseAnyDef2() };
|
|
10251
|
+
}
|
|
10252
|
+
function parseNullDef2() {
|
|
10253
|
+
return {
|
|
10254
|
+
type: "null"
|
|
10255
|
+
};
|
|
10256
|
+
}
|
|
10257
|
+
var primitiveMappings2 = {
|
|
10258
|
+
ZodString: "string",
|
|
10259
|
+
ZodNumber: "number",
|
|
10260
|
+
ZodBigInt: "integer",
|
|
10261
|
+
ZodBoolean: "boolean",
|
|
10262
|
+
ZodNull: "null"
|
|
10263
|
+
};
|
|
10264
|
+
function parseUnionDef2(def, refs) {
|
|
10265
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10266
|
+
if (options.every(
|
|
10267
|
+
(x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length)
|
|
10268
|
+
)) {
|
|
10269
|
+
const types = options.reduce((types2, x) => {
|
|
10270
|
+
const type = primitiveMappings2[x._def.typeName];
|
|
10271
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
10272
|
+
}, []);
|
|
10273
|
+
return {
|
|
10274
|
+
type: types.length > 1 ? types : types[0]
|
|
10275
|
+
};
|
|
10276
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
10277
|
+
const types = options.reduce(
|
|
10278
|
+
(acc, x) => {
|
|
10279
|
+
const type = typeof x._def.value;
|
|
10280
|
+
switch (type) {
|
|
10281
|
+
case "string":
|
|
10282
|
+
case "number":
|
|
10283
|
+
case "boolean":
|
|
10284
|
+
return [...acc, type];
|
|
10285
|
+
case "bigint":
|
|
10286
|
+
return [...acc, "integer"];
|
|
10287
|
+
case "object":
|
|
10288
|
+
if (x._def.value === null)
|
|
10289
|
+
return [...acc, "null"];
|
|
10290
|
+
case "symbol":
|
|
10291
|
+
case "undefined":
|
|
10292
|
+
case "function":
|
|
10293
|
+
default:
|
|
10294
|
+
return acc;
|
|
10295
|
+
}
|
|
10296
|
+
},
|
|
10297
|
+
[]
|
|
10298
|
+
);
|
|
10299
|
+
if (types.length === options.length) {
|
|
10300
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
10301
|
+
return {
|
|
10302
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
10303
|
+
enum: options.reduce(
|
|
10304
|
+
(acc, x) => {
|
|
10305
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
10306
|
+
},
|
|
10307
|
+
[]
|
|
10308
|
+
)
|
|
10309
|
+
};
|
|
10310
|
+
}
|
|
10311
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
10312
|
+
return {
|
|
10313
|
+
type: "string",
|
|
10314
|
+
enum: options.reduce(
|
|
10315
|
+
(acc, x) => [
|
|
10316
|
+
...acc,
|
|
10317
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
10318
|
+
],
|
|
10319
|
+
[]
|
|
10320
|
+
)
|
|
10321
|
+
};
|
|
10322
|
+
}
|
|
10323
|
+
return asAnyOf2(def, refs);
|
|
10324
|
+
}
|
|
10325
|
+
var asAnyOf2 = (def, refs) => {
|
|
10326
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
|
|
10327
|
+
(x, i) => parseDef2(x._def, {
|
|
10328
|
+
...refs,
|
|
10329
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
10330
|
+
})
|
|
10331
|
+
).filter(
|
|
10332
|
+
(x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
|
|
10333
|
+
);
|
|
10334
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
10335
|
+
};
|
|
10336
|
+
function parseNullableDef2(def, refs) {
|
|
10337
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
10338
|
+
def.innerType._def.typeName
|
|
10339
|
+
) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
10340
|
+
return {
|
|
10341
|
+
type: [
|
|
10342
|
+
primitiveMappings2[def.innerType._def.typeName],
|
|
10343
|
+
"null"
|
|
10344
|
+
]
|
|
10345
|
+
};
|
|
10346
|
+
}
|
|
10347
|
+
const base = parseDef2(def.innerType._def, {
|
|
10348
|
+
...refs,
|
|
10349
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
10350
|
+
});
|
|
10351
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
10352
|
+
}
|
|
10353
|
+
function parseNumberDef2(def) {
|
|
10354
|
+
const res = {
|
|
10355
|
+
type: "number"
|
|
10356
|
+
};
|
|
10357
|
+
if (!def.checks)
|
|
10358
|
+
return res;
|
|
10359
|
+
for (const check of def.checks) {
|
|
10360
|
+
switch (check.kind) {
|
|
10361
|
+
case "int":
|
|
10362
|
+
res.type = "integer";
|
|
10363
|
+
break;
|
|
10364
|
+
case "min":
|
|
10365
|
+
if (check.inclusive) {
|
|
10366
|
+
res.minimum = check.value;
|
|
10367
|
+
} else {
|
|
10368
|
+
res.exclusiveMinimum = check.value;
|
|
10369
|
+
}
|
|
10370
|
+
break;
|
|
10371
|
+
case "max":
|
|
10372
|
+
if (check.inclusive) {
|
|
10373
|
+
res.maximum = check.value;
|
|
10374
|
+
} else {
|
|
10375
|
+
res.exclusiveMaximum = check.value;
|
|
10376
|
+
}
|
|
10377
|
+
break;
|
|
10378
|
+
case "multipleOf":
|
|
10379
|
+
res.multipleOf = check.value;
|
|
10380
|
+
break;
|
|
10381
|
+
}
|
|
10382
|
+
}
|
|
10383
|
+
return res;
|
|
10384
|
+
}
|
|
10385
|
+
function parseObjectDef2(def, refs) {
|
|
10386
|
+
const result = {
|
|
10387
|
+
type: "object",
|
|
10388
|
+
properties: {}
|
|
10389
|
+
};
|
|
10390
|
+
const required = [];
|
|
10391
|
+
const shape = def.shape();
|
|
10392
|
+
for (const propName in shape) {
|
|
10393
|
+
let propDef = shape[propName];
|
|
10394
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
10395
|
+
continue;
|
|
10396
|
+
}
|
|
10397
|
+
const propOptional = safeIsOptional2(propDef);
|
|
10398
|
+
const parsedDef = parseDef2(propDef._def, {
|
|
10399
|
+
...refs,
|
|
10400
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
10401
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
10402
|
+
});
|
|
10403
|
+
if (parsedDef === void 0) {
|
|
10404
|
+
continue;
|
|
10405
|
+
}
|
|
10406
|
+
result.properties[propName] = parsedDef;
|
|
10407
|
+
if (!propOptional) {
|
|
10408
|
+
required.push(propName);
|
|
10409
|
+
}
|
|
10410
|
+
}
|
|
10411
|
+
if (required.length) {
|
|
10412
|
+
result.required = required;
|
|
10413
|
+
}
|
|
10414
|
+
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
10415
|
+
if (additionalProperties !== void 0) {
|
|
10416
|
+
result.additionalProperties = additionalProperties;
|
|
10417
|
+
}
|
|
10418
|
+
return result;
|
|
10419
|
+
}
|
|
10420
|
+
function decideAdditionalProperties2(def, refs) {
|
|
10421
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
10422
|
+
return parseDef2(def.catchall._def, {
|
|
10423
|
+
...refs,
|
|
10424
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10425
|
+
});
|
|
10426
|
+
}
|
|
10427
|
+
switch (def.unknownKeys) {
|
|
10428
|
+
case "passthrough":
|
|
10429
|
+
return refs.allowedAdditionalProperties;
|
|
10430
|
+
case "strict":
|
|
10431
|
+
return refs.rejectedAdditionalProperties;
|
|
10432
|
+
case "strip":
|
|
10433
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
10434
|
+
}
|
|
10435
|
+
}
|
|
10436
|
+
function safeIsOptional2(schema) {
|
|
10437
|
+
try {
|
|
10438
|
+
return schema.isOptional();
|
|
10439
|
+
} catch (e2) {
|
|
10440
|
+
return true;
|
|
10441
|
+
}
|
|
10442
|
+
}
|
|
10443
|
+
var parseOptionalDef2 = (def, refs) => {
|
|
10444
|
+
var _a20;
|
|
10445
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
10446
|
+
return parseDef2(def.innerType._def, refs);
|
|
10447
|
+
}
|
|
10448
|
+
const innerSchema = parseDef2(def.innerType._def, {
|
|
10449
|
+
...refs,
|
|
10450
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
10451
|
+
});
|
|
10452
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
10453
|
+
};
|
|
10454
|
+
var parsePipelineDef2 = (def, refs) => {
|
|
10455
|
+
if (refs.pipeStrategy === "input") {
|
|
10456
|
+
return parseDef2(def.in._def, refs);
|
|
10457
|
+
} else if (refs.pipeStrategy === "output") {
|
|
10458
|
+
return parseDef2(def.out._def, refs);
|
|
10459
|
+
}
|
|
10460
|
+
const a = parseDef2(def.in._def, {
|
|
10461
|
+
...refs,
|
|
10462
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
10463
|
+
});
|
|
10464
|
+
const b = parseDef2(def.out._def, {
|
|
10465
|
+
...refs,
|
|
10466
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
10467
|
+
});
|
|
10468
|
+
return {
|
|
10469
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
10470
|
+
};
|
|
10471
|
+
};
|
|
10472
|
+
function parsePromiseDef2(def, refs) {
|
|
10473
|
+
return parseDef2(def.type._def, refs);
|
|
10474
|
+
}
|
|
10475
|
+
function parseSetDef2(def, refs) {
|
|
10476
|
+
const items = parseDef2(def.valueType._def, {
|
|
10477
|
+
...refs,
|
|
10478
|
+
currentPath: [...refs.currentPath, "items"]
|
|
10479
|
+
});
|
|
10480
|
+
const schema = {
|
|
10481
|
+
type: "array",
|
|
10482
|
+
uniqueItems: true,
|
|
10483
|
+
items
|
|
10484
|
+
};
|
|
10485
|
+
if (def.minSize) {
|
|
10486
|
+
schema.minItems = def.minSize.value;
|
|
10487
|
+
}
|
|
10488
|
+
if (def.maxSize) {
|
|
10489
|
+
schema.maxItems = def.maxSize.value;
|
|
10490
|
+
}
|
|
10491
|
+
return schema;
|
|
10492
|
+
}
|
|
10493
|
+
function parseTupleDef2(def, refs) {
|
|
10494
|
+
if (def.rest) {
|
|
10495
|
+
return {
|
|
10496
|
+
type: "array",
|
|
10497
|
+
minItems: def.items.length,
|
|
10498
|
+
items: def.items.map(
|
|
10499
|
+
(x, i) => parseDef2(x._def, {
|
|
10500
|
+
...refs,
|
|
10501
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10502
|
+
})
|
|
10503
|
+
).reduce(
|
|
10504
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10505
|
+
[]
|
|
10506
|
+
),
|
|
10507
|
+
additionalItems: parseDef2(def.rest._def, {
|
|
10508
|
+
...refs,
|
|
10509
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
10510
|
+
})
|
|
10511
|
+
};
|
|
10512
|
+
} else {
|
|
10513
|
+
return {
|
|
10514
|
+
type: "array",
|
|
10515
|
+
minItems: def.items.length,
|
|
10516
|
+
maxItems: def.items.length,
|
|
10517
|
+
items: def.items.map(
|
|
10518
|
+
(x, i) => parseDef2(x._def, {
|
|
10519
|
+
...refs,
|
|
10520
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10521
|
+
})
|
|
10522
|
+
).reduce(
|
|
10523
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10524
|
+
[]
|
|
10525
|
+
)
|
|
10526
|
+
};
|
|
10527
|
+
}
|
|
10528
|
+
}
|
|
10529
|
+
function parseUndefinedDef2() {
|
|
10530
|
+
return {
|
|
10531
|
+
not: parseAnyDef2()
|
|
10532
|
+
};
|
|
10533
|
+
}
|
|
10534
|
+
function parseUnknownDef2() {
|
|
10535
|
+
return parseAnyDef2();
|
|
10536
|
+
}
|
|
10537
|
+
var parseReadonlyDef2 = (def, refs) => {
|
|
10538
|
+
return parseDef2(def.innerType._def, refs);
|
|
10539
|
+
};
|
|
10540
|
+
var selectParser2 = (def, typeName, refs) => {
|
|
10541
|
+
switch (typeName) {
|
|
10542
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
10543
|
+
return parseStringDef2(def, refs);
|
|
10544
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
10545
|
+
return parseNumberDef2(def);
|
|
10546
|
+
case ZodFirstPartyTypeKind.ZodObject:
|
|
10547
|
+
return parseObjectDef2(def, refs);
|
|
10548
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
10549
|
+
return parseBigintDef2(def);
|
|
10550
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
10551
|
+
return parseBooleanDef2();
|
|
10552
|
+
case ZodFirstPartyTypeKind.ZodDate:
|
|
10553
|
+
return parseDateDef2(def, refs);
|
|
10554
|
+
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
10555
|
+
return parseUndefinedDef2();
|
|
10556
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
10557
|
+
return parseNullDef2();
|
|
10558
|
+
case ZodFirstPartyTypeKind.ZodArray:
|
|
10559
|
+
return parseArrayDef2(def, refs);
|
|
10560
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
10561
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
10562
|
+
return parseUnionDef2(def, refs);
|
|
10563
|
+
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
10564
|
+
return parseIntersectionDef2(def, refs);
|
|
10565
|
+
case ZodFirstPartyTypeKind.ZodTuple:
|
|
10566
|
+
return parseTupleDef2(def, refs);
|
|
10567
|
+
case ZodFirstPartyTypeKind.ZodRecord:
|
|
10568
|
+
return parseRecordDef2(def, refs);
|
|
10569
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
10570
|
+
return parseLiteralDef2(def);
|
|
10571
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
10572
|
+
return parseEnumDef2(def);
|
|
10573
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
10574
|
+
return parseNativeEnumDef2(def);
|
|
10575
|
+
case ZodFirstPartyTypeKind.ZodNullable:
|
|
10576
|
+
return parseNullableDef2(def, refs);
|
|
10577
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
10578
|
+
return parseOptionalDef2(def, refs);
|
|
10579
|
+
case ZodFirstPartyTypeKind.ZodMap:
|
|
10580
|
+
return parseMapDef2(def, refs);
|
|
10581
|
+
case ZodFirstPartyTypeKind.ZodSet:
|
|
10582
|
+
return parseSetDef2(def, refs);
|
|
10583
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
10584
|
+
return () => def.getter()._def;
|
|
10585
|
+
case ZodFirstPartyTypeKind.ZodPromise:
|
|
10586
|
+
return parsePromiseDef2(def, refs);
|
|
10587
|
+
case ZodFirstPartyTypeKind.ZodNaN:
|
|
10588
|
+
case ZodFirstPartyTypeKind.ZodNever:
|
|
10589
|
+
return parseNeverDef2();
|
|
10590
|
+
case ZodFirstPartyTypeKind.ZodEffects:
|
|
10591
|
+
return parseEffectsDef2(def, refs);
|
|
10592
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
10593
|
+
return parseAnyDef2();
|
|
10594
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
10595
|
+
return parseUnknownDef2();
|
|
10596
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
10597
|
+
return parseDefaultDef2(def, refs);
|
|
10598
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
10599
|
+
return parseBrandedDef2(def, refs);
|
|
10600
|
+
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
10601
|
+
return parseReadonlyDef2(def, refs);
|
|
10602
|
+
case ZodFirstPartyTypeKind.ZodCatch:
|
|
10603
|
+
return parseCatchDef2(def, refs);
|
|
10604
|
+
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
10605
|
+
return parsePipelineDef2(def, refs);
|
|
10606
|
+
case ZodFirstPartyTypeKind.ZodFunction:
|
|
10607
|
+
case ZodFirstPartyTypeKind.ZodVoid:
|
|
10608
|
+
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
10609
|
+
return void 0;
|
|
10610
|
+
default:
|
|
10611
|
+
return /* @__PURE__ */ ((_) => void 0)();
|
|
10612
|
+
}
|
|
10613
|
+
};
|
|
10614
|
+
function parseDef2(def, refs, forceResolution = false) {
|
|
10615
|
+
var _a20;
|
|
10616
|
+
const seenItem = refs.seen.get(def);
|
|
10617
|
+
if (refs.override) {
|
|
10618
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
10619
|
+
refs,
|
|
10620
|
+
def,
|
|
10621
|
+
refs,
|
|
10622
|
+
seenItem,
|
|
10623
|
+
forceResolution
|
|
10624
|
+
);
|
|
10625
|
+
if (overrideResult !== ignoreOverride2) {
|
|
10626
|
+
return overrideResult;
|
|
10627
|
+
}
|
|
10628
|
+
}
|
|
10629
|
+
if (seenItem && !forceResolution) {
|
|
10630
|
+
const seenSchema = get$ref2(seenItem, refs);
|
|
10631
|
+
if (seenSchema !== void 0) {
|
|
10632
|
+
return seenSchema;
|
|
10633
|
+
}
|
|
10634
|
+
}
|
|
10635
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
10636
|
+
refs.seen.set(def, newItem);
|
|
10637
|
+
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
10638
|
+
const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10639
|
+
if (jsonSchema22) {
|
|
10640
|
+
addMeta2(def, refs, jsonSchema22);
|
|
10641
|
+
}
|
|
10642
|
+
if (refs.postProcess) {
|
|
10643
|
+
const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
|
|
10644
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10645
|
+
return postProcessResult;
|
|
10646
|
+
}
|
|
10647
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10648
|
+
return jsonSchema22;
|
|
10649
|
+
}
|
|
10650
|
+
var get$ref2 = (item, refs) => {
|
|
10651
|
+
switch (refs.$refStrategy) {
|
|
10652
|
+
case "root":
|
|
10653
|
+
return { $ref: item.path.join("/") };
|
|
10654
|
+
case "relative":
|
|
10655
|
+
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
10656
|
+
case "none":
|
|
10657
|
+
case "seen": {
|
|
10658
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
10659
|
+
console.warn(
|
|
10660
|
+
`Recursive reference detected at ${refs.currentPath.join(
|
|
10661
|
+
"/"
|
|
10662
|
+
)}! Defaulting to any`
|
|
10663
|
+
);
|
|
10664
|
+
return parseAnyDef2();
|
|
10665
|
+
}
|
|
10666
|
+
return refs.$refStrategy === "seen" ? parseAnyDef2() : void 0;
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
};
|
|
10670
|
+
var addMeta2 = (def, refs, jsonSchema22) => {
|
|
10671
|
+
if (def.description) {
|
|
10672
|
+
jsonSchema22.description = def.description;
|
|
10673
|
+
}
|
|
10674
|
+
return jsonSchema22;
|
|
10675
|
+
};
|
|
10676
|
+
var getRefs2 = (options) => {
|
|
10677
|
+
const _options = getDefaultOptions2(options);
|
|
10678
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
10679
|
+
return {
|
|
10680
|
+
..._options,
|
|
10681
|
+
currentPath,
|
|
10682
|
+
propertyPath: void 0,
|
|
10683
|
+
seen: new Map(
|
|
10684
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
10685
|
+
def._def,
|
|
10686
|
+
{
|
|
10687
|
+
def: def._def,
|
|
10688
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
10689
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
10690
|
+
jsonSchema: void 0
|
|
10691
|
+
}
|
|
10692
|
+
])
|
|
10693
|
+
)
|
|
10694
|
+
};
|
|
10695
|
+
};
|
|
10696
|
+
var zodToJsonSchema3 = (schema, options) => {
|
|
10697
|
+
var _a20;
|
|
10698
|
+
const refs = getRefs2(options);
|
|
10699
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
10700
|
+
(acc, [name25, schema2]) => {
|
|
10701
|
+
var _a25;
|
|
10702
|
+
return {
|
|
10703
|
+
...acc,
|
|
10704
|
+
[name25]: (_a25 = parseDef2(
|
|
10705
|
+
schema2._def,
|
|
10706
|
+
{
|
|
10707
|
+
...refs,
|
|
10708
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
10709
|
+
},
|
|
10710
|
+
true
|
|
10711
|
+
)) != null ? _a25 : parseAnyDef2()
|
|
10712
|
+
};
|
|
10713
|
+
},
|
|
10714
|
+
{}
|
|
10715
|
+
) : void 0;
|
|
10716
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
10717
|
+
const main = (_a20 = parseDef2(
|
|
10718
|
+
schema._def,
|
|
10719
|
+
name20 === void 0 ? refs : {
|
|
10720
|
+
...refs,
|
|
10721
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
10722
|
+
},
|
|
10723
|
+
false
|
|
10724
|
+
)) != null ? _a20 : parseAnyDef2();
|
|
10725
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10726
|
+
if (title !== void 0) {
|
|
10727
|
+
main.title = title;
|
|
10728
|
+
}
|
|
10729
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
10730
|
+
...main,
|
|
10731
|
+
[refs.definitionPath]: definitions
|
|
10732
|
+
} : main : {
|
|
10733
|
+
$ref: [
|
|
10734
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10735
|
+
refs.definitionPath,
|
|
10736
|
+
name20
|
|
10737
|
+
].join("/"),
|
|
10738
|
+
[refs.definitionPath]: {
|
|
10739
|
+
...definitions,
|
|
10740
|
+
[name20]: main
|
|
10741
|
+
}
|
|
10742
|
+
};
|
|
10743
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10744
|
+
return combined;
|
|
10745
|
+
};
|
|
10746
|
+
var zod_to_json_schema_default2 = zodToJsonSchema3;
|
|
10747
|
+
function zod3Schema2(zodSchema22, options) {
|
|
10748
|
+
var _a20;
|
|
10749
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10750
|
+
return jsonSchema3(
|
|
10751
|
+
zod_to_json_schema_default2(zodSchema22, {
|
|
10752
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
10753
|
+
}),
|
|
10754
|
+
{
|
|
10755
|
+
validate: async (value) => {
|
|
10756
|
+
const result = await zodSchema22.safeParseAsync(value);
|
|
10757
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10758
|
+
}
|
|
10759
|
+
}
|
|
10760
|
+
);
|
|
10761
|
+
}
|
|
10762
|
+
function zod4Schema2(zodSchema22, options) {
|
|
10763
|
+
var _a20;
|
|
10764
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10765
|
+
const z4JSONSchema = z42.toJSONSchema(zodSchema22, {
|
|
10766
|
+
target: "draft-7",
|
|
10767
|
+
io: "output",
|
|
10768
|
+
reused: useReferences ? "ref" : "inline"
|
|
10769
|
+
});
|
|
10770
|
+
return jsonSchema3(z4JSONSchema, {
|
|
10771
|
+
validate: async (value) => {
|
|
10772
|
+
const result = await z42.safeParseAsync(zodSchema22, value);
|
|
10773
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10774
|
+
}
|
|
10775
|
+
});
|
|
10776
|
+
}
|
|
10777
|
+
function isZod4Schema2(zodSchema22) {
|
|
10778
|
+
return "_zod" in zodSchema22;
|
|
10779
|
+
}
|
|
10780
|
+
function zodSchema3(zodSchema22, options) {
|
|
10781
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
10782
|
+
return zod4Schema2(zodSchema22);
|
|
10783
|
+
} else {
|
|
10784
|
+
return zod3Schema2(zodSchema22);
|
|
10785
|
+
}
|
|
10786
|
+
}
|
|
10787
|
+
var schemaSymbol3 = Symbol.for("vercel.ai.schema");
|
|
10788
|
+
function jsonSchema3(jsonSchema22, {
|
|
10789
|
+
validate
|
|
10790
|
+
} = {}) {
|
|
10791
|
+
return {
|
|
10792
|
+
[schemaSymbol3]: true,
|
|
10793
|
+
_type: void 0,
|
|
10794
|
+
// should never be used directly
|
|
10795
|
+
[validatorSymbol3]: true,
|
|
10796
|
+
jsonSchema: jsonSchema22,
|
|
10797
|
+
validate
|
|
10798
|
+
};
|
|
10799
|
+
}
|
|
10800
|
+
function isSchema3(value) {
|
|
10801
|
+
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
10802
|
+
}
|
|
10803
|
+
function asSchema3(schema) {
|
|
10804
|
+
return schema == null ? jsonSchema3({
|
|
10805
|
+
properties: {},
|
|
10806
|
+
additionalProperties: false
|
|
10807
|
+
}) : isSchema3(schema) ? schema : zodSchema3(schema);
|
|
10808
|
+
}
|
|
10809
|
+
var __defProp4 = Object.defineProperty;
|
|
10810
|
+
var __export4 = (target, all) => {
|
|
10811
|
+
for (var name172 in all)
|
|
10812
|
+
__defProp4(target, name172, { get: all[name172], enumerable: true });
|
|
10813
|
+
};
|
|
10814
|
+
var name73 = "AI_NoObjectGeneratedError";
|
|
10815
|
+
var marker74 = `vercel.ai.error.${name73}`;
|
|
10816
|
+
var symbol74 = Symbol.for(marker74);
|
|
10817
|
+
var _a74;
|
|
10818
|
+
var NoObjectGeneratedError3 = class extends AISDKError$1 {
|
|
10819
|
+
constructor({
|
|
10820
|
+
message = "No object generated.",
|
|
10821
|
+
cause,
|
|
10822
|
+
text: text22,
|
|
10823
|
+
response,
|
|
10824
|
+
usage,
|
|
10825
|
+
finishReason
|
|
10826
|
+
}) {
|
|
10827
|
+
super({ name: name73, message, cause });
|
|
10828
|
+
this[_a74] = true;
|
|
10829
|
+
this.text = text22;
|
|
10830
|
+
this.response = response;
|
|
10831
|
+
this.usage = usage;
|
|
10832
|
+
this.finishReason = finishReason;
|
|
10833
|
+
}
|
|
10834
|
+
static isInstance(error) {
|
|
10835
|
+
return AISDKError$1.hasMarker(error, marker74);
|
|
10836
|
+
}
|
|
10837
|
+
};
|
|
10838
|
+
_a74 = symbol74;
|
|
10839
|
+
var dataContentSchema3 = z$1.union([
|
|
10840
|
+
z$1.string(),
|
|
10841
|
+
z$1.instanceof(Uint8Array),
|
|
10842
|
+
z$1.instanceof(ArrayBuffer),
|
|
10843
|
+
z$1.custom(
|
|
10844
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
10845
|
+
(value) => {
|
|
10846
|
+
var _a172, _b8;
|
|
10847
|
+
return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
|
|
10848
|
+
},
|
|
10849
|
+
{ message: "Must be a Buffer" }
|
|
10850
|
+
)
|
|
10851
|
+
]);
|
|
10852
|
+
var jsonValueSchema3 = z$1.lazy(
|
|
10853
|
+
() => z$1.union([
|
|
10854
|
+
z$1.null(),
|
|
10855
|
+
z$1.string(),
|
|
10856
|
+
z$1.number(),
|
|
10857
|
+
z$1.boolean(),
|
|
10858
|
+
z$1.record(z$1.string(), jsonValueSchema3),
|
|
10859
|
+
z$1.array(jsonValueSchema3)
|
|
10860
|
+
])
|
|
10861
|
+
);
|
|
10862
|
+
var providerMetadataSchema3 = z$1.record(
|
|
10863
|
+
z$1.string(),
|
|
10864
|
+
z$1.record(z$1.string(), jsonValueSchema3)
|
|
10865
|
+
);
|
|
10866
|
+
var textPartSchema3 = z$1.object({
|
|
10867
|
+
type: z$1.literal("text"),
|
|
10868
|
+
text: z$1.string(),
|
|
10869
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10870
|
+
});
|
|
10871
|
+
var imagePartSchema3 = z$1.object({
|
|
10872
|
+
type: z$1.literal("image"),
|
|
10873
|
+
image: z$1.union([dataContentSchema3, z$1.instanceof(URL)]),
|
|
10874
|
+
mediaType: z$1.string().optional(),
|
|
10875
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10876
|
+
});
|
|
10877
|
+
var filePartSchema3 = z$1.object({
|
|
10878
|
+
type: z$1.literal("file"),
|
|
10879
|
+
data: z$1.union([dataContentSchema3, z$1.instanceof(URL)]),
|
|
10880
|
+
filename: z$1.string().optional(),
|
|
10881
|
+
mediaType: z$1.string(),
|
|
10882
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10883
|
+
});
|
|
10884
|
+
var reasoningPartSchema3 = z$1.object({
|
|
10885
|
+
type: z$1.literal("reasoning"),
|
|
10886
|
+
text: z$1.string(),
|
|
10887
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10888
|
+
});
|
|
10889
|
+
var toolCallPartSchema3 = z$1.object({
|
|
10890
|
+
type: z$1.literal("tool-call"),
|
|
10891
|
+
toolCallId: z$1.string(),
|
|
10892
|
+
toolName: z$1.string(),
|
|
10893
|
+
input: z$1.unknown(),
|
|
10894
|
+
providerOptions: providerMetadataSchema3.optional(),
|
|
10895
|
+
providerExecuted: z$1.boolean().optional()
|
|
10896
|
+
});
|
|
10897
|
+
var outputSchema2 = z$1.discriminatedUnion("type", [
|
|
10898
|
+
z$1.object({
|
|
10899
|
+
type: z$1.literal("text"),
|
|
10900
|
+
value: z$1.string()
|
|
10901
|
+
}),
|
|
10902
|
+
z$1.object({
|
|
10903
|
+
type: z$1.literal("json"),
|
|
10904
|
+
value: jsonValueSchema3
|
|
10905
|
+
}),
|
|
10906
|
+
z$1.object({
|
|
10907
|
+
type: z$1.literal("error-text"),
|
|
10908
|
+
value: z$1.string()
|
|
10909
|
+
}),
|
|
10910
|
+
z$1.object({
|
|
10911
|
+
type: z$1.literal("error-json"),
|
|
10912
|
+
value: jsonValueSchema3
|
|
10913
|
+
}),
|
|
10914
|
+
z$1.object({
|
|
10915
|
+
type: z$1.literal("content"),
|
|
10916
|
+
value: z$1.array(
|
|
10917
|
+
z$1.union([
|
|
10918
|
+
z$1.object({
|
|
10919
|
+
type: z$1.literal("text"),
|
|
10920
|
+
text: z$1.string()
|
|
10921
|
+
}),
|
|
10922
|
+
z$1.object({
|
|
10923
|
+
type: z$1.literal("media"),
|
|
10924
|
+
data: z$1.string(),
|
|
10925
|
+
mediaType: z$1.string()
|
|
10926
|
+
})
|
|
10927
|
+
])
|
|
10928
|
+
)
|
|
10929
|
+
})
|
|
10930
|
+
]);
|
|
10931
|
+
var toolResultPartSchema3 = z$1.object({
|
|
10932
|
+
type: z$1.literal("tool-result"),
|
|
10933
|
+
toolCallId: z$1.string(),
|
|
10934
|
+
toolName: z$1.string(),
|
|
10935
|
+
output: outputSchema2,
|
|
10936
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10937
|
+
});
|
|
10938
|
+
var systemModelMessageSchema2 = z$1.object(
|
|
10939
|
+
{
|
|
10940
|
+
role: z$1.literal("system"),
|
|
10941
|
+
content: z$1.string(),
|
|
10942
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10943
|
+
}
|
|
10944
|
+
);
|
|
10945
|
+
var userModelMessageSchema2 = z$1.object({
|
|
10946
|
+
role: z$1.literal("user"),
|
|
10947
|
+
content: z$1.union([
|
|
10948
|
+
z$1.string(),
|
|
10949
|
+
z$1.array(z$1.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
|
|
10950
|
+
]),
|
|
10951
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10952
|
+
});
|
|
10953
|
+
var assistantModelMessageSchema2 = z$1.object({
|
|
10954
|
+
role: z$1.literal("assistant"),
|
|
10955
|
+
content: z$1.union([
|
|
10956
|
+
z$1.string(),
|
|
10957
|
+
z$1.array(
|
|
10958
|
+
z$1.union([
|
|
10959
|
+
textPartSchema3,
|
|
10960
|
+
filePartSchema3,
|
|
10961
|
+
reasoningPartSchema3,
|
|
10962
|
+
toolCallPartSchema3,
|
|
10963
|
+
toolResultPartSchema3
|
|
10964
|
+
])
|
|
10965
|
+
)
|
|
10966
|
+
]),
|
|
10967
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10968
|
+
});
|
|
10969
|
+
var toolModelMessageSchema2 = z$1.object({
|
|
10970
|
+
role: z$1.literal("tool"),
|
|
10971
|
+
content: z$1.array(toolResultPartSchema3),
|
|
10972
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10973
|
+
});
|
|
10974
|
+
z$1.union([
|
|
10975
|
+
systemModelMessageSchema2,
|
|
10976
|
+
userModelMessageSchema2,
|
|
10977
|
+
assistantModelMessageSchema2,
|
|
10978
|
+
toolModelMessageSchema2
|
|
10979
|
+
]);
|
|
10980
|
+
function stepCountIs(stepCount) {
|
|
10981
|
+
return ({ steps }) => steps.length === stepCount;
|
|
10982
|
+
}
|
|
10983
|
+
createIdGenerator3({
|
|
10984
|
+
prefix: "aitxt",
|
|
10985
|
+
size: 24
|
|
10986
|
+
});
|
|
10987
|
+
z$1.union([
|
|
10988
|
+
z$1.strictObject({
|
|
10989
|
+
type: z$1.literal("text-start"),
|
|
10990
|
+
id: z$1.string(),
|
|
10991
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
10992
|
+
}),
|
|
10993
|
+
z$1.strictObject({
|
|
10994
|
+
type: z$1.literal("text-delta"),
|
|
10995
|
+
id: z$1.string(),
|
|
10996
|
+
delta: z$1.string(),
|
|
10997
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
10998
|
+
}),
|
|
10999
|
+
z$1.strictObject({
|
|
11000
|
+
type: z$1.literal("text-end"),
|
|
11001
|
+
id: z$1.string(),
|
|
11002
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11003
|
+
}),
|
|
11004
|
+
z$1.strictObject({
|
|
11005
|
+
type: z$1.literal("error"),
|
|
11006
|
+
errorText: z$1.string()
|
|
11007
|
+
}),
|
|
11008
|
+
z$1.strictObject({
|
|
11009
|
+
type: z$1.literal("tool-input-start"),
|
|
11010
|
+
toolCallId: z$1.string(),
|
|
11011
|
+
toolName: z$1.string(),
|
|
11012
|
+
providerExecuted: z$1.boolean().optional(),
|
|
11013
|
+
dynamic: z$1.boolean().optional()
|
|
11014
|
+
}),
|
|
11015
|
+
z$1.strictObject({
|
|
11016
|
+
type: z$1.literal("tool-input-delta"),
|
|
11017
|
+
toolCallId: z$1.string(),
|
|
11018
|
+
inputTextDelta: z$1.string()
|
|
11019
|
+
}),
|
|
11020
|
+
z$1.strictObject({
|
|
11021
|
+
type: z$1.literal("tool-input-available"),
|
|
11022
|
+
toolCallId: z$1.string(),
|
|
11023
|
+
toolName: z$1.string(),
|
|
11024
|
+
input: z$1.unknown(),
|
|
11025
|
+
providerExecuted: z$1.boolean().optional(),
|
|
11026
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11027
|
+
dynamic: z$1.boolean().optional()
|
|
11028
|
+
}),
|
|
11029
|
+
z$1.strictObject({
|
|
11030
|
+
type: z$1.literal("tool-input-error"),
|
|
11031
|
+
toolCallId: z$1.string(),
|
|
11032
|
+
toolName: z$1.string(),
|
|
11033
|
+
input: z$1.unknown(),
|
|
11034
|
+
providerExecuted: z$1.boolean().optional(),
|
|
11035
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11036
|
+
dynamic: z$1.boolean().optional(),
|
|
11037
|
+
errorText: z$1.string()
|
|
11038
|
+
}),
|
|
11039
|
+
z$1.strictObject({
|
|
11040
|
+
type: z$1.literal("tool-output-available"),
|
|
11041
|
+
toolCallId: z$1.string(),
|
|
11042
|
+
output: z$1.unknown(),
|
|
11043
|
+
providerExecuted: z$1.boolean().optional(),
|
|
11044
|
+
dynamic: z$1.boolean().optional(),
|
|
11045
|
+
preliminary: z$1.boolean().optional()
|
|
11046
|
+
}),
|
|
11047
|
+
z$1.strictObject({
|
|
11048
|
+
type: z$1.literal("tool-output-error"),
|
|
11049
|
+
toolCallId: z$1.string(),
|
|
11050
|
+
errorText: z$1.string(),
|
|
11051
|
+
providerExecuted: z$1.boolean().optional(),
|
|
11052
|
+
dynamic: z$1.boolean().optional()
|
|
11053
|
+
}),
|
|
11054
|
+
z$1.strictObject({
|
|
11055
|
+
type: z$1.literal("reasoning"),
|
|
11056
|
+
text: z$1.string(),
|
|
11057
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11058
|
+
}),
|
|
11059
|
+
z$1.strictObject({
|
|
11060
|
+
type: z$1.literal("reasoning-start"),
|
|
11061
|
+
id: z$1.string(),
|
|
11062
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11063
|
+
}),
|
|
11064
|
+
z$1.strictObject({
|
|
11065
|
+
type: z$1.literal("reasoning-delta"),
|
|
11066
|
+
id: z$1.string(),
|
|
11067
|
+
delta: z$1.string(),
|
|
11068
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11069
|
+
}),
|
|
11070
|
+
z$1.strictObject({
|
|
11071
|
+
type: z$1.literal("reasoning-end"),
|
|
11072
|
+
id: z$1.string(),
|
|
11073
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11074
|
+
}),
|
|
11075
|
+
z$1.strictObject({
|
|
11076
|
+
type: z$1.literal("reasoning-part-finish")
|
|
11077
|
+
}),
|
|
11078
|
+
z$1.strictObject({
|
|
11079
|
+
type: z$1.literal("source-url"),
|
|
11080
|
+
sourceId: z$1.string(),
|
|
11081
|
+
url: z$1.string(),
|
|
11082
|
+
title: z$1.string().optional(),
|
|
11083
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11084
|
+
}),
|
|
11085
|
+
z$1.strictObject({
|
|
11086
|
+
type: z$1.literal("source-document"),
|
|
11087
|
+
sourceId: z$1.string(),
|
|
11088
|
+
mediaType: z$1.string(),
|
|
11089
|
+
title: z$1.string(),
|
|
11090
|
+
filename: z$1.string().optional(),
|
|
11091
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11092
|
+
}),
|
|
11093
|
+
z$1.strictObject({
|
|
11094
|
+
type: z$1.literal("file"),
|
|
11095
|
+
url: z$1.string(),
|
|
11096
|
+
mediaType: z$1.string(),
|
|
11097
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11098
|
+
}),
|
|
11099
|
+
z$1.strictObject({
|
|
11100
|
+
type: z$1.string().startsWith("data-"),
|
|
11101
|
+
id: z$1.string().optional(),
|
|
11102
|
+
data: z$1.unknown(),
|
|
11103
|
+
transient: z$1.boolean().optional()
|
|
11104
|
+
}),
|
|
11105
|
+
z$1.strictObject({
|
|
11106
|
+
type: z$1.literal("start-step")
|
|
11107
|
+
}),
|
|
11108
|
+
z$1.strictObject({
|
|
11109
|
+
type: z$1.literal("finish-step")
|
|
11110
|
+
}),
|
|
11111
|
+
z$1.strictObject({
|
|
11112
|
+
type: z$1.literal("start"),
|
|
11113
|
+
messageId: z$1.string().optional(),
|
|
11114
|
+
messageMetadata: z$1.unknown().optional()
|
|
11115
|
+
}),
|
|
11116
|
+
z$1.strictObject({
|
|
11117
|
+
type: z$1.literal("finish"),
|
|
11118
|
+
messageMetadata: z$1.unknown().optional()
|
|
11119
|
+
}),
|
|
11120
|
+
z$1.strictObject({
|
|
11121
|
+
type: z$1.literal("abort")
|
|
11122
|
+
}),
|
|
11123
|
+
z$1.strictObject({
|
|
11124
|
+
type: z$1.literal("message-metadata"),
|
|
11125
|
+
messageMetadata: z$1.unknown()
|
|
11126
|
+
})
|
|
11127
|
+
]);
|
|
11128
|
+
function fixJson3(input) {
|
|
11129
|
+
const stack = ["ROOT"];
|
|
11130
|
+
let lastValidIndex = -1;
|
|
11131
|
+
let literalStart = null;
|
|
11132
|
+
function processValueStart(char, i, swapState) {
|
|
11133
|
+
{
|
|
11134
|
+
switch (char) {
|
|
11135
|
+
case '"': {
|
|
11136
|
+
lastValidIndex = i;
|
|
11137
|
+
stack.pop();
|
|
11138
|
+
stack.push(swapState);
|
|
11139
|
+
stack.push("INSIDE_STRING");
|
|
11140
|
+
break;
|
|
11141
|
+
}
|
|
11142
|
+
case "f":
|
|
11143
|
+
case "t":
|
|
11144
|
+
case "n": {
|
|
11145
|
+
lastValidIndex = i;
|
|
11146
|
+
literalStart = i;
|
|
11147
|
+
stack.pop();
|
|
11148
|
+
stack.push(swapState);
|
|
11149
|
+
stack.push("INSIDE_LITERAL");
|
|
11150
|
+
break;
|
|
11151
|
+
}
|
|
11152
|
+
case "-": {
|
|
11153
|
+
stack.pop();
|
|
11154
|
+
stack.push(swapState);
|
|
11155
|
+
stack.push("INSIDE_NUMBER");
|
|
11156
|
+
break;
|
|
11157
|
+
}
|
|
11158
|
+
case "0":
|
|
11159
|
+
case "1":
|
|
11160
|
+
case "2":
|
|
11161
|
+
case "3":
|
|
11162
|
+
case "4":
|
|
11163
|
+
case "5":
|
|
11164
|
+
case "6":
|
|
11165
|
+
case "7":
|
|
11166
|
+
case "8":
|
|
11167
|
+
case "9": {
|
|
11168
|
+
lastValidIndex = i;
|
|
11169
|
+
stack.pop();
|
|
11170
|
+
stack.push(swapState);
|
|
11171
|
+
stack.push("INSIDE_NUMBER");
|
|
11172
|
+
break;
|
|
11173
|
+
}
|
|
11174
|
+
case "{": {
|
|
11175
|
+
lastValidIndex = i;
|
|
11176
|
+
stack.pop();
|
|
11177
|
+
stack.push(swapState);
|
|
11178
|
+
stack.push("INSIDE_OBJECT_START");
|
|
11179
|
+
break;
|
|
11180
|
+
}
|
|
11181
|
+
case "[": {
|
|
11182
|
+
lastValidIndex = i;
|
|
11183
|
+
stack.pop();
|
|
11184
|
+
stack.push(swapState);
|
|
11185
|
+
stack.push("INSIDE_ARRAY_START");
|
|
11186
|
+
break;
|
|
11187
|
+
}
|
|
11188
|
+
}
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
11191
|
+
function processAfterObjectValue(char, i) {
|
|
11192
|
+
switch (char) {
|
|
11193
|
+
case ",": {
|
|
11194
|
+
stack.pop();
|
|
11195
|
+
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
11196
|
+
break;
|
|
11197
|
+
}
|
|
11198
|
+
case "}": {
|
|
11199
|
+
lastValidIndex = i;
|
|
11200
|
+
stack.pop();
|
|
11201
|
+
break;
|
|
11202
|
+
}
|
|
11203
|
+
}
|
|
11204
|
+
}
|
|
11205
|
+
function processAfterArrayValue(char, i) {
|
|
11206
|
+
switch (char) {
|
|
11207
|
+
case ",": {
|
|
11208
|
+
stack.pop();
|
|
11209
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11210
|
+
break;
|
|
11211
|
+
}
|
|
11212
|
+
case "]": {
|
|
11213
|
+
lastValidIndex = i;
|
|
11214
|
+
stack.pop();
|
|
11215
|
+
break;
|
|
11216
|
+
}
|
|
11217
|
+
}
|
|
11218
|
+
}
|
|
11219
|
+
for (let i = 0; i < input.length; i++) {
|
|
11220
|
+
const char = input[i];
|
|
11221
|
+
const currentState = stack[stack.length - 1];
|
|
11222
|
+
switch (currentState) {
|
|
11223
|
+
case "ROOT":
|
|
11224
|
+
processValueStart(char, i, "FINISH");
|
|
11225
|
+
break;
|
|
11226
|
+
case "INSIDE_OBJECT_START": {
|
|
11227
|
+
switch (char) {
|
|
11228
|
+
case '"': {
|
|
11229
|
+
stack.pop();
|
|
11230
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11231
|
+
break;
|
|
11232
|
+
}
|
|
11233
|
+
case "}": {
|
|
11234
|
+
lastValidIndex = i;
|
|
11235
|
+
stack.pop();
|
|
11236
|
+
break;
|
|
11237
|
+
}
|
|
11238
|
+
}
|
|
11239
|
+
break;
|
|
11240
|
+
}
|
|
11241
|
+
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
11242
|
+
switch (char) {
|
|
11243
|
+
case '"': {
|
|
11244
|
+
stack.pop();
|
|
11245
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11246
|
+
break;
|
|
11247
|
+
}
|
|
11248
|
+
}
|
|
11249
|
+
break;
|
|
11250
|
+
}
|
|
11251
|
+
case "INSIDE_OBJECT_KEY": {
|
|
11252
|
+
switch (char) {
|
|
11253
|
+
case '"': {
|
|
11254
|
+
stack.pop();
|
|
11255
|
+
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
11256
|
+
break;
|
|
11257
|
+
}
|
|
11258
|
+
}
|
|
11259
|
+
break;
|
|
11260
|
+
}
|
|
11261
|
+
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
11262
|
+
switch (char) {
|
|
11263
|
+
case ":": {
|
|
11264
|
+
stack.pop();
|
|
11265
|
+
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
11266
|
+
break;
|
|
11267
|
+
}
|
|
11268
|
+
}
|
|
11269
|
+
break;
|
|
11270
|
+
}
|
|
11271
|
+
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
11272
|
+
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
11273
|
+
break;
|
|
11274
|
+
}
|
|
11275
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11276
|
+
processAfterObjectValue(char, i);
|
|
11277
|
+
break;
|
|
11278
|
+
}
|
|
11279
|
+
case "INSIDE_STRING": {
|
|
11280
|
+
switch (char) {
|
|
11281
|
+
case '"': {
|
|
11282
|
+
stack.pop();
|
|
11283
|
+
lastValidIndex = i;
|
|
11284
|
+
break;
|
|
11285
|
+
}
|
|
11286
|
+
case "\\": {
|
|
11287
|
+
stack.push("INSIDE_STRING_ESCAPE");
|
|
11288
|
+
break;
|
|
11289
|
+
}
|
|
11290
|
+
default: {
|
|
11291
|
+
lastValidIndex = i;
|
|
11292
|
+
}
|
|
11293
|
+
}
|
|
11294
|
+
break;
|
|
11295
|
+
}
|
|
11296
|
+
case "INSIDE_ARRAY_START": {
|
|
11297
|
+
switch (char) {
|
|
11298
|
+
case "]": {
|
|
11299
|
+
lastValidIndex = i;
|
|
11300
|
+
stack.pop();
|
|
11301
|
+
break;
|
|
11302
|
+
}
|
|
11303
|
+
default: {
|
|
11304
|
+
lastValidIndex = i;
|
|
11305
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11306
|
+
break;
|
|
11307
|
+
}
|
|
11308
|
+
}
|
|
11309
|
+
break;
|
|
11310
|
+
}
|
|
11311
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11312
|
+
switch (char) {
|
|
11313
|
+
case ",": {
|
|
11314
|
+
stack.pop();
|
|
11315
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11316
|
+
break;
|
|
11317
|
+
}
|
|
11318
|
+
case "]": {
|
|
11319
|
+
lastValidIndex = i;
|
|
11320
|
+
stack.pop();
|
|
11321
|
+
break;
|
|
11322
|
+
}
|
|
11323
|
+
default: {
|
|
11324
|
+
lastValidIndex = i;
|
|
11325
|
+
break;
|
|
11326
|
+
}
|
|
11327
|
+
}
|
|
11328
|
+
break;
|
|
11329
|
+
}
|
|
11330
|
+
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
11331
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11332
|
+
break;
|
|
11333
|
+
}
|
|
11334
|
+
case "INSIDE_STRING_ESCAPE": {
|
|
11335
|
+
stack.pop();
|
|
11336
|
+
lastValidIndex = i;
|
|
11337
|
+
break;
|
|
11338
|
+
}
|
|
11339
|
+
case "INSIDE_NUMBER": {
|
|
11340
|
+
switch (char) {
|
|
11341
|
+
case "0":
|
|
11342
|
+
case "1":
|
|
11343
|
+
case "2":
|
|
11344
|
+
case "3":
|
|
11345
|
+
case "4":
|
|
11346
|
+
case "5":
|
|
11347
|
+
case "6":
|
|
11348
|
+
case "7":
|
|
11349
|
+
case "8":
|
|
11350
|
+
case "9": {
|
|
11351
|
+
lastValidIndex = i;
|
|
11352
|
+
break;
|
|
11353
|
+
}
|
|
11354
|
+
case "e":
|
|
11355
|
+
case "E":
|
|
11356
|
+
case "-":
|
|
11357
|
+
case ".": {
|
|
11358
|
+
break;
|
|
11359
|
+
}
|
|
11360
|
+
case ",": {
|
|
11361
|
+
stack.pop();
|
|
11362
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11363
|
+
processAfterArrayValue(char, i);
|
|
11364
|
+
}
|
|
11365
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11366
|
+
processAfterObjectValue(char, i);
|
|
11367
|
+
}
|
|
11368
|
+
break;
|
|
11369
|
+
}
|
|
11370
|
+
case "}": {
|
|
11371
|
+
stack.pop();
|
|
11372
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11373
|
+
processAfterObjectValue(char, i);
|
|
11374
|
+
}
|
|
11375
|
+
break;
|
|
11376
|
+
}
|
|
11377
|
+
case "]": {
|
|
11378
|
+
stack.pop();
|
|
11379
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11380
|
+
processAfterArrayValue(char, i);
|
|
11381
|
+
}
|
|
11382
|
+
break;
|
|
11383
|
+
}
|
|
11384
|
+
default: {
|
|
11385
|
+
stack.pop();
|
|
11386
|
+
break;
|
|
11387
|
+
}
|
|
11388
|
+
}
|
|
11389
|
+
break;
|
|
11390
|
+
}
|
|
11391
|
+
case "INSIDE_LITERAL": {
|
|
11392
|
+
const partialLiteral = input.substring(literalStart, i + 1);
|
|
11393
|
+
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
11394
|
+
stack.pop();
|
|
11395
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11396
|
+
processAfterObjectValue(char, i);
|
|
11397
|
+
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11398
|
+
processAfterArrayValue(char, i);
|
|
11399
|
+
}
|
|
11400
|
+
} else {
|
|
11401
|
+
lastValidIndex = i;
|
|
11402
|
+
}
|
|
11403
|
+
break;
|
|
11404
|
+
}
|
|
11405
|
+
}
|
|
11406
|
+
}
|
|
11407
|
+
let result = input.slice(0, lastValidIndex + 1);
|
|
11408
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
11409
|
+
const state = stack[i];
|
|
11410
|
+
switch (state) {
|
|
11411
|
+
case "INSIDE_STRING": {
|
|
11412
|
+
result += '"';
|
|
11413
|
+
break;
|
|
11414
|
+
}
|
|
11415
|
+
case "INSIDE_OBJECT_KEY":
|
|
11416
|
+
case "INSIDE_OBJECT_AFTER_KEY":
|
|
11417
|
+
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
11418
|
+
case "INSIDE_OBJECT_START":
|
|
11419
|
+
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
11420
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11421
|
+
result += "}";
|
|
11422
|
+
break;
|
|
11423
|
+
}
|
|
11424
|
+
case "INSIDE_ARRAY_START":
|
|
11425
|
+
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
11426
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11427
|
+
result += "]";
|
|
11428
|
+
break;
|
|
11429
|
+
}
|
|
11430
|
+
case "INSIDE_LITERAL": {
|
|
11431
|
+
const partialLiteral = input.substring(literalStart, input.length);
|
|
11432
|
+
if ("true".startsWith(partialLiteral)) {
|
|
11433
|
+
result += "true".slice(partialLiteral.length);
|
|
11434
|
+
} else if ("false".startsWith(partialLiteral)) {
|
|
11435
|
+
result += "false".slice(partialLiteral.length);
|
|
11436
|
+
} else if ("null".startsWith(partialLiteral)) {
|
|
11437
|
+
result += "null".slice(partialLiteral.length);
|
|
11438
|
+
}
|
|
11439
|
+
}
|
|
11440
|
+
}
|
|
11441
|
+
}
|
|
11442
|
+
return result;
|
|
11443
|
+
}
|
|
11444
|
+
async function parsePartialJson3(jsonText) {
|
|
11445
|
+
if (jsonText === void 0) {
|
|
11446
|
+
return { value: void 0, state: "undefined-input" };
|
|
11447
|
+
}
|
|
11448
|
+
let result = await safeParseJSON3({ text: jsonText });
|
|
11449
|
+
if (result.success) {
|
|
11450
|
+
return { value: result.value, state: "successful-parse" };
|
|
11451
|
+
}
|
|
11452
|
+
result = await safeParseJSON3({ text: fixJson3(jsonText) });
|
|
11453
|
+
if (result.success) {
|
|
11454
|
+
return { value: result.value, state: "repaired-parse" };
|
|
11455
|
+
}
|
|
11456
|
+
return { value: void 0, state: "failed-parse" };
|
|
11457
|
+
}
|
|
11458
|
+
createIdGenerator3({
|
|
11459
|
+
prefix: "aitxt",
|
|
11460
|
+
size: 24
|
|
11461
|
+
});
|
|
11462
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11463
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11464
|
+
var output_exports3 = {};
|
|
11465
|
+
__export4(output_exports3, {
|
|
11466
|
+
object: () => object3,
|
|
11467
|
+
text: () => text3
|
|
11468
|
+
});
|
|
11469
|
+
var text3 = () => ({
|
|
11470
|
+
type: "text",
|
|
11471
|
+
responseFormat: { type: "text" },
|
|
11472
|
+
async parsePartial({ text: text22 }) {
|
|
11473
|
+
return { partial: text22 };
|
|
11474
|
+
},
|
|
11475
|
+
async parseOutput({ text: text22 }) {
|
|
11476
|
+
return text22;
|
|
11477
|
+
}
|
|
11478
|
+
});
|
|
11479
|
+
var object3 = ({
|
|
11480
|
+
schema: inputSchema
|
|
11481
|
+
}) => {
|
|
11482
|
+
const schema = asSchema3(inputSchema);
|
|
11483
|
+
return {
|
|
11484
|
+
type: "object",
|
|
11485
|
+
responseFormat: {
|
|
11486
|
+
type: "json",
|
|
11487
|
+
schema: schema.jsonSchema
|
|
11488
|
+
},
|
|
11489
|
+
async parsePartial({ text: text22 }) {
|
|
11490
|
+
const result = await parsePartialJson3(text22);
|
|
11491
|
+
switch (result.state) {
|
|
11492
|
+
case "failed-parse":
|
|
11493
|
+
case "undefined-input":
|
|
11494
|
+
return void 0;
|
|
11495
|
+
case "repaired-parse":
|
|
11496
|
+
case "successful-parse":
|
|
11497
|
+
return {
|
|
11498
|
+
// Note: currently no validation of partial results:
|
|
11499
|
+
partial: result.value
|
|
11500
|
+
};
|
|
11501
|
+
default: {
|
|
11502
|
+
const _exhaustiveCheck = result.state;
|
|
11503
|
+
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
11504
|
+
}
|
|
11505
|
+
}
|
|
11506
|
+
},
|
|
11507
|
+
async parseOutput({ text: text22 }, context) {
|
|
11508
|
+
const parseResult = await safeParseJSON3({ text: text22 });
|
|
11509
|
+
if (!parseResult.success) {
|
|
11510
|
+
throw new NoObjectGeneratedError3({
|
|
11511
|
+
message: "No object generated: could not parse the response.",
|
|
11512
|
+
cause: parseResult.error,
|
|
11513
|
+
text: text22,
|
|
11514
|
+
response: context.response,
|
|
11515
|
+
usage: context.usage,
|
|
11516
|
+
finishReason: context.finishReason
|
|
11517
|
+
});
|
|
11518
|
+
}
|
|
11519
|
+
const validationResult = await safeValidateTypes3({
|
|
11520
|
+
value: parseResult.value,
|
|
11521
|
+
schema
|
|
11522
|
+
});
|
|
11523
|
+
if (!validationResult.success) {
|
|
11524
|
+
throw new NoObjectGeneratedError3({
|
|
11525
|
+
message: "No object generated: response did not match schema.",
|
|
11526
|
+
cause: validationResult.error,
|
|
11527
|
+
text: text22,
|
|
11528
|
+
response: context.response,
|
|
11529
|
+
usage: context.usage,
|
|
11530
|
+
finishReason: context.finishReason
|
|
11531
|
+
});
|
|
11532
|
+
}
|
|
11533
|
+
return validationResult.value;
|
|
11534
|
+
}
|
|
11535
|
+
};
|
|
11536
|
+
};
|
|
11537
|
+
var ClientOrServerImplementationSchema3 = z$1.looseObject({
|
|
11538
|
+
name: z$1.string(),
|
|
11539
|
+
version: z$1.string()
|
|
11540
|
+
});
|
|
11541
|
+
var BaseParamsSchema3 = z$1.looseObject({
|
|
11542
|
+
_meta: z$1.optional(z$1.object({}).loose())
|
|
11543
|
+
});
|
|
11544
|
+
var ResultSchema3 = BaseParamsSchema3;
|
|
11545
|
+
var RequestSchema3 = z$1.object({
|
|
11546
|
+
method: z$1.string(),
|
|
11547
|
+
params: z$1.optional(BaseParamsSchema3)
|
|
11548
|
+
});
|
|
11549
|
+
var ServerCapabilitiesSchema3 = z$1.looseObject({
|
|
11550
|
+
experimental: z$1.optional(z$1.object({}).loose()),
|
|
11551
|
+
logging: z$1.optional(z$1.object({}).loose()),
|
|
11552
|
+
prompts: z$1.optional(
|
|
11553
|
+
z$1.looseObject({
|
|
11554
|
+
listChanged: z$1.optional(z$1.boolean())
|
|
11555
|
+
})
|
|
11556
|
+
),
|
|
11557
|
+
resources: z$1.optional(
|
|
11558
|
+
z$1.looseObject({
|
|
11559
|
+
subscribe: z$1.optional(z$1.boolean()),
|
|
11560
|
+
listChanged: z$1.optional(z$1.boolean())
|
|
11561
|
+
})
|
|
11562
|
+
),
|
|
11563
|
+
tools: z$1.optional(
|
|
11564
|
+
z$1.looseObject({
|
|
11565
|
+
listChanged: z$1.optional(z$1.boolean())
|
|
11566
|
+
})
|
|
11567
|
+
)
|
|
11568
|
+
});
|
|
11569
|
+
ResultSchema3.extend({
|
|
11570
|
+
protocolVersion: z$1.string(),
|
|
11571
|
+
capabilities: ServerCapabilitiesSchema3,
|
|
11572
|
+
serverInfo: ClientOrServerImplementationSchema3,
|
|
11573
|
+
instructions: z$1.optional(z$1.string())
|
|
11574
|
+
});
|
|
11575
|
+
var PaginatedResultSchema3 = ResultSchema3.extend({
|
|
11576
|
+
nextCursor: z$1.optional(z$1.string())
|
|
11577
|
+
});
|
|
11578
|
+
var ToolSchema3 = z$1.object({
|
|
11579
|
+
name: z$1.string(),
|
|
11580
|
+
description: z$1.optional(z$1.string()),
|
|
11581
|
+
inputSchema: z$1.object({
|
|
11582
|
+
type: z$1.literal("object"),
|
|
11583
|
+
properties: z$1.optional(z$1.object({}).loose())
|
|
11584
|
+
}).loose()
|
|
11585
|
+
}).loose();
|
|
11586
|
+
PaginatedResultSchema3.extend({
|
|
11587
|
+
tools: z$1.array(ToolSchema3)
|
|
11588
|
+
});
|
|
11589
|
+
var TextContentSchema3 = z$1.object({
|
|
11590
|
+
type: z$1.literal("text"),
|
|
11591
|
+
text: z$1.string()
|
|
11592
|
+
}).loose();
|
|
11593
|
+
var ImageContentSchema3 = z$1.object({
|
|
11594
|
+
type: z$1.literal("image"),
|
|
11595
|
+
data: z$1.base64(),
|
|
11596
|
+
mimeType: z$1.string()
|
|
11597
|
+
}).loose();
|
|
11598
|
+
var ResourceContentsSchema3 = z$1.object({
|
|
11599
|
+
/**
|
|
11600
|
+
* The URI of this resource.
|
|
11601
|
+
*/
|
|
11602
|
+
uri: z$1.string(),
|
|
11603
|
+
/**
|
|
11604
|
+
* The MIME type of this resource, if known.
|
|
11605
|
+
*/
|
|
11606
|
+
mimeType: z$1.optional(z$1.string())
|
|
11607
|
+
}).loose();
|
|
11608
|
+
var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11609
|
+
text: z$1.string()
|
|
11610
|
+
});
|
|
11611
|
+
var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11612
|
+
blob: z$1.base64()
|
|
11613
|
+
});
|
|
11614
|
+
var EmbeddedResourceSchema3 = z$1.object({
|
|
11615
|
+
type: z$1.literal("resource"),
|
|
11616
|
+
resource: z$1.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
|
|
11617
|
+
}).loose();
|
|
11618
|
+
ResultSchema3.extend({
|
|
11619
|
+
content: z$1.array(
|
|
11620
|
+
z$1.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
|
|
11621
|
+
),
|
|
11622
|
+
isError: z$1.boolean().default(false).optional()
|
|
11623
|
+
}).or(
|
|
11624
|
+
ResultSchema3.extend({
|
|
11625
|
+
toolResult: z$1.unknown()
|
|
11626
|
+
})
|
|
11627
|
+
);
|
|
11628
|
+
var JSONRPC_VERSION3 = "2.0";
|
|
11629
|
+
var JSONRPCRequestSchema3 = z$1.object({
|
|
11630
|
+
jsonrpc: z$1.literal(JSONRPC_VERSION3),
|
|
11631
|
+
id: z$1.union([z$1.string(), z$1.number().int()])
|
|
11632
|
+
}).merge(RequestSchema3).strict();
|
|
11633
|
+
var JSONRPCResponseSchema3 = z$1.object({
|
|
11634
|
+
jsonrpc: z$1.literal(JSONRPC_VERSION3),
|
|
11635
|
+
id: z$1.union([z$1.string(), z$1.number().int()]),
|
|
11636
|
+
result: ResultSchema3
|
|
11637
|
+
}).strict();
|
|
11638
|
+
var JSONRPCErrorSchema3 = z$1.object({
|
|
11639
|
+
jsonrpc: z$1.literal(JSONRPC_VERSION3),
|
|
11640
|
+
id: z$1.union([z$1.string(), z$1.number().int()]),
|
|
11641
|
+
error: z$1.object({
|
|
11642
|
+
code: z$1.number().int(),
|
|
11643
|
+
message: z$1.string(),
|
|
11644
|
+
data: z$1.optional(z$1.unknown())
|
|
11645
|
+
})
|
|
11646
|
+
}).strict();
|
|
11647
|
+
var JSONRPCNotificationSchema3 = z$1.object({
|
|
11648
|
+
jsonrpc: z$1.literal(JSONRPC_VERSION3)
|
|
11649
|
+
}).merge(
|
|
11650
|
+
z$1.object({
|
|
11651
|
+
method: z$1.string(),
|
|
11652
|
+
params: z$1.optional(BaseParamsSchema3)
|
|
11653
|
+
})
|
|
11654
|
+
).strict();
|
|
11655
|
+
z$1.union([
|
|
11656
|
+
JSONRPCRequestSchema3,
|
|
11657
|
+
JSONRPCNotificationSchema3,
|
|
11658
|
+
JSONRPCResponseSchema3,
|
|
11659
|
+
JSONRPCErrorSchema3
|
|
11660
|
+
]);
|
|
11661
|
+
var textUIPartSchema2 = z$1.object({
|
|
11662
|
+
type: z$1.literal("text"),
|
|
11663
|
+
text: z$1.string(),
|
|
11664
|
+
state: z$1.enum(["streaming", "done"]).optional(),
|
|
11665
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11666
|
+
});
|
|
11667
|
+
var reasoningUIPartSchema2 = z$1.object({
|
|
11668
|
+
type: z$1.literal("reasoning"),
|
|
11669
|
+
text: z$1.string(),
|
|
11670
|
+
state: z$1.enum(["streaming", "done"]).optional(),
|
|
11671
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11672
|
+
});
|
|
11673
|
+
var sourceUrlUIPartSchema2 = z$1.object({
|
|
11674
|
+
type: z$1.literal("source-url"),
|
|
11675
|
+
sourceId: z$1.string(),
|
|
11676
|
+
url: z$1.string(),
|
|
11677
|
+
title: z$1.string().optional(),
|
|
11678
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11679
|
+
});
|
|
11680
|
+
var sourceDocumentUIPartSchema2 = z$1.object({
|
|
11681
|
+
type: z$1.literal("source-document"),
|
|
11682
|
+
sourceId: z$1.string(),
|
|
11683
|
+
mediaType: z$1.string(),
|
|
11684
|
+
title: z$1.string(),
|
|
11685
|
+
filename: z$1.string().optional(),
|
|
11686
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11687
|
+
});
|
|
11688
|
+
var fileUIPartSchema2 = z$1.object({
|
|
11689
|
+
type: z$1.literal("file"),
|
|
11690
|
+
mediaType: z$1.string(),
|
|
11691
|
+
filename: z$1.string().optional(),
|
|
11692
|
+
url: z$1.string(),
|
|
11693
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11694
|
+
});
|
|
11695
|
+
var stepStartUIPartSchema2 = z$1.object({
|
|
11696
|
+
type: z$1.literal("step-start")
|
|
11697
|
+
});
|
|
11698
|
+
var dataUIPartSchema2 = z$1.object({
|
|
11699
|
+
type: z$1.string().startsWith("data-"),
|
|
11700
|
+
id: z$1.string().optional(),
|
|
11701
|
+
data: z$1.unknown()
|
|
11702
|
+
});
|
|
11703
|
+
var dynamicToolUIPartSchemas2 = [
|
|
11704
|
+
z$1.object({
|
|
11705
|
+
type: z$1.literal("dynamic-tool"),
|
|
11706
|
+
toolName: z$1.string(),
|
|
11707
|
+
toolCallId: z$1.string(),
|
|
11708
|
+
state: z$1.literal("input-streaming"),
|
|
11709
|
+
input: z$1.unknown().optional(),
|
|
11710
|
+
output: z$1.never().optional(),
|
|
11711
|
+
errorText: z$1.never().optional()
|
|
11712
|
+
}),
|
|
11713
|
+
z$1.object({
|
|
11714
|
+
type: z$1.literal("dynamic-tool"),
|
|
11715
|
+
toolName: z$1.string(),
|
|
11716
|
+
toolCallId: z$1.string(),
|
|
11717
|
+
state: z$1.literal("input-available"),
|
|
11718
|
+
input: z$1.unknown(),
|
|
11719
|
+
output: z$1.never().optional(),
|
|
11720
|
+
errorText: z$1.never().optional(),
|
|
11721
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11722
|
+
}),
|
|
11723
|
+
z$1.object({
|
|
11724
|
+
type: z$1.literal("dynamic-tool"),
|
|
11725
|
+
toolName: z$1.string(),
|
|
11726
|
+
toolCallId: z$1.string(),
|
|
11727
|
+
state: z$1.literal("output-available"),
|
|
11728
|
+
input: z$1.unknown(),
|
|
11729
|
+
output: z$1.unknown(),
|
|
11730
|
+
errorText: z$1.never().optional(),
|
|
11731
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11732
|
+
preliminary: z$1.boolean().optional()
|
|
11733
|
+
}),
|
|
11734
|
+
z$1.object({
|
|
11735
|
+
type: z$1.literal("dynamic-tool"),
|
|
11736
|
+
toolName: z$1.string(),
|
|
11737
|
+
toolCallId: z$1.string(),
|
|
11738
|
+
state: z$1.literal("output-error"),
|
|
11739
|
+
input: z$1.unknown(),
|
|
11740
|
+
output: z$1.never().optional(),
|
|
11741
|
+
errorText: z$1.string(),
|
|
11742
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11743
|
+
})
|
|
11744
|
+
];
|
|
11745
|
+
var toolUIPartSchemas2 = [
|
|
11746
|
+
z$1.object({
|
|
11747
|
+
type: z$1.string().startsWith("tool-"),
|
|
11748
|
+
toolCallId: z$1.string(),
|
|
11749
|
+
state: z$1.literal("input-streaming"),
|
|
11750
|
+
input: z$1.unknown().optional(),
|
|
11751
|
+
output: z$1.never().optional(),
|
|
11752
|
+
errorText: z$1.never().optional()
|
|
11753
|
+
}),
|
|
11754
|
+
z$1.object({
|
|
11755
|
+
type: z$1.string().startsWith("tool-"),
|
|
11756
|
+
toolCallId: z$1.string(),
|
|
11757
|
+
state: z$1.literal("input-available"),
|
|
11758
|
+
input: z$1.unknown(),
|
|
11759
|
+
output: z$1.never().optional(),
|
|
11760
|
+
errorText: z$1.never().optional(),
|
|
11761
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11762
|
+
}),
|
|
11763
|
+
z$1.object({
|
|
11764
|
+
type: z$1.string().startsWith("tool-"),
|
|
11765
|
+
toolCallId: z$1.string(),
|
|
11766
|
+
state: z$1.literal("output-available"),
|
|
11767
|
+
input: z$1.unknown(),
|
|
11768
|
+
output: z$1.unknown(),
|
|
11769
|
+
errorText: z$1.never().optional(),
|
|
11770
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11771
|
+
preliminary: z$1.boolean().optional()
|
|
11772
|
+
}),
|
|
11773
|
+
z$1.object({
|
|
11774
|
+
type: z$1.string().startsWith("tool-"),
|
|
11775
|
+
toolCallId: z$1.string(),
|
|
11776
|
+
state: z$1.literal("output-error"),
|
|
11777
|
+
input: z$1.unknown(),
|
|
11778
|
+
output: z$1.never().optional(),
|
|
11779
|
+
errorText: z$1.string(),
|
|
11780
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11781
|
+
})
|
|
11782
|
+
];
|
|
11783
|
+
z$1.object({
|
|
11784
|
+
id: z$1.string(),
|
|
11785
|
+
role: z$1.enum(["system", "user", "assistant"]),
|
|
11786
|
+
metadata: z$1.unknown().optional(),
|
|
11787
|
+
parts: z$1.array(
|
|
11788
|
+
z$1.union([
|
|
11789
|
+
textUIPartSchema2,
|
|
11790
|
+
reasoningUIPartSchema2,
|
|
11791
|
+
sourceUrlUIPartSchema2,
|
|
11792
|
+
sourceDocumentUIPartSchema2,
|
|
11793
|
+
fileUIPartSchema2,
|
|
11794
|
+
stepStartUIPartSchema2,
|
|
11795
|
+
dataUIPartSchema2,
|
|
11796
|
+
...dynamicToolUIPartSchemas2,
|
|
11797
|
+
...toolUIPartSchemas2
|
|
11798
|
+
])
|
|
11799
|
+
)
|
|
11800
|
+
});
|
|
11801
|
+
|
|
11802
|
+
// ../agent-builder/dist/index.js
|
|
9481
11803
|
var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
|
|
9482
11804
|
var TemplateUnitSchema = z.object({
|
|
9483
11805
|
kind: z.enum(UNIT_KINDS),
|
|
@@ -11672,14 +13994,14 @@ export const mastra = new Mastra({
|
|
|
11672
13994
|
noEmit: true
|
|
11673
13995
|
};
|
|
11674
13996
|
const host = {
|
|
11675
|
-
getSourceFile: (
|
|
13997
|
+
getSourceFile: (name20) => name20 === fileName ? sourceFile : void 0,
|
|
11676
13998
|
writeFile: () => {
|
|
11677
13999
|
},
|
|
11678
14000
|
getCurrentDirectory: () => "",
|
|
11679
14001
|
getDirectories: () => [],
|
|
11680
|
-
fileExists: (
|
|
11681
|
-
readFile: (
|
|
11682
|
-
getCanonicalFileName: (
|
|
14002
|
+
fileExists: (name20) => name20 === fileName,
|
|
14003
|
+
readFile: (name20) => name20 === fileName ? fileContent : void 0,
|
|
14004
|
+
getCanonicalFileName: (name20) => name20,
|
|
11683
14005
|
useCaseSensitiveFileNames: () => true,
|
|
11684
14006
|
getNewLine: () => "\n",
|
|
11685
14007
|
getDefaultLibFileName: () => "lib.d.ts"
|
|
@@ -13059,25 +15381,25 @@ var packageMergeStep = createStep({
|
|
|
13059
15381
|
const tplDevDeps = ensureObj(packageInfo.devDependencies);
|
|
13060
15382
|
const tplPeerDeps = ensureObj(packageInfo.peerDependencies);
|
|
13061
15383
|
const tplScripts = ensureObj(packageInfo.scripts);
|
|
13062
|
-
const existsAnywhere = (
|
|
13063
|
-
for (const [
|
|
13064
|
-
if (!existsAnywhere(
|
|
13065
|
-
targetPkg.dependencies[
|
|
15384
|
+
const existsAnywhere = (name20) => name20 in targetPkg.dependencies || name20 in targetPkg.devDependencies || name20 in targetPkg.peerDependencies;
|
|
15385
|
+
for (const [name20, ver] of Object.entries(tplDeps)) {
|
|
15386
|
+
if (!existsAnywhere(name20)) {
|
|
15387
|
+
targetPkg.dependencies[name20] = String(ver);
|
|
13066
15388
|
}
|
|
13067
15389
|
}
|
|
13068
|
-
for (const [
|
|
13069
|
-
if (!existsAnywhere(
|
|
13070
|
-
targetPkg.devDependencies[
|
|
15390
|
+
for (const [name20, ver] of Object.entries(tplDevDeps)) {
|
|
15391
|
+
if (!existsAnywhere(name20)) {
|
|
15392
|
+
targetPkg.devDependencies[name20] = String(ver);
|
|
13071
15393
|
}
|
|
13072
15394
|
}
|
|
13073
|
-
for (const [
|
|
13074
|
-
if (!(
|
|
13075
|
-
targetPkg.peerDependencies[
|
|
15395
|
+
for (const [name20, ver] of Object.entries(tplPeerDeps)) {
|
|
15396
|
+
if (!(name20 in targetPkg.peerDependencies)) {
|
|
15397
|
+
targetPkg.peerDependencies[name20] = String(ver);
|
|
13076
15398
|
}
|
|
13077
15399
|
}
|
|
13078
15400
|
const prefix = `template:${slug}:`;
|
|
13079
|
-
for (const [
|
|
13080
|
-
const newKey = `${prefix}${
|
|
15401
|
+
for (const [name20, cmd] of Object.entries(tplScripts)) {
|
|
15402
|
+
const newKey = `${prefix}${name20}`;
|
|
13081
15403
|
if (!(newKey in targetPkg.scripts)) {
|
|
13082
15404
|
targetPkg.scripts[newKey] = String(cmd);
|
|
13083
15405
|
}
|
|
@@ -13162,9 +15484,9 @@ var programmaticFileCopyStep = createStep({
|
|
|
13162
15484
|
return "unknown";
|
|
13163
15485
|
}
|
|
13164
15486
|
};
|
|
13165
|
-
const convertNaming = (
|
|
13166
|
-
const baseName = basename(
|
|
13167
|
-
const ext = extname(
|
|
15487
|
+
const convertNaming = (name20, convention) => {
|
|
15488
|
+
const baseName = basename(name20, extname(name20));
|
|
15489
|
+
const ext = extname(name20);
|
|
13168
15490
|
switch (convention) {
|
|
13169
15491
|
case "camelCase":
|
|
13170
15492
|
return baseName.replace(/[-_]/g, "").replace(/([A-Z])/g, (match, p1, offset) => offset === 0 ? p1.toLowerCase() : p1) + ext;
|
|
@@ -13175,7 +15497,7 @@ var programmaticFileCopyStep = createStep({
|
|
|
13175
15497
|
case "PascalCase":
|
|
13176
15498
|
return baseName.replace(/[-_]/g, "").replace(/^[a-z]/, (match) => match.toUpperCase()) + ext;
|
|
13177
15499
|
default:
|
|
13178
|
-
return
|
|
15500
|
+
return name20;
|
|
13179
15501
|
}
|
|
13180
15502
|
};
|
|
13181
15503
|
for (const unit of orderedUnits) {
|
|
@@ -15667,5 +17989,5 @@ var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
|
|
|
15667
17989
|
);
|
|
15668
17990
|
|
|
15669
17991
|
export { agent_builder_exports, cancelAgentBuilderActionRunHandler, createAgentBuilderActionRunHandler, getAgentBuilderActionByIdHandler, getAgentBuilderActionRunByIdHandler, getAgentBuilderActionRunExecutionResultHandler, getAgentBuilderActionRunsHandler, getAgentBuilderActionsHandler, resumeAgentBuilderActionHandler, resumeAsyncAgentBuilderActionHandler, sendAgentBuilderActionRunEventHandler, startAgentBuilderActionRunHandler, startAsyncAgentBuilderActionHandler, streamAgentBuilderActionHandler, streamVNextAgentBuilderActionHandler, watchAgentBuilderActionHandler };
|
|
15670
|
-
//# sourceMappingURL=chunk-
|
|
15671
|
-
//# sourceMappingURL=chunk-
|
|
17992
|
+
//# sourceMappingURL=chunk-7XNKAVVA.js.map
|
|
17993
|
+
//# sourceMappingURL=chunk-7XNKAVVA.js.map
|