@mastra/server 0.18.0 → 0.19.0-alpha.1
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 +28 -0
- package/dist/{chunk-5N724Q2T.cjs → chunk-52UP7DFT.cjs} +23 -2
- package/dist/chunk-52UP7DFT.cjs.map +1 -0
- package/dist/{chunk-PUYSH3IL.js → chunk-6IJWRJZE.js} +3 -3
- package/dist/{chunk-PUYSH3IL.js.map → chunk-6IJWRJZE.js.map} +1 -1
- package/dist/{chunk-2GDLSAVJ.cjs → chunk-BKCWZLEL.cjs} +2 -2
- package/dist/{chunk-2GDLSAVJ.cjs.map → chunk-BKCWZLEL.cjs.map} +1 -1
- package/dist/{chunk-BZT5VYDT.js → chunk-BOVFMBXY.js} +2 -2
- package/dist/chunk-BOVFMBXY.js.map +1 -0
- package/dist/{chunk-PLNQ4XER.cjs → chunk-DWVU5R72.cjs} +2491 -216
- package/dist/chunk-DWVU5R72.cjs.map +1 -0
- package/dist/{chunk-57HWW2TY.cjs → chunk-GIM2ZSPB.cjs} +34 -20
- package/dist/chunk-GIM2ZSPB.cjs.map +1 -0
- package/dist/{chunk-AVEPEUN4.cjs → chunk-OPI3FZYH.cjs} +4 -4
- package/dist/{chunk-AVEPEUN4.cjs.map → chunk-OPI3FZYH.cjs.map} +1 -1
- package/dist/{chunk-G662L2YZ.js → chunk-QGW2VHZU.js} +31 -17
- package/dist/chunk-QGW2VHZU.js.map +1 -0
- package/dist/{chunk-2WMATOMO.cjs → chunk-SXENNNR7.cjs} +2 -2
- package/dist/chunk-SXENNNR7.cjs.map +1 -0
- package/dist/{chunk-GDWMF6SB.cjs → chunk-VY4ENABS.cjs} +6 -4
- package/dist/chunk-VY4ENABS.cjs.map +1 -0
- package/dist/{chunk-5KRXONRF.js → chunk-WUJLVNLU.js} +23 -3
- package/dist/chunk-WUJLVNLU.js.map +1 -0
- package/dist/{chunk-X7564COI.js → chunk-X3CRHW4S.js} +2472 -197
- package/dist/chunk-X3CRHW4S.js.map +1 -0
- package/dist/{chunk-IYJW2OVQ.js → chunk-XJOYGRTN.js} +2 -2
- package/dist/{chunk-IYJW2OVQ.js.map → chunk-XJOYGRTN.js.map} +1 -1
- package/dist/{chunk-CNU4A2XU.js → chunk-YWOK4F5A.js} +6 -4
- package/dist/chunk-YWOK4F5A.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts +6 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +17 -17
- package/dist/server/handlers/agents.d.ts +5 -1
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/observability.cjs +8 -4
- package/dist/server/handlers/observability.d.ts +9 -1
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.d.ts +15 -15
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/vNextNetwork.d.ts +7 -7
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -1
- package/dist/server/handlers/workflows.cjs +18 -18
- package/dist/server/handlers/workflows.d.ts +15 -7
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +12 -12
- package/dist/server/handlers.js +6 -6
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-2WMATOMO.cjs.map +0 -1
- package/dist/chunk-57HWW2TY.cjs.map +0 -1
- package/dist/chunk-5KRXONRF.js.map +0 -1
- package/dist/chunk-5N724Q2T.cjs.map +0 -1
- package/dist/chunk-BZT5VYDT.js.map +0 -1
- package/dist/chunk-CNU4A2XU.js.map +0 -1
- package/dist/chunk-G662L2YZ.js.map +0 -1
- package/dist/chunk-GDWMF6SB.cjs.map +0 -1
- package/dist/chunk-PLNQ4XER.cjs.map +0 -1
- package/dist/chunk-X7564COI.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkGIM2ZSPB_cjs = require('./chunk-GIM2ZSPB.cjs');
|
|
4
|
+
var chunkVY4ENABS_cjs = require('./chunk-VY4ENABS.cjs');
|
|
5
5
|
var chunkFALVL2VV_cjs = require('./chunk-FALVL2VV.cjs');
|
|
6
6
|
var chunkHVBBFCDH_cjs = require('./chunk-HVBBFCDH.cjs');
|
|
7
7
|
var chunkPPYGWINI_cjs = require('./chunk-PPYGWINI.cjs');
|
|
@@ -168,8 +168,8 @@ var require_ignore = chunkEMMSS5I5_cjs.__commonJS({
|
|
|
168
168
|
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
169
169
|
}
|
|
170
170
|
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
171
|
-
var define = (
|
|
172
|
-
Object.defineProperty(
|
|
171
|
+
var define = (object4, key, value) => {
|
|
172
|
+
Object.defineProperty(object4, key, { value });
|
|
173
173
|
return value;
|
|
174
174
|
};
|
|
175
175
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
@@ -621,10 +621,10 @@ chunkEMMSS5I5_cjs.__export(agent_builder_exports, {
|
|
|
621
621
|
streamVNextAgentBuilderActionHandler: () => streamVNextAgentBuilderActionHandler,
|
|
622
622
|
watchAgentBuilderActionHandler: () => watchAgentBuilderActionHandler
|
|
623
623
|
});
|
|
624
|
-
function zodToJsonSchema(
|
|
624
|
+
function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relative") {
|
|
625
625
|
const fn = "toJSONSchema";
|
|
626
626
|
if (fn in zod.z) {
|
|
627
|
-
return zod.z[fn](
|
|
627
|
+
return zod.z[fn](zodSchema4, {
|
|
628
628
|
unrepresentable: "any",
|
|
629
629
|
override: (ctx) => {
|
|
630
630
|
const def = ctx.zodSchema?._zod?.def;
|
|
@@ -635,7 +635,7 @@ function zodToJsonSchema(zodSchema3, target = "jsonSchema7", strategy = "relativ
|
|
|
635
635
|
}
|
|
636
636
|
});
|
|
637
637
|
} else {
|
|
638
|
-
return chunkHVBBFCDH_cjs.esm_default(
|
|
638
|
+
return chunkHVBBFCDH_cjs.esm_default(zodSchema4, {
|
|
639
639
|
$refStrategy: strategy,
|
|
640
640
|
target
|
|
641
641
|
});
|
|
@@ -1235,8 +1235,8 @@ function formatDataStreamPart(type, value) {
|
|
|
1235
1235
|
`;
|
|
1236
1236
|
}
|
|
1237
1237
|
function zodSchema(zodSchema22, options) {
|
|
1238
|
-
var
|
|
1239
|
-
const useReferences = (
|
|
1238
|
+
var _a20;
|
|
1239
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
1240
1240
|
return jsonSchema(
|
|
1241
1241
|
chunkHVBBFCDH_cjs.esm_default(zodSchema22, {
|
|
1242
1242
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -1349,11 +1349,11 @@ var major = VERSION.split(".")[0];
|
|
|
1349
1349
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
1350
1350
|
var _global = _globalThis;
|
|
1351
1351
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
1352
|
-
var
|
|
1352
|
+
var _a20;
|
|
1353
1353
|
if (allowOverride === void 0) {
|
|
1354
1354
|
allowOverride = false;
|
|
1355
1355
|
}
|
|
1356
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
1356
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a20 !== void 0 ? _a20 : {
|
|
1357
1357
|
version: VERSION
|
|
1358
1358
|
};
|
|
1359
1359
|
if (!allowOverride && api[type]) {
|
|
@@ -1371,8 +1371,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
1371
1371
|
return true;
|
|
1372
1372
|
}
|
|
1373
1373
|
function getGlobal(type) {
|
|
1374
|
-
var
|
|
1375
|
-
var globalVersion = (
|
|
1374
|
+
var _a20, _b8;
|
|
1375
|
+
var globalVersion = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a20 === void 0 ? void 0 : _a20.version;
|
|
1376
1376
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1377
1377
|
return;
|
|
1378
1378
|
}
|
|
@@ -1549,13 +1549,13 @@ var DiagAPI = (
|
|
|
1549
1549
|
}
|
|
1550
1550
|
var self = this;
|
|
1551
1551
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1552
|
-
var
|
|
1552
|
+
var _a20, _b8, _c;
|
|
1553
1553
|
if (optionsOrLogLevel === void 0) {
|
|
1554
1554
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1555
1555
|
}
|
|
1556
1556
|
if (logger === self) {
|
|
1557
1557
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
1558
|
-
self.error((
|
|
1558
|
+
self.error((_a20 = err.stack) !== null && _a20 !== void 0 ? _a20 : err.message);
|
|
1559
1559
|
return false;
|
|
1560
1560
|
}
|
|
1561
1561
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -1726,12 +1726,12 @@ var ContextAPI = (
|
|
|
1726
1726
|
return this._getContextManager().active();
|
|
1727
1727
|
};
|
|
1728
1728
|
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
1729
|
-
var
|
|
1729
|
+
var _a20;
|
|
1730
1730
|
var args = [];
|
|
1731
1731
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1732
1732
|
args[_i - 3] = arguments[_i];
|
|
1733
1733
|
}
|
|
1734
|
-
return (
|
|
1734
|
+
return (_a20 = this._getContextManager()).with.apply(_a20, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
1735
1735
|
};
|
|
1736
1736
|
ContextAPI2.prototype.bind = function(context, target) {
|
|
1737
1737
|
return this._getContextManager().bind(context, target);
|
|
@@ -1826,8 +1826,8 @@ function setSpanContext(context, spanContext) {
|
|
|
1826
1826
|
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
1827
1827
|
}
|
|
1828
1828
|
function getSpanContext(context) {
|
|
1829
|
-
var
|
|
1830
|
-
return (
|
|
1829
|
+
var _a20;
|
|
1830
|
+
return (_a20 = getSpan(context)) === null || _a20 === void 0 ? void 0 : _a20.spanContext();
|
|
1831
1831
|
}
|
|
1832
1832
|
|
|
1833
1833
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
@@ -1853,7 +1853,7 @@ var NoopTracer = (
|
|
|
1853
1853
|
(function() {
|
|
1854
1854
|
function NoopTracer2() {
|
|
1855
1855
|
}
|
|
1856
|
-
NoopTracer2.prototype.startSpan = function(
|
|
1856
|
+
NoopTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1857
1857
|
if (context === void 0) {
|
|
1858
1858
|
context = contextApi.active();
|
|
1859
1859
|
}
|
|
@@ -1868,7 +1868,7 @@ var NoopTracer = (
|
|
|
1868
1868
|
return new NonRecordingSpan();
|
|
1869
1869
|
}
|
|
1870
1870
|
};
|
|
1871
|
-
NoopTracer2.prototype.startActiveSpan = function(
|
|
1871
|
+
NoopTracer2.prototype.startActiveSpan = function(name20, arg2, arg3, arg4) {
|
|
1872
1872
|
var opts;
|
|
1873
1873
|
var ctx;
|
|
1874
1874
|
var fn;
|
|
@@ -1885,7 +1885,7 @@ var NoopTracer = (
|
|
|
1885
1885
|
fn = arg4;
|
|
1886
1886
|
}
|
|
1887
1887
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1888
|
-
var span = this.startSpan(
|
|
1888
|
+
var span = this.startSpan(name20, opts, parentContext);
|
|
1889
1889
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1890
1890
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1891
1891
|
};
|
|
@@ -1901,14 +1901,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
1901
1901
|
var ProxyTracer = (
|
|
1902
1902
|
/** @class */
|
|
1903
1903
|
(function() {
|
|
1904
|
-
function ProxyTracer2(_provider,
|
|
1904
|
+
function ProxyTracer2(_provider, name20, version, options) {
|
|
1905
1905
|
this._provider = _provider;
|
|
1906
|
-
this.name =
|
|
1906
|
+
this.name = name20;
|
|
1907
1907
|
this.version = version;
|
|
1908
1908
|
this.options = options;
|
|
1909
1909
|
}
|
|
1910
|
-
ProxyTracer2.prototype.startSpan = function(
|
|
1911
|
-
return this._getTracer().startSpan(
|
|
1910
|
+
ProxyTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1911
|
+
return this._getTracer().startSpan(name20, options, context);
|
|
1912
1912
|
};
|
|
1913
1913
|
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1914
1914
|
var tracer = this._getTracer();
|
|
@@ -1949,20 +1949,20 @@ var ProxyTracerProvider = (
|
|
|
1949
1949
|
(function() {
|
|
1950
1950
|
function ProxyTracerProvider2() {
|
|
1951
1951
|
}
|
|
1952
|
-
ProxyTracerProvider2.prototype.getTracer = function(
|
|
1953
|
-
var
|
|
1954
|
-
return (
|
|
1952
|
+
ProxyTracerProvider2.prototype.getTracer = function(name20, version, options) {
|
|
1953
|
+
var _a20;
|
|
1954
|
+
return (_a20 = this.getDelegateTracer(name20, version, options)) !== null && _a20 !== void 0 ? _a20 : new ProxyTracer(this, name20, version, options);
|
|
1955
1955
|
};
|
|
1956
1956
|
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1957
|
-
var
|
|
1958
|
-
return (
|
|
1957
|
+
var _a20;
|
|
1958
|
+
return (_a20 = this._delegate) !== null && _a20 !== void 0 ? _a20 : NOOP_TRACER_PROVIDER;
|
|
1959
1959
|
};
|
|
1960
1960
|
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1961
1961
|
this._delegate = delegate;
|
|
1962
1962
|
};
|
|
1963
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(
|
|
1964
|
-
var
|
|
1965
|
-
return (
|
|
1963
|
+
ProxyTracerProvider2.prototype.getDelegateTracer = function(name20, version, options) {
|
|
1964
|
+
var _a20;
|
|
1965
|
+
return (_a20 = this._delegate) === null || _a20 === void 0 ? void 0 : _a20.getTracer(name20, version, options);
|
|
1966
1966
|
};
|
|
1967
1967
|
return ProxyTracerProvider2;
|
|
1968
1968
|
})()
|
|
@@ -2008,8 +2008,8 @@ var TraceAPI = (
|
|
|
2008
2008
|
TraceAPI2.prototype.getTracerProvider = function() {
|
|
2009
2009
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
2010
2010
|
};
|
|
2011
|
-
TraceAPI2.prototype.getTracer = function(
|
|
2012
|
-
return this.getTracerProvider().getTracer(
|
|
2011
|
+
TraceAPI2.prototype.getTracer = function(name20, version) {
|
|
2012
|
+
return this.getTracerProvider().getTracer(name20, version);
|
|
2013
2013
|
};
|
|
2014
2014
|
TraceAPI2.prototype.disable = function() {
|
|
2015
2015
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -3206,11 +3206,11 @@ function extractResponseHeaders(response) {
|
|
|
3206
3206
|
return Object.fromEntries([...response.headers]);
|
|
3207
3207
|
}
|
|
3208
3208
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
3209
|
-
var
|
|
3209
|
+
var _a20, _b8, _c;
|
|
3210
3210
|
if (globalThisAny.window) {
|
|
3211
3211
|
return `runtime/browser`;
|
|
3212
3212
|
}
|
|
3213
|
-
if ((
|
|
3213
|
+
if ((_a20 = globalThisAny.navigator) == null ? void 0 : _a20.userAgent) {
|
|
3214
3214
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
3215
3215
|
}
|
|
3216
3216
|
if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
|
|
@@ -3391,12 +3391,12 @@ function loadOptionalSetting({
|
|
|
3391
3391
|
}
|
|
3392
3392
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
3393
3393
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
3394
|
-
function _parse(
|
|
3395
|
-
const obj = JSON.parse(
|
|
3394
|
+
function _parse(text4) {
|
|
3395
|
+
const obj = JSON.parse(text4);
|
|
3396
3396
|
if (obj === null || typeof obj !== "object") {
|
|
3397
3397
|
return obj;
|
|
3398
3398
|
}
|
|
3399
|
-
if (suspectProtoRx.test(
|
|
3399
|
+
if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
|
|
3400
3400
|
return obj;
|
|
3401
3401
|
}
|
|
3402
3402
|
return filter(obj);
|
|
@@ -3423,11 +3423,11 @@ function filter(obj) {
|
|
|
3423
3423
|
}
|
|
3424
3424
|
return obj;
|
|
3425
3425
|
}
|
|
3426
|
-
function secureJsonParse(
|
|
3426
|
+
function secureJsonParse(text4) {
|
|
3427
3427
|
const { stackTraceLimit } = Error;
|
|
3428
3428
|
Error.stackTraceLimit = 0;
|
|
3429
3429
|
try {
|
|
3430
|
-
return _parse(
|
|
3430
|
+
return _parse(text4);
|
|
3431
3431
|
} finally {
|
|
3432
3432
|
Error.stackTraceLimit = stackTraceLimit;
|
|
3433
3433
|
}
|
|
@@ -3468,12 +3468,12 @@ async function safeValidateTypes2({
|
|
|
3468
3468
|
value,
|
|
3469
3469
|
schema
|
|
3470
3470
|
}) {
|
|
3471
|
-
const
|
|
3471
|
+
const validator22 = asValidator(schema);
|
|
3472
3472
|
try {
|
|
3473
|
-
if (
|
|
3473
|
+
if (validator22.validate == null) {
|
|
3474
3474
|
return { success: true, value, rawValue: value };
|
|
3475
3475
|
}
|
|
3476
|
-
const result = await
|
|
3476
|
+
const result = await validator22.validate(value);
|
|
3477
3477
|
if (result.success) {
|
|
3478
3478
|
return { success: true, value: result.value, rawValue: value };
|
|
3479
3479
|
}
|
|
@@ -3491,11 +3491,11 @@ async function safeValidateTypes2({
|
|
|
3491
3491
|
}
|
|
3492
3492
|
}
|
|
3493
3493
|
async function parseJSON({
|
|
3494
|
-
text:
|
|
3494
|
+
text: text4,
|
|
3495
3495
|
schema
|
|
3496
3496
|
}) {
|
|
3497
3497
|
try {
|
|
3498
|
-
const value = secureJsonParse(
|
|
3498
|
+
const value = secureJsonParse(text4);
|
|
3499
3499
|
if (schema == null) {
|
|
3500
3500
|
return value;
|
|
3501
3501
|
}
|
|
@@ -3504,15 +3504,15 @@ async function parseJSON({
|
|
|
3504
3504
|
if (chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) || chunkHVBBFCDH_cjs.TypeValidationError.isInstance(error)) {
|
|
3505
3505
|
throw error;
|
|
3506
3506
|
}
|
|
3507
|
-
throw new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3507
|
+
throw new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error });
|
|
3508
3508
|
}
|
|
3509
3509
|
}
|
|
3510
3510
|
async function safeParseJSON2({
|
|
3511
|
-
text:
|
|
3511
|
+
text: text4,
|
|
3512
3512
|
schema
|
|
3513
3513
|
}) {
|
|
3514
3514
|
try {
|
|
3515
|
-
const value = secureJsonParse(
|
|
3515
|
+
const value = secureJsonParse(text4);
|
|
3516
3516
|
if (schema == null) {
|
|
3517
3517
|
return { success: true, value, rawValue: value };
|
|
3518
3518
|
}
|
|
@@ -3520,7 +3520,7 @@ async function safeParseJSON2({
|
|
|
3520
3520
|
} catch (error) {
|
|
3521
3521
|
return {
|
|
3522
3522
|
success: false,
|
|
3523
|
-
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3523
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
3524
3524
|
rawValue: void 0
|
|
3525
3525
|
};
|
|
3526
3526
|
}
|
|
@@ -3773,11 +3773,11 @@ function parseAnyDef() {
|
|
|
3773
3773
|
return {};
|
|
3774
3774
|
}
|
|
3775
3775
|
function parseArrayDef(def, refs) {
|
|
3776
|
-
var
|
|
3776
|
+
var _a20, _b8, _c;
|
|
3777
3777
|
const res = {
|
|
3778
3778
|
type: "array"
|
|
3779
3779
|
};
|
|
3780
|
-
if (((
|
|
3780
|
+
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) {
|
|
3781
3781
|
res.items = parseDef(def.type._def, {
|
|
3782
3782
|
...refs,
|
|
3783
3783
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -4138,8 +4138,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
4138
4138
|
return result;
|
|
4139
4139
|
}
|
|
4140
4140
|
function addFormat(schema, value, message, refs) {
|
|
4141
|
-
var
|
|
4142
|
-
if (schema.format || ((
|
|
4141
|
+
var _a20;
|
|
4142
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
4143
4143
|
if (!schema.anyOf) {
|
|
4144
4144
|
schema.anyOf = [];
|
|
4145
4145
|
}
|
|
@@ -4158,8 +4158,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
4158
4158
|
}
|
|
4159
4159
|
}
|
|
4160
4160
|
function addPattern(schema, regex, message, refs) {
|
|
4161
|
-
var
|
|
4162
|
-
if (schema.pattern || ((
|
|
4161
|
+
var _a20;
|
|
4162
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
4163
4163
|
if (!schema.allOf) {
|
|
4164
4164
|
schema.allOf = [];
|
|
4165
4165
|
}
|
|
@@ -4178,7 +4178,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
4178
4178
|
}
|
|
4179
4179
|
}
|
|
4180
4180
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
4181
|
-
var
|
|
4181
|
+
var _a20;
|
|
4182
4182
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
4183
4183
|
return regex.source;
|
|
4184
4184
|
}
|
|
@@ -4208,7 +4208,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4208
4208
|
pattern += source[i];
|
|
4209
4209
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
4210
4210
|
inCharRange = false;
|
|
4211
|
-
} else if (source[i + 1] === "-" && ((
|
|
4211
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
4212
4212
|
pattern += source[i];
|
|
4213
4213
|
inCharRange = true;
|
|
4214
4214
|
} else {
|
|
@@ -4250,13 +4250,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4250
4250
|
return pattern;
|
|
4251
4251
|
}
|
|
4252
4252
|
function parseRecordDef(def, refs) {
|
|
4253
|
-
var
|
|
4253
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
4254
4254
|
const schema = {
|
|
4255
4255
|
type: "object",
|
|
4256
|
-
additionalProperties: (
|
|
4256
|
+
additionalProperties: (_a20 = parseDef(def.valueType._def, {
|
|
4257
4257
|
...refs,
|
|
4258
4258
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
4259
|
-
})) != null ?
|
|
4259
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
4260
4260
|
};
|
|
4261
4261
|
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
4262
4262
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -4307,11 +4307,11 @@ function parseMapDef(def, refs) {
|
|
|
4307
4307
|
};
|
|
4308
4308
|
}
|
|
4309
4309
|
function parseNativeEnumDef(def) {
|
|
4310
|
-
const
|
|
4310
|
+
const object4 = def.values;
|
|
4311
4311
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
4312
|
-
return typeof
|
|
4312
|
+
return typeof object4[object4[key]] !== "number";
|
|
4313
4313
|
});
|
|
4314
|
-
const actualValues = actualKeys.map((key) =>
|
|
4314
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
4315
4315
|
const parsedTypes = Array.from(
|
|
4316
4316
|
new Set(actualValues.map((values) => typeof values))
|
|
4317
4317
|
);
|
|
@@ -4515,8 +4515,8 @@ function safeIsOptional(schema) {
|
|
|
4515
4515
|
}
|
|
4516
4516
|
}
|
|
4517
4517
|
var parseOptionalDef = (def, refs) => {
|
|
4518
|
-
var
|
|
4519
|
-
if (refs.currentPath.toString() === ((
|
|
4518
|
+
var _a20;
|
|
4519
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
4520
4520
|
return parseDef(def.innerType._def, refs);
|
|
4521
4521
|
}
|
|
4522
4522
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -4686,10 +4686,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
4686
4686
|
}
|
|
4687
4687
|
};
|
|
4688
4688
|
function parseDef(def, refs, forceResolution = false) {
|
|
4689
|
-
var
|
|
4689
|
+
var _a20;
|
|
4690
4690
|
const seenItem = refs.seen.get(def);
|
|
4691
4691
|
if (refs.override) {
|
|
4692
|
-
const overrideResult = (
|
|
4692
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
4693
4693
|
refs,
|
|
4694
4694
|
def,
|
|
4695
4695
|
refs,
|
|
@@ -4755,11 +4755,11 @@ var getRefs = (options) => {
|
|
|
4755
4755
|
currentPath,
|
|
4756
4756
|
propertyPath: void 0,
|
|
4757
4757
|
seen: new Map(
|
|
4758
|
-
Object.entries(_options.definitions).map(([
|
|
4758
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
4759
4759
|
def._def,
|
|
4760
4760
|
{
|
|
4761
4761
|
def: def._def,
|
|
4762
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
4762
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
4763
4763
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
4764
4764
|
jsonSchema: void 0
|
|
4765
4765
|
}
|
|
@@ -4768,50 +4768,50 @@ var getRefs = (options) => {
|
|
|
4768
4768
|
};
|
|
4769
4769
|
};
|
|
4770
4770
|
var zodToJsonSchema2 = (schema, options) => {
|
|
4771
|
-
var
|
|
4771
|
+
var _a20;
|
|
4772
4772
|
const refs = getRefs(options);
|
|
4773
4773
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
4774
|
-
(acc, [
|
|
4775
|
-
var
|
|
4774
|
+
(acc, [name25, schema2]) => {
|
|
4775
|
+
var _a25;
|
|
4776
4776
|
return {
|
|
4777
4777
|
...acc,
|
|
4778
|
-
[
|
|
4778
|
+
[name25]: (_a25 = parseDef(
|
|
4779
4779
|
schema2._def,
|
|
4780
4780
|
{
|
|
4781
4781
|
...refs,
|
|
4782
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4782
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
4783
4783
|
},
|
|
4784
4784
|
true
|
|
4785
|
-
)) != null ?
|
|
4785
|
+
)) != null ? _a25 : parseAnyDef()
|
|
4786
4786
|
};
|
|
4787
4787
|
},
|
|
4788
4788
|
{}
|
|
4789
4789
|
) : void 0;
|
|
4790
|
-
const
|
|
4791
|
-
const main = (
|
|
4790
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
4791
|
+
const main = (_a20 = parseDef(
|
|
4792
4792
|
schema._def,
|
|
4793
|
-
|
|
4793
|
+
name20 === void 0 ? refs : {
|
|
4794
4794
|
...refs,
|
|
4795
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4795
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
4796
4796
|
},
|
|
4797
4797
|
false
|
|
4798
|
-
)) != null ?
|
|
4798
|
+
)) != null ? _a20 : parseAnyDef();
|
|
4799
4799
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
4800
4800
|
if (title !== void 0) {
|
|
4801
4801
|
main.title = title;
|
|
4802
4802
|
}
|
|
4803
|
-
const combined =
|
|
4803
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
4804
4804
|
...main,
|
|
4805
4805
|
[refs.definitionPath]: definitions
|
|
4806
4806
|
} : main : {
|
|
4807
4807
|
$ref: [
|
|
4808
4808
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
4809
4809
|
refs.definitionPath,
|
|
4810
|
-
|
|
4810
|
+
name20
|
|
4811
4811
|
].join("/"),
|
|
4812
4812
|
[refs.definitionPath]: {
|
|
4813
4813
|
...definitions,
|
|
4814
|
-
[
|
|
4814
|
+
[name20]: main
|
|
4815
4815
|
}
|
|
4816
4816
|
};
|
|
4817
4817
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -4819,8 +4819,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
4819
4819
|
};
|
|
4820
4820
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
4821
4821
|
function zod3Schema(zodSchema22, options) {
|
|
4822
|
-
var
|
|
4823
|
-
const useReferences = (
|
|
4822
|
+
var _a20;
|
|
4823
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4824
4824
|
return jsonSchema2(
|
|
4825
4825
|
zod_to_json_schema_default(zodSchema22, {
|
|
4826
4826
|
$refStrategy: useReferences ? "root" : "none"
|
|
@@ -4834,8 +4834,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
4834
4834
|
);
|
|
4835
4835
|
}
|
|
4836
4836
|
function zod4Schema(zodSchema22, options) {
|
|
4837
|
-
var
|
|
4838
|
-
const useReferences = (
|
|
4837
|
+
var _a20;
|
|
4838
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4839
4839
|
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
4840
4840
|
target: "draft-7",
|
|
4841
4841
|
io: "output",
|
|
@@ -5145,14 +5145,14 @@ var gatewayErrorResponseSchema = z42.z.object({
|
|
|
5145
5145
|
})
|
|
5146
5146
|
});
|
|
5147
5147
|
function asGatewayError(error, authMethod) {
|
|
5148
|
-
var
|
|
5148
|
+
var _a84;
|
|
5149
5149
|
if (GatewayError.isInstance(error)) {
|
|
5150
5150
|
return error;
|
|
5151
5151
|
}
|
|
5152
5152
|
if (chunkHVBBFCDH_cjs.APICallError.isInstance(error)) {
|
|
5153
5153
|
return createGatewayErrorFromResponse({
|
|
5154
5154
|
response: extractApiCallResponse(error),
|
|
5155
|
-
statusCode: (
|
|
5155
|
+
statusCode: (_a84 = error.statusCode) != null ? _a84 : 500,
|
|
5156
5156
|
defaultMessage: "Gateway request failed",
|
|
5157
5157
|
cause: error,
|
|
5158
5158
|
authMethod
|
|
@@ -5403,7 +5403,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5403
5403
|
abortSignal,
|
|
5404
5404
|
providerOptions
|
|
5405
5405
|
}) {
|
|
5406
|
-
var
|
|
5406
|
+
var _a84;
|
|
5407
5407
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
5408
5408
|
try {
|
|
5409
5409
|
const {
|
|
@@ -5434,7 +5434,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5434
5434
|
});
|
|
5435
5435
|
return {
|
|
5436
5436
|
embeddings: responseBody.embeddings,
|
|
5437
|
-
usage: (
|
|
5437
|
+
usage: (_a84 = responseBody.usage) != null ? _a84 : void 0,
|
|
5438
5438
|
providerMetadata: responseBody.providerMetadata,
|
|
5439
5439
|
response: { headers: responseHeaders, body: rawValue }
|
|
5440
5440
|
};
|
|
@@ -5458,8 +5458,8 @@ var gatewayEmbeddingResponseSchema = z42.z.object({
|
|
|
5458
5458
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
5459
5459
|
});
|
|
5460
5460
|
async function getVercelOidcToken() {
|
|
5461
|
-
var
|
|
5462
|
-
const token = (_b8 = (
|
|
5461
|
+
var _a84, _b8;
|
|
5462
|
+
const token = (_b8 = (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
5463
5463
|
if (!token) {
|
|
5464
5464
|
throw new GatewayAuthenticationError({
|
|
5465
5465
|
message: "OIDC token not available",
|
|
@@ -5469,21 +5469,21 @@ async function getVercelOidcToken() {
|
|
|
5469
5469
|
return token;
|
|
5470
5470
|
}
|
|
5471
5471
|
async function getVercelRequestId() {
|
|
5472
|
-
var
|
|
5473
|
-
return (
|
|
5472
|
+
var _a84;
|
|
5473
|
+
return (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-id"];
|
|
5474
5474
|
}
|
|
5475
5475
|
var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
|
|
5476
5476
|
function getContext() {
|
|
5477
|
-
var
|
|
5477
|
+
var _a84, _b8, _c;
|
|
5478
5478
|
const fromSymbol = globalThis;
|
|
5479
|
-
return (_c = (_b8 = (
|
|
5479
|
+
return (_c = (_b8 = (_a84 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a84.get) == null ? void 0 : _b8.call(_a84)) != null ? _c : {};
|
|
5480
5480
|
}
|
|
5481
5481
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
5482
5482
|
function createGatewayProvider(options = {}) {
|
|
5483
|
-
var
|
|
5483
|
+
var _a84, _b8;
|
|
5484
5484
|
let pendingMetadata = null;
|
|
5485
5485
|
let metadataCache = null;
|
|
5486
|
-
const cacheRefreshMillis = (
|
|
5486
|
+
const cacheRefreshMillis = (_a84 = options.metadataCacheRefreshMillis) != null ? _a84 : 1e3 * 60 * 5;
|
|
5487
5487
|
let lastFetchTime = 0;
|
|
5488
5488
|
const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
5489
5489
|
const getHeaders = async () => {
|
|
@@ -5535,8 +5535,8 @@ function createGatewayProvider(options = {}) {
|
|
|
5535
5535
|
});
|
|
5536
5536
|
};
|
|
5537
5537
|
const getAvailableModels = async () => {
|
|
5538
|
-
var
|
|
5539
|
-
const now = (_c = (_b9 = (
|
|
5538
|
+
var _a94, _b9, _c;
|
|
5539
|
+
const now = (_c = (_b9 = (_a94 = options._internal) == null ? void 0 : _a94.currentDate) == null ? void 0 : _b9.call(_a94).getTime()) != null ? _c : Date.now();
|
|
5540
5540
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
5541
5541
|
lastFetchTime = now;
|
|
5542
5542
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -6146,9 +6146,6 @@ function prepareRetries2({
|
|
|
6146
6146
|
})
|
|
6147
6147
|
};
|
|
6148
6148
|
}
|
|
6149
|
-
function stepCountIs(stepCount) {
|
|
6150
|
-
return ({ steps }) => steps.length === stepCount;
|
|
6151
|
-
}
|
|
6152
6149
|
var VERSION3 = "5.0.44" ;
|
|
6153
6150
|
createIdGenerator2({
|
|
6154
6151
|
prefix: "aitxt",
|
|
@@ -7866,50 +7863,50 @@ function isValidWithSchema(schema, value) {
|
|
|
7866
7863
|
return schema.safeParse(value).success;
|
|
7867
7864
|
}
|
|
7868
7865
|
var NotHandler = class {
|
|
7869
|
-
apply(
|
|
7870
|
-
if (!schema.not) return
|
|
7866
|
+
apply(zodSchema4, schema) {
|
|
7867
|
+
if (!schema.not) return zodSchema4;
|
|
7871
7868
|
const notSchema = convertJsonSchemaToZod(schema.not);
|
|
7872
|
-
return
|
|
7869
|
+
return zodSchema4.refine(
|
|
7873
7870
|
(value) => !isValidWithSchema(notSchema, value),
|
|
7874
7871
|
{ message: "Value must not match the 'not' schema" }
|
|
7875
7872
|
);
|
|
7876
7873
|
}
|
|
7877
7874
|
};
|
|
7878
7875
|
var UniqueItemsHandler = class {
|
|
7879
|
-
apply(
|
|
7876
|
+
apply(zodSchema4, schema) {
|
|
7880
7877
|
const arraySchema = schema;
|
|
7881
|
-
if (arraySchema.uniqueItems !== true) return
|
|
7882
|
-
return
|
|
7878
|
+
if (arraySchema.uniqueItems !== true) return zodSchema4;
|
|
7879
|
+
return zodSchema4.refine(createUniqueItemsValidator(), {
|
|
7883
7880
|
message: "Array items must be unique"
|
|
7884
7881
|
});
|
|
7885
7882
|
}
|
|
7886
7883
|
};
|
|
7887
7884
|
var AllOfHandler = class {
|
|
7888
|
-
apply(
|
|
7889
|
-
if (!schema.allOf || schema.allOf.length === 0) return
|
|
7885
|
+
apply(zodSchema4, schema) {
|
|
7886
|
+
if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
|
|
7890
7887
|
const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
|
|
7891
7888
|
return allOfSchemas.reduce(
|
|
7892
7889
|
(acc, s) => z42.z.intersection(acc, s),
|
|
7893
|
-
|
|
7890
|
+
zodSchema4
|
|
7894
7891
|
);
|
|
7895
7892
|
}
|
|
7896
7893
|
};
|
|
7897
7894
|
var AnyOfHandler = class {
|
|
7898
|
-
apply(
|
|
7899
|
-
if (!schema.anyOf || schema.anyOf.length === 0) return
|
|
7895
|
+
apply(zodSchema4, schema) {
|
|
7896
|
+
if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
|
|
7900
7897
|
const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z42.z.union([
|
|
7901
7898
|
convertJsonSchemaToZod(schema.anyOf[0]),
|
|
7902
7899
|
convertJsonSchemaToZod(schema.anyOf[1]),
|
|
7903
7900
|
...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
|
|
7904
7901
|
]);
|
|
7905
|
-
return z42.z.intersection(
|
|
7902
|
+
return z42.z.intersection(zodSchema4, anyOfSchema);
|
|
7906
7903
|
}
|
|
7907
7904
|
};
|
|
7908
7905
|
var OneOfHandler = class {
|
|
7909
|
-
apply(
|
|
7910
|
-
if (!schema.oneOf || schema.oneOf.length === 0) return
|
|
7906
|
+
apply(zodSchema4, schema) {
|
|
7907
|
+
if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
|
|
7911
7908
|
const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
|
|
7912
|
-
return
|
|
7909
|
+
return zodSchema4.refine(
|
|
7913
7910
|
(value) => {
|
|
7914
7911
|
let validCount = 0;
|
|
7915
7912
|
for (const oneOfSchema of oneOfSchemas) {
|
|
@@ -7926,12 +7923,12 @@ var OneOfHandler = class {
|
|
|
7926
7923
|
}
|
|
7927
7924
|
};
|
|
7928
7925
|
var PrefixItemsHandler = class {
|
|
7929
|
-
apply(
|
|
7926
|
+
apply(zodSchema4, schema) {
|
|
7930
7927
|
const arraySchema = schema;
|
|
7931
7928
|
if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
|
|
7932
7929
|
const prefixItems = arraySchema.prefixItems;
|
|
7933
7930
|
const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
|
|
7934
|
-
return
|
|
7931
|
+
return zodSchema4.refine(
|
|
7935
7932
|
(value) => {
|
|
7936
7933
|
if (!Array.isArray(value)) return true;
|
|
7937
7934
|
for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
|
|
@@ -7956,16 +7953,16 @@ var PrefixItemsHandler = class {
|
|
|
7956
7953
|
{ message: "Array does not match prefixItems schema" }
|
|
7957
7954
|
);
|
|
7958
7955
|
}
|
|
7959
|
-
return
|
|
7956
|
+
return zodSchema4;
|
|
7960
7957
|
}
|
|
7961
7958
|
};
|
|
7962
7959
|
var ObjectPropertiesHandler = class {
|
|
7963
|
-
apply(
|
|
7960
|
+
apply(zodSchema4, schema) {
|
|
7964
7961
|
const objectSchema = schema;
|
|
7965
7962
|
if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
|
|
7966
|
-
return
|
|
7963
|
+
return zodSchema4;
|
|
7967
7964
|
}
|
|
7968
|
-
if (
|
|
7965
|
+
if (zodSchema4 instanceof z42.z.ZodObject || zodSchema4 instanceof z42.z.ZodRecord) {
|
|
7969
7966
|
const shape = {};
|
|
7970
7967
|
if (objectSchema.properties) {
|
|
7971
7968
|
for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
|
|
@@ -7992,7 +7989,7 @@ var ObjectPropertiesHandler = class {
|
|
|
7992
7989
|
return z42.z.object(shape).passthrough();
|
|
7993
7990
|
}
|
|
7994
7991
|
}
|
|
7995
|
-
return
|
|
7992
|
+
return zodSchema4.refine(
|
|
7996
7993
|
(value) => {
|
|
7997
7994
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7998
7995
|
return true;
|
|
@@ -8034,13 +8031,13 @@ var ObjectPropertiesHandler = class {
|
|
|
8034
8031
|
}
|
|
8035
8032
|
};
|
|
8036
8033
|
var EnumComplexHandler = class {
|
|
8037
|
-
apply(
|
|
8038
|
-
if (!schema.enum || schema.enum.length === 0) return
|
|
8034
|
+
apply(zodSchema4, schema) {
|
|
8035
|
+
if (!schema.enum || schema.enum.length === 0) return zodSchema4;
|
|
8039
8036
|
const complexValues = schema.enum.filter(
|
|
8040
8037
|
(v) => Array.isArray(v) || typeof v === "object" && v !== null
|
|
8041
8038
|
);
|
|
8042
|
-
if (complexValues.length === 0) return
|
|
8043
|
-
return
|
|
8039
|
+
if (complexValues.length === 0) return zodSchema4;
|
|
8040
|
+
return zodSchema4.refine(
|
|
8044
8041
|
(value) => {
|
|
8045
8042
|
if (typeof value !== "object" || value === null) return true;
|
|
8046
8043
|
return complexValues.some(
|
|
@@ -8052,32 +8049,32 @@ var EnumComplexHandler = class {
|
|
|
8052
8049
|
}
|
|
8053
8050
|
};
|
|
8054
8051
|
var ConstComplexHandler = class {
|
|
8055
|
-
apply(
|
|
8056
|
-
if (schema.const === void 0) return
|
|
8052
|
+
apply(zodSchema4, schema) {
|
|
8053
|
+
if (schema.const === void 0) return zodSchema4;
|
|
8057
8054
|
const constValue = schema.const;
|
|
8058
8055
|
if (typeof constValue !== "object" || constValue === null) {
|
|
8059
|
-
return
|
|
8056
|
+
return zodSchema4;
|
|
8060
8057
|
}
|
|
8061
|
-
return
|
|
8058
|
+
return zodSchema4.refine(
|
|
8062
8059
|
(value) => deepEqual(value, constValue),
|
|
8063
8060
|
{ message: "Value must equal the const value" }
|
|
8064
8061
|
);
|
|
8065
8062
|
}
|
|
8066
8063
|
};
|
|
8067
8064
|
var MetadataHandler = class {
|
|
8068
|
-
apply(
|
|
8065
|
+
apply(zodSchema4, schema) {
|
|
8069
8066
|
if (schema.description) {
|
|
8070
|
-
|
|
8067
|
+
zodSchema4 = zodSchema4.describe(schema.description);
|
|
8071
8068
|
}
|
|
8072
|
-
return
|
|
8069
|
+
return zodSchema4;
|
|
8073
8070
|
}
|
|
8074
8071
|
};
|
|
8075
8072
|
var ProtoRequiredHandler = class {
|
|
8076
|
-
apply(
|
|
8077
|
-
var
|
|
8073
|
+
apply(zodSchema4, schema) {
|
|
8074
|
+
var _a20;
|
|
8078
8075
|
const objectSchema = schema;
|
|
8079
|
-
if (!((
|
|
8080
|
-
return
|
|
8076
|
+
if (!((_a20 = objectSchema.required) == null ? void 0 : _a20.includes("__proto__")) || schema.type !== void 0) {
|
|
8077
|
+
return zodSchema4;
|
|
8081
8078
|
}
|
|
8082
8079
|
return z42.z.any().refine(
|
|
8083
8080
|
(value) => this.validateRequired(value, objectSchema.required),
|
|
@@ -8094,14 +8091,14 @@ var ProtoRequiredHandler = class {
|
|
|
8094
8091
|
}
|
|
8095
8092
|
};
|
|
8096
8093
|
var ContainsHandler = class {
|
|
8097
|
-
apply(
|
|
8098
|
-
var
|
|
8094
|
+
apply(zodSchema4, schema) {
|
|
8095
|
+
var _a20;
|
|
8099
8096
|
const arraySchema = schema;
|
|
8100
|
-
if (arraySchema.contains === void 0) return
|
|
8097
|
+
if (arraySchema.contains === void 0) return zodSchema4;
|
|
8101
8098
|
const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
|
|
8102
|
-
const minContains = (
|
|
8099
|
+
const minContains = (_a20 = arraySchema.minContains) != null ? _a20 : 1;
|
|
8103
8100
|
const maxContains = arraySchema.maxContains;
|
|
8104
|
-
return
|
|
8101
|
+
return zodSchema4.refine(
|
|
8105
8102
|
(value) => {
|
|
8106
8103
|
if (!Array.isArray(value)) {
|
|
8107
8104
|
return true;
|
|
@@ -8210,32 +8207,32 @@ function convertJsonSchemaToZod(schema) {
|
|
|
8210
8207
|
allowedSchemas.push(objectSchema);
|
|
8211
8208
|
}
|
|
8212
8209
|
}
|
|
8213
|
-
let
|
|
8210
|
+
let zodSchema4;
|
|
8214
8211
|
if (allowedSchemas.length === 0) {
|
|
8215
|
-
|
|
8212
|
+
zodSchema4 = z42.z.never();
|
|
8216
8213
|
} else if (allowedSchemas.length === 1) {
|
|
8217
|
-
|
|
8214
|
+
zodSchema4 = allowedSchemas[0];
|
|
8218
8215
|
} else {
|
|
8219
8216
|
const hasConstraints = Object.keys(schema).some(
|
|
8220
8217
|
(key) => key !== "$schema" && key !== "title" && key !== "description"
|
|
8221
8218
|
);
|
|
8222
8219
|
if (!hasConstraints) {
|
|
8223
|
-
|
|
8220
|
+
zodSchema4 = z42.z.any();
|
|
8224
8221
|
} else {
|
|
8225
|
-
|
|
8222
|
+
zodSchema4 = z42.z.union(allowedSchemas);
|
|
8226
8223
|
}
|
|
8227
8224
|
}
|
|
8228
8225
|
for (const handler of refinementHandlers) {
|
|
8229
|
-
|
|
8226
|
+
zodSchema4 = handler.apply(zodSchema4, schema);
|
|
8230
8227
|
}
|
|
8231
|
-
return
|
|
8228
|
+
return zodSchema4;
|
|
8232
8229
|
}
|
|
8233
8230
|
function convertJsonSchemaToZod2(schema) {
|
|
8234
|
-
function addMetadata(
|
|
8235
|
-
if (
|
|
8236
|
-
|
|
8231
|
+
function addMetadata(zodSchema4, jsonSchema4) {
|
|
8232
|
+
if (jsonSchema4.description) {
|
|
8233
|
+
zodSchema4 = zodSchema4.describe(jsonSchema4.description);
|
|
8237
8234
|
}
|
|
8238
|
-
return
|
|
8235
|
+
return zodSchema4;
|
|
8239
8236
|
}
|
|
8240
8237
|
if (schema.const !== void 0) {
|
|
8241
8238
|
if (typeof schema.const === "string") {
|
|
@@ -8341,13 +8338,13 @@ function convertJsonSchemaToZod2(schema) {
|
|
|
8341
8338
|
shape[key] = shape[key].optional();
|
|
8342
8339
|
}
|
|
8343
8340
|
}
|
|
8344
|
-
let
|
|
8341
|
+
let zodSchema4;
|
|
8345
8342
|
if (schema.additionalProperties !== false) {
|
|
8346
|
-
|
|
8343
|
+
zodSchema4 = zod.z.object(shape).passthrough();
|
|
8347
8344
|
} else {
|
|
8348
|
-
|
|
8345
|
+
zodSchema4 = zod.z.object(shape);
|
|
8349
8346
|
}
|
|
8350
|
-
return addMetadata(
|
|
8347
|
+
return addMetadata(zodSchema4, schema);
|
|
8351
8348
|
}
|
|
8352
8349
|
return addMetadata(zod.z.object({}), schema);
|
|
8353
8350
|
case "array": {
|
|
@@ -8887,11 +8884,11 @@ ${workingMemory}`;
|
|
|
8887
8884
|
release();
|
|
8888
8885
|
}
|
|
8889
8886
|
}
|
|
8890
|
-
chunkText(
|
|
8887
|
+
chunkText(text4, tokenSize = 4096) {
|
|
8891
8888
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
8892
8889
|
const chunks = [];
|
|
8893
8890
|
let currentChunk = "";
|
|
8894
|
-
const words =
|
|
8891
|
+
const words = text4.split(/\s+/);
|
|
8895
8892
|
for (const word of words) {
|
|
8896
8893
|
const wordWithSpace = currentChunk ? " " + word : word;
|
|
8897
8894
|
if (currentChunk.length + wordWithSpace.length > charSize) {
|
|
@@ -9053,10 +9050,10 @@ ${workingMemory}`;
|
|
|
9053
9050
|
}
|
|
9054
9051
|
return newMessage;
|
|
9055
9052
|
}
|
|
9056
|
-
parseWorkingMemory(
|
|
9053
|
+
parseWorkingMemory(text4) {
|
|
9057
9054
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
9058
9055
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
9059
|
-
const matches =
|
|
9056
|
+
const matches = text4.match(workingMemoryRegex);
|
|
9060
9057
|
const match = matches?.[0];
|
|
9061
9058
|
if (match) {
|
|
9062
9059
|
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
@@ -9356,12 +9353,12 @@ var _Tiktoken = class {
|
|
|
9356
9353
|
this.textMap.set(rank, bytes);
|
|
9357
9354
|
}
|
|
9358
9355
|
this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
|
|
9359
|
-
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [
|
|
9360
|
-
memo[rank] = this.textEncoder.encode(
|
|
9356
|
+
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
|
|
9357
|
+
memo[rank] = this.textEncoder.encode(text4);
|
|
9361
9358
|
return memo;
|
|
9362
9359
|
}, {});
|
|
9363
9360
|
}
|
|
9364
|
-
encode(
|
|
9361
|
+
encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
|
|
9365
9362
|
const regexes = new RegExp(this.patStr, "ug");
|
|
9366
9363
|
const specialRegex = _Tiktoken.specialTokenRegex(
|
|
9367
9364
|
Object.keys(this.specialTokens)
|
|
@@ -9379,7 +9376,7 @@ var _Tiktoken = class {
|
|
|
9379
9376
|
const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
|
|
9380
9377
|
...disallowedSpecialSet
|
|
9381
9378
|
]);
|
|
9382
|
-
const specialMatch =
|
|
9379
|
+
const specialMatch = text4.match(disallowedSpecialRegex);
|
|
9383
9380
|
if (specialMatch != null) {
|
|
9384
9381
|
throw new Error(
|
|
9385
9382
|
`The text contains a special token that is not allowed: ${specialMatch[0]}`
|
|
@@ -9392,13 +9389,13 @@ var _Tiktoken = class {
|
|
|
9392
9389
|
let startFind = start;
|
|
9393
9390
|
while (true) {
|
|
9394
9391
|
specialRegex.lastIndex = startFind;
|
|
9395
|
-
nextSpecial = specialRegex.exec(
|
|
9392
|
+
nextSpecial = specialRegex.exec(text4);
|
|
9396
9393
|
if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
|
|
9397
9394
|
break;
|
|
9398
9395
|
startFind = nextSpecial.index + 1;
|
|
9399
9396
|
}
|
|
9400
|
-
const end = nextSpecial?.index ??
|
|
9401
|
-
for (const match of
|
|
9397
|
+
const end = nextSpecial?.index ?? text4.length;
|
|
9398
|
+
for (const match of text4.substring(start, end).matchAll(regexes)) {
|
|
9402
9399
|
const piece = this.textEncoder.encode(match[0]);
|
|
9403
9400
|
const token2 = this.rankMap.get(piece.join(","));
|
|
9404
9401
|
if (token2 != null) {
|
|
@@ -9546,6 +9543,2284 @@ var TokenLimiter = class extends memory.MemoryProcessor {
|
|
|
9546
9543
|
|
|
9547
9544
|
// ../agent-builder/dist/index.js
|
|
9548
9545
|
var import_ignore = chunkEMMSS5I5_cjs.__toESM(require_ignore(), 1);
|
|
9546
|
+
var createIdGenerator3 = ({
|
|
9547
|
+
prefix,
|
|
9548
|
+
size = 16,
|
|
9549
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
9550
|
+
separator = "-"
|
|
9551
|
+
} = {}) => {
|
|
9552
|
+
const generator = () => {
|
|
9553
|
+
const alphabetLength = alphabet.length;
|
|
9554
|
+
const chars = new Array(size);
|
|
9555
|
+
for (let i = 0; i < size; i++) {
|
|
9556
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
9557
|
+
}
|
|
9558
|
+
return chars.join("");
|
|
9559
|
+
};
|
|
9560
|
+
if (prefix == null) {
|
|
9561
|
+
return generator;
|
|
9562
|
+
}
|
|
9563
|
+
if (alphabet.includes(separator)) {
|
|
9564
|
+
throw new chunkHVBBFCDH_cjs.InvalidArgumentError({
|
|
9565
|
+
argument: "separator",
|
|
9566
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
9567
|
+
});
|
|
9568
|
+
}
|
|
9569
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
9570
|
+
};
|
|
9571
|
+
createIdGenerator3();
|
|
9572
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
9573
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
9574
|
+
function _parse2(text4) {
|
|
9575
|
+
const obj = JSON.parse(text4);
|
|
9576
|
+
if (obj === null || typeof obj !== "object") {
|
|
9577
|
+
return obj;
|
|
9578
|
+
}
|
|
9579
|
+
if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
|
|
9580
|
+
return obj;
|
|
9581
|
+
}
|
|
9582
|
+
return filter2(obj);
|
|
9583
|
+
}
|
|
9584
|
+
function filter2(obj) {
|
|
9585
|
+
let next = [obj];
|
|
9586
|
+
while (next.length) {
|
|
9587
|
+
const nodes = next;
|
|
9588
|
+
next = [];
|
|
9589
|
+
for (const node of nodes) {
|
|
9590
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9591
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9592
|
+
}
|
|
9593
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9594
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9595
|
+
}
|
|
9596
|
+
for (const key in node) {
|
|
9597
|
+
const value = node[key];
|
|
9598
|
+
if (value && typeof value === "object") {
|
|
9599
|
+
next.push(value);
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
return obj;
|
|
9605
|
+
}
|
|
9606
|
+
function secureJsonParse2(text4) {
|
|
9607
|
+
const { stackTraceLimit } = Error;
|
|
9608
|
+
Error.stackTraceLimit = 0;
|
|
9609
|
+
try {
|
|
9610
|
+
return _parse2(text4);
|
|
9611
|
+
} finally {
|
|
9612
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
9613
|
+
}
|
|
9614
|
+
}
|
|
9615
|
+
var validatorSymbol3 = Symbol.for("vercel.ai.validator");
|
|
9616
|
+
function validator2(validate) {
|
|
9617
|
+
return { [validatorSymbol3]: true, validate };
|
|
9618
|
+
}
|
|
9619
|
+
function isValidator2(value) {
|
|
9620
|
+
return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
|
|
9621
|
+
}
|
|
9622
|
+
function asValidator2(value) {
|
|
9623
|
+
return isValidator2(value) ? value : standardSchemaValidator2(value);
|
|
9624
|
+
}
|
|
9625
|
+
function standardSchemaValidator2(standardSchema) {
|
|
9626
|
+
return validator2(async (value) => {
|
|
9627
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
9628
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
9629
|
+
success: false,
|
|
9630
|
+
error: new chunkHVBBFCDH_cjs.TypeValidationError({
|
|
9631
|
+
value,
|
|
9632
|
+
cause: result.issues
|
|
9633
|
+
})
|
|
9634
|
+
};
|
|
9635
|
+
});
|
|
9636
|
+
}
|
|
9637
|
+
async function safeValidateTypes3({
|
|
9638
|
+
value,
|
|
9639
|
+
schema
|
|
9640
|
+
}) {
|
|
9641
|
+
const validator22 = asValidator2(schema);
|
|
9642
|
+
try {
|
|
9643
|
+
if (validator22.validate == null) {
|
|
9644
|
+
return { success: true, value, rawValue: value };
|
|
9645
|
+
}
|
|
9646
|
+
const result = await validator22.validate(value);
|
|
9647
|
+
if (result.success) {
|
|
9648
|
+
return { success: true, value: result.value, rawValue: value };
|
|
9649
|
+
}
|
|
9650
|
+
return {
|
|
9651
|
+
success: false,
|
|
9652
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
9653
|
+
rawValue: value
|
|
9654
|
+
};
|
|
9655
|
+
} catch (error) {
|
|
9656
|
+
return {
|
|
9657
|
+
success: false,
|
|
9658
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
9659
|
+
rawValue: value
|
|
9660
|
+
};
|
|
9661
|
+
}
|
|
9662
|
+
}
|
|
9663
|
+
async function safeParseJSON3({
|
|
9664
|
+
text: text4,
|
|
9665
|
+
schema
|
|
9666
|
+
}) {
|
|
9667
|
+
try {
|
|
9668
|
+
const value = secureJsonParse2(text4);
|
|
9669
|
+
if (schema == null) {
|
|
9670
|
+
return { success: true, value, rawValue: value };
|
|
9671
|
+
}
|
|
9672
|
+
return await safeValidateTypes3({ value, schema });
|
|
9673
|
+
} catch (error) {
|
|
9674
|
+
return {
|
|
9675
|
+
success: false,
|
|
9676
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
9677
|
+
rawValue: void 0
|
|
9678
|
+
};
|
|
9679
|
+
}
|
|
9680
|
+
}
|
|
9681
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
9682
|
+
let i = 0;
|
|
9683
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
9684
|
+
if (pathA[i] !== pathB[i])
|
|
9685
|
+
break;
|
|
9686
|
+
}
|
|
9687
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
9688
|
+
};
|
|
9689
|
+
var ignoreOverride2 = Symbol(
|
|
9690
|
+
"Let zodToJsonSchema decide on which parser to use"
|
|
9691
|
+
);
|
|
9692
|
+
var defaultOptions2 = {
|
|
9693
|
+
name: void 0,
|
|
9694
|
+
$refStrategy: "root",
|
|
9695
|
+
basePath: ["#"],
|
|
9696
|
+
effectStrategy: "input",
|
|
9697
|
+
pipeStrategy: "all",
|
|
9698
|
+
dateStrategy: "format:date-time",
|
|
9699
|
+
mapStrategy: "entries",
|
|
9700
|
+
removeAdditionalStrategy: "passthrough",
|
|
9701
|
+
allowedAdditionalProperties: true,
|
|
9702
|
+
rejectedAdditionalProperties: false,
|
|
9703
|
+
definitionPath: "definitions",
|
|
9704
|
+
strictUnions: false,
|
|
9705
|
+
definitions: {},
|
|
9706
|
+
errorMessages: false,
|
|
9707
|
+
patternStrategy: "escape",
|
|
9708
|
+
applyRegexFlags: false,
|
|
9709
|
+
emailStrategy: "format:email",
|
|
9710
|
+
base64Strategy: "contentEncoding:base64",
|
|
9711
|
+
nameStrategy: "ref"
|
|
9712
|
+
};
|
|
9713
|
+
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
9714
|
+
...defaultOptions2,
|
|
9715
|
+
name: options
|
|
9716
|
+
} : {
|
|
9717
|
+
...defaultOptions2,
|
|
9718
|
+
...options
|
|
9719
|
+
};
|
|
9720
|
+
function parseAnyDef2() {
|
|
9721
|
+
return {};
|
|
9722
|
+
}
|
|
9723
|
+
function parseArrayDef2(def, refs) {
|
|
9724
|
+
var _a20, _b8, _c;
|
|
9725
|
+
const res = {
|
|
9726
|
+
type: "array"
|
|
9727
|
+
};
|
|
9728
|
+
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) {
|
|
9729
|
+
res.items = parseDef2(def.type._def, {
|
|
9730
|
+
...refs,
|
|
9731
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9732
|
+
});
|
|
9733
|
+
}
|
|
9734
|
+
if (def.minLength) {
|
|
9735
|
+
res.minItems = def.minLength.value;
|
|
9736
|
+
}
|
|
9737
|
+
if (def.maxLength) {
|
|
9738
|
+
res.maxItems = def.maxLength.value;
|
|
9739
|
+
}
|
|
9740
|
+
if (def.exactLength) {
|
|
9741
|
+
res.minItems = def.exactLength.value;
|
|
9742
|
+
res.maxItems = def.exactLength.value;
|
|
9743
|
+
}
|
|
9744
|
+
return res;
|
|
9745
|
+
}
|
|
9746
|
+
function parseBigintDef2(def) {
|
|
9747
|
+
const res = {
|
|
9748
|
+
type: "integer",
|
|
9749
|
+
format: "int64"
|
|
9750
|
+
};
|
|
9751
|
+
if (!def.checks)
|
|
9752
|
+
return res;
|
|
9753
|
+
for (const check of def.checks) {
|
|
9754
|
+
switch (check.kind) {
|
|
9755
|
+
case "min":
|
|
9756
|
+
if (check.inclusive) {
|
|
9757
|
+
res.minimum = check.value;
|
|
9758
|
+
} else {
|
|
9759
|
+
res.exclusiveMinimum = check.value;
|
|
9760
|
+
}
|
|
9761
|
+
break;
|
|
9762
|
+
case "max":
|
|
9763
|
+
if (check.inclusive) {
|
|
9764
|
+
res.maximum = check.value;
|
|
9765
|
+
} else {
|
|
9766
|
+
res.exclusiveMaximum = check.value;
|
|
9767
|
+
}
|
|
9768
|
+
break;
|
|
9769
|
+
case "multipleOf":
|
|
9770
|
+
res.multipleOf = check.value;
|
|
9771
|
+
break;
|
|
9772
|
+
}
|
|
9773
|
+
}
|
|
9774
|
+
return res;
|
|
9775
|
+
}
|
|
9776
|
+
function parseBooleanDef2() {
|
|
9777
|
+
return { type: "boolean" };
|
|
9778
|
+
}
|
|
9779
|
+
function parseBrandedDef2(_def, refs) {
|
|
9780
|
+
return parseDef2(_def.type._def, refs);
|
|
9781
|
+
}
|
|
9782
|
+
var parseCatchDef2 = (def, refs) => {
|
|
9783
|
+
return parseDef2(def.innerType._def, refs);
|
|
9784
|
+
};
|
|
9785
|
+
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
9786
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
9787
|
+
if (Array.isArray(strategy)) {
|
|
9788
|
+
return {
|
|
9789
|
+
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
9790
|
+
};
|
|
9791
|
+
}
|
|
9792
|
+
switch (strategy) {
|
|
9793
|
+
case "string":
|
|
9794
|
+
case "format:date-time":
|
|
9795
|
+
return {
|
|
9796
|
+
type: "string",
|
|
9797
|
+
format: "date-time"
|
|
9798
|
+
};
|
|
9799
|
+
case "format:date":
|
|
9800
|
+
return {
|
|
9801
|
+
type: "string",
|
|
9802
|
+
format: "date"
|
|
9803
|
+
};
|
|
9804
|
+
case "integer":
|
|
9805
|
+
return integerDateParser2(def);
|
|
9806
|
+
}
|
|
9807
|
+
}
|
|
9808
|
+
var integerDateParser2 = (def) => {
|
|
9809
|
+
const res = {
|
|
9810
|
+
type: "integer",
|
|
9811
|
+
format: "unix-time"
|
|
9812
|
+
};
|
|
9813
|
+
for (const check of def.checks) {
|
|
9814
|
+
switch (check.kind) {
|
|
9815
|
+
case "min":
|
|
9816
|
+
res.minimum = check.value;
|
|
9817
|
+
break;
|
|
9818
|
+
case "max":
|
|
9819
|
+
res.maximum = check.value;
|
|
9820
|
+
break;
|
|
9821
|
+
}
|
|
9822
|
+
}
|
|
9823
|
+
return res;
|
|
9824
|
+
};
|
|
9825
|
+
function parseDefaultDef2(_def, refs) {
|
|
9826
|
+
return {
|
|
9827
|
+
...parseDef2(_def.innerType._def, refs),
|
|
9828
|
+
default: _def.defaultValue()
|
|
9829
|
+
};
|
|
9830
|
+
}
|
|
9831
|
+
function parseEffectsDef2(_def, refs) {
|
|
9832
|
+
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
|
|
9833
|
+
}
|
|
9834
|
+
function parseEnumDef2(def) {
|
|
9835
|
+
return {
|
|
9836
|
+
type: "string",
|
|
9837
|
+
enum: Array.from(def.values)
|
|
9838
|
+
};
|
|
9839
|
+
}
|
|
9840
|
+
var isJsonSchema7AllOfType2 = (type) => {
|
|
9841
|
+
if ("type" in type && type.type === "string")
|
|
9842
|
+
return false;
|
|
9843
|
+
return "allOf" in type;
|
|
9844
|
+
};
|
|
9845
|
+
function parseIntersectionDef2(def, refs) {
|
|
9846
|
+
const allOf = [
|
|
9847
|
+
parseDef2(def.left._def, {
|
|
9848
|
+
...refs,
|
|
9849
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9850
|
+
}),
|
|
9851
|
+
parseDef2(def.right._def, {
|
|
9852
|
+
...refs,
|
|
9853
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
9854
|
+
})
|
|
9855
|
+
].filter((x) => !!x);
|
|
9856
|
+
const mergedAllOf = [];
|
|
9857
|
+
allOf.forEach((schema) => {
|
|
9858
|
+
if (isJsonSchema7AllOfType2(schema)) {
|
|
9859
|
+
mergedAllOf.push(...schema.allOf);
|
|
9860
|
+
} else {
|
|
9861
|
+
let nestedSchema = schema;
|
|
9862
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
9863
|
+
const { additionalProperties, ...rest } = schema;
|
|
9864
|
+
nestedSchema = rest;
|
|
9865
|
+
}
|
|
9866
|
+
mergedAllOf.push(nestedSchema);
|
|
9867
|
+
}
|
|
9868
|
+
});
|
|
9869
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
|
|
9870
|
+
}
|
|
9871
|
+
function parseLiteralDef2(def) {
|
|
9872
|
+
const parsedType = typeof def.value;
|
|
9873
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
9874
|
+
return {
|
|
9875
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
9876
|
+
};
|
|
9877
|
+
}
|
|
9878
|
+
return {
|
|
9879
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9880
|
+
const: def.value
|
|
9881
|
+
};
|
|
9882
|
+
}
|
|
9883
|
+
var emojiRegex2 = void 0;
|
|
9884
|
+
var zodPatterns2 = {
|
|
9885
|
+
/**
|
|
9886
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
9887
|
+
*/
|
|
9888
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
9889
|
+
cuid2: /^[0-9a-z]+$/,
|
|
9890
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
9891
|
+
/**
|
|
9892
|
+
* `a-z` was added to replicate /i flag
|
|
9893
|
+
*/
|
|
9894
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
9895
|
+
/**
|
|
9896
|
+
* Constructed a valid Unicode RegExp
|
|
9897
|
+
*
|
|
9898
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
9899
|
+
* in all envs (e.g. React Native).
|
|
9900
|
+
*
|
|
9901
|
+
* See:
|
|
9902
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
9903
|
+
* Fix in Zod:
|
|
9904
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
9905
|
+
*/
|
|
9906
|
+
emoji: () => {
|
|
9907
|
+
if (emojiRegex2 === void 0) {
|
|
9908
|
+
emojiRegex2 = RegExp(
|
|
9909
|
+
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
9910
|
+
"u"
|
|
9911
|
+
);
|
|
9912
|
+
}
|
|
9913
|
+
return emojiRegex2;
|
|
9914
|
+
},
|
|
9915
|
+
/**
|
|
9916
|
+
* Unused
|
|
9917
|
+
*/
|
|
9918
|
+
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}$/,
|
|
9919
|
+
/**
|
|
9920
|
+
* Unused
|
|
9921
|
+
*/
|
|
9922
|
+
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])$/,
|
|
9923
|
+
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])$/,
|
|
9924
|
+
/**
|
|
9925
|
+
* Unused
|
|
9926
|
+
*/
|
|
9927
|
+
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})))$/,
|
|
9928
|
+
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])$/,
|
|
9929
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
9930
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
9931
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
9932
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
9933
|
+
};
|
|
9934
|
+
function parseStringDef2(def, refs) {
|
|
9935
|
+
const res = {
|
|
9936
|
+
type: "string"
|
|
9937
|
+
};
|
|
9938
|
+
if (def.checks) {
|
|
9939
|
+
for (const check of def.checks) {
|
|
9940
|
+
switch (check.kind) {
|
|
9941
|
+
case "min":
|
|
9942
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
9943
|
+
break;
|
|
9944
|
+
case "max":
|
|
9945
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
9946
|
+
break;
|
|
9947
|
+
case "email":
|
|
9948
|
+
switch (refs.emailStrategy) {
|
|
9949
|
+
case "format:email":
|
|
9950
|
+
addFormat2(res, "email", check.message, refs);
|
|
9951
|
+
break;
|
|
9952
|
+
case "format:idn-email":
|
|
9953
|
+
addFormat2(res, "idn-email", check.message, refs);
|
|
9954
|
+
break;
|
|
9955
|
+
case "pattern:zod":
|
|
9956
|
+
addPattern2(res, zodPatterns2.email, check.message, refs);
|
|
9957
|
+
break;
|
|
9958
|
+
}
|
|
9959
|
+
break;
|
|
9960
|
+
case "url":
|
|
9961
|
+
addFormat2(res, "uri", check.message, refs);
|
|
9962
|
+
break;
|
|
9963
|
+
case "uuid":
|
|
9964
|
+
addFormat2(res, "uuid", check.message, refs);
|
|
9965
|
+
break;
|
|
9966
|
+
case "regex":
|
|
9967
|
+
addPattern2(res, check.regex, check.message, refs);
|
|
9968
|
+
break;
|
|
9969
|
+
case "cuid":
|
|
9970
|
+
addPattern2(res, zodPatterns2.cuid, check.message, refs);
|
|
9971
|
+
break;
|
|
9972
|
+
case "cuid2":
|
|
9973
|
+
addPattern2(res, zodPatterns2.cuid2, check.message, refs);
|
|
9974
|
+
break;
|
|
9975
|
+
case "startsWith":
|
|
9976
|
+
addPattern2(
|
|
9977
|
+
res,
|
|
9978
|
+
RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`),
|
|
9979
|
+
check.message,
|
|
9980
|
+
refs
|
|
9981
|
+
);
|
|
9982
|
+
break;
|
|
9983
|
+
case "endsWith":
|
|
9984
|
+
addPattern2(
|
|
9985
|
+
res,
|
|
9986
|
+
RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`),
|
|
9987
|
+
check.message,
|
|
9988
|
+
refs
|
|
9989
|
+
);
|
|
9990
|
+
break;
|
|
9991
|
+
case "datetime":
|
|
9992
|
+
addFormat2(res, "date-time", check.message, refs);
|
|
9993
|
+
break;
|
|
9994
|
+
case "date":
|
|
9995
|
+
addFormat2(res, "date", check.message, refs);
|
|
9996
|
+
break;
|
|
9997
|
+
case "time":
|
|
9998
|
+
addFormat2(res, "time", check.message, refs);
|
|
9999
|
+
break;
|
|
10000
|
+
case "duration":
|
|
10001
|
+
addFormat2(res, "duration", check.message, refs);
|
|
10002
|
+
break;
|
|
10003
|
+
case "length":
|
|
10004
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
10005
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
10006
|
+
break;
|
|
10007
|
+
case "includes": {
|
|
10008
|
+
addPattern2(
|
|
10009
|
+
res,
|
|
10010
|
+
RegExp(escapeLiteralCheckValue2(check.value, refs)),
|
|
10011
|
+
check.message,
|
|
10012
|
+
refs
|
|
10013
|
+
);
|
|
10014
|
+
break;
|
|
10015
|
+
}
|
|
10016
|
+
case "ip": {
|
|
10017
|
+
if (check.version !== "v6") {
|
|
10018
|
+
addFormat2(res, "ipv4", check.message, refs);
|
|
10019
|
+
}
|
|
10020
|
+
if (check.version !== "v4") {
|
|
10021
|
+
addFormat2(res, "ipv6", check.message, refs);
|
|
10022
|
+
}
|
|
10023
|
+
break;
|
|
10024
|
+
}
|
|
10025
|
+
case "base64url":
|
|
10026
|
+
addPattern2(res, zodPatterns2.base64url, check.message, refs);
|
|
10027
|
+
break;
|
|
10028
|
+
case "jwt":
|
|
10029
|
+
addPattern2(res, zodPatterns2.jwt, check.message, refs);
|
|
10030
|
+
break;
|
|
10031
|
+
case "cidr": {
|
|
10032
|
+
if (check.version !== "v6") {
|
|
10033
|
+
addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
|
|
10034
|
+
}
|
|
10035
|
+
if (check.version !== "v4") {
|
|
10036
|
+
addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
|
|
10037
|
+
}
|
|
10038
|
+
break;
|
|
10039
|
+
}
|
|
10040
|
+
case "emoji":
|
|
10041
|
+
addPattern2(res, zodPatterns2.emoji(), check.message, refs);
|
|
10042
|
+
break;
|
|
10043
|
+
case "ulid": {
|
|
10044
|
+
addPattern2(res, zodPatterns2.ulid, check.message, refs);
|
|
10045
|
+
break;
|
|
10046
|
+
}
|
|
10047
|
+
case "base64": {
|
|
10048
|
+
switch (refs.base64Strategy) {
|
|
10049
|
+
case "format:binary": {
|
|
10050
|
+
addFormat2(res, "binary", check.message, refs);
|
|
10051
|
+
break;
|
|
10052
|
+
}
|
|
10053
|
+
case "contentEncoding:base64": {
|
|
10054
|
+
res.contentEncoding = "base64";
|
|
10055
|
+
break;
|
|
10056
|
+
}
|
|
10057
|
+
case "pattern:zod": {
|
|
10058
|
+
addPattern2(res, zodPatterns2.base64, check.message, refs);
|
|
10059
|
+
break;
|
|
10060
|
+
}
|
|
10061
|
+
}
|
|
10062
|
+
break;
|
|
10063
|
+
}
|
|
10064
|
+
case "nanoid": {
|
|
10065
|
+
addPattern2(res, zodPatterns2.nanoid, check.message, refs);
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
}
|
|
10070
|
+
return res;
|
|
10071
|
+
}
|
|
10072
|
+
function escapeLiteralCheckValue2(literal, refs) {
|
|
10073
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
|
|
10074
|
+
}
|
|
10075
|
+
var ALPHA_NUMERIC2 = new Set(
|
|
10076
|
+
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
10077
|
+
);
|
|
10078
|
+
function escapeNonAlphaNumeric2(source) {
|
|
10079
|
+
let result = "";
|
|
10080
|
+
for (let i = 0; i < source.length; i++) {
|
|
10081
|
+
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
10082
|
+
result += "\\";
|
|
10083
|
+
}
|
|
10084
|
+
result += source[i];
|
|
10085
|
+
}
|
|
10086
|
+
return result;
|
|
10087
|
+
}
|
|
10088
|
+
function addFormat2(schema, value, message, refs) {
|
|
10089
|
+
var _a20;
|
|
10090
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
10091
|
+
if (!schema.anyOf) {
|
|
10092
|
+
schema.anyOf = [];
|
|
10093
|
+
}
|
|
10094
|
+
if (schema.format) {
|
|
10095
|
+
schema.anyOf.push({
|
|
10096
|
+
format: schema.format
|
|
10097
|
+
});
|
|
10098
|
+
delete schema.format;
|
|
10099
|
+
}
|
|
10100
|
+
schema.anyOf.push({
|
|
10101
|
+
format: value,
|
|
10102
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
10103
|
+
});
|
|
10104
|
+
} else {
|
|
10105
|
+
schema.format = value;
|
|
10106
|
+
}
|
|
10107
|
+
}
|
|
10108
|
+
function addPattern2(schema, regex, message, refs) {
|
|
10109
|
+
var _a20;
|
|
10110
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
10111
|
+
if (!schema.allOf) {
|
|
10112
|
+
schema.allOf = [];
|
|
10113
|
+
}
|
|
10114
|
+
if (schema.pattern) {
|
|
10115
|
+
schema.allOf.push({
|
|
10116
|
+
pattern: schema.pattern
|
|
10117
|
+
});
|
|
10118
|
+
delete schema.pattern;
|
|
10119
|
+
}
|
|
10120
|
+
schema.allOf.push({
|
|
10121
|
+
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
10122
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
10123
|
+
});
|
|
10124
|
+
} else {
|
|
10125
|
+
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
10126
|
+
}
|
|
10127
|
+
}
|
|
10128
|
+
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10129
|
+
var _a20;
|
|
10130
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10131
|
+
return regex.source;
|
|
10132
|
+
}
|
|
10133
|
+
const flags = {
|
|
10134
|
+
i: regex.flags.includes("i"),
|
|
10135
|
+
// Case-insensitive
|
|
10136
|
+
m: regex.flags.includes("m"),
|
|
10137
|
+
// `^` and `$` matches adjacent to newline characters
|
|
10138
|
+
s: regex.flags.includes("s")
|
|
10139
|
+
// `.` matches newlines
|
|
10140
|
+
};
|
|
10141
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
10142
|
+
let pattern = "";
|
|
10143
|
+
let isEscaped = false;
|
|
10144
|
+
let inCharGroup = false;
|
|
10145
|
+
let inCharRange = false;
|
|
10146
|
+
for (let i = 0; i < source.length; i++) {
|
|
10147
|
+
if (isEscaped) {
|
|
10148
|
+
pattern += source[i];
|
|
10149
|
+
isEscaped = false;
|
|
10150
|
+
continue;
|
|
10151
|
+
}
|
|
10152
|
+
if (flags.i) {
|
|
10153
|
+
if (inCharGroup) {
|
|
10154
|
+
if (source[i].match(/[a-z]/)) {
|
|
10155
|
+
if (inCharRange) {
|
|
10156
|
+
pattern += source[i];
|
|
10157
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10158
|
+
inCharRange = false;
|
|
10159
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
10160
|
+
pattern += source[i];
|
|
10161
|
+
inCharRange = true;
|
|
10162
|
+
} else {
|
|
10163
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
10164
|
+
}
|
|
10165
|
+
continue;
|
|
10166
|
+
}
|
|
10167
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
10168
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
10169
|
+
continue;
|
|
10170
|
+
}
|
|
10171
|
+
}
|
|
10172
|
+
if (flags.m) {
|
|
10173
|
+
if (source[i] === "^") {
|
|
10174
|
+
pattern += `(^|(?<=[\r
|
|
10175
|
+
]))`;
|
|
10176
|
+
continue;
|
|
10177
|
+
} else if (source[i] === "$") {
|
|
10178
|
+
pattern += `($|(?=[\r
|
|
10179
|
+
]))`;
|
|
10180
|
+
continue;
|
|
10181
|
+
}
|
|
10182
|
+
}
|
|
10183
|
+
if (flags.s && source[i] === ".") {
|
|
10184
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
10185
|
+
` : `[${source[i]}\r
|
|
10186
|
+
]`;
|
|
10187
|
+
continue;
|
|
10188
|
+
}
|
|
10189
|
+
pattern += source[i];
|
|
10190
|
+
if (source[i] === "\\") {
|
|
10191
|
+
isEscaped = true;
|
|
10192
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
10193
|
+
inCharGroup = false;
|
|
10194
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
10195
|
+
inCharGroup = true;
|
|
10196
|
+
}
|
|
10197
|
+
}
|
|
10198
|
+
return pattern;
|
|
10199
|
+
}
|
|
10200
|
+
function parseRecordDef2(def, refs) {
|
|
10201
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
10202
|
+
const schema = {
|
|
10203
|
+
type: "object",
|
|
10204
|
+
additionalProperties: (_a20 = parseDef2(def.valueType._def, {
|
|
10205
|
+
...refs,
|
|
10206
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10207
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
10208
|
+
};
|
|
10209
|
+
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10210
|
+
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
10211
|
+
return {
|
|
10212
|
+
...schema,
|
|
10213
|
+
propertyNames: keyType
|
|
10214
|
+
};
|
|
10215
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === v3.ZodFirstPartyTypeKind.ZodEnum) {
|
|
10216
|
+
return {
|
|
10217
|
+
...schema,
|
|
10218
|
+
propertyNames: {
|
|
10219
|
+
enum: def.keyType._def.values
|
|
10220
|
+
}
|
|
10221
|
+
};
|
|
10222
|
+
} 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)) {
|
|
10223
|
+
const { type, ...keyType } = parseBrandedDef2(
|
|
10224
|
+
def.keyType._def,
|
|
10225
|
+
refs
|
|
10226
|
+
);
|
|
10227
|
+
return {
|
|
10228
|
+
...schema,
|
|
10229
|
+
propertyNames: keyType
|
|
10230
|
+
};
|
|
10231
|
+
}
|
|
10232
|
+
return schema;
|
|
10233
|
+
}
|
|
10234
|
+
function parseMapDef2(def, refs) {
|
|
10235
|
+
if (refs.mapStrategy === "record") {
|
|
10236
|
+
return parseRecordDef2(def, refs);
|
|
10237
|
+
}
|
|
10238
|
+
const keys = parseDef2(def.keyType._def, {
|
|
10239
|
+
...refs,
|
|
10240
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
10241
|
+
}) || parseAnyDef2();
|
|
10242
|
+
const values = parseDef2(def.valueType._def, {
|
|
10243
|
+
...refs,
|
|
10244
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
10245
|
+
}) || parseAnyDef2();
|
|
10246
|
+
return {
|
|
10247
|
+
type: "array",
|
|
10248
|
+
maxItems: 125,
|
|
10249
|
+
items: {
|
|
10250
|
+
type: "array",
|
|
10251
|
+
items: [keys, values],
|
|
10252
|
+
minItems: 2,
|
|
10253
|
+
maxItems: 2
|
|
10254
|
+
}
|
|
10255
|
+
};
|
|
10256
|
+
}
|
|
10257
|
+
function parseNativeEnumDef2(def) {
|
|
10258
|
+
const object4 = def.values;
|
|
10259
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
10260
|
+
return typeof object4[object4[key]] !== "number";
|
|
10261
|
+
});
|
|
10262
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
10263
|
+
const parsedTypes = Array.from(
|
|
10264
|
+
new Set(actualValues.map((values) => typeof values))
|
|
10265
|
+
);
|
|
10266
|
+
return {
|
|
10267
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
10268
|
+
enum: actualValues
|
|
10269
|
+
};
|
|
10270
|
+
}
|
|
10271
|
+
function parseNeverDef2() {
|
|
10272
|
+
return { not: parseAnyDef2() };
|
|
10273
|
+
}
|
|
10274
|
+
function parseNullDef2() {
|
|
10275
|
+
return {
|
|
10276
|
+
type: "null"
|
|
10277
|
+
};
|
|
10278
|
+
}
|
|
10279
|
+
var primitiveMappings2 = {
|
|
10280
|
+
ZodString: "string",
|
|
10281
|
+
ZodNumber: "number",
|
|
10282
|
+
ZodBigInt: "integer",
|
|
10283
|
+
ZodBoolean: "boolean",
|
|
10284
|
+
ZodNull: "null"
|
|
10285
|
+
};
|
|
10286
|
+
function parseUnionDef2(def, refs) {
|
|
10287
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10288
|
+
if (options.every(
|
|
10289
|
+
(x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length)
|
|
10290
|
+
)) {
|
|
10291
|
+
const types = options.reduce((types2, x) => {
|
|
10292
|
+
const type = primitiveMappings2[x._def.typeName];
|
|
10293
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
10294
|
+
}, []);
|
|
10295
|
+
return {
|
|
10296
|
+
type: types.length > 1 ? types : types[0]
|
|
10297
|
+
};
|
|
10298
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
10299
|
+
const types = options.reduce(
|
|
10300
|
+
(acc, x) => {
|
|
10301
|
+
const type = typeof x._def.value;
|
|
10302
|
+
switch (type) {
|
|
10303
|
+
case "string":
|
|
10304
|
+
case "number":
|
|
10305
|
+
case "boolean":
|
|
10306
|
+
return [...acc, type];
|
|
10307
|
+
case "bigint":
|
|
10308
|
+
return [...acc, "integer"];
|
|
10309
|
+
case "object":
|
|
10310
|
+
if (x._def.value === null)
|
|
10311
|
+
return [...acc, "null"];
|
|
10312
|
+
case "symbol":
|
|
10313
|
+
case "undefined":
|
|
10314
|
+
case "function":
|
|
10315
|
+
default:
|
|
10316
|
+
return acc;
|
|
10317
|
+
}
|
|
10318
|
+
},
|
|
10319
|
+
[]
|
|
10320
|
+
);
|
|
10321
|
+
if (types.length === options.length) {
|
|
10322
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
10323
|
+
return {
|
|
10324
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
10325
|
+
enum: options.reduce(
|
|
10326
|
+
(acc, x) => {
|
|
10327
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
10328
|
+
},
|
|
10329
|
+
[]
|
|
10330
|
+
)
|
|
10331
|
+
};
|
|
10332
|
+
}
|
|
10333
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
10334
|
+
return {
|
|
10335
|
+
type: "string",
|
|
10336
|
+
enum: options.reduce(
|
|
10337
|
+
(acc, x) => [
|
|
10338
|
+
...acc,
|
|
10339
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
10340
|
+
],
|
|
10341
|
+
[]
|
|
10342
|
+
)
|
|
10343
|
+
};
|
|
10344
|
+
}
|
|
10345
|
+
return asAnyOf2(def, refs);
|
|
10346
|
+
}
|
|
10347
|
+
var asAnyOf2 = (def, refs) => {
|
|
10348
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
|
|
10349
|
+
(x, i) => parseDef2(x._def, {
|
|
10350
|
+
...refs,
|
|
10351
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
10352
|
+
})
|
|
10353
|
+
).filter(
|
|
10354
|
+
(x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
|
|
10355
|
+
);
|
|
10356
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
10357
|
+
};
|
|
10358
|
+
function parseNullableDef2(def, refs) {
|
|
10359
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
10360
|
+
def.innerType._def.typeName
|
|
10361
|
+
) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
10362
|
+
return {
|
|
10363
|
+
type: [
|
|
10364
|
+
primitiveMappings2[def.innerType._def.typeName],
|
|
10365
|
+
"null"
|
|
10366
|
+
]
|
|
10367
|
+
};
|
|
10368
|
+
}
|
|
10369
|
+
const base = parseDef2(def.innerType._def, {
|
|
10370
|
+
...refs,
|
|
10371
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
10372
|
+
});
|
|
10373
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
10374
|
+
}
|
|
10375
|
+
function parseNumberDef2(def) {
|
|
10376
|
+
const res = {
|
|
10377
|
+
type: "number"
|
|
10378
|
+
};
|
|
10379
|
+
if (!def.checks)
|
|
10380
|
+
return res;
|
|
10381
|
+
for (const check of def.checks) {
|
|
10382
|
+
switch (check.kind) {
|
|
10383
|
+
case "int":
|
|
10384
|
+
res.type = "integer";
|
|
10385
|
+
break;
|
|
10386
|
+
case "min":
|
|
10387
|
+
if (check.inclusive) {
|
|
10388
|
+
res.minimum = check.value;
|
|
10389
|
+
} else {
|
|
10390
|
+
res.exclusiveMinimum = check.value;
|
|
10391
|
+
}
|
|
10392
|
+
break;
|
|
10393
|
+
case "max":
|
|
10394
|
+
if (check.inclusive) {
|
|
10395
|
+
res.maximum = check.value;
|
|
10396
|
+
} else {
|
|
10397
|
+
res.exclusiveMaximum = check.value;
|
|
10398
|
+
}
|
|
10399
|
+
break;
|
|
10400
|
+
case "multipleOf":
|
|
10401
|
+
res.multipleOf = check.value;
|
|
10402
|
+
break;
|
|
10403
|
+
}
|
|
10404
|
+
}
|
|
10405
|
+
return res;
|
|
10406
|
+
}
|
|
10407
|
+
function parseObjectDef2(def, refs) {
|
|
10408
|
+
const result = {
|
|
10409
|
+
type: "object",
|
|
10410
|
+
properties: {}
|
|
10411
|
+
};
|
|
10412
|
+
const required = [];
|
|
10413
|
+
const shape = def.shape();
|
|
10414
|
+
for (const propName in shape) {
|
|
10415
|
+
let propDef = shape[propName];
|
|
10416
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
10417
|
+
continue;
|
|
10418
|
+
}
|
|
10419
|
+
const propOptional = safeIsOptional2(propDef);
|
|
10420
|
+
const parsedDef = parseDef2(propDef._def, {
|
|
10421
|
+
...refs,
|
|
10422
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
10423
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
10424
|
+
});
|
|
10425
|
+
if (parsedDef === void 0) {
|
|
10426
|
+
continue;
|
|
10427
|
+
}
|
|
10428
|
+
result.properties[propName] = parsedDef;
|
|
10429
|
+
if (!propOptional) {
|
|
10430
|
+
required.push(propName);
|
|
10431
|
+
}
|
|
10432
|
+
}
|
|
10433
|
+
if (required.length) {
|
|
10434
|
+
result.required = required;
|
|
10435
|
+
}
|
|
10436
|
+
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
10437
|
+
if (additionalProperties !== void 0) {
|
|
10438
|
+
result.additionalProperties = additionalProperties;
|
|
10439
|
+
}
|
|
10440
|
+
return result;
|
|
10441
|
+
}
|
|
10442
|
+
function decideAdditionalProperties2(def, refs) {
|
|
10443
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
10444
|
+
return parseDef2(def.catchall._def, {
|
|
10445
|
+
...refs,
|
|
10446
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10447
|
+
});
|
|
10448
|
+
}
|
|
10449
|
+
switch (def.unknownKeys) {
|
|
10450
|
+
case "passthrough":
|
|
10451
|
+
return refs.allowedAdditionalProperties;
|
|
10452
|
+
case "strict":
|
|
10453
|
+
return refs.rejectedAdditionalProperties;
|
|
10454
|
+
case "strip":
|
|
10455
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
10456
|
+
}
|
|
10457
|
+
}
|
|
10458
|
+
function safeIsOptional2(schema) {
|
|
10459
|
+
try {
|
|
10460
|
+
return schema.isOptional();
|
|
10461
|
+
} catch (e2) {
|
|
10462
|
+
return true;
|
|
10463
|
+
}
|
|
10464
|
+
}
|
|
10465
|
+
var parseOptionalDef2 = (def, refs) => {
|
|
10466
|
+
var _a20;
|
|
10467
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
10468
|
+
return parseDef2(def.innerType._def, refs);
|
|
10469
|
+
}
|
|
10470
|
+
const innerSchema = parseDef2(def.innerType._def, {
|
|
10471
|
+
...refs,
|
|
10472
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
10473
|
+
});
|
|
10474
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
10475
|
+
};
|
|
10476
|
+
var parsePipelineDef2 = (def, refs) => {
|
|
10477
|
+
if (refs.pipeStrategy === "input") {
|
|
10478
|
+
return parseDef2(def.in._def, refs);
|
|
10479
|
+
} else if (refs.pipeStrategy === "output") {
|
|
10480
|
+
return parseDef2(def.out._def, refs);
|
|
10481
|
+
}
|
|
10482
|
+
const a = parseDef2(def.in._def, {
|
|
10483
|
+
...refs,
|
|
10484
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
10485
|
+
});
|
|
10486
|
+
const b = parseDef2(def.out._def, {
|
|
10487
|
+
...refs,
|
|
10488
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
10489
|
+
});
|
|
10490
|
+
return {
|
|
10491
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
10492
|
+
};
|
|
10493
|
+
};
|
|
10494
|
+
function parsePromiseDef2(def, refs) {
|
|
10495
|
+
return parseDef2(def.type._def, refs);
|
|
10496
|
+
}
|
|
10497
|
+
function parseSetDef2(def, refs) {
|
|
10498
|
+
const items = parseDef2(def.valueType._def, {
|
|
10499
|
+
...refs,
|
|
10500
|
+
currentPath: [...refs.currentPath, "items"]
|
|
10501
|
+
});
|
|
10502
|
+
const schema = {
|
|
10503
|
+
type: "array",
|
|
10504
|
+
uniqueItems: true,
|
|
10505
|
+
items
|
|
10506
|
+
};
|
|
10507
|
+
if (def.minSize) {
|
|
10508
|
+
schema.minItems = def.minSize.value;
|
|
10509
|
+
}
|
|
10510
|
+
if (def.maxSize) {
|
|
10511
|
+
schema.maxItems = def.maxSize.value;
|
|
10512
|
+
}
|
|
10513
|
+
return schema;
|
|
10514
|
+
}
|
|
10515
|
+
function parseTupleDef2(def, refs) {
|
|
10516
|
+
if (def.rest) {
|
|
10517
|
+
return {
|
|
10518
|
+
type: "array",
|
|
10519
|
+
minItems: def.items.length,
|
|
10520
|
+
items: def.items.map(
|
|
10521
|
+
(x, i) => parseDef2(x._def, {
|
|
10522
|
+
...refs,
|
|
10523
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10524
|
+
})
|
|
10525
|
+
).reduce(
|
|
10526
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10527
|
+
[]
|
|
10528
|
+
),
|
|
10529
|
+
additionalItems: parseDef2(def.rest._def, {
|
|
10530
|
+
...refs,
|
|
10531
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
10532
|
+
})
|
|
10533
|
+
};
|
|
10534
|
+
} else {
|
|
10535
|
+
return {
|
|
10536
|
+
type: "array",
|
|
10537
|
+
minItems: def.items.length,
|
|
10538
|
+
maxItems: def.items.length,
|
|
10539
|
+
items: def.items.map(
|
|
10540
|
+
(x, i) => parseDef2(x._def, {
|
|
10541
|
+
...refs,
|
|
10542
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10543
|
+
})
|
|
10544
|
+
).reduce(
|
|
10545
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10546
|
+
[]
|
|
10547
|
+
)
|
|
10548
|
+
};
|
|
10549
|
+
}
|
|
10550
|
+
}
|
|
10551
|
+
function parseUndefinedDef2() {
|
|
10552
|
+
return {
|
|
10553
|
+
not: parseAnyDef2()
|
|
10554
|
+
};
|
|
10555
|
+
}
|
|
10556
|
+
function parseUnknownDef2() {
|
|
10557
|
+
return parseAnyDef2();
|
|
10558
|
+
}
|
|
10559
|
+
var parseReadonlyDef2 = (def, refs) => {
|
|
10560
|
+
return parseDef2(def.innerType._def, refs);
|
|
10561
|
+
};
|
|
10562
|
+
var selectParser2 = (def, typeName, refs) => {
|
|
10563
|
+
switch (typeName) {
|
|
10564
|
+
case v3.ZodFirstPartyTypeKind.ZodString:
|
|
10565
|
+
return parseStringDef2(def, refs);
|
|
10566
|
+
case v3.ZodFirstPartyTypeKind.ZodNumber:
|
|
10567
|
+
return parseNumberDef2(def);
|
|
10568
|
+
case v3.ZodFirstPartyTypeKind.ZodObject:
|
|
10569
|
+
return parseObjectDef2(def, refs);
|
|
10570
|
+
case v3.ZodFirstPartyTypeKind.ZodBigInt:
|
|
10571
|
+
return parseBigintDef2(def);
|
|
10572
|
+
case v3.ZodFirstPartyTypeKind.ZodBoolean:
|
|
10573
|
+
return parseBooleanDef2();
|
|
10574
|
+
case v3.ZodFirstPartyTypeKind.ZodDate:
|
|
10575
|
+
return parseDateDef2(def, refs);
|
|
10576
|
+
case v3.ZodFirstPartyTypeKind.ZodUndefined:
|
|
10577
|
+
return parseUndefinedDef2();
|
|
10578
|
+
case v3.ZodFirstPartyTypeKind.ZodNull:
|
|
10579
|
+
return parseNullDef2();
|
|
10580
|
+
case v3.ZodFirstPartyTypeKind.ZodArray:
|
|
10581
|
+
return parseArrayDef2(def, refs);
|
|
10582
|
+
case v3.ZodFirstPartyTypeKind.ZodUnion:
|
|
10583
|
+
case v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
10584
|
+
return parseUnionDef2(def, refs);
|
|
10585
|
+
case v3.ZodFirstPartyTypeKind.ZodIntersection:
|
|
10586
|
+
return parseIntersectionDef2(def, refs);
|
|
10587
|
+
case v3.ZodFirstPartyTypeKind.ZodTuple:
|
|
10588
|
+
return parseTupleDef2(def, refs);
|
|
10589
|
+
case v3.ZodFirstPartyTypeKind.ZodRecord:
|
|
10590
|
+
return parseRecordDef2(def, refs);
|
|
10591
|
+
case v3.ZodFirstPartyTypeKind.ZodLiteral:
|
|
10592
|
+
return parseLiteralDef2(def);
|
|
10593
|
+
case v3.ZodFirstPartyTypeKind.ZodEnum:
|
|
10594
|
+
return parseEnumDef2(def);
|
|
10595
|
+
case v3.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
10596
|
+
return parseNativeEnumDef2(def);
|
|
10597
|
+
case v3.ZodFirstPartyTypeKind.ZodNullable:
|
|
10598
|
+
return parseNullableDef2(def, refs);
|
|
10599
|
+
case v3.ZodFirstPartyTypeKind.ZodOptional:
|
|
10600
|
+
return parseOptionalDef2(def, refs);
|
|
10601
|
+
case v3.ZodFirstPartyTypeKind.ZodMap:
|
|
10602
|
+
return parseMapDef2(def, refs);
|
|
10603
|
+
case v3.ZodFirstPartyTypeKind.ZodSet:
|
|
10604
|
+
return parseSetDef2(def, refs);
|
|
10605
|
+
case v3.ZodFirstPartyTypeKind.ZodLazy:
|
|
10606
|
+
return () => def.getter()._def;
|
|
10607
|
+
case v3.ZodFirstPartyTypeKind.ZodPromise:
|
|
10608
|
+
return parsePromiseDef2(def, refs);
|
|
10609
|
+
case v3.ZodFirstPartyTypeKind.ZodNaN:
|
|
10610
|
+
case v3.ZodFirstPartyTypeKind.ZodNever:
|
|
10611
|
+
return parseNeverDef2();
|
|
10612
|
+
case v3.ZodFirstPartyTypeKind.ZodEffects:
|
|
10613
|
+
return parseEffectsDef2(def, refs);
|
|
10614
|
+
case v3.ZodFirstPartyTypeKind.ZodAny:
|
|
10615
|
+
return parseAnyDef2();
|
|
10616
|
+
case v3.ZodFirstPartyTypeKind.ZodUnknown:
|
|
10617
|
+
return parseUnknownDef2();
|
|
10618
|
+
case v3.ZodFirstPartyTypeKind.ZodDefault:
|
|
10619
|
+
return parseDefaultDef2(def, refs);
|
|
10620
|
+
case v3.ZodFirstPartyTypeKind.ZodBranded:
|
|
10621
|
+
return parseBrandedDef2(def, refs);
|
|
10622
|
+
case v3.ZodFirstPartyTypeKind.ZodReadonly:
|
|
10623
|
+
return parseReadonlyDef2(def, refs);
|
|
10624
|
+
case v3.ZodFirstPartyTypeKind.ZodCatch:
|
|
10625
|
+
return parseCatchDef2(def, refs);
|
|
10626
|
+
case v3.ZodFirstPartyTypeKind.ZodPipeline:
|
|
10627
|
+
return parsePipelineDef2(def, refs);
|
|
10628
|
+
case v3.ZodFirstPartyTypeKind.ZodFunction:
|
|
10629
|
+
case v3.ZodFirstPartyTypeKind.ZodVoid:
|
|
10630
|
+
case v3.ZodFirstPartyTypeKind.ZodSymbol:
|
|
10631
|
+
return void 0;
|
|
10632
|
+
default:
|
|
10633
|
+
return /* @__PURE__ */ ((_) => void 0)();
|
|
10634
|
+
}
|
|
10635
|
+
};
|
|
10636
|
+
function parseDef2(def, refs, forceResolution = false) {
|
|
10637
|
+
var _a20;
|
|
10638
|
+
const seenItem = refs.seen.get(def);
|
|
10639
|
+
if (refs.override) {
|
|
10640
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
10641
|
+
refs,
|
|
10642
|
+
def,
|
|
10643
|
+
refs,
|
|
10644
|
+
seenItem,
|
|
10645
|
+
forceResolution
|
|
10646
|
+
);
|
|
10647
|
+
if (overrideResult !== ignoreOverride2) {
|
|
10648
|
+
return overrideResult;
|
|
10649
|
+
}
|
|
10650
|
+
}
|
|
10651
|
+
if (seenItem && !forceResolution) {
|
|
10652
|
+
const seenSchema = get$ref2(seenItem, refs);
|
|
10653
|
+
if (seenSchema !== void 0) {
|
|
10654
|
+
return seenSchema;
|
|
10655
|
+
}
|
|
10656
|
+
}
|
|
10657
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
10658
|
+
refs.seen.set(def, newItem);
|
|
10659
|
+
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
10660
|
+
const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10661
|
+
if (jsonSchema22) {
|
|
10662
|
+
addMeta2(def, refs, jsonSchema22);
|
|
10663
|
+
}
|
|
10664
|
+
if (refs.postProcess) {
|
|
10665
|
+
const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
|
|
10666
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10667
|
+
return postProcessResult;
|
|
10668
|
+
}
|
|
10669
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10670
|
+
return jsonSchema22;
|
|
10671
|
+
}
|
|
10672
|
+
var get$ref2 = (item, refs) => {
|
|
10673
|
+
switch (refs.$refStrategy) {
|
|
10674
|
+
case "root":
|
|
10675
|
+
return { $ref: item.path.join("/") };
|
|
10676
|
+
case "relative":
|
|
10677
|
+
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
10678
|
+
case "none":
|
|
10679
|
+
case "seen": {
|
|
10680
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
10681
|
+
console.warn(
|
|
10682
|
+
`Recursive reference detected at ${refs.currentPath.join(
|
|
10683
|
+
"/"
|
|
10684
|
+
)}! Defaulting to any`
|
|
10685
|
+
);
|
|
10686
|
+
return parseAnyDef2();
|
|
10687
|
+
}
|
|
10688
|
+
return refs.$refStrategy === "seen" ? parseAnyDef2() : void 0;
|
|
10689
|
+
}
|
|
10690
|
+
}
|
|
10691
|
+
};
|
|
10692
|
+
var addMeta2 = (def, refs, jsonSchema22) => {
|
|
10693
|
+
if (def.description) {
|
|
10694
|
+
jsonSchema22.description = def.description;
|
|
10695
|
+
}
|
|
10696
|
+
return jsonSchema22;
|
|
10697
|
+
};
|
|
10698
|
+
var getRefs2 = (options) => {
|
|
10699
|
+
const _options = getDefaultOptions2(options);
|
|
10700
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
10701
|
+
return {
|
|
10702
|
+
..._options,
|
|
10703
|
+
currentPath,
|
|
10704
|
+
propertyPath: void 0,
|
|
10705
|
+
seen: new Map(
|
|
10706
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
10707
|
+
def._def,
|
|
10708
|
+
{
|
|
10709
|
+
def: def._def,
|
|
10710
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
10711
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
10712
|
+
jsonSchema: void 0
|
|
10713
|
+
}
|
|
10714
|
+
])
|
|
10715
|
+
)
|
|
10716
|
+
};
|
|
10717
|
+
};
|
|
10718
|
+
var zodToJsonSchema3 = (schema, options) => {
|
|
10719
|
+
var _a20;
|
|
10720
|
+
const refs = getRefs2(options);
|
|
10721
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
10722
|
+
(acc, [name25, schema2]) => {
|
|
10723
|
+
var _a25;
|
|
10724
|
+
return {
|
|
10725
|
+
...acc,
|
|
10726
|
+
[name25]: (_a25 = parseDef2(
|
|
10727
|
+
schema2._def,
|
|
10728
|
+
{
|
|
10729
|
+
...refs,
|
|
10730
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
10731
|
+
},
|
|
10732
|
+
true
|
|
10733
|
+
)) != null ? _a25 : parseAnyDef2()
|
|
10734
|
+
};
|
|
10735
|
+
},
|
|
10736
|
+
{}
|
|
10737
|
+
) : void 0;
|
|
10738
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
10739
|
+
const main = (_a20 = parseDef2(
|
|
10740
|
+
schema._def,
|
|
10741
|
+
name20 === void 0 ? refs : {
|
|
10742
|
+
...refs,
|
|
10743
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
10744
|
+
},
|
|
10745
|
+
false
|
|
10746
|
+
)) != null ? _a20 : parseAnyDef2();
|
|
10747
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10748
|
+
if (title !== void 0) {
|
|
10749
|
+
main.title = title;
|
|
10750
|
+
}
|
|
10751
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
10752
|
+
...main,
|
|
10753
|
+
[refs.definitionPath]: definitions
|
|
10754
|
+
} : main : {
|
|
10755
|
+
$ref: [
|
|
10756
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10757
|
+
refs.definitionPath,
|
|
10758
|
+
name20
|
|
10759
|
+
].join("/"),
|
|
10760
|
+
[refs.definitionPath]: {
|
|
10761
|
+
...definitions,
|
|
10762
|
+
[name20]: main
|
|
10763
|
+
}
|
|
10764
|
+
};
|
|
10765
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10766
|
+
return combined;
|
|
10767
|
+
};
|
|
10768
|
+
var zod_to_json_schema_default2 = zodToJsonSchema3;
|
|
10769
|
+
function zod3Schema2(zodSchema22, options) {
|
|
10770
|
+
var _a20;
|
|
10771
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10772
|
+
return jsonSchema3(
|
|
10773
|
+
zod_to_json_schema_default2(zodSchema22, {
|
|
10774
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
10775
|
+
}),
|
|
10776
|
+
{
|
|
10777
|
+
validate: async (value) => {
|
|
10778
|
+
const result = await zodSchema22.safeParseAsync(value);
|
|
10779
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10780
|
+
}
|
|
10781
|
+
}
|
|
10782
|
+
);
|
|
10783
|
+
}
|
|
10784
|
+
function zod4Schema2(zodSchema22, options) {
|
|
10785
|
+
var _a20;
|
|
10786
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10787
|
+
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
10788
|
+
target: "draft-7",
|
|
10789
|
+
io: "output",
|
|
10790
|
+
reused: useReferences ? "ref" : "inline"
|
|
10791
|
+
});
|
|
10792
|
+
return jsonSchema3(z4JSONSchema, {
|
|
10793
|
+
validate: async (value) => {
|
|
10794
|
+
const result = await z42__namespace.safeParseAsync(zodSchema22, value);
|
|
10795
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10796
|
+
}
|
|
10797
|
+
});
|
|
10798
|
+
}
|
|
10799
|
+
function isZod4Schema2(zodSchema22) {
|
|
10800
|
+
return "_zod" in zodSchema22;
|
|
10801
|
+
}
|
|
10802
|
+
function zodSchema3(zodSchema22, options) {
|
|
10803
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
10804
|
+
return zod4Schema2(zodSchema22);
|
|
10805
|
+
} else {
|
|
10806
|
+
return zod3Schema2(zodSchema22);
|
|
10807
|
+
}
|
|
10808
|
+
}
|
|
10809
|
+
var schemaSymbol3 = Symbol.for("vercel.ai.schema");
|
|
10810
|
+
function jsonSchema3(jsonSchema22, {
|
|
10811
|
+
validate
|
|
10812
|
+
} = {}) {
|
|
10813
|
+
return {
|
|
10814
|
+
[schemaSymbol3]: true,
|
|
10815
|
+
_type: void 0,
|
|
10816
|
+
// should never be used directly
|
|
10817
|
+
[validatorSymbol3]: true,
|
|
10818
|
+
jsonSchema: jsonSchema22,
|
|
10819
|
+
validate
|
|
10820
|
+
};
|
|
10821
|
+
}
|
|
10822
|
+
function isSchema3(value) {
|
|
10823
|
+
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
10824
|
+
}
|
|
10825
|
+
function asSchema3(schema) {
|
|
10826
|
+
return schema == null ? jsonSchema3({
|
|
10827
|
+
properties: {},
|
|
10828
|
+
additionalProperties: false
|
|
10829
|
+
}) : isSchema3(schema) ? schema : zodSchema3(schema);
|
|
10830
|
+
}
|
|
10831
|
+
var __defProp4 = Object.defineProperty;
|
|
10832
|
+
var __export4 = (target, all) => {
|
|
10833
|
+
for (var name172 in all)
|
|
10834
|
+
__defProp4(target, name172, { get: all[name172], enumerable: true });
|
|
10835
|
+
};
|
|
10836
|
+
var name73 = "AI_NoObjectGeneratedError";
|
|
10837
|
+
var marker74 = `vercel.ai.error.${name73}`;
|
|
10838
|
+
var symbol74 = Symbol.for(marker74);
|
|
10839
|
+
var _a74;
|
|
10840
|
+
var NoObjectGeneratedError3 = class extends chunkHVBBFCDH_cjs.AISDKError {
|
|
10841
|
+
constructor({
|
|
10842
|
+
message = "No object generated.",
|
|
10843
|
+
cause,
|
|
10844
|
+
text: text22,
|
|
10845
|
+
response,
|
|
10846
|
+
usage,
|
|
10847
|
+
finishReason
|
|
10848
|
+
}) {
|
|
10849
|
+
super({ name: name73, message, cause });
|
|
10850
|
+
this[_a74] = true;
|
|
10851
|
+
this.text = text22;
|
|
10852
|
+
this.response = response;
|
|
10853
|
+
this.usage = usage;
|
|
10854
|
+
this.finishReason = finishReason;
|
|
10855
|
+
}
|
|
10856
|
+
static isInstance(error) {
|
|
10857
|
+
return chunkHVBBFCDH_cjs.AISDKError.hasMarker(error, marker74);
|
|
10858
|
+
}
|
|
10859
|
+
};
|
|
10860
|
+
_a74 = symbol74;
|
|
10861
|
+
var dataContentSchema3 = z42.z.union([
|
|
10862
|
+
z42.z.string(),
|
|
10863
|
+
z42.z.instanceof(Uint8Array),
|
|
10864
|
+
z42.z.instanceof(ArrayBuffer),
|
|
10865
|
+
z42.z.custom(
|
|
10866
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
10867
|
+
(value) => {
|
|
10868
|
+
var _a172, _b8;
|
|
10869
|
+
return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
|
|
10870
|
+
},
|
|
10871
|
+
{ message: "Must be a Buffer" }
|
|
10872
|
+
)
|
|
10873
|
+
]);
|
|
10874
|
+
var jsonValueSchema3 = z42.z.lazy(
|
|
10875
|
+
() => z42.z.union([
|
|
10876
|
+
z42.z.null(),
|
|
10877
|
+
z42.z.string(),
|
|
10878
|
+
z42.z.number(),
|
|
10879
|
+
z42.z.boolean(),
|
|
10880
|
+
z42.z.record(z42.z.string(), jsonValueSchema3),
|
|
10881
|
+
z42.z.array(jsonValueSchema3)
|
|
10882
|
+
])
|
|
10883
|
+
);
|
|
10884
|
+
var providerMetadataSchema3 = z42.z.record(
|
|
10885
|
+
z42.z.string(),
|
|
10886
|
+
z42.z.record(z42.z.string(), jsonValueSchema3)
|
|
10887
|
+
);
|
|
10888
|
+
var textPartSchema3 = z42.z.object({
|
|
10889
|
+
type: z42.z.literal("text"),
|
|
10890
|
+
text: z42.z.string(),
|
|
10891
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10892
|
+
});
|
|
10893
|
+
var imagePartSchema3 = z42.z.object({
|
|
10894
|
+
type: z42.z.literal("image"),
|
|
10895
|
+
image: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10896
|
+
mediaType: z42.z.string().optional(),
|
|
10897
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10898
|
+
});
|
|
10899
|
+
var filePartSchema3 = z42.z.object({
|
|
10900
|
+
type: z42.z.literal("file"),
|
|
10901
|
+
data: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10902
|
+
filename: z42.z.string().optional(),
|
|
10903
|
+
mediaType: z42.z.string(),
|
|
10904
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10905
|
+
});
|
|
10906
|
+
var reasoningPartSchema3 = z42.z.object({
|
|
10907
|
+
type: z42.z.literal("reasoning"),
|
|
10908
|
+
text: z42.z.string(),
|
|
10909
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10910
|
+
});
|
|
10911
|
+
var toolCallPartSchema3 = z42.z.object({
|
|
10912
|
+
type: z42.z.literal("tool-call"),
|
|
10913
|
+
toolCallId: z42.z.string(),
|
|
10914
|
+
toolName: z42.z.string(),
|
|
10915
|
+
input: z42.z.unknown(),
|
|
10916
|
+
providerOptions: providerMetadataSchema3.optional(),
|
|
10917
|
+
providerExecuted: z42.z.boolean().optional()
|
|
10918
|
+
});
|
|
10919
|
+
var outputSchema2 = z42.z.discriminatedUnion("type", [
|
|
10920
|
+
z42.z.object({
|
|
10921
|
+
type: z42.z.literal("text"),
|
|
10922
|
+
value: z42.z.string()
|
|
10923
|
+
}),
|
|
10924
|
+
z42.z.object({
|
|
10925
|
+
type: z42.z.literal("json"),
|
|
10926
|
+
value: jsonValueSchema3
|
|
10927
|
+
}),
|
|
10928
|
+
z42.z.object({
|
|
10929
|
+
type: z42.z.literal("error-text"),
|
|
10930
|
+
value: z42.z.string()
|
|
10931
|
+
}),
|
|
10932
|
+
z42.z.object({
|
|
10933
|
+
type: z42.z.literal("error-json"),
|
|
10934
|
+
value: jsonValueSchema3
|
|
10935
|
+
}),
|
|
10936
|
+
z42.z.object({
|
|
10937
|
+
type: z42.z.literal("content"),
|
|
10938
|
+
value: z42.z.array(
|
|
10939
|
+
z42.z.union([
|
|
10940
|
+
z42.z.object({
|
|
10941
|
+
type: z42.z.literal("text"),
|
|
10942
|
+
text: z42.z.string()
|
|
10943
|
+
}),
|
|
10944
|
+
z42.z.object({
|
|
10945
|
+
type: z42.z.literal("media"),
|
|
10946
|
+
data: z42.z.string(),
|
|
10947
|
+
mediaType: z42.z.string()
|
|
10948
|
+
})
|
|
10949
|
+
])
|
|
10950
|
+
)
|
|
10951
|
+
})
|
|
10952
|
+
]);
|
|
10953
|
+
var toolResultPartSchema3 = z42.z.object({
|
|
10954
|
+
type: z42.z.literal("tool-result"),
|
|
10955
|
+
toolCallId: z42.z.string(),
|
|
10956
|
+
toolName: z42.z.string(),
|
|
10957
|
+
output: outputSchema2,
|
|
10958
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10959
|
+
});
|
|
10960
|
+
var systemModelMessageSchema2 = z42.z.object(
|
|
10961
|
+
{
|
|
10962
|
+
role: z42.z.literal("system"),
|
|
10963
|
+
content: z42.z.string(),
|
|
10964
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10965
|
+
}
|
|
10966
|
+
);
|
|
10967
|
+
var userModelMessageSchema2 = z42.z.object({
|
|
10968
|
+
role: z42.z.literal("user"),
|
|
10969
|
+
content: z42.z.union([
|
|
10970
|
+
z42.z.string(),
|
|
10971
|
+
z42.z.array(z42.z.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
|
|
10972
|
+
]),
|
|
10973
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10974
|
+
});
|
|
10975
|
+
var assistantModelMessageSchema2 = z42.z.object({
|
|
10976
|
+
role: z42.z.literal("assistant"),
|
|
10977
|
+
content: z42.z.union([
|
|
10978
|
+
z42.z.string(),
|
|
10979
|
+
z42.z.array(
|
|
10980
|
+
z42.z.union([
|
|
10981
|
+
textPartSchema3,
|
|
10982
|
+
filePartSchema3,
|
|
10983
|
+
reasoningPartSchema3,
|
|
10984
|
+
toolCallPartSchema3,
|
|
10985
|
+
toolResultPartSchema3
|
|
10986
|
+
])
|
|
10987
|
+
)
|
|
10988
|
+
]),
|
|
10989
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10990
|
+
});
|
|
10991
|
+
var toolModelMessageSchema2 = z42.z.object({
|
|
10992
|
+
role: z42.z.literal("tool"),
|
|
10993
|
+
content: z42.z.array(toolResultPartSchema3),
|
|
10994
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10995
|
+
});
|
|
10996
|
+
z42.z.union([
|
|
10997
|
+
systemModelMessageSchema2,
|
|
10998
|
+
userModelMessageSchema2,
|
|
10999
|
+
assistantModelMessageSchema2,
|
|
11000
|
+
toolModelMessageSchema2
|
|
11001
|
+
]);
|
|
11002
|
+
function stepCountIs(stepCount) {
|
|
11003
|
+
return ({ steps }) => steps.length === stepCount;
|
|
11004
|
+
}
|
|
11005
|
+
createIdGenerator3({
|
|
11006
|
+
prefix: "aitxt",
|
|
11007
|
+
size: 24
|
|
11008
|
+
});
|
|
11009
|
+
z42.z.union([
|
|
11010
|
+
z42.z.strictObject({
|
|
11011
|
+
type: z42.z.literal("text-start"),
|
|
11012
|
+
id: z42.z.string(),
|
|
11013
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11014
|
+
}),
|
|
11015
|
+
z42.z.strictObject({
|
|
11016
|
+
type: z42.z.literal("text-delta"),
|
|
11017
|
+
id: z42.z.string(),
|
|
11018
|
+
delta: z42.z.string(),
|
|
11019
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11020
|
+
}),
|
|
11021
|
+
z42.z.strictObject({
|
|
11022
|
+
type: z42.z.literal("text-end"),
|
|
11023
|
+
id: z42.z.string(),
|
|
11024
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11025
|
+
}),
|
|
11026
|
+
z42.z.strictObject({
|
|
11027
|
+
type: z42.z.literal("error"),
|
|
11028
|
+
errorText: z42.z.string()
|
|
11029
|
+
}),
|
|
11030
|
+
z42.z.strictObject({
|
|
11031
|
+
type: z42.z.literal("tool-input-start"),
|
|
11032
|
+
toolCallId: z42.z.string(),
|
|
11033
|
+
toolName: z42.z.string(),
|
|
11034
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11035
|
+
dynamic: z42.z.boolean().optional()
|
|
11036
|
+
}),
|
|
11037
|
+
z42.z.strictObject({
|
|
11038
|
+
type: z42.z.literal("tool-input-delta"),
|
|
11039
|
+
toolCallId: z42.z.string(),
|
|
11040
|
+
inputTextDelta: z42.z.string()
|
|
11041
|
+
}),
|
|
11042
|
+
z42.z.strictObject({
|
|
11043
|
+
type: z42.z.literal("tool-input-available"),
|
|
11044
|
+
toolCallId: z42.z.string(),
|
|
11045
|
+
toolName: z42.z.string(),
|
|
11046
|
+
input: z42.z.unknown(),
|
|
11047
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11048
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11049
|
+
dynamic: z42.z.boolean().optional()
|
|
11050
|
+
}),
|
|
11051
|
+
z42.z.strictObject({
|
|
11052
|
+
type: z42.z.literal("tool-input-error"),
|
|
11053
|
+
toolCallId: z42.z.string(),
|
|
11054
|
+
toolName: z42.z.string(),
|
|
11055
|
+
input: z42.z.unknown(),
|
|
11056
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11057
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11058
|
+
dynamic: z42.z.boolean().optional(),
|
|
11059
|
+
errorText: z42.z.string()
|
|
11060
|
+
}),
|
|
11061
|
+
z42.z.strictObject({
|
|
11062
|
+
type: z42.z.literal("tool-output-available"),
|
|
11063
|
+
toolCallId: z42.z.string(),
|
|
11064
|
+
output: z42.z.unknown(),
|
|
11065
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11066
|
+
dynamic: z42.z.boolean().optional(),
|
|
11067
|
+
preliminary: z42.z.boolean().optional()
|
|
11068
|
+
}),
|
|
11069
|
+
z42.z.strictObject({
|
|
11070
|
+
type: z42.z.literal("tool-output-error"),
|
|
11071
|
+
toolCallId: z42.z.string(),
|
|
11072
|
+
errorText: z42.z.string(),
|
|
11073
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11074
|
+
dynamic: z42.z.boolean().optional()
|
|
11075
|
+
}),
|
|
11076
|
+
z42.z.strictObject({
|
|
11077
|
+
type: z42.z.literal("reasoning-start"),
|
|
11078
|
+
id: z42.z.string(),
|
|
11079
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11080
|
+
}),
|
|
11081
|
+
z42.z.strictObject({
|
|
11082
|
+
type: z42.z.literal("reasoning-delta"),
|
|
11083
|
+
id: z42.z.string(),
|
|
11084
|
+
delta: z42.z.string(),
|
|
11085
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11086
|
+
}),
|
|
11087
|
+
z42.z.strictObject({
|
|
11088
|
+
type: z42.z.literal("reasoning-end"),
|
|
11089
|
+
id: z42.z.string(),
|
|
11090
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11091
|
+
}),
|
|
11092
|
+
z42.z.strictObject({
|
|
11093
|
+
type: z42.z.literal("source-url"),
|
|
11094
|
+
sourceId: z42.z.string(),
|
|
11095
|
+
url: z42.z.string(),
|
|
11096
|
+
title: z42.z.string().optional(),
|
|
11097
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11098
|
+
}),
|
|
11099
|
+
z42.z.strictObject({
|
|
11100
|
+
type: z42.z.literal("source-document"),
|
|
11101
|
+
sourceId: z42.z.string(),
|
|
11102
|
+
mediaType: z42.z.string(),
|
|
11103
|
+
title: z42.z.string(),
|
|
11104
|
+
filename: z42.z.string().optional(),
|
|
11105
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11106
|
+
}),
|
|
11107
|
+
z42.z.strictObject({
|
|
11108
|
+
type: z42.z.literal("file"),
|
|
11109
|
+
url: z42.z.string(),
|
|
11110
|
+
mediaType: z42.z.string(),
|
|
11111
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11112
|
+
}),
|
|
11113
|
+
z42.z.strictObject({
|
|
11114
|
+
type: z42.z.custom(
|
|
11115
|
+
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
11116
|
+
{ message: 'Type must start with "data-"' }
|
|
11117
|
+
),
|
|
11118
|
+
id: z42.z.string().optional(),
|
|
11119
|
+
data: z42.z.unknown(),
|
|
11120
|
+
transient: z42.z.boolean().optional()
|
|
11121
|
+
}),
|
|
11122
|
+
z42.z.strictObject({
|
|
11123
|
+
type: z42.z.literal("start-step")
|
|
11124
|
+
}),
|
|
11125
|
+
z42.z.strictObject({
|
|
11126
|
+
type: z42.z.literal("finish-step")
|
|
11127
|
+
}),
|
|
11128
|
+
z42.z.strictObject({
|
|
11129
|
+
type: z42.z.literal("start"),
|
|
11130
|
+
messageId: z42.z.string().optional(),
|
|
11131
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11132
|
+
}),
|
|
11133
|
+
z42.z.strictObject({
|
|
11134
|
+
type: z42.z.literal("finish"),
|
|
11135
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11136
|
+
}),
|
|
11137
|
+
z42.z.strictObject({
|
|
11138
|
+
type: z42.z.literal("abort")
|
|
11139
|
+
}),
|
|
11140
|
+
z42.z.strictObject({
|
|
11141
|
+
type: z42.z.literal("message-metadata"),
|
|
11142
|
+
messageMetadata: z42.z.unknown()
|
|
11143
|
+
})
|
|
11144
|
+
]);
|
|
11145
|
+
function fixJson3(input) {
|
|
11146
|
+
const stack = ["ROOT"];
|
|
11147
|
+
let lastValidIndex = -1;
|
|
11148
|
+
let literalStart = null;
|
|
11149
|
+
function processValueStart(char, i, swapState) {
|
|
11150
|
+
{
|
|
11151
|
+
switch (char) {
|
|
11152
|
+
case '"': {
|
|
11153
|
+
lastValidIndex = i;
|
|
11154
|
+
stack.pop();
|
|
11155
|
+
stack.push(swapState);
|
|
11156
|
+
stack.push("INSIDE_STRING");
|
|
11157
|
+
break;
|
|
11158
|
+
}
|
|
11159
|
+
case "f":
|
|
11160
|
+
case "t":
|
|
11161
|
+
case "n": {
|
|
11162
|
+
lastValidIndex = i;
|
|
11163
|
+
literalStart = i;
|
|
11164
|
+
stack.pop();
|
|
11165
|
+
stack.push(swapState);
|
|
11166
|
+
stack.push("INSIDE_LITERAL");
|
|
11167
|
+
break;
|
|
11168
|
+
}
|
|
11169
|
+
case "-": {
|
|
11170
|
+
stack.pop();
|
|
11171
|
+
stack.push(swapState);
|
|
11172
|
+
stack.push("INSIDE_NUMBER");
|
|
11173
|
+
break;
|
|
11174
|
+
}
|
|
11175
|
+
case "0":
|
|
11176
|
+
case "1":
|
|
11177
|
+
case "2":
|
|
11178
|
+
case "3":
|
|
11179
|
+
case "4":
|
|
11180
|
+
case "5":
|
|
11181
|
+
case "6":
|
|
11182
|
+
case "7":
|
|
11183
|
+
case "8":
|
|
11184
|
+
case "9": {
|
|
11185
|
+
lastValidIndex = i;
|
|
11186
|
+
stack.pop();
|
|
11187
|
+
stack.push(swapState);
|
|
11188
|
+
stack.push("INSIDE_NUMBER");
|
|
11189
|
+
break;
|
|
11190
|
+
}
|
|
11191
|
+
case "{": {
|
|
11192
|
+
lastValidIndex = i;
|
|
11193
|
+
stack.pop();
|
|
11194
|
+
stack.push(swapState);
|
|
11195
|
+
stack.push("INSIDE_OBJECT_START");
|
|
11196
|
+
break;
|
|
11197
|
+
}
|
|
11198
|
+
case "[": {
|
|
11199
|
+
lastValidIndex = i;
|
|
11200
|
+
stack.pop();
|
|
11201
|
+
stack.push(swapState);
|
|
11202
|
+
stack.push("INSIDE_ARRAY_START");
|
|
11203
|
+
break;
|
|
11204
|
+
}
|
|
11205
|
+
}
|
|
11206
|
+
}
|
|
11207
|
+
}
|
|
11208
|
+
function processAfterObjectValue(char, i) {
|
|
11209
|
+
switch (char) {
|
|
11210
|
+
case ",": {
|
|
11211
|
+
stack.pop();
|
|
11212
|
+
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
11213
|
+
break;
|
|
11214
|
+
}
|
|
11215
|
+
case "}": {
|
|
11216
|
+
lastValidIndex = i;
|
|
11217
|
+
stack.pop();
|
|
11218
|
+
break;
|
|
11219
|
+
}
|
|
11220
|
+
}
|
|
11221
|
+
}
|
|
11222
|
+
function processAfterArrayValue(char, i) {
|
|
11223
|
+
switch (char) {
|
|
11224
|
+
case ",": {
|
|
11225
|
+
stack.pop();
|
|
11226
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11227
|
+
break;
|
|
11228
|
+
}
|
|
11229
|
+
case "]": {
|
|
11230
|
+
lastValidIndex = i;
|
|
11231
|
+
stack.pop();
|
|
11232
|
+
break;
|
|
11233
|
+
}
|
|
11234
|
+
}
|
|
11235
|
+
}
|
|
11236
|
+
for (let i = 0; i < input.length; i++) {
|
|
11237
|
+
const char = input[i];
|
|
11238
|
+
const currentState = stack[stack.length - 1];
|
|
11239
|
+
switch (currentState) {
|
|
11240
|
+
case "ROOT":
|
|
11241
|
+
processValueStart(char, i, "FINISH");
|
|
11242
|
+
break;
|
|
11243
|
+
case "INSIDE_OBJECT_START": {
|
|
11244
|
+
switch (char) {
|
|
11245
|
+
case '"': {
|
|
11246
|
+
stack.pop();
|
|
11247
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11248
|
+
break;
|
|
11249
|
+
}
|
|
11250
|
+
case "}": {
|
|
11251
|
+
lastValidIndex = i;
|
|
11252
|
+
stack.pop();
|
|
11253
|
+
break;
|
|
11254
|
+
}
|
|
11255
|
+
}
|
|
11256
|
+
break;
|
|
11257
|
+
}
|
|
11258
|
+
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
11259
|
+
switch (char) {
|
|
11260
|
+
case '"': {
|
|
11261
|
+
stack.pop();
|
|
11262
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11263
|
+
break;
|
|
11264
|
+
}
|
|
11265
|
+
}
|
|
11266
|
+
break;
|
|
11267
|
+
}
|
|
11268
|
+
case "INSIDE_OBJECT_KEY": {
|
|
11269
|
+
switch (char) {
|
|
11270
|
+
case '"': {
|
|
11271
|
+
stack.pop();
|
|
11272
|
+
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
11273
|
+
break;
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11276
|
+
break;
|
|
11277
|
+
}
|
|
11278
|
+
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
11279
|
+
switch (char) {
|
|
11280
|
+
case ":": {
|
|
11281
|
+
stack.pop();
|
|
11282
|
+
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
11283
|
+
break;
|
|
11284
|
+
}
|
|
11285
|
+
}
|
|
11286
|
+
break;
|
|
11287
|
+
}
|
|
11288
|
+
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
11289
|
+
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
11290
|
+
break;
|
|
11291
|
+
}
|
|
11292
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11293
|
+
processAfterObjectValue(char, i);
|
|
11294
|
+
break;
|
|
11295
|
+
}
|
|
11296
|
+
case "INSIDE_STRING": {
|
|
11297
|
+
switch (char) {
|
|
11298
|
+
case '"': {
|
|
11299
|
+
stack.pop();
|
|
11300
|
+
lastValidIndex = i;
|
|
11301
|
+
break;
|
|
11302
|
+
}
|
|
11303
|
+
case "\\": {
|
|
11304
|
+
stack.push("INSIDE_STRING_ESCAPE");
|
|
11305
|
+
break;
|
|
11306
|
+
}
|
|
11307
|
+
default: {
|
|
11308
|
+
lastValidIndex = i;
|
|
11309
|
+
}
|
|
11310
|
+
}
|
|
11311
|
+
break;
|
|
11312
|
+
}
|
|
11313
|
+
case "INSIDE_ARRAY_START": {
|
|
11314
|
+
switch (char) {
|
|
11315
|
+
case "]": {
|
|
11316
|
+
lastValidIndex = i;
|
|
11317
|
+
stack.pop();
|
|
11318
|
+
break;
|
|
11319
|
+
}
|
|
11320
|
+
default: {
|
|
11321
|
+
lastValidIndex = i;
|
|
11322
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11323
|
+
break;
|
|
11324
|
+
}
|
|
11325
|
+
}
|
|
11326
|
+
break;
|
|
11327
|
+
}
|
|
11328
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11329
|
+
switch (char) {
|
|
11330
|
+
case ",": {
|
|
11331
|
+
stack.pop();
|
|
11332
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11333
|
+
break;
|
|
11334
|
+
}
|
|
11335
|
+
case "]": {
|
|
11336
|
+
lastValidIndex = i;
|
|
11337
|
+
stack.pop();
|
|
11338
|
+
break;
|
|
11339
|
+
}
|
|
11340
|
+
default: {
|
|
11341
|
+
lastValidIndex = i;
|
|
11342
|
+
break;
|
|
11343
|
+
}
|
|
11344
|
+
}
|
|
11345
|
+
break;
|
|
11346
|
+
}
|
|
11347
|
+
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
11348
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11349
|
+
break;
|
|
11350
|
+
}
|
|
11351
|
+
case "INSIDE_STRING_ESCAPE": {
|
|
11352
|
+
stack.pop();
|
|
11353
|
+
lastValidIndex = i;
|
|
11354
|
+
break;
|
|
11355
|
+
}
|
|
11356
|
+
case "INSIDE_NUMBER": {
|
|
11357
|
+
switch (char) {
|
|
11358
|
+
case "0":
|
|
11359
|
+
case "1":
|
|
11360
|
+
case "2":
|
|
11361
|
+
case "3":
|
|
11362
|
+
case "4":
|
|
11363
|
+
case "5":
|
|
11364
|
+
case "6":
|
|
11365
|
+
case "7":
|
|
11366
|
+
case "8":
|
|
11367
|
+
case "9": {
|
|
11368
|
+
lastValidIndex = i;
|
|
11369
|
+
break;
|
|
11370
|
+
}
|
|
11371
|
+
case "e":
|
|
11372
|
+
case "E":
|
|
11373
|
+
case "-":
|
|
11374
|
+
case ".": {
|
|
11375
|
+
break;
|
|
11376
|
+
}
|
|
11377
|
+
case ",": {
|
|
11378
|
+
stack.pop();
|
|
11379
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11380
|
+
processAfterArrayValue(char, i);
|
|
11381
|
+
}
|
|
11382
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11383
|
+
processAfterObjectValue(char, i);
|
|
11384
|
+
}
|
|
11385
|
+
break;
|
|
11386
|
+
}
|
|
11387
|
+
case "}": {
|
|
11388
|
+
stack.pop();
|
|
11389
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11390
|
+
processAfterObjectValue(char, i);
|
|
11391
|
+
}
|
|
11392
|
+
break;
|
|
11393
|
+
}
|
|
11394
|
+
case "]": {
|
|
11395
|
+
stack.pop();
|
|
11396
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11397
|
+
processAfterArrayValue(char, i);
|
|
11398
|
+
}
|
|
11399
|
+
break;
|
|
11400
|
+
}
|
|
11401
|
+
default: {
|
|
11402
|
+
stack.pop();
|
|
11403
|
+
break;
|
|
11404
|
+
}
|
|
11405
|
+
}
|
|
11406
|
+
break;
|
|
11407
|
+
}
|
|
11408
|
+
case "INSIDE_LITERAL": {
|
|
11409
|
+
const partialLiteral = input.substring(literalStart, i + 1);
|
|
11410
|
+
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
11411
|
+
stack.pop();
|
|
11412
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11413
|
+
processAfterObjectValue(char, i);
|
|
11414
|
+
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11415
|
+
processAfterArrayValue(char, i);
|
|
11416
|
+
}
|
|
11417
|
+
} else {
|
|
11418
|
+
lastValidIndex = i;
|
|
11419
|
+
}
|
|
11420
|
+
break;
|
|
11421
|
+
}
|
|
11422
|
+
}
|
|
11423
|
+
}
|
|
11424
|
+
let result = input.slice(0, lastValidIndex + 1);
|
|
11425
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
11426
|
+
const state = stack[i];
|
|
11427
|
+
switch (state) {
|
|
11428
|
+
case "INSIDE_STRING": {
|
|
11429
|
+
result += '"';
|
|
11430
|
+
break;
|
|
11431
|
+
}
|
|
11432
|
+
case "INSIDE_OBJECT_KEY":
|
|
11433
|
+
case "INSIDE_OBJECT_AFTER_KEY":
|
|
11434
|
+
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
11435
|
+
case "INSIDE_OBJECT_START":
|
|
11436
|
+
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
11437
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11438
|
+
result += "}";
|
|
11439
|
+
break;
|
|
11440
|
+
}
|
|
11441
|
+
case "INSIDE_ARRAY_START":
|
|
11442
|
+
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
11443
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11444
|
+
result += "]";
|
|
11445
|
+
break;
|
|
11446
|
+
}
|
|
11447
|
+
case "INSIDE_LITERAL": {
|
|
11448
|
+
const partialLiteral = input.substring(literalStart, input.length);
|
|
11449
|
+
if ("true".startsWith(partialLiteral)) {
|
|
11450
|
+
result += "true".slice(partialLiteral.length);
|
|
11451
|
+
} else if ("false".startsWith(partialLiteral)) {
|
|
11452
|
+
result += "false".slice(partialLiteral.length);
|
|
11453
|
+
} else if ("null".startsWith(partialLiteral)) {
|
|
11454
|
+
result += "null".slice(partialLiteral.length);
|
|
11455
|
+
}
|
|
11456
|
+
}
|
|
11457
|
+
}
|
|
11458
|
+
}
|
|
11459
|
+
return result;
|
|
11460
|
+
}
|
|
11461
|
+
async function parsePartialJson3(jsonText) {
|
|
11462
|
+
if (jsonText === void 0) {
|
|
11463
|
+
return { value: void 0, state: "undefined-input" };
|
|
11464
|
+
}
|
|
11465
|
+
let result = await safeParseJSON3({ text: jsonText });
|
|
11466
|
+
if (result.success) {
|
|
11467
|
+
return { value: result.value, state: "successful-parse" };
|
|
11468
|
+
}
|
|
11469
|
+
result = await safeParseJSON3({ text: fixJson3(jsonText) });
|
|
11470
|
+
if (result.success) {
|
|
11471
|
+
return { value: result.value, state: "repaired-parse" };
|
|
11472
|
+
}
|
|
11473
|
+
return { value: void 0, state: "failed-parse" };
|
|
11474
|
+
}
|
|
11475
|
+
createIdGenerator3({
|
|
11476
|
+
prefix: "aitxt",
|
|
11477
|
+
size: 24
|
|
11478
|
+
});
|
|
11479
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11480
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11481
|
+
var output_exports3 = {};
|
|
11482
|
+
__export4(output_exports3, {
|
|
11483
|
+
object: () => object3,
|
|
11484
|
+
text: () => text3
|
|
11485
|
+
});
|
|
11486
|
+
var text3 = () => ({
|
|
11487
|
+
type: "text",
|
|
11488
|
+
responseFormat: { type: "text" },
|
|
11489
|
+
async parsePartial({ text: text22 }) {
|
|
11490
|
+
return { partial: text22 };
|
|
11491
|
+
},
|
|
11492
|
+
async parseOutput({ text: text22 }) {
|
|
11493
|
+
return text22;
|
|
11494
|
+
}
|
|
11495
|
+
});
|
|
11496
|
+
var object3 = ({
|
|
11497
|
+
schema: inputSchema
|
|
11498
|
+
}) => {
|
|
11499
|
+
const schema = asSchema3(inputSchema);
|
|
11500
|
+
return {
|
|
11501
|
+
type: "object",
|
|
11502
|
+
responseFormat: {
|
|
11503
|
+
type: "json",
|
|
11504
|
+
schema: schema.jsonSchema
|
|
11505
|
+
},
|
|
11506
|
+
async parsePartial({ text: text22 }) {
|
|
11507
|
+
const result = await parsePartialJson3(text22);
|
|
11508
|
+
switch (result.state) {
|
|
11509
|
+
case "failed-parse":
|
|
11510
|
+
case "undefined-input":
|
|
11511
|
+
return void 0;
|
|
11512
|
+
case "repaired-parse":
|
|
11513
|
+
case "successful-parse":
|
|
11514
|
+
return {
|
|
11515
|
+
// Note: currently no validation of partial results:
|
|
11516
|
+
partial: result.value
|
|
11517
|
+
};
|
|
11518
|
+
default: {
|
|
11519
|
+
const _exhaustiveCheck = result.state;
|
|
11520
|
+
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
11521
|
+
}
|
|
11522
|
+
}
|
|
11523
|
+
},
|
|
11524
|
+
async parseOutput({ text: text22 }, context) {
|
|
11525
|
+
const parseResult = await safeParseJSON3({ text: text22 });
|
|
11526
|
+
if (!parseResult.success) {
|
|
11527
|
+
throw new NoObjectGeneratedError3({
|
|
11528
|
+
message: "No object generated: could not parse the response.",
|
|
11529
|
+
cause: parseResult.error,
|
|
11530
|
+
text: text22,
|
|
11531
|
+
response: context.response,
|
|
11532
|
+
usage: context.usage,
|
|
11533
|
+
finishReason: context.finishReason
|
|
11534
|
+
});
|
|
11535
|
+
}
|
|
11536
|
+
const validationResult = await safeValidateTypes3({
|
|
11537
|
+
value: parseResult.value,
|
|
11538
|
+
schema
|
|
11539
|
+
});
|
|
11540
|
+
if (!validationResult.success) {
|
|
11541
|
+
throw new NoObjectGeneratedError3({
|
|
11542
|
+
message: "No object generated: response did not match schema.",
|
|
11543
|
+
cause: validationResult.error,
|
|
11544
|
+
text: text22,
|
|
11545
|
+
response: context.response,
|
|
11546
|
+
usage: context.usage,
|
|
11547
|
+
finishReason: context.finishReason
|
|
11548
|
+
});
|
|
11549
|
+
}
|
|
11550
|
+
return validationResult.value;
|
|
11551
|
+
}
|
|
11552
|
+
};
|
|
11553
|
+
};
|
|
11554
|
+
var ClientOrServerImplementationSchema3 = z42.z.looseObject({
|
|
11555
|
+
name: z42.z.string(),
|
|
11556
|
+
version: z42.z.string()
|
|
11557
|
+
});
|
|
11558
|
+
var BaseParamsSchema3 = z42.z.looseObject({
|
|
11559
|
+
_meta: z42.z.optional(z42.z.object({}).loose())
|
|
11560
|
+
});
|
|
11561
|
+
var ResultSchema3 = BaseParamsSchema3;
|
|
11562
|
+
var RequestSchema3 = z42.z.object({
|
|
11563
|
+
method: z42.z.string(),
|
|
11564
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11565
|
+
});
|
|
11566
|
+
var ServerCapabilitiesSchema3 = z42.z.looseObject({
|
|
11567
|
+
experimental: z42.z.optional(z42.z.object({}).loose()),
|
|
11568
|
+
logging: z42.z.optional(z42.z.object({}).loose()),
|
|
11569
|
+
prompts: z42.z.optional(
|
|
11570
|
+
z42.z.looseObject({
|
|
11571
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11572
|
+
})
|
|
11573
|
+
),
|
|
11574
|
+
resources: z42.z.optional(
|
|
11575
|
+
z42.z.looseObject({
|
|
11576
|
+
subscribe: z42.z.optional(z42.z.boolean()),
|
|
11577
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11578
|
+
})
|
|
11579
|
+
),
|
|
11580
|
+
tools: z42.z.optional(
|
|
11581
|
+
z42.z.looseObject({
|
|
11582
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11583
|
+
})
|
|
11584
|
+
)
|
|
11585
|
+
});
|
|
11586
|
+
ResultSchema3.extend({
|
|
11587
|
+
protocolVersion: z42.z.string(),
|
|
11588
|
+
capabilities: ServerCapabilitiesSchema3,
|
|
11589
|
+
serverInfo: ClientOrServerImplementationSchema3,
|
|
11590
|
+
instructions: z42.z.optional(z42.z.string())
|
|
11591
|
+
});
|
|
11592
|
+
var PaginatedResultSchema3 = ResultSchema3.extend({
|
|
11593
|
+
nextCursor: z42.z.optional(z42.z.string())
|
|
11594
|
+
});
|
|
11595
|
+
var ToolSchema3 = z42.z.object({
|
|
11596
|
+
name: z42.z.string(),
|
|
11597
|
+
description: z42.z.optional(z42.z.string()),
|
|
11598
|
+
inputSchema: z42.z.object({
|
|
11599
|
+
type: z42.z.literal("object"),
|
|
11600
|
+
properties: z42.z.optional(z42.z.object({}).loose())
|
|
11601
|
+
}).loose()
|
|
11602
|
+
}).loose();
|
|
11603
|
+
PaginatedResultSchema3.extend({
|
|
11604
|
+
tools: z42.z.array(ToolSchema3)
|
|
11605
|
+
});
|
|
11606
|
+
var TextContentSchema3 = z42.z.object({
|
|
11607
|
+
type: z42.z.literal("text"),
|
|
11608
|
+
text: z42.z.string()
|
|
11609
|
+
}).loose();
|
|
11610
|
+
var ImageContentSchema3 = z42.z.object({
|
|
11611
|
+
type: z42.z.literal("image"),
|
|
11612
|
+
data: z42.z.base64(),
|
|
11613
|
+
mimeType: z42.z.string()
|
|
11614
|
+
}).loose();
|
|
11615
|
+
var ResourceContentsSchema3 = z42.z.object({
|
|
11616
|
+
/**
|
|
11617
|
+
* The URI of this resource.
|
|
11618
|
+
*/
|
|
11619
|
+
uri: z42.z.string(),
|
|
11620
|
+
/**
|
|
11621
|
+
* The MIME type of this resource, if known.
|
|
11622
|
+
*/
|
|
11623
|
+
mimeType: z42.z.optional(z42.z.string())
|
|
11624
|
+
}).loose();
|
|
11625
|
+
var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11626
|
+
text: z42.z.string()
|
|
11627
|
+
});
|
|
11628
|
+
var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11629
|
+
blob: z42.z.base64()
|
|
11630
|
+
});
|
|
11631
|
+
var EmbeddedResourceSchema3 = z42.z.object({
|
|
11632
|
+
type: z42.z.literal("resource"),
|
|
11633
|
+
resource: z42.z.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
|
|
11634
|
+
}).loose();
|
|
11635
|
+
ResultSchema3.extend({
|
|
11636
|
+
content: z42.z.array(
|
|
11637
|
+
z42.z.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
|
|
11638
|
+
),
|
|
11639
|
+
isError: z42.z.boolean().default(false).optional()
|
|
11640
|
+
}).or(
|
|
11641
|
+
ResultSchema3.extend({
|
|
11642
|
+
toolResult: z42.z.unknown()
|
|
11643
|
+
})
|
|
11644
|
+
);
|
|
11645
|
+
var JSONRPC_VERSION3 = "2.0";
|
|
11646
|
+
var JSONRPCRequestSchema3 = z42.z.object({
|
|
11647
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11648
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()])
|
|
11649
|
+
}).merge(RequestSchema3).strict();
|
|
11650
|
+
var JSONRPCResponseSchema3 = z42.z.object({
|
|
11651
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11652
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11653
|
+
result: ResultSchema3
|
|
11654
|
+
}).strict();
|
|
11655
|
+
var JSONRPCErrorSchema3 = z42.z.object({
|
|
11656
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11657
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11658
|
+
error: z42.z.object({
|
|
11659
|
+
code: z42.z.number().int(),
|
|
11660
|
+
message: z42.z.string(),
|
|
11661
|
+
data: z42.z.optional(z42.z.unknown())
|
|
11662
|
+
})
|
|
11663
|
+
}).strict();
|
|
11664
|
+
var JSONRPCNotificationSchema3 = z42.z.object({
|
|
11665
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3)
|
|
11666
|
+
}).merge(
|
|
11667
|
+
z42.z.object({
|
|
11668
|
+
method: z42.z.string(),
|
|
11669
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11670
|
+
})
|
|
11671
|
+
).strict();
|
|
11672
|
+
z42.z.union([
|
|
11673
|
+
JSONRPCRequestSchema3,
|
|
11674
|
+
JSONRPCNotificationSchema3,
|
|
11675
|
+
JSONRPCResponseSchema3,
|
|
11676
|
+
JSONRPCErrorSchema3
|
|
11677
|
+
]);
|
|
11678
|
+
var textUIPartSchema2 = z42.z.object({
|
|
11679
|
+
type: z42.z.literal("text"),
|
|
11680
|
+
text: z42.z.string(),
|
|
11681
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11682
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11683
|
+
});
|
|
11684
|
+
var reasoningUIPartSchema2 = z42.z.object({
|
|
11685
|
+
type: z42.z.literal("reasoning"),
|
|
11686
|
+
text: z42.z.string(),
|
|
11687
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11688
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11689
|
+
});
|
|
11690
|
+
var sourceUrlUIPartSchema2 = z42.z.object({
|
|
11691
|
+
type: z42.z.literal("source-url"),
|
|
11692
|
+
sourceId: z42.z.string(),
|
|
11693
|
+
url: z42.z.string(),
|
|
11694
|
+
title: z42.z.string().optional(),
|
|
11695
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11696
|
+
});
|
|
11697
|
+
var sourceDocumentUIPartSchema2 = z42.z.object({
|
|
11698
|
+
type: z42.z.literal("source-document"),
|
|
11699
|
+
sourceId: z42.z.string(),
|
|
11700
|
+
mediaType: z42.z.string(),
|
|
11701
|
+
title: z42.z.string(),
|
|
11702
|
+
filename: z42.z.string().optional(),
|
|
11703
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11704
|
+
});
|
|
11705
|
+
var fileUIPartSchema2 = z42.z.object({
|
|
11706
|
+
type: z42.z.literal("file"),
|
|
11707
|
+
mediaType: z42.z.string(),
|
|
11708
|
+
filename: z42.z.string().optional(),
|
|
11709
|
+
url: z42.z.string(),
|
|
11710
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11711
|
+
});
|
|
11712
|
+
var stepStartUIPartSchema2 = z42.z.object({
|
|
11713
|
+
type: z42.z.literal("step-start")
|
|
11714
|
+
});
|
|
11715
|
+
var dataUIPartSchema2 = z42.z.object({
|
|
11716
|
+
type: z42.z.string().startsWith("data-"),
|
|
11717
|
+
id: z42.z.string().optional(),
|
|
11718
|
+
data: z42.z.unknown()
|
|
11719
|
+
});
|
|
11720
|
+
var dynamicToolUIPartSchemas2 = [
|
|
11721
|
+
z42.z.object({
|
|
11722
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11723
|
+
toolName: z42.z.string(),
|
|
11724
|
+
toolCallId: z42.z.string(),
|
|
11725
|
+
state: z42.z.literal("input-streaming"),
|
|
11726
|
+
input: z42.z.unknown().optional(),
|
|
11727
|
+
output: z42.z.never().optional(),
|
|
11728
|
+
errorText: z42.z.never().optional()
|
|
11729
|
+
}),
|
|
11730
|
+
z42.z.object({
|
|
11731
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11732
|
+
toolName: z42.z.string(),
|
|
11733
|
+
toolCallId: z42.z.string(),
|
|
11734
|
+
state: z42.z.literal("input-available"),
|
|
11735
|
+
input: z42.z.unknown(),
|
|
11736
|
+
output: z42.z.never().optional(),
|
|
11737
|
+
errorText: z42.z.never().optional(),
|
|
11738
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11739
|
+
}),
|
|
11740
|
+
z42.z.object({
|
|
11741
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11742
|
+
toolName: z42.z.string(),
|
|
11743
|
+
toolCallId: z42.z.string(),
|
|
11744
|
+
state: z42.z.literal("output-available"),
|
|
11745
|
+
input: z42.z.unknown(),
|
|
11746
|
+
output: z42.z.unknown(),
|
|
11747
|
+
errorText: z42.z.never().optional(),
|
|
11748
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11749
|
+
preliminary: z42.z.boolean().optional()
|
|
11750
|
+
}),
|
|
11751
|
+
z42.z.object({
|
|
11752
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11753
|
+
toolName: z42.z.string(),
|
|
11754
|
+
toolCallId: z42.z.string(),
|
|
11755
|
+
state: z42.z.literal("output-error"),
|
|
11756
|
+
input: z42.z.unknown(),
|
|
11757
|
+
output: z42.z.never().optional(),
|
|
11758
|
+
errorText: z42.z.string(),
|
|
11759
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11760
|
+
})
|
|
11761
|
+
];
|
|
11762
|
+
var toolUIPartSchemas2 = [
|
|
11763
|
+
z42.z.object({
|
|
11764
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11765
|
+
toolCallId: z42.z.string(),
|
|
11766
|
+
state: z42.z.literal("input-streaming"),
|
|
11767
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11768
|
+
input: z42.z.unknown().optional(),
|
|
11769
|
+
output: z42.z.never().optional(),
|
|
11770
|
+
errorText: z42.z.never().optional()
|
|
11771
|
+
}),
|
|
11772
|
+
z42.z.object({
|
|
11773
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11774
|
+
toolCallId: z42.z.string(),
|
|
11775
|
+
state: z42.z.literal("input-available"),
|
|
11776
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11777
|
+
input: z42.z.unknown(),
|
|
11778
|
+
output: z42.z.never().optional(),
|
|
11779
|
+
errorText: z42.z.never().optional(),
|
|
11780
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11781
|
+
}),
|
|
11782
|
+
z42.z.object({
|
|
11783
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11784
|
+
toolCallId: z42.z.string(),
|
|
11785
|
+
state: z42.z.literal("output-available"),
|
|
11786
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11787
|
+
input: z42.z.unknown(),
|
|
11788
|
+
output: z42.z.unknown(),
|
|
11789
|
+
errorText: z42.z.never().optional(),
|
|
11790
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11791
|
+
preliminary: z42.z.boolean().optional()
|
|
11792
|
+
}),
|
|
11793
|
+
z42.z.object({
|
|
11794
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11795
|
+
toolCallId: z42.z.string(),
|
|
11796
|
+
state: z42.z.literal("output-error"),
|
|
11797
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
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
|
|
9549
11824
|
var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
|
|
9550
11825
|
var TemplateUnitSchema = zod.z.object({
|
|
9551
11826
|
kind: zod.z.enum(UNIT_KINDS),
|
|
@@ -11740,14 +14015,14 @@ export const mastra = new Mastra({
|
|
|
11740
14015
|
noEmit: true
|
|
11741
14016
|
};
|
|
11742
14017
|
const host = {
|
|
11743
|
-
getSourceFile: (
|
|
14018
|
+
getSourceFile: (name20) => name20 === fileName ? sourceFile : void 0,
|
|
11744
14019
|
writeFile: () => {
|
|
11745
14020
|
},
|
|
11746
14021
|
getCurrentDirectory: () => "",
|
|
11747
14022
|
getDirectories: () => [],
|
|
11748
|
-
fileExists: (
|
|
11749
|
-
readFile: (
|
|
11750
|
-
getCanonicalFileName: (
|
|
14023
|
+
fileExists: (name20) => name20 === fileName,
|
|
14024
|
+
readFile: (name20) => name20 === fileName ? fileContent : void 0,
|
|
14025
|
+
getCanonicalFileName: (name20) => name20,
|
|
11751
14026
|
useCaseSensitiveFileNames: () => true,
|
|
11752
14027
|
getNewLine: () => "\n",
|
|
11753
14028
|
getDefaultLibFileName: () => "lib.d.ts"
|
|
@@ -13127,25 +15402,25 @@ var packageMergeStep = workflows.createStep({
|
|
|
13127
15402
|
const tplDevDeps = ensureObj(packageInfo.devDependencies);
|
|
13128
15403
|
const tplPeerDeps = ensureObj(packageInfo.peerDependencies);
|
|
13129
15404
|
const tplScripts = ensureObj(packageInfo.scripts);
|
|
13130
|
-
const existsAnywhere = (
|
|
13131
|
-
for (const [
|
|
13132
|
-
if (!existsAnywhere(
|
|
13133
|
-
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);
|
|
13134
15409
|
}
|
|
13135
15410
|
}
|
|
13136
|
-
for (const [
|
|
13137
|
-
if (!existsAnywhere(
|
|
13138
|
-
targetPkg.devDependencies[
|
|
15411
|
+
for (const [name20, ver] of Object.entries(tplDevDeps)) {
|
|
15412
|
+
if (!existsAnywhere(name20)) {
|
|
15413
|
+
targetPkg.devDependencies[name20] = String(ver);
|
|
13139
15414
|
}
|
|
13140
15415
|
}
|
|
13141
|
-
for (const [
|
|
13142
|
-
if (!(
|
|
13143
|
-
targetPkg.peerDependencies[
|
|
15416
|
+
for (const [name20, ver] of Object.entries(tplPeerDeps)) {
|
|
15417
|
+
if (!(name20 in targetPkg.peerDependencies)) {
|
|
15418
|
+
targetPkg.peerDependencies[name20] = String(ver);
|
|
13144
15419
|
}
|
|
13145
15420
|
}
|
|
13146
15421
|
const prefix = `template:${slug}:`;
|
|
13147
|
-
for (const [
|
|
13148
|
-
const newKey = `${prefix}${
|
|
15422
|
+
for (const [name20, cmd] of Object.entries(tplScripts)) {
|
|
15423
|
+
const newKey = `${prefix}${name20}`;
|
|
13149
15424
|
if (!(newKey in targetPkg.scripts)) {
|
|
13150
15425
|
targetPkg.scripts[newKey] = String(cmd);
|
|
13151
15426
|
}
|
|
@@ -13230,9 +15505,9 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13230
15505
|
return "unknown";
|
|
13231
15506
|
}
|
|
13232
15507
|
};
|
|
13233
|
-
const convertNaming = (
|
|
13234
|
-
const baseName = path.basename(
|
|
13235
|
-
const ext = path.extname(
|
|
15508
|
+
const convertNaming = (name20, convention) => {
|
|
15509
|
+
const baseName = path.basename(name20, path.extname(name20));
|
|
15510
|
+
const ext = path.extname(name20);
|
|
13236
15511
|
switch (convention) {
|
|
13237
15512
|
case "camelCase":
|
|
13238
15513
|
return baseName.replace(/[-_]/g, "").replace(/([A-Z])/g, (match, p1, offset) => offset === 0 ? p1.toLowerCase() : p1) + ext;
|
|
@@ -13243,7 +15518,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13243
15518
|
case "PascalCase":
|
|
13244
15519
|
return baseName.replace(/[-_]/g, "").replace(/^[a-z]/, (match) => match.toUpperCase()) + ext;
|
|
13245
15520
|
default:
|
|
13246
|
-
return
|
|
15521
|
+
return name20;
|
|
13247
15522
|
}
|
|
13248
15523
|
};
|
|
13249
15524
|
for (const unit of orderedUnits) {
|
|
@@ -15628,8 +17903,8 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15628
17903
|
const mastra = actionArgs.mastra;
|
|
15629
17904
|
const logger = mastra.getLogger();
|
|
15630
17905
|
try {
|
|
15631
|
-
|
|
15632
|
-
if (actionId && !
|
|
17906
|
+
chunkVY4ENABS_cjs.WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);
|
|
17907
|
+
if (actionId && !chunkVY4ENABS_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
|
|
15633
17908
|
throw new chunk7NADHFD2_cjs.HTTPException(400, {
|
|
15634
17909
|
message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(", ")}`
|
|
15635
17910
|
});
|
|
@@ -15644,7 +17919,7 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15644
17919
|
const result = await workflowHandlerFn(handlerArgs);
|
|
15645
17920
|
return result;
|
|
15646
17921
|
} finally {
|
|
15647
|
-
|
|
17922
|
+
chunkVY4ENABS_cjs.WorkflowRegistry.cleanup();
|
|
15648
17923
|
}
|
|
15649
17924
|
} catch (error) {
|
|
15650
17925
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -15658,10 +17933,10 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15658
17933
|
}
|
|
15659
17934
|
var getAgentBuilderActionsHandler = createAgentBuilderWorkflowHandler(async () => {
|
|
15660
17935
|
try {
|
|
15661
|
-
const registryWorkflows =
|
|
17936
|
+
const registryWorkflows = chunkVY4ENABS_cjs.WorkflowRegistry.getAllWorkflows();
|
|
15662
17937
|
const _workflows = Object.entries(registryWorkflows).reduce(
|
|
15663
17938
|
(acc, [key, workflow]) => {
|
|
15664
|
-
acc[key] =
|
|
17939
|
+
acc[key] = chunkVY4ENABS_cjs.getWorkflowInfo(workflow);
|
|
15665
17940
|
return acc;
|
|
15666
17941
|
},
|
|
15667
17942
|
{}
|
|
@@ -15672,59 +17947,59 @@ var getAgentBuilderActionsHandler = createAgentBuilderWorkflowHandler(async () =
|
|
|
15672
17947
|
}
|
|
15673
17948
|
}, "Getting agent builder actions");
|
|
15674
17949
|
var getAgentBuilderActionByIdHandler = createAgentBuilderWorkflowHandler(
|
|
15675
|
-
|
|
17950
|
+
chunkGIM2ZSPB_cjs.getWorkflowByIdHandler,
|
|
15676
17951
|
"Getting agent builder action by ID"
|
|
15677
17952
|
);
|
|
15678
17953
|
var getAgentBuilderActionRunByIdHandler = createAgentBuilderWorkflowHandler(
|
|
15679
|
-
|
|
17954
|
+
chunkGIM2ZSPB_cjs.getWorkflowRunByIdHandler,
|
|
15680
17955
|
"Getting agent builder action run by ID"
|
|
15681
17956
|
);
|
|
15682
17957
|
var getAgentBuilderActionRunExecutionResultHandler = createAgentBuilderWorkflowHandler(
|
|
15683
|
-
|
|
17958
|
+
chunkGIM2ZSPB_cjs.getWorkflowRunExecutionResultHandler,
|
|
15684
17959
|
"Getting agent builder action run execution result"
|
|
15685
17960
|
);
|
|
15686
17961
|
var createAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15687
|
-
|
|
17962
|
+
chunkGIM2ZSPB_cjs.createWorkflowRunHandler,
|
|
15688
17963
|
"Creating agent builder action run"
|
|
15689
17964
|
);
|
|
15690
17965
|
var startAsyncAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15691
|
-
|
|
17966
|
+
chunkGIM2ZSPB_cjs.startAsyncWorkflowHandler,
|
|
15692
17967
|
"Starting async agent builder action"
|
|
15693
17968
|
);
|
|
15694
17969
|
var startAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15695
|
-
|
|
17970
|
+
chunkGIM2ZSPB_cjs.startWorkflowRunHandler,
|
|
15696
17971
|
"Starting agent builder action run"
|
|
15697
17972
|
);
|
|
15698
17973
|
var watchAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15699
|
-
|
|
17974
|
+
chunkGIM2ZSPB_cjs.watchWorkflowHandler,
|
|
15700
17975
|
"Watching agent builder action"
|
|
15701
17976
|
);
|
|
15702
17977
|
var streamAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15703
|
-
|
|
17978
|
+
chunkGIM2ZSPB_cjs.streamWorkflowHandler,
|
|
15704
17979
|
"Streaming agent builder action"
|
|
15705
17980
|
);
|
|
15706
17981
|
var streamVNextAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15707
|
-
|
|
17982
|
+
chunkGIM2ZSPB_cjs.streamVNextWorkflowHandler,
|
|
15708
17983
|
"Streaming VNext agent builder action"
|
|
15709
17984
|
);
|
|
15710
17985
|
var resumeAsyncAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15711
|
-
|
|
17986
|
+
chunkGIM2ZSPB_cjs.resumeAsyncWorkflowHandler,
|
|
15712
17987
|
"Resuming async agent builder action"
|
|
15713
17988
|
);
|
|
15714
17989
|
var resumeAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15715
|
-
|
|
17990
|
+
chunkGIM2ZSPB_cjs.resumeWorkflowHandler,
|
|
15716
17991
|
"Resuming agent builder action"
|
|
15717
17992
|
);
|
|
15718
17993
|
var getAgentBuilderActionRunsHandler = createAgentBuilderWorkflowHandler(
|
|
15719
|
-
|
|
17994
|
+
chunkGIM2ZSPB_cjs.getWorkflowRunsHandler,
|
|
15720
17995
|
"Getting agent builder action runs"
|
|
15721
17996
|
);
|
|
15722
17997
|
var cancelAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15723
|
-
|
|
17998
|
+
chunkGIM2ZSPB_cjs.cancelWorkflowRunHandler,
|
|
15724
17999
|
"Cancelling agent builder action run"
|
|
15725
18000
|
);
|
|
15726
18001
|
var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
|
|
15727
|
-
|
|
18002
|
+
chunkGIM2ZSPB_cjs.sendWorkflowRunEventHandler,
|
|
15728
18003
|
"Sending agent builder action run event"
|
|
15729
18004
|
);
|
|
15730
18005
|
|
|
@@ -15744,5 +18019,5 @@ exports.startAsyncAgentBuilderActionHandler = startAsyncAgentBuilderActionHandle
|
|
|
15744
18019
|
exports.streamAgentBuilderActionHandler = streamAgentBuilderActionHandler;
|
|
15745
18020
|
exports.streamVNextAgentBuilderActionHandler = streamVNextAgentBuilderActionHandler;
|
|
15746
18021
|
exports.watchAgentBuilderActionHandler = watchAgentBuilderActionHandler;
|
|
15747
|
-
//# sourceMappingURL=chunk-
|
|
15748
|
-
//# sourceMappingURL=chunk-
|
|
18022
|
+
//# sourceMappingURL=chunk-DWVU5R72.cjs.map
|
|
18023
|
+
//# sourceMappingURL=chunk-DWVU5R72.cjs.map
|