@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
|
@@ -167,8 +167,8 @@ var require_ignore = chunkEMMSS5I5_cjs.__commonJS({
|
|
|
167
167
|
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
168
168
|
}
|
|
169
169
|
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
170
|
-
var define = (
|
|
171
|
-
Object.defineProperty(
|
|
170
|
+
var define = (object4, key, value) => {
|
|
171
|
+
Object.defineProperty(object4, key, { value });
|
|
172
172
|
return value;
|
|
173
173
|
};
|
|
174
174
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
@@ -620,10 +620,10 @@ chunkEMMSS5I5_cjs.__export(agent_builder_exports, {
|
|
|
620
620
|
streamVNextAgentBuilderActionHandler: () => streamVNextAgentBuilderActionHandler,
|
|
621
621
|
watchAgentBuilderActionHandler: () => watchAgentBuilderActionHandler
|
|
622
622
|
});
|
|
623
|
-
function zodToJsonSchema(
|
|
623
|
+
function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relative") {
|
|
624
624
|
const fn = "toJSONSchema";
|
|
625
625
|
if (fn in zod.z) {
|
|
626
|
-
return zod.z[fn](
|
|
626
|
+
return zod.z[fn](zodSchema4, {
|
|
627
627
|
unrepresentable: "any",
|
|
628
628
|
override: (ctx) => {
|
|
629
629
|
const def = ctx.zodSchema?._zod?.def;
|
|
@@ -634,7 +634,7 @@ function zodToJsonSchema(zodSchema3, target = "jsonSchema7", strategy = "relativ
|
|
|
634
634
|
}
|
|
635
635
|
});
|
|
636
636
|
} else {
|
|
637
|
-
return chunkHVBBFCDH_cjs.esm_default(
|
|
637
|
+
return chunkHVBBFCDH_cjs.esm_default(zodSchema4, {
|
|
638
638
|
$refStrategy: strategy,
|
|
639
639
|
target
|
|
640
640
|
});
|
|
@@ -1234,8 +1234,8 @@ function formatDataStreamPart(type, value) {
|
|
|
1234
1234
|
`;
|
|
1235
1235
|
}
|
|
1236
1236
|
function zodSchema(zodSchema22, options) {
|
|
1237
|
-
var
|
|
1238
|
-
const useReferences = (
|
|
1237
|
+
var _a20;
|
|
1238
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
1239
1239
|
return jsonSchema(
|
|
1240
1240
|
chunkHVBBFCDH_cjs.esm_default(zodSchema22, {
|
|
1241
1241
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -1348,11 +1348,11 @@ var major = VERSION.split(".")[0];
|
|
|
1348
1348
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
1349
1349
|
var _global = _globalThis;
|
|
1350
1350
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
1351
|
-
var
|
|
1351
|
+
var _a20;
|
|
1352
1352
|
if (allowOverride === void 0) {
|
|
1353
1353
|
allowOverride = false;
|
|
1354
1354
|
}
|
|
1355
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
1355
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a20 !== void 0 ? _a20 : {
|
|
1356
1356
|
version: VERSION
|
|
1357
1357
|
};
|
|
1358
1358
|
if (!allowOverride && api[type]) {
|
|
@@ -1370,8 +1370,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
1370
1370
|
return true;
|
|
1371
1371
|
}
|
|
1372
1372
|
function getGlobal(type) {
|
|
1373
|
-
var
|
|
1374
|
-
var globalVersion = (
|
|
1373
|
+
var _a20, _b8;
|
|
1374
|
+
var globalVersion = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a20 === void 0 ? void 0 : _a20.version;
|
|
1375
1375
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1376
1376
|
return;
|
|
1377
1377
|
}
|
|
@@ -1548,13 +1548,13 @@ var DiagAPI = (
|
|
|
1548
1548
|
}
|
|
1549
1549
|
var self = this;
|
|
1550
1550
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1551
|
-
var
|
|
1551
|
+
var _a20, _b8, _c;
|
|
1552
1552
|
if (optionsOrLogLevel === void 0) {
|
|
1553
1553
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1554
1554
|
}
|
|
1555
1555
|
if (logger === self) {
|
|
1556
1556
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
1557
|
-
self.error((
|
|
1557
|
+
self.error((_a20 = err.stack) !== null && _a20 !== void 0 ? _a20 : err.message);
|
|
1558
1558
|
return false;
|
|
1559
1559
|
}
|
|
1560
1560
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -1725,12 +1725,12 @@ var ContextAPI = (
|
|
|
1725
1725
|
return this._getContextManager().active();
|
|
1726
1726
|
};
|
|
1727
1727
|
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
1728
|
-
var
|
|
1728
|
+
var _a20;
|
|
1729
1729
|
var args = [];
|
|
1730
1730
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1731
1731
|
args[_i - 3] = arguments[_i];
|
|
1732
1732
|
}
|
|
1733
|
-
return (
|
|
1733
|
+
return (_a20 = this._getContextManager()).with.apply(_a20, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
1734
1734
|
};
|
|
1735
1735
|
ContextAPI2.prototype.bind = function(context, target) {
|
|
1736
1736
|
return this._getContextManager().bind(context, target);
|
|
@@ -1825,8 +1825,8 @@ function setSpanContext(context, spanContext) {
|
|
|
1825
1825
|
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
1826
1826
|
}
|
|
1827
1827
|
function getSpanContext(context) {
|
|
1828
|
-
var
|
|
1829
|
-
return (
|
|
1828
|
+
var _a20;
|
|
1829
|
+
return (_a20 = getSpan(context)) === null || _a20 === void 0 ? void 0 : _a20.spanContext();
|
|
1830
1830
|
}
|
|
1831
1831
|
|
|
1832
1832
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
@@ -1852,7 +1852,7 @@ var NoopTracer = (
|
|
|
1852
1852
|
(function() {
|
|
1853
1853
|
function NoopTracer2() {
|
|
1854
1854
|
}
|
|
1855
|
-
NoopTracer2.prototype.startSpan = function(
|
|
1855
|
+
NoopTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1856
1856
|
if (context === void 0) {
|
|
1857
1857
|
context = contextApi.active();
|
|
1858
1858
|
}
|
|
@@ -1867,7 +1867,7 @@ var NoopTracer = (
|
|
|
1867
1867
|
return new NonRecordingSpan();
|
|
1868
1868
|
}
|
|
1869
1869
|
};
|
|
1870
|
-
NoopTracer2.prototype.startActiveSpan = function(
|
|
1870
|
+
NoopTracer2.prototype.startActiveSpan = function(name20, arg2, arg3, arg4) {
|
|
1871
1871
|
var opts;
|
|
1872
1872
|
var ctx;
|
|
1873
1873
|
var fn;
|
|
@@ -1884,7 +1884,7 @@ var NoopTracer = (
|
|
|
1884
1884
|
fn = arg4;
|
|
1885
1885
|
}
|
|
1886
1886
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1887
|
-
var span = this.startSpan(
|
|
1887
|
+
var span = this.startSpan(name20, opts, parentContext);
|
|
1888
1888
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1889
1889
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1890
1890
|
};
|
|
@@ -1900,14 +1900,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
1900
1900
|
var ProxyTracer = (
|
|
1901
1901
|
/** @class */
|
|
1902
1902
|
(function() {
|
|
1903
|
-
function ProxyTracer2(_provider,
|
|
1903
|
+
function ProxyTracer2(_provider, name20, version, options) {
|
|
1904
1904
|
this._provider = _provider;
|
|
1905
|
-
this.name =
|
|
1905
|
+
this.name = name20;
|
|
1906
1906
|
this.version = version;
|
|
1907
1907
|
this.options = options;
|
|
1908
1908
|
}
|
|
1909
|
-
ProxyTracer2.prototype.startSpan = function(
|
|
1910
|
-
return this._getTracer().startSpan(
|
|
1909
|
+
ProxyTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1910
|
+
return this._getTracer().startSpan(name20, options, context);
|
|
1911
1911
|
};
|
|
1912
1912
|
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1913
1913
|
var tracer = this._getTracer();
|
|
@@ -1948,20 +1948,20 @@ var ProxyTracerProvider = (
|
|
|
1948
1948
|
(function() {
|
|
1949
1949
|
function ProxyTracerProvider2() {
|
|
1950
1950
|
}
|
|
1951
|
-
ProxyTracerProvider2.prototype.getTracer = function(
|
|
1952
|
-
var
|
|
1953
|
-
return (
|
|
1951
|
+
ProxyTracerProvider2.prototype.getTracer = function(name20, version, options) {
|
|
1952
|
+
var _a20;
|
|
1953
|
+
return (_a20 = this.getDelegateTracer(name20, version, options)) !== null && _a20 !== void 0 ? _a20 : new ProxyTracer(this, name20, version, options);
|
|
1954
1954
|
};
|
|
1955
1955
|
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1956
|
-
var
|
|
1957
|
-
return (
|
|
1956
|
+
var _a20;
|
|
1957
|
+
return (_a20 = this._delegate) !== null && _a20 !== void 0 ? _a20 : NOOP_TRACER_PROVIDER;
|
|
1958
1958
|
};
|
|
1959
1959
|
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1960
1960
|
this._delegate = delegate;
|
|
1961
1961
|
};
|
|
1962
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(
|
|
1963
|
-
var
|
|
1964
|
-
return (
|
|
1962
|
+
ProxyTracerProvider2.prototype.getDelegateTracer = function(name20, version, options) {
|
|
1963
|
+
var _a20;
|
|
1964
|
+
return (_a20 = this._delegate) === null || _a20 === void 0 ? void 0 : _a20.getTracer(name20, version, options);
|
|
1965
1965
|
};
|
|
1966
1966
|
return ProxyTracerProvider2;
|
|
1967
1967
|
})()
|
|
@@ -2007,8 +2007,8 @@ var TraceAPI = (
|
|
|
2007
2007
|
TraceAPI2.prototype.getTracerProvider = function() {
|
|
2008
2008
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
2009
2009
|
};
|
|
2010
|
-
TraceAPI2.prototype.getTracer = function(
|
|
2011
|
-
return this.getTracerProvider().getTracer(
|
|
2010
|
+
TraceAPI2.prototype.getTracer = function(name20, version) {
|
|
2011
|
+
return this.getTracerProvider().getTracer(name20, version);
|
|
2012
2012
|
};
|
|
2013
2013
|
TraceAPI2.prototype.disable = function() {
|
|
2014
2014
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -3204,6 +3204,39 @@ function createAbortError() {
|
|
|
3204
3204
|
function extractResponseHeaders(response) {
|
|
3205
3205
|
return Object.fromEntries([...response.headers]);
|
|
3206
3206
|
}
|
|
3207
|
+
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
3208
|
+
var _a20, _b8, _c;
|
|
3209
|
+
if (globalThisAny.window) {
|
|
3210
|
+
return `runtime/browser`;
|
|
3211
|
+
}
|
|
3212
|
+
if ((_a20 = globalThisAny.navigator) == null ? void 0 : _a20.userAgent) {
|
|
3213
|
+
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
3214
|
+
}
|
|
3215
|
+
if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
|
|
3216
|
+
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
3217
|
+
}
|
|
3218
|
+
if (globalThisAny.EdgeRuntime) {
|
|
3219
|
+
return `runtime/vercel-edge`;
|
|
3220
|
+
}
|
|
3221
|
+
return "runtime/unknown";
|
|
3222
|
+
}
|
|
3223
|
+
function removeUndefinedEntries(record) {
|
|
3224
|
+
return Object.fromEntries(
|
|
3225
|
+
Object.entries(record).filter(([_key, value]) => value != null)
|
|
3226
|
+
);
|
|
3227
|
+
}
|
|
3228
|
+
function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
3229
|
+
const cleanedHeaders = removeUndefinedEntries(
|
|
3230
|
+
headers != null ? headers : {}
|
|
3231
|
+
);
|
|
3232
|
+
const normalizedHeaders = new Headers(cleanedHeaders);
|
|
3233
|
+
const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
|
|
3234
|
+
normalizedHeaders.set(
|
|
3235
|
+
"user-agent",
|
|
3236
|
+
[currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
|
|
3237
|
+
);
|
|
3238
|
+
return Object.fromEntries(normalizedHeaders);
|
|
3239
|
+
}
|
|
3207
3240
|
var createIdGenerator2 = ({
|
|
3208
3241
|
prefix,
|
|
3209
3242
|
size = 16,
|
|
@@ -3270,11 +3303,7 @@ function handleFetchError({
|
|
|
3270
3303
|
}
|
|
3271
3304
|
return error;
|
|
3272
3305
|
}
|
|
3273
|
-
|
|
3274
|
-
return Object.fromEntries(
|
|
3275
|
-
Object.entries(record).filter(([_key, value]) => value != null)
|
|
3276
|
-
);
|
|
3277
|
-
}
|
|
3306
|
+
var VERSION2 = "3.0.9" ;
|
|
3278
3307
|
var getOriginalFetch = () => globalThis.fetch;
|
|
3279
3308
|
var getFromApi = async ({
|
|
3280
3309
|
url,
|
|
@@ -3287,7 +3316,11 @@ var getFromApi = async ({
|
|
|
3287
3316
|
try {
|
|
3288
3317
|
const response = await fetch2(url, {
|
|
3289
3318
|
method: "GET",
|
|
3290
|
-
headers:
|
|
3319
|
+
headers: withUserAgentSuffix(
|
|
3320
|
+
headers,
|
|
3321
|
+
`ai-sdk/provider-utils/${VERSION2}`,
|
|
3322
|
+
getRuntimeEnvironmentUserAgent()
|
|
3323
|
+
),
|
|
3291
3324
|
signal: abortSignal
|
|
3292
3325
|
});
|
|
3293
3326
|
const responseHeaders = extractResponseHeaders(response);
|
|
@@ -3357,12 +3390,12 @@ function loadOptionalSetting({
|
|
|
3357
3390
|
}
|
|
3358
3391
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
3359
3392
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
3360
|
-
function _parse(
|
|
3361
|
-
const obj = JSON.parse(
|
|
3393
|
+
function _parse(text4) {
|
|
3394
|
+
const obj = JSON.parse(text4);
|
|
3362
3395
|
if (obj === null || typeof obj !== "object") {
|
|
3363
3396
|
return obj;
|
|
3364
3397
|
}
|
|
3365
|
-
if (suspectProtoRx.test(
|
|
3398
|
+
if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
|
|
3366
3399
|
return obj;
|
|
3367
3400
|
}
|
|
3368
3401
|
return filter(obj);
|
|
@@ -3389,11 +3422,11 @@ function filter(obj) {
|
|
|
3389
3422
|
}
|
|
3390
3423
|
return obj;
|
|
3391
3424
|
}
|
|
3392
|
-
function secureJsonParse(
|
|
3425
|
+
function secureJsonParse(text4) {
|
|
3393
3426
|
const { stackTraceLimit } = Error;
|
|
3394
3427
|
Error.stackTraceLimit = 0;
|
|
3395
3428
|
try {
|
|
3396
|
-
return _parse(
|
|
3429
|
+
return _parse(text4);
|
|
3397
3430
|
} finally {
|
|
3398
3431
|
Error.stackTraceLimit = stackTraceLimit;
|
|
3399
3432
|
}
|
|
@@ -3434,12 +3467,12 @@ async function safeValidateTypes2({
|
|
|
3434
3467
|
value,
|
|
3435
3468
|
schema
|
|
3436
3469
|
}) {
|
|
3437
|
-
const
|
|
3470
|
+
const validator22 = asValidator(schema);
|
|
3438
3471
|
try {
|
|
3439
|
-
if (
|
|
3472
|
+
if (validator22.validate == null) {
|
|
3440
3473
|
return { success: true, value, rawValue: value };
|
|
3441
3474
|
}
|
|
3442
|
-
const result = await
|
|
3475
|
+
const result = await validator22.validate(value);
|
|
3443
3476
|
if (result.success) {
|
|
3444
3477
|
return { success: true, value: result.value, rawValue: value };
|
|
3445
3478
|
}
|
|
@@ -3457,11 +3490,11 @@ async function safeValidateTypes2({
|
|
|
3457
3490
|
}
|
|
3458
3491
|
}
|
|
3459
3492
|
async function parseJSON({
|
|
3460
|
-
text:
|
|
3493
|
+
text: text4,
|
|
3461
3494
|
schema
|
|
3462
3495
|
}) {
|
|
3463
3496
|
try {
|
|
3464
|
-
const value = secureJsonParse(
|
|
3497
|
+
const value = secureJsonParse(text4);
|
|
3465
3498
|
if (schema == null) {
|
|
3466
3499
|
return value;
|
|
3467
3500
|
}
|
|
@@ -3470,15 +3503,15 @@ async function parseJSON({
|
|
|
3470
3503
|
if (chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) || chunkHVBBFCDH_cjs.TypeValidationError.isInstance(error)) {
|
|
3471
3504
|
throw error;
|
|
3472
3505
|
}
|
|
3473
|
-
throw new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3506
|
+
throw new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error });
|
|
3474
3507
|
}
|
|
3475
3508
|
}
|
|
3476
3509
|
async function safeParseJSON2({
|
|
3477
|
-
text:
|
|
3510
|
+
text: text4,
|
|
3478
3511
|
schema
|
|
3479
3512
|
}) {
|
|
3480
3513
|
try {
|
|
3481
|
-
const value = secureJsonParse(
|
|
3514
|
+
const value = secureJsonParse(text4);
|
|
3482
3515
|
if (schema == null) {
|
|
3483
3516
|
return { success: true, value, rawValue: value };
|
|
3484
3517
|
}
|
|
@@ -3486,7 +3519,7 @@ async function safeParseJSON2({
|
|
|
3486
3519
|
} catch (error) {
|
|
3487
3520
|
return {
|
|
3488
3521
|
success: false,
|
|
3489
|
-
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3522
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
3490
3523
|
rawValue: void 0
|
|
3491
3524
|
};
|
|
3492
3525
|
}
|
|
@@ -3542,7 +3575,11 @@ var postToApi = async ({
|
|
|
3542
3575
|
try {
|
|
3543
3576
|
const response = await fetch2(url, {
|
|
3544
3577
|
method: "POST",
|
|
3545
|
-
headers:
|
|
3578
|
+
headers: withUserAgentSuffix(
|
|
3579
|
+
headers,
|
|
3580
|
+
`ai-sdk/provider-utils/${VERSION2}`,
|
|
3581
|
+
getRuntimeEnvironmentUserAgent()
|
|
3582
|
+
),
|
|
3546
3583
|
body: body.content,
|
|
3547
3584
|
signal: abortSignal
|
|
3548
3585
|
});
|
|
@@ -3735,11 +3772,11 @@ function parseAnyDef() {
|
|
|
3735
3772
|
return {};
|
|
3736
3773
|
}
|
|
3737
3774
|
function parseArrayDef(def, refs) {
|
|
3738
|
-
var
|
|
3775
|
+
var _a20, _b8, _c;
|
|
3739
3776
|
const res = {
|
|
3740
3777
|
type: "array"
|
|
3741
3778
|
};
|
|
3742
|
-
if (((
|
|
3779
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
3743
3780
|
res.items = parseDef(def.type._def, {
|
|
3744
3781
|
...refs,
|
|
3745
3782
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -4100,8 +4137,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
4100
4137
|
return result;
|
|
4101
4138
|
}
|
|
4102
4139
|
function addFormat(schema, value, message, refs) {
|
|
4103
|
-
var
|
|
4104
|
-
if (schema.format || ((
|
|
4140
|
+
var _a20;
|
|
4141
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
4105
4142
|
if (!schema.anyOf) {
|
|
4106
4143
|
schema.anyOf = [];
|
|
4107
4144
|
}
|
|
@@ -4120,8 +4157,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
4120
4157
|
}
|
|
4121
4158
|
}
|
|
4122
4159
|
function addPattern(schema, regex, message, refs) {
|
|
4123
|
-
var
|
|
4124
|
-
if (schema.pattern || ((
|
|
4160
|
+
var _a20;
|
|
4161
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
4125
4162
|
if (!schema.allOf) {
|
|
4126
4163
|
schema.allOf = [];
|
|
4127
4164
|
}
|
|
@@ -4140,7 +4177,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
4140
4177
|
}
|
|
4141
4178
|
}
|
|
4142
4179
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
4143
|
-
var
|
|
4180
|
+
var _a20;
|
|
4144
4181
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
4145
4182
|
return regex.source;
|
|
4146
4183
|
}
|
|
@@ -4170,7 +4207,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4170
4207
|
pattern += source[i];
|
|
4171
4208
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
4172
4209
|
inCharRange = false;
|
|
4173
|
-
} else if (source[i + 1] === "-" && ((
|
|
4210
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
4174
4211
|
pattern += source[i];
|
|
4175
4212
|
inCharRange = true;
|
|
4176
4213
|
} else {
|
|
@@ -4212,13 +4249,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4212
4249
|
return pattern;
|
|
4213
4250
|
}
|
|
4214
4251
|
function parseRecordDef(def, refs) {
|
|
4215
|
-
var
|
|
4252
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
4216
4253
|
const schema = {
|
|
4217
4254
|
type: "object",
|
|
4218
|
-
additionalProperties: (
|
|
4255
|
+
additionalProperties: (_a20 = parseDef(def.valueType._def, {
|
|
4219
4256
|
...refs,
|
|
4220
4257
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
4221
|
-
})) != null ?
|
|
4258
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
4222
4259
|
};
|
|
4223
4260
|
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
4224
4261
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -4269,11 +4306,11 @@ function parseMapDef(def, refs) {
|
|
|
4269
4306
|
};
|
|
4270
4307
|
}
|
|
4271
4308
|
function parseNativeEnumDef(def) {
|
|
4272
|
-
const
|
|
4309
|
+
const object4 = def.values;
|
|
4273
4310
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
4274
|
-
return typeof
|
|
4311
|
+
return typeof object4[object4[key]] !== "number";
|
|
4275
4312
|
});
|
|
4276
|
-
const actualValues = actualKeys.map((key) =>
|
|
4313
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
4277
4314
|
const parsedTypes = Array.from(
|
|
4278
4315
|
new Set(actualValues.map((values) => typeof values))
|
|
4279
4316
|
);
|
|
@@ -4477,8 +4514,8 @@ function safeIsOptional(schema) {
|
|
|
4477
4514
|
}
|
|
4478
4515
|
}
|
|
4479
4516
|
var parseOptionalDef = (def, refs) => {
|
|
4480
|
-
var
|
|
4481
|
-
if (refs.currentPath.toString() === ((
|
|
4517
|
+
var _a20;
|
|
4518
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
4482
4519
|
return parseDef(def.innerType._def, refs);
|
|
4483
4520
|
}
|
|
4484
4521
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -4648,10 +4685,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
4648
4685
|
}
|
|
4649
4686
|
};
|
|
4650
4687
|
function parseDef(def, refs, forceResolution = false) {
|
|
4651
|
-
var
|
|
4688
|
+
var _a20;
|
|
4652
4689
|
const seenItem = refs.seen.get(def);
|
|
4653
4690
|
if (refs.override) {
|
|
4654
|
-
const overrideResult = (
|
|
4691
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
4655
4692
|
refs,
|
|
4656
4693
|
def,
|
|
4657
4694
|
refs,
|
|
@@ -4717,11 +4754,11 @@ var getRefs = (options) => {
|
|
|
4717
4754
|
currentPath,
|
|
4718
4755
|
propertyPath: void 0,
|
|
4719
4756
|
seen: new Map(
|
|
4720
|
-
Object.entries(_options.definitions).map(([
|
|
4757
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
4721
4758
|
def._def,
|
|
4722
4759
|
{
|
|
4723
4760
|
def: def._def,
|
|
4724
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
4761
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
4725
4762
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
4726
4763
|
jsonSchema: void 0
|
|
4727
4764
|
}
|
|
@@ -4730,50 +4767,50 @@ var getRefs = (options) => {
|
|
|
4730
4767
|
};
|
|
4731
4768
|
};
|
|
4732
4769
|
var zodToJsonSchema2 = (schema, options) => {
|
|
4733
|
-
var
|
|
4770
|
+
var _a20;
|
|
4734
4771
|
const refs = getRefs(options);
|
|
4735
4772
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
4736
|
-
(acc, [
|
|
4737
|
-
var
|
|
4773
|
+
(acc, [name25, schema2]) => {
|
|
4774
|
+
var _a25;
|
|
4738
4775
|
return {
|
|
4739
4776
|
...acc,
|
|
4740
|
-
[
|
|
4777
|
+
[name25]: (_a25 = parseDef(
|
|
4741
4778
|
schema2._def,
|
|
4742
4779
|
{
|
|
4743
4780
|
...refs,
|
|
4744
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4781
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
4745
4782
|
},
|
|
4746
4783
|
true
|
|
4747
|
-
)) != null ?
|
|
4784
|
+
)) != null ? _a25 : parseAnyDef()
|
|
4748
4785
|
};
|
|
4749
4786
|
},
|
|
4750
4787
|
{}
|
|
4751
4788
|
) : void 0;
|
|
4752
|
-
const
|
|
4753
|
-
const main = (
|
|
4789
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
4790
|
+
const main = (_a20 = parseDef(
|
|
4754
4791
|
schema._def,
|
|
4755
|
-
|
|
4792
|
+
name20 === void 0 ? refs : {
|
|
4756
4793
|
...refs,
|
|
4757
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4794
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
4758
4795
|
},
|
|
4759
4796
|
false
|
|
4760
|
-
)) != null ?
|
|
4797
|
+
)) != null ? _a20 : parseAnyDef();
|
|
4761
4798
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
4762
4799
|
if (title !== void 0) {
|
|
4763
4800
|
main.title = title;
|
|
4764
4801
|
}
|
|
4765
|
-
const combined =
|
|
4802
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
4766
4803
|
...main,
|
|
4767
4804
|
[refs.definitionPath]: definitions
|
|
4768
4805
|
} : main : {
|
|
4769
4806
|
$ref: [
|
|
4770
4807
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
4771
4808
|
refs.definitionPath,
|
|
4772
|
-
|
|
4809
|
+
name20
|
|
4773
4810
|
].join("/"),
|
|
4774
4811
|
[refs.definitionPath]: {
|
|
4775
4812
|
...definitions,
|
|
4776
|
-
[
|
|
4813
|
+
[name20]: main
|
|
4777
4814
|
}
|
|
4778
4815
|
};
|
|
4779
4816
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -4781,8 +4818,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
4781
4818
|
};
|
|
4782
4819
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
4783
4820
|
function zod3Schema(zodSchema22, options) {
|
|
4784
|
-
var
|
|
4785
|
-
const useReferences = (
|
|
4821
|
+
var _a20;
|
|
4822
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4786
4823
|
return jsonSchema2(
|
|
4787
4824
|
zod_to_json_schema_default(zodSchema22, {
|
|
4788
4825
|
$refStrategy: useReferences ? "root" : "none"
|
|
@@ -4796,8 +4833,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
4796
4833
|
);
|
|
4797
4834
|
}
|
|
4798
4835
|
function zod4Schema(zodSchema22, options) {
|
|
4799
|
-
var
|
|
4800
|
-
const useReferences = (
|
|
4836
|
+
var _a20;
|
|
4837
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4801
4838
|
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
4802
4839
|
target: "draft-7",
|
|
4803
4840
|
io: "output",
|
|
@@ -5107,14 +5144,14 @@ var gatewayErrorResponseSchema = z42.z.object({
|
|
|
5107
5144
|
})
|
|
5108
5145
|
});
|
|
5109
5146
|
function asGatewayError(error, authMethod) {
|
|
5110
|
-
var
|
|
5147
|
+
var _a84;
|
|
5111
5148
|
if (GatewayError.isInstance(error)) {
|
|
5112
5149
|
return error;
|
|
5113
5150
|
}
|
|
5114
5151
|
if (chunkHVBBFCDH_cjs.APICallError.isInstance(error)) {
|
|
5115
5152
|
return createGatewayErrorFromResponse({
|
|
5116
5153
|
response: extractApiCallResponse(error),
|
|
5117
|
-
statusCode: (
|
|
5154
|
+
statusCode: (_a84 = error.statusCode) != null ? _a84 : 500,
|
|
5118
5155
|
defaultMessage: "Gateway request failed",
|
|
5119
5156
|
cause: error,
|
|
5120
5157
|
authMethod
|
|
@@ -5365,7 +5402,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5365
5402
|
abortSignal,
|
|
5366
5403
|
providerOptions
|
|
5367
5404
|
}) {
|
|
5368
|
-
var
|
|
5405
|
+
var _a84;
|
|
5369
5406
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
5370
5407
|
try {
|
|
5371
5408
|
const {
|
|
@@ -5382,7 +5419,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5382
5419
|
),
|
|
5383
5420
|
body: {
|
|
5384
5421
|
input: values.length === 1 ? values[0] : values,
|
|
5385
|
-
...providerOptions
|
|
5422
|
+
...providerOptions ? { providerOptions } : {}
|
|
5386
5423
|
},
|
|
5387
5424
|
successfulResponseHandler: createJsonResponseHandler(
|
|
5388
5425
|
gatewayEmbeddingResponseSchema
|
|
@@ -5396,7 +5433,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5396
5433
|
});
|
|
5397
5434
|
return {
|
|
5398
5435
|
embeddings: responseBody.embeddings,
|
|
5399
|
-
usage: (
|
|
5436
|
+
usage: (_a84 = responseBody.usage) != null ? _a84 : void 0,
|
|
5400
5437
|
providerMetadata: responseBody.providerMetadata,
|
|
5401
5438
|
response: { headers: responseHeaders, body: rawValue }
|
|
5402
5439
|
};
|
|
@@ -5420,8 +5457,8 @@ var gatewayEmbeddingResponseSchema = z42.z.object({
|
|
|
5420
5457
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
5421
5458
|
});
|
|
5422
5459
|
async function getVercelOidcToken() {
|
|
5423
|
-
var
|
|
5424
|
-
const token = (_b8 = (
|
|
5460
|
+
var _a84, _b8;
|
|
5461
|
+
const token = (_b8 = (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
5425
5462
|
if (!token) {
|
|
5426
5463
|
throw new GatewayAuthenticationError({
|
|
5427
5464
|
message: "OIDC token not available",
|
|
@@ -5431,21 +5468,21 @@ async function getVercelOidcToken() {
|
|
|
5431
5468
|
return token;
|
|
5432
5469
|
}
|
|
5433
5470
|
async function getVercelRequestId() {
|
|
5434
|
-
var
|
|
5435
|
-
return (
|
|
5471
|
+
var _a84;
|
|
5472
|
+
return (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-id"];
|
|
5436
5473
|
}
|
|
5437
5474
|
var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
|
|
5438
5475
|
function getContext() {
|
|
5439
|
-
var
|
|
5476
|
+
var _a84, _b8, _c;
|
|
5440
5477
|
const fromSymbol = globalThis;
|
|
5441
|
-
return (_c = (_b8 = (
|
|
5478
|
+
return (_c = (_b8 = (_a84 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a84.get) == null ? void 0 : _b8.call(_a84)) != null ? _c : {};
|
|
5442
5479
|
}
|
|
5443
5480
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
5444
5481
|
function createGatewayProvider(options = {}) {
|
|
5445
|
-
var
|
|
5482
|
+
var _a84, _b8;
|
|
5446
5483
|
let pendingMetadata = null;
|
|
5447
5484
|
let metadataCache = null;
|
|
5448
|
-
const cacheRefreshMillis = (
|
|
5485
|
+
const cacheRefreshMillis = (_a84 = options.metadataCacheRefreshMillis) != null ? _a84 : 1e3 * 60 * 5;
|
|
5449
5486
|
let lastFetchTime = 0;
|
|
5450
5487
|
const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
5451
5488
|
const getHeaders = async () => {
|
|
@@ -5497,8 +5534,8 @@ function createGatewayProvider(options = {}) {
|
|
|
5497
5534
|
});
|
|
5498
5535
|
};
|
|
5499
5536
|
const getAvailableModels = async () => {
|
|
5500
|
-
var
|
|
5501
|
-
const now = (_c = (_b9 = (
|
|
5537
|
+
var _a94, _b9, _c;
|
|
5538
|
+
const now = (_c = (_b9 = (_a94 = options._internal) == null ? void 0 : _a94.currentDate) == null ? void 0 : _b9.call(_a94).getTime()) != null ? _c : Date.now();
|
|
5502
5539
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
5503
5540
|
lastFetchTime = now;
|
|
5504
5541
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -6108,9 +6145,7 @@ function prepareRetries2({
|
|
|
6108
6145
|
})
|
|
6109
6146
|
};
|
|
6110
6147
|
}
|
|
6111
|
-
|
|
6112
|
-
return ({ steps }) => steps.length === stepCount;
|
|
6113
|
-
}
|
|
6148
|
+
var VERSION3 = "5.0.44" ;
|
|
6114
6149
|
createIdGenerator2({
|
|
6115
6150
|
prefix: "aitxt",
|
|
6116
6151
|
size: 24
|
|
@@ -6615,10 +6650,14 @@ async function embedMany2({
|
|
|
6615
6650
|
maxRetries: maxRetriesArg,
|
|
6616
6651
|
abortSignal
|
|
6617
6652
|
});
|
|
6653
|
+
const headersWithUserAgent = withUserAgentSuffix(
|
|
6654
|
+
headers != null ? headers : {},
|
|
6655
|
+
`ai/${VERSION3}`
|
|
6656
|
+
);
|
|
6618
6657
|
const baseTelemetryAttributes = getBaseTelemetryAttributes2({
|
|
6619
6658
|
model,
|
|
6620
6659
|
telemetry,
|
|
6621
|
-
headers,
|
|
6660
|
+
headers: headersWithUserAgent,
|
|
6622
6661
|
settings: { maxRetries }
|
|
6623
6662
|
});
|
|
6624
6663
|
const tracer = getTracer2(telemetry);
|
|
@@ -6667,7 +6706,7 @@ async function embedMany2({
|
|
|
6667
6706
|
const modelResponse = await model.doEmbed({
|
|
6668
6707
|
values,
|
|
6669
6708
|
abortSignal,
|
|
6670
|
-
headers,
|
|
6709
|
+
headers: headersWithUserAgent,
|
|
6671
6710
|
providerOptions
|
|
6672
6711
|
});
|
|
6673
6712
|
const embeddings3 = modelResponse.embeddings;
|
|
@@ -6749,7 +6788,7 @@ async function embedMany2({
|
|
|
6749
6788
|
const modelResponse = await model.doEmbed({
|
|
6750
6789
|
values: chunk,
|
|
6751
6790
|
abortSignal,
|
|
6752
|
-
headers,
|
|
6791
|
+
headers: headersWithUserAgent,
|
|
6753
6792
|
providerOptions
|
|
6754
6793
|
});
|
|
6755
6794
|
const embeddings2 = modelResponse.embeddings;
|
|
@@ -7116,6 +7155,7 @@ var toolUIPartSchemas = [
|
|
|
7116
7155
|
type: z42.z.string().startsWith("tool-"),
|
|
7117
7156
|
toolCallId: z42.z.string(),
|
|
7118
7157
|
state: z42.z.literal("input-streaming"),
|
|
7158
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
7119
7159
|
input: z42.z.unknown().optional(),
|
|
7120
7160
|
output: z42.z.never().optional(),
|
|
7121
7161
|
errorText: z42.z.never().optional()
|
|
@@ -7124,6 +7164,7 @@ var toolUIPartSchemas = [
|
|
|
7124
7164
|
type: z42.z.string().startsWith("tool-"),
|
|
7125
7165
|
toolCallId: z42.z.string(),
|
|
7126
7166
|
state: z42.z.literal("input-available"),
|
|
7167
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
7127
7168
|
input: z42.z.unknown(),
|
|
7128
7169
|
output: z42.z.never().optional(),
|
|
7129
7170
|
errorText: z42.z.never().optional(),
|
|
@@ -7133,6 +7174,7 @@ var toolUIPartSchemas = [
|
|
|
7133
7174
|
type: z42.z.string().startsWith("tool-"),
|
|
7134
7175
|
toolCallId: z42.z.string(),
|
|
7135
7176
|
state: z42.z.literal("output-available"),
|
|
7177
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
7136
7178
|
input: z42.z.unknown(),
|
|
7137
7179
|
output: z42.z.unknown(),
|
|
7138
7180
|
errorText: z42.z.never().optional(),
|
|
@@ -7143,6 +7185,7 @@ var toolUIPartSchemas = [
|
|
|
7143
7185
|
type: z42.z.string().startsWith("tool-"),
|
|
7144
7186
|
toolCallId: z42.z.string(),
|
|
7145
7187
|
state: z42.z.literal("output-error"),
|
|
7188
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
7146
7189
|
input: z42.z.unknown(),
|
|
7147
7190
|
output: z42.z.never().optional(),
|
|
7148
7191
|
errorText: z42.z.string(),
|
|
@@ -7819,50 +7862,50 @@ function isValidWithSchema(schema, value) {
|
|
|
7819
7862
|
return schema.safeParse(value).success;
|
|
7820
7863
|
}
|
|
7821
7864
|
var NotHandler = class {
|
|
7822
|
-
apply(
|
|
7823
|
-
if (!schema.not) return
|
|
7865
|
+
apply(zodSchema4, schema) {
|
|
7866
|
+
if (!schema.not) return zodSchema4;
|
|
7824
7867
|
const notSchema = convertJsonSchemaToZod(schema.not);
|
|
7825
|
-
return
|
|
7868
|
+
return zodSchema4.refine(
|
|
7826
7869
|
(value) => !isValidWithSchema(notSchema, value),
|
|
7827
7870
|
{ message: "Value must not match the 'not' schema" }
|
|
7828
7871
|
);
|
|
7829
7872
|
}
|
|
7830
7873
|
};
|
|
7831
7874
|
var UniqueItemsHandler = class {
|
|
7832
|
-
apply(
|
|
7875
|
+
apply(zodSchema4, schema) {
|
|
7833
7876
|
const arraySchema = schema;
|
|
7834
|
-
if (arraySchema.uniqueItems !== true) return
|
|
7835
|
-
return
|
|
7877
|
+
if (arraySchema.uniqueItems !== true) return zodSchema4;
|
|
7878
|
+
return zodSchema4.refine(createUniqueItemsValidator(), {
|
|
7836
7879
|
message: "Array items must be unique"
|
|
7837
7880
|
});
|
|
7838
7881
|
}
|
|
7839
7882
|
};
|
|
7840
7883
|
var AllOfHandler = class {
|
|
7841
|
-
apply(
|
|
7842
|
-
if (!schema.allOf || schema.allOf.length === 0) return
|
|
7884
|
+
apply(zodSchema4, schema) {
|
|
7885
|
+
if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
|
|
7843
7886
|
const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
|
|
7844
7887
|
return allOfSchemas.reduce(
|
|
7845
7888
|
(acc, s) => z42.z.intersection(acc, s),
|
|
7846
|
-
|
|
7889
|
+
zodSchema4
|
|
7847
7890
|
);
|
|
7848
7891
|
}
|
|
7849
7892
|
};
|
|
7850
7893
|
var AnyOfHandler = class {
|
|
7851
|
-
apply(
|
|
7852
|
-
if (!schema.anyOf || schema.anyOf.length === 0) return
|
|
7894
|
+
apply(zodSchema4, schema) {
|
|
7895
|
+
if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
|
|
7853
7896
|
const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z42.z.union([
|
|
7854
7897
|
convertJsonSchemaToZod(schema.anyOf[0]),
|
|
7855
7898
|
convertJsonSchemaToZod(schema.anyOf[1]),
|
|
7856
7899
|
...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
|
|
7857
7900
|
]);
|
|
7858
|
-
return z42.z.intersection(
|
|
7901
|
+
return z42.z.intersection(zodSchema4, anyOfSchema);
|
|
7859
7902
|
}
|
|
7860
7903
|
};
|
|
7861
7904
|
var OneOfHandler = class {
|
|
7862
|
-
apply(
|
|
7863
|
-
if (!schema.oneOf || schema.oneOf.length === 0) return
|
|
7905
|
+
apply(zodSchema4, schema) {
|
|
7906
|
+
if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
|
|
7864
7907
|
const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
|
|
7865
|
-
return
|
|
7908
|
+
return zodSchema4.refine(
|
|
7866
7909
|
(value) => {
|
|
7867
7910
|
let validCount = 0;
|
|
7868
7911
|
for (const oneOfSchema of oneOfSchemas) {
|
|
@@ -7879,12 +7922,12 @@ var OneOfHandler = class {
|
|
|
7879
7922
|
}
|
|
7880
7923
|
};
|
|
7881
7924
|
var PrefixItemsHandler = class {
|
|
7882
|
-
apply(
|
|
7925
|
+
apply(zodSchema4, schema) {
|
|
7883
7926
|
const arraySchema = schema;
|
|
7884
7927
|
if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
|
|
7885
7928
|
const prefixItems = arraySchema.prefixItems;
|
|
7886
7929
|
const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
|
|
7887
|
-
return
|
|
7930
|
+
return zodSchema4.refine(
|
|
7888
7931
|
(value) => {
|
|
7889
7932
|
if (!Array.isArray(value)) return true;
|
|
7890
7933
|
for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
|
|
@@ -7909,16 +7952,16 @@ var PrefixItemsHandler = class {
|
|
|
7909
7952
|
{ message: "Array does not match prefixItems schema" }
|
|
7910
7953
|
);
|
|
7911
7954
|
}
|
|
7912
|
-
return
|
|
7955
|
+
return zodSchema4;
|
|
7913
7956
|
}
|
|
7914
7957
|
};
|
|
7915
7958
|
var ObjectPropertiesHandler = class {
|
|
7916
|
-
apply(
|
|
7959
|
+
apply(zodSchema4, schema) {
|
|
7917
7960
|
const objectSchema = schema;
|
|
7918
7961
|
if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
|
|
7919
|
-
return
|
|
7962
|
+
return zodSchema4;
|
|
7920
7963
|
}
|
|
7921
|
-
if (
|
|
7964
|
+
if (zodSchema4 instanceof z42.z.ZodObject || zodSchema4 instanceof z42.z.ZodRecord) {
|
|
7922
7965
|
const shape = {};
|
|
7923
7966
|
if (objectSchema.properties) {
|
|
7924
7967
|
for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
|
|
@@ -7945,7 +7988,7 @@ var ObjectPropertiesHandler = class {
|
|
|
7945
7988
|
return z42.z.object(shape).passthrough();
|
|
7946
7989
|
}
|
|
7947
7990
|
}
|
|
7948
|
-
return
|
|
7991
|
+
return zodSchema4.refine(
|
|
7949
7992
|
(value) => {
|
|
7950
7993
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7951
7994
|
return true;
|
|
@@ -7987,13 +8030,13 @@ var ObjectPropertiesHandler = class {
|
|
|
7987
8030
|
}
|
|
7988
8031
|
};
|
|
7989
8032
|
var EnumComplexHandler = class {
|
|
7990
|
-
apply(
|
|
7991
|
-
if (!schema.enum || schema.enum.length === 0) return
|
|
8033
|
+
apply(zodSchema4, schema) {
|
|
8034
|
+
if (!schema.enum || schema.enum.length === 0) return zodSchema4;
|
|
7992
8035
|
const complexValues = schema.enum.filter(
|
|
7993
8036
|
(v) => Array.isArray(v) || typeof v === "object" && v !== null
|
|
7994
8037
|
);
|
|
7995
|
-
if (complexValues.length === 0) return
|
|
7996
|
-
return
|
|
8038
|
+
if (complexValues.length === 0) return zodSchema4;
|
|
8039
|
+
return zodSchema4.refine(
|
|
7997
8040
|
(value) => {
|
|
7998
8041
|
if (typeof value !== "object" || value === null) return true;
|
|
7999
8042
|
return complexValues.some(
|
|
@@ -8005,32 +8048,32 @@ var EnumComplexHandler = class {
|
|
|
8005
8048
|
}
|
|
8006
8049
|
};
|
|
8007
8050
|
var ConstComplexHandler = class {
|
|
8008
|
-
apply(
|
|
8009
|
-
if (schema.const === void 0) return
|
|
8051
|
+
apply(zodSchema4, schema) {
|
|
8052
|
+
if (schema.const === void 0) return zodSchema4;
|
|
8010
8053
|
const constValue = schema.const;
|
|
8011
8054
|
if (typeof constValue !== "object" || constValue === null) {
|
|
8012
|
-
return
|
|
8055
|
+
return zodSchema4;
|
|
8013
8056
|
}
|
|
8014
|
-
return
|
|
8057
|
+
return zodSchema4.refine(
|
|
8015
8058
|
(value) => deepEqual(value, constValue),
|
|
8016
8059
|
{ message: "Value must equal the const value" }
|
|
8017
8060
|
);
|
|
8018
8061
|
}
|
|
8019
8062
|
};
|
|
8020
8063
|
var MetadataHandler = class {
|
|
8021
|
-
apply(
|
|
8064
|
+
apply(zodSchema4, schema) {
|
|
8022
8065
|
if (schema.description) {
|
|
8023
|
-
|
|
8066
|
+
zodSchema4 = zodSchema4.describe(schema.description);
|
|
8024
8067
|
}
|
|
8025
|
-
return
|
|
8068
|
+
return zodSchema4;
|
|
8026
8069
|
}
|
|
8027
8070
|
};
|
|
8028
8071
|
var ProtoRequiredHandler = class {
|
|
8029
|
-
apply(
|
|
8030
|
-
var
|
|
8072
|
+
apply(zodSchema4, schema) {
|
|
8073
|
+
var _a20;
|
|
8031
8074
|
const objectSchema = schema;
|
|
8032
|
-
if (!((
|
|
8033
|
-
return
|
|
8075
|
+
if (!((_a20 = objectSchema.required) == null ? void 0 : _a20.includes("__proto__")) || schema.type !== void 0) {
|
|
8076
|
+
return zodSchema4;
|
|
8034
8077
|
}
|
|
8035
8078
|
return z42.z.any().refine(
|
|
8036
8079
|
(value) => this.validateRequired(value, objectSchema.required),
|
|
@@ -8047,14 +8090,14 @@ var ProtoRequiredHandler = class {
|
|
|
8047
8090
|
}
|
|
8048
8091
|
};
|
|
8049
8092
|
var ContainsHandler = class {
|
|
8050
|
-
apply(
|
|
8051
|
-
var
|
|
8093
|
+
apply(zodSchema4, schema) {
|
|
8094
|
+
var _a20;
|
|
8052
8095
|
const arraySchema = schema;
|
|
8053
|
-
if (arraySchema.contains === void 0) return
|
|
8096
|
+
if (arraySchema.contains === void 0) return zodSchema4;
|
|
8054
8097
|
const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
|
|
8055
|
-
const minContains = (
|
|
8098
|
+
const minContains = (_a20 = arraySchema.minContains) != null ? _a20 : 1;
|
|
8056
8099
|
const maxContains = arraySchema.maxContains;
|
|
8057
|
-
return
|
|
8100
|
+
return zodSchema4.refine(
|
|
8058
8101
|
(value) => {
|
|
8059
8102
|
if (!Array.isArray(value)) {
|
|
8060
8103
|
return true;
|
|
@@ -8163,32 +8206,32 @@ function convertJsonSchemaToZod(schema) {
|
|
|
8163
8206
|
allowedSchemas.push(objectSchema);
|
|
8164
8207
|
}
|
|
8165
8208
|
}
|
|
8166
|
-
let
|
|
8209
|
+
let zodSchema4;
|
|
8167
8210
|
if (allowedSchemas.length === 0) {
|
|
8168
|
-
|
|
8211
|
+
zodSchema4 = z42.z.never();
|
|
8169
8212
|
} else if (allowedSchemas.length === 1) {
|
|
8170
|
-
|
|
8213
|
+
zodSchema4 = allowedSchemas[0];
|
|
8171
8214
|
} else {
|
|
8172
8215
|
const hasConstraints = Object.keys(schema).some(
|
|
8173
8216
|
(key) => key !== "$schema" && key !== "title" && key !== "description"
|
|
8174
8217
|
);
|
|
8175
8218
|
if (!hasConstraints) {
|
|
8176
|
-
|
|
8219
|
+
zodSchema4 = z42.z.any();
|
|
8177
8220
|
} else {
|
|
8178
|
-
|
|
8221
|
+
zodSchema4 = z42.z.union(allowedSchemas);
|
|
8179
8222
|
}
|
|
8180
8223
|
}
|
|
8181
8224
|
for (const handler of refinementHandlers) {
|
|
8182
|
-
|
|
8225
|
+
zodSchema4 = handler.apply(zodSchema4, schema);
|
|
8183
8226
|
}
|
|
8184
|
-
return
|
|
8227
|
+
return zodSchema4;
|
|
8185
8228
|
}
|
|
8186
8229
|
function convertJsonSchemaToZod2(schema) {
|
|
8187
|
-
function addMetadata(
|
|
8188
|
-
if (
|
|
8189
|
-
|
|
8230
|
+
function addMetadata(zodSchema4, jsonSchema4) {
|
|
8231
|
+
if (jsonSchema4.description) {
|
|
8232
|
+
zodSchema4 = zodSchema4.describe(jsonSchema4.description);
|
|
8190
8233
|
}
|
|
8191
|
-
return
|
|
8234
|
+
return zodSchema4;
|
|
8192
8235
|
}
|
|
8193
8236
|
if (schema.const !== void 0) {
|
|
8194
8237
|
if (typeof schema.const === "string") {
|
|
@@ -8294,13 +8337,13 @@ function convertJsonSchemaToZod2(schema) {
|
|
|
8294
8337
|
shape[key] = shape[key].optional();
|
|
8295
8338
|
}
|
|
8296
8339
|
}
|
|
8297
|
-
let
|
|
8340
|
+
let zodSchema4;
|
|
8298
8341
|
if (schema.additionalProperties !== false) {
|
|
8299
|
-
|
|
8342
|
+
zodSchema4 = zod.z.object(shape).passthrough();
|
|
8300
8343
|
} else {
|
|
8301
|
-
|
|
8344
|
+
zodSchema4 = zod.z.object(shape);
|
|
8302
8345
|
}
|
|
8303
|
-
return addMetadata(
|
|
8346
|
+
return addMetadata(zodSchema4, schema);
|
|
8304
8347
|
}
|
|
8305
8348
|
return addMetadata(zod.z.object({}), schema);
|
|
8306
8349
|
case "array": {
|
|
@@ -8840,11 +8883,11 @@ ${workingMemory}`;
|
|
|
8840
8883
|
release();
|
|
8841
8884
|
}
|
|
8842
8885
|
}
|
|
8843
|
-
chunkText(
|
|
8886
|
+
chunkText(text4, tokenSize = 4096) {
|
|
8844
8887
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
8845
8888
|
const chunks = [];
|
|
8846
8889
|
let currentChunk = "";
|
|
8847
|
-
const words =
|
|
8890
|
+
const words = text4.split(/\s+/);
|
|
8848
8891
|
for (const word of words) {
|
|
8849
8892
|
const wordWithSpace = currentChunk ? " " + word : word;
|
|
8850
8893
|
if (currentChunk.length + wordWithSpace.length > charSize) {
|
|
@@ -9006,10 +9049,10 @@ ${workingMemory}`;
|
|
|
9006
9049
|
}
|
|
9007
9050
|
return newMessage;
|
|
9008
9051
|
}
|
|
9009
|
-
parseWorkingMemory(
|
|
9052
|
+
parseWorkingMemory(text4) {
|
|
9010
9053
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
9011
9054
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
9012
|
-
const matches =
|
|
9055
|
+
const matches = text4.match(workingMemoryRegex);
|
|
9013
9056
|
const match = matches?.[0];
|
|
9014
9057
|
if (match) {
|
|
9015
9058
|
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
@@ -9309,12 +9352,12 @@ var _Tiktoken = class {
|
|
|
9309
9352
|
this.textMap.set(rank, bytes);
|
|
9310
9353
|
}
|
|
9311
9354
|
this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
|
|
9312
|
-
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [
|
|
9313
|
-
memo[rank] = this.textEncoder.encode(
|
|
9355
|
+
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
|
|
9356
|
+
memo[rank] = this.textEncoder.encode(text4);
|
|
9314
9357
|
return memo;
|
|
9315
9358
|
}, {});
|
|
9316
9359
|
}
|
|
9317
|
-
encode(
|
|
9360
|
+
encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
|
|
9318
9361
|
const regexes = new RegExp(this.patStr, "ug");
|
|
9319
9362
|
const specialRegex = _Tiktoken.specialTokenRegex(
|
|
9320
9363
|
Object.keys(this.specialTokens)
|
|
@@ -9332,7 +9375,7 @@ var _Tiktoken = class {
|
|
|
9332
9375
|
const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
|
|
9333
9376
|
...disallowedSpecialSet
|
|
9334
9377
|
]);
|
|
9335
|
-
const specialMatch =
|
|
9378
|
+
const specialMatch = text4.match(disallowedSpecialRegex);
|
|
9336
9379
|
if (specialMatch != null) {
|
|
9337
9380
|
throw new Error(
|
|
9338
9381
|
`The text contains a special token that is not allowed: ${specialMatch[0]}`
|
|
@@ -9345,13 +9388,13 @@ var _Tiktoken = class {
|
|
|
9345
9388
|
let startFind = start;
|
|
9346
9389
|
while (true) {
|
|
9347
9390
|
specialRegex.lastIndex = startFind;
|
|
9348
|
-
nextSpecial = specialRegex.exec(
|
|
9391
|
+
nextSpecial = specialRegex.exec(text4);
|
|
9349
9392
|
if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
|
|
9350
9393
|
break;
|
|
9351
9394
|
startFind = nextSpecial.index + 1;
|
|
9352
9395
|
}
|
|
9353
|
-
const end = nextSpecial?.index ??
|
|
9354
|
-
for (const match of
|
|
9396
|
+
const end = nextSpecial?.index ?? text4.length;
|
|
9397
|
+
for (const match of text4.substring(start, end).matchAll(regexes)) {
|
|
9355
9398
|
const piece = this.textEncoder.encode(match[0]);
|
|
9356
9399
|
const token2 = this.rankMap.get(piece.join(","));
|
|
9357
9400
|
if (token2 != null) {
|
|
@@ -9499,6 +9542,2285 @@ var TokenLimiter = class extends memory.MemoryProcessor {
|
|
|
9499
9542
|
|
|
9500
9543
|
// ../agent-builder/dist/index.js
|
|
9501
9544
|
var import_ignore = chunkEMMSS5I5_cjs.__toESM(require_ignore(), 1);
|
|
9545
|
+
var createIdGenerator3 = ({
|
|
9546
|
+
prefix,
|
|
9547
|
+
size = 16,
|
|
9548
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
9549
|
+
separator = "-"
|
|
9550
|
+
} = {}) => {
|
|
9551
|
+
const generator = () => {
|
|
9552
|
+
const alphabetLength = alphabet.length;
|
|
9553
|
+
const chars = new Array(size);
|
|
9554
|
+
for (let i = 0; i < size; i++) {
|
|
9555
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
9556
|
+
}
|
|
9557
|
+
return chars.join("");
|
|
9558
|
+
};
|
|
9559
|
+
if (prefix == null) {
|
|
9560
|
+
return generator;
|
|
9561
|
+
}
|
|
9562
|
+
if (alphabet.includes(separator)) {
|
|
9563
|
+
throw new chunkHVBBFCDH_cjs.InvalidArgumentError({
|
|
9564
|
+
argument: "separator",
|
|
9565
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
9566
|
+
});
|
|
9567
|
+
}
|
|
9568
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
9569
|
+
};
|
|
9570
|
+
createIdGenerator3();
|
|
9571
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
9572
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
9573
|
+
function _parse2(text4) {
|
|
9574
|
+
const obj = JSON.parse(text4);
|
|
9575
|
+
if (obj === null || typeof obj !== "object") {
|
|
9576
|
+
return obj;
|
|
9577
|
+
}
|
|
9578
|
+
if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
|
|
9579
|
+
return obj;
|
|
9580
|
+
}
|
|
9581
|
+
return filter2(obj);
|
|
9582
|
+
}
|
|
9583
|
+
function filter2(obj) {
|
|
9584
|
+
let next = [obj];
|
|
9585
|
+
while (next.length) {
|
|
9586
|
+
const nodes = next;
|
|
9587
|
+
next = [];
|
|
9588
|
+
for (const node of nodes) {
|
|
9589
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9590
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9591
|
+
}
|
|
9592
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9593
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9594
|
+
}
|
|
9595
|
+
for (const key in node) {
|
|
9596
|
+
const value = node[key];
|
|
9597
|
+
if (value && typeof value === "object") {
|
|
9598
|
+
next.push(value);
|
|
9599
|
+
}
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
}
|
|
9603
|
+
return obj;
|
|
9604
|
+
}
|
|
9605
|
+
function secureJsonParse2(text4) {
|
|
9606
|
+
const { stackTraceLimit } = Error;
|
|
9607
|
+
Error.stackTraceLimit = 0;
|
|
9608
|
+
try {
|
|
9609
|
+
return _parse2(text4);
|
|
9610
|
+
} finally {
|
|
9611
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
var validatorSymbol3 = Symbol.for("vercel.ai.validator");
|
|
9615
|
+
function validator2(validate) {
|
|
9616
|
+
return { [validatorSymbol3]: true, validate };
|
|
9617
|
+
}
|
|
9618
|
+
function isValidator2(value) {
|
|
9619
|
+
return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
|
|
9620
|
+
}
|
|
9621
|
+
function asValidator2(value) {
|
|
9622
|
+
return isValidator2(value) ? value : standardSchemaValidator2(value);
|
|
9623
|
+
}
|
|
9624
|
+
function standardSchemaValidator2(standardSchema) {
|
|
9625
|
+
return validator2(async (value) => {
|
|
9626
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
9627
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
9628
|
+
success: false,
|
|
9629
|
+
error: new chunkHVBBFCDH_cjs.TypeValidationError({
|
|
9630
|
+
value,
|
|
9631
|
+
cause: result.issues
|
|
9632
|
+
})
|
|
9633
|
+
};
|
|
9634
|
+
});
|
|
9635
|
+
}
|
|
9636
|
+
async function safeValidateTypes3({
|
|
9637
|
+
value,
|
|
9638
|
+
schema
|
|
9639
|
+
}) {
|
|
9640
|
+
const validator22 = asValidator2(schema);
|
|
9641
|
+
try {
|
|
9642
|
+
if (validator22.validate == null) {
|
|
9643
|
+
return { success: true, value, rawValue: value };
|
|
9644
|
+
}
|
|
9645
|
+
const result = await validator22.validate(value);
|
|
9646
|
+
if (result.success) {
|
|
9647
|
+
return { success: true, value: result.value, rawValue: value };
|
|
9648
|
+
}
|
|
9649
|
+
return {
|
|
9650
|
+
success: false,
|
|
9651
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
9652
|
+
rawValue: value
|
|
9653
|
+
};
|
|
9654
|
+
} catch (error) {
|
|
9655
|
+
return {
|
|
9656
|
+
success: false,
|
|
9657
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
9658
|
+
rawValue: value
|
|
9659
|
+
};
|
|
9660
|
+
}
|
|
9661
|
+
}
|
|
9662
|
+
async function safeParseJSON3({
|
|
9663
|
+
text: text4,
|
|
9664
|
+
schema
|
|
9665
|
+
}) {
|
|
9666
|
+
try {
|
|
9667
|
+
const value = secureJsonParse2(text4);
|
|
9668
|
+
if (schema == null) {
|
|
9669
|
+
return { success: true, value, rawValue: value };
|
|
9670
|
+
}
|
|
9671
|
+
return await safeValidateTypes3({ value, schema });
|
|
9672
|
+
} catch (error) {
|
|
9673
|
+
return {
|
|
9674
|
+
success: false,
|
|
9675
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
9676
|
+
rawValue: void 0
|
|
9677
|
+
};
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
9681
|
+
let i = 0;
|
|
9682
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
9683
|
+
if (pathA[i] !== pathB[i])
|
|
9684
|
+
break;
|
|
9685
|
+
}
|
|
9686
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
9687
|
+
};
|
|
9688
|
+
var ignoreOverride2 = Symbol(
|
|
9689
|
+
"Let zodToJsonSchema decide on which parser to use"
|
|
9690
|
+
);
|
|
9691
|
+
var defaultOptions2 = {
|
|
9692
|
+
name: void 0,
|
|
9693
|
+
$refStrategy: "root",
|
|
9694
|
+
basePath: ["#"],
|
|
9695
|
+
effectStrategy: "input",
|
|
9696
|
+
pipeStrategy: "all",
|
|
9697
|
+
dateStrategy: "format:date-time",
|
|
9698
|
+
mapStrategy: "entries",
|
|
9699
|
+
removeAdditionalStrategy: "passthrough",
|
|
9700
|
+
allowedAdditionalProperties: true,
|
|
9701
|
+
rejectedAdditionalProperties: false,
|
|
9702
|
+
definitionPath: "definitions",
|
|
9703
|
+
strictUnions: false,
|
|
9704
|
+
definitions: {},
|
|
9705
|
+
errorMessages: false,
|
|
9706
|
+
patternStrategy: "escape",
|
|
9707
|
+
applyRegexFlags: false,
|
|
9708
|
+
emailStrategy: "format:email",
|
|
9709
|
+
base64Strategy: "contentEncoding:base64",
|
|
9710
|
+
nameStrategy: "ref"
|
|
9711
|
+
};
|
|
9712
|
+
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
9713
|
+
...defaultOptions2,
|
|
9714
|
+
name: options
|
|
9715
|
+
} : {
|
|
9716
|
+
...defaultOptions2,
|
|
9717
|
+
...options
|
|
9718
|
+
};
|
|
9719
|
+
function parseAnyDef2() {
|
|
9720
|
+
return {};
|
|
9721
|
+
}
|
|
9722
|
+
function parseArrayDef2(def, refs) {
|
|
9723
|
+
var _a20, _b8, _c;
|
|
9724
|
+
const res = {
|
|
9725
|
+
type: "array"
|
|
9726
|
+
};
|
|
9727
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
9728
|
+
res.items = parseDef2(def.type._def, {
|
|
9729
|
+
...refs,
|
|
9730
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9731
|
+
});
|
|
9732
|
+
}
|
|
9733
|
+
if (def.minLength) {
|
|
9734
|
+
res.minItems = def.minLength.value;
|
|
9735
|
+
}
|
|
9736
|
+
if (def.maxLength) {
|
|
9737
|
+
res.maxItems = def.maxLength.value;
|
|
9738
|
+
}
|
|
9739
|
+
if (def.exactLength) {
|
|
9740
|
+
res.minItems = def.exactLength.value;
|
|
9741
|
+
res.maxItems = def.exactLength.value;
|
|
9742
|
+
}
|
|
9743
|
+
return res;
|
|
9744
|
+
}
|
|
9745
|
+
function parseBigintDef2(def) {
|
|
9746
|
+
const res = {
|
|
9747
|
+
type: "integer",
|
|
9748
|
+
format: "int64"
|
|
9749
|
+
};
|
|
9750
|
+
if (!def.checks)
|
|
9751
|
+
return res;
|
|
9752
|
+
for (const check of def.checks) {
|
|
9753
|
+
switch (check.kind) {
|
|
9754
|
+
case "min":
|
|
9755
|
+
if (check.inclusive) {
|
|
9756
|
+
res.minimum = check.value;
|
|
9757
|
+
} else {
|
|
9758
|
+
res.exclusiveMinimum = check.value;
|
|
9759
|
+
}
|
|
9760
|
+
break;
|
|
9761
|
+
case "max":
|
|
9762
|
+
if (check.inclusive) {
|
|
9763
|
+
res.maximum = check.value;
|
|
9764
|
+
} else {
|
|
9765
|
+
res.exclusiveMaximum = check.value;
|
|
9766
|
+
}
|
|
9767
|
+
break;
|
|
9768
|
+
case "multipleOf":
|
|
9769
|
+
res.multipleOf = check.value;
|
|
9770
|
+
break;
|
|
9771
|
+
}
|
|
9772
|
+
}
|
|
9773
|
+
return res;
|
|
9774
|
+
}
|
|
9775
|
+
function parseBooleanDef2() {
|
|
9776
|
+
return { type: "boolean" };
|
|
9777
|
+
}
|
|
9778
|
+
function parseBrandedDef2(_def, refs) {
|
|
9779
|
+
return parseDef2(_def.type._def, refs);
|
|
9780
|
+
}
|
|
9781
|
+
var parseCatchDef2 = (def, refs) => {
|
|
9782
|
+
return parseDef2(def.innerType._def, refs);
|
|
9783
|
+
};
|
|
9784
|
+
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
9785
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
9786
|
+
if (Array.isArray(strategy)) {
|
|
9787
|
+
return {
|
|
9788
|
+
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
9789
|
+
};
|
|
9790
|
+
}
|
|
9791
|
+
switch (strategy) {
|
|
9792
|
+
case "string":
|
|
9793
|
+
case "format:date-time":
|
|
9794
|
+
return {
|
|
9795
|
+
type: "string",
|
|
9796
|
+
format: "date-time"
|
|
9797
|
+
};
|
|
9798
|
+
case "format:date":
|
|
9799
|
+
return {
|
|
9800
|
+
type: "string",
|
|
9801
|
+
format: "date"
|
|
9802
|
+
};
|
|
9803
|
+
case "integer":
|
|
9804
|
+
return integerDateParser2(def);
|
|
9805
|
+
}
|
|
9806
|
+
}
|
|
9807
|
+
var integerDateParser2 = (def) => {
|
|
9808
|
+
const res = {
|
|
9809
|
+
type: "integer",
|
|
9810
|
+
format: "unix-time"
|
|
9811
|
+
};
|
|
9812
|
+
for (const check of def.checks) {
|
|
9813
|
+
switch (check.kind) {
|
|
9814
|
+
case "min":
|
|
9815
|
+
res.minimum = check.value;
|
|
9816
|
+
break;
|
|
9817
|
+
case "max":
|
|
9818
|
+
res.maximum = check.value;
|
|
9819
|
+
break;
|
|
9820
|
+
}
|
|
9821
|
+
}
|
|
9822
|
+
return res;
|
|
9823
|
+
};
|
|
9824
|
+
function parseDefaultDef2(_def, refs) {
|
|
9825
|
+
return {
|
|
9826
|
+
...parseDef2(_def.innerType._def, refs),
|
|
9827
|
+
default: _def.defaultValue()
|
|
9828
|
+
};
|
|
9829
|
+
}
|
|
9830
|
+
function parseEffectsDef2(_def, refs) {
|
|
9831
|
+
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
|
|
9832
|
+
}
|
|
9833
|
+
function parseEnumDef2(def) {
|
|
9834
|
+
return {
|
|
9835
|
+
type: "string",
|
|
9836
|
+
enum: Array.from(def.values)
|
|
9837
|
+
};
|
|
9838
|
+
}
|
|
9839
|
+
var isJsonSchema7AllOfType2 = (type) => {
|
|
9840
|
+
if ("type" in type && type.type === "string")
|
|
9841
|
+
return false;
|
|
9842
|
+
return "allOf" in type;
|
|
9843
|
+
};
|
|
9844
|
+
function parseIntersectionDef2(def, refs) {
|
|
9845
|
+
const allOf = [
|
|
9846
|
+
parseDef2(def.left._def, {
|
|
9847
|
+
...refs,
|
|
9848
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9849
|
+
}),
|
|
9850
|
+
parseDef2(def.right._def, {
|
|
9851
|
+
...refs,
|
|
9852
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
9853
|
+
})
|
|
9854
|
+
].filter((x) => !!x);
|
|
9855
|
+
const mergedAllOf = [];
|
|
9856
|
+
allOf.forEach((schema) => {
|
|
9857
|
+
if (isJsonSchema7AllOfType2(schema)) {
|
|
9858
|
+
mergedAllOf.push(...schema.allOf);
|
|
9859
|
+
} else {
|
|
9860
|
+
let nestedSchema = schema;
|
|
9861
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
9862
|
+
const { additionalProperties, ...rest } = schema;
|
|
9863
|
+
nestedSchema = rest;
|
|
9864
|
+
}
|
|
9865
|
+
mergedAllOf.push(nestedSchema);
|
|
9866
|
+
}
|
|
9867
|
+
});
|
|
9868
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
|
|
9869
|
+
}
|
|
9870
|
+
function parseLiteralDef2(def) {
|
|
9871
|
+
const parsedType = typeof def.value;
|
|
9872
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
9873
|
+
return {
|
|
9874
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9877
|
+
return {
|
|
9878
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9879
|
+
const: def.value
|
|
9880
|
+
};
|
|
9881
|
+
}
|
|
9882
|
+
var emojiRegex2 = void 0;
|
|
9883
|
+
var zodPatterns2 = {
|
|
9884
|
+
/**
|
|
9885
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
9886
|
+
*/
|
|
9887
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
9888
|
+
cuid2: /^[0-9a-z]+$/,
|
|
9889
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
9890
|
+
/**
|
|
9891
|
+
* `a-z` was added to replicate /i flag
|
|
9892
|
+
*/
|
|
9893
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
9894
|
+
/**
|
|
9895
|
+
* Constructed a valid Unicode RegExp
|
|
9896
|
+
*
|
|
9897
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
9898
|
+
* in all envs (e.g. React Native).
|
|
9899
|
+
*
|
|
9900
|
+
* See:
|
|
9901
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
9902
|
+
* Fix in Zod:
|
|
9903
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
9904
|
+
*/
|
|
9905
|
+
emoji: () => {
|
|
9906
|
+
if (emojiRegex2 === void 0) {
|
|
9907
|
+
emojiRegex2 = RegExp(
|
|
9908
|
+
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
9909
|
+
"u"
|
|
9910
|
+
);
|
|
9911
|
+
}
|
|
9912
|
+
return emojiRegex2;
|
|
9913
|
+
},
|
|
9914
|
+
/**
|
|
9915
|
+
* Unused
|
|
9916
|
+
*/
|
|
9917
|
+
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}$/,
|
|
9918
|
+
/**
|
|
9919
|
+
* Unused
|
|
9920
|
+
*/
|
|
9921
|
+
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])$/,
|
|
9922
|
+
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])$/,
|
|
9923
|
+
/**
|
|
9924
|
+
* Unused
|
|
9925
|
+
*/
|
|
9926
|
+
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})))$/,
|
|
9927
|
+
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])$/,
|
|
9928
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
9929
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
9930
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
9931
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
9932
|
+
};
|
|
9933
|
+
function parseStringDef2(def, refs) {
|
|
9934
|
+
const res = {
|
|
9935
|
+
type: "string"
|
|
9936
|
+
};
|
|
9937
|
+
if (def.checks) {
|
|
9938
|
+
for (const check of def.checks) {
|
|
9939
|
+
switch (check.kind) {
|
|
9940
|
+
case "min":
|
|
9941
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
9942
|
+
break;
|
|
9943
|
+
case "max":
|
|
9944
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
9945
|
+
break;
|
|
9946
|
+
case "email":
|
|
9947
|
+
switch (refs.emailStrategy) {
|
|
9948
|
+
case "format:email":
|
|
9949
|
+
addFormat2(res, "email", check.message, refs);
|
|
9950
|
+
break;
|
|
9951
|
+
case "format:idn-email":
|
|
9952
|
+
addFormat2(res, "idn-email", check.message, refs);
|
|
9953
|
+
break;
|
|
9954
|
+
case "pattern:zod":
|
|
9955
|
+
addPattern2(res, zodPatterns2.email, check.message, refs);
|
|
9956
|
+
break;
|
|
9957
|
+
}
|
|
9958
|
+
break;
|
|
9959
|
+
case "url":
|
|
9960
|
+
addFormat2(res, "uri", check.message, refs);
|
|
9961
|
+
break;
|
|
9962
|
+
case "uuid":
|
|
9963
|
+
addFormat2(res, "uuid", check.message, refs);
|
|
9964
|
+
break;
|
|
9965
|
+
case "regex":
|
|
9966
|
+
addPattern2(res, check.regex, check.message, refs);
|
|
9967
|
+
break;
|
|
9968
|
+
case "cuid":
|
|
9969
|
+
addPattern2(res, zodPatterns2.cuid, check.message, refs);
|
|
9970
|
+
break;
|
|
9971
|
+
case "cuid2":
|
|
9972
|
+
addPattern2(res, zodPatterns2.cuid2, check.message, refs);
|
|
9973
|
+
break;
|
|
9974
|
+
case "startsWith":
|
|
9975
|
+
addPattern2(
|
|
9976
|
+
res,
|
|
9977
|
+
RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`),
|
|
9978
|
+
check.message,
|
|
9979
|
+
refs
|
|
9980
|
+
);
|
|
9981
|
+
break;
|
|
9982
|
+
case "endsWith":
|
|
9983
|
+
addPattern2(
|
|
9984
|
+
res,
|
|
9985
|
+
RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`),
|
|
9986
|
+
check.message,
|
|
9987
|
+
refs
|
|
9988
|
+
);
|
|
9989
|
+
break;
|
|
9990
|
+
case "datetime":
|
|
9991
|
+
addFormat2(res, "date-time", check.message, refs);
|
|
9992
|
+
break;
|
|
9993
|
+
case "date":
|
|
9994
|
+
addFormat2(res, "date", check.message, refs);
|
|
9995
|
+
break;
|
|
9996
|
+
case "time":
|
|
9997
|
+
addFormat2(res, "time", check.message, refs);
|
|
9998
|
+
break;
|
|
9999
|
+
case "duration":
|
|
10000
|
+
addFormat2(res, "duration", check.message, refs);
|
|
10001
|
+
break;
|
|
10002
|
+
case "length":
|
|
10003
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
10004
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
10005
|
+
break;
|
|
10006
|
+
case "includes": {
|
|
10007
|
+
addPattern2(
|
|
10008
|
+
res,
|
|
10009
|
+
RegExp(escapeLiteralCheckValue2(check.value, refs)),
|
|
10010
|
+
check.message,
|
|
10011
|
+
refs
|
|
10012
|
+
);
|
|
10013
|
+
break;
|
|
10014
|
+
}
|
|
10015
|
+
case "ip": {
|
|
10016
|
+
if (check.version !== "v6") {
|
|
10017
|
+
addFormat2(res, "ipv4", check.message, refs);
|
|
10018
|
+
}
|
|
10019
|
+
if (check.version !== "v4") {
|
|
10020
|
+
addFormat2(res, "ipv6", check.message, refs);
|
|
10021
|
+
}
|
|
10022
|
+
break;
|
|
10023
|
+
}
|
|
10024
|
+
case "base64url":
|
|
10025
|
+
addPattern2(res, zodPatterns2.base64url, check.message, refs);
|
|
10026
|
+
break;
|
|
10027
|
+
case "jwt":
|
|
10028
|
+
addPattern2(res, zodPatterns2.jwt, check.message, refs);
|
|
10029
|
+
break;
|
|
10030
|
+
case "cidr": {
|
|
10031
|
+
if (check.version !== "v6") {
|
|
10032
|
+
addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
|
|
10033
|
+
}
|
|
10034
|
+
if (check.version !== "v4") {
|
|
10035
|
+
addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
|
|
10036
|
+
}
|
|
10037
|
+
break;
|
|
10038
|
+
}
|
|
10039
|
+
case "emoji":
|
|
10040
|
+
addPattern2(res, zodPatterns2.emoji(), check.message, refs);
|
|
10041
|
+
break;
|
|
10042
|
+
case "ulid": {
|
|
10043
|
+
addPattern2(res, zodPatterns2.ulid, check.message, refs);
|
|
10044
|
+
break;
|
|
10045
|
+
}
|
|
10046
|
+
case "base64": {
|
|
10047
|
+
switch (refs.base64Strategy) {
|
|
10048
|
+
case "format:binary": {
|
|
10049
|
+
addFormat2(res, "binary", check.message, refs);
|
|
10050
|
+
break;
|
|
10051
|
+
}
|
|
10052
|
+
case "contentEncoding:base64": {
|
|
10053
|
+
res.contentEncoding = "base64";
|
|
10054
|
+
break;
|
|
10055
|
+
}
|
|
10056
|
+
case "pattern:zod": {
|
|
10057
|
+
addPattern2(res, zodPatterns2.base64, check.message, refs);
|
|
10058
|
+
break;
|
|
10059
|
+
}
|
|
10060
|
+
}
|
|
10061
|
+
break;
|
|
10062
|
+
}
|
|
10063
|
+
case "nanoid": {
|
|
10064
|
+
addPattern2(res, zodPatterns2.nanoid, check.message, refs);
|
|
10065
|
+
}
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
return res;
|
|
10070
|
+
}
|
|
10071
|
+
function escapeLiteralCheckValue2(literal, refs) {
|
|
10072
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
|
|
10073
|
+
}
|
|
10074
|
+
var ALPHA_NUMERIC2 = new Set(
|
|
10075
|
+
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
10076
|
+
);
|
|
10077
|
+
function escapeNonAlphaNumeric2(source) {
|
|
10078
|
+
let result = "";
|
|
10079
|
+
for (let i = 0; i < source.length; i++) {
|
|
10080
|
+
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
10081
|
+
result += "\\";
|
|
10082
|
+
}
|
|
10083
|
+
result += source[i];
|
|
10084
|
+
}
|
|
10085
|
+
return result;
|
|
10086
|
+
}
|
|
10087
|
+
function addFormat2(schema, value, message, refs) {
|
|
10088
|
+
var _a20;
|
|
10089
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
10090
|
+
if (!schema.anyOf) {
|
|
10091
|
+
schema.anyOf = [];
|
|
10092
|
+
}
|
|
10093
|
+
if (schema.format) {
|
|
10094
|
+
schema.anyOf.push({
|
|
10095
|
+
format: schema.format
|
|
10096
|
+
});
|
|
10097
|
+
delete schema.format;
|
|
10098
|
+
}
|
|
10099
|
+
schema.anyOf.push({
|
|
10100
|
+
format: value,
|
|
10101
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
10102
|
+
});
|
|
10103
|
+
} else {
|
|
10104
|
+
schema.format = value;
|
|
10105
|
+
}
|
|
10106
|
+
}
|
|
10107
|
+
function addPattern2(schema, regex, message, refs) {
|
|
10108
|
+
var _a20;
|
|
10109
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
10110
|
+
if (!schema.allOf) {
|
|
10111
|
+
schema.allOf = [];
|
|
10112
|
+
}
|
|
10113
|
+
if (schema.pattern) {
|
|
10114
|
+
schema.allOf.push({
|
|
10115
|
+
pattern: schema.pattern
|
|
10116
|
+
});
|
|
10117
|
+
delete schema.pattern;
|
|
10118
|
+
}
|
|
10119
|
+
schema.allOf.push({
|
|
10120
|
+
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
10121
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
10122
|
+
});
|
|
10123
|
+
} else {
|
|
10124
|
+
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
10125
|
+
}
|
|
10126
|
+
}
|
|
10127
|
+
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10128
|
+
var _a20;
|
|
10129
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10130
|
+
return regex.source;
|
|
10131
|
+
}
|
|
10132
|
+
const flags = {
|
|
10133
|
+
i: regex.flags.includes("i"),
|
|
10134
|
+
// Case-insensitive
|
|
10135
|
+
m: regex.flags.includes("m"),
|
|
10136
|
+
// `^` and `$` matches adjacent to newline characters
|
|
10137
|
+
s: regex.flags.includes("s")
|
|
10138
|
+
// `.` matches newlines
|
|
10139
|
+
};
|
|
10140
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
10141
|
+
let pattern = "";
|
|
10142
|
+
let isEscaped = false;
|
|
10143
|
+
let inCharGroup = false;
|
|
10144
|
+
let inCharRange = false;
|
|
10145
|
+
for (let i = 0; i < source.length; i++) {
|
|
10146
|
+
if (isEscaped) {
|
|
10147
|
+
pattern += source[i];
|
|
10148
|
+
isEscaped = false;
|
|
10149
|
+
continue;
|
|
10150
|
+
}
|
|
10151
|
+
if (flags.i) {
|
|
10152
|
+
if (inCharGroup) {
|
|
10153
|
+
if (source[i].match(/[a-z]/)) {
|
|
10154
|
+
if (inCharRange) {
|
|
10155
|
+
pattern += source[i];
|
|
10156
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10157
|
+
inCharRange = false;
|
|
10158
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
10159
|
+
pattern += source[i];
|
|
10160
|
+
inCharRange = true;
|
|
10161
|
+
} else {
|
|
10162
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
10163
|
+
}
|
|
10164
|
+
continue;
|
|
10165
|
+
}
|
|
10166
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
10167
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
10168
|
+
continue;
|
|
10169
|
+
}
|
|
10170
|
+
}
|
|
10171
|
+
if (flags.m) {
|
|
10172
|
+
if (source[i] === "^") {
|
|
10173
|
+
pattern += `(^|(?<=[\r
|
|
10174
|
+
]))`;
|
|
10175
|
+
continue;
|
|
10176
|
+
} else if (source[i] === "$") {
|
|
10177
|
+
pattern += `($|(?=[\r
|
|
10178
|
+
]))`;
|
|
10179
|
+
continue;
|
|
10180
|
+
}
|
|
10181
|
+
}
|
|
10182
|
+
if (flags.s && source[i] === ".") {
|
|
10183
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
10184
|
+
` : `[${source[i]}\r
|
|
10185
|
+
]`;
|
|
10186
|
+
continue;
|
|
10187
|
+
}
|
|
10188
|
+
pattern += source[i];
|
|
10189
|
+
if (source[i] === "\\") {
|
|
10190
|
+
isEscaped = true;
|
|
10191
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
10192
|
+
inCharGroup = false;
|
|
10193
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
10194
|
+
inCharGroup = true;
|
|
10195
|
+
}
|
|
10196
|
+
}
|
|
10197
|
+
return pattern;
|
|
10198
|
+
}
|
|
10199
|
+
function parseRecordDef2(def, refs) {
|
|
10200
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
10201
|
+
const schema = {
|
|
10202
|
+
type: "object",
|
|
10203
|
+
additionalProperties: (_a20 = parseDef2(def.valueType._def, {
|
|
10204
|
+
...refs,
|
|
10205
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10206
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
10207
|
+
};
|
|
10208
|
+
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10209
|
+
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
10210
|
+
return {
|
|
10211
|
+
...schema,
|
|
10212
|
+
propertyNames: keyType
|
|
10213
|
+
};
|
|
10214
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === v3.ZodFirstPartyTypeKind.ZodEnum) {
|
|
10215
|
+
return {
|
|
10216
|
+
...schema,
|
|
10217
|
+
propertyNames: {
|
|
10218
|
+
enum: def.keyType._def.values
|
|
10219
|
+
}
|
|
10220
|
+
};
|
|
10221
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
10222
|
+
const { type, ...keyType } = parseBrandedDef2(
|
|
10223
|
+
def.keyType._def,
|
|
10224
|
+
refs
|
|
10225
|
+
);
|
|
10226
|
+
return {
|
|
10227
|
+
...schema,
|
|
10228
|
+
propertyNames: keyType
|
|
10229
|
+
};
|
|
10230
|
+
}
|
|
10231
|
+
return schema;
|
|
10232
|
+
}
|
|
10233
|
+
function parseMapDef2(def, refs) {
|
|
10234
|
+
if (refs.mapStrategy === "record") {
|
|
10235
|
+
return parseRecordDef2(def, refs);
|
|
10236
|
+
}
|
|
10237
|
+
const keys = parseDef2(def.keyType._def, {
|
|
10238
|
+
...refs,
|
|
10239
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
10240
|
+
}) || parseAnyDef2();
|
|
10241
|
+
const values = parseDef2(def.valueType._def, {
|
|
10242
|
+
...refs,
|
|
10243
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
10244
|
+
}) || parseAnyDef2();
|
|
10245
|
+
return {
|
|
10246
|
+
type: "array",
|
|
10247
|
+
maxItems: 125,
|
|
10248
|
+
items: {
|
|
10249
|
+
type: "array",
|
|
10250
|
+
items: [keys, values],
|
|
10251
|
+
minItems: 2,
|
|
10252
|
+
maxItems: 2
|
|
10253
|
+
}
|
|
10254
|
+
};
|
|
10255
|
+
}
|
|
10256
|
+
function parseNativeEnumDef2(def) {
|
|
10257
|
+
const object4 = def.values;
|
|
10258
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
10259
|
+
return typeof object4[object4[key]] !== "number";
|
|
10260
|
+
});
|
|
10261
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
10262
|
+
const parsedTypes = Array.from(
|
|
10263
|
+
new Set(actualValues.map((values) => typeof values))
|
|
10264
|
+
);
|
|
10265
|
+
return {
|
|
10266
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
10267
|
+
enum: actualValues
|
|
10268
|
+
};
|
|
10269
|
+
}
|
|
10270
|
+
function parseNeverDef2() {
|
|
10271
|
+
return { not: parseAnyDef2() };
|
|
10272
|
+
}
|
|
10273
|
+
function parseNullDef2() {
|
|
10274
|
+
return {
|
|
10275
|
+
type: "null"
|
|
10276
|
+
};
|
|
10277
|
+
}
|
|
10278
|
+
var primitiveMappings2 = {
|
|
10279
|
+
ZodString: "string",
|
|
10280
|
+
ZodNumber: "number",
|
|
10281
|
+
ZodBigInt: "integer",
|
|
10282
|
+
ZodBoolean: "boolean",
|
|
10283
|
+
ZodNull: "null"
|
|
10284
|
+
};
|
|
10285
|
+
function parseUnionDef2(def, refs) {
|
|
10286
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10287
|
+
if (options.every(
|
|
10288
|
+
(x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length)
|
|
10289
|
+
)) {
|
|
10290
|
+
const types = options.reduce((types2, x) => {
|
|
10291
|
+
const type = primitiveMappings2[x._def.typeName];
|
|
10292
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
10293
|
+
}, []);
|
|
10294
|
+
return {
|
|
10295
|
+
type: types.length > 1 ? types : types[0]
|
|
10296
|
+
};
|
|
10297
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
10298
|
+
const types = options.reduce(
|
|
10299
|
+
(acc, x) => {
|
|
10300
|
+
const type = typeof x._def.value;
|
|
10301
|
+
switch (type) {
|
|
10302
|
+
case "string":
|
|
10303
|
+
case "number":
|
|
10304
|
+
case "boolean":
|
|
10305
|
+
return [...acc, type];
|
|
10306
|
+
case "bigint":
|
|
10307
|
+
return [...acc, "integer"];
|
|
10308
|
+
case "object":
|
|
10309
|
+
if (x._def.value === null)
|
|
10310
|
+
return [...acc, "null"];
|
|
10311
|
+
case "symbol":
|
|
10312
|
+
case "undefined":
|
|
10313
|
+
case "function":
|
|
10314
|
+
default:
|
|
10315
|
+
return acc;
|
|
10316
|
+
}
|
|
10317
|
+
},
|
|
10318
|
+
[]
|
|
10319
|
+
);
|
|
10320
|
+
if (types.length === options.length) {
|
|
10321
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
10322
|
+
return {
|
|
10323
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
10324
|
+
enum: options.reduce(
|
|
10325
|
+
(acc, x) => {
|
|
10326
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
10327
|
+
},
|
|
10328
|
+
[]
|
|
10329
|
+
)
|
|
10330
|
+
};
|
|
10331
|
+
}
|
|
10332
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
10333
|
+
return {
|
|
10334
|
+
type: "string",
|
|
10335
|
+
enum: options.reduce(
|
|
10336
|
+
(acc, x) => [
|
|
10337
|
+
...acc,
|
|
10338
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
10339
|
+
],
|
|
10340
|
+
[]
|
|
10341
|
+
)
|
|
10342
|
+
};
|
|
10343
|
+
}
|
|
10344
|
+
return asAnyOf2(def, refs);
|
|
10345
|
+
}
|
|
10346
|
+
var asAnyOf2 = (def, refs) => {
|
|
10347
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
|
|
10348
|
+
(x, i) => parseDef2(x._def, {
|
|
10349
|
+
...refs,
|
|
10350
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
10351
|
+
})
|
|
10352
|
+
).filter(
|
|
10353
|
+
(x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
|
|
10354
|
+
);
|
|
10355
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
10356
|
+
};
|
|
10357
|
+
function parseNullableDef2(def, refs) {
|
|
10358
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
10359
|
+
def.innerType._def.typeName
|
|
10360
|
+
) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
10361
|
+
return {
|
|
10362
|
+
type: [
|
|
10363
|
+
primitiveMappings2[def.innerType._def.typeName],
|
|
10364
|
+
"null"
|
|
10365
|
+
]
|
|
10366
|
+
};
|
|
10367
|
+
}
|
|
10368
|
+
const base = parseDef2(def.innerType._def, {
|
|
10369
|
+
...refs,
|
|
10370
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
10371
|
+
});
|
|
10372
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
10373
|
+
}
|
|
10374
|
+
function parseNumberDef2(def) {
|
|
10375
|
+
const res = {
|
|
10376
|
+
type: "number"
|
|
10377
|
+
};
|
|
10378
|
+
if (!def.checks)
|
|
10379
|
+
return res;
|
|
10380
|
+
for (const check of def.checks) {
|
|
10381
|
+
switch (check.kind) {
|
|
10382
|
+
case "int":
|
|
10383
|
+
res.type = "integer";
|
|
10384
|
+
break;
|
|
10385
|
+
case "min":
|
|
10386
|
+
if (check.inclusive) {
|
|
10387
|
+
res.minimum = check.value;
|
|
10388
|
+
} else {
|
|
10389
|
+
res.exclusiveMinimum = check.value;
|
|
10390
|
+
}
|
|
10391
|
+
break;
|
|
10392
|
+
case "max":
|
|
10393
|
+
if (check.inclusive) {
|
|
10394
|
+
res.maximum = check.value;
|
|
10395
|
+
} else {
|
|
10396
|
+
res.exclusiveMaximum = check.value;
|
|
10397
|
+
}
|
|
10398
|
+
break;
|
|
10399
|
+
case "multipleOf":
|
|
10400
|
+
res.multipleOf = check.value;
|
|
10401
|
+
break;
|
|
10402
|
+
}
|
|
10403
|
+
}
|
|
10404
|
+
return res;
|
|
10405
|
+
}
|
|
10406
|
+
function parseObjectDef2(def, refs) {
|
|
10407
|
+
const result = {
|
|
10408
|
+
type: "object",
|
|
10409
|
+
properties: {}
|
|
10410
|
+
};
|
|
10411
|
+
const required = [];
|
|
10412
|
+
const shape = def.shape();
|
|
10413
|
+
for (const propName in shape) {
|
|
10414
|
+
let propDef = shape[propName];
|
|
10415
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
10416
|
+
continue;
|
|
10417
|
+
}
|
|
10418
|
+
const propOptional = safeIsOptional2(propDef);
|
|
10419
|
+
const parsedDef = parseDef2(propDef._def, {
|
|
10420
|
+
...refs,
|
|
10421
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
10422
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
10423
|
+
});
|
|
10424
|
+
if (parsedDef === void 0) {
|
|
10425
|
+
continue;
|
|
10426
|
+
}
|
|
10427
|
+
result.properties[propName] = parsedDef;
|
|
10428
|
+
if (!propOptional) {
|
|
10429
|
+
required.push(propName);
|
|
10430
|
+
}
|
|
10431
|
+
}
|
|
10432
|
+
if (required.length) {
|
|
10433
|
+
result.required = required;
|
|
10434
|
+
}
|
|
10435
|
+
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
10436
|
+
if (additionalProperties !== void 0) {
|
|
10437
|
+
result.additionalProperties = additionalProperties;
|
|
10438
|
+
}
|
|
10439
|
+
return result;
|
|
10440
|
+
}
|
|
10441
|
+
function decideAdditionalProperties2(def, refs) {
|
|
10442
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
10443
|
+
return parseDef2(def.catchall._def, {
|
|
10444
|
+
...refs,
|
|
10445
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10446
|
+
});
|
|
10447
|
+
}
|
|
10448
|
+
switch (def.unknownKeys) {
|
|
10449
|
+
case "passthrough":
|
|
10450
|
+
return refs.allowedAdditionalProperties;
|
|
10451
|
+
case "strict":
|
|
10452
|
+
return refs.rejectedAdditionalProperties;
|
|
10453
|
+
case "strip":
|
|
10454
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
function safeIsOptional2(schema) {
|
|
10458
|
+
try {
|
|
10459
|
+
return schema.isOptional();
|
|
10460
|
+
} catch (e2) {
|
|
10461
|
+
return true;
|
|
10462
|
+
}
|
|
10463
|
+
}
|
|
10464
|
+
var parseOptionalDef2 = (def, refs) => {
|
|
10465
|
+
var _a20;
|
|
10466
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
10467
|
+
return parseDef2(def.innerType._def, refs);
|
|
10468
|
+
}
|
|
10469
|
+
const innerSchema = parseDef2(def.innerType._def, {
|
|
10470
|
+
...refs,
|
|
10471
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
10472
|
+
});
|
|
10473
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
10474
|
+
};
|
|
10475
|
+
var parsePipelineDef2 = (def, refs) => {
|
|
10476
|
+
if (refs.pipeStrategy === "input") {
|
|
10477
|
+
return parseDef2(def.in._def, refs);
|
|
10478
|
+
} else if (refs.pipeStrategy === "output") {
|
|
10479
|
+
return parseDef2(def.out._def, refs);
|
|
10480
|
+
}
|
|
10481
|
+
const a = parseDef2(def.in._def, {
|
|
10482
|
+
...refs,
|
|
10483
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
10484
|
+
});
|
|
10485
|
+
const b = parseDef2(def.out._def, {
|
|
10486
|
+
...refs,
|
|
10487
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
10488
|
+
});
|
|
10489
|
+
return {
|
|
10490
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
10491
|
+
};
|
|
10492
|
+
};
|
|
10493
|
+
function parsePromiseDef2(def, refs) {
|
|
10494
|
+
return parseDef2(def.type._def, refs);
|
|
10495
|
+
}
|
|
10496
|
+
function parseSetDef2(def, refs) {
|
|
10497
|
+
const items = parseDef2(def.valueType._def, {
|
|
10498
|
+
...refs,
|
|
10499
|
+
currentPath: [...refs.currentPath, "items"]
|
|
10500
|
+
});
|
|
10501
|
+
const schema = {
|
|
10502
|
+
type: "array",
|
|
10503
|
+
uniqueItems: true,
|
|
10504
|
+
items
|
|
10505
|
+
};
|
|
10506
|
+
if (def.minSize) {
|
|
10507
|
+
schema.minItems = def.minSize.value;
|
|
10508
|
+
}
|
|
10509
|
+
if (def.maxSize) {
|
|
10510
|
+
schema.maxItems = def.maxSize.value;
|
|
10511
|
+
}
|
|
10512
|
+
return schema;
|
|
10513
|
+
}
|
|
10514
|
+
function parseTupleDef2(def, refs) {
|
|
10515
|
+
if (def.rest) {
|
|
10516
|
+
return {
|
|
10517
|
+
type: "array",
|
|
10518
|
+
minItems: def.items.length,
|
|
10519
|
+
items: def.items.map(
|
|
10520
|
+
(x, i) => parseDef2(x._def, {
|
|
10521
|
+
...refs,
|
|
10522
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10523
|
+
})
|
|
10524
|
+
).reduce(
|
|
10525
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10526
|
+
[]
|
|
10527
|
+
),
|
|
10528
|
+
additionalItems: parseDef2(def.rest._def, {
|
|
10529
|
+
...refs,
|
|
10530
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
10531
|
+
})
|
|
10532
|
+
};
|
|
10533
|
+
} else {
|
|
10534
|
+
return {
|
|
10535
|
+
type: "array",
|
|
10536
|
+
minItems: def.items.length,
|
|
10537
|
+
maxItems: def.items.length,
|
|
10538
|
+
items: def.items.map(
|
|
10539
|
+
(x, i) => parseDef2(x._def, {
|
|
10540
|
+
...refs,
|
|
10541
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10542
|
+
})
|
|
10543
|
+
).reduce(
|
|
10544
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10545
|
+
[]
|
|
10546
|
+
)
|
|
10547
|
+
};
|
|
10548
|
+
}
|
|
10549
|
+
}
|
|
10550
|
+
function parseUndefinedDef2() {
|
|
10551
|
+
return {
|
|
10552
|
+
not: parseAnyDef2()
|
|
10553
|
+
};
|
|
10554
|
+
}
|
|
10555
|
+
function parseUnknownDef2() {
|
|
10556
|
+
return parseAnyDef2();
|
|
10557
|
+
}
|
|
10558
|
+
var parseReadonlyDef2 = (def, refs) => {
|
|
10559
|
+
return parseDef2(def.innerType._def, refs);
|
|
10560
|
+
};
|
|
10561
|
+
var selectParser2 = (def, typeName, refs) => {
|
|
10562
|
+
switch (typeName) {
|
|
10563
|
+
case v3.ZodFirstPartyTypeKind.ZodString:
|
|
10564
|
+
return parseStringDef2(def, refs);
|
|
10565
|
+
case v3.ZodFirstPartyTypeKind.ZodNumber:
|
|
10566
|
+
return parseNumberDef2(def);
|
|
10567
|
+
case v3.ZodFirstPartyTypeKind.ZodObject:
|
|
10568
|
+
return parseObjectDef2(def, refs);
|
|
10569
|
+
case v3.ZodFirstPartyTypeKind.ZodBigInt:
|
|
10570
|
+
return parseBigintDef2(def);
|
|
10571
|
+
case v3.ZodFirstPartyTypeKind.ZodBoolean:
|
|
10572
|
+
return parseBooleanDef2();
|
|
10573
|
+
case v3.ZodFirstPartyTypeKind.ZodDate:
|
|
10574
|
+
return parseDateDef2(def, refs);
|
|
10575
|
+
case v3.ZodFirstPartyTypeKind.ZodUndefined:
|
|
10576
|
+
return parseUndefinedDef2();
|
|
10577
|
+
case v3.ZodFirstPartyTypeKind.ZodNull:
|
|
10578
|
+
return parseNullDef2();
|
|
10579
|
+
case v3.ZodFirstPartyTypeKind.ZodArray:
|
|
10580
|
+
return parseArrayDef2(def, refs);
|
|
10581
|
+
case v3.ZodFirstPartyTypeKind.ZodUnion:
|
|
10582
|
+
case v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
10583
|
+
return parseUnionDef2(def, refs);
|
|
10584
|
+
case v3.ZodFirstPartyTypeKind.ZodIntersection:
|
|
10585
|
+
return parseIntersectionDef2(def, refs);
|
|
10586
|
+
case v3.ZodFirstPartyTypeKind.ZodTuple:
|
|
10587
|
+
return parseTupleDef2(def, refs);
|
|
10588
|
+
case v3.ZodFirstPartyTypeKind.ZodRecord:
|
|
10589
|
+
return parseRecordDef2(def, refs);
|
|
10590
|
+
case v3.ZodFirstPartyTypeKind.ZodLiteral:
|
|
10591
|
+
return parseLiteralDef2(def);
|
|
10592
|
+
case v3.ZodFirstPartyTypeKind.ZodEnum:
|
|
10593
|
+
return parseEnumDef2(def);
|
|
10594
|
+
case v3.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
10595
|
+
return parseNativeEnumDef2(def);
|
|
10596
|
+
case v3.ZodFirstPartyTypeKind.ZodNullable:
|
|
10597
|
+
return parseNullableDef2(def, refs);
|
|
10598
|
+
case v3.ZodFirstPartyTypeKind.ZodOptional:
|
|
10599
|
+
return parseOptionalDef2(def, refs);
|
|
10600
|
+
case v3.ZodFirstPartyTypeKind.ZodMap:
|
|
10601
|
+
return parseMapDef2(def, refs);
|
|
10602
|
+
case v3.ZodFirstPartyTypeKind.ZodSet:
|
|
10603
|
+
return parseSetDef2(def, refs);
|
|
10604
|
+
case v3.ZodFirstPartyTypeKind.ZodLazy:
|
|
10605
|
+
return () => def.getter()._def;
|
|
10606
|
+
case v3.ZodFirstPartyTypeKind.ZodPromise:
|
|
10607
|
+
return parsePromiseDef2(def, refs);
|
|
10608
|
+
case v3.ZodFirstPartyTypeKind.ZodNaN:
|
|
10609
|
+
case v3.ZodFirstPartyTypeKind.ZodNever:
|
|
10610
|
+
return parseNeverDef2();
|
|
10611
|
+
case v3.ZodFirstPartyTypeKind.ZodEffects:
|
|
10612
|
+
return parseEffectsDef2(def, refs);
|
|
10613
|
+
case v3.ZodFirstPartyTypeKind.ZodAny:
|
|
10614
|
+
return parseAnyDef2();
|
|
10615
|
+
case v3.ZodFirstPartyTypeKind.ZodUnknown:
|
|
10616
|
+
return parseUnknownDef2();
|
|
10617
|
+
case v3.ZodFirstPartyTypeKind.ZodDefault:
|
|
10618
|
+
return parseDefaultDef2(def, refs);
|
|
10619
|
+
case v3.ZodFirstPartyTypeKind.ZodBranded:
|
|
10620
|
+
return parseBrandedDef2(def, refs);
|
|
10621
|
+
case v3.ZodFirstPartyTypeKind.ZodReadonly:
|
|
10622
|
+
return parseReadonlyDef2(def, refs);
|
|
10623
|
+
case v3.ZodFirstPartyTypeKind.ZodCatch:
|
|
10624
|
+
return parseCatchDef2(def, refs);
|
|
10625
|
+
case v3.ZodFirstPartyTypeKind.ZodPipeline:
|
|
10626
|
+
return parsePipelineDef2(def, refs);
|
|
10627
|
+
case v3.ZodFirstPartyTypeKind.ZodFunction:
|
|
10628
|
+
case v3.ZodFirstPartyTypeKind.ZodVoid:
|
|
10629
|
+
case v3.ZodFirstPartyTypeKind.ZodSymbol:
|
|
10630
|
+
return void 0;
|
|
10631
|
+
default:
|
|
10632
|
+
return /* @__PURE__ */ ((_) => void 0)();
|
|
10633
|
+
}
|
|
10634
|
+
};
|
|
10635
|
+
function parseDef2(def, refs, forceResolution = false) {
|
|
10636
|
+
var _a20;
|
|
10637
|
+
const seenItem = refs.seen.get(def);
|
|
10638
|
+
if (refs.override) {
|
|
10639
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
10640
|
+
refs,
|
|
10641
|
+
def,
|
|
10642
|
+
refs,
|
|
10643
|
+
seenItem,
|
|
10644
|
+
forceResolution
|
|
10645
|
+
);
|
|
10646
|
+
if (overrideResult !== ignoreOverride2) {
|
|
10647
|
+
return overrideResult;
|
|
10648
|
+
}
|
|
10649
|
+
}
|
|
10650
|
+
if (seenItem && !forceResolution) {
|
|
10651
|
+
const seenSchema = get$ref2(seenItem, refs);
|
|
10652
|
+
if (seenSchema !== void 0) {
|
|
10653
|
+
return seenSchema;
|
|
10654
|
+
}
|
|
10655
|
+
}
|
|
10656
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
10657
|
+
refs.seen.set(def, newItem);
|
|
10658
|
+
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
10659
|
+
const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10660
|
+
if (jsonSchema22) {
|
|
10661
|
+
addMeta2(def, refs, jsonSchema22);
|
|
10662
|
+
}
|
|
10663
|
+
if (refs.postProcess) {
|
|
10664
|
+
const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
|
|
10665
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10666
|
+
return postProcessResult;
|
|
10667
|
+
}
|
|
10668
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10669
|
+
return jsonSchema22;
|
|
10670
|
+
}
|
|
10671
|
+
var get$ref2 = (item, refs) => {
|
|
10672
|
+
switch (refs.$refStrategy) {
|
|
10673
|
+
case "root":
|
|
10674
|
+
return { $ref: item.path.join("/") };
|
|
10675
|
+
case "relative":
|
|
10676
|
+
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
10677
|
+
case "none":
|
|
10678
|
+
case "seen": {
|
|
10679
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
10680
|
+
console.warn(
|
|
10681
|
+
`Recursive reference detected at ${refs.currentPath.join(
|
|
10682
|
+
"/"
|
|
10683
|
+
)}! Defaulting to any`
|
|
10684
|
+
);
|
|
10685
|
+
return parseAnyDef2();
|
|
10686
|
+
}
|
|
10687
|
+
return refs.$refStrategy === "seen" ? parseAnyDef2() : void 0;
|
|
10688
|
+
}
|
|
10689
|
+
}
|
|
10690
|
+
};
|
|
10691
|
+
var addMeta2 = (def, refs, jsonSchema22) => {
|
|
10692
|
+
if (def.description) {
|
|
10693
|
+
jsonSchema22.description = def.description;
|
|
10694
|
+
}
|
|
10695
|
+
return jsonSchema22;
|
|
10696
|
+
};
|
|
10697
|
+
var getRefs2 = (options) => {
|
|
10698
|
+
const _options = getDefaultOptions2(options);
|
|
10699
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
10700
|
+
return {
|
|
10701
|
+
..._options,
|
|
10702
|
+
currentPath,
|
|
10703
|
+
propertyPath: void 0,
|
|
10704
|
+
seen: new Map(
|
|
10705
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
10706
|
+
def._def,
|
|
10707
|
+
{
|
|
10708
|
+
def: def._def,
|
|
10709
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
10710
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
10711
|
+
jsonSchema: void 0
|
|
10712
|
+
}
|
|
10713
|
+
])
|
|
10714
|
+
)
|
|
10715
|
+
};
|
|
10716
|
+
};
|
|
10717
|
+
var zodToJsonSchema3 = (schema, options) => {
|
|
10718
|
+
var _a20;
|
|
10719
|
+
const refs = getRefs2(options);
|
|
10720
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
10721
|
+
(acc, [name25, schema2]) => {
|
|
10722
|
+
var _a25;
|
|
10723
|
+
return {
|
|
10724
|
+
...acc,
|
|
10725
|
+
[name25]: (_a25 = parseDef2(
|
|
10726
|
+
schema2._def,
|
|
10727
|
+
{
|
|
10728
|
+
...refs,
|
|
10729
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
10730
|
+
},
|
|
10731
|
+
true
|
|
10732
|
+
)) != null ? _a25 : parseAnyDef2()
|
|
10733
|
+
};
|
|
10734
|
+
},
|
|
10735
|
+
{}
|
|
10736
|
+
) : void 0;
|
|
10737
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
10738
|
+
const main = (_a20 = parseDef2(
|
|
10739
|
+
schema._def,
|
|
10740
|
+
name20 === void 0 ? refs : {
|
|
10741
|
+
...refs,
|
|
10742
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
10743
|
+
},
|
|
10744
|
+
false
|
|
10745
|
+
)) != null ? _a20 : parseAnyDef2();
|
|
10746
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10747
|
+
if (title !== void 0) {
|
|
10748
|
+
main.title = title;
|
|
10749
|
+
}
|
|
10750
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
10751
|
+
...main,
|
|
10752
|
+
[refs.definitionPath]: definitions
|
|
10753
|
+
} : main : {
|
|
10754
|
+
$ref: [
|
|
10755
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10756
|
+
refs.definitionPath,
|
|
10757
|
+
name20
|
|
10758
|
+
].join("/"),
|
|
10759
|
+
[refs.definitionPath]: {
|
|
10760
|
+
...definitions,
|
|
10761
|
+
[name20]: main
|
|
10762
|
+
}
|
|
10763
|
+
};
|
|
10764
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10765
|
+
return combined;
|
|
10766
|
+
};
|
|
10767
|
+
var zod_to_json_schema_default2 = zodToJsonSchema3;
|
|
10768
|
+
function zod3Schema2(zodSchema22, options) {
|
|
10769
|
+
var _a20;
|
|
10770
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10771
|
+
return jsonSchema3(
|
|
10772
|
+
zod_to_json_schema_default2(zodSchema22, {
|
|
10773
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
10774
|
+
}),
|
|
10775
|
+
{
|
|
10776
|
+
validate: async (value) => {
|
|
10777
|
+
const result = await zodSchema22.safeParseAsync(value);
|
|
10778
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10779
|
+
}
|
|
10780
|
+
}
|
|
10781
|
+
);
|
|
10782
|
+
}
|
|
10783
|
+
function zod4Schema2(zodSchema22, options) {
|
|
10784
|
+
var _a20;
|
|
10785
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10786
|
+
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
10787
|
+
target: "draft-7",
|
|
10788
|
+
io: "output",
|
|
10789
|
+
reused: useReferences ? "ref" : "inline"
|
|
10790
|
+
});
|
|
10791
|
+
return jsonSchema3(z4JSONSchema, {
|
|
10792
|
+
validate: async (value) => {
|
|
10793
|
+
const result = await z42__namespace.safeParseAsync(zodSchema22, value);
|
|
10794
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10795
|
+
}
|
|
10796
|
+
});
|
|
10797
|
+
}
|
|
10798
|
+
function isZod4Schema2(zodSchema22) {
|
|
10799
|
+
return "_zod" in zodSchema22;
|
|
10800
|
+
}
|
|
10801
|
+
function zodSchema3(zodSchema22, options) {
|
|
10802
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
10803
|
+
return zod4Schema2(zodSchema22);
|
|
10804
|
+
} else {
|
|
10805
|
+
return zod3Schema2(zodSchema22);
|
|
10806
|
+
}
|
|
10807
|
+
}
|
|
10808
|
+
var schemaSymbol3 = Symbol.for("vercel.ai.schema");
|
|
10809
|
+
function jsonSchema3(jsonSchema22, {
|
|
10810
|
+
validate
|
|
10811
|
+
} = {}) {
|
|
10812
|
+
return {
|
|
10813
|
+
[schemaSymbol3]: true,
|
|
10814
|
+
_type: void 0,
|
|
10815
|
+
// should never be used directly
|
|
10816
|
+
[validatorSymbol3]: true,
|
|
10817
|
+
jsonSchema: jsonSchema22,
|
|
10818
|
+
validate
|
|
10819
|
+
};
|
|
10820
|
+
}
|
|
10821
|
+
function isSchema3(value) {
|
|
10822
|
+
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
10823
|
+
}
|
|
10824
|
+
function asSchema3(schema) {
|
|
10825
|
+
return schema == null ? jsonSchema3({
|
|
10826
|
+
properties: {},
|
|
10827
|
+
additionalProperties: false
|
|
10828
|
+
}) : isSchema3(schema) ? schema : zodSchema3(schema);
|
|
10829
|
+
}
|
|
10830
|
+
var __defProp4 = Object.defineProperty;
|
|
10831
|
+
var __export4 = (target, all) => {
|
|
10832
|
+
for (var name172 in all)
|
|
10833
|
+
__defProp4(target, name172, { get: all[name172], enumerable: true });
|
|
10834
|
+
};
|
|
10835
|
+
var name73 = "AI_NoObjectGeneratedError";
|
|
10836
|
+
var marker74 = `vercel.ai.error.${name73}`;
|
|
10837
|
+
var symbol74 = Symbol.for(marker74);
|
|
10838
|
+
var _a74;
|
|
10839
|
+
var NoObjectGeneratedError3 = class extends chunkHVBBFCDH_cjs.AISDKError {
|
|
10840
|
+
constructor({
|
|
10841
|
+
message = "No object generated.",
|
|
10842
|
+
cause,
|
|
10843
|
+
text: text22,
|
|
10844
|
+
response,
|
|
10845
|
+
usage,
|
|
10846
|
+
finishReason
|
|
10847
|
+
}) {
|
|
10848
|
+
super({ name: name73, message, cause });
|
|
10849
|
+
this[_a74] = true;
|
|
10850
|
+
this.text = text22;
|
|
10851
|
+
this.response = response;
|
|
10852
|
+
this.usage = usage;
|
|
10853
|
+
this.finishReason = finishReason;
|
|
10854
|
+
}
|
|
10855
|
+
static isInstance(error) {
|
|
10856
|
+
return chunkHVBBFCDH_cjs.AISDKError.hasMarker(error, marker74);
|
|
10857
|
+
}
|
|
10858
|
+
};
|
|
10859
|
+
_a74 = symbol74;
|
|
10860
|
+
var dataContentSchema3 = z42.z.union([
|
|
10861
|
+
z42.z.string(),
|
|
10862
|
+
z42.z.instanceof(Uint8Array),
|
|
10863
|
+
z42.z.instanceof(ArrayBuffer),
|
|
10864
|
+
z42.z.custom(
|
|
10865
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
10866
|
+
(value) => {
|
|
10867
|
+
var _a172, _b8;
|
|
10868
|
+
return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
|
|
10869
|
+
},
|
|
10870
|
+
{ message: "Must be a Buffer" }
|
|
10871
|
+
)
|
|
10872
|
+
]);
|
|
10873
|
+
var jsonValueSchema3 = z42.z.lazy(
|
|
10874
|
+
() => z42.z.union([
|
|
10875
|
+
z42.z.null(),
|
|
10876
|
+
z42.z.string(),
|
|
10877
|
+
z42.z.number(),
|
|
10878
|
+
z42.z.boolean(),
|
|
10879
|
+
z42.z.record(z42.z.string(), jsonValueSchema3),
|
|
10880
|
+
z42.z.array(jsonValueSchema3)
|
|
10881
|
+
])
|
|
10882
|
+
);
|
|
10883
|
+
var providerMetadataSchema3 = z42.z.record(
|
|
10884
|
+
z42.z.string(),
|
|
10885
|
+
z42.z.record(z42.z.string(), jsonValueSchema3)
|
|
10886
|
+
);
|
|
10887
|
+
var textPartSchema3 = z42.z.object({
|
|
10888
|
+
type: z42.z.literal("text"),
|
|
10889
|
+
text: z42.z.string(),
|
|
10890
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10891
|
+
});
|
|
10892
|
+
var imagePartSchema3 = z42.z.object({
|
|
10893
|
+
type: z42.z.literal("image"),
|
|
10894
|
+
image: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10895
|
+
mediaType: z42.z.string().optional(),
|
|
10896
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10897
|
+
});
|
|
10898
|
+
var filePartSchema3 = z42.z.object({
|
|
10899
|
+
type: z42.z.literal("file"),
|
|
10900
|
+
data: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10901
|
+
filename: z42.z.string().optional(),
|
|
10902
|
+
mediaType: z42.z.string(),
|
|
10903
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10904
|
+
});
|
|
10905
|
+
var reasoningPartSchema3 = z42.z.object({
|
|
10906
|
+
type: z42.z.literal("reasoning"),
|
|
10907
|
+
text: z42.z.string(),
|
|
10908
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10909
|
+
});
|
|
10910
|
+
var toolCallPartSchema3 = z42.z.object({
|
|
10911
|
+
type: z42.z.literal("tool-call"),
|
|
10912
|
+
toolCallId: z42.z.string(),
|
|
10913
|
+
toolName: z42.z.string(),
|
|
10914
|
+
input: z42.z.unknown(),
|
|
10915
|
+
providerOptions: providerMetadataSchema3.optional(),
|
|
10916
|
+
providerExecuted: z42.z.boolean().optional()
|
|
10917
|
+
});
|
|
10918
|
+
var outputSchema2 = z42.z.discriminatedUnion("type", [
|
|
10919
|
+
z42.z.object({
|
|
10920
|
+
type: z42.z.literal("text"),
|
|
10921
|
+
value: z42.z.string()
|
|
10922
|
+
}),
|
|
10923
|
+
z42.z.object({
|
|
10924
|
+
type: z42.z.literal("json"),
|
|
10925
|
+
value: jsonValueSchema3
|
|
10926
|
+
}),
|
|
10927
|
+
z42.z.object({
|
|
10928
|
+
type: z42.z.literal("error-text"),
|
|
10929
|
+
value: z42.z.string()
|
|
10930
|
+
}),
|
|
10931
|
+
z42.z.object({
|
|
10932
|
+
type: z42.z.literal("error-json"),
|
|
10933
|
+
value: jsonValueSchema3
|
|
10934
|
+
}),
|
|
10935
|
+
z42.z.object({
|
|
10936
|
+
type: z42.z.literal("content"),
|
|
10937
|
+
value: z42.z.array(
|
|
10938
|
+
z42.z.union([
|
|
10939
|
+
z42.z.object({
|
|
10940
|
+
type: z42.z.literal("text"),
|
|
10941
|
+
text: z42.z.string()
|
|
10942
|
+
}),
|
|
10943
|
+
z42.z.object({
|
|
10944
|
+
type: z42.z.literal("media"),
|
|
10945
|
+
data: z42.z.string(),
|
|
10946
|
+
mediaType: z42.z.string()
|
|
10947
|
+
})
|
|
10948
|
+
])
|
|
10949
|
+
)
|
|
10950
|
+
})
|
|
10951
|
+
]);
|
|
10952
|
+
var toolResultPartSchema3 = z42.z.object({
|
|
10953
|
+
type: z42.z.literal("tool-result"),
|
|
10954
|
+
toolCallId: z42.z.string(),
|
|
10955
|
+
toolName: z42.z.string(),
|
|
10956
|
+
output: outputSchema2,
|
|
10957
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10958
|
+
});
|
|
10959
|
+
var systemModelMessageSchema2 = z42.z.object(
|
|
10960
|
+
{
|
|
10961
|
+
role: z42.z.literal("system"),
|
|
10962
|
+
content: z42.z.string(),
|
|
10963
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10964
|
+
}
|
|
10965
|
+
);
|
|
10966
|
+
var userModelMessageSchema2 = z42.z.object({
|
|
10967
|
+
role: z42.z.literal("user"),
|
|
10968
|
+
content: z42.z.union([
|
|
10969
|
+
z42.z.string(),
|
|
10970
|
+
z42.z.array(z42.z.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
|
|
10971
|
+
]),
|
|
10972
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10973
|
+
});
|
|
10974
|
+
var assistantModelMessageSchema2 = z42.z.object({
|
|
10975
|
+
role: z42.z.literal("assistant"),
|
|
10976
|
+
content: z42.z.union([
|
|
10977
|
+
z42.z.string(),
|
|
10978
|
+
z42.z.array(
|
|
10979
|
+
z42.z.union([
|
|
10980
|
+
textPartSchema3,
|
|
10981
|
+
filePartSchema3,
|
|
10982
|
+
reasoningPartSchema3,
|
|
10983
|
+
toolCallPartSchema3,
|
|
10984
|
+
toolResultPartSchema3
|
|
10985
|
+
])
|
|
10986
|
+
)
|
|
10987
|
+
]),
|
|
10988
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10989
|
+
});
|
|
10990
|
+
var toolModelMessageSchema2 = z42.z.object({
|
|
10991
|
+
role: z42.z.literal("tool"),
|
|
10992
|
+
content: z42.z.array(toolResultPartSchema3),
|
|
10993
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10994
|
+
});
|
|
10995
|
+
z42.z.union([
|
|
10996
|
+
systemModelMessageSchema2,
|
|
10997
|
+
userModelMessageSchema2,
|
|
10998
|
+
assistantModelMessageSchema2,
|
|
10999
|
+
toolModelMessageSchema2
|
|
11000
|
+
]);
|
|
11001
|
+
function stepCountIs(stepCount) {
|
|
11002
|
+
return ({ steps }) => steps.length === stepCount;
|
|
11003
|
+
}
|
|
11004
|
+
createIdGenerator3({
|
|
11005
|
+
prefix: "aitxt",
|
|
11006
|
+
size: 24
|
|
11007
|
+
});
|
|
11008
|
+
z42.z.union([
|
|
11009
|
+
z42.z.strictObject({
|
|
11010
|
+
type: z42.z.literal("text-start"),
|
|
11011
|
+
id: z42.z.string(),
|
|
11012
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11013
|
+
}),
|
|
11014
|
+
z42.z.strictObject({
|
|
11015
|
+
type: z42.z.literal("text-delta"),
|
|
11016
|
+
id: z42.z.string(),
|
|
11017
|
+
delta: z42.z.string(),
|
|
11018
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11019
|
+
}),
|
|
11020
|
+
z42.z.strictObject({
|
|
11021
|
+
type: z42.z.literal("text-end"),
|
|
11022
|
+
id: z42.z.string(),
|
|
11023
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11024
|
+
}),
|
|
11025
|
+
z42.z.strictObject({
|
|
11026
|
+
type: z42.z.literal("error"),
|
|
11027
|
+
errorText: z42.z.string()
|
|
11028
|
+
}),
|
|
11029
|
+
z42.z.strictObject({
|
|
11030
|
+
type: z42.z.literal("tool-input-start"),
|
|
11031
|
+
toolCallId: z42.z.string(),
|
|
11032
|
+
toolName: z42.z.string(),
|
|
11033
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11034
|
+
dynamic: z42.z.boolean().optional()
|
|
11035
|
+
}),
|
|
11036
|
+
z42.z.strictObject({
|
|
11037
|
+
type: z42.z.literal("tool-input-delta"),
|
|
11038
|
+
toolCallId: z42.z.string(),
|
|
11039
|
+
inputTextDelta: z42.z.string()
|
|
11040
|
+
}),
|
|
11041
|
+
z42.z.strictObject({
|
|
11042
|
+
type: z42.z.literal("tool-input-available"),
|
|
11043
|
+
toolCallId: z42.z.string(),
|
|
11044
|
+
toolName: z42.z.string(),
|
|
11045
|
+
input: z42.z.unknown(),
|
|
11046
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11047
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11048
|
+
dynamic: z42.z.boolean().optional()
|
|
11049
|
+
}),
|
|
11050
|
+
z42.z.strictObject({
|
|
11051
|
+
type: z42.z.literal("tool-input-error"),
|
|
11052
|
+
toolCallId: z42.z.string(),
|
|
11053
|
+
toolName: z42.z.string(),
|
|
11054
|
+
input: z42.z.unknown(),
|
|
11055
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11056
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11057
|
+
dynamic: z42.z.boolean().optional(),
|
|
11058
|
+
errorText: z42.z.string()
|
|
11059
|
+
}),
|
|
11060
|
+
z42.z.strictObject({
|
|
11061
|
+
type: z42.z.literal("tool-output-available"),
|
|
11062
|
+
toolCallId: z42.z.string(),
|
|
11063
|
+
output: z42.z.unknown(),
|
|
11064
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11065
|
+
dynamic: z42.z.boolean().optional(),
|
|
11066
|
+
preliminary: z42.z.boolean().optional()
|
|
11067
|
+
}),
|
|
11068
|
+
z42.z.strictObject({
|
|
11069
|
+
type: z42.z.literal("tool-output-error"),
|
|
11070
|
+
toolCallId: z42.z.string(),
|
|
11071
|
+
errorText: z42.z.string(),
|
|
11072
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11073
|
+
dynamic: z42.z.boolean().optional()
|
|
11074
|
+
}),
|
|
11075
|
+
z42.z.strictObject({
|
|
11076
|
+
type: z42.z.literal("reasoning"),
|
|
11077
|
+
text: z42.z.string(),
|
|
11078
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11079
|
+
}),
|
|
11080
|
+
z42.z.strictObject({
|
|
11081
|
+
type: z42.z.literal("reasoning-start"),
|
|
11082
|
+
id: z42.z.string(),
|
|
11083
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11084
|
+
}),
|
|
11085
|
+
z42.z.strictObject({
|
|
11086
|
+
type: z42.z.literal("reasoning-delta"),
|
|
11087
|
+
id: z42.z.string(),
|
|
11088
|
+
delta: z42.z.string(),
|
|
11089
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11090
|
+
}),
|
|
11091
|
+
z42.z.strictObject({
|
|
11092
|
+
type: z42.z.literal("reasoning-end"),
|
|
11093
|
+
id: z42.z.string(),
|
|
11094
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11095
|
+
}),
|
|
11096
|
+
z42.z.strictObject({
|
|
11097
|
+
type: z42.z.literal("reasoning-part-finish")
|
|
11098
|
+
}),
|
|
11099
|
+
z42.z.strictObject({
|
|
11100
|
+
type: z42.z.literal("source-url"),
|
|
11101
|
+
sourceId: z42.z.string(),
|
|
11102
|
+
url: z42.z.string(),
|
|
11103
|
+
title: z42.z.string().optional(),
|
|
11104
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11105
|
+
}),
|
|
11106
|
+
z42.z.strictObject({
|
|
11107
|
+
type: z42.z.literal("source-document"),
|
|
11108
|
+
sourceId: z42.z.string(),
|
|
11109
|
+
mediaType: z42.z.string(),
|
|
11110
|
+
title: z42.z.string(),
|
|
11111
|
+
filename: z42.z.string().optional(),
|
|
11112
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11113
|
+
}),
|
|
11114
|
+
z42.z.strictObject({
|
|
11115
|
+
type: z42.z.literal("file"),
|
|
11116
|
+
url: z42.z.string(),
|
|
11117
|
+
mediaType: z42.z.string(),
|
|
11118
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11119
|
+
}),
|
|
11120
|
+
z42.z.strictObject({
|
|
11121
|
+
type: z42.z.string().startsWith("data-"),
|
|
11122
|
+
id: z42.z.string().optional(),
|
|
11123
|
+
data: z42.z.unknown(),
|
|
11124
|
+
transient: z42.z.boolean().optional()
|
|
11125
|
+
}),
|
|
11126
|
+
z42.z.strictObject({
|
|
11127
|
+
type: z42.z.literal("start-step")
|
|
11128
|
+
}),
|
|
11129
|
+
z42.z.strictObject({
|
|
11130
|
+
type: z42.z.literal("finish-step")
|
|
11131
|
+
}),
|
|
11132
|
+
z42.z.strictObject({
|
|
11133
|
+
type: z42.z.literal("start"),
|
|
11134
|
+
messageId: z42.z.string().optional(),
|
|
11135
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11136
|
+
}),
|
|
11137
|
+
z42.z.strictObject({
|
|
11138
|
+
type: z42.z.literal("finish"),
|
|
11139
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11140
|
+
}),
|
|
11141
|
+
z42.z.strictObject({
|
|
11142
|
+
type: z42.z.literal("abort")
|
|
11143
|
+
}),
|
|
11144
|
+
z42.z.strictObject({
|
|
11145
|
+
type: z42.z.literal("message-metadata"),
|
|
11146
|
+
messageMetadata: z42.z.unknown()
|
|
11147
|
+
})
|
|
11148
|
+
]);
|
|
11149
|
+
function fixJson3(input) {
|
|
11150
|
+
const stack = ["ROOT"];
|
|
11151
|
+
let lastValidIndex = -1;
|
|
11152
|
+
let literalStart = null;
|
|
11153
|
+
function processValueStart(char, i, swapState) {
|
|
11154
|
+
{
|
|
11155
|
+
switch (char) {
|
|
11156
|
+
case '"': {
|
|
11157
|
+
lastValidIndex = i;
|
|
11158
|
+
stack.pop();
|
|
11159
|
+
stack.push(swapState);
|
|
11160
|
+
stack.push("INSIDE_STRING");
|
|
11161
|
+
break;
|
|
11162
|
+
}
|
|
11163
|
+
case "f":
|
|
11164
|
+
case "t":
|
|
11165
|
+
case "n": {
|
|
11166
|
+
lastValidIndex = i;
|
|
11167
|
+
literalStart = i;
|
|
11168
|
+
stack.pop();
|
|
11169
|
+
stack.push(swapState);
|
|
11170
|
+
stack.push("INSIDE_LITERAL");
|
|
11171
|
+
break;
|
|
11172
|
+
}
|
|
11173
|
+
case "-": {
|
|
11174
|
+
stack.pop();
|
|
11175
|
+
stack.push(swapState);
|
|
11176
|
+
stack.push("INSIDE_NUMBER");
|
|
11177
|
+
break;
|
|
11178
|
+
}
|
|
11179
|
+
case "0":
|
|
11180
|
+
case "1":
|
|
11181
|
+
case "2":
|
|
11182
|
+
case "3":
|
|
11183
|
+
case "4":
|
|
11184
|
+
case "5":
|
|
11185
|
+
case "6":
|
|
11186
|
+
case "7":
|
|
11187
|
+
case "8":
|
|
11188
|
+
case "9": {
|
|
11189
|
+
lastValidIndex = i;
|
|
11190
|
+
stack.pop();
|
|
11191
|
+
stack.push(swapState);
|
|
11192
|
+
stack.push("INSIDE_NUMBER");
|
|
11193
|
+
break;
|
|
11194
|
+
}
|
|
11195
|
+
case "{": {
|
|
11196
|
+
lastValidIndex = i;
|
|
11197
|
+
stack.pop();
|
|
11198
|
+
stack.push(swapState);
|
|
11199
|
+
stack.push("INSIDE_OBJECT_START");
|
|
11200
|
+
break;
|
|
11201
|
+
}
|
|
11202
|
+
case "[": {
|
|
11203
|
+
lastValidIndex = i;
|
|
11204
|
+
stack.pop();
|
|
11205
|
+
stack.push(swapState);
|
|
11206
|
+
stack.push("INSIDE_ARRAY_START");
|
|
11207
|
+
break;
|
|
11208
|
+
}
|
|
11209
|
+
}
|
|
11210
|
+
}
|
|
11211
|
+
}
|
|
11212
|
+
function processAfterObjectValue(char, i) {
|
|
11213
|
+
switch (char) {
|
|
11214
|
+
case ",": {
|
|
11215
|
+
stack.pop();
|
|
11216
|
+
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
11217
|
+
break;
|
|
11218
|
+
}
|
|
11219
|
+
case "}": {
|
|
11220
|
+
lastValidIndex = i;
|
|
11221
|
+
stack.pop();
|
|
11222
|
+
break;
|
|
11223
|
+
}
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
11226
|
+
function processAfterArrayValue(char, i) {
|
|
11227
|
+
switch (char) {
|
|
11228
|
+
case ",": {
|
|
11229
|
+
stack.pop();
|
|
11230
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11231
|
+
break;
|
|
11232
|
+
}
|
|
11233
|
+
case "]": {
|
|
11234
|
+
lastValidIndex = i;
|
|
11235
|
+
stack.pop();
|
|
11236
|
+
break;
|
|
11237
|
+
}
|
|
11238
|
+
}
|
|
11239
|
+
}
|
|
11240
|
+
for (let i = 0; i < input.length; i++) {
|
|
11241
|
+
const char = input[i];
|
|
11242
|
+
const currentState = stack[stack.length - 1];
|
|
11243
|
+
switch (currentState) {
|
|
11244
|
+
case "ROOT":
|
|
11245
|
+
processValueStart(char, i, "FINISH");
|
|
11246
|
+
break;
|
|
11247
|
+
case "INSIDE_OBJECT_START": {
|
|
11248
|
+
switch (char) {
|
|
11249
|
+
case '"': {
|
|
11250
|
+
stack.pop();
|
|
11251
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11252
|
+
break;
|
|
11253
|
+
}
|
|
11254
|
+
case "}": {
|
|
11255
|
+
lastValidIndex = i;
|
|
11256
|
+
stack.pop();
|
|
11257
|
+
break;
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
break;
|
|
11261
|
+
}
|
|
11262
|
+
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
11263
|
+
switch (char) {
|
|
11264
|
+
case '"': {
|
|
11265
|
+
stack.pop();
|
|
11266
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11267
|
+
break;
|
|
11268
|
+
}
|
|
11269
|
+
}
|
|
11270
|
+
break;
|
|
11271
|
+
}
|
|
11272
|
+
case "INSIDE_OBJECT_KEY": {
|
|
11273
|
+
switch (char) {
|
|
11274
|
+
case '"': {
|
|
11275
|
+
stack.pop();
|
|
11276
|
+
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
11277
|
+
break;
|
|
11278
|
+
}
|
|
11279
|
+
}
|
|
11280
|
+
break;
|
|
11281
|
+
}
|
|
11282
|
+
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
11283
|
+
switch (char) {
|
|
11284
|
+
case ":": {
|
|
11285
|
+
stack.pop();
|
|
11286
|
+
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
11287
|
+
break;
|
|
11288
|
+
}
|
|
11289
|
+
}
|
|
11290
|
+
break;
|
|
11291
|
+
}
|
|
11292
|
+
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
11293
|
+
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
11294
|
+
break;
|
|
11295
|
+
}
|
|
11296
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11297
|
+
processAfterObjectValue(char, i);
|
|
11298
|
+
break;
|
|
11299
|
+
}
|
|
11300
|
+
case "INSIDE_STRING": {
|
|
11301
|
+
switch (char) {
|
|
11302
|
+
case '"': {
|
|
11303
|
+
stack.pop();
|
|
11304
|
+
lastValidIndex = i;
|
|
11305
|
+
break;
|
|
11306
|
+
}
|
|
11307
|
+
case "\\": {
|
|
11308
|
+
stack.push("INSIDE_STRING_ESCAPE");
|
|
11309
|
+
break;
|
|
11310
|
+
}
|
|
11311
|
+
default: {
|
|
11312
|
+
lastValidIndex = i;
|
|
11313
|
+
}
|
|
11314
|
+
}
|
|
11315
|
+
break;
|
|
11316
|
+
}
|
|
11317
|
+
case "INSIDE_ARRAY_START": {
|
|
11318
|
+
switch (char) {
|
|
11319
|
+
case "]": {
|
|
11320
|
+
lastValidIndex = i;
|
|
11321
|
+
stack.pop();
|
|
11322
|
+
break;
|
|
11323
|
+
}
|
|
11324
|
+
default: {
|
|
11325
|
+
lastValidIndex = i;
|
|
11326
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11327
|
+
break;
|
|
11328
|
+
}
|
|
11329
|
+
}
|
|
11330
|
+
break;
|
|
11331
|
+
}
|
|
11332
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11333
|
+
switch (char) {
|
|
11334
|
+
case ",": {
|
|
11335
|
+
stack.pop();
|
|
11336
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11337
|
+
break;
|
|
11338
|
+
}
|
|
11339
|
+
case "]": {
|
|
11340
|
+
lastValidIndex = i;
|
|
11341
|
+
stack.pop();
|
|
11342
|
+
break;
|
|
11343
|
+
}
|
|
11344
|
+
default: {
|
|
11345
|
+
lastValidIndex = i;
|
|
11346
|
+
break;
|
|
11347
|
+
}
|
|
11348
|
+
}
|
|
11349
|
+
break;
|
|
11350
|
+
}
|
|
11351
|
+
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
11352
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11353
|
+
break;
|
|
11354
|
+
}
|
|
11355
|
+
case "INSIDE_STRING_ESCAPE": {
|
|
11356
|
+
stack.pop();
|
|
11357
|
+
lastValidIndex = i;
|
|
11358
|
+
break;
|
|
11359
|
+
}
|
|
11360
|
+
case "INSIDE_NUMBER": {
|
|
11361
|
+
switch (char) {
|
|
11362
|
+
case "0":
|
|
11363
|
+
case "1":
|
|
11364
|
+
case "2":
|
|
11365
|
+
case "3":
|
|
11366
|
+
case "4":
|
|
11367
|
+
case "5":
|
|
11368
|
+
case "6":
|
|
11369
|
+
case "7":
|
|
11370
|
+
case "8":
|
|
11371
|
+
case "9": {
|
|
11372
|
+
lastValidIndex = i;
|
|
11373
|
+
break;
|
|
11374
|
+
}
|
|
11375
|
+
case "e":
|
|
11376
|
+
case "E":
|
|
11377
|
+
case "-":
|
|
11378
|
+
case ".": {
|
|
11379
|
+
break;
|
|
11380
|
+
}
|
|
11381
|
+
case ",": {
|
|
11382
|
+
stack.pop();
|
|
11383
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11384
|
+
processAfterArrayValue(char, i);
|
|
11385
|
+
}
|
|
11386
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11387
|
+
processAfterObjectValue(char, i);
|
|
11388
|
+
}
|
|
11389
|
+
break;
|
|
11390
|
+
}
|
|
11391
|
+
case "}": {
|
|
11392
|
+
stack.pop();
|
|
11393
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11394
|
+
processAfterObjectValue(char, i);
|
|
11395
|
+
}
|
|
11396
|
+
break;
|
|
11397
|
+
}
|
|
11398
|
+
case "]": {
|
|
11399
|
+
stack.pop();
|
|
11400
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11401
|
+
processAfterArrayValue(char, i);
|
|
11402
|
+
}
|
|
11403
|
+
break;
|
|
11404
|
+
}
|
|
11405
|
+
default: {
|
|
11406
|
+
stack.pop();
|
|
11407
|
+
break;
|
|
11408
|
+
}
|
|
11409
|
+
}
|
|
11410
|
+
break;
|
|
11411
|
+
}
|
|
11412
|
+
case "INSIDE_LITERAL": {
|
|
11413
|
+
const partialLiteral = input.substring(literalStart, i + 1);
|
|
11414
|
+
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
11415
|
+
stack.pop();
|
|
11416
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11417
|
+
processAfterObjectValue(char, i);
|
|
11418
|
+
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11419
|
+
processAfterArrayValue(char, i);
|
|
11420
|
+
}
|
|
11421
|
+
} else {
|
|
11422
|
+
lastValidIndex = i;
|
|
11423
|
+
}
|
|
11424
|
+
break;
|
|
11425
|
+
}
|
|
11426
|
+
}
|
|
11427
|
+
}
|
|
11428
|
+
let result = input.slice(0, lastValidIndex + 1);
|
|
11429
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
11430
|
+
const state = stack[i];
|
|
11431
|
+
switch (state) {
|
|
11432
|
+
case "INSIDE_STRING": {
|
|
11433
|
+
result += '"';
|
|
11434
|
+
break;
|
|
11435
|
+
}
|
|
11436
|
+
case "INSIDE_OBJECT_KEY":
|
|
11437
|
+
case "INSIDE_OBJECT_AFTER_KEY":
|
|
11438
|
+
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
11439
|
+
case "INSIDE_OBJECT_START":
|
|
11440
|
+
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
11441
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11442
|
+
result += "}";
|
|
11443
|
+
break;
|
|
11444
|
+
}
|
|
11445
|
+
case "INSIDE_ARRAY_START":
|
|
11446
|
+
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
11447
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11448
|
+
result += "]";
|
|
11449
|
+
break;
|
|
11450
|
+
}
|
|
11451
|
+
case "INSIDE_LITERAL": {
|
|
11452
|
+
const partialLiteral = input.substring(literalStart, input.length);
|
|
11453
|
+
if ("true".startsWith(partialLiteral)) {
|
|
11454
|
+
result += "true".slice(partialLiteral.length);
|
|
11455
|
+
} else if ("false".startsWith(partialLiteral)) {
|
|
11456
|
+
result += "false".slice(partialLiteral.length);
|
|
11457
|
+
} else if ("null".startsWith(partialLiteral)) {
|
|
11458
|
+
result += "null".slice(partialLiteral.length);
|
|
11459
|
+
}
|
|
11460
|
+
}
|
|
11461
|
+
}
|
|
11462
|
+
}
|
|
11463
|
+
return result;
|
|
11464
|
+
}
|
|
11465
|
+
async function parsePartialJson3(jsonText) {
|
|
11466
|
+
if (jsonText === void 0) {
|
|
11467
|
+
return { value: void 0, state: "undefined-input" };
|
|
11468
|
+
}
|
|
11469
|
+
let result = await safeParseJSON3({ text: jsonText });
|
|
11470
|
+
if (result.success) {
|
|
11471
|
+
return { value: result.value, state: "successful-parse" };
|
|
11472
|
+
}
|
|
11473
|
+
result = await safeParseJSON3({ text: fixJson3(jsonText) });
|
|
11474
|
+
if (result.success) {
|
|
11475
|
+
return { value: result.value, state: "repaired-parse" };
|
|
11476
|
+
}
|
|
11477
|
+
return { value: void 0, state: "failed-parse" };
|
|
11478
|
+
}
|
|
11479
|
+
createIdGenerator3({
|
|
11480
|
+
prefix: "aitxt",
|
|
11481
|
+
size: 24
|
|
11482
|
+
});
|
|
11483
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11484
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11485
|
+
var output_exports3 = {};
|
|
11486
|
+
__export4(output_exports3, {
|
|
11487
|
+
object: () => object3,
|
|
11488
|
+
text: () => text3
|
|
11489
|
+
});
|
|
11490
|
+
var text3 = () => ({
|
|
11491
|
+
type: "text",
|
|
11492
|
+
responseFormat: { type: "text" },
|
|
11493
|
+
async parsePartial({ text: text22 }) {
|
|
11494
|
+
return { partial: text22 };
|
|
11495
|
+
},
|
|
11496
|
+
async parseOutput({ text: text22 }) {
|
|
11497
|
+
return text22;
|
|
11498
|
+
}
|
|
11499
|
+
});
|
|
11500
|
+
var object3 = ({
|
|
11501
|
+
schema: inputSchema
|
|
11502
|
+
}) => {
|
|
11503
|
+
const schema = asSchema3(inputSchema);
|
|
11504
|
+
return {
|
|
11505
|
+
type: "object",
|
|
11506
|
+
responseFormat: {
|
|
11507
|
+
type: "json",
|
|
11508
|
+
schema: schema.jsonSchema
|
|
11509
|
+
},
|
|
11510
|
+
async parsePartial({ text: text22 }) {
|
|
11511
|
+
const result = await parsePartialJson3(text22);
|
|
11512
|
+
switch (result.state) {
|
|
11513
|
+
case "failed-parse":
|
|
11514
|
+
case "undefined-input":
|
|
11515
|
+
return void 0;
|
|
11516
|
+
case "repaired-parse":
|
|
11517
|
+
case "successful-parse":
|
|
11518
|
+
return {
|
|
11519
|
+
// Note: currently no validation of partial results:
|
|
11520
|
+
partial: result.value
|
|
11521
|
+
};
|
|
11522
|
+
default: {
|
|
11523
|
+
const _exhaustiveCheck = result.state;
|
|
11524
|
+
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
11525
|
+
}
|
|
11526
|
+
}
|
|
11527
|
+
},
|
|
11528
|
+
async parseOutput({ text: text22 }, context) {
|
|
11529
|
+
const parseResult = await safeParseJSON3({ text: text22 });
|
|
11530
|
+
if (!parseResult.success) {
|
|
11531
|
+
throw new NoObjectGeneratedError3({
|
|
11532
|
+
message: "No object generated: could not parse the response.",
|
|
11533
|
+
cause: parseResult.error,
|
|
11534
|
+
text: text22,
|
|
11535
|
+
response: context.response,
|
|
11536
|
+
usage: context.usage,
|
|
11537
|
+
finishReason: context.finishReason
|
|
11538
|
+
});
|
|
11539
|
+
}
|
|
11540
|
+
const validationResult = await safeValidateTypes3({
|
|
11541
|
+
value: parseResult.value,
|
|
11542
|
+
schema
|
|
11543
|
+
});
|
|
11544
|
+
if (!validationResult.success) {
|
|
11545
|
+
throw new NoObjectGeneratedError3({
|
|
11546
|
+
message: "No object generated: response did not match schema.",
|
|
11547
|
+
cause: validationResult.error,
|
|
11548
|
+
text: text22,
|
|
11549
|
+
response: context.response,
|
|
11550
|
+
usage: context.usage,
|
|
11551
|
+
finishReason: context.finishReason
|
|
11552
|
+
});
|
|
11553
|
+
}
|
|
11554
|
+
return validationResult.value;
|
|
11555
|
+
}
|
|
11556
|
+
};
|
|
11557
|
+
};
|
|
11558
|
+
var ClientOrServerImplementationSchema3 = z42.z.looseObject({
|
|
11559
|
+
name: z42.z.string(),
|
|
11560
|
+
version: z42.z.string()
|
|
11561
|
+
});
|
|
11562
|
+
var BaseParamsSchema3 = z42.z.looseObject({
|
|
11563
|
+
_meta: z42.z.optional(z42.z.object({}).loose())
|
|
11564
|
+
});
|
|
11565
|
+
var ResultSchema3 = BaseParamsSchema3;
|
|
11566
|
+
var RequestSchema3 = z42.z.object({
|
|
11567
|
+
method: z42.z.string(),
|
|
11568
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11569
|
+
});
|
|
11570
|
+
var ServerCapabilitiesSchema3 = z42.z.looseObject({
|
|
11571
|
+
experimental: z42.z.optional(z42.z.object({}).loose()),
|
|
11572
|
+
logging: z42.z.optional(z42.z.object({}).loose()),
|
|
11573
|
+
prompts: z42.z.optional(
|
|
11574
|
+
z42.z.looseObject({
|
|
11575
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11576
|
+
})
|
|
11577
|
+
),
|
|
11578
|
+
resources: z42.z.optional(
|
|
11579
|
+
z42.z.looseObject({
|
|
11580
|
+
subscribe: z42.z.optional(z42.z.boolean()),
|
|
11581
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11582
|
+
})
|
|
11583
|
+
),
|
|
11584
|
+
tools: z42.z.optional(
|
|
11585
|
+
z42.z.looseObject({
|
|
11586
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11587
|
+
})
|
|
11588
|
+
)
|
|
11589
|
+
});
|
|
11590
|
+
ResultSchema3.extend({
|
|
11591
|
+
protocolVersion: z42.z.string(),
|
|
11592
|
+
capabilities: ServerCapabilitiesSchema3,
|
|
11593
|
+
serverInfo: ClientOrServerImplementationSchema3,
|
|
11594
|
+
instructions: z42.z.optional(z42.z.string())
|
|
11595
|
+
});
|
|
11596
|
+
var PaginatedResultSchema3 = ResultSchema3.extend({
|
|
11597
|
+
nextCursor: z42.z.optional(z42.z.string())
|
|
11598
|
+
});
|
|
11599
|
+
var ToolSchema3 = z42.z.object({
|
|
11600
|
+
name: z42.z.string(),
|
|
11601
|
+
description: z42.z.optional(z42.z.string()),
|
|
11602
|
+
inputSchema: z42.z.object({
|
|
11603
|
+
type: z42.z.literal("object"),
|
|
11604
|
+
properties: z42.z.optional(z42.z.object({}).loose())
|
|
11605
|
+
}).loose()
|
|
11606
|
+
}).loose();
|
|
11607
|
+
PaginatedResultSchema3.extend({
|
|
11608
|
+
tools: z42.z.array(ToolSchema3)
|
|
11609
|
+
});
|
|
11610
|
+
var TextContentSchema3 = z42.z.object({
|
|
11611
|
+
type: z42.z.literal("text"),
|
|
11612
|
+
text: z42.z.string()
|
|
11613
|
+
}).loose();
|
|
11614
|
+
var ImageContentSchema3 = z42.z.object({
|
|
11615
|
+
type: z42.z.literal("image"),
|
|
11616
|
+
data: z42.z.base64(),
|
|
11617
|
+
mimeType: z42.z.string()
|
|
11618
|
+
}).loose();
|
|
11619
|
+
var ResourceContentsSchema3 = z42.z.object({
|
|
11620
|
+
/**
|
|
11621
|
+
* The URI of this resource.
|
|
11622
|
+
*/
|
|
11623
|
+
uri: z42.z.string(),
|
|
11624
|
+
/**
|
|
11625
|
+
* The MIME type of this resource, if known.
|
|
11626
|
+
*/
|
|
11627
|
+
mimeType: z42.z.optional(z42.z.string())
|
|
11628
|
+
}).loose();
|
|
11629
|
+
var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11630
|
+
text: z42.z.string()
|
|
11631
|
+
});
|
|
11632
|
+
var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11633
|
+
blob: z42.z.base64()
|
|
11634
|
+
});
|
|
11635
|
+
var EmbeddedResourceSchema3 = z42.z.object({
|
|
11636
|
+
type: z42.z.literal("resource"),
|
|
11637
|
+
resource: z42.z.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
|
|
11638
|
+
}).loose();
|
|
11639
|
+
ResultSchema3.extend({
|
|
11640
|
+
content: z42.z.array(
|
|
11641
|
+
z42.z.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
|
|
11642
|
+
),
|
|
11643
|
+
isError: z42.z.boolean().default(false).optional()
|
|
11644
|
+
}).or(
|
|
11645
|
+
ResultSchema3.extend({
|
|
11646
|
+
toolResult: z42.z.unknown()
|
|
11647
|
+
})
|
|
11648
|
+
);
|
|
11649
|
+
var JSONRPC_VERSION3 = "2.0";
|
|
11650
|
+
var JSONRPCRequestSchema3 = z42.z.object({
|
|
11651
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11652
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()])
|
|
11653
|
+
}).merge(RequestSchema3).strict();
|
|
11654
|
+
var JSONRPCResponseSchema3 = z42.z.object({
|
|
11655
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11656
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11657
|
+
result: ResultSchema3
|
|
11658
|
+
}).strict();
|
|
11659
|
+
var JSONRPCErrorSchema3 = z42.z.object({
|
|
11660
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11661
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11662
|
+
error: z42.z.object({
|
|
11663
|
+
code: z42.z.number().int(),
|
|
11664
|
+
message: z42.z.string(),
|
|
11665
|
+
data: z42.z.optional(z42.z.unknown())
|
|
11666
|
+
})
|
|
11667
|
+
}).strict();
|
|
11668
|
+
var JSONRPCNotificationSchema3 = z42.z.object({
|
|
11669
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3)
|
|
11670
|
+
}).merge(
|
|
11671
|
+
z42.z.object({
|
|
11672
|
+
method: z42.z.string(),
|
|
11673
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11674
|
+
})
|
|
11675
|
+
).strict();
|
|
11676
|
+
z42.z.union([
|
|
11677
|
+
JSONRPCRequestSchema3,
|
|
11678
|
+
JSONRPCNotificationSchema3,
|
|
11679
|
+
JSONRPCResponseSchema3,
|
|
11680
|
+
JSONRPCErrorSchema3
|
|
11681
|
+
]);
|
|
11682
|
+
var textUIPartSchema2 = z42.z.object({
|
|
11683
|
+
type: z42.z.literal("text"),
|
|
11684
|
+
text: z42.z.string(),
|
|
11685
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11686
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11687
|
+
});
|
|
11688
|
+
var reasoningUIPartSchema2 = z42.z.object({
|
|
11689
|
+
type: z42.z.literal("reasoning"),
|
|
11690
|
+
text: z42.z.string(),
|
|
11691
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11692
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11693
|
+
});
|
|
11694
|
+
var sourceUrlUIPartSchema2 = z42.z.object({
|
|
11695
|
+
type: z42.z.literal("source-url"),
|
|
11696
|
+
sourceId: z42.z.string(),
|
|
11697
|
+
url: z42.z.string(),
|
|
11698
|
+
title: z42.z.string().optional(),
|
|
11699
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11700
|
+
});
|
|
11701
|
+
var sourceDocumentUIPartSchema2 = z42.z.object({
|
|
11702
|
+
type: z42.z.literal("source-document"),
|
|
11703
|
+
sourceId: z42.z.string(),
|
|
11704
|
+
mediaType: z42.z.string(),
|
|
11705
|
+
title: z42.z.string(),
|
|
11706
|
+
filename: z42.z.string().optional(),
|
|
11707
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11708
|
+
});
|
|
11709
|
+
var fileUIPartSchema2 = z42.z.object({
|
|
11710
|
+
type: z42.z.literal("file"),
|
|
11711
|
+
mediaType: z42.z.string(),
|
|
11712
|
+
filename: z42.z.string().optional(),
|
|
11713
|
+
url: z42.z.string(),
|
|
11714
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11715
|
+
});
|
|
11716
|
+
var stepStartUIPartSchema2 = z42.z.object({
|
|
11717
|
+
type: z42.z.literal("step-start")
|
|
11718
|
+
});
|
|
11719
|
+
var dataUIPartSchema2 = z42.z.object({
|
|
11720
|
+
type: z42.z.string().startsWith("data-"),
|
|
11721
|
+
id: z42.z.string().optional(),
|
|
11722
|
+
data: z42.z.unknown()
|
|
11723
|
+
});
|
|
11724
|
+
var dynamicToolUIPartSchemas2 = [
|
|
11725
|
+
z42.z.object({
|
|
11726
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11727
|
+
toolName: z42.z.string(),
|
|
11728
|
+
toolCallId: z42.z.string(),
|
|
11729
|
+
state: z42.z.literal("input-streaming"),
|
|
11730
|
+
input: z42.z.unknown().optional(),
|
|
11731
|
+
output: z42.z.never().optional(),
|
|
11732
|
+
errorText: z42.z.never().optional()
|
|
11733
|
+
}),
|
|
11734
|
+
z42.z.object({
|
|
11735
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11736
|
+
toolName: z42.z.string(),
|
|
11737
|
+
toolCallId: z42.z.string(),
|
|
11738
|
+
state: z42.z.literal("input-available"),
|
|
11739
|
+
input: z42.z.unknown(),
|
|
11740
|
+
output: z42.z.never().optional(),
|
|
11741
|
+
errorText: z42.z.never().optional(),
|
|
11742
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11743
|
+
}),
|
|
11744
|
+
z42.z.object({
|
|
11745
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11746
|
+
toolName: z42.z.string(),
|
|
11747
|
+
toolCallId: z42.z.string(),
|
|
11748
|
+
state: z42.z.literal("output-available"),
|
|
11749
|
+
input: z42.z.unknown(),
|
|
11750
|
+
output: z42.z.unknown(),
|
|
11751
|
+
errorText: z42.z.never().optional(),
|
|
11752
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11753
|
+
preliminary: z42.z.boolean().optional()
|
|
11754
|
+
}),
|
|
11755
|
+
z42.z.object({
|
|
11756
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11757
|
+
toolName: z42.z.string(),
|
|
11758
|
+
toolCallId: z42.z.string(),
|
|
11759
|
+
state: z42.z.literal("output-error"),
|
|
11760
|
+
input: z42.z.unknown(),
|
|
11761
|
+
output: z42.z.never().optional(),
|
|
11762
|
+
errorText: z42.z.string(),
|
|
11763
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11764
|
+
})
|
|
11765
|
+
];
|
|
11766
|
+
var toolUIPartSchemas2 = [
|
|
11767
|
+
z42.z.object({
|
|
11768
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11769
|
+
toolCallId: z42.z.string(),
|
|
11770
|
+
state: z42.z.literal("input-streaming"),
|
|
11771
|
+
input: z42.z.unknown().optional(),
|
|
11772
|
+
output: z42.z.never().optional(),
|
|
11773
|
+
errorText: z42.z.never().optional()
|
|
11774
|
+
}),
|
|
11775
|
+
z42.z.object({
|
|
11776
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11777
|
+
toolCallId: z42.z.string(),
|
|
11778
|
+
state: z42.z.literal("input-available"),
|
|
11779
|
+
input: z42.z.unknown(),
|
|
11780
|
+
output: z42.z.never().optional(),
|
|
11781
|
+
errorText: z42.z.never().optional(),
|
|
11782
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11783
|
+
}),
|
|
11784
|
+
z42.z.object({
|
|
11785
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11786
|
+
toolCallId: z42.z.string(),
|
|
11787
|
+
state: z42.z.literal("output-available"),
|
|
11788
|
+
input: z42.z.unknown(),
|
|
11789
|
+
output: z42.z.unknown(),
|
|
11790
|
+
errorText: z42.z.never().optional(),
|
|
11791
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11792
|
+
preliminary: z42.z.boolean().optional()
|
|
11793
|
+
}),
|
|
11794
|
+
z42.z.object({
|
|
11795
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11796
|
+
toolCallId: z42.z.string(),
|
|
11797
|
+
state: z42.z.literal("output-error"),
|
|
11798
|
+
input: z42.z.unknown(),
|
|
11799
|
+
output: z42.z.never().optional(),
|
|
11800
|
+
errorText: z42.z.string(),
|
|
11801
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11802
|
+
})
|
|
11803
|
+
];
|
|
11804
|
+
z42.z.object({
|
|
11805
|
+
id: z42.z.string(),
|
|
11806
|
+
role: z42.z.enum(["system", "user", "assistant"]),
|
|
11807
|
+
metadata: z42.z.unknown().optional(),
|
|
11808
|
+
parts: z42.z.array(
|
|
11809
|
+
z42.z.union([
|
|
11810
|
+
textUIPartSchema2,
|
|
11811
|
+
reasoningUIPartSchema2,
|
|
11812
|
+
sourceUrlUIPartSchema2,
|
|
11813
|
+
sourceDocumentUIPartSchema2,
|
|
11814
|
+
fileUIPartSchema2,
|
|
11815
|
+
stepStartUIPartSchema2,
|
|
11816
|
+
dataUIPartSchema2,
|
|
11817
|
+
...dynamicToolUIPartSchemas2,
|
|
11818
|
+
...toolUIPartSchemas2
|
|
11819
|
+
])
|
|
11820
|
+
)
|
|
11821
|
+
});
|
|
11822
|
+
|
|
11823
|
+
// ../agent-builder/dist/index.js
|
|
9502
11824
|
var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
|
|
9503
11825
|
var TemplateUnitSchema = zod.z.object({
|
|
9504
11826
|
kind: zod.z.enum(UNIT_KINDS),
|
|
@@ -11693,14 +14015,14 @@ export const mastra = new Mastra({
|
|
|
11693
14015
|
noEmit: true
|
|
11694
14016
|
};
|
|
11695
14017
|
const host = {
|
|
11696
|
-
getSourceFile: (
|
|
14018
|
+
getSourceFile: (name20) => name20 === fileName ? sourceFile : void 0,
|
|
11697
14019
|
writeFile: () => {
|
|
11698
14020
|
},
|
|
11699
14021
|
getCurrentDirectory: () => "",
|
|
11700
14022
|
getDirectories: () => [],
|
|
11701
|
-
fileExists: (
|
|
11702
|
-
readFile: (
|
|
11703
|
-
getCanonicalFileName: (
|
|
14023
|
+
fileExists: (name20) => name20 === fileName,
|
|
14024
|
+
readFile: (name20) => name20 === fileName ? fileContent : void 0,
|
|
14025
|
+
getCanonicalFileName: (name20) => name20,
|
|
11704
14026
|
useCaseSensitiveFileNames: () => true,
|
|
11705
14027
|
getNewLine: () => "\n",
|
|
11706
14028
|
getDefaultLibFileName: () => "lib.d.ts"
|
|
@@ -13080,25 +15402,25 @@ var packageMergeStep = workflows.createStep({
|
|
|
13080
15402
|
const tplDevDeps = ensureObj(packageInfo.devDependencies);
|
|
13081
15403
|
const tplPeerDeps = ensureObj(packageInfo.peerDependencies);
|
|
13082
15404
|
const tplScripts = ensureObj(packageInfo.scripts);
|
|
13083
|
-
const existsAnywhere = (
|
|
13084
|
-
for (const [
|
|
13085
|
-
if (!existsAnywhere(
|
|
13086
|
-
targetPkg.dependencies[
|
|
15405
|
+
const existsAnywhere = (name20) => name20 in targetPkg.dependencies || name20 in targetPkg.devDependencies || name20 in targetPkg.peerDependencies;
|
|
15406
|
+
for (const [name20, ver] of Object.entries(tplDeps)) {
|
|
15407
|
+
if (!existsAnywhere(name20)) {
|
|
15408
|
+
targetPkg.dependencies[name20] = String(ver);
|
|
13087
15409
|
}
|
|
13088
15410
|
}
|
|
13089
|
-
for (const [
|
|
13090
|
-
if (!existsAnywhere(
|
|
13091
|
-
targetPkg.devDependencies[
|
|
15411
|
+
for (const [name20, ver] of Object.entries(tplDevDeps)) {
|
|
15412
|
+
if (!existsAnywhere(name20)) {
|
|
15413
|
+
targetPkg.devDependencies[name20] = String(ver);
|
|
13092
15414
|
}
|
|
13093
15415
|
}
|
|
13094
|
-
for (const [
|
|
13095
|
-
if (!(
|
|
13096
|
-
targetPkg.peerDependencies[
|
|
15416
|
+
for (const [name20, ver] of Object.entries(tplPeerDeps)) {
|
|
15417
|
+
if (!(name20 in targetPkg.peerDependencies)) {
|
|
15418
|
+
targetPkg.peerDependencies[name20] = String(ver);
|
|
13097
15419
|
}
|
|
13098
15420
|
}
|
|
13099
15421
|
const prefix = `template:${slug}:`;
|
|
13100
|
-
for (const [
|
|
13101
|
-
const newKey = `${prefix}${
|
|
15422
|
+
for (const [name20, cmd] of Object.entries(tplScripts)) {
|
|
15423
|
+
const newKey = `${prefix}${name20}`;
|
|
13102
15424
|
if (!(newKey in targetPkg.scripts)) {
|
|
13103
15425
|
targetPkg.scripts[newKey] = String(cmd);
|
|
13104
15426
|
}
|
|
@@ -13183,9 +15505,9 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13183
15505
|
return "unknown";
|
|
13184
15506
|
}
|
|
13185
15507
|
};
|
|
13186
|
-
const convertNaming = (
|
|
13187
|
-
const baseName = path.basename(
|
|
13188
|
-
const ext = path.extname(
|
|
15508
|
+
const convertNaming = (name20, convention) => {
|
|
15509
|
+
const baseName = path.basename(name20, path.extname(name20));
|
|
15510
|
+
const ext = path.extname(name20);
|
|
13189
15511
|
switch (convention) {
|
|
13190
15512
|
case "camelCase":
|
|
13191
15513
|
return baseName.replace(/[-_]/g, "").replace(/([A-Z])/g, (match, p1, offset) => offset === 0 ? p1.toLowerCase() : p1) + ext;
|
|
@@ -13196,7 +15518,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13196
15518
|
case "PascalCase":
|
|
13197
15519
|
return baseName.replace(/[-_]/g, "").replace(/^[a-z]/, (match) => match.toUpperCase()) + ext;
|
|
13198
15520
|
default:
|
|
13199
|
-
return
|
|
15521
|
+
return name20;
|
|
13200
15522
|
}
|
|
13201
15523
|
};
|
|
13202
15524
|
for (const unit of orderedUnits) {
|
|
@@ -15703,5 +18025,5 @@ exports.startAsyncAgentBuilderActionHandler = startAsyncAgentBuilderActionHandle
|
|
|
15703
18025
|
exports.streamAgentBuilderActionHandler = streamAgentBuilderActionHandler;
|
|
15704
18026
|
exports.streamVNextAgentBuilderActionHandler = streamVNextAgentBuilderActionHandler;
|
|
15705
18027
|
exports.watchAgentBuilderActionHandler = watchAgentBuilderActionHandler;
|
|
15706
|
-
//# sourceMappingURL=chunk-
|
|
15707
|
-
//# sourceMappingURL=chunk-
|
|
18028
|
+
//# sourceMappingURL=chunk-JJBXJYMY.cjs.map
|
|
18029
|
+
//# sourceMappingURL=chunk-JJBXJYMY.cjs.map
|