@mastra/server 0.0.0-fix-cloud-peer-deps-20250923194656 → 0.0.0-gl-test-20250917080133
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 +3 -119
- package/dist/{chunk-AVEPEUN4.cjs → chunk-3THIIWWW.cjs} +3 -4
- package/dist/chunk-3THIIWWW.cjs.map +1 -0
- package/dist/{chunk-PUYSH3IL.js → chunk-5QUKZCEF.js} +3 -4
- package/dist/chunk-5QUKZCEF.js.map +1 -0
- package/dist/{chunk-2WMATOMO.cjs → chunk-5VTTUNVK.cjs} +8 -93
- package/dist/chunk-5VTTUNVK.cjs.map +1 -0
- package/dist/{chunk-57HWW2TY.cjs → chunk-6LUKYSWE.cjs} +119 -96
- package/dist/chunk-6LUKYSWE.cjs.map +1 -0
- package/dist/{chunk-IYJW2OVQ.js → chunk-7QEJ5QG5.js} +22 -60
- package/dist/chunk-7QEJ5QG5.js.map +1 -0
- package/dist/{chunk-X7564COI.js → chunk-7XNKAVVA.js} +2596 -315
- package/dist/chunk-7XNKAVVA.js.map +1 -0
- package/dist/{chunk-G662L2YZ.js → chunk-B2V3PUB7.js} +116 -93
- package/dist/chunk-B2V3PUB7.js.map +1 -0
- package/dist/{chunk-2GDLSAVJ.cjs → chunk-GUI3CROV.cjs} +22 -60
- package/dist/chunk-GUI3CROV.cjs.map +1 -0
- package/dist/chunk-IY34NOLA.cjs +150 -0
- package/dist/chunk-IY34NOLA.cjs.map +1 -0
- package/dist/{chunk-LJFAAEU7.cjs → chunk-J7BPKKOG.cjs} +4 -8
- package/dist/chunk-J7BPKKOG.cjs.map +1 -0
- package/dist/{chunk-PLNQ4XER.cjs → chunk-JJBXJYMY.cjs} +2615 -334
- package/dist/chunk-JJBXJYMY.cjs.map +1 -0
- package/dist/{chunk-5N724Q2T.cjs → chunk-L265APUD.cjs} +3 -43
- package/dist/chunk-L265APUD.cjs.map +1 -0
- package/dist/{chunk-5KRXONRF.js → chunk-R7NOGUZG.js} +4 -43
- package/dist/chunk-R7NOGUZG.js.map +1 -0
- package/dist/{chunk-KM7EJKXV.js → chunk-SYRRSBGL.js} +4 -8
- package/dist/chunk-SYRRSBGL.js.map +1 -0
- package/dist/chunk-U46VIX2V.js +144 -0
- package/dist/chunk-U46VIX2V.js.map +1 -0
- package/dist/{chunk-BZT5VYDT.js → chunk-ZSAOHEZK.js} +9 -92
- package/dist/chunk-ZSAOHEZK.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- 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 +4 -5
- 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 +15 -23
- package/dist/server/handlers/agents.d.ts +4 -46
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/network.cjs +24 -0
- package/dist/server/handlers/network.cjs.map +1 -0
- package/dist/server/handlers/network.d.ts +50 -0
- package/dist/server/handlers/network.d.ts.map +1 -0
- package/dist/server/handlers/network.js +3 -0
- package/dist/server/handlers/network.js.map +1 -0
- package/dist/server/handlers/observability.cjs +3 -7
- package/dist/server/handlers/observability.d.ts +0 -18
- 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 +6 -208
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vNextNetwork.d.ts +6 -73
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -1
- package/dist/server/handlers/workflows.cjs +16 -24
- package/dist/server/handlers/workflows.d.ts +7 -16
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +19 -14
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +8 -7
- package/dist/server/utils.d.ts +0 -2
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-2GDLSAVJ.cjs.map +0 -1
- 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-AVEPEUN4.cjs.map +0 -1
- package/dist/chunk-BZT5VYDT.js.map +0 -1
- package/dist/chunk-CNU4A2XU.js +0 -129
- package/dist/chunk-CNU4A2XU.js.map +0 -1
- package/dist/chunk-G662L2YZ.js.map +0 -1
- package/dist/chunk-GDWMF6SB.cjs +0 -133
- package/dist/chunk-GDWMF6SB.cjs.map +0 -1
- package/dist/chunk-IYJW2OVQ.js.map +0 -1
- package/dist/chunk-KM7EJKXV.js.map +0 -1
- package/dist/chunk-LJFAAEU7.cjs.map +0 -1
- package/dist/chunk-PLNQ4XER.cjs.map +0 -1
- package/dist/chunk-PUYSH3IL.js.map +0 -1
- package/dist/chunk-X7564COI.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunkGDWMF6SB_cjs = require('./chunk-GDWMF6SB.cjs');
|
|
3
|
+
var chunk6LUKYSWE_cjs = require('./chunk-6LUKYSWE.cjs');
|
|
5
4
|
var chunkFALVL2VV_cjs = require('./chunk-FALVL2VV.cjs');
|
|
6
5
|
var chunkHVBBFCDH_cjs = require('./chunk-HVBBFCDH.cjs');
|
|
7
6
|
var chunkPPYGWINI_cjs = require('./chunk-PPYGWINI.cjs');
|
|
@@ -168,8 +167,8 @@ var require_ignore = chunkEMMSS5I5_cjs.__commonJS({
|
|
|
168
167
|
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
169
168
|
}
|
|
170
169
|
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
171
|
-
var define = (
|
|
172
|
-
Object.defineProperty(
|
|
170
|
+
var define = (object4, key, value) => {
|
|
171
|
+
Object.defineProperty(object4, key, { value });
|
|
173
172
|
return value;
|
|
174
173
|
};
|
|
175
174
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
@@ -621,10 +620,10 @@ chunkEMMSS5I5_cjs.__export(agent_builder_exports, {
|
|
|
621
620
|
streamVNextAgentBuilderActionHandler: () => streamVNextAgentBuilderActionHandler,
|
|
622
621
|
watchAgentBuilderActionHandler: () => watchAgentBuilderActionHandler
|
|
623
622
|
});
|
|
624
|
-
function zodToJsonSchema(
|
|
623
|
+
function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relative") {
|
|
625
624
|
const fn = "toJSONSchema";
|
|
626
625
|
if (fn in zod.z) {
|
|
627
|
-
return zod.z[fn](
|
|
626
|
+
return zod.z[fn](zodSchema4, {
|
|
628
627
|
unrepresentable: "any",
|
|
629
628
|
override: (ctx) => {
|
|
630
629
|
const def = ctx.zodSchema?._zod?.def;
|
|
@@ -635,7 +634,7 @@ function zodToJsonSchema(zodSchema3, target = "jsonSchema7", strategy = "relativ
|
|
|
635
634
|
}
|
|
636
635
|
});
|
|
637
636
|
} else {
|
|
638
|
-
return chunkHVBBFCDH_cjs.esm_default(
|
|
637
|
+
return chunkHVBBFCDH_cjs.esm_default(zodSchema4, {
|
|
639
638
|
$refStrategy: strategy,
|
|
640
639
|
target
|
|
641
640
|
});
|
|
@@ -1235,8 +1234,8 @@ function formatDataStreamPart(type, value) {
|
|
|
1235
1234
|
`;
|
|
1236
1235
|
}
|
|
1237
1236
|
function zodSchema(zodSchema22, options) {
|
|
1238
|
-
var
|
|
1239
|
-
const useReferences = (
|
|
1237
|
+
var _a20;
|
|
1238
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
1240
1239
|
return jsonSchema(
|
|
1241
1240
|
chunkHVBBFCDH_cjs.esm_default(zodSchema22, {
|
|
1242
1241
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -1349,11 +1348,11 @@ var major = VERSION.split(".")[0];
|
|
|
1349
1348
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
1350
1349
|
var _global = _globalThis;
|
|
1351
1350
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
1352
|
-
var
|
|
1351
|
+
var _a20;
|
|
1353
1352
|
if (allowOverride === void 0) {
|
|
1354
1353
|
allowOverride = false;
|
|
1355
1354
|
}
|
|
1356
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
1355
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a20 !== void 0 ? _a20 : {
|
|
1357
1356
|
version: VERSION
|
|
1358
1357
|
};
|
|
1359
1358
|
if (!allowOverride && api[type]) {
|
|
@@ -1371,8 +1370,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
1371
1370
|
return true;
|
|
1372
1371
|
}
|
|
1373
1372
|
function getGlobal(type) {
|
|
1374
|
-
var
|
|
1375
|
-
var globalVersion = (
|
|
1373
|
+
var _a20, _b8;
|
|
1374
|
+
var globalVersion = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a20 === void 0 ? void 0 : _a20.version;
|
|
1376
1375
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
1377
1376
|
return;
|
|
1378
1377
|
}
|
|
@@ -1549,13 +1548,13 @@ var DiagAPI = (
|
|
|
1549
1548
|
}
|
|
1550
1549
|
var self = this;
|
|
1551
1550
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
1552
|
-
var
|
|
1551
|
+
var _a20, _b8, _c;
|
|
1553
1552
|
if (optionsOrLogLevel === void 0) {
|
|
1554
1553
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
1555
1554
|
}
|
|
1556
1555
|
if (logger === self) {
|
|
1557
1556
|
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((
|
|
1557
|
+
self.error((_a20 = err.stack) !== null && _a20 !== void 0 ? _a20 : err.message);
|
|
1559
1558
|
return false;
|
|
1560
1559
|
}
|
|
1561
1560
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -1726,12 +1725,12 @@ var ContextAPI = (
|
|
|
1726
1725
|
return this._getContextManager().active();
|
|
1727
1726
|
};
|
|
1728
1727
|
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
1729
|
-
var
|
|
1728
|
+
var _a20;
|
|
1730
1729
|
var args = [];
|
|
1731
1730
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
1732
1731
|
args[_i - 3] = arguments[_i];
|
|
1733
1732
|
}
|
|
1734
|
-
return (
|
|
1733
|
+
return (_a20 = this._getContextManager()).with.apply(_a20, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
1735
1734
|
};
|
|
1736
1735
|
ContextAPI2.prototype.bind = function(context, target) {
|
|
1737
1736
|
return this._getContextManager().bind(context, target);
|
|
@@ -1826,8 +1825,8 @@ function setSpanContext(context, spanContext) {
|
|
|
1826
1825
|
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
1827
1826
|
}
|
|
1828
1827
|
function getSpanContext(context) {
|
|
1829
|
-
var
|
|
1830
|
-
return (
|
|
1828
|
+
var _a20;
|
|
1829
|
+
return (_a20 = getSpan(context)) === null || _a20 === void 0 ? void 0 : _a20.spanContext();
|
|
1831
1830
|
}
|
|
1832
1831
|
|
|
1833
1832
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
@@ -1853,7 +1852,7 @@ var NoopTracer = (
|
|
|
1853
1852
|
(function() {
|
|
1854
1853
|
function NoopTracer2() {
|
|
1855
1854
|
}
|
|
1856
|
-
NoopTracer2.prototype.startSpan = function(
|
|
1855
|
+
NoopTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1857
1856
|
if (context === void 0) {
|
|
1858
1857
|
context = contextApi.active();
|
|
1859
1858
|
}
|
|
@@ -1868,7 +1867,7 @@ var NoopTracer = (
|
|
|
1868
1867
|
return new NonRecordingSpan();
|
|
1869
1868
|
}
|
|
1870
1869
|
};
|
|
1871
|
-
NoopTracer2.prototype.startActiveSpan = function(
|
|
1870
|
+
NoopTracer2.prototype.startActiveSpan = function(name20, arg2, arg3, arg4) {
|
|
1872
1871
|
var opts;
|
|
1873
1872
|
var ctx;
|
|
1874
1873
|
var fn;
|
|
@@ -1885,7 +1884,7 @@ var NoopTracer = (
|
|
|
1885
1884
|
fn = arg4;
|
|
1886
1885
|
}
|
|
1887
1886
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
1888
|
-
var span = this.startSpan(
|
|
1887
|
+
var span = this.startSpan(name20, opts, parentContext);
|
|
1889
1888
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
1890
1889
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
1891
1890
|
};
|
|
@@ -1901,14 +1900,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
1901
1900
|
var ProxyTracer = (
|
|
1902
1901
|
/** @class */
|
|
1903
1902
|
(function() {
|
|
1904
|
-
function ProxyTracer2(_provider,
|
|
1903
|
+
function ProxyTracer2(_provider, name20, version, options) {
|
|
1905
1904
|
this._provider = _provider;
|
|
1906
|
-
this.name =
|
|
1905
|
+
this.name = name20;
|
|
1907
1906
|
this.version = version;
|
|
1908
1907
|
this.options = options;
|
|
1909
1908
|
}
|
|
1910
|
-
ProxyTracer2.prototype.startSpan = function(
|
|
1911
|
-
return this._getTracer().startSpan(
|
|
1909
|
+
ProxyTracer2.prototype.startSpan = function(name20, options, context) {
|
|
1910
|
+
return this._getTracer().startSpan(name20, options, context);
|
|
1912
1911
|
};
|
|
1913
1912
|
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
1914
1913
|
var tracer = this._getTracer();
|
|
@@ -1949,20 +1948,20 @@ var ProxyTracerProvider = (
|
|
|
1949
1948
|
(function() {
|
|
1950
1949
|
function ProxyTracerProvider2() {
|
|
1951
1950
|
}
|
|
1952
|
-
ProxyTracerProvider2.prototype.getTracer = function(
|
|
1953
|
-
var
|
|
1954
|
-
return (
|
|
1951
|
+
ProxyTracerProvider2.prototype.getTracer = function(name20, version, options) {
|
|
1952
|
+
var _a20;
|
|
1953
|
+
return (_a20 = this.getDelegateTracer(name20, version, options)) !== null && _a20 !== void 0 ? _a20 : new ProxyTracer(this, name20, version, options);
|
|
1955
1954
|
};
|
|
1956
1955
|
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
1957
|
-
var
|
|
1958
|
-
return (
|
|
1956
|
+
var _a20;
|
|
1957
|
+
return (_a20 = this._delegate) !== null && _a20 !== void 0 ? _a20 : NOOP_TRACER_PROVIDER;
|
|
1959
1958
|
};
|
|
1960
1959
|
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
1961
1960
|
this._delegate = delegate;
|
|
1962
1961
|
};
|
|
1963
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(
|
|
1964
|
-
var
|
|
1965
|
-
return (
|
|
1962
|
+
ProxyTracerProvider2.prototype.getDelegateTracer = function(name20, version, options) {
|
|
1963
|
+
var _a20;
|
|
1964
|
+
return (_a20 = this._delegate) === null || _a20 === void 0 ? void 0 : _a20.getTracer(name20, version, options);
|
|
1966
1965
|
};
|
|
1967
1966
|
return ProxyTracerProvider2;
|
|
1968
1967
|
})()
|
|
@@ -2008,8 +2007,8 @@ var TraceAPI = (
|
|
|
2008
2007
|
TraceAPI2.prototype.getTracerProvider = function() {
|
|
2009
2008
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
2010
2009
|
};
|
|
2011
|
-
TraceAPI2.prototype.getTracer = function(
|
|
2012
|
-
return this.getTracerProvider().getTracer(
|
|
2010
|
+
TraceAPI2.prototype.getTracer = function(name20, version) {
|
|
2011
|
+
return this.getTracerProvider().getTracer(name20, version);
|
|
2013
2012
|
};
|
|
2014
2013
|
TraceAPI2.prototype.disable = function() {
|
|
2015
2014
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -3206,11 +3205,11 @@ function extractResponseHeaders(response) {
|
|
|
3206
3205
|
return Object.fromEntries([...response.headers]);
|
|
3207
3206
|
}
|
|
3208
3207
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
3209
|
-
var
|
|
3208
|
+
var _a20, _b8, _c;
|
|
3210
3209
|
if (globalThisAny.window) {
|
|
3211
3210
|
return `runtime/browser`;
|
|
3212
3211
|
}
|
|
3213
|
-
if ((
|
|
3212
|
+
if ((_a20 = globalThisAny.navigator) == null ? void 0 : _a20.userAgent) {
|
|
3214
3213
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
3215
3214
|
}
|
|
3216
3215
|
if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
|
|
@@ -3391,12 +3390,12 @@ function loadOptionalSetting({
|
|
|
3391
3390
|
}
|
|
3392
3391
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
3393
3392
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
3394
|
-
function _parse(
|
|
3395
|
-
const obj = JSON.parse(
|
|
3393
|
+
function _parse(text4) {
|
|
3394
|
+
const obj = JSON.parse(text4);
|
|
3396
3395
|
if (obj === null || typeof obj !== "object") {
|
|
3397
3396
|
return obj;
|
|
3398
3397
|
}
|
|
3399
|
-
if (suspectProtoRx.test(
|
|
3398
|
+
if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
|
|
3400
3399
|
return obj;
|
|
3401
3400
|
}
|
|
3402
3401
|
return filter(obj);
|
|
@@ -3423,11 +3422,11 @@ function filter(obj) {
|
|
|
3423
3422
|
}
|
|
3424
3423
|
return obj;
|
|
3425
3424
|
}
|
|
3426
|
-
function secureJsonParse(
|
|
3425
|
+
function secureJsonParse(text4) {
|
|
3427
3426
|
const { stackTraceLimit } = Error;
|
|
3428
3427
|
Error.stackTraceLimit = 0;
|
|
3429
3428
|
try {
|
|
3430
|
-
return _parse(
|
|
3429
|
+
return _parse(text4);
|
|
3431
3430
|
} finally {
|
|
3432
3431
|
Error.stackTraceLimit = stackTraceLimit;
|
|
3433
3432
|
}
|
|
@@ -3468,12 +3467,12 @@ async function safeValidateTypes2({
|
|
|
3468
3467
|
value,
|
|
3469
3468
|
schema
|
|
3470
3469
|
}) {
|
|
3471
|
-
const
|
|
3470
|
+
const validator22 = asValidator(schema);
|
|
3472
3471
|
try {
|
|
3473
|
-
if (
|
|
3472
|
+
if (validator22.validate == null) {
|
|
3474
3473
|
return { success: true, value, rawValue: value };
|
|
3475
3474
|
}
|
|
3476
|
-
const result = await
|
|
3475
|
+
const result = await validator22.validate(value);
|
|
3477
3476
|
if (result.success) {
|
|
3478
3477
|
return { success: true, value: result.value, rawValue: value };
|
|
3479
3478
|
}
|
|
@@ -3491,11 +3490,11 @@ async function safeValidateTypes2({
|
|
|
3491
3490
|
}
|
|
3492
3491
|
}
|
|
3493
3492
|
async function parseJSON({
|
|
3494
|
-
text:
|
|
3493
|
+
text: text4,
|
|
3495
3494
|
schema
|
|
3496
3495
|
}) {
|
|
3497
3496
|
try {
|
|
3498
|
-
const value = secureJsonParse(
|
|
3497
|
+
const value = secureJsonParse(text4);
|
|
3499
3498
|
if (schema == null) {
|
|
3500
3499
|
return value;
|
|
3501
3500
|
}
|
|
@@ -3504,15 +3503,15 @@ async function parseJSON({
|
|
|
3504
3503
|
if (chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) || chunkHVBBFCDH_cjs.TypeValidationError.isInstance(error)) {
|
|
3505
3504
|
throw error;
|
|
3506
3505
|
}
|
|
3507
|
-
throw new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3506
|
+
throw new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error });
|
|
3508
3507
|
}
|
|
3509
3508
|
}
|
|
3510
3509
|
async function safeParseJSON2({
|
|
3511
|
-
text:
|
|
3510
|
+
text: text4,
|
|
3512
3511
|
schema
|
|
3513
3512
|
}) {
|
|
3514
3513
|
try {
|
|
3515
|
-
const value = secureJsonParse(
|
|
3514
|
+
const value = secureJsonParse(text4);
|
|
3516
3515
|
if (schema == null) {
|
|
3517
3516
|
return { success: true, value, rawValue: value };
|
|
3518
3517
|
}
|
|
@@ -3520,7 +3519,7 @@ async function safeParseJSON2({
|
|
|
3520
3519
|
} catch (error) {
|
|
3521
3520
|
return {
|
|
3522
3521
|
success: false,
|
|
3523
|
-
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text:
|
|
3522
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
3524
3523
|
rawValue: void 0
|
|
3525
3524
|
};
|
|
3526
3525
|
}
|
|
@@ -3773,11 +3772,11 @@ function parseAnyDef() {
|
|
|
3773
3772
|
return {};
|
|
3774
3773
|
}
|
|
3775
3774
|
function parseArrayDef(def, refs) {
|
|
3776
|
-
var
|
|
3775
|
+
var _a20, _b8, _c;
|
|
3777
3776
|
const res = {
|
|
3778
3777
|
type: "array"
|
|
3779
3778
|
};
|
|
3780
|
-
if (((
|
|
3779
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
3781
3780
|
res.items = parseDef(def.type._def, {
|
|
3782
3781
|
...refs,
|
|
3783
3782
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -4138,8 +4137,8 @@ function escapeNonAlphaNumeric(source) {
|
|
|
4138
4137
|
return result;
|
|
4139
4138
|
}
|
|
4140
4139
|
function addFormat(schema, value, message, refs) {
|
|
4141
|
-
var
|
|
4142
|
-
if (schema.format || ((
|
|
4140
|
+
var _a20;
|
|
4141
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
4143
4142
|
if (!schema.anyOf) {
|
|
4144
4143
|
schema.anyOf = [];
|
|
4145
4144
|
}
|
|
@@ -4158,8 +4157,8 @@ function addFormat(schema, value, message, refs) {
|
|
|
4158
4157
|
}
|
|
4159
4158
|
}
|
|
4160
4159
|
function addPattern(schema, regex, message, refs) {
|
|
4161
|
-
var
|
|
4162
|
-
if (schema.pattern || ((
|
|
4160
|
+
var _a20;
|
|
4161
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
4163
4162
|
if (!schema.allOf) {
|
|
4164
4163
|
schema.allOf = [];
|
|
4165
4164
|
}
|
|
@@ -4178,7 +4177,7 @@ function addPattern(schema, regex, message, refs) {
|
|
|
4178
4177
|
}
|
|
4179
4178
|
}
|
|
4180
4179
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
4181
|
-
var
|
|
4180
|
+
var _a20;
|
|
4182
4181
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
4183
4182
|
return regex.source;
|
|
4184
4183
|
}
|
|
@@ -4208,7 +4207,7 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4208
4207
|
pattern += source[i];
|
|
4209
4208
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
4210
4209
|
inCharRange = false;
|
|
4211
|
-
} else if (source[i + 1] === "-" && ((
|
|
4210
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
4212
4211
|
pattern += source[i];
|
|
4213
4212
|
inCharRange = true;
|
|
4214
4213
|
} else {
|
|
@@ -4250,13 +4249,13 @@ function stringifyRegExpWithFlags(regex, refs) {
|
|
|
4250
4249
|
return pattern;
|
|
4251
4250
|
}
|
|
4252
4251
|
function parseRecordDef(def, refs) {
|
|
4253
|
-
var
|
|
4252
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
4254
4253
|
const schema = {
|
|
4255
4254
|
type: "object",
|
|
4256
|
-
additionalProperties: (
|
|
4255
|
+
additionalProperties: (_a20 = parseDef(def.valueType._def, {
|
|
4257
4256
|
...refs,
|
|
4258
4257
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
4259
|
-
})) != null ?
|
|
4258
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
4260
4259
|
};
|
|
4261
4260
|
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
4262
4261
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
@@ -4307,11 +4306,11 @@ function parseMapDef(def, refs) {
|
|
|
4307
4306
|
};
|
|
4308
4307
|
}
|
|
4309
4308
|
function parseNativeEnumDef(def) {
|
|
4310
|
-
const
|
|
4309
|
+
const object4 = def.values;
|
|
4311
4310
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
4312
|
-
return typeof
|
|
4311
|
+
return typeof object4[object4[key]] !== "number";
|
|
4313
4312
|
});
|
|
4314
|
-
const actualValues = actualKeys.map((key) =>
|
|
4313
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
4315
4314
|
const parsedTypes = Array.from(
|
|
4316
4315
|
new Set(actualValues.map((values) => typeof values))
|
|
4317
4316
|
);
|
|
@@ -4515,8 +4514,8 @@ function safeIsOptional(schema) {
|
|
|
4515
4514
|
}
|
|
4516
4515
|
}
|
|
4517
4516
|
var parseOptionalDef = (def, refs) => {
|
|
4518
|
-
var
|
|
4519
|
-
if (refs.currentPath.toString() === ((
|
|
4517
|
+
var _a20;
|
|
4518
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
4520
4519
|
return parseDef(def.innerType._def, refs);
|
|
4521
4520
|
}
|
|
4522
4521
|
const innerSchema = parseDef(def.innerType._def, {
|
|
@@ -4686,10 +4685,10 @@ var selectParser = (def, typeName, refs) => {
|
|
|
4686
4685
|
}
|
|
4687
4686
|
};
|
|
4688
4687
|
function parseDef(def, refs, forceResolution = false) {
|
|
4689
|
-
var
|
|
4688
|
+
var _a20;
|
|
4690
4689
|
const seenItem = refs.seen.get(def);
|
|
4691
4690
|
if (refs.override) {
|
|
4692
|
-
const overrideResult = (
|
|
4691
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
4693
4692
|
refs,
|
|
4694
4693
|
def,
|
|
4695
4694
|
refs,
|
|
@@ -4755,11 +4754,11 @@ var getRefs = (options) => {
|
|
|
4755
4754
|
currentPath,
|
|
4756
4755
|
propertyPath: void 0,
|
|
4757
4756
|
seen: new Map(
|
|
4758
|
-
Object.entries(_options.definitions).map(([
|
|
4757
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
4759
4758
|
def._def,
|
|
4760
4759
|
{
|
|
4761
4760
|
def: def._def,
|
|
4762
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
4761
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
4763
4762
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
4764
4763
|
jsonSchema: void 0
|
|
4765
4764
|
}
|
|
@@ -4768,50 +4767,50 @@ var getRefs = (options) => {
|
|
|
4768
4767
|
};
|
|
4769
4768
|
};
|
|
4770
4769
|
var zodToJsonSchema2 = (schema, options) => {
|
|
4771
|
-
var
|
|
4770
|
+
var _a20;
|
|
4772
4771
|
const refs = getRefs(options);
|
|
4773
4772
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
4774
|
-
(acc, [
|
|
4775
|
-
var
|
|
4773
|
+
(acc, [name25, schema2]) => {
|
|
4774
|
+
var _a25;
|
|
4776
4775
|
return {
|
|
4777
4776
|
...acc,
|
|
4778
|
-
[
|
|
4777
|
+
[name25]: (_a25 = parseDef(
|
|
4779
4778
|
schema2._def,
|
|
4780
4779
|
{
|
|
4781
4780
|
...refs,
|
|
4782
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4781
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
4783
4782
|
},
|
|
4784
4783
|
true
|
|
4785
|
-
)) != null ?
|
|
4784
|
+
)) != null ? _a25 : parseAnyDef()
|
|
4786
4785
|
};
|
|
4787
4786
|
},
|
|
4788
4787
|
{}
|
|
4789
4788
|
) : void 0;
|
|
4790
|
-
const
|
|
4791
|
-
const main = (
|
|
4789
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
4790
|
+
const main = (_a20 = parseDef(
|
|
4792
4791
|
schema._def,
|
|
4793
|
-
|
|
4792
|
+
name20 === void 0 ? refs : {
|
|
4794
4793
|
...refs,
|
|
4795
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
4794
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
4796
4795
|
},
|
|
4797
4796
|
false
|
|
4798
|
-
)) != null ?
|
|
4797
|
+
)) != null ? _a20 : parseAnyDef();
|
|
4799
4798
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
4800
4799
|
if (title !== void 0) {
|
|
4801
4800
|
main.title = title;
|
|
4802
4801
|
}
|
|
4803
|
-
const combined =
|
|
4802
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
4804
4803
|
...main,
|
|
4805
4804
|
[refs.definitionPath]: definitions
|
|
4806
4805
|
} : main : {
|
|
4807
4806
|
$ref: [
|
|
4808
4807
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
4809
4808
|
refs.definitionPath,
|
|
4810
|
-
|
|
4809
|
+
name20
|
|
4811
4810
|
].join("/"),
|
|
4812
4811
|
[refs.definitionPath]: {
|
|
4813
4812
|
...definitions,
|
|
4814
|
-
[
|
|
4813
|
+
[name20]: main
|
|
4815
4814
|
}
|
|
4816
4815
|
};
|
|
4817
4816
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -4819,8 +4818,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
4819
4818
|
};
|
|
4820
4819
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
4821
4820
|
function zod3Schema(zodSchema22, options) {
|
|
4822
|
-
var
|
|
4823
|
-
const useReferences = (
|
|
4821
|
+
var _a20;
|
|
4822
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4824
4823
|
return jsonSchema2(
|
|
4825
4824
|
zod_to_json_schema_default(zodSchema22, {
|
|
4826
4825
|
$refStrategy: useReferences ? "root" : "none"
|
|
@@ -4834,8 +4833,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
4834
4833
|
);
|
|
4835
4834
|
}
|
|
4836
4835
|
function zod4Schema(zodSchema22, options) {
|
|
4837
|
-
var
|
|
4838
|
-
const useReferences = (
|
|
4836
|
+
var _a20;
|
|
4837
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
4839
4838
|
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
4840
4839
|
target: "draft-7",
|
|
4841
4840
|
io: "output",
|
|
@@ -5145,14 +5144,14 @@ var gatewayErrorResponseSchema = z42.z.object({
|
|
|
5145
5144
|
})
|
|
5146
5145
|
});
|
|
5147
5146
|
function asGatewayError(error, authMethod) {
|
|
5148
|
-
var
|
|
5147
|
+
var _a84;
|
|
5149
5148
|
if (GatewayError.isInstance(error)) {
|
|
5150
5149
|
return error;
|
|
5151
5150
|
}
|
|
5152
5151
|
if (chunkHVBBFCDH_cjs.APICallError.isInstance(error)) {
|
|
5153
5152
|
return createGatewayErrorFromResponse({
|
|
5154
5153
|
response: extractApiCallResponse(error),
|
|
5155
|
-
statusCode: (
|
|
5154
|
+
statusCode: (_a84 = error.statusCode) != null ? _a84 : 500,
|
|
5156
5155
|
defaultMessage: "Gateway request failed",
|
|
5157
5156
|
cause: error,
|
|
5158
5157
|
authMethod
|
|
@@ -5403,7 +5402,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5403
5402
|
abortSignal,
|
|
5404
5403
|
providerOptions
|
|
5405
5404
|
}) {
|
|
5406
|
-
var
|
|
5405
|
+
var _a84;
|
|
5407
5406
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
5408
5407
|
try {
|
|
5409
5408
|
const {
|
|
@@ -5434,7 +5433,7 @@ var GatewayEmbeddingModel = class {
|
|
|
5434
5433
|
});
|
|
5435
5434
|
return {
|
|
5436
5435
|
embeddings: responseBody.embeddings,
|
|
5437
|
-
usage: (
|
|
5436
|
+
usage: (_a84 = responseBody.usage) != null ? _a84 : void 0,
|
|
5438
5437
|
providerMetadata: responseBody.providerMetadata,
|
|
5439
5438
|
response: { headers: responseHeaders, body: rawValue }
|
|
5440
5439
|
};
|
|
@@ -5458,8 +5457,8 @@ var gatewayEmbeddingResponseSchema = z42.z.object({
|
|
|
5458
5457
|
providerMetadata: z42.z.record(z42.z.string(), z42.z.record(z42.z.string(), z42.z.unknown())).optional()
|
|
5459
5458
|
});
|
|
5460
5459
|
async function getVercelOidcToken() {
|
|
5461
|
-
var
|
|
5462
|
-
const token = (_b8 = (
|
|
5460
|
+
var _a84, _b8;
|
|
5461
|
+
const token = (_b8 = (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
5463
5462
|
if (!token) {
|
|
5464
5463
|
throw new GatewayAuthenticationError({
|
|
5465
5464
|
message: "OIDC token not available",
|
|
@@ -5469,21 +5468,21 @@ async function getVercelOidcToken() {
|
|
|
5469
5468
|
return token;
|
|
5470
5469
|
}
|
|
5471
5470
|
async function getVercelRequestId() {
|
|
5472
|
-
var
|
|
5473
|
-
return (
|
|
5471
|
+
var _a84;
|
|
5472
|
+
return (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-id"];
|
|
5474
5473
|
}
|
|
5475
5474
|
var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
|
|
5476
5475
|
function getContext() {
|
|
5477
|
-
var
|
|
5476
|
+
var _a84, _b8, _c;
|
|
5478
5477
|
const fromSymbol = globalThis;
|
|
5479
|
-
return (_c = (_b8 = (
|
|
5478
|
+
return (_c = (_b8 = (_a84 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a84.get) == null ? void 0 : _b8.call(_a84)) != null ? _c : {};
|
|
5480
5479
|
}
|
|
5481
5480
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
5482
5481
|
function createGatewayProvider(options = {}) {
|
|
5483
|
-
var
|
|
5482
|
+
var _a84, _b8;
|
|
5484
5483
|
let pendingMetadata = null;
|
|
5485
5484
|
let metadataCache = null;
|
|
5486
|
-
const cacheRefreshMillis = (
|
|
5485
|
+
const cacheRefreshMillis = (_a84 = options.metadataCacheRefreshMillis) != null ? _a84 : 1e3 * 60 * 5;
|
|
5487
5486
|
let lastFetchTime = 0;
|
|
5488
5487
|
const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
5489
5488
|
const getHeaders = async () => {
|
|
@@ -5535,8 +5534,8 @@ function createGatewayProvider(options = {}) {
|
|
|
5535
5534
|
});
|
|
5536
5535
|
};
|
|
5537
5536
|
const getAvailableModels = async () => {
|
|
5538
|
-
var
|
|
5539
|
-
const now = (_c = (_b9 = (
|
|
5537
|
+
var _a94, _b9, _c;
|
|
5538
|
+
const now = (_c = (_b9 = (_a94 = options._internal) == null ? void 0 : _a94.currentDate) == null ? void 0 : _b9.call(_a94).getTime()) != null ? _c : Date.now();
|
|
5540
5539
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
5541
5540
|
lastFetchTime = now;
|
|
5542
5541
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -6146,9 +6145,6 @@ function prepareRetries2({
|
|
|
6146
6145
|
})
|
|
6147
6146
|
};
|
|
6148
6147
|
}
|
|
6149
|
-
function stepCountIs(stepCount) {
|
|
6150
|
-
return ({ steps }) => steps.length === stepCount;
|
|
6151
|
-
}
|
|
6152
6148
|
var VERSION3 = "5.0.44" ;
|
|
6153
6149
|
createIdGenerator2({
|
|
6154
6150
|
prefix: "aitxt",
|
|
@@ -7866,50 +7862,50 @@ function isValidWithSchema(schema, value) {
|
|
|
7866
7862
|
return schema.safeParse(value).success;
|
|
7867
7863
|
}
|
|
7868
7864
|
var NotHandler = class {
|
|
7869
|
-
apply(
|
|
7870
|
-
if (!schema.not) return
|
|
7865
|
+
apply(zodSchema4, schema) {
|
|
7866
|
+
if (!schema.not) return zodSchema4;
|
|
7871
7867
|
const notSchema = convertJsonSchemaToZod(schema.not);
|
|
7872
|
-
return
|
|
7868
|
+
return zodSchema4.refine(
|
|
7873
7869
|
(value) => !isValidWithSchema(notSchema, value),
|
|
7874
7870
|
{ message: "Value must not match the 'not' schema" }
|
|
7875
7871
|
);
|
|
7876
7872
|
}
|
|
7877
7873
|
};
|
|
7878
7874
|
var UniqueItemsHandler = class {
|
|
7879
|
-
apply(
|
|
7875
|
+
apply(zodSchema4, schema) {
|
|
7880
7876
|
const arraySchema = schema;
|
|
7881
|
-
if (arraySchema.uniqueItems !== true) return
|
|
7882
|
-
return
|
|
7877
|
+
if (arraySchema.uniqueItems !== true) return zodSchema4;
|
|
7878
|
+
return zodSchema4.refine(createUniqueItemsValidator(), {
|
|
7883
7879
|
message: "Array items must be unique"
|
|
7884
7880
|
});
|
|
7885
7881
|
}
|
|
7886
7882
|
};
|
|
7887
7883
|
var AllOfHandler = class {
|
|
7888
|
-
apply(
|
|
7889
|
-
if (!schema.allOf || schema.allOf.length === 0) return
|
|
7884
|
+
apply(zodSchema4, schema) {
|
|
7885
|
+
if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
|
|
7890
7886
|
const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
|
|
7891
7887
|
return allOfSchemas.reduce(
|
|
7892
7888
|
(acc, s) => z42.z.intersection(acc, s),
|
|
7893
|
-
|
|
7889
|
+
zodSchema4
|
|
7894
7890
|
);
|
|
7895
7891
|
}
|
|
7896
7892
|
};
|
|
7897
7893
|
var AnyOfHandler = class {
|
|
7898
|
-
apply(
|
|
7899
|
-
if (!schema.anyOf || schema.anyOf.length === 0) return
|
|
7894
|
+
apply(zodSchema4, schema) {
|
|
7895
|
+
if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
|
|
7900
7896
|
const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z42.z.union([
|
|
7901
7897
|
convertJsonSchemaToZod(schema.anyOf[0]),
|
|
7902
7898
|
convertJsonSchemaToZod(schema.anyOf[1]),
|
|
7903
7899
|
...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
|
|
7904
7900
|
]);
|
|
7905
|
-
return z42.z.intersection(
|
|
7901
|
+
return z42.z.intersection(zodSchema4, anyOfSchema);
|
|
7906
7902
|
}
|
|
7907
7903
|
};
|
|
7908
7904
|
var OneOfHandler = class {
|
|
7909
|
-
apply(
|
|
7910
|
-
if (!schema.oneOf || schema.oneOf.length === 0) return
|
|
7905
|
+
apply(zodSchema4, schema) {
|
|
7906
|
+
if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
|
|
7911
7907
|
const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
|
|
7912
|
-
return
|
|
7908
|
+
return zodSchema4.refine(
|
|
7913
7909
|
(value) => {
|
|
7914
7910
|
let validCount = 0;
|
|
7915
7911
|
for (const oneOfSchema of oneOfSchemas) {
|
|
@@ -7926,12 +7922,12 @@ var OneOfHandler = class {
|
|
|
7926
7922
|
}
|
|
7927
7923
|
};
|
|
7928
7924
|
var PrefixItemsHandler = class {
|
|
7929
|
-
apply(
|
|
7925
|
+
apply(zodSchema4, schema) {
|
|
7930
7926
|
const arraySchema = schema;
|
|
7931
7927
|
if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
|
|
7932
7928
|
const prefixItems = arraySchema.prefixItems;
|
|
7933
7929
|
const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
|
|
7934
|
-
return
|
|
7930
|
+
return zodSchema4.refine(
|
|
7935
7931
|
(value) => {
|
|
7936
7932
|
if (!Array.isArray(value)) return true;
|
|
7937
7933
|
for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
|
|
@@ -7956,16 +7952,16 @@ var PrefixItemsHandler = class {
|
|
|
7956
7952
|
{ message: "Array does not match prefixItems schema" }
|
|
7957
7953
|
);
|
|
7958
7954
|
}
|
|
7959
|
-
return
|
|
7955
|
+
return zodSchema4;
|
|
7960
7956
|
}
|
|
7961
7957
|
};
|
|
7962
7958
|
var ObjectPropertiesHandler = class {
|
|
7963
|
-
apply(
|
|
7959
|
+
apply(zodSchema4, schema) {
|
|
7964
7960
|
const objectSchema = schema;
|
|
7965
7961
|
if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
|
|
7966
|
-
return
|
|
7962
|
+
return zodSchema4;
|
|
7967
7963
|
}
|
|
7968
|
-
if (
|
|
7964
|
+
if (zodSchema4 instanceof z42.z.ZodObject || zodSchema4 instanceof z42.z.ZodRecord) {
|
|
7969
7965
|
const shape = {};
|
|
7970
7966
|
if (objectSchema.properties) {
|
|
7971
7967
|
for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
|
|
@@ -7992,7 +7988,7 @@ var ObjectPropertiesHandler = class {
|
|
|
7992
7988
|
return z42.z.object(shape).passthrough();
|
|
7993
7989
|
}
|
|
7994
7990
|
}
|
|
7995
|
-
return
|
|
7991
|
+
return zodSchema4.refine(
|
|
7996
7992
|
(value) => {
|
|
7997
7993
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
7998
7994
|
return true;
|
|
@@ -8034,13 +8030,13 @@ var ObjectPropertiesHandler = class {
|
|
|
8034
8030
|
}
|
|
8035
8031
|
};
|
|
8036
8032
|
var EnumComplexHandler = class {
|
|
8037
|
-
apply(
|
|
8038
|
-
if (!schema.enum || schema.enum.length === 0) return
|
|
8033
|
+
apply(zodSchema4, schema) {
|
|
8034
|
+
if (!schema.enum || schema.enum.length === 0) return zodSchema4;
|
|
8039
8035
|
const complexValues = schema.enum.filter(
|
|
8040
8036
|
(v) => Array.isArray(v) || typeof v === "object" && v !== null
|
|
8041
8037
|
);
|
|
8042
|
-
if (complexValues.length === 0) return
|
|
8043
|
-
return
|
|
8038
|
+
if (complexValues.length === 0) return zodSchema4;
|
|
8039
|
+
return zodSchema4.refine(
|
|
8044
8040
|
(value) => {
|
|
8045
8041
|
if (typeof value !== "object" || value === null) return true;
|
|
8046
8042
|
return complexValues.some(
|
|
@@ -8052,32 +8048,32 @@ var EnumComplexHandler = class {
|
|
|
8052
8048
|
}
|
|
8053
8049
|
};
|
|
8054
8050
|
var ConstComplexHandler = class {
|
|
8055
|
-
apply(
|
|
8056
|
-
if (schema.const === void 0) return
|
|
8051
|
+
apply(zodSchema4, schema) {
|
|
8052
|
+
if (schema.const === void 0) return zodSchema4;
|
|
8057
8053
|
const constValue = schema.const;
|
|
8058
8054
|
if (typeof constValue !== "object" || constValue === null) {
|
|
8059
|
-
return
|
|
8055
|
+
return zodSchema4;
|
|
8060
8056
|
}
|
|
8061
|
-
return
|
|
8057
|
+
return zodSchema4.refine(
|
|
8062
8058
|
(value) => deepEqual(value, constValue),
|
|
8063
8059
|
{ message: "Value must equal the const value" }
|
|
8064
8060
|
);
|
|
8065
8061
|
}
|
|
8066
8062
|
};
|
|
8067
8063
|
var MetadataHandler = class {
|
|
8068
|
-
apply(
|
|
8064
|
+
apply(zodSchema4, schema) {
|
|
8069
8065
|
if (schema.description) {
|
|
8070
|
-
|
|
8066
|
+
zodSchema4 = zodSchema4.describe(schema.description);
|
|
8071
8067
|
}
|
|
8072
|
-
return
|
|
8068
|
+
return zodSchema4;
|
|
8073
8069
|
}
|
|
8074
8070
|
};
|
|
8075
8071
|
var ProtoRequiredHandler = class {
|
|
8076
|
-
apply(
|
|
8077
|
-
var
|
|
8072
|
+
apply(zodSchema4, schema) {
|
|
8073
|
+
var _a20;
|
|
8078
8074
|
const objectSchema = schema;
|
|
8079
|
-
if (!((
|
|
8080
|
-
return
|
|
8075
|
+
if (!((_a20 = objectSchema.required) == null ? void 0 : _a20.includes("__proto__")) || schema.type !== void 0) {
|
|
8076
|
+
return zodSchema4;
|
|
8081
8077
|
}
|
|
8082
8078
|
return z42.z.any().refine(
|
|
8083
8079
|
(value) => this.validateRequired(value, objectSchema.required),
|
|
@@ -8094,14 +8090,14 @@ var ProtoRequiredHandler = class {
|
|
|
8094
8090
|
}
|
|
8095
8091
|
};
|
|
8096
8092
|
var ContainsHandler = class {
|
|
8097
|
-
apply(
|
|
8098
|
-
var
|
|
8093
|
+
apply(zodSchema4, schema) {
|
|
8094
|
+
var _a20;
|
|
8099
8095
|
const arraySchema = schema;
|
|
8100
|
-
if (arraySchema.contains === void 0) return
|
|
8096
|
+
if (arraySchema.contains === void 0) return zodSchema4;
|
|
8101
8097
|
const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
|
|
8102
|
-
const minContains = (
|
|
8098
|
+
const minContains = (_a20 = arraySchema.minContains) != null ? _a20 : 1;
|
|
8103
8099
|
const maxContains = arraySchema.maxContains;
|
|
8104
|
-
return
|
|
8100
|
+
return zodSchema4.refine(
|
|
8105
8101
|
(value) => {
|
|
8106
8102
|
if (!Array.isArray(value)) {
|
|
8107
8103
|
return true;
|
|
@@ -8210,32 +8206,32 @@ function convertJsonSchemaToZod(schema) {
|
|
|
8210
8206
|
allowedSchemas.push(objectSchema);
|
|
8211
8207
|
}
|
|
8212
8208
|
}
|
|
8213
|
-
let
|
|
8209
|
+
let zodSchema4;
|
|
8214
8210
|
if (allowedSchemas.length === 0) {
|
|
8215
|
-
|
|
8211
|
+
zodSchema4 = z42.z.never();
|
|
8216
8212
|
} else if (allowedSchemas.length === 1) {
|
|
8217
|
-
|
|
8213
|
+
zodSchema4 = allowedSchemas[0];
|
|
8218
8214
|
} else {
|
|
8219
8215
|
const hasConstraints = Object.keys(schema).some(
|
|
8220
8216
|
(key) => key !== "$schema" && key !== "title" && key !== "description"
|
|
8221
8217
|
);
|
|
8222
8218
|
if (!hasConstraints) {
|
|
8223
|
-
|
|
8219
|
+
zodSchema4 = z42.z.any();
|
|
8224
8220
|
} else {
|
|
8225
|
-
|
|
8221
|
+
zodSchema4 = z42.z.union(allowedSchemas);
|
|
8226
8222
|
}
|
|
8227
8223
|
}
|
|
8228
8224
|
for (const handler of refinementHandlers) {
|
|
8229
|
-
|
|
8225
|
+
zodSchema4 = handler.apply(zodSchema4, schema);
|
|
8230
8226
|
}
|
|
8231
|
-
return
|
|
8227
|
+
return zodSchema4;
|
|
8232
8228
|
}
|
|
8233
8229
|
function convertJsonSchemaToZod2(schema) {
|
|
8234
|
-
function addMetadata(
|
|
8235
|
-
if (
|
|
8236
|
-
|
|
8230
|
+
function addMetadata(zodSchema4, jsonSchema4) {
|
|
8231
|
+
if (jsonSchema4.description) {
|
|
8232
|
+
zodSchema4 = zodSchema4.describe(jsonSchema4.description);
|
|
8237
8233
|
}
|
|
8238
|
-
return
|
|
8234
|
+
return zodSchema4;
|
|
8239
8235
|
}
|
|
8240
8236
|
if (schema.const !== void 0) {
|
|
8241
8237
|
if (typeof schema.const === "string") {
|
|
@@ -8341,13 +8337,13 @@ function convertJsonSchemaToZod2(schema) {
|
|
|
8341
8337
|
shape[key] = shape[key].optional();
|
|
8342
8338
|
}
|
|
8343
8339
|
}
|
|
8344
|
-
let
|
|
8340
|
+
let zodSchema4;
|
|
8345
8341
|
if (schema.additionalProperties !== false) {
|
|
8346
|
-
|
|
8342
|
+
zodSchema4 = zod.z.object(shape).passthrough();
|
|
8347
8343
|
} else {
|
|
8348
|
-
|
|
8344
|
+
zodSchema4 = zod.z.object(shape);
|
|
8349
8345
|
}
|
|
8350
|
-
return addMetadata(
|
|
8346
|
+
return addMetadata(zodSchema4, schema);
|
|
8351
8347
|
}
|
|
8352
8348
|
return addMetadata(zod.z.object({}), schema);
|
|
8353
8349
|
case "array": {
|
|
@@ -8624,7 +8620,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
8624
8620
|
const resourceScope = typeof config?.semanticRecall === "object" && config?.semanticRecall?.scope === `resource`;
|
|
8625
8621
|
if (config?.semanticRecall && selectBy?.vectorSearchString && this.vector) {
|
|
8626
8622
|
const { embeddings, dimension } = await this.embedMessageContent(selectBy.vectorSearchString);
|
|
8627
|
-
const { indexName } = await this.createEmbeddingIndex(dimension
|
|
8623
|
+
const { indexName } = await this.createEmbeddingIndex(dimension);
|
|
8628
8624
|
await Promise.all(
|
|
8629
8625
|
embeddings.map(async (embedding) => {
|
|
8630
8626
|
if (typeof this.vector === `undefined`) {
|
|
@@ -8887,11 +8883,11 @@ ${workingMemory}`;
|
|
|
8887
8883
|
release();
|
|
8888
8884
|
}
|
|
8889
8885
|
}
|
|
8890
|
-
chunkText(
|
|
8886
|
+
chunkText(text4, tokenSize = 4096) {
|
|
8891
8887
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
8892
8888
|
const chunks = [];
|
|
8893
8889
|
let currentChunk = "";
|
|
8894
|
-
const words =
|
|
8890
|
+
const words = text4.split(/\s+/);
|
|
8895
8891
|
for (const word of words) {
|
|
8896
8892
|
const wordWithSpace = currentChunk ? " " + word : word;
|
|
8897
8893
|
if (currentChunk.length + wordWithSpace.length > charSize) {
|
|
@@ -8978,7 +8974,7 @@ ${workingMemory}`;
|
|
|
8978
8974
|
if (!textForEmbedding) return;
|
|
8979
8975
|
const { embeddings, chunks, dimension } = await this.embedMessageContent(textForEmbedding);
|
|
8980
8976
|
if (typeof indexName === `undefined`) {
|
|
8981
|
-
indexName = this.createEmbeddingIndex(dimension
|
|
8977
|
+
indexName = this.createEmbeddingIndex(dimension).then((result2) => result2.indexName);
|
|
8982
8978
|
}
|
|
8983
8979
|
if (typeof this.vector === `undefined`) {
|
|
8984
8980
|
throw new Error(
|
|
@@ -9053,10 +9049,10 @@ ${workingMemory}`;
|
|
|
9053
9049
|
}
|
|
9054
9050
|
return newMessage;
|
|
9055
9051
|
}
|
|
9056
|
-
parseWorkingMemory(
|
|
9052
|
+
parseWorkingMemory(text4) {
|
|
9057
9053
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
9058
9054
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
9059
|
-
const matches =
|
|
9055
|
+
const matches = text4.match(workingMemoryRegex);
|
|
9060
9056
|
const match = matches?.[0];
|
|
9061
9057
|
if (match) {
|
|
9062
9058
|
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
@@ -9356,12 +9352,12 @@ var _Tiktoken = class {
|
|
|
9356
9352
|
this.textMap.set(rank, bytes);
|
|
9357
9353
|
}
|
|
9358
9354
|
this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
|
|
9359
|
-
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [
|
|
9360
|
-
memo[rank] = this.textEncoder.encode(
|
|
9355
|
+
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
|
|
9356
|
+
memo[rank] = this.textEncoder.encode(text4);
|
|
9361
9357
|
return memo;
|
|
9362
9358
|
}, {});
|
|
9363
9359
|
}
|
|
9364
|
-
encode(
|
|
9360
|
+
encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
|
|
9365
9361
|
const regexes = new RegExp(this.patStr, "ug");
|
|
9366
9362
|
const specialRegex = _Tiktoken.specialTokenRegex(
|
|
9367
9363
|
Object.keys(this.specialTokens)
|
|
@@ -9379,7 +9375,7 @@ var _Tiktoken = class {
|
|
|
9379
9375
|
const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
|
|
9380
9376
|
...disallowedSpecialSet
|
|
9381
9377
|
]);
|
|
9382
|
-
const specialMatch =
|
|
9378
|
+
const specialMatch = text4.match(disallowedSpecialRegex);
|
|
9383
9379
|
if (specialMatch != null) {
|
|
9384
9380
|
throw new Error(
|
|
9385
9381
|
`The text contains a special token that is not allowed: ${specialMatch[0]}`
|
|
@@ -9392,13 +9388,13 @@ var _Tiktoken = class {
|
|
|
9392
9388
|
let startFind = start;
|
|
9393
9389
|
while (true) {
|
|
9394
9390
|
specialRegex.lastIndex = startFind;
|
|
9395
|
-
nextSpecial = specialRegex.exec(
|
|
9391
|
+
nextSpecial = specialRegex.exec(text4);
|
|
9396
9392
|
if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
|
|
9397
9393
|
break;
|
|
9398
9394
|
startFind = nextSpecial.index + 1;
|
|
9399
9395
|
}
|
|
9400
|
-
const end = nextSpecial?.index ??
|
|
9401
|
-
for (const match of
|
|
9396
|
+
const end = nextSpecial?.index ?? text4.length;
|
|
9397
|
+
for (const match of text4.substring(start, end).matchAll(regexes)) {
|
|
9402
9398
|
const piece = this.textEncoder.encode(match[0]);
|
|
9403
9399
|
const token2 = this.rankMap.get(piece.join(","));
|
|
9404
9400
|
if (token2 != null) {
|
|
@@ -9536,16 +9532,2295 @@ var TokenLimiter = class extends memory.MemoryProcessor {
|
|
|
9536
9532
|
}
|
|
9537
9533
|
}
|
|
9538
9534
|
}
|
|
9539
|
-
if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
|
|
9540
|
-
message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
|
|
9541
|
-
overhead += this.TOKENS_PER_MESSAGE;
|
|
9542
|
-
}
|
|
9543
|
-
return this.encoder.encode(tokenString).length + overhead;
|
|
9544
|
-
}
|
|
9535
|
+
if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
|
|
9536
|
+
message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
|
|
9537
|
+
overhead += this.TOKENS_PER_MESSAGE;
|
|
9538
|
+
}
|
|
9539
|
+
return this.encoder.encode(tokenString).length + overhead;
|
|
9540
|
+
}
|
|
9541
|
+
};
|
|
9542
|
+
|
|
9543
|
+
// ../agent-builder/dist/index.js
|
|
9544
|
+
var import_ignore = chunkEMMSS5I5_cjs.__toESM(require_ignore(), 1);
|
|
9545
|
+
var createIdGenerator3 = ({
|
|
9546
|
+
prefix,
|
|
9547
|
+
size = 16,
|
|
9548
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
9549
|
+
separator = "-"
|
|
9550
|
+
} = {}) => {
|
|
9551
|
+
const generator = () => {
|
|
9552
|
+
const alphabetLength = alphabet.length;
|
|
9553
|
+
const chars = new Array(size);
|
|
9554
|
+
for (let i = 0; i < size; i++) {
|
|
9555
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
9556
|
+
}
|
|
9557
|
+
return chars.join("");
|
|
9558
|
+
};
|
|
9559
|
+
if (prefix == null) {
|
|
9560
|
+
return generator;
|
|
9561
|
+
}
|
|
9562
|
+
if (alphabet.includes(separator)) {
|
|
9563
|
+
throw new chunkHVBBFCDH_cjs.InvalidArgumentError({
|
|
9564
|
+
argument: "separator",
|
|
9565
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
9566
|
+
});
|
|
9567
|
+
}
|
|
9568
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
9569
|
+
};
|
|
9570
|
+
createIdGenerator3();
|
|
9571
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
9572
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
9573
|
+
function _parse2(text4) {
|
|
9574
|
+
const obj = JSON.parse(text4);
|
|
9575
|
+
if (obj === null || typeof obj !== "object") {
|
|
9576
|
+
return obj;
|
|
9577
|
+
}
|
|
9578
|
+
if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
|
|
9579
|
+
return obj;
|
|
9580
|
+
}
|
|
9581
|
+
return filter2(obj);
|
|
9582
|
+
}
|
|
9583
|
+
function filter2(obj) {
|
|
9584
|
+
let next = [obj];
|
|
9585
|
+
while (next.length) {
|
|
9586
|
+
const nodes = next;
|
|
9587
|
+
next = [];
|
|
9588
|
+
for (const node of nodes) {
|
|
9589
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
9590
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9591
|
+
}
|
|
9592
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
9593
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
9594
|
+
}
|
|
9595
|
+
for (const key in node) {
|
|
9596
|
+
const value = node[key];
|
|
9597
|
+
if (value && typeof value === "object") {
|
|
9598
|
+
next.push(value);
|
|
9599
|
+
}
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
}
|
|
9603
|
+
return obj;
|
|
9604
|
+
}
|
|
9605
|
+
function secureJsonParse2(text4) {
|
|
9606
|
+
const { stackTraceLimit } = Error;
|
|
9607
|
+
Error.stackTraceLimit = 0;
|
|
9608
|
+
try {
|
|
9609
|
+
return _parse2(text4);
|
|
9610
|
+
} finally {
|
|
9611
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
9612
|
+
}
|
|
9613
|
+
}
|
|
9614
|
+
var validatorSymbol3 = Symbol.for("vercel.ai.validator");
|
|
9615
|
+
function validator2(validate) {
|
|
9616
|
+
return { [validatorSymbol3]: true, validate };
|
|
9617
|
+
}
|
|
9618
|
+
function isValidator2(value) {
|
|
9619
|
+
return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
|
|
9620
|
+
}
|
|
9621
|
+
function asValidator2(value) {
|
|
9622
|
+
return isValidator2(value) ? value : standardSchemaValidator2(value);
|
|
9623
|
+
}
|
|
9624
|
+
function standardSchemaValidator2(standardSchema) {
|
|
9625
|
+
return validator2(async (value) => {
|
|
9626
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
9627
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
9628
|
+
success: false,
|
|
9629
|
+
error: new chunkHVBBFCDH_cjs.TypeValidationError({
|
|
9630
|
+
value,
|
|
9631
|
+
cause: result.issues
|
|
9632
|
+
})
|
|
9633
|
+
};
|
|
9634
|
+
});
|
|
9635
|
+
}
|
|
9636
|
+
async function safeValidateTypes3({
|
|
9637
|
+
value,
|
|
9638
|
+
schema
|
|
9639
|
+
}) {
|
|
9640
|
+
const validator22 = asValidator2(schema);
|
|
9641
|
+
try {
|
|
9642
|
+
if (validator22.validate == null) {
|
|
9643
|
+
return { success: true, value, rawValue: value };
|
|
9644
|
+
}
|
|
9645
|
+
const result = await validator22.validate(value);
|
|
9646
|
+
if (result.success) {
|
|
9647
|
+
return { success: true, value: result.value, rawValue: value };
|
|
9648
|
+
}
|
|
9649
|
+
return {
|
|
9650
|
+
success: false,
|
|
9651
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: result.error }),
|
|
9652
|
+
rawValue: value
|
|
9653
|
+
};
|
|
9654
|
+
} catch (error) {
|
|
9655
|
+
return {
|
|
9656
|
+
success: false,
|
|
9657
|
+
error: chunkHVBBFCDH_cjs.TypeValidationError.wrap({ value, cause: error }),
|
|
9658
|
+
rawValue: value
|
|
9659
|
+
};
|
|
9660
|
+
}
|
|
9661
|
+
}
|
|
9662
|
+
async function safeParseJSON3({
|
|
9663
|
+
text: text4,
|
|
9664
|
+
schema
|
|
9665
|
+
}) {
|
|
9666
|
+
try {
|
|
9667
|
+
const value = secureJsonParse2(text4);
|
|
9668
|
+
if (schema == null) {
|
|
9669
|
+
return { success: true, value, rawValue: value };
|
|
9670
|
+
}
|
|
9671
|
+
return await safeValidateTypes3({ value, schema });
|
|
9672
|
+
} catch (error) {
|
|
9673
|
+
return {
|
|
9674
|
+
success: false,
|
|
9675
|
+
error: chunkHVBBFCDH_cjs.JSONParseError.isInstance(error) ? error : new chunkHVBBFCDH_cjs.JSONParseError({ text: text4, cause: error }),
|
|
9676
|
+
rawValue: void 0
|
|
9677
|
+
};
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
9681
|
+
let i = 0;
|
|
9682
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
9683
|
+
if (pathA[i] !== pathB[i])
|
|
9684
|
+
break;
|
|
9685
|
+
}
|
|
9686
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
9687
|
+
};
|
|
9688
|
+
var ignoreOverride2 = Symbol(
|
|
9689
|
+
"Let zodToJsonSchema decide on which parser to use"
|
|
9690
|
+
);
|
|
9691
|
+
var defaultOptions2 = {
|
|
9692
|
+
name: void 0,
|
|
9693
|
+
$refStrategy: "root",
|
|
9694
|
+
basePath: ["#"],
|
|
9695
|
+
effectStrategy: "input",
|
|
9696
|
+
pipeStrategy: "all",
|
|
9697
|
+
dateStrategy: "format:date-time",
|
|
9698
|
+
mapStrategy: "entries",
|
|
9699
|
+
removeAdditionalStrategy: "passthrough",
|
|
9700
|
+
allowedAdditionalProperties: true,
|
|
9701
|
+
rejectedAdditionalProperties: false,
|
|
9702
|
+
definitionPath: "definitions",
|
|
9703
|
+
strictUnions: false,
|
|
9704
|
+
definitions: {},
|
|
9705
|
+
errorMessages: false,
|
|
9706
|
+
patternStrategy: "escape",
|
|
9707
|
+
applyRegexFlags: false,
|
|
9708
|
+
emailStrategy: "format:email",
|
|
9709
|
+
base64Strategy: "contentEncoding:base64",
|
|
9710
|
+
nameStrategy: "ref"
|
|
9711
|
+
};
|
|
9712
|
+
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
9713
|
+
...defaultOptions2,
|
|
9714
|
+
name: options
|
|
9715
|
+
} : {
|
|
9716
|
+
...defaultOptions2,
|
|
9717
|
+
...options
|
|
9718
|
+
};
|
|
9719
|
+
function parseAnyDef2() {
|
|
9720
|
+
return {};
|
|
9721
|
+
}
|
|
9722
|
+
function parseArrayDef2(def, refs) {
|
|
9723
|
+
var _a20, _b8, _c;
|
|
9724
|
+
const res = {
|
|
9725
|
+
type: "array"
|
|
9726
|
+
};
|
|
9727
|
+
if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
9728
|
+
res.items = parseDef2(def.type._def, {
|
|
9729
|
+
...refs,
|
|
9730
|
+
currentPath: [...refs.currentPath, "items"]
|
|
9731
|
+
});
|
|
9732
|
+
}
|
|
9733
|
+
if (def.minLength) {
|
|
9734
|
+
res.minItems = def.minLength.value;
|
|
9735
|
+
}
|
|
9736
|
+
if (def.maxLength) {
|
|
9737
|
+
res.maxItems = def.maxLength.value;
|
|
9738
|
+
}
|
|
9739
|
+
if (def.exactLength) {
|
|
9740
|
+
res.minItems = def.exactLength.value;
|
|
9741
|
+
res.maxItems = def.exactLength.value;
|
|
9742
|
+
}
|
|
9743
|
+
return res;
|
|
9744
|
+
}
|
|
9745
|
+
function parseBigintDef2(def) {
|
|
9746
|
+
const res = {
|
|
9747
|
+
type: "integer",
|
|
9748
|
+
format: "int64"
|
|
9749
|
+
};
|
|
9750
|
+
if (!def.checks)
|
|
9751
|
+
return res;
|
|
9752
|
+
for (const check of def.checks) {
|
|
9753
|
+
switch (check.kind) {
|
|
9754
|
+
case "min":
|
|
9755
|
+
if (check.inclusive) {
|
|
9756
|
+
res.minimum = check.value;
|
|
9757
|
+
} else {
|
|
9758
|
+
res.exclusiveMinimum = check.value;
|
|
9759
|
+
}
|
|
9760
|
+
break;
|
|
9761
|
+
case "max":
|
|
9762
|
+
if (check.inclusive) {
|
|
9763
|
+
res.maximum = check.value;
|
|
9764
|
+
} else {
|
|
9765
|
+
res.exclusiveMaximum = check.value;
|
|
9766
|
+
}
|
|
9767
|
+
break;
|
|
9768
|
+
case "multipleOf":
|
|
9769
|
+
res.multipleOf = check.value;
|
|
9770
|
+
break;
|
|
9771
|
+
}
|
|
9772
|
+
}
|
|
9773
|
+
return res;
|
|
9774
|
+
}
|
|
9775
|
+
function parseBooleanDef2() {
|
|
9776
|
+
return { type: "boolean" };
|
|
9777
|
+
}
|
|
9778
|
+
function parseBrandedDef2(_def, refs) {
|
|
9779
|
+
return parseDef2(_def.type._def, refs);
|
|
9780
|
+
}
|
|
9781
|
+
var parseCatchDef2 = (def, refs) => {
|
|
9782
|
+
return parseDef2(def.innerType._def, refs);
|
|
9783
|
+
};
|
|
9784
|
+
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
9785
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
9786
|
+
if (Array.isArray(strategy)) {
|
|
9787
|
+
return {
|
|
9788
|
+
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
9789
|
+
};
|
|
9790
|
+
}
|
|
9791
|
+
switch (strategy) {
|
|
9792
|
+
case "string":
|
|
9793
|
+
case "format:date-time":
|
|
9794
|
+
return {
|
|
9795
|
+
type: "string",
|
|
9796
|
+
format: "date-time"
|
|
9797
|
+
};
|
|
9798
|
+
case "format:date":
|
|
9799
|
+
return {
|
|
9800
|
+
type: "string",
|
|
9801
|
+
format: "date"
|
|
9802
|
+
};
|
|
9803
|
+
case "integer":
|
|
9804
|
+
return integerDateParser2(def);
|
|
9805
|
+
}
|
|
9806
|
+
}
|
|
9807
|
+
var integerDateParser2 = (def) => {
|
|
9808
|
+
const res = {
|
|
9809
|
+
type: "integer",
|
|
9810
|
+
format: "unix-time"
|
|
9811
|
+
};
|
|
9812
|
+
for (const check of def.checks) {
|
|
9813
|
+
switch (check.kind) {
|
|
9814
|
+
case "min":
|
|
9815
|
+
res.minimum = check.value;
|
|
9816
|
+
break;
|
|
9817
|
+
case "max":
|
|
9818
|
+
res.maximum = check.value;
|
|
9819
|
+
break;
|
|
9820
|
+
}
|
|
9821
|
+
}
|
|
9822
|
+
return res;
|
|
9823
|
+
};
|
|
9824
|
+
function parseDefaultDef2(_def, refs) {
|
|
9825
|
+
return {
|
|
9826
|
+
...parseDef2(_def.innerType._def, refs),
|
|
9827
|
+
default: _def.defaultValue()
|
|
9828
|
+
};
|
|
9829
|
+
}
|
|
9830
|
+
function parseEffectsDef2(_def, refs) {
|
|
9831
|
+
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
|
|
9832
|
+
}
|
|
9833
|
+
function parseEnumDef2(def) {
|
|
9834
|
+
return {
|
|
9835
|
+
type: "string",
|
|
9836
|
+
enum: Array.from(def.values)
|
|
9837
|
+
};
|
|
9838
|
+
}
|
|
9839
|
+
var isJsonSchema7AllOfType2 = (type) => {
|
|
9840
|
+
if ("type" in type && type.type === "string")
|
|
9841
|
+
return false;
|
|
9842
|
+
return "allOf" in type;
|
|
9843
|
+
};
|
|
9844
|
+
function parseIntersectionDef2(def, refs) {
|
|
9845
|
+
const allOf = [
|
|
9846
|
+
parseDef2(def.left._def, {
|
|
9847
|
+
...refs,
|
|
9848
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
9849
|
+
}),
|
|
9850
|
+
parseDef2(def.right._def, {
|
|
9851
|
+
...refs,
|
|
9852
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
9853
|
+
})
|
|
9854
|
+
].filter((x) => !!x);
|
|
9855
|
+
const mergedAllOf = [];
|
|
9856
|
+
allOf.forEach((schema) => {
|
|
9857
|
+
if (isJsonSchema7AllOfType2(schema)) {
|
|
9858
|
+
mergedAllOf.push(...schema.allOf);
|
|
9859
|
+
} else {
|
|
9860
|
+
let nestedSchema = schema;
|
|
9861
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
9862
|
+
const { additionalProperties, ...rest } = schema;
|
|
9863
|
+
nestedSchema = rest;
|
|
9864
|
+
}
|
|
9865
|
+
mergedAllOf.push(nestedSchema);
|
|
9866
|
+
}
|
|
9867
|
+
});
|
|
9868
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
|
|
9869
|
+
}
|
|
9870
|
+
function parseLiteralDef2(def) {
|
|
9871
|
+
const parsedType = typeof def.value;
|
|
9872
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
9873
|
+
return {
|
|
9874
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9877
|
+
return {
|
|
9878
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
9879
|
+
const: def.value
|
|
9880
|
+
};
|
|
9881
|
+
}
|
|
9882
|
+
var emojiRegex2 = void 0;
|
|
9883
|
+
var zodPatterns2 = {
|
|
9884
|
+
/**
|
|
9885
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
9886
|
+
*/
|
|
9887
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
9888
|
+
cuid2: /^[0-9a-z]+$/,
|
|
9889
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
9890
|
+
/**
|
|
9891
|
+
* `a-z` was added to replicate /i flag
|
|
9892
|
+
*/
|
|
9893
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
9894
|
+
/**
|
|
9895
|
+
* Constructed a valid Unicode RegExp
|
|
9896
|
+
*
|
|
9897
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
9898
|
+
* in all envs (e.g. React Native).
|
|
9899
|
+
*
|
|
9900
|
+
* See:
|
|
9901
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
9902
|
+
* Fix in Zod:
|
|
9903
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
9904
|
+
*/
|
|
9905
|
+
emoji: () => {
|
|
9906
|
+
if (emojiRegex2 === void 0) {
|
|
9907
|
+
emojiRegex2 = RegExp(
|
|
9908
|
+
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
9909
|
+
"u"
|
|
9910
|
+
);
|
|
9911
|
+
}
|
|
9912
|
+
return emojiRegex2;
|
|
9913
|
+
},
|
|
9914
|
+
/**
|
|
9915
|
+
* Unused
|
|
9916
|
+
*/
|
|
9917
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
9918
|
+
/**
|
|
9919
|
+
* Unused
|
|
9920
|
+
*/
|
|
9921
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
9922
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
9923
|
+
/**
|
|
9924
|
+
* Unused
|
|
9925
|
+
*/
|
|
9926
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
9927
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
9928
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
9929
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
9930
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
9931
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
9932
|
+
};
|
|
9933
|
+
function parseStringDef2(def, refs) {
|
|
9934
|
+
const res = {
|
|
9935
|
+
type: "string"
|
|
9936
|
+
};
|
|
9937
|
+
if (def.checks) {
|
|
9938
|
+
for (const check of def.checks) {
|
|
9939
|
+
switch (check.kind) {
|
|
9940
|
+
case "min":
|
|
9941
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
9942
|
+
break;
|
|
9943
|
+
case "max":
|
|
9944
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
9945
|
+
break;
|
|
9946
|
+
case "email":
|
|
9947
|
+
switch (refs.emailStrategy) {
|
|
9948
|
+
case "format:email":
|
|
9949
|
+
addFormat2(res, "email", check.message, refs);
|
|
9950
|
+
break;
|
|
9951
|
+
case "format:idn-email":
|
|
9952
|
+
addFormat2(res, "idn-email", check.message, refs);
|
|
9953
|
+
break;
|
|
9954
|
+
case "pattern:zod":
|
|
9955
|
+
addPattern2(res, zodPatterns2.email, check.message, refs);
|
|
9956
|
+
break;
|
|
9957
|
+
}
|
|
9958
|
+
break;
|
|
9959
|
+
case "url":
|
|
9960
|
+
addFormat2(res, "uri", check.message, refs);
|
|
9961
|
+
break;
|
|
9962
|
+
case "uuid":
|
|
9963
|
+
addFormat2(res, "uuid", check.message, refs);
|
|
9964
|
+
break;
|
|
9965
|
+
case "regex":
|
|
9966
|
+
addPattern2(res, check.regex, check.message, refs);
|
|
9967
|
+
break;
|
|
9968
|
+
case "cuid":
|
|
9969
|
+
addPattern2(res, zodPatterns2.cuid, check.message, refs);
|
|
9970
|
+
break;
|
|
9971
|
+
case "cuid2":
|
|
9972
|
+
addPattern2(res, zodPatterns2.cuid2, check.message, refs);
|
|
9973
|
+
break;
|
|
9974
|
+
case "startsWith":
|
|
9975
|
+
addPattern2(
|
|
9976
|
+
res,
|
|
9977
|
+
RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`),
|
|
9978
|
+
check.message,
|
|
9979
|
+
refs
|
|
9980
|
+
);
|
|
9981
|
+
break;
|
|
9982
|
+
case "endsWith":
|
|
9983
|
+
addPattern2(
|
|
9984
|
+
res,
|
|
9985
|
+
RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`),
|
|
9986
|
+
check.message,
|
|
9987
|
+
refs
|
|
9988
|
+
);
|
|
9989
|
+
break;
|
|
9990
|
+
case "datetime":
|
|
9991
|
+
addFormat2(res, "date-time", check.message, refs);
|
|
9992
|
+
break;
|
|
9993
|
+
case "date":
|
|
9994
|
+
addFormat2(res, "date", check.message, refs);
|
|
9995
|
+
break;
|
|
9996
|
+
case "time":
|
|
9997
|
+
addFormat2(res, "time", check.message, refs);
|
|
9998
|
+
break;
|
|
9999
|
+
case "duration":
|
|
10000
|
+
addFormat2(res, "duration", check.message, refs);
|
|
10001
|
+
break;
|
|
10002
|
+
case "length":
|
|
10003
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
10004
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
10005
|
+
break;
|
|
10006
|
+
case "includes": {
|
|
10007
|
+
addPattern2(
|
|
10008
|
+
res,
|
|
10009
|
+
RegExp(escapeLiteralCheckValue2(check.value, refs)),
|
|
10010
|
+
check.message,
|
|
10011
|
+
refs
|
|
10012
|
+
);
|
|
10013
|
+
break;
|
|
10014
|
+
}
|
|
10015
|
+
case "ip": {
|
|
10016
|
+
if (check.version !== "v6") {
|
|
10017
|
+
addFormat2(res, "ipv4", check.message, refs);
|
|
10018
|
+
}
|
|
10019
|
+
if (check.version !== "v4") {
|
|
10020
|
+
addFormat2(res, "ipv6", check.message, refs);
|
|
10021
|
+
}
|
|
10022
|
+
break;
|
|
10023
|
+
}
|
|
10024
|
+
case "base64url":
|
|
10025
|
+
addPattern2(res, zodPatterns2.base64url, check.message, refs);
|
|
10026
|
+
break;
|
|
10027
|
+
case "jwt":
|
|
10028
|
+
addPattern2(res, zodPatterns2.jwt, check.message, refs);
|
|
10029
|
+
break;
|
|
10030
|
+
case "cidr": {
|
|
10031
|
+
if (check.version !== "v6") {
|
|
10032
|
+
addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
|
|
10033
|
+
}
|
|
10034
|
+
if (check.version !== "v4") {
|
|
10035
|
+
addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
|
|
10036
|
+
}
|
|
10037
|
+
break;
|
|
10038
|
+
}
|
|
10039
|
+
case "emoji":
|
|
10040
|
+
addPattern2(res, zodPatterns2.emoji(), check.message, refs);
|
|
10041
|
+
break;
|
|
10042
|
+
case "ulid": {
|
|
10043
|
+
addPattern2(res, zodPatterns2.ulid, check.message, refs);
|
|
10044
|
+
break;
|
|
10045
|
+
}
|
|
10046
|
+
case "base64": {
|
|
10047
|
+
switch (refs.base64Strategy) {
|
|
10048
|
+
case "format:binary": {
|
|
10049
|
+
addFormat2(res, "binary", check.message, refs);
|
|
10050
|
+
break;
|
|
10051
|
+
}
|
|
10052
|
+
case "contentEncoding:base64": {
|
|
10053
|
+
res.contentEncoding = "base64";
|
|
10054
|
+
break;
|
|
10055
|
+
}
|
|
10056
|
+
case "pattern:zod": {
|
|
10057
|
+
addPattern2(res, zodPatterns2.base64, check.message, refs);
|
|
10058
|
+
break;
|
|
10059
|
+
}
|
|
10060
|
+
}
|
|
10061
|
+
break;
|
|
10062
|
+
}
|
|
10063
|
+
case "nanoid": {
|
|
10064
|
+
addPattern2(res, zodPatterns2.nanoid, check.message, refs);
|
|
10065
|
+
}
|
|
10066
|
+
}
|
|
10067
|
+
}
|
|
10068
|
+
}
|
|
10069
|
+
return res;
|
|
10070
|
+
}
|
|
10071
|
+
function escapeLiteralCheckValue2(literal, refs) {
|
|
10072
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
|
|
10073
|
+
}
|
|
10074
|
+
var ALPHA_NUMERIC2 = new Set(
|
|
10075
|
+
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
10076
|
+
);
|
|
10077
|
+
function escapeNonAlphaNumeric2(source) {
|
|
10078
|
+
let result = "";
|
|
10079
|
+
for (let i = 0; i < source.length; i++) {
|
|
10080
|
+
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
10081
|
+
result += "\\";
|
|
10082
|
+
}
|
|
10083
|
+
result += source[i];
|
|
10084
|
+
}
|
|
10085
|
+
return result;
|
|
10086
|
+
}
|
|
10087
|
+
function addFormat2(schema, value, message, refs) {
|
|
10088
|
+
var _a20;
|
|
10089
|
+
if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
|
|
10090
|
+
if (!schema.anyOf) {
|
|
10091
|
+
schema.anyOf = [];
|
|
10092
|
+
}
|
|
10093
|
+
if (schema.format) {
|
|
10094
|
+
schema.anyOf.push({
|
|
10095
|
+
format: schema.format
|
|
10096
|
+
});
|
|
10097
|
+
delete schema.format;
|
|
10098
|
+
}
|
|
10099
|
+
schema.anyOf.push({
|
|
10100
|
+
format: value,
|
|
10101
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
10102
|
+
});
|
|
10103
|
+
} else {
|
|
10104
|
+
schema.format = value;
|
|
10105
|
+
}
|
|
10106
|
+
}
|
|
10107
|
+
function addPattern2(schema, regex, message, refs) {
|
|
10108
|
+
var _a20;
|
|
10109
|
+
if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
|
|
10110
|
+
if (!schema.allOf) {
|
|
10111
|
+
schema.allOf = [];
|
|
10112
|
+
}
|
|
10113
|
+
if (schema.pattern) {
|
|
10114
|
+
schema.allOf.push({
|
|
10115
|
+
pattern: schema.pattern
|
|
10116
|
+
});
|
|
10117
|
+
delete schema.pattern;
|
|
10118
|
+
}
|
|
10119
|
+
schema.allOf.push({
|
|
10120
|
+
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
10121
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
10122
|
+
});
|
|
10123
|
+
} else {
|
|
10124
|
+
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
10125
|
+
}
|
|
10126
|
+
}
|
|
10127
|
+
function stringifyRegExpWithFlags2(regex, refs) {
|
|
10128
|
+
var _a20;
|
|
10129
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
10130
|
+
return regex.source;
|
|
10131
|
+
}
|
|
10132
|
+
const flags = {
|
|
10133
|
+
i: regex.flags.includes("i"),
|
|
10134
|
+
// Case-insensitive
|
|
10135
|
+
m: regex.flags.includes("m"),
|
|
10136
|
+
// `^` and `$` matches adjacent to newline characters
|
|
10137
|
+
s: regex.flags.includes("s")
|
|
10138
|
+
// `.` matches newlines
|
|
10139
|
+
};
|
|
10140
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
10141
|
+
let pattern = "";
|
|
10142
|
+
let isEscaped = false;
|
|
10143
|
+
let inCharGroup = false;
|
|
10144
|
+
let inCharRange = false;
|
|
10145
|
+
for (let i = 0; i < source.length; i++) {
|
|
10146
|
+
if (isEscaped) {
|
|
10147
|
+
pattern += source[i];
|
|
10148
|
+
isEscaped = false;
|
|
10149
|
+
continue;
|
|
10150
|
+
}
|
|
10151
|
+
if (flags.i) {
|
|
10152
|
+
if (inCharGroup) {
|
|
10153
|
+
if (source[i].match(/[a-z]/)) {
|
|
10154
|
+
if (inCharRange) {
|
|
10155
|
+
pattern += source[i];
|
|
10156
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
10157
|
+
inCharRange = false;
|
|
10158
|
+
} else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
|
|
10159
|
+
pattern += source[i];
|
|
10160
|
+
inCharRange = true;
|
|
10161
|
+
} else {
|
|
10162
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
10163
|
+
}
|
|
10164
|
+
continue;
|
|
10165
|
+
}
|
|
10166
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
10167
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
10168
|
+
continue;
|
|
10169
|
+
}
|
|
10170
|
+
}
|
|
10171
|
+
if (flags.m) {
|
|
10172
|
+
if (source[i] === "^") {
|
|
10173
|
+
pattern += `(^|(?<=[\r
|
|
10174
|
+
]))`;
|
|
10175
|
+
continue;
|
|
10176
|
+
} else if (source[i] === "$") {
|
|
10177
|
+
pattern += `($|(?=[\r
|
|
10178
|
+
]))`;
|
|
10179
|
+
continue;
|
|
10180
|
+
}
|
|
10181
|
+
}
|
|
10182
|
+
if (flags.s && source[i] === ".") {
|
|
10183
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
10184
|
+
` : `[${source[i]}\r
|
|
10185
|
+
]`;
|
|
10186
|
+
continue;
|
|
10187
|
+
}
|
|
10188
|
+
pattern += source[i];
|
|
10189
|
+
if (source[i] === "\\") {
|
|
10190
|
+
isEscaped = true;
|
|
10191
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
10192
|
+
inCharGroup = false;
|
|
10193
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
10194
|
+
inCharGroup = true;
|
|
10195
|
+
}
|
|
10196
|
+
}
|
|
10197
|
+
return pattern;
|
|
10198
|
+
}
|
|
10199
|
+
function parseRecordDef2(def, refs) {
|
|
10200
|
+
var _a20, _b8, _c, _d, _e, _f;
|
|
10201
|
+
const schema = {
|
|
10202
|
+
type: "object",
|
|
10203
|
+
additionalProperties: (_a20 = parseDef2(def.valueType._def, {
|
|
10204
|
+
...refs,
|
|
10205
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10206
|
+
})) != null ? _a20 : refs.allowedAdditionalProperties
|
|
10207
|
+
};
|
|
10208
|
+
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
10209
|
+
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
10210
|
+
return {
|
|
10211
|
+
...schema,
|
|
10212
|
+
propertyNames: keyType
|
|
10213
|
+
};
|
|
10214
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === v3.ZodFirstPartyTypeKind.ZodEnum) {
|
|
10215
|
+
return {
|
|
10216
|
+
...schema,
|
|
10217
|
+
propertyNames: {
|
|
10218
|
+
enum: def.keyType._def.values
|
|
10219
|
+
}
|
|
10220
|
+
};
|
|
10221
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
10222
|
+
const { type, ...keyType } = parseBrandedDef2(
|
|
10223
|
+
def.keyType._def,
|
|
10224
|
+
refs
|
|
10225
|
+
);
|
|
10226
|
+
return {
|
|
10227
|
+
...schema,
|
|
10228
|
+
propertyNames: keyType
|
|
10229
|
+
};
|
|
10230
|
+
}
|
|
10231
|
+
return schema;
|
|
10232
|
+
}
|
|
10233
|
+
function parseMapDef2(def, refs) {
|
|
10234
|
+
if (refs.mapStrategy === "record") {
|
|
10235
|
+
return parseRecordDef2(def, refs);
|
|
10236
|
+
}
|
|
10237
|
+
const keys = parseDef2(def.keyType._def, {
|
|
10238
|
+
...refs,
|
|
10239
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
10240
|
+
}) || parseAnyDef2();
|
|
10241
|
+
const values = parseDef2(def.valueType._def, {
|
|
10242
|
+
...refs,
|
|
10243
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
10244
|
+
}) || parseAnyDef2();
|
|
10245
|
+
return {
|
|
10246
|
+
type: "array",
|
|
10247
|
+
maxItems: 125,
|
|
10248
|
+
items: {
|
|
10249
|
+
type: "array",
|
|
10250
|
+
items: [keys, values],
|
|
10251
|
+
minItems: 2,
|
|
10252
|
+
maxItems: 2
|
|
10253
|
+
}
|
|
10254
|
+
};
|
|
10255
|
+
}
|
|
10256
|
+
function parseNativeEnumDef2(def) {
|
|
10257
|
+
const object4 = def.values;
|
|
10258
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
10259
|
+
return typeof object4[object4[key]] !== "number";
|
|
10260
|
+
});
|
|
10261
|
+
const actualValues = actualKeys.map((key) => object4[key]);
|
|
10262
|
+
const parsedTypes = Array.from(
|
|
10263
|
+
new Set(actualValues.map((values) => typeof values))
|
|
10264
|
+
);
|
|
10265
|
+
return {
|
|
10266
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
10267
|
+
enum: actualValues
|
|
10268
|
+
};
|
|
10269
|
+
}
|
|
10270
|
+
function parseNeverDef2() {
|
|
10271
|
+
return { not: parseAnyDef2() };
|
|
10272
|
+
}
|
|
10273
|
+
function parseNullDef2() {
|
|
10274
|
+
return {
|
|
10275
|
+
type: "null"
|
|
10276
|
+
};
|
|
10277
|
+
}
|
|
10278
|
+
var primitiveMappings2 = {
|
|
10279
|
+
ZodString: "string",
|
|
10280
|
+
ZodNumber: "number",
|
|
10281
|
+
ZodBigInt: "integer",
|
|
10282
|
+
ZodBoolean: "boolean",
|
|
10283
|
+
ZodNull: "null"
|
|
10284
|
+
};
|
|
10285
|
+
function parseUnionDef2(def, refs) {
|
|
10286
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
10287
|
+
if (options.every(
|
|
10288
|
+
(x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length)
|
|
10289
|
+
)) {
|
|
10290
|
+
const types = options.reduce((types2, x) => {
|
|
10291
|
+
const type = primitiveMappings2[x._def.typeName];
|
|
10292
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
10293
|
+
}, []);
|
|
10294
|
+
return {
|
|
10295
|
+
type: types.length > 1 ? types : types[0]
|
|
10296
|
+
};
|
|
10297
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
10298
|
+
const types = options.reduce(
|
|
10299
|
+
(acc, x) => {
|
|
10300
|
+
const type = typeof x._def.value;
|
|
10301
|
+
switch (type) {
|
|
10302
|
+
case "string":
|
|
10303
|
+
case "number":
|
|
10304
|
+
case "boolean":
|
|
10305
|
+
return [...acc, type];
|
|
10306
|
+
case "bigint":
|
|
10307
|
+
return [...acc, "integer"];
|
|
10308
|
+
case "object":
|
|
10309
|
+
if (x._def.value === null)
|
|
10310
|
+
return [...acc, "null"];
|
|
10311
|
+
case "symbol":
|
|
10312
|
+
case "undefined":
|
|
10313
|
+
case "function":
|
|
10314
|
+
default:
|
|
10315
|
+
return acc;
|
|
10316
|
+
}
|
|
10317
|
+
},
|
|
10318
|
+
[]
|
|
10319
|
+
);
|
|
10320
|
+
if (types.length === options.length) {
|
|
10321
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
10322
|
+
return {
|
|
10323
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
10324
|
+
enum: options.reduce(
|
|
10325
|
+
(acc, x) => {
|
|
10326
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
10327
|
+
},
|
|
10328
|
+
[]
|
|
10329
|
+
)
|
|
10330
|
+
};
|
|
10331
|
+
}
|
|
10332
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
10333
|
+
return {
|
|
10334
|
+
type: "string",
|
|
10335
|
+
enum: options.reduce(
|
|
10336
|
+
(acc, x) => [
|
|
10337
|
+
...acc,
|
|
10338
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
10339
|
+
],
|
|
10340
|
+
[]
|
|
10341
|
+
)
|
|
10342
|
+
};
|
|
10343
|
+
}
|
|
10344
|
+
return asAnyOf2(def, refs);
|
|
10345
|
+
}
|
|
10346
|
+
var asAnyOf2 = (def, refs) => {
|
|
10347
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
|
|
10348
|
+
(x, i) => parseDef2(x._def, {
|
|
10349
|
+
...refs,
|
|
10350
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
10351
|
+
})
|
|
10352
|
+
).filter(
|
|
10353
|
+
(x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
|
|
10354
|
+
);
|
|
10355
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
10356
|
+
};
|
|
10357
|
+
function parseNullableDef2(def, refs) {
|
|
10358
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
10359
|
+
def.innerType._def.typeName
|
|
10360
|
+
) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
10361
|
+
return {
|
|
10362
|
+
type: [
|
|
10363
|
+
primitiveMappings2[def.innerType._def.typeName],
|
|
10364
|
+
"null"
|
|
10365
|
+
]
|
|
10366
|
+
};
|
|
10367
|
+
}
|
|
10368
|
+
const base = parseDef2(def.innerType._def, {
|
|
10369
|
+
...refs,
|
|
10370
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
10371
|
+
});
|
|
10372
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
10373
|
+
}
|
|
10374
|
+
function parseNumberDef2(def) {
|
|
10375
|
+
const res = {
|
|
10376
|
+
type: "number"
|
|
10377
|
+
};
|
|
10378
|
+
if (!def.checks)
|
|
10379
|
+
return res;
|
|
10380
|
+
for (const check of def.checks) {
|
|
10381
|
+
switch (check.kind) {
|
|
10382
|
+
case "int":
|
|
10383
|
+
res.type = "integer";
|
|
10384
|
+
break;
|
|
10385
|
+
case "min":
|
|
10386
|
+
if (check.inclusive) {
|
|
10387
|
+
res.minimum = check.value;
|
|
10388
|
+
} else {
|
|
10389
|
+
res.exclusiveMinimum = check.value;
|
|
10390
|
+
}
|
|
10391
|
+
break;
|
|
10392
|
+
case "max":
|
|
10393
|
+
if (check.inclusive) {
|
|
10394
|
+
res.maximum = check.value;
|
|
10395
|
+
} else {
|
|
10396
|
+
res.exclusiveMaximum = check.value;
|
|
10397
|
+
}
|
|
10398
|
+
break;
|
|
10399
|
+
case "multipleOf":
|
|
10400
|
+
res.multipleOf = check.value;
|
|
10401
|
+
break;
|
|
10402
|
+
}
|
|
10403
|
+
}
|
|
10404
|
+
return res;
|
|
10405
|
+
}
|
|
10406
|
+
function parseObjectDef2(def, refs) {
|
|
10407
|
+
const result = {
|
|
10408
|
+
type: "object",
|
|
10409
|
+
properties: {}
|
|
10410
|
+
};
|
|
10411
|
+
const required = [];
|
|
10412
|
+
const shape = def.shape();
|
|
10413
|
+
for (const propName in shape) {
|
|
10414
|
+
let propDef = shape[propName];
|
|
10415
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
10416
|
+
continue;
|
|
10417
|
+
}
|
|
10418
|
+
const propOptional = safeIsOptional2(propDef);
|
|
10419
|
+
const parsedDef = parseDef2(propDef._def, {
|
|
10420
|
+
...refs,
|
|
10421
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
10422
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
10423
|
+
});
|
|
10424
|
+
if (parsedDef === void 0) {
|
|
10425
|
+
continue;
|
|
10426
|
+
}
|
|
10427
|
+
result.properties[propName] = parsedDef;
|
|
10428
|
+
if (!propOptional) {
|
|
10429
|
+
required.push(propName);
|
|
10430
|
+
}
|
|
10431
|
+
}
|
|
10432
|
+
if (required.length) {
|
|
10433
|
+
result.required = required;
|
|
10434
|
+
}
|
|
10435
|
+
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
10436
|
+
if (additionalProperties !== void 0) {
|
|
10437
|
+
result.additionalProperties = additionalProperties;
|
|
10438
|
+
}
|
|
10439
|
+
return result;
|
|
10440
|
+
}
|
|
10441
|
+
function decideAdditionalProperties2(def, refs) {
|
|
10442
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
10443
|
+
return parseDef2(def.catchall._def, {
|
|
10444
|
+
...refs,
|
|
10445
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
10446
|
+
});
|
|
10447
|
+
}
|
|
10448
|
+
switch (def.unknownKeys) {
|
|
10449
|
+
case "passthrough":
|
|
10450
|
+
return refs.allowedAdditionalProperties;
|
|
10451
|
+
case "strict":
|
|
10452
|
+
return refs.rejectedAdditionalProperties;
|
|
10453
|
+
case "strip":
|
|
10454
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
10455
|
+
}
|
|
10456
|
+
}
|
|
10457
|
+
function safeIsOptional2(schema) {
|
|
10458
|
+
try {
|
|
10459
|
+
return schema.isOptional();
|
|
10460
|
+
} catch (e2) {
|
|
10461
|
+
return true;
|
|
10462
|
+
}
|
|
10463
|
+
}
|
|
10464
|
+
var parseOptionalDef2 = (def, refs) => {
|
|
10465
|
+
var _a20;
|
|
10466
|
+
if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
|
|
10467
|
+
return parseDef2(def.innerType._def, refs);
|
|
10468
|
+
}
|
|
10469
|
+
const innerSchema = parseDef2(def.innerType._def, {
|
|
10470
|
+
...refs,
|
|
10471
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
10472
|
+
});
|
|
10473
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
10474
|
+
};
|
|
10475
|
+
var parsePipelineDef2 = (def, refs) => {
|
|
10476
|
+
if (refs.pipeStrategy === "input") {
|
|
10477
|
+
return parseDef2(def.in._def, refs);
|
|
10478
|
+
} else if (refs.pipeStrategy === "output") {
|
|
10479
|
+
return parseDef2(def.out._def, refs);
|
|
10480
|
+
}
|
|
10481
|
+
const a = parseDef2(def.in._def, {
|
|
10482
|
+
...refs,
|
|
10483
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
10484
|
+
});
|
|
10485
|
+
const b = parseDef2(def.out._def, {
|
|
10486
|
+
...refs,
|
|
10487
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
10488
|
+
});
|
|
10489
|
+
return {
|
|
10490
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
10491
|
+
};
|
|
10492
|
+
};
|
|
10493
|
+
function parsePromiseDef2(def, refs) {
|
|
10494
|
+
return parseDef2(def.type._def, refs);
|
|
10495
|
+
}
|
|
10496
|
+
function parseSetDef2(def, refs) {
|
|
10497
|
+
const items = parseDef2(def.valueType._def, {
|
|
10498
|
+
...refs,
|
|
10499
|
+
currentPath: [...refs.currentPath, "items"]
|
|
10500
|
+
});
|
|
10501
|
+
const schema = {
|
|
10502
|
+
type: "array",
|
|
10503
|
+
uniqueItems: true,
|
|
10504
|
+
items
|
|
10505
|
+
};
|
|
10506
|
+
if (def.minSize) {
|
|
10507
|
+
schema.minItems = def.minSize.value;
|
|
10508
|
+
}
|
|
10509
|
+
if (def.maxSize) {
|
|
10510
|
+
schema.maxItems = def.maxSize.value;
|
|
10511
|
+
}
|
|
10512
|
+
return schema;
|
|
10513
|
+
}
|
|
10514
|
+
function parseTupleDef2(def, refs) {
|
|
10515
|
+
if (def.rest) {
|
|
10516
|
+
return {
|
|
10517
|
+
type: "array",
|
|
10518
|
+
minItems: def.items.length,
|
|
10519
|
+
items: def.items.map(
|
|
10520
|
+
(x, i) => parseDef2(x._def, {
|
|
10521
|
+
...refs,
|
|
10522
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10523
|
+
})
|
|
10524
|
+
).reduce(
|
|
10525
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10526
|
+
[]
|
|
10527
|
+
),
|
|
10528
|
+
additionalItems: parseDef2(def.rest._def, {
|
|
10529
|
+
...refs,
|
|
10530
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
10531
|
+
})
|
|
10532
|
+
};
|
|
10533
|
+
} else {
|
|
10534
|
+
return {
|
|
10535
|
+
type: "array",
|
|
10536
|
+
minItems: def.items.length,
|
|
10537
|
+
maxItems: def.items.length,
|
|
10538
|
+
items: def.items.map(
|
|
10539
|
+
(x, i) => parseDef2(x._def, {
|
|
10540
|
+
...refs,
|
|
10541
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
10542
|
+
})
|
|
10543
|
+
).reduce(
|
|
10544
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
10545
|
+
[]
|
|
10546
|
+
)
|
|
10547
|
+
};
|
|
10548
|
+
}
|
|
10549
|
+
}
|
|
10550
|
+
function parseUndefinedDef2() {
|
|
10551
|
+
return {
|
|
10552
|
+
not: parseAnyDef2()
|
|
10553
|
+
};
|
|
10554
|
+
}
|
|
10555
|
+
function parseUnknownDef2() {
|
|
10556
|
+
return parseAnyDef2();
|
|
10557
|
+
}
|
|
10558
|
+
var parseReadonlyDef2 = (def, refs) => {
|
|
10559
|
+
return parseDef2(def.innerType._def, refs);
|
|
10560
|
+
};
|
|
10561
|
+
var selectParser2 = (def, typeName, refs) => {
|
|
10562
|
+
switch (typeName) {
|
|
10563
|
+
case v3.ZodFirstPartyTypeKind.ZodString:
|
|
10564
|
+
return parseStringDef2(def, refs);
|
|
10565
|
+
case v3.ZodFirstPartyTypeKind.ZodNumber:
|
|
10566
|
+
return parseNumberDef2(def);
|
|
10567
|
+
case v3.ZodFirstPartyTypeKind.ZodObject:
|
|
10568
|
+
return parseObjectDef2(def, refs);
|
|
10569
|
+
case v3.ZodFirstPartyTypeKind.ZodBigInt:
|
|
10570
|
+
return parseBigintDef2(def);
|
|
10571
|
+
case v3.ZodFirstPartyTypeKind.ZodBoolean:
|
|
10572
|
+
return parseBooleanDef2();
|
|
10573
|
+
case v3.ZodFirstPartyTypeKind.ZodDate:
|
|
10574
|
+
return parseDateDef2(def, refs);
|
|
10575
|
+
case v3.ZodFirstPartyTypeKind.ZodUndefined:
|
|
10576
|
+
return parseUndefinedDef2();
|
|
10577
|
+
case v3.ZodFirstPartyTypeKind.ZodNull:
|
|
10578
|
+
return parseNullDef2();
|
|
10579
|
+
case v3.ZodFirstPartyTypeKind.ZodArray:
|
|
10580
|
+
return parseArrayDef2(def, refs);
|
|
10581
|
+
case v3.ZodFirstPartyTypeKind.ZodUnion:
|
|
10582
|
+
case v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
10583
|
+
return parseUnionDef2(def, refs);
|
|
10584
|
+
case v3.ZodFirstPartyTypeKind.ZodIntersection:
|
|
10585
|
+
return parseIntersectionDef2(def, refs);
|
|
10586
|
+
case v3.ZodFirstPartyTypeKind.ZodTuple:
|
|
10587
|
+
return parseTupleDef2(def, refs);
|
|
10588
|
+
case v3.ZodFirstPartyTypeKind.ZodRecord:
|
|
10589
|
+
return parseRecordDef2(def, refs);
|
|
10590
|
+
case v3.ZodFirstPartyTypeKind.ZodLiteral:
|
|
10591
|
+
return parseLiteralDef2(def);
|
|
10592
|
+
case v3.ZodFirstPartyTypeKind.ZodEnum:
|
|
10593
|
+
return parseEnumDef2(def);
|
|
10594
|
+
case v3.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
10595
|
+
return parseNativeEnumDef2(def);
|
|
10596
|
+
case v3.ZodFirstPartyTypeKind.ZodNullable:
|
|
10597
|
+
return parseNullableDef2(def, refs);
|
|
10598
|
+
case v3.ZodFirstPartyTypeKind.ZodOptional:
|
|
10599
|
+
return parseOptionalDef2(def, refs);
|
|
10600
|
+
case v3.ZodFirstPartyTypeKind.ZodMap:
|
|
10601
|
+
return parseMapDef2(def, refs);
|
|
10602
|
+
case v3.ZodFirstPartyTypeKind.ZodSet:
|
|
10603
|
+
return parseSetDef2(def, refs);
|
|
10604
|
+
case v3.ZodFirstPartyTypeKind.ZodLazy:
|
|
10605
|
+
return () => def.getter()._def;
|
|
10606
|
+
case v3.ZodFirstPartyTypeKind.ZodPromise:
|
|
10607
|
+
return parsePromiseDef2(def, refs);
|
|
10608
|
+
case v3.ZodFirstPartyTypeKind.ZodNaN:
|
|
10609
|
+
case v3.ZodFirstPartyTypeKind.ZodNever:
|
|
10610
|
+
return parseNeverDef2();
|
|
10611
|
+
case v3.ZodFirstPartyTypeKind.ZodEffects:
|
|
10612
|
+
return parseEffectsDef2(def, refs);
|
|
10613
|
+
case v3.ZodFirstPartyTypeKind.ZodAny:
|
|
10614
|
+
return parseAnyDef2();
|
|
10615
|
+
case v3.ZodFirstPartyTypeKind.ZodUnknown:
|
|
10616
|
+
return parseUnknownDef2();
|
|
10617
|
+
case v3.ZodFirstPartyTypeKind.ZodDefault:
|
|
10618
|
+
return parseDefaultDef2(def, refs);
|
|
10619
|
+
case v3.ZodFirstPartyTypeKind.ZodBranded:
|
|
10620
|
+
return parseBrandedDef2(def, refs);
|
|
10621
|
+
case v3.ZodFirstPartyTypeKind.ZodReadonly:
|
|
10622
|
+
return parseReadonlyDef2(def, refs);
|
|
10623
|
+
case v3.ZodFirstPartyTypeKind.ZodCatch:
|
|
10624
|
+
return parseCatchDef2(def, refs);
|
|
10625
|
+
case v3.ZodFirstPartyTypeKind.ZodPipeline:
|
|
10626
|
+
return parsePipelineDef2(def, refs);
|
|
10627
|
+
case v3.ZodFirstPartyTypeKind.ZodFunction:
|
|
10628
|
+
case v3.ZodFirstPartyTypeKind.ZodVoid:
|
|
10629
|
+
case v3.ZodFirstPartyTypeKind.ZodSymbol:
|
|
10630
|
+
return void 0;
|
|
10631
|
+
default:
|
|
10632
|
+
return /* @__PURE__ */ ((_) => void 0)();
|
|
10633
|
+
}
|
|
10634
|
+
};
|
|
10635
|
+
function parseDef2(def, refs, forceResolution = false) {
|
|
10636
|
+
var _a20;
|
|
10637
|
+
const seenItem = refs.seen.get(def);
|
|
10638
|
+
if (refs.override) {
|
|
10639
|
+
const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
|
|
10640
|
+
refs,
|
|
10641
|
+
def,
|
|
10642
|
+
refs,
|
|
10643
|
+
seenItem,
|
|
10644
|
+
forceResolution
|
|
10645
|
+
);
|
|
10646
|
+
if (overrideResult !== ignoreOverride2) {
|
|
10647
|
+
return overrideResult;
|
|
10648
|
+
}
|
|
10649
|
+
}
|
|
10650
|
+
if (seenItem && !forceResolution) {
|
|
10651
|
+
const seenSchema = get$ref2(seenItem, refs);
|
|
10652
|
+
if (seenSchema !== void 0) {
|
|
10653
|
+
return seenSchema;
|
|
10654
|
+
}
|
|
10655
|
+
}
|
|
10656
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
10657
|
+
refs.seen.set(def, newItem);
|
|
10658
|
+
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
10659
|
+
const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
10660
|
+
if (jsonSchema22) {
|
|
10661
|
+
addMeta2(def, refs, jsonSchema22);
|
|
10662
|
+
}
|
|
10663
|
+
if (refs.postProcess) {
|
|
10664
|
+
const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
|
|
10665
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10666
|
+
return postProcessResult;
|
|
10667
|
+
}
|
|
10668
|
+
newItem.jsonSchema = jsonSchema22;
|
|
10669
|
+
return jsonSchema22;
|
|
10670
|
+
}
|
|
10671
|
+
var get$ref2 = (item, refs) => {
|
|
10672
|
+
switch (refs.$refStrategy) {
|
|
10673
|
+
case "root":
|
|
10674
|
+
return { $ref: item.path.join("/") };
|
|
10675
|
+
case "relative":
|
|
10676
|
+
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
10677
|
+
case "none":
|
|
10678
|
+
case "seen": {
|
|
10679
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
10680
|
+
console.warn(
|
|
10681
|
+
`Recursive reference detected at ${refs.currentPath.join(
|
|
10682
|
+
"/"
|
|
10683
|
+
)}! Defaulting to any`
|
|
10684
|
+
);
|
|
10685
|
+
return parseAnyDef2();
|
|
10686
|
+
}
|
|
10687
|
+
return refs.$refStrategy === "seen" ? parseAnyDef2() : void 0;
|
|
10688
|
+
}
|
|
10689
|
+
}
|
|
10690
|
+
};
|
|
10691
|
+
var addMeta2 = (def, refs, jsonSchema22) => {
|
|
10692
|
+
if (def.description) {
|
|
10693
|
+
jsonSchema22.description = def.description;
|
|
10694
|
+
}
|
|
10695
|
+
return jsonSchema22;
|
|
10696
|
+
};
|
|
10697
|
+
var getRefs2 = (options) => {
|
|
10698
|
+
const _options = getDefaultOptions2(options);
|
|
10699
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
10700
|
+
return {
|
|
10701
|
+
..._options,
|
|
10702
|
+
currentPath,
|
|
10703
|
+
propertyPath: void 0,
|
|
10704
|
+
seen: new Map(
|
|
10705
|
+
Object.entries(_options.definitions).map(([name20, def]) => [
|
|
10706
|
+
def._def,
|
|
10707
|
+
{
|
|
10708
|
+
def: def._def,
|
|
10709
|
+
path: [..._options.basePath, _options.definitionPath, name20],
|
|
10710
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
10711
|
+
jsonSchema: void 0
|
|
10712
|
+
}
|
|
10713
|
+
])
|
|
10714
|
+
)
|
|
10715
|
+
};
|
|
10716
|
+
};
|
|
10717
|
+
var zodToJsonSchema3 = (schema, options) => {
|
|
10718
|
+
var _a20;
|
|
10719
|
+
const refs = getRefs2(options);
|
|
10720
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
10721
|
+
(acc, [name25, schema2]) => {
|
|
10722
|
+
var _a25;
|
|
10723
|
+
return {
|
|
10724
|
+
...acc,
|
|
10725
|
+
[name25]: (_a25 = parseDef2(
|
|
10726
|
+
schema2._def,
|
|
10727
|
+
{
|
|
10728
|
+
...refs,
|
|
10729
|
+
currentPath: [...refs.basePath, refs.definitionPath, name25]
|
|
10730
|
+
},
|
|
10731
|
+
true
|
|
10732
|
+
)) != null ? _a25 : parseAnyDef2()
|
|
10733
|
+
};
|
|
10734
|
+
},
|
|
10735
|
+
{}
|
|
10736
|
+
) : void 0;
|
|
10737
|
+
const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
10738
|
+
const main = (_a20 = parseDef2(
|
|
10739
|
+
schema._def,
|
|
10740
|
+
name20 === void 0 ? refs : {
|
|
10741
|
+
...refs,
|
|
10742
|
+
currentPath: [...refs.basePath, refs.definitionPath, name20]
|
|
10743
|
+
},
|
|
10744
|
+
false
|
|
10745
|
+
)) != null ? _a20 : parseAnyDef2();
|
|
10746
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
10747
|
+
if (title !== void 0) {
|
|
10748
|
+
main.title = title;
|
|
10749
|
+
}
|
|
10750
|
+
const combined = name20 === void 0 ? definitions ? {
|
|
10751
|
+
...main,
|
|
10752
|
+
[refs.definitionPath]: definitions
|
|
10753
|
+
} : main : {
|
|
10754
|
+
$ref: [
|
|
10755
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
10756
|
+
refs.definitionPath,
|
|
10757
|
+
name20
|
|
10758
|
+
].join("/"),
|
|
10759
|
+
[refs.definitionPath]: {
|
|
10760
|
+
...definitions,
|
|
10761
|
+
[name20]: main
|
|
10762
|
+
}
|
|
10763
|
+
};
|
|
10764
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
10765
|
+
return combined;
|
|
10766
|
+
};
|
|
10767
|
+
var zod_to_json_schema_default2 = zodToJsonSchema3;
|
|
10768
|
+
function zod3Schema2(zodSchema22, options) {
|
|
10769
|
+
var _a20;
|
|
10770
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10771
|
+
return jsonSchema3(
|
|
10772
|
+
zod_to_json_schema_default2(zodSchema22, {
|
|
10773
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
10774
|
+
}),
|
|
10775
|
+
{
|
|
10776
|
+
validate: async (value) => {
|
|
10777
|
+
const result = await zodSchema22.safeParseAsync(value);
|
|
10778
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10779
|
+
}
|
|
10780
|
+
}
|
|
10781
|
+
);
|
|
10782
|
+
}
|
|
10783
|
+
function zod4Schema2(zodSchema22, options) {
|
|
10784
|
+
var _a20;
|
|
10785
|
+
const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
|
|
10786
|
+
const z4JSONSchema = z42__namespace.toJSONSchema(zodSchema22, {
|
|
10787
|
+
target: "draft-7",
|
|
10788
|
+
io: "output",
|
|
10789
|
+
reused: useReferences ? "ref" : "inline"
|
|
10790
|
+
});
|
|
10791
|
+
return jsonSchema3(z4JSONSchema, {
|
|
10792
|
+
validate: async (value) => {
|
|
10793
|
+
const result = await z42__namespace.safeParseAsync(zodSchema22, value);
|
|
10794
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
10795
|
+
}
|
|
10796
|
+
});
|
|
10797
|
+
}
|
|
10798
|
+
function isZod4Schema2(zodSchema22) {
|
|
10799
|
+
return "_zod" in zodSchema22;
|
|
10800
|
+
}
|
|
10801
|
+
function zodSchema3(zodSchema22, options) {
|
|
10802
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
10803
|
+
return zod4Schema2(zodSchema22);
|
|
10804
|
+
} else {
|
|
10805
|
+
return zod3Schema2(zodSchema22);
|
|
10806
|
+
}
|
|
10807
|
+
}
|
|
10808
|
+
var schemaSymbol3 = Symbol.for("vercel.ai.schema");
|
|
10809
|
+
function jsonSchema3(jsonSchema22, {
|
|
10810
|
+
validate
|
|
10811
|
+
} = {}) {
|
|
10812
|
+
return {
|
|
10813
|
+
[schemaSymbol3]: true,
|
|
10814
|
+
_type: void 0,
|
|
10815
|
+
// should never be used directly
|
|
10816
|
+
[validatorSymbol3]: true,
|
|
10817
|
+
jsonSchema: jsonSchema22,
|
|
10818
|
+
validate
|
|
10819
|
+
};
|
|
10820
|
+
}
|
|
10821
|
+
function isSchema3(value) {
|
|
10822
|
+
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
10823
|
+
}
|
|
10824
|
+
function asSchema3(schema) {
|
|
10825
|
+
return schema == null ? jsonSchema3({
|
|
10826
|
+
properties: {},
|
|
10827
|
+
additionalProperties: false
|
|
10828
|
+
}) : isSchema3(schema) ? schema : zodSchema3(schema);
|
|
10829
|
+
}
|
|
10830
|
+
var __defProp4 = Object.defineProperty;
|
|
10831
|
+
var __export4 = (target, all) => {
|
|
10832
|
+
for (var name172 in all)
|
|
10833
|
+
__defProp4(target, name172, { get: all[name172], enumerable: true });
|
|
10834
|
+
};
|
|
10835
|
+
var name73 = "AI_NoObjectGeneratedError";
|
|
10836
|
+
var marker74 = `vercel.ai.error.${name73}`;
|
|
10837
|
+
var symbol74 = Symbol.for(marker74);
|
|
10838
|
+
var _a74;
|
|
10839
|
+
var NoObjectGeneratedError3 = class extends chunkHVBBFCDH_cjs.AISDKError {
|
|
10840
|
+
constructor({
|
|
10841
|
+
message = "No object generated.",
|
|
10842
|
+
cause,
|
|
10843
|
+
text: text22,
|
|
10844
|
+
response,
|
|
10845
|
+
usage,
|
|
10846
|
+
finishReason
|
|
10847
|
+
}) {
|
|
10848
|
+
super({ name: name73, message, cause });
|
|
10849
|
+
this[_a74] = true;
|
|
10850
|
+
this.text = text22;
|
|
10851
|
+
this.response = response;
|
|
10852
|
+
this.usage = usage;
|
|
10853
|
+
this.finishReason = finishReason;
|
|
10854
|
+
}
|
|
10855
|
+
static isInstance(error) {
|
|
10856
|
+
return chunkHVBBFCDH_cjs.AISDKError.hasMarker(error, marker74);
|
|
10857
|
+
}
|
|
10858
|
+
};
|
|
10859
|
+
_a74 = symbol74;
|
|
10860
|
+
var dataContentSchema3 = z42.z.union([
|
|
10861
|
+
z42.z.string(),
|
|
10862
|
+
z42.z.instanceof(Uint8Array),
|
|
10863
|
+
z42.z.instanceof(ArrayBuffer),
|
|
10864
|
+
z42.z.custom(
|
|
10865
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
10866
|
+
(value) => {
|
|
10867
|
+
var _a172, _b8;
|
|
10868
|
+
return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
|
|
10869
|
+
},
|
|
10870
|
+
{ message: "Must be a Buffer" }
|
|
10871
|
+
)
|
|
10872
|
+
]);
|
|
10873
|
+
var jsonValueSchema3 = z42.z.lazy(
|
|
10874
|
+
() => z42.z.union([
|
|
10875
|
+
z42.z.null(),
|
|
10876
|
+
z42.z.string(),
|
|
10877
|
+
z42.z.number(),
|
|
10878
|
+
z42.z.boolean(),
|
|
10879
|
+
z42.z.record(z42.z.string(), jsonValueSchema3),
|
|
10880
|
+
z42.z.array(jsonValueSchema3)
|
|
10881
|
+
])
|
|
10882
|
+
);
|
|
10883
|
+
var providerMetadataSchema3 = z42.z.record(
|
|
10884
|
+
z42.z.string(),
|
|
10885
|
+
z42.z.record(z42.z.string(), jsonValueSchema3)
|
|
10886
|
+
);
|
|
10887
|
+
var textPartSchema3 = z42.z.object({
|
|
10888
|
+
type: z42.z.literal("text"),
|
|
10889
|
+
text: z42.z.string(),
|
|
10890
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10891
|
+
});
|
|
10892
|
+
var imagePartSchema3 = z42.z.object({
|
|
10893
|
+
type: z42.z.literal("image"),
|
|
10894
|
+
image: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10895
|
+
mediaType: z42.z.string().optional(),
|
|
10896
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10897
|
+
});
|
|
10898
|
+
var filePartSchema3 = z42.z.object({
|
|
10899
|
+
type: z42.z.literal("file"),
|
|
10900
|
+
data: z42.z.union([dataContentSchema3, z42.z.instanceof(URL)]),
|
|
10901
|
+
filename: z42.z.string().optional(),
|
|
10902
|
+
mediaType: z42.z.string(),
|
|
10903
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10904
|
+
});
|
|
10905
|
+
var reasoningPartSchema3 = z42.z.object({
|
|
10906
|
+
type: z42.z.literal("reasoning"),
|
|
10907
|
+
text: z42.z.string(),
|
|
10908
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10909
|
+
});
|
|
10910
|
+
var toolCallPartSchema3 = z42.z.object({
|
|
10911
|
+
type: z42.z.literal("tool-call"),
|
|
10912
|
+
toolCallId: z42.z.string(),
|
|
10913
|
+
toolName: z42.z.string(),
|
|
10914
|
+
input: z42.z.unknown(),
|
|
10915
|
+
providerOptions: providerMetadataSchema3.optional(),
|
|
10916
|
+
providerExecuted: z42.z.boolean().optional()
|
|
10917
|
+
});
|
|
10918
|
+
var outputSchema2 = z42.z.discriminatedUnion("type", [
|
|
10919
|
+
z42.z.object({
|
|
10920
|
+
type: z42.z.literal("text"),
|
|
10921
|
+
value: z42.z.string()
|
|
10922
|
+
}),
|
|
10923
|
+
z42.z.object({
|
|
10924
|
+
type: z42.z.literal("json"),
|
|
10925
|
+
value: jsonValueSchema3
|
|
10926
|
+
}),
|
|
10927
|
+
z42.z.object({
|
|
10928
|
+
type: z42.z.literal("error-text"),
|
|
10929
|
+
value: z42.z.string()
|
|
10930
|
+
}),
|
|
10931
|
+
z42.z.object({
|
|
10932
|
+
type: z42.z.literal("error-json"),
|
|
10933
|
+
value: jsonValueSchema3
|
|
10934
|
+
}),
|
|
10935
|
+
z42.z.object({
|
|
10936
|
+
type: z42.z.literal("content"),
|
|
10937
|
+
value: z42.z.array(
|
|
10938
|
+
z42.z.union([
|
|
10939
|
+
z42.z.object({
|
|
10940
|
+
type: z42.z.literal("text"),
|
|
10941
|
+
text: z42.z.string()
|
|
10942
|
+
}),
|
|
10943
|
+
z42.z.object({
|
|
10944
|
+
type: z42.z.literal("media"),
|
|
10945
|
+
data: z42.z.string(),
|
|
10946
|
+
mediaType: z42.z.string()
|
|
10947
|
+
})
|
|
10948
|
+
])
|
|
10949
|
+
)
|
|
10950
|
+
})
|
|
10951
|
+
]);
|
|
10952
|
+
var toolResultPartSchema3 = z42.z.object({
|
|
10953
|
+
type: z42.z.literal("tool-result"),
|
|
10954
|
+
toolCallId: z42.z.string(),
|
|
10955
|
+
toolName: z42.z.string(),
|
|
10956
|
+
output: outputSchema2,
|
|
10957
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10958
|
+
});
|
|
10959
|
+
var systemModelMessageSchema2 = z42.z.object(
|
|
10960
|
+
{
|
|
10961
|
+
role: z42.z.literal("system"),
|
|
10962
|
+
content: z42.z.string(),
|
|
10963
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10964
|
+
}
|
|
10965
|
+
);
|
|
10966
|
+
var userModelMessageSchema2 = z42.z.object({
|
|
10967
|
+
role: z42.z.literal("user"),
|
|
10968
|
+
content: z42.z.union([
|
|
10969
|
+
z42.z.string(),
|
|
10970
|
+
z42.z.array(z42.z.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
|
|
10971
|
+
]),
|
|
10972
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10973
|
+
});
|
|
10974
|
+
var assistantModelMessageSchema2 = z42.z.object({
|
|
10975
|
+
role: z42.z.literal("assistant"),
|
|
10976
|
+
content: z42.z.union([
|
|
10977
|
+
z42.z.string(),
|
|
10978
|
+
z42.z.array(
|
|
10979
|
+
z42.z.union([
|
|
10980
|
+
textPartSchema3,
|
|
10981
|
+
filePartSchema3,
|
|
10982
|
+
reasoningPartSchema3,
|
|
10983
|
+
toolCallPartSchema3,
|
|
10984
|
+
toolResultPartSchema3
|
|
10985
|
+
])
|
|
10986
|
+
)
|
|
10987
|
+
]),
|
|
10988
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10989
|
+
});
|
|
10990
|
+
var toolModelMessageSchema2 = z42.z.object({
|
|
10991
|
+
role: z42.z.literal("tool"),
|
|
10992
|
+
content: z42.z.array(toolResultPartSchema3),
|
|
10993
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
10994
|
+
});
|
|
10995
|
+
z42.z.union([
|
|
10996
|
+
systemModelMessageSchema2,
|
|
10997
|
+
userModelMessageSchema2,
|
|
10998
|
+
assistantModelMessageSchema2,
|
|
10999
|
+
toolModelMessageSchema2
|
|
11000
|
+
]);
|
|
11001
|
+
function stepCountIs(stepCount) {
|
|
11002
|
+
return ({ steps }) => steps.length === stepCount;
|
|
11003
|
+
}
|
|
11004
|
+
createIdGenerator3({
|
|
11005
|
+
prefix: "aitxt",
|
|
11006
|
+
size: 24
|
|
11007
|
+
});
|
|
11008
|
+
z42.z.union([
|
|
11009
|
+
z42.z.strictObject({
|
|
11010
|
+
type: z42.z.literal("text-start"),
|
|
11011
|
+
id: z42.z.string(),
|
|
11012
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11013
|
+
}),
|
|
11014
|
+
z42.z.strictObject({
|
|
11015
|
+
type: z42.z.literal("text-delta"),
|
|
11016
|
+
id: z42.z.string(),
|
|
11017
|
+
delta: z42.z.string(),
|
|
11018
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11019
|
+
}),
|
|
11020
|
+
z42.z.strictObject({
|
|
11021
|
+
type: z42.z.literal("text-end"),
|
|
11022
|
+
id: z42.z.string(),
|
|
11023
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11024
|
+
}),
|
|
11025
|
+
z42.z.strictObject({
|
|
11026
|
+
type: z42.z.literal("error"),
|
|
11027
|
+
errorText: z42.z.string()
|
|
11028
|
+
}),
|
|
11029
|
+
z42.z.strictObject({
|
|
11030
|
+
type: z42.z.literal("tool-input-start"),
|
|
11031
|
+
toolCallId: z42.z.string(),
|
|
11032
|
+
toolName: z42.z.string(),
|
|
11033
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11034
|
+
dynamic: z42.z.boolean().optional()
|
|
11035
|
+
}),
|
|
11036
|
+
z42.z.strictObject({
|
|
11037
|
+
type: z42.z.literal("tool-input-delta"),
|
|
11038
|
+
toolCallId: z42.z.string(),
|
|
11039
|
+
inputTextDelta: z42.z.string()
|
|
11040
|
+
}),
|
|
11041
|
+
z42.z.strictObject({
|
|
11042
|
+
type: z42.z.literal("tool-input-available"),
|
|
11043
|
+
toolCallId: z42.z.string(),
|
|
11044
|
+
toolName: z42.z.string(),
|
|
11045
|
+
input: z42.z.unknown(),
|
|
11046
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11047
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11048
|
+
dynamic: z42.z.boolean().optional()
|
|
11049
|
+
}),
|
|
11050
|
+
z42.z.strictObject({
|
|
11051
|
+
type: z42.z.literal("tool-input-error"),
|
|
11052
|
+
toolCallId: z42.z.string(),
|
|
11053
|
+
toolName: z42.z.string(),
|
|
11054
|
+
input: z42.z.unknown(),
|
|
11055
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11056
|
+
providerMetadata: providerMetadataSchema3.optional(),
|
|
11057
|
+
dynamic: z42.z.boolean().optional(),
|
|
11058
|
+
errorText: z42.z.string()
|
|
11059
|
+
}),
|
|
11060
|
+
z42.z.strictObject({
|
|
11061
|
+
type: z42.z.literal("tool-output-available"),
|
|
11062
|
+
toolCallId: z42.z.string(),
|
|
11063
|
+
output: z42.z.unknown(),
|
|
11064
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11065
|
+
dynamic: z42.z.boolean().optional(),
|
|
11066
|
+
preliminary: z42.z.boolean().optional()
|
|
11067
|
+
}),
|
|
11068
|
+
z42.z.strictObject({
|
|
11069
|
+
type: z42.z.literal("tool-output-error"),
|
|
11070
|
+
toolCallId: z42.z.string(),
|
|
11071
|
+
errorText: z42.z.string(),
|
|
11072
|
+
providerExecuted: z42.z.boolean().optional(),
|
|
11073
|
+
dynamic: z42.z.boolean().optional()
|
|
11074
|
+
}),
|
|
11075
|
+
z42.z.strictObject({
|
|
11076
|
+
type: z42.z.literal("reasoning"),
|
|
11077
|
+
text: z42.z.string(),
|
|
11078
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11079
|
+
}),
|
|
11080
|
+
z42.z.strictObject({
|
|
11081
|
+
type: z42.z.literal("reasoning-start"),
|
|
11082
|
+
id: z42.z.string(),
|
|
11083
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11084
|
+
}),
|
|
11085
|
+
z42.z.strictObject({
|
|
11086
|
+
type: z42.z.literal("reasoning-delta"),
|
|
11087
|
+
id: z42.z.string(),
|
|
11088
|
+
delta: z42.z.string(),
|
|
11089
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11090
|
+
}),
|
|
11091
|
+
z42.z.strictObject({
|
|
11092
|
+
type: z42.z.literal("reasoning-end"),
|
|
11093
|
+
id: z42.z.string(),
|
|
11094
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11095
|
+
}),
|
|
11096
|
+
z42.z.strictObject({
|
|
11097
|
+
type: z42.z.literal("reasoning-part-finish")
|
|
11098
|
+
}),
|
|
11099
|
+
z42.z.strictObject({
|
|
11100
|
+
type: z42.z.literal("source-url"),
|
|
11101
|
+
sourceId: z42.z.string(),
|
|
11102
|
+
url: z42.z.string(),
|
|
11103
|
+
title: z42.z.string().optional(),
|
|
11104
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11105
|
+
}),
|
|
11106
|
+
z42.z.strictObject({
|
|
11107
|
+
type: z42.z.literal("source-document"),
|
|
11108
|
+
sourceId: z42.z.string(),
|
|
11109
|
+
mediaType: z42.z.string(),
|
|
11110
|
+
title: z42.z.string(),
|
|
11111
|
+
filename: z42.z.string().optional(),
|
|
11112
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11113
|
+
}),
|
|
11114
|
+
z42.z.strictObject({
|
|
11115
|
+
type: z42.z.literal("file"),
|
|
11116
|
+
url: z42.z.string(),
|
|
11117
|
+
mediaType: z42.z.string(),
|
|
11118
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11119
|
+
}),
|
|
11120
|
+
z42.z.strictObject({
|
|
11121
|
+
type: z42.z.string().startsWith("data-"),
|
|
11122
|
+
id: z42.z.string().optional(),
|
|
11123
|
+
data: z42.z.unknown(),
|
|
11124
|
+
transient: z42.z.boolean().optional()
|
|
11125
|
+
}),
|
|
11126
|
+
z42.z.strictObject({
|
|
11127
|
+
type: z42.z.literal("start-step")
|
|
11128
|
+
}),
|
|
11129
|
+
z42.z.strictObject({
|
|
11130
|
+
type: z42.z.literal("finish-step")
|
|
11131
|
+
}),
|
|
11132
|
+
z42.z.strictObject({
|
|
11133
|
+
type: z42.z.literal("start"),
|
|
11134
|
+
messageId: z42.z.string().optional(),
|
|
11135
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11136
|
+
}),
|
|
11137
|
+
z42.z.strictObject({
|
|
11138
|
+
type: z42.z.literal("finish"),
|
|
11139
|
+
messageMetadata: z42.z.unknown().optional()
|
|
11140
|
+
}),
|
|
11141
|
+
z42.z.strictObject({
|
|
11142
|
+
type: z42.z.literal("abort")
|
|
11143
|
+
}),
|
|
11144
|
+
z42.z.strictObject({
|
|
11145
|
+
type: z42.z.literal("message-metadata"),
|
|
11146
|
+
messageMetadata: z42.z.unknown()
|
|
11147
|
+
})
|
|
11148
|
+
]);
|
|
11149
|
+
function fixJson3(input) {
|
|
11150
|
+
const stack = ["ROOT"];
|
|
11151
|
+
let lastValidIndex = -1;
|
|
11152
|
+
let literalStart = null;
|
|
11153
|
+
function processValueStart(char, i, swapState) {
|
|
11154
|
+
{
|
|
11155
|
+
switch (char) {
|
|
11156
|
+
case '"': {
|
|
11157
|
+
lastValidIndex = i;
|
|
11158
|
+
stack.pop();
|
|
11159
|
+
stack.push(swapState);
|
|
11160
|
+
stack.push("INSIDE_STRING");
|
|
11161
|
+
break;
|
|
11162
|
+
}
|
|
11163
|
+
case "f":
|
|
11164
|
+
case "t":
|
|
11165
|
+
case "n": {
|
|
11166
|
+
lastValidIndex = i;
|
|
11167
|
+
literalStart = i;
|
|
11168
|
+
stack.pop();
|
|
11169
|
+
stack.push(swapState);
|
|
11170
|
+
stack.push("INSIDE_LITERAL");
|
|
11171
|
+
break;
|
|
11172
|
+
}
|
|
11173
|
+
case "-": {
|
|
11174
|
+
stack.pop();
|
|
11175
|
+
stack.push(swapState);
|
|
11176
|
+
stack.push("INSIDE_NUMBER");
|
|
11177
|
+
break;
|
|
11178
|
+
}
|
|
11179
|
+
case "0":
|
|
11180
|
+
case "1":
|
|
11181
|
+
case "2":
|
|
11182
|
+
case "3":
|
|
11183
|
+
case "4":
|
|
11184
|
+
case "5":
|
|
11185
|
+
case "6":
|
|
11186
|
+
case "7":
|
|
11187
|
+
case "8":
|
|
11188
|
+
case "9": {
|
|
11189
|
+
lastValidIndex = i;
|
|
11190
|
+
stack.pop();
|
|
11191
|
+
stack.push(swapState);
|
|
11192
|
+
stack.push("INSIDE_NUMBER");
|
|
11193
|
+
break;
|
|
11194
|
+
}
|
|
11195
|
+
case "{": {
|
|
11196
|
+
lastValidIndex = i;
|
|
11197
|
+
stack.pop();
|
|
11198
|
+
stack.push(swapState);
|
|
11199
|
+
stack.push("INSIDE_OBJECT_START");
|
|
11200
|
+
break;
|
|
11201
|
+
}
|
|
11202
|
+
case "[": {
|
|
11203
|
+
lastValidIndex = i;
|
|
11204
|
+
stack.pop();
|
|
11205
|
+
stack.push(swapState);
|
|
11206
|
+
stack.push("INSIDE_ARRAY_START");
|
|
11207
|
+
break;
|
|
11208
|
+
}
|
|
11209
|
+
}
|
|
11210
|
+
}
|
|
11211
|
+
}
|
|
11212
|
+
function processAfterObjectValue(char, i) {
|
|
11213
|
+
switch (char) {
|
|
11214
|
+
case ",": {
|
|
11215
|
+
stack.pop();
|
|
11216
|
+
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
11217
|
+
break;
|
|
11218
|
+
}
|
|
11219
|
+
case "}": {
|
|
11220
|
+
lastValidIndex = i;
|
|
11221
|
+
stack.pop();
|
|
11222
|
+
break;
|
|
11223
|
+
}
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
11226
|
+
function processAfterArrayValue(char, i) {
|
|
11227
|
+
switch (char) {
|
|
11228
|
+
case ",": {
|
|
11229
|
+
stack.pop();
|
|
11230
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11231
|
+
break;
|
|
11232
|
+
}
|
|
11233
|
+
case "]": {
|
|
11234
|
+
lastValidIndex = i;
|
|
11235
|
+
stack.pop();
|
|
11236
|
+
break;
|
|
11237
|
+
}
|
|
11238
|
+
}
|
|
11239
|
+
}
|
|
11240
|
+
for (let i = 0; i < input.length; i++) {
|
|
11241
|
+
const char = input[i];
|
|
11242
|
+
const currentState = stack[stack.length - 1];
|
|
11243
|
+
switch (currentState) {
|
|
11244
|
+
case "ROOT":
|
|
11245
|
+
processValueStart(char, i, "FINISH");
|
|
11246
|
+
break;
|
|
11247
|
+
case "INSIDE_OBJECT_START": {
|
|
11248
|
+
switch (char) {
|
|
11249
|
+
case '"': {
|
|
11250
|
+
stack.pop();
|
|
11251
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11252
|
+
break;
|
|
11253
|
+
}
|
|
11254
|
+
case "}": {
|
|
11255
|
+
lastValidIndex = i;
|
|
11256
|
+
stack.pop();
|
|
11257
|
+
break;
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
break;
|
|
11261
|
+
}
|
|
11262
|
+
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
11263
|
+
switch (char) {
|
|
11264
|
+
case '"': {
|
|
11265
|
+
stack.pop();
|
|
11266
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
11267
|
+
break;
|
|
11268
|
+
}
|
|
11269
|
+
}
|
|
11270
|
+
break;
|
|
11271
|
+
}
|
|
11272
|
+
case "INSIDE_OBJECT_KEY": {
|
|
11273
|
+
switch (char) {
|
|
11274
|
+
case '"': {
|
|
11275
|
+
stack.pop();
|
|
11276
|
+
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
11277
|
+
break;
|
|
11278
|
+
}
|
|
11279
|
+
}
|
|
11280
|
+
break;
|
|
11281
|
+
}
|
|
11282
|
+
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
11283
|
+
switch (char) {
|
|
11284
|
+
case ":": {
|
|
11285
|
+
stack.pop();
|
|
11286
|
+
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
11287
|
+
break;
|
|
11288
|
+
}
|
|
11289
|
+
}
|
|
11290
|
+
break;
|
|
11291
|
+
}
|
|
11292
|
+
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
11293
|
+
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
11294
|
+
break;
|
|
11295
|
+
}
|
|
11296
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11297
|
+
processAfterObjectValue(char, i);
|
|
11298
|
+
break;
|
|
11299
|
+
}
|
|
11300
|
+
case "INSIDE_STRING": {
|
|
11301
|
+
switch (char) {
|
|
11302
|
+
case '"': {
|
|
11303
|
+
stack.pop();
|
|
11304
|
+
lastValidIndex = i;
|
|
11305
|
+
break;
|
|
11306
|
+
}
|
|
11307
|
+
case "\\": {
|
|
11308
|
+
stack.push("INSIDE_STRING_ESCAPE");
|
|
11309
|
+
break;
|
|
11310
|
+
}
|
|
11311
|
+
default: {
|
|
11312
|
+
lastValidIndex = i;
|
|
11313
|
+
}
|
|
11314
|
+
}
|
|
11315
|
+
break;
|
|
11316
|
+
}
|
|
11317
|
+
case "INSIDE_ARRAY_START": {
|
|
11318
|
+
switch (char) {
|
|
11319
|
+
case "]": {
|
|
11320
|
+
lastValidIndex = i;
|
|
11321
|
+
stack.pop();
|
|
11322
|
+
break;
|
|
11323
|
+
}
|
|
11324
|
+
default: {
|
|
11325
|
+
lastValidIndex = i;
|
|
11326
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11327
|
+
break;
|
|
11328
|
+
}
|
|
11329
|
+
}
|
|
11330
|
+
break;
|
|
11331
|
+
}
|
|
11332
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11333
|
+
switch (char) {
|
|
11334
|
+
case ",": {
|
|
11335
|
+
stack.pop();
|
|
11336
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
11337
|
+
break;
|
|
11338
|
+
}
|
|
11339
|
+
case "]": {
|
|
11340
|
+
lastValidIndex = i;
|
|
11341
|
+
stack.pop();
|
|
11342
|
+
break;
|
|
11343
|
+
}
|
|
11344
|
+
default: {
|
|
11345
|
+
lastValidIndex = i;
|
|
11346
|
+
break;
|
|
11347
|
+
}
|
|
11348
|
+
}
|
|
11349
|
+
break;
|
|
11350
|
+
}
|
|
11351
|
+
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
11352
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
11353
|
+
break;
|
|
11354
|
+
}
|
|
11355
|
+
case "INSIDE_STRING_ESCAPE": {
|
|
11356
|
+
stack.pop();
|
|
11357
|
+
lastValidIndex = i;
|
|
11358
|
+
break;
|
|
11359
|
+
}
|
|
11360
|
+
case "INSIDE_NUMBER": {
|
|
11361
|
+
switch (char) {
|
|
11362
|
+
case "0":
|
|
11363
|
+
case "1":
|
|
11364
|
+
case "2":
|
|
11365
|
+
case "3":
|
|
11366
|
+
case "4":
|
|
11367
|
+
case "5":
|
|
11368
|
+
case "6":
|
|
11369
|
+
case "7":
|
|
11370
|
+
case "8":
|
|
11371
|
+
case "9": {
|
|
11372
|
+
lastValidIndex = i;
|
|
11373
|
+
break;
|
|
11374
|
+
}
|
|
11375
|
+
case "e":
|
|
11376
|
+
case "E":
|
|
11377
|
+
case "-":
|
|
11378
|
+
case ".": {
|
|
11379
|
+
break;
|
|
11380
|
+
}
|
|
11381
|
+
case ",": {
|
|
11382
|
+
stack.pop();
|
|
11383
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11384
|
+
processAfterArrayValue(char, i);
|
|
11385
|
+
}
|
|
11386
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11387
|
+
processAfterObjectValue(char, i);
|
|
11388
|
+
}
|
|
11389
|
+
break;
|
|
11390
|
+
}
|
|
11391
|
+
case "}": {
|
|
11392
|
+
stack.pop();
|
|
11393
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11394
|
+
processAfterObjectValue(char, i);
|
|
11395
|
+
}
|
|
11396
|
+
break;
|
|
11397
|
+
}
|
|
11398
|
+
case "]": {
|
|
11399
|
+
stack.pop();
|
|
11400
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11401
|
+
processAfterArrayValue(char, i);
|
|
11402
|
+
}
|
|
11403
|
+
break;
|
|
11404
|
+
}
|
|
11405
|
+
default: {
|
|
11406
|
+
stack.pop();
|
|
11407
|
+
break;
|
|
11408
|
+
}
|
|
11409
|
+
}
|
|
11410
|
+
break;
|
|
11411
|
+
}
|
|
11412
|
+
case "INSIDE_LITERAL": {
|
|
11413
|
+
const partialLiteral = input.substring(literalStart, i + 1);
|
|
11414
|
+
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
11415
|
+
stack.pop();
|
|
11416
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
11417
|
+
processAfterObjectValue(char, i);
|
|
11418
|
+
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
11419
|
+
processAfterArrayValue(char, i);
|
|
11420
|
+
}
|
|
11421
|
+
} else {
|
|
11422
|
+
lastValidIndex = i;
|
|
11423
|
+
}
|
|
11424
|
+
break;
|
|
11425
|
+
}
|
|
11426
|
+
}
|
|
11427
|
+
}
|
|
11428
|
+
let result = input.slice(0, lastValidIndex + 1);
|
|
11429
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
11430
|
+
const state = stack[i];
|
|
11431
|
+
switch (state) {
|
|
11432
|
+
case "INSIDE_STRING": {
|
|
11433
|
+
result += '"';
|
|
11434
|
+
break;
|
|
11435
|
+
}
|
|
11436
|
+
case "INSIDE_OBJECT_KEY":
|
|
11437
|
+
case "INSIDE_OBJECT_AFTER_KEY":
|
|
11438
|
+
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
11439
|
+
case "INSIDE_OBJECT_START":
|
|
11440
|
+
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
11441
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
11442
|
+
result += "}";
|
|
11443
|
+
break;
|
|
11444
|
+
}
|
|
11445
|
+
case "INSIDE_ARRAY_START":
|
|
11446
|
+
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
11447
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
11448
|
+
result += "]";
|
|
11449
|
+
break;
|
|
11450
|
+
}
|
|
11451
|
+
case "INSIDE_LITERAL": {
|
|
11452
|
+
const partialLiteral = input.substring(literalStart, input.length);
|
|
11453
|
+
if ("true".startsWith(partialLiteral)) {
|
|
11454
|
+
result += "true".slice(partialLiteral.length);
|
|
11455
|
+
} else if ("false".startsWith(partialLiteral)) {
|
|
11456
|
+
result += "false".slice(partialLiteral.length);
|
|
11457
|
+
} else if ("null".startsWith(partialLiteral)) {
|
|
11458
|
+
result += "null".slice(partialLiteral.length);
|
|
11459
|
+
}
|
|
11460
|
+
}
|
|
11461
|
+
}
|
|
11462
|
+
}
|
|
11463
|
+
return result;
|
|
11464
|
+
}
|
|
11465
|
+
async function parsePartialJson3(jsonText) {
|
|
11466
|
+
if (jsonText === void 0) {
|
|
11467
|
+
return { value: void 0, state: "undefined-input" };
|
|
11468
|
+
}
|
|
11469
|
+
let result = await safeParseJSON3({ text: jsonText });
|
|
11470
|
+
if (result.success) {
|
|
11471
|
+
return { value: result.value, state: "successful-parse" };
|
|
11472
|
+
}
|
|
11473
|
+
result = await safeParseJSON3({ text: fixJson3(jsonText) });
|
|
11474
|
+
if (result.success) {
|
|
11475
|
+
return { value: result.value, state: "repaired-parse" };
|
|
11476
|
+
}
|
|
11477
|
+
return { value: void 0, state: "failed-parse" };
|
|
11478
|
+
}
|
|
11479
|
+
createIdGenerator3({
|
|
11480
|
+
prefix: "aitxt",
|
|
11481
|
+
size: 24
|
|
11482
|
+
});
|
|
11483
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11484
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
11485
|
+
var output_exports3 = {};
|
|
11486
|
+
__export4(output_exports3, {
|
|
11487
|
+
object: () => object3,
|
|
11488
|
+
text: () => text3
|
|
11489
|
+
});
|
|
11490
|
+
var text3 = () => ({
|
|
11491
|
+
type: "text",
|
|
11492
|
+
responseFormat: { type: "text" },
|
|
11493
|
+
async parsePartial({ text: text22 }) {
|
|
11494
|
+
return { partial: text22 };
|
|
11495
|
+
},
|
|
11496
|
+
async parseOutput({ text: text22 }) {
|
|
11497
|
+
return text22;
|
|
11498
|
+
}
|
|
11499
|
+
});
|
|
11500
|
+
var object3 = ({
|
|
11501
|
+
schema: inputSchema
|
|
11502
|
+
}) => {
|
|
11503
|
+
const schema = asSchema3(inputSchema);
|
|
11504
|
+
return {
|
|
11505
|
+
type: "object",
|
|
11506
|
+
responseFormat: {
|
|
11507
|
+
type: "json",
|
|
11508
|
+
schema: schema.jsonSchema
|
|
11509
|
+
},
|
|
11510
|
+
async parsePartial({ text: text22 }) {
|
|
11511
|
+
const result = await parsePartialJson3(text22);
|
|
11512
|
+
switch (result.state) {
|
|
11513
|
+
case "failed-parse":
|
|
11514
|
+
case "undefined-input":
|
|
11515
|
+
return void 0;
|
|
11516
|
+
case "repaired-parse":
|
|
11517
|
+
case "successful-parse":
|
|
11518
|
+
return {
|
|
11519
|
+
// Note: currently no validation of partial results:
|
|
11520
|
+
partial: result.value
|
|
11521
|
+
};
|
|
11522
|
+
default: {
|
|
11523
|
+
const _exhaustiveCheck = result.state;
|
|
11524
|
+
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
11525
|
+
}
|
|
11526
|
+
}
|
|
11527
|
+
},
|
|
11528
|
+
async parseOutput({ text: text22 }, context) {
|
|
11529
|
+
const parseResult = await safeParseJSON3({ text: text22 });
|
|
11530
|
+
if (!parseResult.success) {
|
|
11531
|
+
throw new NoObjectGeneratedError3({
|
|
11532
|
+
message: "No object generated: could not parse the response.",
|
|
11533
|
+
cause: parseResult.error,
|
|
11534
|
+
text: text22,
|
|
11535
|
+
response: context.response,
|
|
11536
|
+
usage: context.usage,
|
|
11537
|
+
finishReason: context.finishReason
|
|
11538
|
+
});
|
|
11539
|
+
}
|
|
11540
|
+
const validationResult = await safeValidateTypes3({
|
|
11541
|
+
value: parseResult.value,
|
|
11542
|
+
schema
|
|
11543
|
+
});
|
|
11544
|
+
if (!validationResult.success) {
|
|
11545
|
+
throw new NoObjectGeneratedError3({
|
|
11546
|
+
message: "No object generated: response did not match schema.",
|
|
11547
|
+
cause: validationResult.error,
|
|
11548
|
+
text: text22,
|
|
11549
|
+
response: context.response,
|
|
11550
|
+
usage: context.usage,
|
|
11551
|
+
finishReason: context.finishReason
|
|
11552
|
+
});
|
|
11553
|
+
}
|
|
11554
|
+
return validationResult.value;
|
|
11555
|
+
}
|
|
11556
|
+
};
|
|
9545
11557
|
};
|
|
11558
|
+
var ClientOrServerImplementationSchema3 = z42.z.looseObject({
|
|
11559
|
+
name: z42.z.string(),
|
|
11560
|
+
version: z42.z.string()
|
|
11561
|
+
});
|
|
11562
|
+
var BaseParamsSchema3 = z42.z.looseObject({
|
|
11563
|
+
_meta: z42.z.optional(z42.z.object({}).loose())
|
|
11564
|
+
});
|
|
11565
|
+
var ResultSchema3 = BaseParamsSchema3;
|
|
11566
|
+
var RequestSchema3 = z42.z.object({
|
|
11567
|
+
method: z42.z.string(),
|
|
11568
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11569
|
+
});
|
|
11570
|
+
var ServerCapabilitiesSchema3 = z42.z.looseObject({
|
|
11571
|
+
experimental: z42.z.optional(z42.z.object({}).loose()),
|
|
11572
|
+
logging: z42.z.optional(z42.z.object({}).loose()),
|
|
11573
|
+
prompts: z42.z.optional(
|
|
11574
|
+
z42.z.looseObject({
|
|
11575
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11576
|
+
})
|
|
11577
|
+
),
|
|
11578
|
+
resources: z42.z.optional(
|
|
11579
|
+
z42.z.looseObject({
|
|
11580
|
+
subscribe: z42.z.optional(z42.z.boolean()),
|
|
11581
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11582
|
+
})
|
|
11583
|
+
),
|
|
11584
|
+
tools: z42.z.optional(
|
|
11585
|
+
z42.z.looseObject({
|
|
11586
|
+
listChanged: z42.z.optional(z42.z.boolean())
|
|
11587
|
+
})
|
|
11588
|
+
)
|
|
11589
|
+
});
|
|
11590
|
+
ResultSchema3.extend({
|
|
11591
|
+
protocolVersion: z42.z.string(),
|
|
11592
|
+
capabilities: ServerCapabilitiesSchema3,
|
|
11593
|
+
serverInfo: ClientOrServerImplementationSchema3,
|
|
11594
|
+
instructions: z42.z.optional(z42.z.string())
|
|
11595
|
+
});
|
|
11596
|
+
var PaginatedResultSchema3 = ResultSchema3.extend({
|
|
11597
|
+
nextCursor: z42.z.optional(z42.z.string())
|
|
11598
|
+
});
|
|
11599
|
+
var ToolSchema3 = z42.z.object({
|
|
11600
|
+
name: z42.z.string(),
|
|
11601
|
+
description: z42.z.optional(z42.z.string()),
|
|
11602
|
+
inputSchema: z42.z.object({
|
|
11603
|
+
type: z42.z.literal("object"),
|
|
11604
|
+
properties: z42.z.optional(z42.z.object({}).loose())
|
|
11605
|
+
}).loose()
|
|
11606
|
+
}).loose();
|
|
11607
|
+
PaginatedResultSchema3.extend({
|
|
11608
|
+
tools: z42.z.array(ToolSchema3)
|
|
11609
|
+
});
|
|
11610
|
+
var TextContentSchema3 = z42.z.object({
|
|
11611
|
+
type: z42.z.literal("text"),
|
|
11612
|
+
text: z42.z.string()
|
|
11613
|
+
}).loose();
|
|
11614
|
+
var ImageContentSchema3 = z42.z.object({
|
|
11615
|
+
type: z42.z.literal("image"),
|
|
11616
|
+
data: z42.z.base64(),
|
|
11617
|
+
mimeType: z42.z.string()
|
|
11618
|
+
}).loose();
|
|
11619
|
+
var ResourceContentsSchema3 = z42.z.object({
|
|
11620
|
+
/**
|
|
11621
|
+
* The URI of this resource.
|
|
11622
|
+
*/
|
|
11623
|
+
uri: z42.z.string(),
|
|
11624
|
+
/**
|
|
11625
|
+
* The MIME type of this resource, if known.
|
|
11626
|
+
*/
|
|
11627
|
+
mimeType: z42.z.optional(z42.z.string())
|
|
11628
|
+
}).loose();
|
|
11629
|
+
var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11630
|
+
text: z42.z.string()
|
|
11631
|
+
});
|
|
11632
|
+
var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
11633
|
+
blob: z42.z.base64()
|
|
11634
|
+
});
|
|
11635
|
+
var EmbeddedResourceSchema3 = z42.z.object({
|
|
11636
|
+
type: z42.z.literal("resource"),
|
|
11637
|
+
resource: z42.z.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
|
|
11638
|
+
}).loose();
|
|
11639
|
+
ResultSchema3.extend({
|
|
11640
|
+
content: z42.z.array(
|
|
11641
|
+
z42.z.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
|
|
11642
|
+
),
|
|
11643
|
+
isError: z42.z.boolean().default(false).optional()
|
|
11644
|
+
}).or(
|
|
11645
|
+
ResultSchema3.extend({
|
|
11646
|
+
toolResult: z42.z.unknown()
|
|
11647
|
+
})
|
|
11648
|
+
);
|
|
11649
|
+
var JSONRPC_VERSION3 = "2.0";
|
|
11650
|
+
var JSONRPCRequestSchema3 = z42.z.object({
|
|
11651
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11652
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()])
|
|
11653
|
+
}).merge(RequestSchema3).strict();
|
|
11654
|
+
var JSONRPCResponseSchema3 = z42.z.object({
|
|
11655
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11656
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11657
|
+
result: ResultSchema3
|
|
11658
|
+
}).strict();
|
|
11659
|
+
var JSONRPCErrorSchema3 = z42.z.object({
|
|
11660
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3),
|
|
11661
|
+
id: z42.z.union([z42.z.string(), z42.z.number().int()]),
|
|
11662
|
+
error: z42.z.object({
|
|
11663
|
+
code: z42.z.number().int(),
|
|
11664
|
+
message: z42.z.string(),
|
|
11665
|
+
data: z42.z.optional(z42.z.unknown())
|
|
11666
|
+
})
|
|
11667
|
+
}).strict();
|
|
11668
|
+
var JSONRPCNotificationSchema3 = z42.z.object({
|
|
11669
|
+
jsonrpc: z42.z.literal(JSONRPC_VERSION3)
|
|
11670
|
+
}).merge(
|
|
11671
|
+
z42.z.object({
|
|
11672
|
+
method: z42.z.string(),
|
|
11673
|
+
params: z42.z.optional(BaseParamsSchema3)
|
|
11674
|
+
})
|
|
11675
|
+
).strict();
|
|
11676
|
+
z42.z.union([
|
|
11677
|
+
JSONRPCRequestSchema3,
|
|
11678
|
+
JSONRPCNotificationSchema3,
|
|
11679
|
+
JSONRPCResponseSchema3,
|
|
11680
|
+
JSONRPCErrorSchema3
|
|
11681
|
+
]);
|
|
11682
|
+
var textUIPartSchema2 = z42.z.object({
|
|
11683
|
+
type: z42.z.literal("text"),
|
|
11684
|
+
text: z42.z.string(),
|
|
11685
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11686
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11687
|
+
});
|
|
11688
|
+
var reasoningUIPartSchema2 = z42.z.object({
|
|
11689
|
+
type: z42.z.literal("reasoning"),
|
|
11690
|
+
text: z42.z.string(),
|
|
11691
|
+
state: z42.z.enum(["streaming", "done"]).optional(),
|
|
11692
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11693
|
+
});
|
|
11694
|
+
var sourceUrlUIPartSchema2 = z42.z.object({
|
|
11695
|
+
type: z42.z.literal("source-url"),
|
|
11696
|
+
sourceId: z42.z.string(),
|
|
11697
|
+
url: z42.z.string(),
|
|
11698
|
+
title: z42.z.string().optional(),
|
|
11699
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11700
|
+
});
|
|
11701
|
+
var sourceDocumentUIPartSchema2 = z42.z.object({
|
|
11702
|
+
type: z42.z.literal("source-document"),
|
|
11703
|
+
sourceId: z42.z.string(),
|
|
11704
|
+
mediaType: z42.z.string(),
|
|
11705
|
+
title: z42.z.string(),
|
|
11706
|
+
filename: z42.z.string().optional(),
|
|
11707
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11708
|
+
});
|
|
11709
|
+
var fileUIPartSchema2 = z42.z.object({
|
|
11710
|
+
type: z42.z.literal("file"),
|
|
11711
|
+
mediaType: z42.z.string(),
|
|
11712
|
+
filename: z42.z.string().optional(),
|
|
11713
|
+
url: z42.z.string(),
|
|
11714
|
+
providerMetadata: providerMetadataSchema3.optional()
|
|
11715
|
+
});
|
|
11716
|
+
var stepStartUIPartSchema2 = z42.z.object({
|
|
11717
|
+
type: z42.z.literal("step-start")
|
|
11718
|
+
});
|
|
11719
|
+
var dataUIPartSchema2 = z42.z.object({
|
|
11720
|
+
type: z42.z.string().startsWith("data-"),
|
|
11721
|
+
id: z42.z.string().optional(),
|
|
11722
|
+
data: z42.z.unknown()
|
|
11723
|
+
});
|
|
11724
|
+
var dynamicToolUIPartSchemas2 = [
|
|
11725
|
+
z42.z.object({
|
|
11726
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11727
|
+
toolName: z42.z.string(),
|
|
11728
|
+
toolCallId: z42.z.string(),
|
|
11729
|
+
state: z42.z.literal("input-streaming"),
|
|
11730
|
+
input: z42.z.unknown().optional(),
|
|
11731
|
+
output: z42.z.never().optional(),
|
|
11732
|
+
errorText: z42.z.never().optional()
|
|
11733
|
+
}),
|
|
11734
|
+
z42.z.object({
|
|
11735
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11736
|
+
toolName: z42.z.string(),
|
|
11737
|
+
toolCallId: z42.z.string(),
|
|
11738
|
+
state: z42.z.literal("input-available"),
|
|
11739
|
+
input: z42.z.unknown(),
|
|
11740
|
+
output: z42.z.never().optional(),
|
|
11741
|
+
errorText: z42.z.never().optional(),
|
|
11742
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11743
|
+
}),
|
|
11744
|
+
z42.z.object({
|
|
11745
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11746
|
+
toolName: z42.z.string(),
|
|
11747
|
+
toolCallId: z42.z.string(),
|
|
11748
|
+
state: z42.z.literal("output-available"),
|
|
11749
|
+
input: z42.z.unknown(),
|
|
11750
|
+
output: z42.z.unknown(),
|
|
11751
|
+
errorText: z42.z.never().optional(),
|
|
11752
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11753
|
+
preliminary: z42.z.boolean().optional()
|
|
11754
|
+
}),
|
|
11755
|
+
z42.z.object({
|
|
11756
|
+
type: z42.z.literal("dynamic-tool"),
|
|
11757
|
+
toolName: z42.z.string(),
|
|
11758
|
+
toolCallId: z42.z.string(),
|
|
11759
|
+
state: z42.z.literal("output-error"),
|
|
11760
|
+
input: z42.z.unknown(),
|
|
11761
|
+
output: z42.z.never().optional(),
|
|
11762
|
+
errorText: z42.z.string(),
|
|
11763
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11764
|
+
})
|
|
11765
|
+
];
|
|
11766
|
+
var toolUIPartSchemas2 = [
|
|
11767
|
+
z42.z.object({
|
|
11768
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11769
|
+
toolCallId: z42.z.string(),
|
|
11770
|
+
state: z42.z.literal("input-streaming"),
|
|
11771
|
+
input: z42.z.unknown().optional(),
|
|
11772
|
+
output: z42.z.never().optional(),
|
|
11773
|
+
errorText: z42.z.never().optional()
|
|
11774
|
+
}),
|
|
11775
|
+
z42.z.object({
|
|
11776
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11777
|
+
toolCallId: z42.z.string(),
|
|
11778
|
+
state: z42.z.literal("input-available"),
|
|
11779
|
+
input: z42.z.unknown(),
|
|
11780
|
+
output: z42.z.never().optional(),
|
|
11781
|
+
errorText: z42.z.never().optional(),
|
|
11782
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11783
|
+
}),
|
|
11784
|
+
z42.z.object({
|
|
11785
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11786
|
+
toolCallId: z42.z.string(),
|
|
11787
|
+
state: z42.z.literal("output-available"),
|
|
11788
|
+
input: z42.z.unknown(),
|
|
11789
|
+
output: z42.z.unknown(),
|
|
11790
|
+
errorText: z42.z.never().optional(),
|
|
11791
|
+
callProviderMetadata: providerMetadataSchema3.optional(),
|
|
11792
|
+
preliminary: z42.z.boolean().optional()
|
|
11793
|
+
}),
|
|
11794
|
+
z42.z.object({
|
|
11795
|
+
type: z42.z.string().startsWith("tool-"),
|
|
11796
|
+
toolCallId: z42.z.string(),
|
|
11797
|
+
state: z42.z.literal("output-error"),
|
|
11798
|
+
input: z42.z.unknown(),
|
|
11799
|
+
output: z42.z.never().optional(),
|
|
11800
|
+
errorText: z42.z.string(),
|
|
11801
|
+
callProviderMetadata: providerMetadataSchema3.optional()
|
|
11802
|
+
})
|
|
11803
|
+
];
|
|
11804
|
+
z42.z.object({
|
|
11805
|
+
id: z42.z.string(),
|
|
11806
|
+
role: z42.z.enum(["system", "user", "assistant"]),
|
|
11807
|
+
metadata: z42.z.unknown().optional(),
|
|
11808
|
+
parts: z42.z.array(
|
|
11809
|
+
z42.z.union([
|
|
11810
|
+
textUIPartSchema2,
|
|
11811
|
+
reasoningUIPartSchema2,
|
|
11812
|
+
sourceUrlUIPartSchema2,
|
|
11813
|
+
sourceDocumentUIPartSchema2,
|
|
11814
|
+
fileUIPartSchema2,
|
|
11815
|
+
stepStartUIPartSchema2,
|
|
11816
|
+
dataUIPartSchema2,
|
|
11817
|
+
...dynamicToolUIPartSchemas2,
|
|
11818
|
+
...toolUIPartSchemas2
|
|
11819
|
+
])
|
|
11820
|
+
)
|
|
11821
|
+
});
|
|
9546
11822
|
|
|
9547
11823
|
// ../agent-builder/dist/index.js
|
|
9548
|
-
var import_ignore = chunkEMMSS5I5_cjs.__toESM(require_ignore(), 1);
|
|
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),
|
|
@@ -9750,7 +12025,7 @@ function isInWorkspaceSubfolder(cwd) {
|
|
|
9750
12025
|
if (currentDir === cwd) {
|
|
9751
12026
|
continue;
|
|
9752
12027
|
}
|
|
9753
|
-
console.
|
|
12028
|
+
console.log(`Checking for workspace indicators in: ${currentDir}`);
|
|
9754
12029
|
if (fs.existsSync(path.resolve(currentDir, "pnpm-workspace.yaml"))) {
|
|
9755
12030
|
return true;
|
|
9756
12031
|
}
|
|
@@ -9770,7 +12045,7 @@ function isInWorkspaceSubfolder(cwd) {
|
|
|
9770
12045
|
}
|
|
9771
12046
|
return false;
|
|
9772
12047
|
} catch (error) {
|
|
9773
|
-
console.
|
|
12048
|
+
console.log(`Error in workspace detection: ${error}`);
|
|
9774
12049
|
return false;
|
|
9775
12050
|
}
|
|
9776
12051
|
}
|
|
@@ -9841,12 +12116,12 @@ function spawnWithOutput(command, args, options) {
|
|
|
9841
12116
|
}
|
|
9842
12117
|
async function spawnSWPM(cwd, command, packageNames) {
|
|
9843
12118
|
try {
|
|
9844
|
-
console.
|
|
12119
|
+
console.log("Running install command with swpm");
|
|
9845
12120
|
const swpmPath = module$1.createRequire(undefined).resolve("swpm");
|
|
9846
12121
|
await spawn(swpmPath, [command, ...packageNames], { cwd });
|
|
9847
12122
|
return;
|
|
9848
12123
|
} catch (e2) {
|
|
9849
|
-
console.
|
|
12124
|
+
console.log("Failed to run install command with swpm", e2);
|
|
9850
12125
|
}
|
|
9851
12126
|
try {
|
|
9852
12127
|
let packageManager;
|
|
@@ -9874,11 +12149,11 @@ async function spawnSWPM(cwd, command, packageNames) {
|
|
|
9874
12149
|
}
|
|
9875
12150
|
}
|
|
9876
12151
|
args.push(...packageNames);
|
|
9877
|
-
console.
|
|
12152
|
+
console.log(`Falling back to ${packageManager} ${args.join(" ")}`);
|
|
9878
12153
|
await spawn(packageManager, args, { cwd });
|
|
9879
12154
|
return;
|
|
9880
12155
|
} catch (e2) {
|
|
9881
|
-
console.
|
|
12156
|
+
console.log(`Failed to run install command with native package manager: ${e2}`);
|
|
9882
12157
|
}
|
|
9883
12158
|
throw new Error(`Failed to run install command with swpm and native package managers`);
|
|
9884
12159
|
}
|
|
@@ -9892,10 +12167,10 @@ async function logGitState(targetPath, label) {
|
|
|
9892
12167
|
const gitStatusResult = await git(targetPath, "status", "--porcelain");
|
|
9893
12168
|
const gitLogResult = await git(targetPath, "log", "--oneline", "-3");
|
|
9894
12169
|
const gitCountResult = await git(targetPath, "rev-list", "--count", "HEAD");
|
|
9895
|
-
console.
|
|
9896
|
-
console.
|
|
9897
|
-
console.
|
|
9898
|
-
console.
|
|
12170
|
+
console.log(`\u{1F4CA} Git state ${label}:`);
|
|
12171
|
+
console.log("Status:", gitStatusResult.stdout.trim() || "Clean working directory");
|
|
12172
|
+
console.log("Recent commits:", gitLogResult.stdout.trim());
|
|
12173
|
+
console.log("Total commits:", gitCountResult.stdout.trim());
|
|
9899
12174
|
} catch (gitError) {
|
|
9900
12175
|
console.warn(`Could not get git state ${label}:`, gitError);
|
|
9901
12176
|
}
|
|
@@ -9967,18 +12242,18 @@ async function gitCheckoutBranch(branchName, targetPath) {
|
|
|
9967
12242
|
try {
|
|
9968
12243
|
if (!await isInsideGitRepo(targetPath)) return;
|
|
9969
12244
|
await git(targetPath, "checkout", "-b", branchName);
|
|
9970
|
-
console.
|
|
12245
|
+
console.log(`Created new branch: ${branchName}`);
|
|
9971
12246
|
} catch (error) {
|
|
9972
12247
|
const errorStr = error instanceof Error ? error.message : String(error);
|
|
9973
12248
|
if (errorStr.includes("already exists")) {
|
|
9974
12249
|
try {
|
|
9975
12250
|
await git(targetPath, "checkout", branchName);
|
|
9976
|
-
console.
|
|
12251
|
+
console.log(`Switched to existing branch: ${branchName}`);
|
|
9977
12252
|
} catch {
|
|
9978
12253
|
const timestamp = Date.now().toString().slice(-6);
|
|
9979
12254
|
const uniqueBranchName = `${branchName}-${timestamp}`;
|
|
9980
12255
|
await git(targetPath, "checkout", "-b", uniqueBranchName);
|
|
9981
|
-
console.
|
|
12256
|
+
console.log(`Created unique branch: ${uniqueBranchName}`);
|
|
9982
12257
|
}
|
|
9983
12258
|
} else {
|
|
9984
12259
|
throw error;
|
|
@@ -9988,9 +12263,9 @@ async function gitCheckoutBranch(branchName, targetPath) {
|
|
|
9988
12263
|
async function backupAndReplaceFile(sourceFile, targetFile) {
|
|
9989
12264
|
const backupFile = `${targetFile}.backup-${Date.now()}`;
|
|
9990
12265
|
await promises.copyFile(targetFile, backupFile);
|
|
9991
|
-
console.
|
|
12266
|
+
console.log(`\u{1F4E6} Created backup: ${path.basename(backupFile)}`);
|
|
9992
12267
|
await promises.copyFile(sourceFile, targetFile);
|
|
9993
|
-
console.
|
|
12268
|
+
console.log(`\u{1F504} Replaced file with template version (backup created)`);
|
|
9994
12269
|
}
|
|
9995
12270
|
async function renameAndCopyFile(sourceFile, targetFile) {
|
|
9996
12271
|
let counter = 1;
|
|
@@ -10004,7 +12279,7 @@ async function renameAndCopyFile(sourceFile, targetFile) {
|
|
|
10004
12279
|
counter++;
|
|
10005
12280
|
}
|
|
10006
12281
|
await promises.copyFile(sourceFile, uniqueTargetFile);
|
|
10007
|
-
console.
|
|
12282
|
+
console.log(`\u{1F4DD} Copied with unique name: ${path.basename(uniqueTargetFile)}`);
|
|
10008
12283
|
return uniqueTargetFile;
|
|
10009
12284
|
}
|
|
10010
12285
|
var isValidMastraLanguageModel = (model) => {
|
|
@@ -10053,7 +12328,7 @@ var mergeGitignoreFiles = (targetContent, templateContent, templateSlug) => {
|
|
|
10053
12328
|
if (!hasConflict) {
|
|
10054
12329
|
newEntries.push(trimmed);
|
|
10055
12330
|
} else {
|
|
10056
|
-
console.
|
|
12331
|
+
console.log(`\u26A0 Skipping conflicting .gitignore rule: ${trimmed} (conflicts with existing rule)`);
|
|
10057
12332
|
}
|
|
10058
12333
|
}
|
|
10059
12334
|
}
|
|
@@ -10088,7 +12363,7 @@ var mergeEnvFiles = (targetContent, templateVariables, templateSlug) => {
|
|
|
10088
12363
|
if (!existingVars.has(key)) {
|
|
10089
12364
|
newVars.push({ key, value });
|
|
10090
12365
|
} else {
|
|
10091
|
-
console.
|
|
12366
|
+
console.log(`\u26A0 Skipping existing environment variable: ${key} (already exists in .env)`);
|
|
10092
12367
|
}
|
|
10093
12368
|
}
|
|
10094
12369
|
if (newVars.length === 0) {
|
|
@@ -10109,7 +12384,7 @@ var detectAISDKVersion = async (projectPath) => {
|
|
|
10109
12384
|
try {
|
|
10110
12385
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
10111
12386
|
if (!fs.existsSync(packageJsonPath)) {
|
|
10112
|
-
console.
|
|
12387
|
+
console.log("No package.json found, defaulting to v2");
|
|
10113
12388
|
return "v2";
|
|
10114
12389
|
}
|
|
10115
12390
|
const packageContent = await promises.readFile(packageJsonPath, "utf-8");
|
|
@@ -10127,16 +12402,16 @@ var detectAISDKVersion = async (projectPath) => {
|
|
|
10127
12402
|
if (versionMatch) {
|
|
10128
12403
|
const majorVersion = parseInt(versionMatch[1]);
|
|
10129
12404
|
if (majorVersion >= 2) {
|
|
10130
|
-
console.
|
|
12405
|
+
console.log(`Detected ${pkg} v${majorVersion} -> using v2 specification`);
|
|
10131
12406
|
return "v2";
|
|
10132
12407
|
} else {
|
|
10133
|
-
console.
|
|
12408
|
+
console.log(`Detected ${pkg} v${majorVersion} -> using v1 specification`);
|
|
10134
12409
|
return "v1";
|
|
10135
12410
|
}
|
|
10136
12411
|
}
|
|
10137
12412
|
}
|
|
10138
12413
|
}
|
|
10139
|
-
console.
|
|
12414
|
+
console.log("No AI SDK version detected, defaulting to v2");
|
|
10140
12415
|
return "v2";
|
|
10141
12416
|
} catch (error) {
|
|
10142
12417
|
console.warn(`Failed to detect AI SDK version: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10197,7 +12472,7 @@ var createModelInstance = async (provider, modelId, version = "v2") => {
|
|
|
10197
12472
|
return null;
|
|
10198
12473
|
}
|
|
10199
12474
|
const modelInstance = await providerFn();
|
|
10200
|
-
console.
|
|
12475
|
+
console.log(`Created ${provider} model instance (${version}): ${modelId}`);
|
|
10201
12476
|
return modelInstance;
|
|
10202
12477
|
} catch (error) {
|
|
10203
12478
|
console.error(`Failed to create model instance: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -10211,7 +12486,7 @@ var resolveModel = async ({
|
|
|
10211
12486
|
}) => {
|
|
10212
12487
|
const modelFromContext = runtimeContext.get("model");
|
|
10213
12488
|
if (modelFromContext) {
|
|
10214
|
-
console.
|
|
12489
|
+
console.log("Using model from runtime context");
|
|
10215
12490
|
if (isValidMastraLanguageModel(modelFromContext)) {
|
|
10216
12491
|
return modelFromContext;
|
|
10217
12492
|
}
|
|
@@ -10221,7 +12496,7 @@ var resolveModel = async ({
|
|
|
10221
12496
|
}
|
|
10222
12497
|
const selectedModel = runtimeContext.get("selectedModel");
|
|
10223
12498
|
if (selectedModel?.provider && selectedModel?.modelId && projectPath) {
|
|
10224
|
-
console.
|
|
12499
|
+
console.log(`Resolving selected model: ${selectedModel.provider}/${selectedModel.modelId}`);
|
|
10225
12500
|
const version = await detectAISDKVersion(projectPath);
|
|
10226
12501
|
const modelInstance = await createModelInstance(selectedModel.provider, selectedModel.modelId, version);
|
|
10227
12502
|
if (modelInstance) {
|
|
@@ -10229,7 +12504,7 @@ var resolveModel = async ({
|
|
|
10229
12504
|
return modelInstance;
|
|
10230
12505
|
}
|
|
10231
12506
|
}
|
|
10232
|
-
console.
|
|
12507
|
+
console.log("Using default model");
|
|
10233
12508
|
return defaultModel;
|
|
10234
12509
|
};
|
|
10235
12510
|
var AgentBuilderDefaults = class _AgentBuilderDefaults {
|
|
@@ -11263,7 +13538,7 @@ export const mastra = new Mastra({
|
|
|
11263
13538
|
error: stderr
|
|
11264
13539
|
};
|
|
11265
13540
|
} catch (error) {
|
|
11266
|
-
console.
|
|
13541
|
+
console.log(error);
|
|
11267
13542
|
return {
|
|
11268
13543
|
success: false,
|
|
11269
13544
|
message: `Failed to create project: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -11278,7 +13553,7 @@ export const mastra = new Mastra({
|
|
|
11278
13553
|
projectPath
|
|
11279
13554
|
}) {
|
|
11280
13555
|
try {
|
|
11281
|
-
console.
|
|
13556
|
+
console.log("Installing packages:", JSON.stringify(packages, null, 2));
|
|
11282
13557
|
const packageStrings = packages.map((p) => `${p.name}`);
|
|
11283
13558
|
await spawnSWPM(projectPath || "", "add", packageStrings);
|
|
11284
13559
|
return {
|
|
@@ -11302,7 +13577,7 @@ export const mastra = new Mastra({
|
|
|
11302
13577
|
projectPath
|
|
11303
13578
|
}) {
|
|
11304
13579
|
try {
|
|
11305
|
-
console.
|
|
13580
|
+
console.log("Upgrading specific packages:", JSON.stringify(packages, null, 2));
|
|
11306
13581
|
let packageNames = [];
|
|
11307
13582
|
if (packages && packages.length > 0) {
|
|
11308
13583
|
packageNames = packages.map((p) => `${p.name}`);
|
|
@@ -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"
|
|
@@ -12893,13 +15168,13 @@ var analyzePackageStep = workflows.createStep({
|
|
|
12893
15168
|
inputSchema: CloneTemplateResultSchema,
|
|
12894
15169
|
outputSchema: PackageAnalysisSchema,
|
|
12895
15170
|
execute: async ({ inputData }) => {
|
|
12896
|
-
console.
|
|
15171
|
+
console.log("Analyzing template package.json...");
|
|
12897
15172
|
const { templateDir } = inputData;
|
|
12898
15173
|
const packageJsonPath = path.join(templateDir, "package.json");
|
|
12899
15174
|
try {
|
|
12900
15175
|
const packageJsonContent = await promises.readFile(packageJsonPath, "utf-8");
|
|
12901
15176
|
const packageJson = JSON.parse(packageJsonContent);
|
|
12902
|
-
console.
|
|
15177
|
+
console.log("Template package.json:", JSON.stringify(packageJson, null, 2));
|
|
12903
15178
|
return {
|
|
12904
15179
|
dependencies: packageJson.dependencies || {},
|
|
12905
15180
|
devDependencies: packageJson.devDependencies || {},
|
|
@@ -12935,7 +15210,7 @@ var discoverUnitsStep = workflows.createStep({
|
|
|
12935
15210
|
const { templateDir } = inputData;
|
|
12936
15211
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
12937
15212
|
const tools = await AgentBuilderDefaults.DEFAULT_TOOLS(templateDir);
|
|
12938
|
-
console.
|
|
15213
|
+
console.log("targetPath", targetPath);
|
|
12939
15214
|
const model = await resolveModel({ runtimeContext, projectPath: targetPath, defaultModel: chunkPPYGWINI_cjs.openai("gpt-4.1") });
|
|
12940
15215
|
try {
|
|
12941
15216
|
const agent$1 = new agent.Agent({
|
|
@@ -13023,7 +15298,7 @@ Return the actual exported names of the units, as well as the file names.`,
|
|
|
13023
15298
|
template.other?.forEach((otherId) => {
|
|
13024
15299
|
units.push({ kind: "other", id: otherId.name, file: otherId.file });
|
|
13025
15300
|
});
|
|
13026
|
-
console.
|
|
15301
|
+
console.log("Discovered units:", JSON.stringify(units, null, 2));
|
|
13027
15302
|
if (units.length === 0) {
|
|
13028
15303
|
throw new Error(`No Mastra units (agents, workflows, tools) found in template.
|
|
13029
15304
|
Possible causes:
|
|
@@ -13099,7 +15374,7 @@ var packageMergeStep = workflows.createStep({
|
|
|
13099
15374
|
inputSchema: PackageMergeInputSchema,
|
|
13100
15375
|
outputSchema: PackageMergeResultSchema,
|
|
13101
15376
|
execute: async ({ inputData, runtimeContext }) => {
|
|
13102
|
-
console.
|
|
15377
|
+
console.log("Package merge step starting...");
|
|
13103
15378
|
const { slug, packageInfo } = inputData;
|
|
13104
15379
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
13105
15380
|
try {
|
|
@@ -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
|
}
|
|
@@ -13176,7 +15451,7 @@ var installStep = workflows.createStep({
|
|
|
13176
15451
|
inputSchema: InstallInputSchema,
|
|
13177
15452
|
outputSchema: InstallResultSchema,
|
|
13178
15453
|
execute: async ({ inputData, runtimeContext }) => {
|
|
13179
|
-
console.
|
|
15454
|
+
console.log("Running install step...");
|
|
13180
15455
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
13181
15456
|
try {
|
|
13182
15457
|
await spawnSWPM(targetPath, "install", []);
|
|
@@ -13204,7 +15479,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13204
15479
|
inputSchema: FileCopyInputSchema,
|
|
13205
15480
|
outputSchema: FileCopyResultSchema,
|
|
13206
15481
|
execute: async ({ inputData, runtimeContext }) => {
|
|
13207
|
-
console.
|
|
15482
|
+
console.log("Programmatic file copy step starting...");
|
|
13208
15483
|
const { orderedUnits, templateDir, commitSha, slug } = inputData;
|
|
13209
15484
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
13210
15485
|
try {
|
|
@@ -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,11 +15518,11 @@ 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) {
|
|
13250
|
-
console.
|
|
15525
|
+
console.log(`Processing ${unit.kind} unit "${unit.id}" from file "${unit.file}"`);
|
|
13251
15526
|
let sourceFile;
|
|
13252
15527
|
let resolvedUnitFile;
|
|
13253
15528
|
if (unit.file.includes("/")) {
|
|
@@ -13278,7 +15553,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13278
15553
|
}
|
|
13279
15554
|
const targetDir = path.dirname(resolvedUnitFile);
|
|
13280
15555
|
const namingConvention = await analyzeNamingConvention(targetDir);
|
|
13281
|
-
console.
|
|
15556
|
+
console.log(`Detected naming convention in ${targetDir}: ${namingConvention}`);
|
|
13282
15557
|
const hasExtension = path.extname(unit.id) !== "";
|
|
13283
15558
|
const baseId = hasExtension ? path.basename(unit.id, path.extname(unit.id)) : unit.id;
|
|
13284
15559
|
const fileExtension = path.extname(unit.file);
|
|
@@ -13286,7 +15561,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13286
15561
|
const targetFile = path.resolve(targetPath, targetDir, convertedFileName);
|
|
13287
15562
|
if (fs.existsSync(targetFile)) {
|
|
13288
15563
|
const strategy = determineConflictStrategy();
|
|
13289
|
-
console.
|
|
15564
|
+
console.log(`File exists: ${convertedFileName}, using strategy: ${strategy}`);
|
|
13290
15565
|
switch (strategy) {
|
|
13291
15566
|
case "skip":
|
|
13292
15567
|
conflicts.push({
|
|
@@ -13295,7 +15570,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13295
15570
|
sourceFile: unit.file,
|
|
13296
15571
|
targetFile: `${targetDir}/${convertedFileName}`
|
|
13297
15572
|
});
|
|
13298
|
-
console.
|
|
15573
|
+
console.log(`\u23ED\uFE0F Skipped ${unit.kind} "${unit.id}": file already exists`);
|
|
13299
15574
|
continue;
|
|
13300
15575
|
case "backup-and-replace":
|
|
13301
15576
|
try {
|
|
@@ -13305,7 +15580,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13305
15580
|
destination: targetFile,
|
|
13306
15581
|
unit: { kind: unit.kind, id: unit.id }
|
|
13307
15582
|
});
|
|
13308
|
-
console.
|
|
15583
|
+
console.log(
|
|
13309
15584
|
`\u{1F504} Replaced ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${convertedFileName} (backup created)`
|
|
13310
15585
|
);
|
|
13311
15586
|
continue;
|
|
@@ -13326,7 +15601,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13326
15601
|
destination: uniqueTargetFile,
|
|
13327
15602
|
unit: { kind: unit.kind, id: unit.id }
|
|
13328
15603
|
});
|
|
13329
|
-
console.
|
|
15604
|
+
console.log(`\u{1F4DD} Renamed ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${path.basename(uniqueTargetFile)}`);
|
|
13330
15605
|
continue;
|
|
13331
15606
|
} catch (renameError) {
|
|
13332
15607
|
conflicts.push({
|
|
@@ -13355,7 +15630,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13355
15630
|
destination: targetFile,
|
|
13356
15631
|
unit: { kind: unit.kind, id: unit.id }
|
|
13357
15632
|
});
|
|
13358
|
-
console.
|
|
15633
|
+
console.log(`\u2713 Copied ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${convertedFileName}`);
|
|
13359
15634
|
} catch (copyError) {
|
|
13360
15635
|
conflicts.push({
|
|
13361
15636
|
unit: { kind: unit.kind, id: unit.id },
|
|
@@ -13376,7 +15651,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13376
15651
|
destination: targetTsconfig,
|
|
13377
15652
|
unit: { kind: "other", id: "tsconfig.json" }
|
|
13378
15653
|
});
|
|
13379
|
-
console.
|
|
15654
|
+
console.log("\u2713 Copied tsconfig.json from template to target");
|
|
13380
15655
|
} else {
|
|
13381
15656
|
const minimalTsconfig = {
|
|
13382
15657
|
compilerOptions: {
|
|
@@ -13398,7 +15673,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13398
15673
|
destination: targetTsconfig,
|
|
13399
15674
|
unit: { kind: "other", id: "tsconfig.json" }
|
|
13400
15675
|
});
|
|
13401
|
-
console.
|
|
15676
|
+
console.log("\u2713 Generated minimal tsconfig.json in target");
|
|
13402
15677
|
}
|
|
13403
15678
|
}
|
|
13404
15679
|
} catch (e2) {
|
|
@@ -13423,7 +15698,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13423
15698
|
destination: targetMastraIndex,
|
|
13424
15699
|
unit: { kind: "other", id: "mastra-index" }
|
|
13425
15700
|
});
|
|
13426
|
-
console.
|
|
15701
|
+
console.log("\u2713 Copied Mastra index file from template");
|
|
13427
15702
|
}
|
|
13428
15703
|
}
|
|
13429
15704
|
} catch (e2) {
|
|
@@ -13447,7 +15722,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13447
15722
|
destination: targetGitignore,
|
|
13448
15723
|
unit: { kind: "other", id: "gitignore" }
|
|
13449
15724
|
});
|
|
13450
|
-
console.
|
|
15725
|
+
console.log("\u2713 Copied .gitignore from template to target");
|
|
13451
15726
|
} else {
|
|
13452
15727
|
const targetContent = await promises.readFile(targetGitignore, "utf-8");
|
|
13453
15728
|
const templateContent = await promises.readFile(templateGitignore, "utf-8");
|
|
@@ -13460,9 +15735,9 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13460
15735
|
destination: targetGitignore,
|
|
13461
15736
|
unit: { kind: "other", id: "gitignore-merge" }
|
|
13462
15737
|
});
|
|
13463
|
-
console.
|
|
15738
|
+
console.log(`\u2713 Merged template .gitignore entries into existing .gitignore (${addedLines} new entries)`);
|
|
13464
15739
|
} else {
|
|
13465
|
-
console.
|
|
15740
|
+
console.log("\u2139 No new .gitignore entries to add from template");
|
|
13466
15741
|
}
|
|
13467
15742
|
}
|
|
13468
15743
|
}
|
|
@@ -13490,7 +15765,7 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13490
15765
|
destination: targetEnv,
|
|
13491
15766
|
unit: { kind: "other", id: "env" }
|
|
13492
15767
|
});
|
|
13493
|
-
console.
|
|
15768
|
+
console.log(`\u2713 Created .env file with ${Object.keys(variables).length} template variables`);
|
|
13494
15769
|
} else {
|
|
13495
15770
|
const targetContent = await promises.readFile(targetEnv, "utf-8");
|
|
13496
15771
|
const mergedContent = mergeEnvFiles(targetContent, variables, slug);
|
|
@@ -13502,9 +15777,9 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13502
15777
|
destination: targetEnv,
|
|
13503
15778
|
unit: { kind: "other", id: "env-merge" }
|
|
13504
15779
|
});
|
|
13505
|
-
console.
|
|
15780
|
+
console.log(`\u2713 Merged new environment variables into existing .env file (${addedLines} new entries)`);
|
|
13506
15781
|
} else {
|
|
13507
|
-
console.
|
|
15782
|
+
console.log("\u2139 No new environment variables to add (all already exist in .env)");
|
|
13508
15783
|
}
|
|
13509
15784
|
}
|
|
13510
15785
|
}
|
|
@@ -13525,13 +15800,13 @@ var programmaticFileCopyStep = workflows.createStep({
|
|
|
13525
15800
|
fileList,
|
|
13526
15801
|
{ skipIfNoStaged: true }
|
|
13527
15802
|
);
|
|
13528
|
-
console.
|
|
15803
|
+
console.log(`\u2713 Committed ${copiedFiles.length} copied files`);
|
|
13529
15804
|
} catch (commitError) {
|
|
13530
15805
|
console.warn("Failed to commit copied files:", commitError);
|
|
13531
15806
|
}
|
|
13532
15807
|
}
|
|
13533
15808
|
const message = `Programmatic file copy completed. Copied ${copiedFiles.length} files, ${conflicts.length} conflicts detected.`;
|
|
13534
|
-
console.
|
|
15809
|
+
console.log(message);
|
|
13535
15810
|
return {
|
|
13536
15811
|
success: true,
|
|
13537
15812
|
copiedFiles,
|
|
@@ -13556,7 +15831,7 @@ var intelligentMergeStep = workflows.createStep({
|
|
|
13556
15831
|
inputSchema: IntelligentMergeInputSchema,
|
|
13557
15832
|
outputSchema: IntelligentMergeResultSchema,
|
|
13558
15833
|
execute: async ({ inputData, runtimeContext }) => {
|
|
13559
|
-
console.
|
|
15834
|
+
console.log("Intelligent merge step starting...");
|
|
13560
15835
|
const { conflicts, copiedFiles, commitSha, slug, templateDir, branchName } = inputData;
|
|
13561
15836
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
13562
15837
|
try {
|
|
@@ -13683,8 +15958,8 @@ Template information:
|
|
|
13683
15958
|
const registrableFiles = copiedFiles.filter((f) => registrableKinds.has(f.unit.kind));
|
|
13684
15959
|
const targetMastraIndex = path.resolve(targetPath, "src/mastra/index.ts");
|
|
13685
15960
|
const mastraIndexExists = fs.existsSync(targetMastraIndex);
|
|
13686
|
-
console.
|
|
13687
|
-
console.
|
|
15961
|
+
console.log(`Mastra index exists: ${mastraIndexExists} at ${targetMastraIndex}`);
|
|
15962
|
+
console.log(
|
|
13688
15963
|
"Registrable components:",
|
|
13689
15964
|
registrableFiles.map((f) => `${f.unit.kind}:${f.unit.id}`)
|
|
13690
15965
|
);
|
|
@@ -13698,7 +15973,7 @@ Template information:
|
|
|
13698
15973
|
notes: `Components to register: ${registrableFiles.map((f) => `${f.unit.kind}:${f.unit.id}`).join(", ")}`
|
|
13699
15974
|
});
|
|
13700
15975
|
}
|
|
13701
|
-
console.
|
|
15976
|
+
console.log(`Creating task list with ${tasks.length} tasks...`);
|
|
13702
15977
|
await AgentBuilderDefaults.manageTaskList({ action: "create", tasks });
|
|
13703
15978
|
await logGitState(targetPath, "before intelligent merge");
|
|
13704
15979
|
const prompt = `
|
|
@@ -13750,12 +16025,12 @@ Start by listing your tasks and work through them systematically!
|
|
|
13750
16025
|
for await (const chunk of result.fullStream) {
|
|
13751
16026
|
if (chunk.type === "step-finish" || chunk.type === "step-start") {
|
|
13752
16027
|
const chunkData = "payload" in chunk ? chunk.payload : chunk;
|
|
13753
|
-
console.
|
|
16028
|
+
console.log({
|
|
13754
16029
|
type: chunk.type,
|
|
13755
16030
|
msgId: chunkData.messageId
|
|
13756
16031
|
});
|
|
13757
16032
|
} else {
|
|
13758
|
-
console.
|
|
16033
|
+
console.log(JSON.stringify(chunk, null, 2));
|
|
13759
16034
|
if (chunk.type === "tool-result") {
|
|
13760
16035
|
const chunkData = "payload" in chunk ? chunk.payload : chunk;
|
|
13761
16036
|
if (chunkData.toolName === "manageTaskList") {
|
|
@@ -13769,7 +16044,7 @@ Start by listing your tasks and work through them systematically!
|
|
|
13769
16044
|
content: toolResult.content || "",
|
|
13770
16045
|
notes: toolResult.notes
|
|
13771
16046
|
});
|
|
13772
|
-
console.
|
|
16047
|
+
console.log(`\u{1F4CB} Task completed: ${toolResult.taskId} - ${toolResult.content}`);
|
|
13773
16048
|
}
|
|
13774
16049
|
} catch (parseError) {
|
|
13775
16050
|
console.warn("Failed to parse task management result:", parseError);
|
|
@@ -13824,12 +16099,12 @@ var validationAndFixStep = workflows.createStep({
|
|
|
13824
16099
|
inputSchema: ValidationFixInputSchema,
|
|
13825
16100
|
outputSchema: ValidationFixResultSchema,
|
|
13826
16101
|
execute: async ({ inputData, runtimeContext }) => {
|
|
13827
|
-
console.
|
|
16102
|
+
console.log("Validation and fix step starting...");
|
|
13828
16103
|
const { commitSha, slug, orderedUnits, templateDir, copiedFiles, conflictsResolved, maxIterations = 5 } = inputData;
|
|
13829
16104
|
const targetPath = resolveTargetPath(inputData, runtimeContext);
|
|
13830
16105
|
const hasChanges = copiedFiles.length > 0 || conflictsResolved && conflictsResolved.length > 0;
|
|
13831
16106
|
if (!hasChanges) {
|
|
13832
|
-
console.
|
|
16107
|
+
console.log("\u23ED\uFE0F Skipping validation - no files copied or conflicts resolved");
|
|
13833
16108
|
return {
|
|
13834
16109
|
success: true,
|
|
13835
16110
|
applied: false,
|
|
@@ -13841,7 +16116,7 @@ var validationAndFixStep = workflows.createStep({
|
|
|
13841
16116
|
}
|
|
13842
16117
|
};
|
|
13843
16118
|
}
|
|
13844
|
-
console.
|
|
16119
|
+
console.log(
|
|
13845
16120
|
`\u{1F4CB} Changes detected: ${copiedFiles.length} files copied, ${conflictsResolved?.length || 0} conflicts resolved`
|
|
13846
16121
|
);
|
|
13847
16122
|
let currentIteration = 1;
|
|
@@ -13967,7 +16242,7 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
|
|
|
13967
16242
|
executeCommand: allTools.executeCommand
|
|
13968
16243
|
}
|
|
13969
16244
|
});
|
|
13970
|
-
console.
|
|
16245
|
+
console.log("Starting validation and fix agent with internal loop...");
|
|
13971
16246
|
let validationResults = {
|
|
13972
16247
|
valid: false,
|
|
13973
16248
|
errorsFixed: 0,
|
|
@@ -13978,7 +16253,7 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
|
|
|
13978
16253
|
// Store the actual error details
|
|
13979
16254
|
};
|
|
13980
16255
|
while (validationResults.remainingErrors > 0 && currentIteration <= maxIterations) {
|
|
13981
|
-
console.
|
|
16256
|
+
console.log(`
|
|
13982
16257
|
=== Validation Iteration ${currentIteration} ===`);
|
|
13983
16258
|
const iterationPrompt = currentIteration === 1 ? `Please validate the template integration and fix any errors found in the project at ${targetPath}. The template "${slug}" (${commitSha.substring(0, 7)}) was just integrated and may have validation issues that need fixing.
|
|
13984
16259
|
|
|
@@ -13998,13 +16273,13 @@ Previous iterations may have fixed some issues, so start by re-running validateC
|
|
|
13998
16273
|
for await (const chunk of result.fullStream) {
|
|
13999
16274
|
if (chunk.type === "step-finish" || chunk.type === "step-start") {
|
|
14000
16275
|
const chunkData = "payload" in chunk ? chunk.payload : chunk;
|
|
14001
|
-
console.
|
|
16276
|
+
console.log({
|
|
14002
16277
|
type: chunk.type,
|
|
14003
16278
|
msgId: chunkData.messageId,
|
|
14004
16279
|
iteration: currentIteration
|
|
14005
16280
|
});
|
|
14006
16281
|
} else {
|
|
14007
|
-
console.
|
|
16282
|
+
console.log(JSON.stringify(chunk, null, 2));
|
|
14008
16283
|
}
|
|
14009
16284
|
if (chunk.type === "tool-result") {
|
|
14010
16285
|
const chunkData = "payload" in chunk ? chunk.payload : chunk;
|
|
@@ -14013,7 +16288,7 @@ Previous iterations may have fixed some issues, so start by re-running validateC
|
|
|
14013
16288
|
lastValidationResult = toolResult;
|
|
14014
16289
|
if (toolResult?.summary) {
|
|
14015
16290
|
iterationErrors = toolResult.summary.totalErrors || 0;
|
|
14016
|
-
console.
|
|
16291
|
+
console.log(`Iteration ${currentIteration}: Found ${iterationErrors} errors`);
|
|
14017
16292
|
}
|
|
14018
16293
|
}
|
|
14019
16294
|
}
|
|
@@ -14025,12 +16300,12 @@ Previous iterations may have fixed some issues, so start by re-running validateC
|
|
|
14025
16300
|
if (iterationErrors > 0 && lastValidationResult?.errors) {
|
|
14026
16301
|
validationResults.lastValidationErrors = lastValidationResult.errors;
|
|
14027
16302
|
}
|
|
14028
|
-
console.
|
|
16303
|
+
console.log(`Iteration ${currentIteration} complete: ${iterationErrors} errors remaining`);
|
|
14029
16304
|
if (iterationErrors === 0) {
|
|
14030
|
-
console.
|
|
16305
|
+
console.log(`\u2705 All validation issues resolved in ${currentIteration} iterations!`);
|
|
14031
16306
|
break;
|
|
14032
16307
|
} else if (currentIteration >= maxIterations) {
|
|
14033
|
-
console.
|
|
16308
|
+
console.log(`\u26A0\uFE0F Max iterations (${maxIterations}) reached. ${iterationErrors} errors still remaining.`);
|
|
14034
16309
|
break;
|
|
14035
16310
|
}
|
|
14036
16311
|
currentIteration++;
|
|
@@ -14075,7 +16350,7 @@ Previous iterations may have fixed some issues, so start by re-running validateC
|
|
|
14075
16350
|
} finally {
|
|
14076
16351
|
try {
|
|
14077
16352
|
await promises.rm(templateDir, { recursive: true, force: true });
|
|
14078
|
-
console.
|
|
16353
|
+
console.log(`\u2713 Cleaned up template directory: ${templateDir}`);
|
|
14079
16354
|
} catch (cleanupError) {
|
|
14080
16355
|
console.warn("Failed to cleanup template directory:", cleanupError);
|
|
14081
16356
|
}
|
|
@@ -14551,10 +16826,12 @@ var planningIterationStep = workflows.createStep({
|
|
|
14551
16826
|
research,
|
|
14552
16827
|
userAnswers
|
|
14553
16828
|
} = inputData;
|
|
14554
|
-
console.
|
|
16829
|
+
console.log("Starting planning iteration...");
|
|
14555
16830
|
const qaKey = "workflow-builder-qa";
|
|
14556
16831
|
let storedQAPairs = runtimeContext.get(qaKey) || [];
|
|
14557
16832
|
const newAnswers = { ...userAnswers || {}, ...resumeData?.answers || {} };
|
|
16833
|
+
console.log("before", storedQAPairs);
|
|
16834
|
+
console.log("newAnswers", newAnswers);
|
|
14558
16835
|
if (Object.keys(newAnswers).length > 0) {
|
|
14559
16836
|
storedQAPairs = storedQAPairs.map((pair) => {
|
|
14560
16837
|
if (newAnswers[pair.question.id]) {
|
|
@@ -14568,6 +16845,10 @@ var planningIterationStep = workflows.createStep({
|
|
|
14568
16845
|
});
|
|
14569
16846
|
runtimeContext.set(qaKey, storedQAPairs);
|
|
14570
16847
|
}
|
|
16848
|
+
console.log("after", storedQAPairs);
|
|
16849
|
+
console.log(
|
|
16850
|
+
`Current Q&A state: ${storedQAPairs.length} question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
|
|
16851
|
+
);
|
|
14571
16852
|
try {
|
|
14572
16853
|
const model = await resolveModel({ runtimeContext });
|
|
14573
16854
|
const planningAgent = new agent.Agent({
|
|
@@ -14615,8 +16896,8 @@ var planningIterationStep = workflows.createStep({
|
|
|
14615
16896
|
};
|
|
14616
16897
|
}
|
|
14617
16898
|
if (planResult.questions && planResult.questions.length > 0 && !planResult.planComplete) {
|
|
14618
|
-
console.
|
|
14619
|
-
console.
|
|
16899
|
+
console.log(`Planning needs user clarification: ${planResult.questions.length} questions`);
|
|
16900
|
+
console.log(planResult.questions);
|
|
14620
16901
|
const newQAPairs = planResult.questions.map((question) => ({
|
|
14621
16902
|
question,
|
|
14622
16903
|
answer: null,
|
|
@@ -14625,7 +16906,7 @@ var planningIterationStep = workflows.createStep({
|
|
|
14625
16906
|
}));
|
|
14626
16907
|
storedQAPairs = [...storedQAPairs, ...newQAPairs];
|
|
14627
16908
|
runtimeContext.set(qaKey, storedQAPairs);
|
|
14628
|
-
console.
|
|
16909
|
+
console.log(
|
|
14629
16910
|
`Updated Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
|
|
14630
16911
|
);
|
|
14631
16912
|
return suspend({
|
|
@@ -14637,9 +16918,9 @@ var planningIterationStep = workflows.createStep({
|
|
|
14637
16918
|
}
|
|
14638
16919
|
});
|
|
14639
16920
|
}
|
|
14640
|
-
console.
|
|
16921
|
+
console.log(`Planning complete with ${planResult.tasks.length} tasks`);
|
|
14641
16922
|
runtimeContext.set(qaKey, storedQAPairs);
|
|
14642
|
-
console.
|
|
16923
|
+
console.log(
|
|
14643
16924
|
`Final Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
|
|
14644
16925
|
);
|
|
14645
16926
|
return {
|
|
@@ -14682,7 +16963,7 @@ var taskApprovalStep = workflows.createStep({
|
|
|
14682
16963
|
execute: async ({ inputData, resumeData, suspend }) => {
|
|
14683
16964
|
const { tasks } = inputData;
|
|
14684
16965
|
if (!resumeData?.approved && resumeData?.approved !== false) {
|
|
14685
|
-
console.
|
|
16966
|
+
console.log(`Requesting user approval for ${tasks.length} tasks`);
|
|
14686
16967
|
const summary = `Task List for Approval:
|
|
14687
16968
|
|
|
14688
16969
|
${tasks.length} tasks planned:
|
|
@@ -14695,14 +16976,14 @@ ${tasks.map((task, i) => `${i + 1}. [${task.priority.toUpperCase()}] ${task.cont
|
|
|
14695
16976
|
});
|
|
14696
16977
|
}
|
|
14697
16978
|
if (resumeData.approved) {
|
|
14698
|
-
console.
|
|
16979
|
+
console.log("Task list approved by user");
|
|
14699
16980
|
return {
|
|
14700
16981
|
approved: true,
|
|
14701
16982
|
tasks,
|
|
14702
16983
|
message: "Task list approved, ready for execution"
|
|
14703
16984
|
};
|
|
14704
16985
|
} else {
|
|
14705
|
-
console.
|
|
16986
|
+
console.log("Task list rejected by user");
|
|
14706
16987
|
return {
|
|
14707
16988
|
approved: false,
|
|
14708
16989
|
tasks,
|
|
@@ -14719,7 +17000,7 @@ var planningAndApprovalWorkflow = workflows.createWorkflow({
|
|
|
14719
17000
|
outputSchema: TaskApprovalOutputSchema,
|
|
14720
17001
|
steps: [planningIterationStep, taskApprovalStep]
|
|
14721
17002
|
}).dountil(planningIterationStep, async ({ inputData }) => {
|
|
14722
|
-
console.
|
|
17003
|
+
console.log(`Sub-workflow planning check: planComplete=${inputData.planComplete}`);
|
|
14723
17004
|
return inputData.planComplete === true;
|
|
14724
17005
|
}).map(async ({ inputData }) => {
|
|
14725
17006
|
return {
|
|
@@ -15170,12 +17451,12 @@ var workflowDiscoveryStep = workflows.createStep({
|
|
|
15170
17451
|
inputSchema: WorkflowBuilderInputSchema,
|
|
15171
17452
|
outputSchema: WorkflowDiscoveryResultSchema,
|
|
15172
17453
|
execute: async ({ inputData, runtimeContext: _runtimeContext }) => {
|
|
15173
|
-
console.
|
|
17454
|
+
console.log("Starting workflow discovery...");
|
|
15174
17455
|
const { projectPath = process.cwd() } = inputData;
|
|
15175
17456
|
try {
|
|
15176
17457
|
const workflowsPath = path.join(projectPath, "src/mastra/workflows");
|
|
15177
17458
|
if (!fs.existsSync(workflowsPath)) {
|
|
15178
|
-
console.
|
|
17459
|
+
console.log("No workflows directory found");
|
|
15179
17460
|
return {
|
|
15180
17461
|
success: true,
|
|
15181
17462
|
workflows: [],
|
|
@@ -15204,7 +17485,7 @@ var workflowDiscoveryStep = workflows.createStep({
|
|
|
15204
17485
|
}
|
|
15205
17486
|
}
|
|
15206
17487
|
}
|
|
15207
|
-
console.
|
|
17488
|
+
console.log(`Discovered ${workflows.length} existing workflows`);
|
|
15208
17489
|
return {
|
|
15209
17490
|
success: true,
|
|
15210
17491
|
workflows,
|
|
@@ -15229,7 +17510,7 @@ var projectDiscoveryStep = workflows.createStep({
|
|
|
15229
17510
|
inputSchema: WorkflowDiscoveryResultSchema,
|
|
15230
17511
|
outputSchema: ProjectDiscoveryResultSchema,
|
|
15231
17512
|
execute: async ({ inputData: _inputData, runtimeContext: _runtimeContext }) => {
|
|
15232
|
-
console.
|
|
17513
|
+
console.log("Starting project discovery...");
|
|
15233
17514
|
try {
|
|
15234
17515
|
const projectPath = process.cwd();
|
|
15235
17516
|
const projectStructure = {
|
|
@@ -15250,7 +17531,7 @@ var projectDiscoveryStep = workflows.createStep({
|
|
|
15250
17531
|
console.warn("Failed to read package.json:", error);
|
|
15251
17532
|
}
|
|
15252
17533
|
}
|
|
15253
|
-
console.
|
|
17534
|
+
console.log("Project discovery completed");
|
|
15254
17535
|
return {
|
|
15255
17536
|
success: true,
|
|
15256
17537
|
structure: {
|
|
@@ -15291,7 +17572,7 @@ var workflowResearchStep = workflows.createStep({
|
|
|
15291
17572
|
inputSchema: ProjectDiscoveryResultSchema,
|
|
15292
17573
|
outputSchema: WorkflowResearchResultSchema,
|
|
15293
17574
|
execute: async ({ inputData, runtimeContext }) => {
|
|
15294
|
-
console.
|
|
17575
|
+
console.log("Starting workflow research...");
|
|
15295
17576
|
try {
|
|
15296
17577
|
const model = await resolveModel({ runtimeContext });
|
|
15297
17578
|
const researchAgent = new agent.Agent({
|
|
@@ -15323,7 +17604,7 @@ var workflowResearchStep = workflows.createStep({
|
|
|
15323
17604
|
error: "Research agent failed to generate valid response"
|
|
15324
17605
|
};
|
|
15325
17606
|
}
|
|
15326
|
-
console.
|
|
17607
|
+
console.log("Research completed successfully");
|
|
15327
17608
|
return {
|
|
15328
17609
|
success: true,
|
|
15329
17610
|
documentation: {
|
|
@@ -15367,12 +17648,12 @@ var taskExecutionStep = workflows.createStep({
|
|
|
15367
17648
|
research,
|
|
15368
17649
|
projectPath
|
|
15369
17650
|
} = inputData;
|
|
15370
|
-
console.
|
|
15371
|
-
console.
|
|
17651
|
+
console.log(`Starting task execution for ${action}ing workflow: ${workflowName}`);
|
|
17652
|
+
console.log(`Executing ${tasks.length} tasks using AgentBuilder stream...`);
|
|
15372
17653
|
try {
|
|
15373
17654
|
const model = await resolveModel({ runtimeContext });
|
|
15374
17655
|
const currentProjectPath = projectPath || process.cwd();
|
|
15375
|
-
console.
|
|
17656
|
+
console.log("Pre-populating taskManager with planned tasks...");
|
|
15376
17657
|
const taskManagerContext = {
|
|
15377
17658
|
action: "create",
|
|
15378
17659
|
tasks: tasks.map((task) => ({
|
|
@@ -15385,7 +17666,7 @@ var taskExecutionStep = workflows.createStep({
|
|
|
15385
17666
|
}))
|
|
15386
17667
|
};
|
|
15387
17668
|
const taskManagerResult = await AgentBuilderDefaults.manageTaskList(taskManagerContext);
|
|
15388
|
-
console.
|
|
17669
|
+
console.log(`Task manager initialized with ${taskManagerResult.tasks.length} tasks`);
|
|
15389
17670
|
if (!taskManagerResult.success) {
|
|
15390
17671
|
throw new Error(`Failed to initialize task manager: ${taskManagerResult.message}`);
|
|
15391
17672
|
}
|
|
@@ -15438,13 +17719,13 @@ ${additionalInstructions}`;
|
|
|
15438
17719
|
const currentTaskStatus = await AgentBuilderDefaults.manageTaskList({ action: "list" });
|
|
15439
17720
|
const completedTasks = currentTaskStatus.tasks.filter((task) => task.status === "completed");
|
|
15440
17721
|
const pendingTasks = currentTaskStatus.tasks.filter((task) => task.status !== "completed");
|
|
15441
|
-
console.
|
|
17722
|
+
console.log(`
|
|
15442
17723
|
=== EXECUTION ITERATION ${iterationCount} ===`);
|
|
15443
|
-
console.
|
|
15444
|
-
console.
|
|
17724
|
+
console.log(`Completed tasks: ${completedTasks.length}/${expectedTaskIds.length}`);
|
|
17725
|
+
console.log(`Remaining tasks: ${pendingTasks.map((t2) => t2.id).join(", ")}`);
|
|
15445
17726
|
allTasksCompleted = pendingTasks.length === 0;
|
|
15446
17727
|
if (allTasksCompleted) {
|
|
15447
|
-
console.
|
|
17728
|
+
console.log("All tasks completed! Breaking execution loop.");
|
|
15448
17729
|
break;
|
|
15449
17730
|
}
|
|
15450
17731
|
const iterationPrompt = iterationCount === 1 ? executionPrompt : `${workflowBuilderPrompts.executionAgent.iterationPrompt({
|
|
@@ -15468,19 +17749,19 @@ ${workflowBuilderPrompts.validation.instructions}`;
|
|
|
15468
17749
|
finalMessage += chunk.payload.text;
|
|
15469
17750
|
}
|
|
15470
17751
|
if (chunk.type === "step-finish") {
|
|
15471
|
-
console.
|
|
17752
|
+
console.log(finalMessage);
|
|
15472
17753
|
finalMessage = "";
|
|
15473
17754
|
}
|
|
15474
17755
|
if (chunk.type === "tool-result") {
|
|
15475
|
-
console.
|
|
17756
|
+
console.log(JSON.stringify(chunk, null, 2));
|
|
15476
17757
|
}
|
|
15477
17758
|
if (chunk.type === "finish") {
|
|
15478
|
-
console.
|
|
17759
|
+
console.log(chunk);
|
|
15479
17760
|
}
|
|
15480
17761
|
}
|
|
15481
17762
|
await stream.consumeStream();
|
|
15482
17763
|
finalResult = await stream.object;
|
|
15483
|
-
console.
|
|
17764
|
+
console.log(`Iteration ${iterationCount} result:`, { finalResult });
|
|
15484
17765
|
if (!finalResult) {
|
|
15485
17766
|
throw new Error(`No result received from agent execution on iteration ${iterationCount}`);
|
|
15486
17767
|
}
|
|
@@ -15488,17 +17769,17 @@ ${workflowBuilderPrompts.validation.instructions}`;
|
|
|
15488
17769
|
const postCompletedTasks = postIterationTaskStatus.tasks.filter((task) => task.status === "completed");
|
|
15489
17770
|
const postPendingTasks = postIterationTaskStatus.tasks.filter((task) => task.status !== "completed");
|
|
15490
17771
|
allTasksCompleted = postPendingTasks.length === 0;
|
|
15491
|
-
console.
|
|
17772
|
+
console.log(
|
|
15492
17773
|
`After iteration ${iterationCount}: ${postCompletedTasks.length}/${expectedTaskIds.length} tasks completed in taskManager`
|
|
15493
17774
|
);
|
|
15494
17775
|
if (finalResult.status === "needs_clarification" && finalResult.questions && finalResult.questions.length > 0) {
|
|
15495
|
-
console.
|
|
17776
|
+
console.log(
|
|
15496
17777
|
`Agent needs clarification on iteration ${iterationCount}: ${finalResult.questions.length} questions`
|
|
15497
17778
|
);
|
|
15498
17779
|
break;
|
|
15499
17780
|
}
|
|
15500
17781
|
if (finalResult.status === "completed" && !allTasksCompleted) {
|
|
15501
|
-
console.
|
|
17782
|
+
console.log(
|
|
15502
17783
|
`Agent claimed completion but taskManager shows pending tasks: ${postPendingTasks.map((t2) => t2.id).join(", ")}`
|
|
15503
17784
|
);
|
|
15504
17785
|
}
|
|
@@ -15511,8 +17792,8 @@ ${workflowBuilderPrompts.validation.instructions}`;
|
|
|
15511
17792
|
throw new Error("No result received from agent execution");
|
|
15512
17793
|
}
|
|
15513
17794
|
if (finalResult.status === "needs_clarification" && finalResult.questions && finalResult.questions.length > 0) {
|
|
15514
|
-
console.
|
|
15515
|
-
console.
|
|
17795
|
+
console.log(`Agent needs clarification: ${finalResult.questions.length} questions`);
|
|
17796
|
+
console.log("finalResult", JSON.stringify(finalResult, null, 2));
|
|
15516
17797
|
return suspend({
|
|
15517
17798
|
questions: finalResult.questions,
|
|
15518
17799
|
currentProgress: finalResult.progress,
|
|
@@ -15528,7 +17809,7 @@ ${workflowBuilderPrompts.validation.instructions}`;
|
|
|
15528
17809
|
const finalAllTasksCompleted = finalPendingTasks.length === 0;
|
|
15529
17810
|
const success = finalAllTasksCompleted && !finalResult.error;
|
|
15530
17811
|
const message = success ? `Successfully completed workflow ${action} - all ${tasksExpected} tasks completed after ${iterationCount} iteration(s): ${finalResult.message}` : `Workflow execution finished with issues after ${iterationCount} iteration(s): ${finalResult.message}. Completed: ${tasksCompleted}/${tasksExpected} tasks`;
|
|
15531
|
-
console.
|
|
17812
|
+
console.log(message);
|
|
15532
17813
|
const missingTasks = finalPendingTasks.map((task) => task.id);
|
|
15533
17814
|
const validationErrors = [];
|
|
15534
17815
|
if (finalResult.error) {
|
|
@@ -15596,7 +17877,7 @@ var workflowBuilderWorkflow = workflows.createWorkflow({
|
|
|
15596
17877
|
userAnswers: void 0
|
|
15597
17878
|
};
|
|
15598
17879
|
}).dountil(planningAndApprovalWorkflow, async ({ inputData }) => {
|
|
15599
|
-
console.
|
|
17880
|
+
console.log(`Sub-workflow check: approved=${inputData.approved}`);
|
|
15600
17881
|
return inputData.approved === true;
|
|
15601
17882
|
}).map(async ({ getStepResult, getInitData }) => {
|
|
15602
17883
|
const initData = getInitData();
|
|
@@ -15628,8 +17909,8 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15628
17909
|
const mastra = actionArgs.mastra;
|
|
15629
17910
|
const logger = mastra.getLogger();
|
|
15630
17911
|
try {
|
|
15631
|
-
|
|
15632
|
-
if (actionId && !
|
|
17912
|
+
chunk6LUKYSWE_cjs.WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);
|
|
17913
|
+
if (actionId && !chunk6LUKYSWE_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
|
|
15633
17914
|
throw new chunk7NADHFD2_cjs.HTTPException(400, {
|
|
15634
17915
|
message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(", ")}`
|
|
15635
17916
|
});
|
|
@@ -15644,7 +17925,7 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15644
17925
|
const result = await workflowHandlerFn(handlerArgs);
|
|
15645
17926
|
return result;
|
|
15646
17927
|
} finally {
|
|
15647
|
-
|
|
17928
|
+
chunk6LUKYSWE_cjs.WorkflowRegistry.cleanup();
|
|
15648
17929
|
}
|
|
15649
17930
|
} catch (error) {
|
|
15650
17931
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -15658,10 +17939,10 @@ function createAgentBuilderWorkflowHandler(workflowHandlerFn, logMessage) {
|
|
|
15658
17939
|
}
|
|
15659
17940
|
var getAgentBuilderActionsHandler = createAgentBuilderWorkflowHandler(async () => {
|
|
15660
17941
|
try {
|
|
15661
|
-
const registryWorkflows =
|
|
17942
|
+
const registryWorkflows = chunk6LUKYSWE_cjs.WorkflowRegistry.getAllWorkflows();
|
|
15662
17943
|
const _workflows = Object.entries(registryWorkflows).reduce(
|
|
15663
17944
|
(acc, [key, workflow]) => {
|
|
15664
|
-
acc[key] =
|
|
17945
|
+
acc[key] = chunk6LUKYSWE_cjs.getWorkflowInfo(workflow);
|
|
15665
17946
|
return acc;
|
|
15666
17947
|
},
|
|
15667
17948
|
{}
|
|
@@ -15672,59 +17953,59 @@ var getAgentBuilderActionsHandler = createAgentBuilderWorkflowHandler(async () =
|
|
|
15672
17953
|
}
|
|
15673
17954
|
}, "Getting agent builder actions");
|
|
15674
17955
|
var getAgentBuilderActionByIdHandler = createAgentBuilderWorkflowHandler(
|
|
15675
|
-
|
|
17956
|
+
chunk6LUKYSWE_cjs.getWorkflowByIdHandler,
|
|
15676
17957
|
"Getting agent builder action by ID"
|
|
15677
17958
|
);
|
|
15678
17959
|
var getAgentBuilderActionRunByIdHandler = createAgentBuilderWorkflowHandler(
|
|
15679
|
-
|
|
17960
|
+
chunk6LUKYSWE_cjs.getWorkflowRunByIdHandler,
|
|
15680
17961
|
"Getting agent builder action run by ID"
|
|
15681
17962
|
);
|
|
15682
17963
|
var getAgentBuilderActionRunExecutionResultHandler = createAgentBuilderWorkflowHandler(
|
|
15683
|
-
|
|
17964
|
+
chunk6LUKYSWE_cjs.getWorkflowRunExecutionResultHandler,
|
|
15684
17965
|
"Getting agent builder action run execution result"
|
|
15685
17966
|
);
|
|
15686
17967
|
var createAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15687
|
-
|
|
17968
|
+
chunk6LUKYSWE_cjs.createWorkflowRunHandler,
|
|
15688
17969
|
"Creating agent builder action run"
|
|
15689
17970
|
);
|
|
15690
17971
|
var startAsyncAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15691
|
-
|
|
17972
|
+
chunk6LUKYSWE_cjs.startAsyncWorkflowHandler,
|
|
15692
17973
|
"Starting async agent builder action"
|
|
15693
17974
|
);
|
|
15694
17975
|
var startAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15695
|
-
|
|
17976
|
+
chunk6LUKYSWE_cjs.startWorkflowRunHandler,
|
|
15696
17977
|
"Starting agent builder action run"
|
|
15697
17978
|
);
|
|
15698
17979
|
var watchAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15699
|
-
|
|
17980
|
+
chunk6LUKYSWE_cjs.watchWorkflowHandler,
|
|
15700
17981
|
"Watching agent builder action"
|
|
15701
17982
|
);
|
|
15702
17983
|
var streamAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15703
|
-
|
|
17984
|
+
chunk6LUKYSWE_cjs.streamWorkflowHandler,
|
|
15704
17985
|
"Streaming agent builder action"
|
|
15705
17986
|
);
|
|
15706
17987
|
var streamVNextAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15707
|
-
|
|
17988
|
+
chunk6LUKYSWE_cjs.streamVNextWorkflowHandler,
|
|
15708
17989
|
"Streaming VNext agent builder action"
|
|
15709
17990
|
);
|
|
15710
17991
|
var resumeAsyncAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15711
|
-
|
|
17992
|
+
chunk6LUKYSWE_cjs.resumeAsyncWorkflowHandler,
|
|
15712
17993
|
"Resuming async agent builder action"
|
|
15713
17994
|
);
|
|
15714
17995
|
var resumeAgentBuilderActionHandler = createAgentBuilderWorkflowHandler(
|
|
15715
|
-
|
|
17996
|
+
chunk6LUKYSWE_cjs.resumeWorkflowHandler,
|
|
15716
17997
|
"Resuming agent builder action"
|
|
15717
17998
|
);
|
|
15718
17999
|
var getAgentBuilderActionRunsHandler = createAgentBuilderWorkflowHandler(
|
|
15719
|
-
|
|
18000
|
+
chunk6LUKYSWE_cjs.getWorkflowRunsHandler,
|
|
15720
18001
|
"Getting agent builder action runs"
|
|
15721
18002
|
);
|
|
15722
18003
|
var cancelAgentBuilderActionRunHandler = createAgentBuilderWorkflowHandler(
|
|
15723
|
-
|
|
18004
|
+
chunk6LUKYSWE_cjs.cancelWorkflowRunHandler,
|
|
15724
18005
|
"Cancelling agent builder action run"
|
|
15725
18006
|
);
|
|
15726
18007
|
var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
|
|
15727
|
-
|
|
18008
|
+
chunk6LUKYSWE_cjs.sendWorkflowRunEventHandler,
|
|
15728
18009
|
"Sending agent builder action run event"
|
|
15729
18010
|
);
|
|
15730
18011
|
|
|
@@ -15744,5 +18025,5 @@ exports.startAsyncAgentBuilderActionHandler = startAsyncAgentBuilderActionHandle
|
|
|
15744
18025
|
exports.streamAgentBuilderActionHandler = streamAgentBuilderActionHandler;
|
|
15745
18026
|
exports.streamVNextAgentBuilderActionHandler = streamVNextAgentBuilderActionHandler;
|
|
15746
18027
|
exports.watchAgentBuilderActionHandler = watchAgentBuilderActionHandler;
|
|
15747
|
-
//# sourceMappingURL=chunk-
|
|
15748
|
-
//# sourceMappingURL=chunk-
|
|
18028
|
+
//# sourceMappingURL=chunk-JJBXJYMY.cjs.map
|
|
18029
|
+
//# sourceMappingURL=chunk-JJBXJYMY.cjs.map
|