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