@mastra/server 0.17.0-alpha.5 → 0.17.0-alpha.6

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