@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,4 +1,4 @@
1
- import { WorkflowRegistry, getWorkflowInfo, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, createWorkflowRunHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, streamWorkflowHandler, streamVNextWorkflowHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, getWorkflowRunsHandler, cancelWorkflowRunHandler, sendWorkflowRunEventHandler } from './chunk-B2V3PUB7.js';
1
+ import { WorkflowRegistry, getWorkflowInfo, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, createWorkflowRunHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, streamWorkflowHandler, streamVNextWorkflowHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, getWorkflowRunsHandler, cancelWorkflowRunHandler, sendWorkflowRunEventHandler } from './chunk-SLV7G742.js';
2
2
  import { openai as openai$1 } from './chunk-4RRMWXQ2.js';
3
3
  import { InvalidArgumentError, esm_default, APICallError, EmptyResponseBodyError, AISDKError as AISDKError$1, JSONParseError, TypeValidationError, EventSourceParserStream, NoSuchModelError } from './chunk-N7F33WAD.js';
4
4
  import { openai } from './chunk-6GMFZ5LK.js';
@@ -146,8 +146,8 @@ var require_ignore = __commonJS({
146
146
  TMP_KEY_IGNORE = Symbol.for("node-ignore");
147
147
  }
148
148
  var KEY_IGNORE = TMP_KEY_IGNORE;
149
- var define = (object4, key, value) => {
150
- Object.defineProperty(object4, key, { value });
149
+ var define = (object3, key, value) => {
150
+ Object.defineProperty(object3, key, { value });
151
151
  return value;
152
152
  };
153
153
  var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
@@ -599,10 +599,10 @@ __export(agent_builder_exports, {
599
599
  streamVNextAgentBuilderActionHandler: () => streamVNextAgentBuilderActionHandler,
600
600
  watchAgentBuilderActionHandler: () => watchAgentBuilderActionHandler
601
601
  });
602
- function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relative") {
602
+ function zodToJsonSchema(zodSchema3, target = "jsonSchema7", strategy = "relative") {
603
603
  const fn = "toJSONSchema";
604
604
  if (fn in z) {
605
- return z[fn](zodSchema4, {
605
+ return z[fn](zodSchema3, {
606
606
  unrepresentable: "any",
607
607
  override: (ctx) => {
608
608
  const def = ctx.zodSchema?._zod?.def;
@@ -613,7 +613,7 @@ function zodToJsonSchema(zodSchema4, target = "jsonSchema7", strategy = "relativ
613
613
  }
614
614
  });
615
615
  } else {
616
- return esm_default(zodSchema4, {
616
+ return esm_default(zodSchema3, {
617
617
  $refStrategy: strategy,
618
618
  target
619
619
  });
@@ -1213,8 +1213,8 @@ function formatDataStreamPart(type, value) {
1213
1213
  `;
1214
1214
  }
1215
1215
  function zodSchema(zodSchema22, options) {
1216
- var _a20;
1217
- const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
1216
+ var _a19;
1217
+ const useReferences = (_a19 = void 0 ) != null ? _a19 : false;
1218
1218
  return jsonSchema(
1219
1219
  esm_default(zodSchema22, {
1220
1220
  $refStrategy: useReferences ? "root" : "none",
@@ -1327,11 +1327,11 @@ var major = VERSION.split(".")[0];
1327
1327
  var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
1328
1328
  var _global = _globalThis;
1329
1329
  function registerGlobal(type, instance, diag, allowOverride) {
1330
- var _a20;
1330
+ var _a19;
1331
1331
  if (allowOverride === void 0) {
1332
1332
  allowOverride = false;
1333
1333
  }
1334
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a20 !== void 0 ? _a20 : {
1334
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a19 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a19 !== void 0 ? _a19 : {
1335
1335
  version: VERSION
1336
1336
  };
1337
1337
  if (!allowOverride && api[type]) {
@@ -1349,8 +1349,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
1349
1349
  return true;
1350
1350
  }
1351
1351
  function getGlobal(type) {
1352
- var _a20, _b8;
1353
- var globalVersion = (_a20 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a20 === void 0 ? void 0 : _a20.version;
1352
+ var _a19, _b8;
1353
+ var globalVersion = (_a19 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a19 === void 0 ? void 0 : _a19.version;
1354
1354
  if (!globalVersion || !isCompatible(globalVersion)) {
1355
1355
  return;
1356
1356
  }
@@ -1527,13 +1527,13 @@ var DiagAPI = (
1527
1527
  }
1528
1528
  var self = this;
1529
1529
  var setLogger = function(logger, optionsOrLogLevel) {
1530
- var _a20, _b8, _c;
1530
+ var _a19, _b8, _c;
1531
1531
  if (optionsOrLogLevel === void 0) {
1532
1532
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
1533
1533
  }
1534
1534
  if (logger === self) {
1535
1535
  var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
1536
- self.error((_a20 = err.stack) !== null && _a20 !== void 0 ? _a20 : err.message);
1536
+ self.error((_a19 = err.stack) !== null && _a19 !== void 0 ? _a19 : err.message);
1537
1537
  return false;
1538
1538
  }
1539
1539
  if (typeof optionsOrLogLevel === "number") {
@@ -1704,12 +1704,12 @@ var ContextAPI = (
1704
1704
  return this._getContextManager().active();
1705
1705
  };
1706
1706
  ContextAPI2.prototype.with = function(context, fn, thisArg) {
1707
- var _a20;
1707
+ var _a19;
1708
1708
  var args = [];
1709
1709
  for (var _i = 3; _i < arguments.length; _i++) {
1710
1710
  args[_i - 3] = arguments[_i];
1711
1711
  }
1712
- return (_a20 = this._getContextManager()).with.apply(_a20, __spreadArray4([context, fn, thisArg], __read4(args), false));
1712
+ return (_a19 = this._getContextManager()).with.apply(_a19, __spreadArray4([context, fn, thisArg], __read4(args), false));
1713
1713
  };
1714
1714
  ContextAPI2.prototype.bind = function(context, target) {
1715
1715
  return this._getContextManager().bind(context, target);
@@ -1804,8 +1804,8 @@ function setSpanContext(context, spanContext) {
1804
1804
  return setSpan(context, new NonRecordingSpan(spanContext));
1805
1805
  }
1806
1806
  function getSpanContext(context) {
1807
- var _a20;
1808
- return (_a20 = getSpan(context)) === null || _a20 === void 0 ? void 0 : _a20.spanContext();
1807
+ var _a19;
1808
+ return (_a19 = getSpan(context)) === null || _a19 === void 0 ? void 0 : _a19.spanContext();
1809
1809
  }
1810
1810
 
1811
1811
  // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
@@ -1831,7 +1831,7 @@ var NoopTracer = (
1831
1831
  (function() {
1832
1832
  function NoopTracer2() {
1833
1833
  }
1834
- NoopTracer2.prototype.startSpan = function(name20, options, context) {
1834
+ NoopTracer2.prototype.startSpan = function(name19, options, context) {
1835
1835
  if (context === void 0) {
1836
1836
  context = contextApi.active();
1837
1837
  }
@@ -1846,7 +1846,7 @@ var NoopTracer = (
1846
1846
  return new NonRecordingSpan();
1847
1847
  }
1848
1848
  };
1849
- NoopTracer2.prototype.startActiveSpan = function(name20, arg2, arg3, arg4) {
1849
+ NoopTracer2.prototype.startActiveSpan = function(name19, arg2, arg3, arg4) {
1850
1850
  var opts;
1851
1851
  var ctx;
1852
1852
  var fn;
@@ -1863,7 +1863,7 @@ var NoopTracer = (
1863
1863
  fn = arg4;
1864
1864
  }
1865
1865
  var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
1866
- var span = this.startSpan(name20, opts, parentContext);
1866
+ var span = this.startSpan(name19, opts, parentContext);
1867
1867
  var contextWithSpanSet = setSpan(parentContext, span);
1868
1868
  return contextApi.with(contextWithSpanSet, fn, void 0, span);
1869
1869
  };
@@ -1879,14 +1879,14 @@ var NOOP_TRACER = new NoopTracer();
1879
1879
  var ProxyTracer = (
1880
1880
  /** @class */
1881
1881
  (function() {
1882
- function ProxyTracer2(_provider, name20, version, options) {
1882
+ function ProxyTracer2(_provider, name19, version, options) {
1883
1883
  this._provider = _provider;
1884
- this.name = name20;
1884
+ this.name = name19;
1885
1885
  this.version = version;
1886
1886
  this.options = options;
1887
1887
  }
1888
- ProxyTracer2.prototype.startSpan = function(name20, options, context) {
1889
- return this._getTracer().startSpan(name20, options, context);
1888
+ ProxyTracer2.prototype.startSpan = function(name19, options, context) {
1889
+ return this._getTracer().startSpan(name19, options, context);
1890
1890
  };
1891
1891
  ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
1892
1892
  var tracer = this._getTracer();
@@ -1927,20 +1927,20 @@ var ProxyTracerProvider = (
1927
1927
  (function() {
1928
1928
  function ProxyTracerProvider2() {
1929
1929
  }
1930
- ProxyTracerProvider2.prototype.getTracer = function(name20, version, options) {
1931
- var _a20;
1932
- return (_a20 = this.getDelegateTracer(name20, version, options)) !== null && _a20 !== void 0 ? _a20 : new ProxyTracer(this, name20, version, options);
1930
+ ProxyTracerProvider2.prototype.getTracer = function(name19, version, options) {
1931
+ var _a19;
1932
+ return (_a19 = this.getDelegateTracer(name19, version, options)) !== null && _a19 !== void 0 ? _a19 : new ProxyTracer(this, name19, version, options);
1933
1933
  };
1934
1934
  ProxyTracerProvider2.prototype.getDelegate = function() {
1935
- var _a20;
1936
- return (_a20 = this._delegate) !== null && _a20 !== void 0 ? _a20 : NOOP_TRACER_PROVIDER;
1935
+ var _a19;
1936
+ return (_a19 = this._delegate) !== null && _a19 !== void 0 ? _a19 : NOOP_TRACER_PROVIDER;
1937
1937
  };
1938
1938
  ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
1939
1939
  this._delegate = delegate;
1940
1940
  };
1941
- ProxyTracerProvider2.prototype.getDelegateTracer = function(name20, version, options) {
1942
- var _a20;
1943
- return (_a20 = this._delegate) === null || _a20 === void 0 ? void 0 : _a20.getTracer(name20, version, options);
1941
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name19, version, options) {
1942
+ var _a19;
1943
+ return (_a19 = this._delegate) === null || _a19 === void 0 ? void 0 : _a19.getTracer(name19, version, options);
1944
1944
  };
1945
1945
  return ProxyTracerProvider2;
1946
1946
  })()
@@ -1986,8 +1986,8 @@ var TraceAPI = (
1986
1986
  TraceAPI2.prototype.getTracerProvider = function() {
1987
1987
  return getGlobal(API_NAME3) || this._proxyTracerProvider;
1988
1988
  };
1989
- TraceAPI2.prototype.getTracer = function(name20, version) {
1990
- return this.getTracerProvider().getTracer(name20, version);
1989
+ TraceAPI2.prototype.getTracer = function(name19, version) {
1990
+ return this.getTracerProvider().getTracer(name19, version);
1991
1991
  };
1992
1992
  TraceAPI2.prototype.disable = function() {
1993
1993
  unregisterGlobal(API_NAME3, DiagAPI.instance());
@@ -3184,11 +3184,11 @@ function extractResponseHeaders(response) {
3184
3184
  return Object.fromEntries([...response.headers]);
3185
3185
  }
3186
3186
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
3187
- var _a20, _b8, _c;
3187
+ var _a19, _b8, _c;
3188
3188
  if (globalThisAny.window) {
3189
3189
  return `runtime/browser`;
3190
3190
  }
3191
- if ((_a20 = globalThisAny.navigator) == null ? void 0 : _a20.userAgent) {
3191
+ if ((_a19 = globalThisAny.navigator) == null ? void 0 : _a19.userAgent) {
3192
3192
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
3193
3193
  }
3194
3194
  if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
@@ -3369,12 +3369,12 @@ function loadOptionalSetting({
3369
3369
  }
3370
3370
  var suspectProtoRx = /"__proto__"\s*:/;
3371
3371
  var suspectConstructorRx = /"constructor"\s*:/;
3372
- function _parse(text4) {
3373
- const obj = JSON.parse(text4);
3372
+ function _parse(text3) {
3373
+ const obj = JSON.parse(text3);
3374
3374
  if (obj === null || typeof obj !== "object") {
3375
3375
  return obj;
3376
3376
  }
3377
- if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
3377
+ if (suspectProtoRx.test(text3) === false && suspectConstructorRx.test(text3) === false) {
3378
3378
  return obj;
3379
3379
  }
3380
3380
  return filter(obj);
@@ -3401,11 +3401,11 @@ function filter(obj) {
3401
3401
  }
3402
3402
  return obj;
3403
3403
  }
3404
- function secureJsonParse(text4) {
3404
+ function secureJsonParse(text3) {
3405
3405
  const { stackTraceLimit } = Error;
3406
3406
  Error.stackTraceLimit = 0;
3407
3407
  try {
3408
- return _parse(text4);
3408
+ return _parse(text3);
3409
3409
  } finally {
3410
3410
  Error.stackTraceLimit = stackTraceLimit;
3411
3411
  }
@@ -3446,12 +3446,12 @@ async function safeValidateTypes2({
3446
3446
  value,
3447
3447
  schema
3448
3448
  }) {
3449
- const validator22 = asValidator(schema);
3449
+ const validator2 = asValidator(schema);
3450
3450
  try {
3451
- if (validator22.validate == null) {
3451
+ if (validator2.validate == null) {
3452
3452
  return { success: true, value, rawValue: value };
3453
3453
  }
3454
- const result = await validator22.validate(value);
3454
+ const result = await validator2.validate(value);
3455
3455
  if (result.success) {
3456
3456
  return { success: true, value: result.value, rawValue: value };
3457
3457
  }
@@ -3469,11 +3469,11 @@ async function safeValidateTypes2({
3469
3469
  }
3470
3470
  }
3471
3471
  async function parseJSON({
3472
- text: text4,
3472
+ text: text3,
3473
3473
  schema
3474
3474
  }) {
3475
3475
  try {
3476
- const value = secureJsonParse(text4);
3476
+ const value = secureJsonParse(text3);
3477
3477
  if (schema == null) {
3478
3478
  return value;
3479
3479
  }
@@ -3482,15 +3482,15 @@ async function parseJSON({
3482
3482
  if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
3483
3483
  throw error;
3484
3484
  }
3485
- throw new JSONParseError({ text: text4, cause: error });
3485
+ throw new JSONParseError({ text: text3, cause: error });
3486
3486
  }
3487
3487
  }
3488
3488
  async function safeParseJSON2({
3489
- text: text4,
3489
+ text: text3,
3490
3490
  schema
3491
3491
  }) {
3492
3492
  try {
3493
- const value = secureJsonParse(text4);
3493
+ const value = secureJsonParse(text3);
3494
3494
  if (schema == null) {
3495
3495
  return { success: true, value, rawValue: value };
3496
3496
  }
@@ -3498,7 +3498,7 @@ async function safeParseJSON2({
3498
3498
  } catch (error) {
3499
3499
  return {
3500
3500
  success: false,
3501
- error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
3501
+ error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text3, cause: error }),
3502
3502
  rawValue: void 0
3503
3503
  };
3504
3504
  }
@@ -3751,11 +3751,11 @@ function parseAnyDef() {
3751
3751
  return {};
3752
3752
  }
3753
3753
  function parseArrayDef(def, refs) {
3754
- var _a20, _b8, _c;
3754
+ var _a19, _b8, _c;
3755
3755
  const res = {
3756
3756
  type: "array"
3757
3757
  };
3758
- if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
3758
+ if (((_a19 = def.type) == null ? void 0 : _a19._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
3759
3759
  res.items = parseDef(def.type._def, {
3760
3760
  ...refs,
3761
3761
  currentPath: [...refs.currentPath, "items"]
@@ -4116,8 +4116,8 @@ function escapeNonAlphaNumeric(source) {
4116
4116
  return result;
4117
4117
  }
4118
4118
  function addFormat(schema, value, message, refs) {
4119
- var _a20;
4120
- if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
4119
+ var _a19;
4120
+ if (schema.format || ((_a19 = schema.anyOf) == null ? void 0 : _a19.some((x) => x.format))) {
4121
4121
  if (!schema.anyOf) {
4122
4122
  schema.anyOf = [];
4123
4123
  }
@@ -4136,8 +4136,8 @@ function addFormat(schema, value, message, refs) {
4136
4136
  }
4137
4137
  }
4138
4138
  function addPattern(schema, regex, message, refs) {
4139
- var _a20;
4140
- if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
4139
+ var _a19;
4140
+ if (schema.pattern || ((_a19 = schema.allOf) == null ? void 0 : _a19.some((x) => x.pattern))) {
4141
4141
  if (!schema.allOf) {
4142
4142
  schema.allOf = [];
4143
4143
  }
@@ -4156,7 +4156,7 @@ function addPattern(schema, regex, message, refs) {
4156
4156
  }
4157
4157
  }
4158
4158
  function stringifyRegExpWithFlags(regex, refs) {
4159
- var _a20;
4159
+ var _a19;
4160
4160
  if (!refs.applyRegexFlags || !regex.flags) {
4161
4161
  return regex.source;
4162
4162
  }
@@ -4186,7 +4186,7 @@ function stringifyRegExpWithFlags(regex, refs) {
4186
4186
  pattern += source[i];
4187
4187
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
4188
4188
  inCharRange = false;
4189
- } else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
4189
+ } else if (source[i + 1] === "-" && ((_a19 = source[i + 2]) == null ? void 0 : _a19.match(/[a-z]/))) {
4190
4190
  pattern += source[i];
4191
4191
  inCharRange = true;
4192
4192
  } else {
@@ -4228,13 +4228,13 @@ function stringifyRegExpWithFlags(regex, refs) {
4228
4228
  return pattern;
4229
4229
  }
4230
4230
  function parseRecordDef(def, refs) {
4231
- var _a20, _b8, _c, _d, _e, _f;
4231
+ var _a19, _b8, _c, _d, _e, _f;
4232
4232
  const schema = {
4233
4233
  type: "object",
4234
- additionalProperties: (_a20 = parseDef(def.valueType._def, {
4234
+ additionalProperties: (_a19 = parseDef(def.valueType._def, {
4235
4235
  ...refs,
4236
4236
  currentPath: [...refs.currentPath, "additionalProperties"]
4237
- })) != null ? _a20 : refs.allowedAdditionalProperties
4237
+ })) != null ? _a19 : refs.allowedAdditionalProperties
4238
4238
  };
4239
4239
  if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
4240
4240
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
@@ -4285,11 +4285,11 @@ function parseMapDef(def, refs) {
4285
4285
  };
4286
4286
  }
4287
4287
  function parseNativeEnumDef(def) {
4288
- const object4 = def.values;
4288
+ const object3 = def.values;
4289
4289
  const actualKeys = Object.keys(def.values).filter((key) => {
4290
- return typeof object4[object4[key]] !== "number";
4290
+ return typeof object3[object3[key]] !== "number";
4291
4291
  });
4292
- const actualValues = actualKeys.map((key) => object4[key]);
4292
+ const actualValues = actualKeys.map((key) => object3[key]);
4293
4293
  const parsedTypes = Array.from(
4294
4294
  new Set(actualValues.map((values) => typeof values))
4295
4295
  );
@@ -4493,8 +4493,8 @@ function safeIsOptional(schema) {
4493
4493
  }
4494
4494
  }
4495
4495
  var parseOptionalDef = (def, refs) => {
4496
- var _a20;
4497
- if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
4496
+ var _a19;
4497
+ if (refs.currentPath.toString() === ((_a19 = refs.propertyPath) == null ? void 0 : _a19.toString())) {
4498
4498
  return parseDef(def.innerType._def, refs);
4499
4499
  }
4500
4500
  const innerSchema = parseDef(def.innerType._def, {
@@ -4664,10 +4664,10 @@ var selectParser = (def, typeName, refs) => {
4664
4664
  }
4665
4665
  };
4666
4666
  function parseDef(def, refs, forceResolution = false) {
4667
- var _a20;
4667
+ var _a19;
4668
4668
  const seenItem = refs.seen.get(def);
4669
4669
  if (refs.override) {
4670
- const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
4670
+ const overrideResult = (_a19 = refs.override) == null ? void 0 : _a19.call(
4671
4671
  refs,
4672
4672
  def,
4673
4673
  refs,
@@ -4733,11 +4733,11 @@ var getRefs = (options) => {
4733
4733
  currentPath,
4734
4734
  propertyPath: void 0,
4735
4735
  seen: new Map(
4736
- Object.entries(_options.definitions).map(([name20, def]) => [
4736
+ Object.entries(_options.definitions).map(([name19, def]) => [
4737
4737
  def._def,
4738
4738
  {
4739
4739
  def: def._def,
4740
- path: [..._options.basePath, _options.definitionPath, name20],
4740
+ path: [..._options.basePath, _options.definitionPath, name19],
4741
4741
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
4742
4742
  jsonSchema: void 0
4743
4743
  }
@@ -4746,50 +4746,50 @@ var getRefs = (options) => {
4746
4746
  };
4747
4747
  };
4748
4748
  var zodToJsonSchema2 = (schema, options) => {
4749
- var _a20;
4749
+ var _a19;
4750
4750
  const refs = getRefs(options);
4751
4751
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
4752
- (acc, [name25, schema2]) => {
4753
- var _a25;
4752
+ (acc, [name24, schema2]) => {
4753
+ var _a24;
4754
4754
  return {
4755
4755
  ...acc,
4756
- [name25]: (_a25 = parseDef(
4756
+ [name24]: (_a24 = parseDef(
4757
4757
  schema2._def,
4758
4758
  {
4759
4759
  ...refs,
4760
- currentPath: [...refs.basePath, refs.definitionPath, name25]
4760
+ currentPath: [...refs.basePath, refs.definitionPath, name24]
4761
4761
  },
4762
4762
  true
4763
- )) != null ? _a25 : parseAnyDef()
4763
+ )) != null ? _a24 : parseAnyDef()
4764
4764
  };
4765
4765
  },
4766
4766
  {}
4767
4767
  ) : void 0;
4768
- const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
4769
- const main = (_a20 = parseDef(
4768
+ const name19 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
4769
+ const main = (_a19 = parseDef(
4770
4770
  schema._def,
4771
- name20 === void 0 ? refs : {
4771
+ name19 === void 0 ? refs : {
4772
4772
  ...refs,
4773
- currentPath: [...refs.basePath, refs.definitionPath, name20]
4773
+ currentPath: [...refs.basePath, refs.definitionPath, name19]
4774
4774
  },
4775
4775
  false
4776
- )) != null ? _a20 : parseAnyDef();
4776
+ )) != null ? _a19 : parseAnyDef();
4777
4777
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
4778
4778
  if (title !== void 0) {
4779
4779
  main.title = title;
4780
4780
  }
4781
- const combined = name20 === void 0 ? definitions ? {
4781
+ const combined = name19 === void 0 ? definitions ? {
4782
4782
  ...main,
4783
4783
  [refs.definitionPath]: definitions
4784
4784
  } : main : {
4785
4785
  $ref: [
4786
4786
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
4787
4787
  refs.definitionPath,
4788
- name20
4788
+ name19
4789
4789
  ].join("/"),
4790
4790
  [refs.definitionPath]: {
4791
4791
  ...definitions,
4792
- [name20]: main
4792
+ [name19]: main
4793
4793
  }
4794
4794
  };
4795
4795
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -4797,8 +4797,8 @@ var zodToJsonSchema2 = (schema, options) => {
4797
4797
  };
4798
4798
  var zod_to_json_schema_default = zodToJsonSchema2;
4799
4799
  function zod3Schema(zodSchema22, options) {
4800
- var _a20;
4801
- const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
4800
+ var _a19;
4801
+ const useReferences = (_a19 = void 0 ) != null ? _a19 : false;
4802
4802
  return jsonSchema2(
4803
4803
  zod_to_json_schema_default(zodSchema22, {
4804
4804
  $refStrategy: useReferences ? "root" : "none"
@@ -4812,8 +4812,8 @@ function zod3Schema(zodSchema22, options) {
4812
4812
  );
4813
4813
  }
4814
4814
  function zod4Schema(zodSchema22, options) {
4815
- var _a20;
4816
- const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
4815
+ var _a19;
4816
+ const useReferences = (_a19 = void 0 ) != null ? _a19 : false;
4817
4817
  const z4JSONSchema = z42.toJSONSchema(zodSchema22, {
4818
4818
  target: "draft-7",
4819
4819
  io: "output",
@@ -5123,14 +5123,14 @@ var gatewayErrorResponseSchema = z$1.object({
5123
5123
  })
5124
5124
  });
5125
5125
  function asGatewayError(error, authMethod) {
5126
- var _a84;
5126
+ var _a83;
5127
5127
  if (GatewayError.isInstance(error)) {
5128
5128
  return error;
5129
5129
  }
5130
5130
  if (APICallError.isInstance(error)) {
5131
5131
  return createGatewayErrorFromResponse({
5132
5132
  response: extractApiCallResponse(error),
5133
- statusCode: (_a84 = error.statusCode) != null ? _a84 : 500,
5133
+ statusCode: (_a83 = error.statusCode) != null ? _a83 : 500,
5134
5134
  defaultMessage: "Gateway request failed",
5135
5135
  cause: error,
5136
5136
  authMethod
@@ -5381,7 +5381,7 @@ var GatewayEmbeddingModel = class {
5381
5381
  abortSignal,
5382
5382
  providerOptions
5383
5383
  }) {
5384
- var _a84;
5384
+ var _a83;
5385
5385
  const resolvedHeaders = await resolve(this.config.headers());
5386
5386
  try {
5387
5387
  const {
@@ -5412,7 +5412,7 @@ var GatewayEmbeddingModel = class {
5412
5412
  });
5413
5413
  return {
5414
5414
  embeddings: responseBody.embeddings,
5415
- usage: (_a84 = responseBody.usage) != null ? _a84 : void 0,
5415
+ usage: (_a83 = responseBody.usage) != null ? _a83 : void 0,
5416
5416
  providerMetadata: responseBody.providerMetadata,
5417
5417
  response: { headers: responseHeaders, body: rawValue }
5418
5418
  };
@@ -5436,8 +5436,8 @@ var gatewayEmbeddingResponseSchema = z$1.object({
5436
5436
  providerMetadata: z$1.record(z$1.string(), z$1.record(z$1.string(), z$1.unknown())).optional()
5437
5437
  });
5438
5438
  async function getVercelOidcToken() {
5439
- var _a84, _b8;
5440
- const token = (_b8 = (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
5439
+ var _a83, _b8;
5440
+ const token = (_b8 = (_a83 = getContext().headers) == null ? void 0 : _a83["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
5441
5441
  if (!token) {
5442
5442
  throw new GatewayAuthenticationError({
5443
5443
  message: "OIDC token not available",
@@ -5447,21 +5447,21 @@ async function getVercelOidcToken() {
5447
5447
  return token;
5448
5448
  }
5449
5449
  async function getVercelRequestId() {
5450
- var _a84;
5451
- return (_a84 = getContext().headers) == null ? void 0 : _a84["x-vercel-id"];
5450
+ var _a83;
5451
+ return (_a83 = getContext().headers) == null ? void 0 : _a83["x-vercel-id"];
5452
5452
  }
5453
5453
  var SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
5454
5454
  function getContext() {
5455
- var _a84, _b8, _c;
5455
+ var _a83, _b8, _c;
5456
5456
  const fromSymbol = globalThis;
5457
- return (_c = (_b8 = (_a84 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a84.get) == null ? void 0 : _b8.call(_a84)) != null ? _c : {};
5457
+ return (_c = (_b8 = (_a83 = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a83.get) == null ? void 0 : _b8.call(_a83)) != null ? _c : {};
5458
5458
  }
5459
5459
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
5460
5460
  function createGatewayProvider(options = {}) {
5461
- var _a84, _b8;
5461
+ var _a83, _b8;
5462
5462
  let pendingMetadata = null;
5463
5463
  let metadataCache = null;
5464
- const cacheRefreshMillis = (_a84 = options.metadataCacheRefreshMillis) != null ? _a84 : 1e3 * 60 * 5;
5464
+ const cacheRefreshMillis = (_a83 = options.metadataCacheRefreshMillis) != null ? _a83 : 1e3 * 60 * 5;
5465
5465
  let lastFetchTime = 0;
5466
5466
  const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
5467
5467
  const getHeaders = async () => {
@@ -5513,8 +5513,8 @@ function createGatewayProvider(options = {}) {
5513
5513
  });
5514
5514
  };
5515
5515
  const getAvailableModels = async () => {
5516
- var _a94, _b9, _c;
5517
- const now = (_c = (_b9 = (_a94 = options._internal) == null ? void 0 : _a94.currentDate) == null ? void 0 : _b9.call(_a94).getTime()) != null ? _c : Date.now();
5516
+ var _a93, _b9, _c;
5517
+ const now = (_c = (_b9 = (_a93 = options._internal) == null ? void 0 : _a93.currentDate) == null ? void 0 : _b9.call(_a93).getTime()) != null ? _c : Date.now();
5518
5518
  if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
5519
5519
  lastFetchTime = now;
5520
5520
  pendingMetadata = new GatewayFetchMetadata({
@@ -6124,6 +6124,9 @@ function prepareRetries2({
6124
6124
  })
6125
6125
  };
6126
6126
  }
6127
+ function stepCountIs(stepCount) {
6128
+ return ({ steps }) => steps.length === stepCount;
6129
+ }
6127
6130
  var VERSION3 = "5.0.44" ;
6128
6131
  createIdGenerator2({
6129
6132
  prefix: "aitxt",
@@ -7841,50 +7844,50 @@ function isValidWithSchema(schema, value) {
7841
7844
  return schema.safeParse(value).success;
7842
7845
  }
7843
7846
  var NotHandler = class {
7844
- apply(zodSchema4, schema) {
7845
- if (!schema.not) return zodSchema4;
7847
+ apply(zodSchema3, schema) {
7848
+ if (!schema.not) return zodSchema3;
7846
7849
  const notSchema = convertJsonSchemaToZod(schema.not);
7847
- return zodSchema4.refine(
7850
+ return zodSchema3.refine(
7848
7851
  (value) => !isValidWithSchema(notSchema, value),
7849
7852
  { message: "Value must not match the 'not' schema" }
7850
7853
  );
7851
7854
  }
7852
7855
  };
7853
7856
  var UniqueItemsHandler = class {
7854
- apply(zodSchema4, schema) {
7857
+ apply(zodSchema3, schema) {
7855
7858
  const arraySchema = schema;
7856
- if (arraySchema.uniqueItems !== true) return zodSchema4;
7857
- return zodSchema4.refine(createUniqueItemsValidator(), {
7859
+ if (arraySchema.uniqueItems !== true) return zodSchema3;
7860
+ return zodSchema3.refine(createUniqueItemsValidator(), {
7858
7861
  message: "Array items must be unique"
7859
7862
  });
7860
7863
  }
7861
7864
  };
7862
7865
  var AllOfHandler = class {
7863
- apply(zodSchema4, schema) {
7864
- if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
7866
+ apply(zodSchema3, schema) {
7867
+ if (!schema.allOf || schema.allOf.length === 0) return zodSchema3;
7865
7868
  const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
7866
7869
  return allOfSchemas.reduce(
7867
7870
  (acc, s) => z$1.intersection(acc, s),
7868
- zodSchema4
7871
+ zodSchema3
7869
7872
  );
7870
7873
  }
7871
7874
  };
7872
7875
  var AnyOfHandler = class {
7873
- apply(zodSchema4, schema) {
7874
- if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
7876
+ apply(zodSchema3, schema) {
7877
+ if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema3;
7875
7878
  const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z$1.union([
7876
7879
  convertJsonSchemaToZod(schema.anyOf[0]),
7877
7880
  convertJsonSchemaToZod(schema.anyOf[1]),
7878
7881
  ...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
7879
7882
  ]);
7880
- return z$1.intersection(zodSchema4, anyOfSchema);
7883
+ return z$1.intersection(zodSchema3, anyOfSchema);
7881
7884
  }
7882
7885
  };
7883
7886
  var OneOfHandler = class {
7884
- apply(zodSchema4, schema) {
7885
- if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
7887
+ apply(zodSchema3, schema) {
7888
+ if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema3;
7886
7889
  const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
7887
- return zodSchema4.refine(
7890
+ return zodSchema3.refine(
7888
7891
  (value) => {
7889
7892
  let validCount = 0;
7890
7893
  for (const oneOfSchema of oneOfSchemas) {
@@ -7901,12 +7904,12 @@ var OneOfHandler = class {
7901
7904
  }
7902
7905
  };
7903
7906
  var PrefixItemsHandler = class {
7904
- apply(zodSchema4, schema) {
7907
+ apply(zodSchema3, schema) {
7905
7908
  const arraySchema = schema;
7906
7909
  if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
7907
7910
  const prefixItems = arraySchema.prefixItems;
7908
7911
  const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
7909
- return zodSchema4.refine(
7912
+ return zodSchema3.refine(
7910
7913
  (value) => {
7911
7914
  if (!Array.isArray(value)) return true;
7912
7915
  for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
@@ -7931,16 +7934,16 @@ var PrefixItemsHandler = class {
7931
7934
  { message: "Array does not match prefixItems schema" }
7932
7935
  );
7933
7936
  }
7934
- return zodSchema4;
7937
+ return zodSchema3;
7935
7938
  }
7936
7939
  };
7937
7940
  var ObjectPropertiesHandler = class {
7938
- apply(zodSchema4, schema) {
7941
+ apply(zodSchema3, schema) {
7939
7942
  const objectSchema = schema;
7940
7943
  if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
7941
- return zodSchema4;
7944
+ return zodSchema3;
7942
7945
  }
7943
- if (zodSchema4 instanceof z$1.ZodObject || zodSchema4 instanceof z$1.ZodRecord) {
7946
+ if (zodSchema3 instanceof z$1.ZodObject || zodSchema3 instanceof z$1.ZodRecord) {
7944
7947
  const shape = {};
7945
7948
  if (objectSchema.properties) {
7946
7949
  for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
@@ -7967,7 +7970,7 @@ var ObjectPropertiesHandler = class {
7967
7970
  return z$1.object(shape).passthrough();
7968
7971
  }
7969
7972
  }
7970
- return zodSchema4.refine(
7973
+ return zodSchema3.refine(
7971
7974
  (value) => {
7972
7975
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
7973
7976
  return true;
@@ -8009,13 +8012,13 @@ var ObjectPropertiesHandler = class {
8009
8012
  }
8010
8013
  };
8011
8014
  var EnumComplexHandler = class {
8012
- apply(zodSchema4, schema) {
8013
- if (!schema.enum || schema.enum.length === 0) return zodSchema4;
8015
+ apply(zodSchema3, schema) {
8016
+ if (!schema.enum || schema.enum.length === 0) return zodSchema3;
8014
8017
  const complexValues = schema.enum.filter(
8015
8018
  (v) => Array.isArray(v) || typeof v === "object" && v !== null
8016
8019
  );
8017
- if (complexValues.length === 0) return zodSchema4;
8018
- return zodSchema4.refine(
8020
+ if (complexValues.length === 0) return zodSchema3;
8021
+ return zodSchema3.refine(
8019
8022
  (value) => {
8020
8023
  if (typeof value !== "object" || value === null) return true;
8021
8024
  return complexValues.some(
@@ -8027,32 +8030,32 @@ var EnumComplexHandler = class {
8027
8030
  }
8028
8031
  };
8029
8032
  var ConstComplexHandler = class {
8030
- apply(zodSchema4, schema) {
8031
- if (schema.const === void 0) return zodSchema4;
8033
+ apply(zodSchema3, schema) {
8034
+ if (schema.const === void 0) return zodSchema3;
8032
8035
  const constValue = schema.const;
8033
8036
  if (typeof constValue !== "object" || constValue === null) {
8034
- return zodSchema4;
8037
+ return zodSchema3;
8035
8038
  }
8036
- return zodSchema4.refine(
8039
+ return zodSchema3.refine(
8037
8040
  (value) => deepEqual(value, constValue),
8038
8041
  { message: "Value must equal the const value" }
8039
8042
  );
8040
8043
  }
8041
8044
  };
8042
8045
  var MetadataHandler = class {
8043
- apply(zodSchema4, schema) {
8046
+ apply(zodSchema3, schema) {
8044
8047
  if (schema.description) {
8045
- zodSchema4 = zodSchema4.describe(schema.description);
8048
+ zodSchema3 = zodSchema3.describe(schema.description);
8046
8049
  }
8047
- return zodSchema4;
8050
+ return zodSchema3;
8048
8051
  }
8049
8052
  };
8050
8053
  var ProtoRequiredHandler = class {
8051
- apply(zodSchema4, schema) {
8052
- var _a20;
8054
+ apply(zodSchema3, schema) {
8055
+ var _a19;
8053
8056
  const objectSchema = schema;
8054
- if (!((_a20 = objectSchema.required) == null ? void 0 : _a20.includes("__proto__")) || schema.type !== void 0) {
8055
- return zodSchema4;
8057
+ if (!((_a19 = objectSchema.required) == null ? void 0 : _a19.includes("__proto__")) || schema.type !== void 0) {
8058
+ return zodSchema3;
8056
8059
  }
8057
8060
  return z$1.any().refine(
8058
8061
  (value) => this.validateRequired(value, objectSchema.required),
@@ -8069,14 +8072,14 @@ var ProtoRequiredHandler = class {
8069
8072
  }
8070
8073
  };
8071
8074
  var ContainsHandler = class {
8072
- apply(zodSchema4, schema) {
8073
- var _a20;
8075
+ apply(zodSchema3, schema) {
8076
+ var _a19;
8074
8077
  const arraySchema = schema;
8075
- if (arraySchema.contains === void 0) return zodSchema4;
8078
+ if (arraySchema.contains === void 0) return zodSchema3;
8076
8079
  const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
8077
- const minContains = (_a20 = arraySchema.minContains) != null ? _a20 : 1;
8080
+ const minContains = (_a19 = arraySchema.minContains) != null ? _a19 : 1;
8078
8081
  const maxContains = arraySchema.maxContains;
8079
- return zodSchema4.refine(
8082
+ return zodSchema3.refine(
8080
8083
  (value) => {
8081
8084
  if (!Array.isArray(value)) {
8082
8085
  return true;
@@ -8185,32 +8188,32 @@ function convertJsonSchemaToZod(schema) {
8185
8188
  allowedSchemas.push(objectSchema);
8186
8189
  }
8187
8190
  }
8188
- let zodSchema4;
8191
+ let zodSchema3;
8189
8192
  if (allowedSchemas.length === 0) {
8190
- zodSchema4 = z$1.never();
8193
+ zodSchema3 = z$1.never();
8191
8194
  } else if (allowedSchemas.length === 1) {
8192
- zodSchema4 = allowedSchemas[0];
8195
+ zodSchema3 = allowedSchemas[0];
8193
8196
  } else {
8194
8197
  const hasConstraints = Object.keys(schema).some(
8195
8198
  (key) => key !== "$schema" && key !== "title" && key !== "description"
8196
8199
  );
8197
8200
  if (!hasConstraints) {
8198
- zodSchema4 = z$1.any();
8201
+ zodSchema3 = z$1.any();
8199
8202
  } else {
8200
- zodSchema4 = z$1.union(allowedSchemas);
8203
+ zodSchema3 = z$1.union(allowedSchemas);
8201
8204
  }
8202
8205
  }
8203
8206
  for (const handler of refinementHandlers) {
8204
- zodSchema4 = handler.apply(zodSchema4, schema);
8207
+ zodSchema3 = handler.apply(zodSchema3, schema);
8205
8208
  }
8206
- return zodSchema4;
8209
+ return zodSchema3;
8207
8210
  }
8208
8211
  function convertJsonSchemaToZod2(schema) {
8209
- function addMetadata(zodSchema4, jsonSchema4) {
8210
- if (jsonSchema4.description) {
8211
- zodSchema4 = zodSchema4.describe(jsonSchema4.description);
8212
+ function addMetadata(zodSchema3, jsonSchema3) {
8213
+ if (jsonSchema3.description) {
8214
+ zodSchema3 = zodSchema3.describe(jsonSchema3.description);
8212
8215
  }
8213
- return zodSchema4;
8216
+ return zodSchema3;
8214
8217
  }
8215
8218
  if (schema.const !== void 0) {
8216
8219
  if (typeof schema.const === "string") {
@@ -8316,13 +8319,13 @@ function convertJsonSchemaToZod2(schema) {
8316
8319
  shape[key] = shape[key].optional();
8317
8320
  }
8318
8321
  }
8319
- let zodSchema4;
8322
+ let zodSchema3;
8320
8323
  if (schema.additionalProperties !== false) {
8321
- zodSchema4 = z.object(shape).passthrough();
8324
+ zodSchema3 = z.object(shape).passthrough();
8322
8325
  } else {
8323
- zodSchema4 = z.object(shape);
8326
+ zodSchema3 = z.object(shape);
8324
8327
  }
8325
- return addMetadata(zodSchema4, schema);
8328
+ return addMetadata(zodSchema3, schema);
8326
8329
  }
8327
8330
  return addMetadata(z.object({}), schema);
8328
8331
  case "array": {
@@ -8862,11 +8865,11 @@ ${workingMemory}`;
8862
8865
  release();
8863
8866
  }
8864
8867
  }
8865
- chunkText(text4, tokenSize = 4096) {
8868
+ chunkText(text3, tokenSize = 4096) {
8866
8869
  const charSize = tokenSize * CHARS_PER_TOKEN;
8867
8870
  const chunks = [];
8868
8871
  let currentChunk = "";
8869
- const words = text4.split(/\s+/);
8872
+ const words = text3.split(/\s+/);
8870
8873
  for (const word of words) {
8871
8874
  const wordWithSpace = currentChunk ? " " + word : word;
8872
8875
  if (currentChunk.length + wordWithSpace.length > charSize) {
@@ -9028,10 +9031,10 @@ ${workingMemory}`;
9028
9031
  }
9029
9032
  return newMessage;
9030
9033
  }
9031
- parseWorkingMemory(text4) {
9034
+ parseWorkingMemory(text3) {
9032
9035
  if (!this.threadConfig.workingMemory?.enabled) return null;
9033
9036
  const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
9034
- const matches = text4.match(workingMemoryRegex);
9037
+ const matches = text3.match(workingMemoryRegex);
9035
9038
  const match = matches?.[0];
9036
9039
  if (match) {
9037
9040
  return match.replace(/<\/?working_memory>/g, "").trim();
@@ -9331,12 +9334,12 @@ var _Tiktoken = class {
9331
9334
  this.textMap.set(rank, bytes);
9332
9335
  }
9333
9336
  this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
9334
- this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
9335
- memo[rank] = this.textEncoder.encode(text4);
9337
+ this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text3, rank]) => {
9338
+ memo[rank] = this.textEncoder.encode(text3);
9336
9339
  return memo;
9337
9340
  }, {});
9338
9341
  }
9339
- encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
9342
+ encode(text3, allowedSpecial = [], disallowedSpecial = "all") {
9340
9343
  const regexes = new RegExp(this.patStr, "ug");
9341
9344
  const specialRegex = _Tiktoken.specialTokenRegex(
9342
9345
  Object.keys(this.specialTokens)
@@ -9354,7 +9357,7 @@ var _Tiktoken = class {
9354
9357
  const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
9355
9358
  ...disallowedSpecialSet
9356
9359
  ]);
9357
- const specialMatch = text4.match(disallowedSpecialRegex);
9360
+ const specialMatch = text3.match(disallowedSpecialRegex);
9358
9361
  if (specialMatch != null) {
9359
9362
  throw new Error(
9360
9363
  `The text contains a special token that is not allowed: ${specialMatch[0]}`
@@ -9367,13 +9370,13 @@ var _Tiktoken = class {
9367
9370
  let startFind = start;
9368
9371
  while (true) {
9369
9372
  specialRegex.lastIndex = startFind;
9370
- nextSpecial = specialRegex.exec(text4);
9373
+ nextSpecial = specialRegex.exec(text3);
9371
9374
  if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
9372
9375
  break;
9373
9376
  startFind = nextSpecial.index + 1;
9374
9377
  }
9375
- const end = nextSpecial?.index ?? text4.length;
9376
- for (const match of text4.substring(start, end).matchAll(regexes)) {
9378
+ const end = nextSpecial?.index ?? text3.length;
9379
+ for (const match of text3.substring(start, end).matchAll(regexes)) {
9377
9380
  const piece = this.textEncoder.encode(match[0]);
9378
9381
  const token2 = this.rankMap.get(piece.join(","));
9379
9382
  if (token2 != null) {
@@ -9469,2337 +9472,58 @@ var TokenLimiter = class extends MemoryProcessor {
9469
9472
  totalTokens += messageTokens;
9470
9473
  } else {
9471
9474
  this.logger.info(
9472
- `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`
9473
- );
9474
- break;
9475
- }
9476
- }
9477
- return result;
9478
- }
9479
- countTokens(message) {
9480
- if (typeof message === `string`) {
9481
- return this.encoder.encode(message).length;
9482
- }
9483
- let tokenString = message.role;
9484
- let overhead = 0;
9485
- if (typeof message.content === "string" && message.content) {
9486
- tokenString += message.content;
9487
- } else if (Array.isArray(message.content)) {
9488
- for (const part of message.content) {
9489
- if (part.type === "text") {
9490
- tokenString += part.text;
9491
- } else if (part.type === "tool-call" || part.type === `tool-result`) {
9492
- if (`args` in part && part.args && part.type === `tool-call`) {
9493
- tokenString += part.toolName;
9494
- if (typeof part.args === "string") {
9495
- tokenString += part.args;
9496
- } else {
9497
- tokenString += JSON.stringify(part.args);
9498
- overhead -= 12;
9499
- }
9500
- }
9501
- if (`result` in part && part.result !== void 0 && part.type === `tool-result`) {
9502
- if (typeof part.result === "string") {
9503
- tokenString += part.result;
9504
- } else {
9505
- tokenString += JSON.stringify(part.result);
9506
- overhead -= 12;
9507
- }
9508
- }
9509
- } else {
9510
- tokenString += JSON.stringify(part);
9511
- }
9512
- }
9513
- }
9514
- if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
9515
- message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
9516
- overhead += this.TOKENS_PER_MESSAGE;
9517
- }
9518
- return this.encoder.encode(tokenString).length + overhead;
9519
- }
9520
- };
9521
-
9522
- // ../agent-builder/dist/index.js
9523
- var import_ignore = __toESM(require_ignore(), 1);
9524
- var createIdGenerator3 = ({
9525
- prefix,
9526
- size = 16,
9527
- alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
9528
- separator = "-"
9529
- } = {}) => {
9530
- const generator = () => {
9531
- const alphabetLength = alphabet.length;
9532
- const chars = new Array(size);
9533
- for (let i = 0; i < size; i++) {
9534
- chars[i] = alphabet[Math.random() * alphabetLength | 0];
9535
- }
9536
- return chars.join("");
9537
- };
9538
- if (prefix == null) {
9539
- return generator;
9540
- }
9541
- if (alphabet.includes(separator)) {
9542
- throw new InvalidArgumentError({
9543
- argument: "separator",
9544
- message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
9545
- });
9546
- }
9547
- return () => `${prefix}${separator}${generator()}`;
9548
- };
9549
- createIdGenerator3();
9550
- var suspectProtoRx2 = /"__proto__"\s*:/;
9551
- var suspectConstructorRx2 = /"constructor"\s*:/;
9552
- function _parse2(text4) {
9553
- const obj = JSON.parse(text4);
9554
- if (obj === null || typeof obj !== "object") {
9555
- return obj;
9556
- }
9557
- if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
9558
- return obj;
9559
- }
9560
- return filter2(obj);
9561
- }
9562
- function filter2(obj) {
9563
- let next = [obj];
9564
- while (next.length) {
9565
- const nodes = next;
9566
- next = [];
9567
- for (const node of nodes) {
9568
- if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
9569
- throw new SyntaxError("Object contains forbidden prototype property");
9570
- }
9571
- if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
9572
- throw new SyntaxError("Object contains forbidden prototype property");
9573
- }
9574
- for (const key in node) {
9575
- const value = node[key];
9576
- if (value && typeof value === "object") {
9577
- next.push(value);
9578
- }
9579
- }
9580
- }
9581
- }
9582
- return obj;
9583
- }
9584
- function secureJsonParse2(text4) {
9585
- const { stackTraceLimit } = Error;
9586
- Error.stackTraceLimit = 0;
9587
- try {
9588
- return _parse2(text4);
9589
- } finally {
9590
- Error.stackTraceLimit = stackTraceLimit;
9591
- }
9592
- }
9593
- var validatorSymbol3 = Symbol.for("vercel.ai.validator");
9594
- function validator2(validate) {
9595
- return { [validatorSymbol3]: true, validate };
9596
- }
9597
- function isValidator2(value) {
9598
- return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
9599
- }
9600
- function asValidator2(value) {
9601
- return isValidator2(value) ? value : standardSchemaValidator2(value);
9602
- }
9603
- function standardSchemaValidator2(standardSchema) {
9604
- return validator2(async (value) => {
9605
- const result = await standardSchema["~standard"].validate(value);
9606
- return result.issues == null ? { success: true, value: result.value } : {
9607
- success: false,
9608
- error: new TypeValidationError({
9609
- value,
9610
- cause: result.issues
9611
- })
9612
- };
9613
- });
9614
- }
9615
- async function safeValidateTypes3({
9616
- value,
9617
- schema
9618
- }) {
9619
- const validator22 = asValidator2(schema);
9620
- try {
9621
- if (validator22.validate == null) {
9622
- return { success: true, value, rawValue: value };
9623
- }
9624
- const result = await validator22.validate(value);
9625
- if (result.success) {
9626
- return { success: true, value: result.value, rawValue: value };
9627
- }
9628
- return {
9629
- success: false,
9630
- error: TypeValidationError.wrap({ value, cause: result.error }),
9631
- rawValue: value
9632
- };
9633
- } catch (error) {
9634
- return {
9635
- success: false,
9636
- error: TypeValidationError.wrap({ value, cause: error }),
9637
- rawValue: value
9638
- };
9639
- }
9640
- }
9641
- async function safeParseJSON3({
9642
- text: text4,
9643
- schema
9644
- }) {
9645
- try {
9646
- const value = secureJsonParse2(text4);
9647
- if (schema == null) {
9648
- return { success: true, value, rawValue: value };
9649
- }
9650
- return await safeValidateTypes3({ value, schema });
9651
- } catch (error) {
9652
- return {
9653
- success: false,
9654
- error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
9655
- rawValue: void 0
9656
- };
9657
- }
9658
- }
9659
- var getRelativePath2 = (pathA, pathB) => {
9660
- let i = 0;
9661
- for (; i < pathA.length && i < pathB.length; i++) {
9662
- if (pathA[i] !== pathB[i])
9663
- break;
9664
- }
9665
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
9666
- };
9667
- var ignoreOverride2 = Symbol(
9668
- "Let zodToJsonSchema decide on which parser to use"
9669
- );
9670
- var defaultOptions2 = {
9671
- name: void 0,
9672
- $refStrategy: "root",
9673
- basePath: ["#"],
9674
- effectStrategy: "input",
9675
- pipeStrategy: "all",
9676
- dateStrategy: "format:date-time",
9677
- mapStrategy: "entries",
9678
- removeAdditionalStrategy: "passthrough",
9679
- allowedAdditionalProperties: true,
9680
- rejectedAdditionalProperties: false,
9681
- definitionPath: "definitions",
9682
- strictUnions: false,
9683
- definitions: {},
9684
- errorMessages: false,
9685
- patternStrategy: "escape",
9686
- applyRegexFlags: false,
9687
- emailStrategy: "format:email",
9688
- base64Strategy: "contentEncoding:base64",
9689
- nameStrategy: "ref"
9690
- };
9691
- var getDefaultOptions2 = (options) => typeof options === "string" ? {
9692
- ...defaultOptions2,
9693
- name: options
9694
- } : {
9695
- ...defaultOptions2,
9696
- ...options
9697
- };
9698
- function parseAnyDef2() {
9699
- return {};
9700
- }
9701
- function parseArrayDef2(def, refs) {
9702
- var _a20, _b8, _c;
9703
- const res = {
9704
- type: "array"
9705
- };
9706
- if (((_a20 = def.type) == null ? void 0 : _a20._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
9707
- res.items = parseDef2(def.type._def, {
9708
- ...refs,
9709
- currentPath: [...refs.currentPath, "items"]
9710
- });
9711
- }
9712
- if (def.minLength) {
9713
- res.minItems = def.minLength.value;
9714
- }
9715
- if (def.maxLength) {
9716
- res.maxItems = def.maxLength.value;
9717
- }
9718
- if (def.exactLength) {
9719
- res.minItems = def.exactLength.value;
9720
- res.maxItems = def.exactLength.value;
9721
- }
9722
- return res;
9723
- }
9724
- function parseBigintDef2(def) {
9725
- const res = {
9726
- type: "integer",
9727
- format: "int64"
9728
- };
9729
- if (!def.checks)
9730
- return res;
9731
- for (const check of def.checks) {
9732
- switch (check.kind) {
9733
- case "min":
9734
- if (check.inclusive) {
9735
- res.minimum = check.value;
9736
- } else {
9737
- res.exclusiveMinimum = check.value;
9738
- }
9739
- break;
9740
- case "max":
9741
- if (check.inclusive) {
9742
- res.maximum = check.value;
9743
- } else {
9744
- res.exclusiveMaximum = check.value;
9745
- }
9746
- break;
9747
- case "multipleOf":
9748
- res.multipleOf = check.value;
9749
- break;
9750
- }
9751
- }
9752
- return res;
9753
- }
9754
- function parseBooleanDef2() {
9755
- return { type: "boolean" };
9756
- }
9757
- function parseBrandedDef2(_def, refs) {
9758
- return parseDef2(_def.type._def, refs);
9759
- }
9760
- var parseCatchDef2 = (def, refs) => {
9761
- return parseDef2(def.innerType._def, refs);
9762
- };
9763
- function parseDateDef2(def, refs, overrideDateStrategy) {
9764
- const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
9765
- if (Array.isArray(strategy)) {
9766
- return {
9767
- anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
9768
- };
9769
- }
9770
- switch (strategy) {
9771
- case "string":
9772
- case "format:date-time":
9773
- return {
9774
- type: "string",
9775
- format: "date-time"
9776
- };
9777
- case "format:date":
9778
- return {
9779
- type: "string",
9780
- format: "date"
9781
- };
9782
- case "integer":
9783
- return integerDateParser2(def);
9784
- }
9785
- }
9786
- var integerDateParser2 = (def) => {
9787
- const res = {
9788
- type: "integer",
9789
- format: "unix-time"
9790
- };
9791
- for (const check of def.checks) {
9792
- switch (check.kind) {
9793
- case "min":
9794
- res.minimum = check.value;
9795
- break;
9796
- case "max":
9797
- res.maximum = check.value;
9798
- break;
9799
- }
9800
- }
9801
- return res;
9802
- };
9803
- function parseDefaultDef2(_def, refs) {
9804
- return {
9805
- ...parseDef2(_def.innerType._def, refs),
9806
- default: _def.defaultValue()
9807
- };
9808
- }
9809
- function parseEffectsDef2(_def, refs) {
9810
- return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
9811
- }
9812
- function parseEnumDef2(def) {
9813
- return {
9814
- type: "string",
9815
- enum: Array.from(def.values)
9816
- };
9817
- }
9818
- var isJsonSchema7AllOfType2 = (type) => {
9819
- if ("type" in type && type.type === "string")
9820
- return false;
9821
- return "allOf" in type;
9822
- };
9823
- function parseIntersectionDef2(def, refs) {
9824
- const allOf = [
9825
- parseDef2(def.left._def, {
9826
- ...refs,
9827
- currentPath: [...refs.currentPath, "allOf", "0"]
9828
- }),
9829
- parseDef2(def.right._def, {
9830
- ...refs,
9831
- currentPath: [...refs.currentPath, "allOf", "1"]
9832
- })
9833
- ].filter((x) => !!x);
9834
- const mergedAllOf = [];
9835
- allOf.forEach((schema) => {
9836
- if (isJsonSchema7AllOfType2(schema)) {
9837
- mergedAllOf.push(...schema.allOf);
9838
- } else {
9839
- let nestedSchema = schema;
9840
- if ("additionalProperties" in schema && schema.additionalProperties === false) {
9841
- const { additionalProperties, ...rest } = schema;
9842
- nestedSchema = rest;
9843
- }
9844
- mergedAllOf.push(nestedSchema);
9845
- }
9846
- });
9847
- return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
9848
- }
9849
- function parseLiteralDef2(def) {
9850
- const parsedType = typeof def.value;
9851
- if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
9852
- return {
9853
- type: Array.isArray(def.value) ? "array" : "object"
9854
- };
9855
- }
9856
- return {
9857
- type: parsedType === "bigint" ? "integer" : parsedType,
9858
- const: def.value
9859
- };
9860
- }
9861
- var emojiRegex2 = void 0;
9862
- var zodPatterns2 = {
9863
- /**
9864
- * `c` was changed to `[cC]` to replicate /i flag
9865
- */
9866
- cuid: /^[cC][^\s-]{8,}$/,
9867
- cuid2: /^[0-9a-z]+$/,
9868
- ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
9869
- /**
9870
- * `a-z` was added to replicate /i flag
9871
- */
9872
- email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
9873
- /**
9874
- * Constructed a valid Unicode RegExp
9875
- *
9876
- * Lazily instantiate since this type of regex isn't supported
9877
- * in all envs (e.g. React Native).
9878
- *
9879
- * See:
9880
- * https://github.com/colinhacks/zod/issues/2433
9881
- * Fix in Zod:
9882
- * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
9883
- */
9884
- emoji: () => {
9885
- if (emojiRegex2 === void 0) {
9886
- emojiRegex2 = RegExp(
9887
- "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
9888
- "u"
9889
- );
9890
- }
9891
- return emojiRegex2;
9892
- },
9893
- /**
9894
- * Unused
9895
- */
9896
- 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}$/,
9897
- /**
9898
- * Unused
9899
- */
9900
- 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])$/,
9901
- 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])$/,
9902
- /**
9903
- * Unused
9904
- */
9905
- 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})))$/,
9906
- 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])$/,
9907
- base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
9908
- base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
9909
- nanoid: /^[a-zA-Z0-9_-]{21}$/,
9910
- jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
9911
- };
9912
- function parseStringDef2(def, refs) {
9913
- const res = {
9914
- type: "string"
9915
- };
9916
- if (def.checks) {
9917
- for (const check of def.checks) {
9918
- switch (check.kind) {
9919
- case "min":
9920
- res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
9921
- break;
9922
- case "max":
9923
- res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
9924
- break;
9925
- case "email":
9926
- switch (refs.emailStrategy) {
9927
- case "format:email":
9928
- addFormat2(res, "email", check.message, refs);
9929
- break;
9930
- case "format:idn-email":
9931
- addFormat2(res, "idn-email", check.message, refs);
9932
- break;
9933
- case "pattern:zod":
9934
- addPattern2(res, zodPatterns2.email, check.message, refs);
9935
- break;
9936
- }
9937
- break;
9938
- case "url":
9939
- addFormat2(res, "uri", check.message, refs);
9940
- break;
9941
- case "uuid":
9942
- addFormat2(res, "uuid", check.message, refs);
9943
- break;
9944
- case "regex":
9945
- addPattern2(res, check.regex, check.message, refs);
9946
- break;
9947
- case "cuid":
9948
- addPattern2(res, zodPatterns2.cuid, check.message, refs);
9949
- break;
9950
- case "cuid2":
9951
- addPattern2(res, zodPatterns2.cuid2, check.message, refs);
9952
- break;
9953
- case "startsWith":
9954
- addPattern2(
9955
- res,
9956
- RegExp(`^${escapeLiteralCheckValue2(check.value, refs)}`),
9957
- check.message,
9958
- refs
9959
- );
9960
- break;
9961
- case "endsWith":
9962
- addPattern2(
9963
- res,
9964
- RegExp(`${escapeLiteralCheckValue2(check.value, refs)}$`),
9965
- check.message,
9966
- refs
9967
- );
9968
- break;
9969
- case "datetime":
9970
- addFormat2(res, "date-time", check.message, refs);
9971
- break;
9972
- case "date":
9973
- addFormat2(res, "date", check.message, refs);
9974
- break;
9975
- case "time":
9976
- addFormat2(res, "time", check.message, refs);
9977
- break;
9978
- case "duration":
9979
- addFormat2(res, "duration", check.message, refs);
9980
- break;
9981
- case "length":
9982
- res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
9983
- res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
9984
- break;
9985
- case "includes": {
9986
- addPattern2(
9987
- res,
9988
- RegExp(escapeLiteralCheckValue2(check.value, refs)),
9989
- check.message,
9990
- refs
9991
- );
9992
- break;
9993
- }
9994
- case "ip": {
9995
- if (check.version !== "v6") {
9996
- addFormat2(res, "ipv4", check.message, refs);
9997
- }
9998
- if (check.version !== "v4") {
9999
- addFormat2(res, "ipv6", check.message, refs);
10000
- }
10001
- break;
10002
- }
10003
- case "base64url":
10004
- addPattern2(res, zodPatterns2.base64url, check.message, refs);
10005
- break;
10006
- case "jwt":
10007
- addPattern2(res, zodPatterns2.jwt, check.message, refs);
10008
- break;
10009
- case "cidr": {
10010
- if (check.version !== "v6") {
10011
- addPattern2(res, zodPatterns2.ipv4Cidr, check.message, refs);
10012
- }
10013
- if (check.version !== "v4") {
10014
- addPattern2(res, zodPatterns2.ipv6Cidr, check.message, refs);
10015
- }
10016
- break;
10017
- }
10018
- case "emoji":
10019
- addPattern2(res, zodPatterns2.emoji(), check.message, refs);
10020
- break;
10021
- case "ulid": {
10022
- addPattern2(res, zodPatterns2.ulid, check.message, refs);
10023
- break;
10024
- }
10025
- case "base64": {
10026
- switch (refs.base64Strategy) {
10027
- case "format:binary": {
10028
- addFormat2(res, "binary", check.message, refs);
10029
- break;
10030
- }
10031
- case "contentEncoding:base64": {
10032
- res.contentEncoding = "base64";
10033
- break;
10034
- }
10035
- case "pattern:zod": {
10036
- addPattern2(res, zodPatterns2.base64, check.message, refs);
10037
- break;
10038
- }
10039
- }
10040
- break;
10041
- }
10042
- case "nanoid": {
10043
- addPattern2(res, zodPatterns2.nanoid, check.message, refs);
10044
- }
10045
- }
10046
- }
10047
- }
10048
- return res;
10049
- }
10050
- function escapeLiteralCheckValue2(literal, refs) {
10051
- return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal) : literal;
10052
- }
10053
- var ALPHA_NUMERIC2 = new Set(
10054
- "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
10055
- );
10056
- function escapeNonAlphaNumeric2(source) {
10057
- let result = "";
10058
- for (let i = 0; i < source.length; i++) {
10059
- if (!ALPHA_NUMERIC2.has(source[i])) {
10060
- result += "\\";
10061
- }
10062
- result += source[i];
10063
- }
10064
- return result;
10065
- }
10066
- function addFormat2(schema, value, message, refs) {
10067
- var _a20;
10068
- if (schema.format || ((_a20 = schema.anyOf) == null ? void 0 : _a20.some((x) => x.format))) {
10069
- if (!schema.anyOf) {
10070
- schema.anyOf = [];
10071
- }
10072
- if (schema.format) {
10073
- schema.anyOf.push({
10074
- format: schema.format
10075
- });
10076
- delete schema.format;
10077
- }
10078
- schema.anyOf.push({
10079
- format: value,
10080
- ...message && refs.errorMessages && { errorMessage: { format: message } }
10081
- });
10082
- } else {
10083
- schema.format = value;
10084
- }
10085
- }
10086
- function addPattern2(schema, regex, message, refs) {
10087
- var _a20;
10088
- if (schema.pattern || ((_a20 = schema.allOf) == null ? void 0 : _a20.some((x) => x.pattern))) {
10089
- if (!schema.allOf) {
10090
- schema.allOf = [];
10091
- }
10092
- if (schema.pattern) {
10093
- schema.allOf.push({
10094
- pattern: schema.pattern
10095
- });
10096
- delete schema.pattern;
10097
- }
10098
- schema.allOf.push({
10099
- pattern: stringifyRegExpWithFlags2(regex, refs),
10100
- ...message && refs.errorMessages && { errorMessage: { pattern: message } }
10101
- });
10102
- } else {
10103
- schema.pattern = stringifyRegExpWithFlags2(regex, refs);
10104
- }
10105
- }
10106
- function stringifyRegExpWithFlags2(regex, refs) {
10107
- var _a20;
10108
- if (!refs.applyRegexFlags || !regex.flags) {
10109
- return regex.source;
10110
- }
10111
- const flags = {
10112
- i: regex.flags.includes("i"),
10113
- // Case-insensitive
10114
- m: regex.flags.includes("m"),
10115
- // `^` and `$` matches adjacent to newline characters
10116
- s: regex.flags.includes("s")
10117
- // `.` matches newlines
10118
- };
10119
- const source = flags.i ? regex.source.toLowerCase() : regex.source;
10120
- let pattern = "";
10121
- let isEscaped = false;
10122
- let inCharGroup = false;
10123
- let inCharRange = false;
10124
- for (let i = 0; i < source.length; i++) {
10125
- if (isEscaped) {
10126
- pattern += source[i];
10127
- isEscaped = false;
10128
- continue;
10129
- }
10130
- if (flags.i) {
10131
- if (inCharGroup) {
10132
- if (source[i].match(/[a-z]/)) {
10133
- if (inCharRange) {
10134
- pattern += source[i];
10135
- pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
10136
- inCharRange = false;
10137
- } else if (source[i + 1] === "-" && ((_a20 = source[i + 2]) == null ? void 0 : _a20.match(/[a-z]/))) {
10138
- pattern += source[i];
10139
- inCharRange = true;
10140
- } else {
10141
- pattern += `${source[i]}${source[i].toUpperCase()}`;
10142
- }
10143
- continue;
10144
- }
10145
- } else if (source[i].match(/[a-z]/)) {
10146
- pattern += `[${source[i]}${source[i].toUpperCase()}]`;
10147
- continue;
10148
- }
10149
- }
10150
- if (flags.m) {
10151
- if (source[i] === "^") {
10152
- pattern += `(^|(?<=[\r
10153
- ]))`;
10154
- continue;
10155
- } else if (source[i] === "$") {
10156
- pattern += `($|(?=[\r
10157
- ]))`;
10158
- continue;
10159
- }
10160
- }
10161
- if (flags.s && source[i] === ".") {
10162
- pattern += inCharGroup ? `${source[i]}\r
10163
- ` : `[${source[i]}\r
10164
- ]`;
10165
- continue;
10166
- }
10167
- pattern += source[i];
10168
- if (source[i] === "\\") {
10169
- isEscaped = true;
10170
- } else if (inCharGroup && source[i] === "]") {
10171
- inCharGroup = false;
10172
- } else if (!inCharGroup && source[i] === "[") {
10173
- inCharGroup = true;
10174
- }
10175
- }
10176
- return pattern;
10177
- }
10178
- function parseRecordDef2(def, refs) {
10179
- var _a20, _b8, _c, _d, _e, _f;
10180
- const schema = {
10181
- type: "object",
10182
- additionalProperties: (_a20 = parseDef2(def.valueType._def, {
10183
- ...refs,
10184
- currentPath: [...refs.currentPath, "additionalProperties"]
10185
- })) != null ? _a20 : refs.allowedAdditionalProperties
10186
- };
10187
- if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
10188
- const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
10189
- return {
10190
- ...schema,
10191
- propertyNames: keyType
10192
- };
10193
- } else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind.ZodEnum) {
10194
- return {
10195
- ...schema,
10196
- propertyNames: {
10197
- enum: def.keyType._def.values
10198
- }
10199
- };
10200
- } else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
10201
- const { type, ...keyType } = parseBrandedDef2(
10202
- def.keyType._def,
10203
- refs
10204
- );
10205
- return {
10206
- ...schema,
10207
- propertyNames: keyType
10208
- };
10209
- }
10210
- return schema;
10211
- }
10212
- function parseMapDef2(def, refs) {
10213
- if (refs.mapStrategy === "record") {
10214
- return parseRecordDef2(def, refs);
10215
- }
10216
- const keys = parseDef2(def.keyType._def, {
10217
- ...refs,
10218
- currentPath: [...refs.currentPath, "items", "items", "0"]
10219
- }) || parseAnyDef2();
10220
- const values = parseDef2(def.valueType._def, {
10221
- ...refs,
10222
- currentPath: [...refs.currentPath, "items", "items", "1"]
10223
- }) || parseAnyDef2();
10224
- return {
10225
- type: "array",
10226
- maxItems: 125,
10227
- items: {
10228
- type: "array",
10229
- items: [keys, values],
10230
- minItems: 2,
10231
- maxItems: 2
10232
- }
10233
- };
10234
- }
10235
- function parseNativeEnumDef2(def) {
10236
- const object4 = def.values;
10237
- const actualKeys = Object.keys(def.values).filter((key) => {
10238
- return typeof object4[object4[key]] !== "number";
10239
- });
10240
- const actualValues = actualKeys.map((key) => object4[key]);
10241
- const parsedTypes = Array.from(
10242
- new Set(actualValues.map((values) => typeof values))
10243
- );
10244
- return {
10245
- type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
10246
- enum: actualValues
10247
- };
10248
- }
10249
- function parseNeverDef2() {
10250
- return { not: parseAnyDef2() };
10251
- }
10252
- function parseNullDef2() {
10253
- return {
10254
- type: "null"
10255
- };
10256
- }
10257
- var primitiveMappings2 = {
10258
- ZodString: "string",
10259
- ZodNumber: "number",
10260
- ZodBigInt: "integer",
10261
- ZodBoolean: "boolean",
10262
- ZodNull: "null"
10263
- };
10264
- function parseUnionDef2(def, refs) {
10265
- const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
10266
- if (options.every(
10267
- (x) => x._def.typeName in primitiveMappings2 && (!x._def.checks || !x._def.checks.length)
10268
- )) {
10269
- const types = options.reduce((types2, x) => {
10270
- const type = primitiveMappings2[x._def.typeName];
10271
- return type && !types2.includes(type) ? [...types2, type] : types2;
10272
- }, []);
10273
- return {
10274
- type: types.length > 1 ? types : types[0]
10275
- };
10276
- } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
10277
- const types = options.reduce(
10278
- (acc, x) => {
10279
- const type = typeof x._def.value;
10280
- switch (type) {
10281
- case "string":
10282
- case "number":
10283
- case "boolean":
10284
- return [...acc, type];
10285
- case "bigint":
10286
- return [...acc, "integer"];
10287
- case "object":
10288
- if (x._def.value === null)
10289
- return [...acc, "null"];
10290
- case "symbol":
10291
- case "undefined":
10292
- case "function":
10293
- default:
10294
- return acc;
10295
- }
10296
- },
10297
- []
10298
- );
10299
- if (types.length === options.length) {
10300
- const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
10301
- return {
10302
- type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
10303
- enum: options.reduce(
10304
- (acc, x) => {
10305
- return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
10306
- },
10307
- []
10308
- )
10309
- };
10310
- }
10311
- } else if (options.every((x) => x._def.typeName === "ZodEnum")) {
10312
- return {
10313
- type: "string",
10314
- enum: options.reduce(
10315
- (acc, x) => [
10316
- ...acc,
10317
- ...x._def.values.filter((x2) => !acc.includes(x2))
10318
- ],
10319
- []
10320
- )
10321
- };
10322
- }
10323
- return asAnyOf2(def, refs);
10324
- }
10325
- var asAnyOf2 = (def, refs) => {
10326
- const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
10327
- (x, i) => parseDef2(x._def, {
10328
- ...refs,
10329
- currentPath: [...refs.currentPath, "anyOf", `${i}`]
10330
- })
10331
- ).filter(
10332
- (x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
10333
- );
10334
- return anyOf.length ? { anyOf } : void 0;
10335
- };
10336
- function parseNullableDef2(def, refs) {
10337
- if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
10338
- def.innerType._def.typeName
10339
- ) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
10340
- return {
10341
- type: [
10342
- primitiveMappings2[def.innerType._def.typeName],
10343
- "null"
10344
- ]
10345
- };
10346
- }
10347
- const base = parseDef2(def.innerType._def, {
10348
- ...refs,
10349
- currentPath: [...refs.currentPath, "anyOf", "0"]
10350
- });
10351
- return base && { anyOf: [base, { type: "null" }] };
10352
- }
10353
- function parseNumberDef2(def) {
10354
- const res = {
10355
- type: "number"
10356
- };
10357
- if (!def.checks)
10358
- return res;
10359
- for (const check of def.checks) {
10360
- switch (check.kind) {
10361
- case "int":
10362
- res.type = "integer";
10363
- break;
10364
- case "min":
10365
- if (check.inclusive) {
10366
- res.minimum = check.value;
10367
- } else {
10368
- res.exclusiveMinimum = check.value;
10369
- }
10370
- break;
10371
- case "max":
10372
- if (check.inclusive) {
10373
- res.maximum = check.value;
10374
- } else {
10375
- res.exclusiveMaximum = check.value;
10376
- }
10377
- break;
10378
- case "multipleOf":
10379
- res.multipleOf = check.value;
10380
- break;
10381
- }
10382
- }
10383
- return res;
10384
- }
10385
- function parseObjectDef2(def, refs) {
10386
- const result = {
10387
- type: "object",
10388
- properties: {}
10389
- };
10390
- const required = [];
10391
- const shape = def.shape();
10392
- for (const propName in shape) {
10393
- let propDef = shape[propName];
10394
- if (propDef === void 0 || propDef._def === void 0) {
10395
- continue;
10396
- }
10397
- const propOptional = safeIsOptional2(propDef);
10398
- const parsedDef = parseDef2(propDef._def, {
10399
- ...refs,
10400
- currentPath: [...refs.currentPath, "properties", propName],
10401
- propertyPath: [...refs.currentPath, "properties", propName]
10402
- });
10403
- if (parsedDef === void 0) {
10404
- continue;
10405
- }
10406
- result.properties[propName] = parsedDef;
10407
- if (!propOptional) {
10408
- required.push(propName);
10409
- }
10410
- }
10411
- if (required.length) {
10412
- result.required = required;
10413
- }
10414
- const additionalProperties = decideAdditionalProperties2(def, refs);
10415
- if (additionalProperties !== void 0) {
10416
- result.additionalProperties = additionalProperties;
10417
- }
10418
- return result;
10419
- }
10420
- function decideAdditionalProperties2(def, refs) {
10421
- if (def.catchall._def.typeName !== "ZodNever") {
10422
- return parseDef2(def.catchall._def, {
10423
- ...refs,
10424
- currentPath: [...refs.currentPath, "additionalProperties"]
10425
- });
10426
- }
10427
- switch (def.unknownKeys) {
10428
- case "passthrough":
10429
- return refs.allowedAdditionalProperties;
10430
- case "strict":
10431
- return refs.rejectedAdditionalProperties;
10432
- case "strip":
10433
- return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
10434
- }
10435
- }
10436
- function safeIsOptional2(schema) {
10437
- try {
10438
- return schema.isOptional();
10439
- } catch (e2) {
10440
- return true;
10441
- }
10442
- }
10443
- var parseOptionalDef2 = (def, refs) => {
10444
- var _a20;
10445
- if (refs.currentPath.toString() === ((_a20 = refs.propertyPath) == null ? void 0 : _a20.toString())) {
10446
- return parseDef2(def.innerType._def, refs);
10447
- }
10448
- const innerSchema = parseDef2(def.innerType._def, {
10449
- ...refs,
10450
- currentPath: [...refs.currentPath, "anyOf", "1"]
10451
- });
10452
- return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
10453
- };
10454
- var parsePipelineDef2 = (def, refs) => {
10455
- if (refs.pipeStrategy === "input") {
10456
- return parseDef2(def.in._def, refs);
10457
- } else if (refs.pipeStrategy === "output") {
10458
- return parseDef2(def.out._def, refs);
10459
- }
10460
- const a = parseDef2(def.in._def, {
10461
- ...refs,
10462
- currentPath: [...refs.currentPath, "allOf", "0"]
10463
- });
10464
- const b = parseDef2(def.out._def, {
10465
- ...refs,
10466
- currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
10467
- });
10468
- return {
10469
- allOf: [a, b].filter((x) => x !== void 0)
10470
- };
10471
- };
10472
- function parsePromiseDef2(def, refs) {
10473
- return parseDef2(def.type._def, refs);
10474
- }
10475
- function parseSetDef2(def, refs) {
10476
- const items = parseDef2(def.valueType._def, {
10477
- ...refs,
10478
- currentPath: [...refs.currentPath, "items"]
10479
- });
10480
- const schema = {
10481
- type: "array",
10482
- uniqueItems: true,
10483
- items
10484
- };
10485
- if (def.minSize) {
10486
- schema.minItems = def.minSize.value;
10487
- }
10488
- if (def.maxSize) {
10489
- schema.maxItems = def.maxSize.value;
10490
- }
10491
- return schema;
10492
- }
10493
- function parseTupleDef2(def, refs) {
10494
- if (def.rest) {
10495
- return {
10496
- type: "array",
10497
- minItems: def.items.length,
10498
- items: def.items.map(
10499
- (x, i) => parseDef2(x._def, {
10500
- ...refs,
10501
- currentPath: [...refs.currentPath, "items", `${i}`]
10502
- })
10503
- ).reduce(
10504
- (acc, x) => x === void 0 ? acc : [...acc, x],
10505
- []
10506
- ),
10507
- additionalItems: parseDef2(def.rest._def, {
10508
- ...refs,
10509
- currentPath: [...refs.currentPath, "additionalItems"]
10510
- })
10511
- };
10512
- } else {
10513
- return {
10514
- type: "array",
10515
- minItems: def.items.length,
10516
- maxItems: def.items.length,
10517
- items: def.items.map(
10518
- (x, i) => parseDef2(x._def, {
10519
- ...refs,
10520
- currentPath: [...refs.currentPath, "items", `${i}`]
10521
- })
10522
- ).reduce(
10523
- (acc, x) => x === void 0 ? acc : [...acc, x],
10524
- []
10525
- )
10526
- };
10527
- }
10528
- }
10529
- function parseUndefinedDef2() {
10530
- return {
10531
- not: parseAnyDef2()
10532
- };
10533
- }
10534
- function parseUnknownDef2() {
10535
- return parseAnyDef2();
10536
- }
10537
- var parseReadonlyDef2 = (def, refs) => {
10538
- return parseDef2(def.innerType._def, refs);
10539
- };
10540
- var selectParser2 = (def, typeName, refs) => {
10541
- switch (typeName) {
10542
- case ZodFirstPartyTypeKind.ZodString:
10543
- return parseStringDef2(def, refs);
10544
- case ZodFirstPartyTypeKind.ZodNumber:
10545
- return parseNumberDef2(def);
10546
- case ZodFirstPartyTypeKind.ZodObject:
10547
- return parseObjectDef2(def, refs);
10548
- case ZodFirstPartyTypeKind.ZodBigInt:
10549
- return parseBigintDef2(def);
10550
- case ZodFirstPartyTypeKind.ZodBoolean:
10551
- return parseBooleanDef2();
10552
- case ZodFirstPartyTypeKind.ZodDate:
10553
- return parseDateDef2(def, refs);
10554
- case ZodFirstPartyTypeKind.ZodUndefined:
10555
- return parseUndefinedDef2();
10556
- case ZodFirstPartyTypeKind.ZodNull:
10557
- return parseNullDef2();
10558
- case ZodFirstPartyTypeKind.ZodArray:
10559
- return parseArrayDef2(def, refs);
10560
- case ZodFirstPartyTypeKind.ZodUnion:
10561
- case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
10562
- return parseUnionDef2(def, refs);
10563
- case ZodFirstPartyTypeKind.ZodIntersection:
10564
- return parseIntersectionDef2(def, refs);
10565
- case ZodFirstPartyTypeKind.ZodTuple:
10566
- return parseTupleDef2(def, refs);
10567
- case ZodFirstPartyTypeKind.ZodRecord:
10568
- return parseRecordDef2(def, refs);
10569
- case ZodFirstPartyTypeKind.ZodLiteral:
10570
- return parseLiteralDef2(def);
10571
- case ZodFirstPartyTypeKind.ZodEnum:
10572
- return parseEnumDef2(def);
10573
- case ZodFirstPartyTypeKind.ZodNativeEnum:
10574
- return parseNativeEnumDef2(def);
10575
- case ZodFirstPartyTypeKind.ZodNullable:
10576
- return parseNullableDef2(def, refs);
10577
- case ZodFirstPartyTypeKind.ZodOptional:
10578
- return parseOptionalDef2(def, refs);
10579
- case ZodFirstPartyTypeKind.ZodMap:
10580
- return parseMapDef2(def, refs);
10581
- case ZodFirstPartyTypeKind.ZodSet:
10582
- return parseSetDef2(def, refs);
10583
- case ZodFirstPartyTypeKind.ZodLazy:
10584
- return () => def.getter()._def;
10585
- case ZodFirstPartyTypeKind.ZodPromise:
10586
- return parsePromiseDef2(def, refs);
10587
- case ZodFirstPartyTypeKind.ZodNaN:
10588
- case ZodFirstPartyTypeKind.ZodNever:
10589
- return parseNeverDef2();
10590
- case ZodFirstPartyTypeKind.ZodEffects:
10591
- return parseEffectsDef2(def, refs);
10592
- case ZodFirstPartyTypeKind.ZodAny:
10593
- return parseAnyDef2();
10594
- case ZodFirstPartyTypeKind.ZodUnknown:
10595
- return parseUnknownDef2();
10596
- case ZodFirstPartyTypeKind.ZodDefault:
10597
- return parseDefaultDef2(def, refs);
10598
- case ZodFirstPartyTypeKind.ZodBranded:
10599
- return parseBrandedDef2(def, refs);
10600
- case ZodFirstPartyTypeKind.ZodReadonly:
10601
- return parseReadonlyDef2(def, refs);
10602
- case ZodFirstPartyTypeKind.ZodCatch:
10603
- return parseCatchDef2(def, refs);
10604
- case ZodFirstPartyTypeKind.ZodPipeline:
10605
- return parsePipelineDef2(def, refs);
10606
- case ZodFirstPartyTypeKind.ZodFunction:
10607
- case ZodFirstPartyTypeKind.ZodVoid:
10608
- case ZodFirstPartyTypeKind.ZodSymbol:
10609
- return void 0;
10610
- default:
10611
- return /* @__PURE__ */ ((_) => void 0)();
10612
- }
10613
- };
10614
- function parseDef2(def, refs, forceResolution = false) {
10615
- var _a20;
10616
- const seenItem = refs.seen.get(def);
10617
- if (refs.override) {
10618
- const overrideResult = (_a20 = refs.override) == null ? void 0 : _a20.call(
10619
- refs,
10620
- def,
10621
- refs,
10622
- seenItem,
10623
- forceResolution
10624
- );
10625
- if (overrideResult !== ignoreOverride2) {
10626
- return overrideResult;
10627
- }
10628
- }
10629
- if (seenItem && !forceResolution) {
10630
- const seenSchema = get$ref2(seenItem, refs);
10631
- if (seenSchema !== void 0) {
10632
- return seenSchema;
10633
- }
10634
- }
10635
- const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
10636
- refs.seen.set(def, newItem);
10637
- const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
10638
- const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
10639
- if (jsonSchema22) {
10640
- addMeta2(def, refs, jsonSchema22);
10641
- }
10642
- if (refs.postProcess) {
10643
- const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
10644
- newItem.jsonSchema = jsonSchema22;
10645
- return postProcessResult;
10646
- }
10647
- newItem.jsonSchema = jsonSchema22;
10648
- return jsonSchema22;
10649
- }
10650
- var get$ref2 = (item, refs) => {
10651
- switch (refs.$refStrategy) {
10652
- case "root":
10653
- return { $ref: item.path.join("/") };
10654
- case "relative":
10655
- return { $ref: getRelativePath2(refs.currentPath, item.path) };
10656
- case "none":
10657
- case "seen": {
10658
- if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
10659
- console.warn(
10660
- `Recursive reference detected at ${refs.currentPath.join(
10661
- "/"
10662
- )}! Defaulting to any`
10663
- );
10664
- return parseAnyDef2();
10665
- }
10666
- return refs.$refStrategy === "seen" ? parseAnyDef2() : void 0;
10667
- }
10668
- }
10669
- };
10670
- var addMeta2 = (def, refs, jsonSchema22) => {
10671
- if (def.description) {
10672
- jsonSchema22.description = def.description;
10673
- }
10674
- return jsonSchema22;
10675
- };
10676
- var getRefs2 = (options) => {
10677
- const _options = getDefaultOptions2(options);
10678
- const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
10679
- return {
10680
- ..._options,
10681
- currentPath,
10682
- propertyPath: void 0,
10683
- seen: new Map(
10684
- Object.entries(_options.definitions).map(([name20, def]) => [
10685
- def._def,
10686
- {
10687
- def: def._def,
10688
- path: [..._options.basePath, _options.definitionPath, name20],
10689
- // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
10690
- jsonSchema: void 0
10691
- }
10692
- ])
10693
- )
10694
- };
10695
- };
10696
- var zodToJsonSchema3 = (schema, options) => {
10697
- var _a20;
10698
- const refs = getRefs2(options);
10699
- let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
10700
- (acc, [name25, schema2]) => {
10701
- var _a25;
10702
- return {
10703
- ...acc,
10704
- [name25]: (_a25 = parseDef2(
10705
- schema2._def,
10706
- {
10707
- ...refs,
10708
- currentPath: [...refs.basePath, refs.definitionPath, name25]
10709
- },
10710
- true
10711
- )) != null ? _a25 : parseAnyDef2()
10712
- };
10713
- },
10714
- {}
10715
- ) : void 0;
10716
- const name20 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
10717
- const main = (_a20 = parseDef2(
10718
- schema._def,
10719
- name20 === void 0 ? refs : {
10720
- ...refs,
10721
- currentPath: [...refs.basePath, refs.definitionPath, name20]
10722
- },
10723
- false
10724
- )) != null ? _a20 : parseAnyDef2();
10725
- const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
10726
- if (title !== void 0) {
10727
- main.title = title;
10728
- }
10729
- const combined = name20 === void 0 ? definitions ? {
10730
- ...main,
10731
- [refs.definitionPath]: definitions
10732
- } : main : {
10733
- $ref: [
10734
- ...refs.$refStrategy === "relative" ? [] : refs.basePath,
10735
- refs.definitionPath,
10736
- name20
10737
- ].join("/"),
10738
- [refs.definitionPath]: {
10739
- ...definitions,
10740
- [name20]: main
10741
- }
10742
- };
10743
- combined.$schema = "http://json-schema.org/draft-07/schema#";
10744
- return combined;
10745
- };
10746
- var zod_to_json_schema_default2 = zodToJsonSchema3;
10747
- function zod3Schema2(zodSchema22, options) {
10748
- var _a20;
10749
- const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
10750
- return jsonSchema3(
10751
- zod_to_json_schema_default2(zodSchema22, {
10752
- $refStrategy: useReferences ? "root" : "none"
10753
- }),
10754
- {
10755
- validate: async (value) => {
10756
- const result = await zodSchema22.safeParseAsync(value);
10757
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
10758
- }
10759
- }
10760
- );
10761
- }
10762
- function zod4Schema2(zodSchema22, options) {
10763
- var _a20;
10764
- const useReferences = (_a20 = void 0 ) != null ? _a20 : false;
10765
- const z4JSONSchema = z42.toJSONSchema(zodSchema22, {
10766
- target: "draft-7",
10767
- io: "output",
10768
- reused: useReferences ? "ref" : "inline"
10769
- });
10770
- return jsonSchema3(z4JSONSchema, {
10771
- validate: async (value) => {
10772
- const result = await z42.safeParseAsync(zodSchema22, value);
10773
- return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
10774
- }
10775
- });
10776
- }
10777
- function isZod4Schema2(zodSchema22) {
10778
- return "_zod" in zodSchema22;
10779
- }
10780
- function zodSchema3(zodSchema22, options) {
10781
- if (isZod4Schema2(zodSchema22)) {
10782
- return zod4Schema2(zodSchema22);
10783
- } else {
10784
- return zod3Schema2(zodSchema22);
10785
- }
10786
- }
10787
- var schemaSymbol3 = Symbol.for("vercel.ai.schema");
10788
- function jsonSchema3(jsonSchema22, {
10789
- validate
10790
- } = {}) {
10791
- return {
10792
- [schemaSymbol3]: true,
10793
- _type: void 0,
10794
- // should never be used directly
10795
- [validatorSymbol3]: true,
10796
- jsonSchema: jsonSchema22,
10797
- validate
10798
- };
10799
- }
10800
- function isSchema3(value) {
10801
- return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
10802
- }
10803
- function asSchema3(schema) {
10804
- return schema == null ? jsonSchema3({
10805
- properties: {},
10806
- additionalProperties: false
10807
- }) : isSchema3(schema) ? schema : zodSchema3(schema);
10808
- }
10809
- var __defProp4 = Object.defineProperty;
10810
- var __export4 = (target, all) => {
10811
- for (var name172 in all)
10812
- __defProp4(target, name172, { get: all[name172], enumerable: true });
10813
- };
10814
- var name73 = "AI_NoObjectGeneratedError";
10815
- var marker74 = `vercel.ai.error.${name73}`;
10816
- var symbol74 = Symbol.for(marker74);
10817
- var _a74;
10818
- var NoObjectGeneratedError3 = class extends AISDKError$1 {
10819
- constructor({
10820
- message = "No object generated.",
10821
- cause,
10822
- text: text22,
10823
- response,
10824
- usage,
10825
- finishReason
10826
- }) {
10827
- super({ name: name73, message, cause });
10828
- this[_a74] = true;
10829
- this.text = text22;
10830
- this.response = response;
10831
- this.usage = usage;
10832
- this.finishReason = finishReason;
10833
- }
10834
- static isInstance(error) {
10835
- return AISDKError$1.hasMarker(error, marker74);
10836
- }
10837
- };
10838
- _a74 = symbol74;
10839
- var dataContentSchema3 = z$1.union([
10840
- z$1.string(),
10841
- z$1.instanceof(Uint8Array),
10842
- z$1.instanceof(ArrayBuffer),
10843
- z$1.custom(
10844
- // Buffer might not be available in some environments such as CloudFlare:
10845
- (value) => {
10846
- var _a172, _b8;
10847
- return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
10848
- },
10849
- { message: "Must be a Buffer" }
10850
- )
10851
- ]);
10852
- var jsonValueSchema3 = z$1.lazy(
10853
- () => z$1.union([
10854
- z$1.null(),
10855
- z$1.string(),
10856
- z$1.number(),
10857
- z$1.boolean(),
10858
- z$1.record(z$1.string(), jsonValueSchema3),
10859
- z$1.array(jsonValueSchema3)
10860
- ])
10861
- );
10862
- var providerMetadataSchema3 = z$1.record(
10863
- z$1.string(),
10864
- z$1.record(z$1.string(), jsonValueSchema3)
10865
- );
10866
- var textPartSchema3 = z$1.object({
10867
- type: z$1.literal("text"),
10868
- text: z$1.string(),
10869
- providerOptions: providerMetadataSchema3.optional()
10870
- });
10871
- var imagePartSchema3 = z$1.object({
10872
- type: z$1.literal("image"),
10873
- image: z$1.union([dataContentSchema3, z$1.instanceof(URL)]),
10874
- mediaType: z$1.string().optional(),
10875
- providerOptions: providerMetadataSchema3.optional()
10876
- });
10877
- var filePartSchema3 = z$1.object({
10878
- type: z$1.literal("file"),
10879
- data: z$1.union([dataContentSchema3, z$1.instanceof(URL)]),
10880
- filename: z$1.string().optional(),
10881
- mediaType: z$1.string(),
10882
- providerOptions: providerMetadataSchema3.optional()
10883
- });
10884
- var reasoningPartSchema3 = z$1.object({
10885
- type: z$1.literal("reasoning"),
10886
- text: z$1.string(),
10887
- providerOptions: providerMetadataSchema3.optional()
10888
- });
10889
- var toolCallPartSchema3 = z$1.object({
10890
- type: z$1.literal("tool-call"),
10891
- toolCallId: z$1.string(),
10892
- toolName: z$1.string(),
10893
- input: z$1.unknown(),
10894
- providerOptions: providerMetadataSchema3.optional(),
10895
- providerExecuted: z$1.boolean().optional()
10896
- });
10897
- var outputSchema2 = z$1.discriminatedUnion("type", [
10898
- z$1.object({
10899
- type: z$1.literal("text"),
10900
- value: z$1.string()
10901
- }),
10902
- z$1.object({
10903
- type: z$1.literal("json"),
10904
- value: jsonValueSchema3
10905
- }),
10906
- z$1.object({
10907
- type: z$1.literal("error-text"),
10908
- value: z$1.string()
10909
- }),
10910
- z$1.object({
10911
- type: z$1.literal("error-json"),
10912
- value: jsonValueSchema3
10913
- }),
10914
- z$1.object({
10915
- type: z$1.literal("content"),
10916
- value: z$1.array(
10917
- z$1.union([
10918
- z$1.object({
10919
- type: z$1.literal("text"),
10920
- text: z$1.string()
10921
- }),
10922
- z$1.object({
10923
- type: z$1.literal("media"),
10924
- data: z$1.string(),
10925
- mediaType: z$1.string()
10926
- })
10927
- ])
10928
- )
10929
- })
10930
- ]);
10931
- var toolResultPartSchema3 = z$1.object({
10932
- type: z$1.literal("tool-result"),
10933
- toolCallId: z$1.string(),
10934
- toolName: z$1.string(),
10935
- output: outputSchema2,
10936
- providerOptions: providerMetadataSchema3.optional()
10937
- });
10938
- var systemModelMessageSchema2 = z$1.object(
10939
- {
10940
- role: z$1.literal("system"),
10941
- content: z$1.string(),
10942
- providerOptions: providerMetadataSchema3.optional()
10943
- }
10944
- );
10945
- var userModelMessageSchema2 = z$1.object({
10946
- role: z$1.literal("user"),
10947
- content: z$1.union([
10948
- z$1.string(),
10949
- z$1.array(z$1.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
10950
- ]),
10951
- providerOptions: providerMetadataSchema3.optional()
10952
- });
10953
- var assistantModelMessageSchema2 = z$1.object({
10954
- role: z$1.literal("assistant"),
10955
- content: z$1.union([
10956
- z$1.string(),
10957
- z$1.array(
10958
- z$1.union([
10959
- textPartSchema3,
10960
- filePartSchema3,
10961
- reasoningPartSchema3,
10962
- toolCallPartSchema3,
10963
- toolResultPartSchema3
10964
- ])
10965
- )
10966
- ]),
10967
- providerOptions: providerMetadataSchema3.optional()
10968
- });
10969
- var toolModelMessageSchema2 = z$1.object({
10970
- role: z$1.literal("tool"),
10971
- content: z$1.array(toolResultPartSchema3),
10972
- providerOptions: providerMetadataSchema3.optional()
10973
- });
10974
- z$1.union([
10975
- systemModelMessageSchema2,
10976
- userModelMessageSchema2,
10977
- assistantModelMessageSchema2,
10978
- toolModelMessageSchema2
10979
- ]);
10980
- function stepCountIs(stepCount) {
10981
- return ({ steps }) => steps.length === stepCount;
10982
- }
10983
- createIdGenerator3({
10984
- prefix: "aitxt",
10985
- size: 24
10986
- });
10987
- z$1.union([
10988
- z$1.strictObject({
10989
- type: z$1.literal("text-start"),
10990
- id: z$1.string(),
10991
- providerMetadata: providerMetadataSchema3.optional()
10992
- }),
10993
- z$1.strictObject({
10994
- type: z$1.literal("text-delta"),
10995
- id: z$1.string(),
10996
- delta: z$1.string(),
10997
- providerMetadata: providerMetadataSchema3.optional()
10998
- }),
10999
- z$1.strictObject({
11000
- type: z$1.literal("text-end"),
11001
- id: z$1.string(),
11002
- providerMetadata: providerMetadataSchema3.optional()
11003
- }),
11004
- z$1.strictObject({
11005
- type: z$1.literal("error"),
11006
- errorText: z$1.string()
11007
- }),
11008
- z$1.strictObject({
11009
- type: z$1.literal("tool-input-start"),
11010
- toolCallId: z$1.string(),
11011
- toolName: z$1.string(),
11012
- providerExecuted: z$1.boolean().optional(),
11013
- dynamic: z$1.boolean().optional()
11014
- }),
11015
- z$1.strictObject({
11016
- type: z$1.literal("tool-input-delta"),
11017
- toolCallId: z$1.string(),
11018
- inputTextDelta: z$1.string()
11019
- }),
11020
- z$1.strictObject({
11021
- type: z$1.literal("tool-input-available"),
11022
- toolCallId: z$1.string(),
11023
- toolName: z$1.string(),
11024
- input: z$1.unknown(),
11025
- providerExecuted: z$1.boolean().optional(),
11026
- providerMetadata: providerMetadataSchema3.optional(),
11027
- dynamic: z$1.boolean().optional()
11028
- }),
11029
- z$1.strictObject({
11030
- type: z$1.literal("tool-input-error"),
11031
- toolCallId: z$1.string(),
11032
- toolName: z$1.string(),
11033
- input: z$1.unknown(),
11034
- providerExecuted: z$1.boolean().optional(),
11035
- providerMetadata: providerMetadataSchema3.optional(),
11036
- dynamic: z$1.boolean().optional(),
11037
- errorText: z$1.string()
11038
- }),
11039
- z$1.strictObject({
11040
- type: z$1.literal("tool-output-available"),
11041
- toolCallId: z$1.string(),
11042
- output: z$1.unknown(),
11043
- providerExecuted: z$1.boolean().optional(),
11044
- dynamic: z$1.boolean().optional(),
11045
- preliminary: z$1.boolean().optional()
11046
- }),
11047
- z$1.strictObject({
11048
- type: z$1.literal("tool-output-error"),
11049
- toolCallId: z$1.string(),
11050
- errorText: z$1.string(),
11051
- providerExecuted: z$1.boolean().optional(),
11052
- dynamic: z$1.boolean().optional()
11053
- }),
11054
- z$1.strictObject({
11055
- type: z$1.literal("reasoning"),
11056
- text: z$1.string(),
11057
- providerMetadata: providerMetadataSchema3.optional()
11058
- }),
11059
- z$1.strictObject({
11060
- type: z$1.literal("reasoning-start"),
11061
- id: z$1.string(),
11062
- providerMetadata: providerMetadataSchema3.optional()
11063
- }),
11064
- z$1.strictObject({
11065
- type: z$1.literal("reasoning-delta"),
11066
- id: z$1.string(),
11067
- delta: z$1.string(),
11068
- providerMetadata: providerMetadataSchema3.optional()
11069
- }),
11070
- z$1.strictObject({
11071
- type: z$1.literal("reasoning-end"),
11072
- id: z$1.string(),
11073
- providerMetadata: providerMetadataSchema3.optional()
11074
- }),
11075
- z$1.strictObject({
11076
- type: z$1.literal("reasoning-part-finish")
11077
- }),
11078
- z$1.strictObject({
11079
- type: z$1.literal("source-url"),
11080
- sourceId: z$1.string(),
11081
- url: z$1.string(),
11082
- title: z$1.string().optional(),
11083
- providerMetadata: providerMetadataSchema3.optional()
11084
- }),
11085
- z$1.strictObject({
11086
- type: z$1.literal("source-document"),
11087
- sourceId: z$1.string(),
11088
- mediaType: z$1.string(),
11089
- title: z$1.string(),
11090
- filename: z$1.string().optional(),
11091
- providerMetadata: providerMetadataSchema3.optional()
11092
- }),
11093
- z$1.strictObject({
11094
- type: z$1.literal("file"),
11095
- url: z$1.string(),
11096
- mediaType: z$1.string(),
11097
- providerMetadata: providerMetadataSchema3.optional()
11098
- }),
11099
- z$1.strictObject({
11100
- type: z$1.string().startsWith("data-"),
11101
- id: z$1.string().optional(),
11102
- data: z$1.unknown(),
11103
- transient: z$1.boolean().optional()
11104
- }),
11105
- z$1.strictObject({
11106
- type: z$1.literal("start-step")
11107
- }),
11108
- z$1.strictObject({
11109
- type: z$1.literal("finish-step")
11110
- }),
11111
- z$1.strictObject({
11112
- type: z$1.literal("start"),
11113
- messageId: z$1.string().optional(),
11114
- messageMetadata: z$1.unknown().optional()
11115
- }),
11116
- z$1.strictObject({
11117
- type: z$1.literal("finish"),
11118
- messageMetadata: z$1.unknown().optional()
11119
- }),
11120
- z$1.strictObject({
11121
- type: z$1.literal("abort")
11122
- }),
11123
- z$1.strictObject({
11124
- type: z$1.literal("message-metadata"),
11125
- messageMetadata: z$1.unknown()
11126
- })
11127
- ]);
11128
- function fixJson3(input) {
11129
- const stack = ["ROOT"];
11130
- let lastValidIndex = -1;
11131
- let literalStart = null;
11132
- function processValueStart(char, i, swapState) {
11133
- {
11134
- switch (char) {
11135
- case '"': {
11136
- lastValidIndex = i;
11137
- stack.pop();
11138
- stack.push(swapState);
11139
- stack.push("INSIDE_STRING");
11140
- break;
11141
- }
11142
- case "f":
11143
- case "t":
11144
- case "n": {
11145
- lastValidIndex = i;
11146
- literalStart = i;
11147
- stack.pop();
11148
- stack.push(swapState);
11149
- stack.push("INSIDE_LITERAL");
11150
- break;
11151
- }
11152
- case "-": {
11153
- stack.pop();
11154
- stack.push(swapState);
11155
- stack.push("INSIDE_NUMBER");
11156
- break;
11157
- }
11158
- case "0":
11159
- case "1":
11160
- case "2":
11161
- case "3":
11162
- case "4":
11163
- case "5":
11164
- case "6":
11165
- case "7":
11166
- case "8":
11167
- case "9": {
11168
- lastValidIndex = i;
11169
- stack.pop();
11170
- stack.push(swapState);
11171
- stack.push("INSIDE_NUMBER");
11172
- break;
11173
- }
11174
- case "{": {
11175
- lastValidIndex = i;
11176
- stack.pop();
11177
- stack.push(swapState);
11178
- stack.push("INSIDE_OBJECT_START");
11179
- break;
11180
- }
11181
- case "[": {
11182
- lastValidIndex = i;
11183
- stack.pop();
11184
- stack.push(swapState);
11185
- stack.push("INSIDE_ARRAY_START");
11186
- break;
11187
- }
11188
- }
11189
- }
11190
- }
11191
- function processAfterObjectValue(char, i) {
11192
- switch (char) {
11193
- case ",": {
11194
- stack.pop();
11195
- stack.push("INSIDE_OBJECT_AFTER_COMMA");
11196
- break;
11197
- }
11198
- case "}": {
11199
- lastValidIndex = i;
11200
- stack.pop();
11201
- break;
11202
- }
11203
- }
11204
- }
11205
- function processAfterArrayValue(char, i) {
11206
- switch (char) {
11207
- case ",": {
11208
- stack.pop();
11209
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
11210
- break;
11211
- }
11212
- case "]": {
11213
- lastValidIndex = i;
11214
- stack.pop();
11215
- break;
11216
- }
11217
- }
11218
- }
11219
- for (let i = 0; i < input.length; i++) {
11220
- const char = input[i];
11221
- const currentState = stack[stack.length - 1];
11222
- switch (currentState) {
11223
- case "ROOT":
11224
- processValueStart(char, i, "FINISH");
11225
- break;
11226
- case "INSIDE_OBJECT_START": {
11227
- switch (char) {
11228
- case '"': {
11229
- stack.pop();
11230
- stack.push("INSIDE_OBJECT_KEY");
11231
- break;
11232
- }
11233
- case "}": {
11234
- lastValidIndex = i;
11235
- stack.pop();
11236
- break;
11237
- }
11238
- }
11239
- break;
11240
- }
11241
- case "INSIDE_OBJECT_AFTER_COMMA": {
11242
- switch (char) {
11243
- case '"': {
11244
- stack.pop();
11245
- stack.push("INSIDE_OBJECT_KEY");
11246
- break;
11247
- }
11248
- }
11249
- break;
11250
- }
11251
- case "INSIDE_OBJECT_KEY": {
11252
- switch (char) {
11253
- case '"': {
11254
- stack.pop();
11255
- stack.push("INSIDE_OBJECT_AFTER_KEY");
11256
- break;
11257
- }
11258
- }
11259
- break;
11260
- }
11261
- case "INSIDE_OBJECT_AFTER_KEY": {
11262
- switch (char) {
11263
- case ":": {
11264
- stack.pop();
11265
- stack.push("INSIDE_OBJECT_BEFORE_VALUE");
11266
- break;
11267
- }
11268
- }
11269
- break;
11270
- }
11271
- case "INSIDE_OBJECT_BEFORE_VALUE": {
11272
- processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
11273
- break;
11274
- }
11275
- case "INSIDE_OBJECT_AFTER_VALUE": {
11276
- processAfterObjectValue(char, i);
11277
- break;
11278
- }
11279
- case "INSIDE_STRING": {
11280
- switch (char) {
11281
- case '"': {
11282
- stack.pop();
11283
- lastValidIndex = i;
11284
- break;
11285
- }
11286
- case "\\": {
11287
- stack.push("INSIDE_STRING_ESCAPE");
11288
- break;
11289
- }
11290
- default: {
11291
- lastValidIndex = i;
11292
- }
11293
- }
11294
- break;
11295
- }
11296
- case "INSIDE_ARRAY_START": {
11297
- switch (char) {
11298
- case "]": {
11299
- lastValidIndex = i;
11300
- stack.pop();
11301
- break;
11302
- }
11303
- default: {
11304
- lastValidIndex = i;
11305
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
11306
- break;
11307
- }
11308
- }
11309
- break;
11310
- }
11311
- case "INSIDE_ARRAY_AFTER_VALUE": {
11312
- switch (char) {
11313
- case ",": {
11314
- stack.pop();
11315
- stack.push("INSIDE_ARRAY_AFTER_COMMA");
11316
- break;
11317
- }
11318
- case "]": {
11319
- lastValidIndex = i;
11320
- stack.pop();
11321
- break;
11322
- }
11323
- default: {
11324
- lastValidIndex = i;
11325
- break;
11326
- }
11327
- }
11328
- break;
11329
- }
11330
- case "INSIDE_ARRAY_AFTER_COMMA": {
11331
- processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
11332
- break;
11333
- }
11334
- case "INSIDE_STRING_ESCAPE": {
11335
- stack.pop();
11336
- lastValidIndex = i;
11337
- break;
11338
- }
11339
- case "INSIDE_NUMBER": {
11340
- switch (char) {
11341
- case "0":
11342
- case "1":
11343
- case "2":
11344
- case "3":
11345
- case "4":
11346
- case "5":
11347
- case "6":
11348
- case "7":
11349
- case "8":
11350
- case "9": {
11351
- lastValidIndex = i;
11352
- break;
11353
- }
11354
- case "e":
11355
- case "E":
11356
- case "-":
11357
- case ".": {
11358
- break;
11359
- }
11360
- case ",": {
11361
- stack.pop();
11362
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
11363
- processAfterArrayValue(char, i);
11364
- }
11365
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
11366
- processAfterObjectValue(char, i);
11367
- }
11368
- break;
11369
- }
11370
- case "}": {
11371
- stack.pop();
11372
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
11373
- processAfterObjectValue(char, i);
11374
- }
11375
- break;
11376
- }
11377
- case "]": {
11378
- stack.pop();
11379
- if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
11380
- processAfterArrayValue(char, i);
11381
- }
11382
- break;
11383
- }
11384
- default: {
11385
- stack.pop();
11386
- break;
11387
- }
11388
- }
11389
- break;
11390
- }
11391
- case "INSIDE_LITERAL": {
11392
- const partialLiteral = input.substring(literalStart, i + 1);
11393
- if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
11394
- stack.pop();
11395
- if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
11396
- processAfterObjectValue(char, i);
11397
- } else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
11398
- processAfterArrayValue(char, i);
11399
- }
11400
- } else {
11401
- lastValidIndex = i;
11402
- }
11403
- break;
11404
- }
11405
- }
11406
- }
11407
- let result = input.slice(0, lastValidIndex + 1);
11408
- for (let i = stack.length - 1; i >= 0; i--) {
11409
- const state = stack[i];
11410
- switch (state) {
11411
- case "INSIDE_STRING": {
11412
- result += '"';
11413
- break;
11414
- }
11415
- case "INSIDE_OBJECT_KEY":
11416
- case "INSIDE_OBJECT_AFTER_KEY":
11417
- case "INSIDE_OBJECT_AFTER_COMMA":
11418
- case "INSIDE_OBJECT_START":
11419
- case "INSIDE_OBJECT_BEFORE_VALUE":
11420
- case "INSIDE_OBJECT_AFTER_VALUE": {
11421
- result += "}";
11422
- break;
11423
- }
11424
- case "INSIDE_ARRAY_START":
11425
- case "INSIDE_ARRAY_AFTER_COMMA":
11426
- case "INSIDE_ARRAY_AFTER_VALUE": {
11427
- result += "]";
11428
- break;
11429
- }
11430
- case "INSIDE_LITERAL": {
11431
- const partialLiteral = input.substring(literalStart, input.length);
11432
- if ("true".startsWith(partialLiteral)) {
11433
- result += "true".slice(partialLiteral.length);
11434
- } else if ("false".startsWith(partialLiteral)) {
11435
- result += "false".slice(partialLiteral.length);
11436
- } else if ("null".startsWith(partialLiteral)) {
11437
- result += "null".slice(partialLiteral.length);
11438
- }
11439
- }
11440
- }
11441
- }
11442
- return result;
11443
- }
11444
- async function parsePartialJson3(jsonText) {
11445
- if (jsonText === void 0) {
11446
- return { value: void 0, state: "undefined-input" };
11447
- }
11448
- let result = await safeParseJSON3({ text: jsonText });
11449
- if (result.success) {
11450
- return { value: result.value, state: "successful-parse" };
11451
- }
11452
- result = await safeParseJSON3({ text: fixJson3(jsonText) });
11453
- if (result.success) {
11454
- return { value: result.value, state: "repaired-parse" };
11455
- }
11456
- return { value: void 0, state: "failed-parse" };
11457
- }
11458
- createIdGenerator3({
11459
- prefix: "aitxt",
11460
- size: 24
11461
- });
11462
- createIdGenerator3({ prefix: "aiobj", size: 24 });
11463
- createIdGenerator3({ prefix: "aiobj", size: 24 });
11464
- var output_exports3 = {};
11465
- __export4(output_exports3, {
11466
- object: () => object3,
11467
- text: () => text3
11468
- });
11469
- var text3 = () => ({
11470
- type: "text",
11471
- responseFormat: { type: "text" },
11472
- async parsePartial({ text: text22 }) {
11473
- return { partial: text22 };
11474
- },
11475
- async parseOutput({ text: text22 }) {
11476
- return text22;
11477
- }
11478
- });
11479
- var object3 = ({
11480
- schema: inputSchema
11481
- }) => {
11482
- const schema = asSchema3(inputSchema);
11483
- return {
11484
- type: "object",
11485
- responseFormat: {
11486
- type: "json",
11487
- schema: schema.jsonSchema
11488
- },
11489
- async parsePartial({ text: text22 }) {
11490
- const result = await parsePartialJson3(text22);
11491
- switch (result.state) {
11492
- case "failed-parse":
11493
- case "undefined-input":
11494
- return void 0;
11495
- case "repaired-parse":
11496
- case "successful-parse":
11497
- return {
11498
- // Note: currently no validation of partial results:
11499
- partial: result.value
11500
- };
11501
- default: {
11502
- const _exhaustiveCheck = result.state;
11503
- throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
11504
- }
11505
- }
11506
- },
11507
- async parseOutput({ text: text22 }, context) {
11508
- const parseResult = await safeParseJSON3({ text: text22 });
11509
- if (!parseResult.success) {
11510
- throw new NoObjectGeneratedError3({
11511
- message: "No object generated: could not parse the response.",
11512
- cause: parseResult.error,
11513
- text: text22,
11514
- response: context.response,
11515
- usage: context.usage,
11516
- finishReason: context.finishReason
11517
- });
9475
+ `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`
9476
+ );
9477
+ break;
11518
9478
  }
11519
- const validationResult = await safeValidateTypes3({
11520
- value: parseResult.value,
11521
- schema
11522
- });
11523
- if (!validationResult.success) {
11524
- throw new NoObjectGeneratedError3({
11525
- message: "No object generated: response did not match schema.",
11526
- cause: validationResult.error,
11527
- text: text22,
11528
- response: context.response,
11529
- usage: context.usage,
11530
- finishReason: context.finishReason
11531
- });
9479
+ }
9480
+ return result;
9481
+ }
9482
+ countTokens(message) {
9483
+ if (typeof message === `string`) {
9484
+ return this.encoder.encode(message).length;
9485
+ }
9486
+ let tokenString = message.role;
9487
+ let overhead = 0;
9488
+ if (typeof message.content === "string" && message.content) {
9489
+ tokenString += message.content;
9490
+ } else if (Array.isArray(message.content)) {
9491
+ for (const part of message.content) {
9492
+ if (part.type === "text") {
9493
+ tokenString += part.text;
9494
+ } else if (part.type === "tool-call" || part.type === `tool-result`) {
9495
+ if (`args` in part && part.args && part.type === `tool-call`) {
9496
+ tokenString += part.toolName;
9497
+ if (typeof part.args === "string") {
9498
+ tokenString += part.args;
9499
+ } else {
9500
+ tokenString += JSON.stringify(part.args);
9501
+ overhead -= 12;
9502
+ }
9503
+ }
9504
+ if (`result` in part && part.result !== void 0 && part.type === `tool-result`) {
9505
+ if (typeof part.result === "string") {
9506
+ tokenString += part.result;
9507
+ } else {
9508
+ tokenString += JSON.stringify(part.result);
9509
+ overhead -= 12;
9510
+ }
9511
+ }
9512
+ } else {
9513
+ tokenString += JSON.stringify(part);
9514
+ }
11532
9515
  }
11533
- return validationResult.value;
11534
9516
  }
11535
- };
9517
+ if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
9518
+ message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
9519
+ overhead += this.TOKENS_PER_MESSAGE;
9520
+ }
9521
+ return this.encoder.encode(tokenString).length + overhead;
9522
+ }
11536
9523
  };
11537
- var ClientOrServerImplementationSchema3 = z$1.looseObject({
11538
- name: z$1.string(),
11539
- version: z$1.string()
11540
- });
11541
- var BaseParamsSchema3 = z$1.looseObject({
11542
- _meta: z$1.optional(z$1.object({}).loose())
11543
- });
11544
- var ResultSchema3 = BaseParamsSchema3;
11545
- var RequestSchema3 = z$1.object({
11546
- method: z$1.string(),
11547
- params: z$1.optional(BaseParamsSchema3)
11548
- });
11549
- var ServerCapabilitiesSchema3 = z$1.looseObject({
11550
- experimental: z$1.optional(z$1.object({}).loose()),
11551
- logging: z$1.optional(z$1.object({}).loose()),
11552
- prompts: z$1.optional(
11553
- z$1.looseObject({
11554
- listChanged: z$1.optional(z$1.boolean())
11555
- })
11556
- ),
11557
- resources: z$1.optional(
11558
- z$1.looseObject({
11559
- subscribe: z$1.optional(z$1.boolean()),
11560
- listChanged: z$1.optional(z$1.boolean())
11561
- })
11562
- ),
11563
- tools: z$1.optional(
11564
- z$1.looseObject({
11565
- listChanged: z$1.optional(z$1.boolean())
11566
- })
11567
- )
11568
- });
11569
- ResultSchema3.extend({
11570
- protocolVersion: z$1.string(),
11571
- capabilities: ServerCapabilitiesSchema3,
11572
- serverInfo: ClientOrServerImplementationSchema3,
11573
- instructions: z$1.optional(z$1.string())
11574
- });
11575
- var PaginatedResultSchema3 = ResultSchema3.extend({
11576
- nextCursor: z$1.optional(z$1.string())
11577
- });
11578
- var ToolSchema3 = z$1.object({
11579
- name: z$1.string(),
11580
- description: z$1.optional(z$1.string()),
11581
- inputSchema: z$1.object({
11582
- type: z$1.literal("object"),
11583
- properties: z$1.optional(z$1.object({}).loose())
11584
- }).loose()
11585
- }).loose();
11586
- PaginatedResultSchema3.extend({
11587
- tools: z$1.array(ToolSchema3)
11588
- });
11589
- var TextContentSchema3 = z$1.object({
11590
- type: z$1.literal("text"),
11591
- text: z$1.string()
11592
- }).loose();
11593
- var ImageContentSchema3 = z$1.object({
11594
- type: z$1.literal("image"),
11595
- data: z$1.base64(),
11596
- mimeType: z$1.string()
11597
- }).loose();
11598
- var ResourceContentsSchema3 = z$1.object({
11599
- /**
11600
- * The URI of this resource.
11601
- */
11602
- uri: z$1.string(),
11603
- /**
11604
- * The MIME type of this resource, if known.
11605
- */
11606
- mimeType: z$1.optional(z$1.string())
11607
- }).loose();
11608
- var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
11609
- text: z$1.string()
11610
- });
11611
- var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
11612
- blob: z$1.base64()
11613
- });
11614
- var EmbeddedResourceSchema3 = z$1.object({
11615
- type: z$1.literal("resource"),
11616
- resource: z$1.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
11617
- }).loose();
11618
- ResultSchema3.extend({
11619
- content: z$1.array(
11620
- z$1.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
11621
- ),
11622
- isError: z$1.boolean().default(false).optional()
11623
- }).or(
11624
- ResultSchema3.extend({
11625
- toolResult: z$1.unknown()
11626
- })
11627
- );
11628
- var JSONRPC_VERSION3 = "2.0";
11629
- var JSONRPCRequestSchema3 = z$1.object({
11630
- jsonrpc: z$1.literal(JSONRPC_VERSION3),
11631
- id: z$1.union([z$1.string(), z$1.number().int()])
11632
- }).merge(RequestSchema3).strict();
11633
- var JSONRPCResponseSchema3 = z$1.object({
11634
- jsonrpc: z$1.literal(JSONRPC_VERSION3),
11635
- id: z$1.union([z$1.string(), z$1.number().int()]),
11636
- result: ResultSchema3
11637
- }).strict();
11638
- var JSONRPCErrorSchema3 = z$1.object({
11639
- jsonrpc: z$1.literal(JSONRPC_VERSION3),
11640
- id: z$1.union([z$1.string(), z$1.number().int()]),
11641
- error: z$1.object({
11642
- code: z$1.number().int(),
11643
- message: z$1.string(),
11644
- data: z$1.optional(z$1.unknown())
11645
- })
11646
- }).strict();
11647
- var JSONRPCNotificationSchema3 = z$1.object({
11648
- jsonrpc: z$1.literal(JSONRPC_VERSION3)
11649
- }).merge(
11650
- z$1.object({
11651
- method: z$1.string(),
11652
- params: z$1.optional(BaseParamsSchema3)
11653
- })
11654
- ).strict();
11655
- z$1.union([
11656
- JSONRPCRequestSchema3,
11657
- JSONRPCNotificationSchema3,
11658
- JSONRPCResponseSchema3,
11659
- JSONRPCErrorSchema3
11660
- ]);
11661
- var textUIPartSchema2 = z$1.object({
11662
- type: z$1.literal("text"),
11663
- text: z$1.string(),
11664
- state: z$1.enum(["streaming", "done"]).optional(),
11665
- providerMetadata: providerMetadataSchema3.optional()
11666
- });
11667
- var reasoningUIPartSchema2 = z$1.object({
11668
- type: z$1.literal("reasoning"),
11669
- text: z$1.string(),
11670
- state: z$1.enum(["streaming", "done"]).optional(),
11671
- providerMetadata: providerMetadataSchema3.optional()
11672
- });
11673
- var sourceUrlUIPartSchema2 = z$1.object({
11674
- type: z$1.literal("source-url"),
11675
- sourceId: z$1.string(),
11676
- url: z$1.string(),
11677
- title: z$1.string().optional(),
11678
- providerMetadata: providerMetadataSchema3.optional()
11679
- });
11680
- var sourceDocumentUIPartSchema2 = z$1.object({
11681
- type: z$1.literal("source-document"),
11682
- sourceId: z$1.string(),
11683
- mediaType: z$1.string(),
11684
- title: z$1.string(),
11685
- filename: z$1.string().optional(),
11686
- providerMetadata: providerMetadataSchema3.optional()
11687
- });
11688
- var fileUIPartSchema2 = z$1.object({
11689
- type: z$1.literal("file"),
11690
- mediaType: z$1.string(),
11691
- filename: z$1.string().optional(),
11692
- url: z$1.string(),
11693
- providerMetadata: providerMetadataSchema3.optional()
11694
- });
11695
- var stepStartUIPartSchema2 = z$1.object({
11696
- type: z$1.literal("step-start")
11697
- });
11698
- var dataUIPartSchema2 = z$1.object({
11699
- type: z$1.string().startsWith("data-"),
11700
- id: z$1.string().optional(),
11701
- data: z$1.unknown()
11702
- });
11703
- var dynamicToolUIPartSchemas2 = [
11704
- z$1.object({
11705
- type: z$1.literal("dynamic-tool"),
11706
- toolName: z$1.string(),
11707
- toolCallId: z$1.string(),
11708
- state: z$1.literal("input-streaming"),
11709
- input: z$1.unknown().optional(),
11710
- output: z$1.never().optional(),
11711
- errorText: z$1.never().optional()
11712
- }),
11713
- z$1.object({
11714
- type: z$1.literal("dynamic-tool"),
11715
- toolName: z$1.string(),
11716
- toolCallId: z$1.string(),
11717
- state: z$1.literal("input-available"),
11718
- input: z$1.unknown(),
11719
- output: z$1.never().optional(),
11720
- errorText: z$1.never().optional(),
11721
- callProviderMetadata: providerMetadataSchema3.optional()
11722
- }),
11723
- z$1.object({
11724
- type: z$1.literal("dynamic-tool"),
11725
- toolName: z$1.string(),
11726
- toolCallId: z$1.string(),
11727
- state: z$1.literal("output-available"),
11728
- input: z$1.unknown(),
11729
- output: z$1.unknown(),
11730
- errorText: z$1.never().optional(),
11731
- callProviderMetadata: providerMetadataSchema3.optional(),
11732
- preliminary: z$1.boolean().optional()
11733
- }),
11734
- z$1.object({
11735
- type: z$1.literal("dynamic-tool"),
11736
- toolName: z$1.string(),
11737
- toolCallId: z$1.string(),
11738
- state: z$1.literal("output-error"),
11739
- input: z$1.unknown(),
11740
- output: z$1.never().optional(),
11741
- errorText: z$1.string(),
11742
- callProviderMetadata: providerMetadataSchema3.optional()
11743
- })
11744
- ];
11745
- var toolUIPartSchemas2 = [
11746
- z$1.object({
11747
- type: z$1.string().startsWith("tool-"),
11748
- toolCallId: z$1.string(),
11749
- state: z$1.literal("input-streaming"),
11750
- input: z$1.unknown().optional(),
11751
- output: z$1.never().optional(),
11752
- errorText: z$1.never().optional()
11753
- }),
11754
- z$1.object({
11755
- type: z$1.string().startsWith("tool-"),
11756
- toolCallId: z$1.string(),
11757
- state: z$1.literal("input-available"),
11758
- input: z$1.unknown(),
11759
- output: z$1.never().optional(),
11760
- errorText: z$1.never().optional(),
11761
- callProviderMetadata: providerMetadataSchema3.optional()
11762
- }),
11763
- z$1.object({
11764
- type: z$1.string().startsWith("tool-"),
11765
- toolCallId: z$1.string(),
11766
- state: z$1.literal("output-available"),
11767
- input: z$1.unknown(),
11768
- output: z$1.unknown(),
11769
- errorText: z$1.never().optional(),
11770
- callProviderMetadata: providerMetadataSchema3.optional(),
11771
- preliminary: z$1.boolean().optional()
11772
- }),
11773
- z$1.object({
11774
- type: z$1.string().startsWith("tool-"),
11775
- toolCallId: z$1.string(),
11776
- state: z$1.literal("output-error"),
11777
- input: z$1.unknown(),
11778
- output: z$1.never().optional(),
11779
- errorText: z$1.string(),
11780
- callProviderMetadata: providerMetadataSchema3.optional()
11781
- })
11782
- ];
11783
- z$1.object({
11784
- id: z$1.string(),
11785
- role: z$1.enum(["system", "user", "assistant"]),
11786
- metadata: z$1.unknown().optional(),
11787
- parts: z$1.array(
11788
- z$1.union([
11789
- textUIPartSchema2,
11790
- reasoningUIPartSchema2,
11791
- sourceUrlUIPartSchema2,
11792
- sourceDocumentUIPartSchema2,
11793
- fileUIPartSchema2,
11794
- stepStartUIPartSchema2,
11795
- dataUIPartSchema2,
11796
- ...dynamicToolUIPartSchemas2,
11797
- ...toolUIPartSchemas2
11798
- ])
11799
- )
11800
- });
11801
9524
 
11802
9525
  // ../agent-builder/dist/index.js
9526
+ var import_ignore = __toESM(require_ignore(), 1);
11803
9527
  var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
11804
9528
  var TemplateUnitSchema = z.object({
11805
9529
  kind: z.enum(UNIT_KINDS),
@@ -12004,7 +9728,7 @@ function isInWorkspaceSubfolder(cwd) {
12004
9728
  if (currentDir === cwd) {
12005
9729
  continue;
12006
9730
  }
12007
- console.log(`Checking for workspace indicators in: ${currentDir}`);
9731
+ console.info(`Checking for workspace indicators in: ${currentDir}`);
12008
9732
  if (existsSync(resolve$1(currentDir, "pnpm-workspace.yaml"))) {
12009
9733
  return true;
12010
9734
  }
@@ -12024,7 +9748,7 @@ function isInWorkspaceSubfolder(cwd) {
12024
9748
  }
12025
9749
  return false;
12026
9750
  } catch (error) {
12027
- console.log(`Error in workspace detection: ${error}`);
9751
+ console.warn(`Error in workspace detection: ${error}`);
12028
9752
  return false;
12029
9753
  }
12030
9754
  }
@@ -12095,12 +9819,12 @@ function spawnWithOutput(command, args, options) {
12095
9819
  }
12096
9820
  async function spawnSWPM(cwd, command, packageNames) {
12097
9821
  try {
12098
- console.log("Running install command with swpm");
9822
+ console.info("Running install command with swpm");
12099
9823
  const swpmPath = createRequire(import.meta.filename).resolve("swpm");
12100
9824
  await spawn(swpmPath, [command, ...packageNames], { cwd });
12101
9825
  return;
12102
9826
  } catch (e2) {
12103
- console.log("Failed to run install command with swpm", e2);
9827
+ console.warn("Failed to run install command with swpm", e2);
12104
9828
  }
12105
9829
  try {
12106
9830
  let packageManager;
@@ -12128,11 +9852,11 @@ async function spawnSWPM(cwd, command, packageNames) {
12128
9852
  }
12129
9853
  }
12130
9854
  args.push(...packageNames);
12131
- console.log(`Falling back to ${packageManager} ${args.join(" ")}`);
9855
+ console.info(`Falling back to ${packageManager} ${args.join(" ")}`);
12132
9856
  await spawn(packageManager, args, { cwd });
12133
9857
  return;
12134
9858
  } catch (e2) {
12135
- console.log(`Failed to run install command with native package manager: ${e2}`);
9859
+ console.warn(`Failed to run install command with native package manager: ${e2}`);
12136
9860
  }
12137
9861
  throw new Error(`Failed to run install command with swpm and native package managers`);
12138
9862
  }
@@ -12146,10 +9870,10 @@ async function logGitState(targetPath, label) {
12146
9870
  const gitStatusResult = await git(targetPath, "status", "--porcelain");
12147
9871
  const gitLogResult = await git(targetPath, "log", "--oneline", "-3");
12148
9872
  const gitCountResult = await git(targetPath, "rev-list", "--count", "HEAD");
12149
- console.log(`\u{1F4CA} Git state ${label}:`);
12150
- console.log("Status:", gitStatusResult.stdout.trim() || "Clean working directory");
12151
- console.log("Recent commits:", gitLogResult.stdout.trim());
12152
- console.log("Total commits:", gitCountResult.stdout.trim());
9873
+ console.info(`\u{1F4CA} Git state ${label}:`);
9874
+ console.info("Status:", gitStatusResult.stdout.trim() || "Clean working directory");
9875
+ console.info("Recent commits:", gitLogResult.stdout.trim());
9876
+ console.info("Total commits:", gitCountResult.stdout.trim());
12153
9877
  } catch (gitError) {
12154
9878
  console.warn(`Could not get git state ${label}:`, gitError);
12155
9879
  }
@@ -12221,18 +9945,18 @@ async function gitCheckoutBranch(branchName, targetPath) {
12221
9945
  try {
12222
9946
  if (!await isInsideGitRepo(targetPath)) return;
12223
9947
  await git(targetPath, "checkout", "-b", branchName);
12224
- console.log(`Created new branch: ${branchName}`);
9948
+ console.info(`Created new branch: ${branchName}`);
12225
9949
  } catch (error) {
12226
9950
  const errorStr = error instanceof Error ? error.message : String(error);
12227
9951
  if (errorStr.includes("already exists")) {
12228
9952
  try {
12229
9953
  await git(targetPath, "checkout", branchName);
12230
- console.log(`Switched to existing branch: ${branchName}`);
9954
+ console.info(`Switched to existing branch: ${branchName}`);
12231
9955
  } catch {
12232
9956
  const timestamp = Date.now().toString().slice(-6);
12233
9957
  const uniqueBranchName = `${branchName}-${timestamp}`;
12234
9958
  await git(targetPath, "checkout", "-b", uniqueBranchName);
12235
- console.log(`Created unique branch: ${uniqueBranchName}`);
9959
+ console.info(`Created unique branch: ${uniqueBranchName}`);
12236
9960
  }
12237
9961
  } else {
12238
9962
  throw error;
@@ -12242,9 +9966,9 @@ async function gitCheckoutBranch(branchName, targetPath) {
12242
9966
  async function backupAndReplaceFile(sourceFile, targetFile) {
12243
9967
  const backupFile = `${targetFile}.backup-${Date.now()}`;
12244
9968
  await copyFile(targetFile, backupFile);
12245
- console.log(`\u{1F4E6} Created backup: ${basename(backupFile)}`);
9969
+ console.info(`\u{1F4E6} Created backup: ${basename(backupFile)}`);
12246
9970
  await copyFile(sourceFile, targetFile);
12247
- console.log(`\u{1F504} Replaced file with template version (backup created)`);
9971
+ console.info(`\u{1F504} Replaced file with template version (backup created)`);
12248
9972
  }
12249
9973
  async function renameAndCopyFile(sourceFile, targetFile) {
12250
9974
  let counter = 1;
@@ -12258,7 +9982,7 @@ async function renameAndCopyFile(sourceFile, targetFile) {
12258
9982
  counter++;
12259
9983
  }
12260
9984
  await copyFile(sourceFile, uniqueTargetFile);
12261
- console.log(`\u{1F4DD} Copied with unique name: ${basename(uniqueTargetFile)}`);
9985
+ console.info(`\u{1F4DD} Copied with unique name: ${basename(uniqueTargetFile)}`);
12262
9986
  return uniqueTargetFile;
12263
9987
  }
12264
9988
  var isValidMastraLanguageModel = (model) => {
@@ -12307,7 +10031,7 @@ var mergeGitignoreFiles = (targetContent, templateContent, templateSlug) => {
12307
10031
  if (!hasConflict) {
12308
10032
  newEntries.push(trimmed);
12309
10033
  } else {
12310
- console.log(`\u26A0 Skipping conflicting .gitignore rule: ${trimmed} (conflicts with existing rule)`);
10034
+ console.info(`\u26A0 Skipping conflicting .gitignore rule: ${trimmed} (conflicts with existing rule)`);
12311
10035
  }
12312
10036
  }
12313
10037
  }
@@ -12342,7 +10066,7 @@ var mergeEnvFiles = (targetContent, templateVariables, templateSlug) => {
12342
10066
  if (!existingVars.has(key)) {
12343
10067
  newVars.push({ key, value });
12344
10068
  } else {
12345
- console.log(`\u26A0 Skipping existing environment variable: ${key} (already exists in .env)`);
10069
+ console.info(`\u26A0 Skipping existing environment variable: ${key} (already exists in .env)`);
12346
10070
  }
12347
10071
  }
12348
10072
  if (newVars.length === 0) {
@@ -12363,7 +10087,7 @@ var detectAISDKVersion = async (projectPath) => {
12363
10087
  try {
12364
10088
  const packageJsonPath = join(projectPath, "package.json");
12365
10089
  if (!existsSync(packageJsonPath)) {
12366
- console.log("No package.json found, defaulting to v2");
10090
+ console.info("No package.json found, defaulting to v2");
12367
10091
  return "v2";
12368
10092
  }
12369
10093
  const packageContent = await readFile(packageJsonPath, "utf-8");
@@ -12381,16 +10105,16 @@ var detectAISDKVersion = async (projectPath) => {
12381
10105
  if (versionMatch) {
12382
10106
  const majorVersion = parseInt(versionMatch[1]);
12383
10107
  if (majorVersion >= 2) {
12384
- console.log(`Detected ${pkg} v${majorVersion} -> using v2 specification`);
10108
+ console.info(`Detected ${pkg} v${majorVersion} -> using v2 specification`);
12385
10109
  return "v2";
12386
10110
  } else {
12387
- console.log(`Detected ${pkg} v${majorVersion} -> using v1 specification`);
10111
+ console.info(`Detected ${pkg} v${majorVersion} -> using v1 specification`);
12388
10112
  return "v1";
12389
10113
  }
12390
10114
  }
12391
10115
  }
12392
10116
  }
12393
- console.log("No AI SDK version detected, defaulting to v2");
10117
+ console.info("No AI SDK version detected, defaulting to v2");
12394
10118
  return "v2";
12395
10119
  } catch (error) {
12396
10120
  console.warn(`Failed to detect AI SDK version: ${error instanceof Error ? error.message : String(error)}`);
@@ -12451,7 +10175,7 @@ var createModelInstance = async (provider, modelId, version = "v2") => {
12451
10175
  return null;
12452
10176
  }
12453
10177
  const modelInstance = await providerFn();
12454
- console.log(`Created ${provider} model instance (${version}): ${modelId}`);
10178
+ console.info(`Created ${provider} model instance (${version}): ${modelId}`);
12455
10179
  return modelInstance;
12456
10180
  } catch (error) {
12457
10181
  console.error(`Failed to create model instance: ${error instanceof Error ? error.message : String(error)}`);
@@ -12465,7 +10189,7 @@ var resolveModel = async ({
12465
10189
  }) => {
12466
10190
  const modelFromContext = runtimeContext.get("model");
12467
10191
  if (modelFromContext) {
12468
- console.log("Using model from runtime context");
10192
+ console.info("Using model from runtime context");
12469
10193
  if (isValidMastraLanguageModel(modelFromContext)) {
12470
10194
  return modelFromContext;
12471
10195
  }
@@ -12475,7 +10199,7 @@ var resolveModel = async ({
12475
10199
  }
12476
10200
  const selectedModel = runtimeContext.get("selectedModel");
12477
10201
  if (selectedModel?.provider && selectedModel?.modelId && projectPath) {
12478
- console.log(`Resolving selected model: ${selectedModel.provider}/${selectedModel.modelId}`);
10202
+ console.info(`Resolving selected model: ${selectedModel.provider}/${selectedModel.modelId}`);
12479
10203
  const version = await detectAISDKVersion(projectPath);
12480
10204
  const modelInstance = await createModelInstance(selectedModel.provider, selectedModel.modelId, version);
12481
10205
  if (modelInstance) {
@@ -12483,7 +10207,7 @@ var resolveModel = async ({
12483
10207
  return modelInstance;
12484
10208
  }
12485
10209
  }
12486
- console.log("Using default model");
10210
+ console.info("Using default model");
12487
10211
  return defaultModel;
12488
10212
  };
12489
10213
  var AgentBuilderDefaults = class _AgentBuilderDefaults {
@@ -13517,7 +11241,7 @@ export const mastra = new Mastra({
13517
11241
  error: stderr
13518
11242
  };
13519
11243
  } catch (error) {
13520
- console.log(error);
11244
+ console.error(error);
13521
11245
  return {
13522
11246
  success: false,
13523
11247
  message: `Failed to create project: ${error instanceof Error ? error.message : String(error)}`
@@ -13532,7 +11256,7 @@ export const mastra = new Mastra({
13532
11256
  projectPath
13533
11257
  }) {
13534
11258
  try {
13535
- console.log("Installing packages:", JSON.stringify(packages, null, 2));
11259
+ console.info("Installing packages:", JSON.stringify(packages, null, 2));
13536
11260
  const packageStrings = packages.map((p) => `${p.name}`);
13537
11261
  await spawnSWPM(projectPath || "", "add", packageStrings);
13538
11262
  return {
@@ -13556,7 +11280,7 @@ export const mastra = new Mastra({
13556
11280
  projectPath
13557
11281
  }) {
13558
11282
  try {
13559
- console.log("Upgrading specific packages:", JSON.stringify(packages, null, 2));
11283
+ console.info("Upgrading specific packages:", JSON.stringify(packages, null, 2));
13560
11284
  let packageNames = [];
13561
11285
  if (packages && packages.length > 0) {
13562
11286
  packageNames = packages.map((p) => `${p.name}`);
@@ -13994,14 +11718,14 @@ export const mastra = new Mastra({
13994
11718
  noEmit: true
13995
11719
  };
13996
11720
  const host = {
13997
- getSourceFile: (name20) => name20 === fileName ? sourceFile : void 0,
11721
+ getSourceFile: (name19) => name19 === fileName ? sourceFile : void 0,
13998
11722
  writeFile: () => {
13999
11723
  },
14000
11724
  getCurrentDirectory: () => "",
14001
11725
  getDirectories: () => [],
14002
- fileExists: (name20) => name20 === fileName,
14003
- readFile: (name20) => name20 === fileName ? fileContent : void 0,
14004
- getCanonicalFileName: (name20) => name20,
11726
+ fileExists: (name19) => name19 === fileName,
11727
+ readFile: (name19) => name19 === fileName ? fileContent : void 0,
11728
+ getCanonicalFileName: (name19) => name19,
14005
11729
  useCaseSensitiveFileNames: () => true,
14006
11730
  getNewLine: () => "\n",
14007
11731
  getDefaultLibFileName: () => "lib.d.ts"
@@ -15147,13 +12871,13 @@ var analyzePackageStep = createStep({
15147
12871
  inputSchema: CloneTemplateResultSchema,
15148
12872
  outputSchema: PackageAnalysisSchema,
15149
12873
  execute: async ({ inputData }) => {
15150
- console.log("Analyzing template package.json...");
12874
+ console.info("Analyzing template package.json...");
15151
12875
  const { templateDir } = inputData;
15152
12876
  const packageJsonPath = join(templateDir, "package.json");
15153
12877
  try {
15154
12878
  const packageJsonContent = await readFile(packageJsonPath, "utf-8");
15155
12879
  const packageJson = JSON.parse(packageJsonContent);
15156
- console.log("Template package.json:", JSON.stringify(packageJson, null, 2));
12880
+ console.info("Template package.json:", JSON.stringify(packageJson, null, 2));
15157
12881
  return {
15158
12882
  dependencies: packageJson.dependencies || {},
15159
12883
  devDependencies: packageJson.devDependencies || {},
@@ -15189,7 +12913,7 @@ var discoverUnitsStep = createStep({
15189
12913
  const { templateDir } = inputData;
15190
12914
  const targetPath = resolveTargetPath(inputData, runtimeContext);
15191
12915
  const tools = await AgentBuilderDefaults.DEFAULT_TOOLS(templateDir);
15192
- console.log("targetPath", targetPath);
12916
+ console.info("targetPath", targetPath);
15193
12917
  const model = await resolveModel({ runtimeContext, projectPath: targetPath, defaultModel: openai("gpt-4.1") });
15194
12918
  try {
15195
12919
  const agent = new Agent({
@@ -15277,7 +13001,7 @@ Return the actual exported names of the units, as well as the file names.`,
15277
13001
  template.other?.forEach((otherId) => {
15278
13002
  units.push({ kind: "other", id: otherId.name, file: otherId.file });
15279
13003
  });
15280
- console.log("Discovered units:", JSON.stringify(units, null, 2));
13004
+ console.info("Discovered units:", JSON.stringify(units, null, 2));
15281
13005
  if (units.length === 0) {
15282
13006
  throw new Error(`No Mastra units (agents, workflows, tools) found in template.
15283
13007
  Possible causes:
@@ -15353,7 +13077,7 @@ var packageMergeStep = createStep({
15353
13077
  inputSchema: PackageMergeInputSchema,
15354
13078
  outputSchema: PackageMergeResultSchema,
15355
13079
  execute: async ({ inputData, runtimeContext }) => {
15356
- console.log("Package merge step starting...");
13080
+ console.info("Package merge step starting...");
15357
13081
  const { slug, packageInfo } = inputData;
15358
13082
  const targetPath = resolveTargetPath(inputData, runtimeContext);
15359
13083
  try {
@@ -15381,25 +13105,25 @@ var packageMergeStep = createStep({
15381
13105
  const tplDevDeps = ensureObj(packageInfo.devDependencies);
15382
13106
  const tplPeerDeps = ensureObj(packageInfo.peerDependencies);
15383
13107
  const tplScripts = ensureObj(packageInfo.scripts);
15384
- const existsAnywhere = (name20) => name20 in targetPkg.dependencies || name20 in targetPkg.devDependencies || name20 in targetPkg.peerDependencies;
15385
- for (const [name20, ver] of Object.entries(tplDeps)) {
15386
- if (!existsAnywhere(name20)) {
15387
- targetPkg.dependencies[name20] = String(ver);
13108
+ const existsAnywhere = (name19) => name19 in targetPkg.dependencies || name19 in targetPkg.devDependencies || name19 in targetPkg.peerDependencies;
13109
+ for (const [name19, ver] of Object.entries(tplDeps)) {
13110
+ if (!existsAnywhere(name19)) {
13111
+ targetPkg.dependencies[name19] = String(ver);
15388
13112
  }
15389
13113
  }
15390
- for (const [name20, ver] of Object.entries(tplDevDeps)) {
15391
- if (!existsAnywhere(name20)) {
15392
- targetPkg.devDependencies[name20] = String(ver);
13114
+ for (const [name19, ver] of Object.entries(tplDevDeps)) {
13115
+ if (!existsAnywhere(name19)) {
13116
+ targetPkg.devDependencies[name19] = String(ver);
15393
13117
  }
15394
13118
  }
15395
- for (const [name20, ver] of Object.entries(tplPeerDeps)) {
15396
- if (!(name20 in targetPkg.peerDependencies)) {
15397
- targetPkg.peerDependencies[name20] = String(ver);
13119
+ for (const [name19, ver] of Object.entries(tplPeerDeps)) {
13120
+ if (!(name19 in targetPkg.peerDependencies)) {
13121
+ targetPkg.peerDependencies[name19] = String(ver);
15398
13122
  }
15399
13123
  }
15400
13124
  const prefix = `template:${slug}:`;
15401
- for (const [name20, cmd] of Object.entries(tplScripts)) {
15402
- const newKey = `${prefix}${name20}`;
13125
+ for (const [name19, cmd] of Object.entries(tplScripts)) {
13126
+ const newKey = `${prefix}${name19}`;
15403
13127
  if (!(newKey in targetPkg.scripts)) {
15404
13128
  targetPkg.scripts[newKey] = String(cmd);
15405
13129
  }
@@ -15430,7 +13154,7 @@ var installStep = createStep({
15430
13154
  inputSchema: InstallInputSchema,
15431
13155
  outputSchema: InstallResultSchema,
15432
13156
  execute: async ({ inputData, runtimeContext }) => {
15433
- console.log("Running install step...");
13157
+ console.info("Running install step...");
15434
13158
  const targetPath = resolveTargetPath(inputData, runtimeContext);
15435
13159
  try {
15436
13160
  await spawnSWPM(targetPath, "install", []);
@@ -15458,7 +13182,7 @@ var programmaticFileCopyStep = createStep({
15458
13182
  inputSchema: FileCopyInputSchema,
15459
13183
  outputSchema: FileCopyResultSchema,
15460
13184
  execute: async ({ inputData, runtimeContext }) => {
15461
- console.log("Programmatic file copy step starting...");
13185
+ console.info("Programmatic file copy step starting...");
15462
13186
  const { orderedUnits, templateDir, commitSha, slug } = inputData;
15463
13187
  const targetPath = resolveTargetPath(inputData, runtimeContext);
15464
13188
  try {
@@ -15484,9 +13208,9 @@ var programmaticFileCopyStep = createStep({
15484
13208
  return "unknown";
15485
13209
  }
15486
13210
  };
15487
- const convertNaming = (name20, convention) => {
15488
- const baseName = basename(name20, extname(name20));
15489
- const ext = extname(name20);
13211
+ const convertNaming = (name19, convention) => {
13212
+ const baseName = basename(name19, extname(name19));
13213
+ const ext = extname(name19);
15490
13214
  switch (convention) {
15491
13215
  case "camelCase":
15492
13216
  return baseName.replace(/[-_]/g, "").replace(/([A-Z])/g, (match, p1, offset) => offset === 0 ? p1.toLowerCase() : p1) + ext;
@@ -15497,11 +13221,11 @@ var programmaticFileCopyStep = createStep({
15497
13221
  case "PascalCase":
15498
13222
  return baseName.replace(/[-_]/g, "").replace(/^[a-z]/, (match) => match.toUpperCase()) + ext;
15499
13223
  default:
15500
- return name20;
13224
+ return name19;
15501
13225
  }
15502
13226
  };
15503
13227
  for (const unit of orderedUnits) {
15504
- console.log(`Processing ${unit.kind} unit "${unit.id}" from file "${unit.file}"`);
13228
+ console.info(`Processing ${unit.kind} unit "${unit.id}" from file "${unit.file}"`);
15505
13229
  let sourceFile;
15506
13230
  let resolvedUnitFile;
15507
13231
  if (unit.file.includes("/")) {
@@ -15532,7 +13256,7 @@ var programmaticFileCopyStep = createStep({
15532
13256
  }
15533
13257
  const targetDir = dirname(resolvedUnitFile);
15534
13258
  const namingConvention = await analyzeNamingConvention(targetDir);
15535
- console.log(`Detected naming convention in ${targetDir}: ${namingConvention}`);
13259
+ console.info(`Detected naming convention in ${targetDir}: ${namingConvention}`);
15536
13260
  const hasExtension = extname(unit.id) !== "";
15537
13261
  const baseId = hasExtension ? basename(unit.id, extname(unit.id)) : unit.id;
15538
13262
  const fileExtension = extname(unit.file);
@@ -15540,7 +13264,7 @@ var programmaticFileCopyStep = createStep({
15540
13264
  const targetFile = resolve$1(targetPath, targetDir, convertedFileName);
15541
13265
  if (existsSync(targetFile)) {
15542
13266
  const strategy = determineConflictStrategy();
15543
- console.log(`File exists: ${convertedFileName}, using strategy: ${strategy}`);
13267
+ console.info(`File exists: ${convertedFileName}, using strategy: ${strategy}`);
15544
13268
  switch (strategy) {
15545
13269
  case "skip":
15546
13270
  conflicts.push({
@@ -15549,7 +13273,7 @@ var programmaticFileCopyStep = createStep({
15549
13273
  sourceFile: unit.file,
15550
13274
  targetFile: `${targetDir}/${convertedFileName}`
15551
13275
  });
15552
- console.log(`\u23ED\uFE0F Skipped ${unit.kind} "${unit.id}": file already exists`);
13276
+ console.info(`\u23ED\uFE0F Skipped ${unit.kind} "${unit.id}": file already exists`);
15553
13277
  continue;
15554
13278
  case "backup-and-replace":
15555
13279
  try {
@@ -15559,7 +13283,7 @@ var programmaticFileCopyStep = createStep({
15559
13283
  destination: targetFile,
15560
13284
  unit: { kind: unit.kind, id: unit.id }
15561
13285
  });
15562
- console.log(
13286
+ console.info(
15563
13287
  `\u{1F504} Replaced ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${convertedFileName} (backup created)`
15564
13288
  );
15565
13289
  continue;
@@ -15580,7 +13304,7 @@ var programmaticFileCopyStep = createStep({
15580
13304
  destination: uniqueTargetFile,
15581
13305
  unit: { kind: unit.kind, id: unit.id }
15582
13306
  });
15583
- console.log(`\u{1F4DD} Renamed ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${basename(uniqueTargetFile)}`);
13307
+ console.info(`\u{1F4DD} Renamed ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${basename(uniqueTargetFile)}`);
15584
13308
  continue;
15585
13309
  } catch (renameError) {
15586
13310
  conflicts.push({
@@ -15609,7 +13333,7 @@ var programmaticFileCopyStep = createStep({
15609
13333
  destination: targetFile,
15610
13334
  unit: { kind: unit.kind, id: unit.id }
15611
13335
  });
15612
- console.log(`\u2713 Copied ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${convertedFileName}`);
13336
+ console.info(`\u2713 Copied ${unit.kind} "${unit.id}": ${unit.file} \u2192 ${convertedFileName}`);
15613
13337
  } catch (copyError) {
15614
13338
  conflicts.push({
15615
13339
  unit: { kind: unit.kind, id: unit.id },
@@ -15630,7 +13354,7 @@ var programmaticFileCopyStep = createStep({
15630
13354
  destination: targetTsconfig,
15631
13355
  unit: { kind: "other", id: "tsconfig.json" }
15632
13356
  });
15633
- console.log("\u2713 Copied tsconfig.json from template to target");
13357
+ console.info("\u2713 Copied tsconfig.json from template to target");
15634
13358
  } else {
15635
13359
  const minimalTsconfig = {
15636
13360
  compilerOptions: {
@@ -15652,7 +13376,7 @@ var programmaticFileCopyStep = createStep({
15652
13376
  destination: targetTsconfig,
15653
13377
  unit: { kind: "other", id: "tsconfig.json" }
15654
13378
  });
15655
- console.log("\u2713 Generated minimal tsconfig.json in target");
13379
+ console.info("\u2713 Generated minimal tsconfig.json in target");
15656
13380
  }
15657
13381
  }
15658
13382
  } catch (e2) {
@@ -15677,7 +13401,7 @@ var programmaticFileCopyStep = createStep({
15677
13401
  destination: targetMastraIndex,
15678
13402
  unit: { kind: "other", id: "mastra-index" }
15679
13403
  });
15680
- console.log("\u2713 Copied Mastra index file from template");
13404
+ console.info("\u2713 Copied Mastra index file from template");
15681
13405
  }
15682
13406
  }
15683
13407
  } catch (e2) {
@@ -15701,7 +13425,7 @@ var programmaticFileCopyStep = createStep({
15701
13425
  destination: targetGitignore,
15702
13426
  unit: { kind: "other", id: "gitignore" }
15703
13427
  });
15704
- console.log("\u2713 Copied .gitignore from template to target");
13428
+ console.info("\u2713 Copied .gitignore from template to target");
15705
13429
  } else {
15706
13430
  const targetContent = await readFile(targetGitignore, "utf-8");
15707
13431
  const templateContent = await readFile(templateGitignore, "utf-8");
@@ -15714,9 +13438,9 @@ var programmaticFileCopyStep = createStep({
15714
13438
  destination: targetGitignore,
15715
13439
  unit: { kind: "other", id: "gitignore-merge" }
15716
13440
  });
15717
- console.log(`\u2713 Merged template .gitignore entries into existing .gitignore (${addedLines} new entries)`);
13441
+ console.info(`\u2713 Merged template .gitignore entries into existing .gitignore (${addedLines} new entries)`);
15718
13442
  } else {
15719
- console.log("\u2139 No new .gitignore entries to add from template");
13443
+ console.info("\u2139 No new .gitignore entries to add from template");
15720
13444
  }
15721
13445
  }
15722
13446
  }
@@ -15744,7 +13468,7 @@ var programmaticFileCopyStep = createStep({
15744
13468
  destination: targetEnv,
15745
13469
  unit: { kind: "other", id: "env" }
15746
13470
  });
15747
- console.log(`\u2713 Created .env file with ${Object.keys(variables).length} template variables`);
13471
+ console.info(`\u2713 Created .env file with ${Object.keys(variables).length} template variables`);
15748
13472
  } else {
15749
13473
  const targetContent = await readFile(targetEnv, "utf-8");
15750
13474
  const mergedContent = mergeEnvFiles(targetContent, variables, slug);
@@ -15756,9 +13480,9 @@ var programmaticFileCopyStep = createStep({
15756
13480
  destination: targetEnv,
15757
13481
  unit: { kind: "other", id: "env-merge" }
15758
13482
  });
15759
- console.log(`\u2713 Merged new environment variables into existing .env file (${addedLines} new entries)`);
13483
+ console.info(`\u2713 Merged new environment variables into existing .env file (${addedLines} new entries)`);
15760
13484
  } else {
15761
- console.log("\u2139 No new environment variables to add (all already exist in .env)");
13485
+ console.info("\u2139 No new environment variables to add (all already exist in .env)");
15762
13486
  }
15763
13487
  }
15764
13488
  }
@@ -15779,13 +13503,13 @@ var programmaticFileCopyStep = createStep({
15779
13503
  fileList,
15780
13504
  { skipIfNoStaged: true }
15781
13505
  );
15782
- console.log(`\u2713 Committed ${copiedFiles.length} copied files`);
13506
+ console.info(`\u2713 Committed ${copiedFiles.length} copied files`);
15783
13507
  } catch (commitError) {
15784
13508
  console.warn("Failed to commit copied files:", commitError);
15785
13509
  }
15786
13510
  }
15787
13511
  const message = `Programmatic file copy completed. Copied ${copiedFiles.length} files, ${conflicts.length} conflicts detected.`;
15788
- console.log(message);
13512
+ console.info(message);
15789
13513
  return {
15790
13514
  success: true,
15791
13515
  copiedFiles,
@@ -15810,7 +13534,7 @@ var intelligentMergeStep = createStep({
15810
13534
  inputSchema: IntelligentMergeInputSchema,
15811
13535
  outputSchema: IntelligentMergeResultSchema,
15812
13536
  execute: async ({ inputData, runtimeContext }) => {
15813
- console.log("Intelligent merge step starting...");
13537
+ console.info("Intelligent merge step starting...");
15814
13538
  const { conflicts, copiedFiles, commitSha, slug, templateDir, branchName } = inputData;
15815
13539
  const targetPath = resolveTargetPath(inputData, runtimeContext);
15816
13540
  try {
@@ -15937,8 +13661,8 @@ Template information:
15937
13661
  const registrableFiles = copiedFiles.filter((f) => registrableKinds.has(f.unit.kind));
15938
13662
  const targetMastraIndex = resolve$1(targetPath, "src/mastra/index.ts");
15939
13663
  const mastraIndexExists = existsSync(targetMastraIndex);
15940
- console.log(`Mastra index exists: ${mastraIndexExists} at ${targetMastraIndex}`);
15941
- console.log(
13664
+ console.info(`Mastra index exists: ${mastraIndexExists} at ${targetMastraIndex}`);
13665
+ console.info(
15942
13666
  "Registrable components:",
15943
13667
  registrableFiles.map((f) => `${f.unit.kind}:${f.unit.id}`)
15944
13668
  );
@@ -15952,7 +13676,7 @@ Template information:
15952
13676
  notes: `Components to register: ${registrableFiles.map((f) => `${f.unit.kind}:${f.unit.id}`).join(", ")}`
15953
13677
  });
15954
13678
  }
15955
- console.log(`Creating task list with ${tasks.length} tasks...`);
13679
+ console.info(`Creating task list with ${tasks.length} tasks...`);
15956
13680
  await AgentBuilderDefaults.manageTaskList({ action: "create", tasks });
15957
13681
  await logGitState(targetPath, "before intelligent merge");
15958
13682
  const prompt = `
@@ -16004,12 +13728,12 @@ Start by listing your tasks and work through them systematically!
16004
13728
  for await (const chunk of result.fullStream) {
16005
13729
  if (chunk.type === "step-finish" || chunk.type === "step-start") {
16006
13730
  const chunkData = "payload" in chunk ? chunk.payload : chunk;
16007
- console.log({
13731
+ console.info({
16008
13732
  type: chunk.type,
16009
13733
  msgId: chunkData.messageId
16010
13734
  });
16011
13735
  } else {
16012
- console.log(JSON.stringify(chunk, null, 2));
13736
+ console.info(JSON.stringify(chunk, null, 2));
16013
13737
  if (chunk.type === "tool-result") {
16014
13738
  const chunkData = "payload" in chunk ? chunk.payload : chunk;
16015
13739
  if (chunkData.toolName === "manageTaskList") {
@@ -16023,7 +13747,7 @@ Start by listing your tasks and work through them systematically!
16023
13747
  content: toolResult.content || "",
16024
13748
  notes: toolResult.notes
16025
13749
  });
16026
- console.log(`\u{1F4CB} Task completed: ${toolResult.taskId} - ${toolResult.content}`);
13750
+ console.info(`\u{1F4CB} Task completed: ${toolResult.taskId} - ${toolResult.content}`);
16027
13751
  }
16028
13752
  } catch (parseError) {
16029
13753
  console.warn("Failed to parse task management result:", parseError);
@@ -16078,12 +13802,12 @@ var validationAndFixStep = createStep({
16078
13802
  inputSchema: ValidationFixInputSchema,
16079
13803
  outputSchema: ValidationFixResultSchema,
16080
13804
  execute: async ({ inputData, runtimeContext }) => {
16081
- console.log("Validation and fix step starting...");
13805
+ console.info("Validation and fix step starting...");
16082
13806
  const { commitSha, slug, orderedUnits, templateDir, copiedFiles, conflictsResolved, maxIterations = 5 } = inputData;
16083
13807
  const targetPath = resolveTargetPath(inputData, runtimeContext);
16084
13808
  const hasChanges = copiedFiles.length > 0 || conflictsResolved && conflictsResolved.length > 0;
16085
13809
  if (!hasChanges) {
16086
- console.log("\u23ED\uFE0F Skipping validation - no files copied or conflicts resolved");
13810
+ console.info("\u23ED\uFE0F Skipping validation - no files copied or conflicts resolved");
16087
13811
  return {
16088
13812
  success: true,
16089
13813
  applied: false,
@@ -16095,7 +13819,7 @@ var validationAndFixStep = createStep({
16095
13819
  }
16096
13820
  };
16097
13821
  }
16098
- console.log(
13822
+ console.info(
16099
13823
  `\u{1F4CB} Changes detected: ${copiedFiles.length} files copied, ${conflictsResolved?.length || 0} conflicts resolved`
16100
13824
  );
16101
13825
  let currentIteration = 1;
@@ -16221,7 +13945,7 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
16221
13945
  executeCommand: allTools.executeCommand
16222
13946
  }
16223
13947
  });
16224
- console.log("Starting validation and fix agent with internal loop...");
13948
+ console.info("Starting validation and fix agent with internal loop...");
16225
13949
  let validationResults = {
16226
13950
  valid: false,
16227
13951
  errorsFixed: 0,
@@ -16232,7 +13956,7 @@ Be thorough and methodical. Always use listDirectory to verify actual file exist
16232
13956
  // Store the actual error details
16233
13957
  };
16234
13958
  while (validationResults.remainingErrors > 0 && currentIteration <= maxIterations) {
16235
- console.log(`
13959
+ console.info(`
16236
13960
  === Validation Iteration ${currentIteration} ===`);
16237
13961
  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.
16238
13962
 
@@ -16252,13 +13976,13 @@ Previous iterations may have fixed some issues, so start by re-running validateC
16252
13976
  for await (const chunk of result.fullStream) {
16253
13977
  if (chunk.type === "step-finish" || chunk.type === "step-start") {
16254
13978
  const chunkData = "payload" in chunk ? chunk.payload : chunk;
16255
- console.log({
13979
+ console.info({
16256
13980
  type: chunk.type,
16257
13981
  msgId: chunkData.messageId,
16258
13982
  iteration: currentIteration
16259
13983
  });
16260
13984
  } else {
16261
- console.log(JSON.stringify(chunk, null, 2));
13985
+ console.info(JSON.stringify(chunk, null, 2));
16262
13986
  }
16263
13987
  if (chunk.type === "tool-result") {
16264
13988
  const chunkData = "payload" in chunk ? chunk.payload : chunk;
@@ -16267,7 +13991,7 @@ Previous iterations may have fixed some issues, so start by re-running validateC
16267
13991
  lastValidationResult = toolResult;
16268
13992
  if (toolResult?.summary) {
16269
13993
  iterationErrors = toolResult.summary.totalErrors || 0;
16270
- console.log(`Iteration ${currentIteration}: Found ${iterationErrors} errors`);
13994
+ console.info(`Iteration ${currentIteration}: Found ${iterationErrors} errors`);
16271
13995
  }
16272
13996
  }
16273
13997
  }
@@ -16279,12 +14003,12 @@ Previous iterations may have fixed some issues, so start by re-running validateC
16279
14003
  if (iterationErrors > 0 && lastValidationResult?.errors) {
16280
14004
  validationResults.lastValidationErrors = lastValidationResult.errors;
16281
14005
  }
16282
- console.log(`Iteration ${currentIteration} complete: ${iterationErrors} errors remaining`);
14006
+ console.info(`Iteration ${currentIteration} complete: ${iterationErrors} errors remaining`);
16283
14007
  if (iterationErrors === 0) {
16284
- console.log(`\u2705 All validation issues resolved in ${currentIteration} iterations!`);
14008
+ console.info(`\u2705 All validation issues resolved in ${currentIteration} iterations!`);
16285
14009
  break;
16286
14010
  } else if (currentIteration >= maxIterations) {
16287
- console.log(`\u26A0\uFE0F Max iterations (${maxIterations}) reached. ${iterationErrors} errors still remaining.`);
14011
+ console.info(`\u26A0\uFE0F Max iterations (${maxIterations}) reached. ${iterationErrors} errors still remaining.`);
16288
14012
  break;
16289
14013
  }
16290
14014
  currentIteration++;
@@ -16329,7 +14053,7 @@ Previous iterations may have fixed some issues, so start by re-running validateC
16329
14053
  } finally {
16330
14054
  try {
16331
14055
  await rm(templateDir, { recursive: true, force: true });
16332
- console.log(`\u2713 Cleaned up template directory: ${templateDir}`);
14056
+ console.info(`\u2713 Cleaned up template directory: ${templateDir}`);
16333
14057
  } catch (cleanupError) {
16334
14058
  console.warn("Failed to cleanup template directory:", cleanupError);
16335
14059
  }
@@ -16805,12 +14529,10 @@ var planningIterationStep = createStep({
16805
14529
  research,
16806
14530
  userAnswers
16807
14531
  } = inputData;
16808
- console.log("Starting planning iteration...");
14532
+ console.info("Starting planning iteration...");
16809
14533
  const qaKey = "workflow-builder-qa";
16810
14534
  let storedQAPairs = runtimeContext.get(qaKey) || [];
16811
14535
  const newAnswers = { ...userAnswers || {}, ...resumeData?.answers || {} };
16812
- console.log("before", storedQAPairs);
16813
- console.log("newAnswers", newAnswers);
16814
14536
  if (Object.keys(newAnswers).length > 0) {
16815
14537
  storedQAPairs = storedQAPairs.map((pair) => {
16816
14538
  if (newAnswers[pair.question.id]) {
@@ -16824,10 +14546,6 @@ var planningIterationStep = createStep({
16824
14546
  });
16825
14547
  runtimeContext.set(qaKey, storedQAPairs);
16826
14548
  }
16827
- console.log("after", storedQAPairs);
16828
- console.log(
16829
- `Current Q&A state: ${storedQAPairs.length} question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
16830
- );
16831
14549
  try {
16832
14550
  const model = await resolveModel({ runtimeContext });
16833
14551
  const planningAgent = new Agent({
@@ -16875,8 +14593,8 @@ var planningIterationStep = createStep({
16875
14593
  };
16876
14594
  }
16877
14595
  if (planResult.questions && planResult.questions.length > 0 && !planResult.planComplete) {
16878
- console.log(`Planning needs user clarification: ${planResult.questions.length} questions`);
16879
- console.log(planResult.questions);
14596
+ console.info(`Planning needs user clarification: ${planResult.questions.length} questions`);
14597
+ console.info(planResult.questions);
16880
14598
  const newQAPairs = planResult.questions.map((question) => ({
16881
14599
  question,
16882
14600
  answer: null,
@@ -16885,7 +14603,7 @@ var planningIterationStep = createStep({
16885
14603
  }));
16886
14604
  storedQAPairs = [...storedQAPairs, ...newQAPairs];
16887
14605
  runtimeContext.set(qaKey, storedQAPairs);
16888
- console.log(
14606
+ console.info(
16889
14607
  `Updated Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
16890
14608
  );
16891
14609
  return suspend({
@@ -16897,9 +14615,9 @@ var planningIterationStep = createStep({
16897
14615
  }
16898
14616
  });
16899
14617
  }
16900
- console.log(`Planning complete with ${planResult.tasks.length} tasks`);
14618
+ console.info(`Planning complete with ${planResult.tasks.length} tasks`);
16901
14619
  runtimeContext.set(qaKey, storedQAPairs);
16902
- console.log(
14620
+ console.info(
16903
14621
  `Final Q&A state: ${storedQAPairs.length} total question-answer pairs, ${storedQAPairs.filter((p) => p.answer).length} answered`
16904
14622
  );
16905
14623
  return {
@@ -16942,7 +14660,7 @@ var taskApprovalStep = createStep({
16942
14660
  execute: async ({ inputData, resumeData, suspend }) => {
16943
14661
  const { tasks } = inputData;
16944
14662
  if (!resumeData?.approved && resumeData?.approved !== false) {
16945
- console.log(`Requesting user approval for ${tasks.length} tasks`);
14663
+ console.info(`Requesting user approval for ${tasks.length} tasks`);
16946
14664
  const summary = `Task List for Approval:
16947
14665
 
16948
14666
  ${tasks.length} tasks planned:
@@ -16955,14 +14673,14 @@ ${tasks.map((task, i) => `${i + 1}. [${task.priority.toUpperCase()}] ${task.cont
16955
14673
  });
16956
14674
  }
16957
14675
  if (resumeData.approved) {
16958
- console.log("Task list approved by user");
14676
+ console.info("Task list approved by user");
16959
14677
  return {
16960
14678
  approved: true,
16961
14679
  tasks,
16962
14680
  message: "Task list approved, ready for execution"
16963
14681
  };
16964
14682
  } else {
16965
- console.log("Task list rejected by user");
14683
+ console.info("Task list rejected by user");
16966
14684
  return {
16967
14685
  approved: false,
16968
14686
  tasks,
@@ -16979,7 +14697,7 @@ var planningAndApprovalWorkflow = createWorkflow({
16979
14697
  outputSchema: TaskApprovalOutputSchema,
16980
14698
  steps: [planningIterationStep, taskApprovalStep]
16981
14699
  }).dountil(planningIterationStep, async ({ inputData }) => {
16982
- console.log(`Sub-workflow planning check: planComplete=${inputData.planComplete}`);
14700
+ console.info(`Sub-workflow planning check: planComplete=${inputData.planComplete}`);
16983
14701
  return inputData.planComplete === true;
16984
14702
  }).map(async ({ inputData }) => {
16985
14703
  return {
@@ -17430,12 +15148,12 @@ var workflowDiscoveryStep = createStep({
17430
15148
  inputSchema: WorkflowBuilderInputSchema,
17431
15149
  outputSchema: WorkflowDiscoveryResultSchema,
17432
15150
  execute: async ({ inputData, runtimeContext: _runtimeContext }) => {
17433
- console.log("Starting workflow discovery...");
15151
+ console.info("Starting workflow discovery...");
17434
15152
  const { projectPath = process.cwd() } = inputData;
17435
15153
  try {
17436
15154
  const workflowsPath = join(projectPath, "src/mastra/workflows");
17437
15155
  if (!existsSync(workflowsPath)) {
17438
- console.log("No workflows directory found");
15156
+ console.info("No workflows directory found");
17439
15157
  return {
17440
15158
  success: true,
17441
15159
  workflows: [],
@@ -17464,7 +15182,7 @@ var workflowDiscoveryStep = createStep({
17464
15182
  }
17465
15183
  }
17466
15184
  }
17467
- console.log(`Discovered ${workflows.length} existing workflows`);
15185
+ console.info(`Discovered ${workflows.length} existing workflows`);
17468
15186
  return {
17469
15187
  success: true,
17470
15188
  workflows,
@@ -17489,7 +15207,7 @@ var projectDiscoveryStep = createStep({
17489
15207
  inputSchema: WorkflowDiscoveryResultSchema,
17490
15208
  outputSchema: ProjectDiscoveryResultSchema,
17491
15209
  execute: async ({ inputData: _inputData, runtimeContext: _runtimeContext }) => {
17492
- console.log("Starting project discovery...");
15210
+ console.info("Starting project discovery...");
17493
15211
  try {
17494
15212
  const projectPath = process.cwd();
17495
15213
  const projectStructure = {
@@ -17510,7 +15228,7 @@ var projectDiscoveryStep = createStep({
17510
15228
  console.warn("Failed to read package.json:", error);
17511
15229
  }
17512
15230
  }
17513
- console.log("Project discovery completed");
15231
+ console.info("Project discovery completed");
17514
15232
  return {
17515
15233
  success: true,
17516
15234
  structure: {
@@ -17551,7 +15269,7 @@ var workflowResearchStep = createStep({
17551
15269
  inputSchema: ProjectDiscoveryResultSchema,
17552
15270
  outputSchema: WorkflowResearchResultSchema,
17553
15271
  execute: async ({ inputData, runtimeContext }) => {
17554
- console.log("Starting workflow research...");
15272
+ console.info("Starting workflow research...");
17555
15273
  try {
17556
15274
  const model = await resolveModel({ runtimeContext });
17557
15275
  const researchAgent = new Agent({
@@ -17583,7 +15301,7 @@ var workflowResearchStep = createStep({
17583
15301
  error: "Research agent failed to generate valid response"
17584
15302
  };
17585
15303
  }
17586
- console.log("Research completed successfully");
15304
+ console.info("Research completed successfully");
17587
15305
  return {
17588
15306
  success: true,
17589
15307
  documentation: {
@@ -17627,12 +15345,12 @@ var taskExecutionStep = createStep({
17627
15345
  research,
17628
15346
  projectPath
17629
15347
  } = inputData;
17630
- console.log(`Starting task execution for ${action}ing workflow: ${workflowName}`);
17631
- console.log(`Executing ${tasks.length} tasks using AgentBuilder stream...`);
15348
+ console.info(`Starting task execution for ${action}ing workflow: ${workflowName}`);
15349
+ console.info(`Executing ${tasks.length} tasks using AgentBuilder stream...`);
17632
15350
  try {
17633
15351
  const model = await resolveModel({ runtimeContext });
17634
15352
  const currentProjectPath = projectPath || process.cwd();
17635
- console.log("Pre-populating taskManager with planned tasks...");
15353
+ console.info("Pre-populating taskManager with planned tasks...");
17636
15354
  const taskManagerContext = {
17637
15355
  action: "create",
17638
15356
  tasks: tasks.map((task) => ({
@@ -17645,7 +15363,7 @@ var taskExecutionStep = createStep({
17645
15363
  }))
17646
15364
  };
17647
15365
  const taskManagerResult = await AgentBuilderDefaults.manageTaskList(taskManagerContext);
17648
- console.log(`Task manager initialized with ${taskManagerResult.tasks.length} tasks`);
15366
+ console.info(`Task manager initialized with ${taskManagerResult.tasks.length} tasks`);
17649
15367
  if (!taskManagerResult.success) {
17650
15368
  throw new Error(`Failed to initialize task manager: ${taskManagerResult.message}`);
17651
15369
  }
@@ -17698,13 +15416,13 @@ ${additionalInstructions}`;
17698
15416
  const currentTaskStatus = await AgentBuilderDefaults.manageTaskList({ action: "list" });
17699
15417
  const completedTasks = currentTaskStatus.tasks.filter((task) => task.status === "completed");
17700
15418
  const pendingTasks = currentTaskStatus.tasks.filter((task) => task.status !== "completed");
17701
- console.log(`
15419
+ console.info(`
17702
15420
  === EXECUTION ITERATION ${iterationCount} ===`);
17703
- console.log(`Completed tasks: ${completedTasks.length}/${expectedTaskIds.length}`);
17704
- console.log(`Remaining tasks: ${pendingTasks.map((t2) => t2.id).join(", ")}`);
15421
+ console.info(`Completed tasks: ${completedTasks.length}/${expectedTaskIds.length}`);
15422
+ console.info(`Remaining tasks: ${pendingTasks.map((t2) => t2.id).join(", ")}`);
17705
15423
  allTasksCompleted = pendingTasks.length === 0;
17706
15424
  if (allTasksCompleted) {
17707
- console.log("All tasks completed! Breaking execution loop.");
15425
+ console.info("All tasks completed! Breaking execution loop.");
17708
15426
  break;
17709
15427
  }
17710
15428
  const iterationPrompt = iterationCount === 1 ? executionPrompt : `${workflowBuilderPrompts.executionAgent.iterationPrompt({
@@ -17728,19 +15446,19 @@ ${workflowBuilderPrompts.validation.instructions}`;
17728
15446
  finalMessage += chunk.payload.text;
17729
15447
  }
17730
15448
  if (chunk.type === "step-finish") {
17731
- console.log(finalMessage);
15449
+ console.info(finalMessage);
17732
15450
  finalMessage = "";
17733
15451
  }
17734
15452
  if (chunk.type === "tool-result") {
17735
- console.log(JSON.stringify(chunk, null, 2));
15453
+ console.info(JSON.stringify(chunk, null, 2));
17736
15454
  }
17737
15455
  if (chunk.type === "finish") {
17738
- console.log(chunk);
15456
+ console.info(chunk);
17739
15457
  }
17740
15458
  }
17741
15459
  await stream.consumeStream();
17742
15460
  finalResult = await stream.object;
17743
- console.log(`Iteration ${iterationCount} result:`, { finalResult });
15461
+ console.info(`Iteration ${iterationCount} result:`, { finalResult });
17744
15462
  if (!finalResult) {
17745
15463
  throw new Error(`No result received from agent execution on iteration ${iterationCount}`);
17746
15464
  }
@@ -17748,17 +15466,17 @@ ${workflowBuilderPrompts.validation.instructions}`;
17748
15466
  const postCompletedTasks = postIterationTaskStatus.tasks.filter((task) => task.status === "completed");
17749
15467
  const postPendingTasks = postIterationTaskStatus.tasks.filter((task) => task.status !== "completed");
17750
15468
  allTasksCompleted = postPendingTasks.length === 0;
17751
- console.log(
15469
+ console.info(
17752
15470
  `After iteration ${iterationCount}: ${postCompletedTasks.length}/${expectedTaskIds.length} tasks completed in taskManager`
17753
15471
  );
17754
15472
  if (finalResult.status === "needs_clarification" && finalResult.questions && finalResult.questions.length > 0) {
17755
- console.log(
15473
+ console.info(
17756
15474
  `Agent needs clarification on iteration ${iterationCount}: ${finalResult.questions.length} questions`
17757
15475
  );
17758
15476
  break;
17759
15477
  }
17760
15478
  if (finalResult.status === "completed" && !allTasksCompleted) {
17761
- console.log(
15479
+ console.info(
17762
15480
  `Agent claimed completion but taskManager shows pending tasks: ${postPendingTasks.map((t2) => t2.id).join(", ")}`
17763
15481
  );
17764
15482
  }
@@ -17771,8 +15489,8 @@ ${workflowBuilderPrompts.validation.instructions}`;
17771
15489
  throw new Error("No result received from agent execution");
17772
15490
  }
17773
15491
  if (finalResult.status === "needs_clarification" && finalResult.questions && finalResult.questions.length > 0) {
17774
- console.log(`Agent needs clarification: ${finalResult.questions.length} questions`);
17775
- console.log("finalResult", JSON.stringify(finalResult, null, 2));
15492
+ console.info(`Agent needs clarification: ${finalResult.questions.length} questions`);
15493
+ console.info("finalResult", JSON.stringify(finalResult, null, 2));
17776
15494
  return suspend({
17777
15495
  questions: finalResult.questions,
17778
15496
  currentProgress: finalResult.progress,
@@ -17788,7 +15506,7 @@ ${workflowBuilderPrompts.validation.instructions}`;
17788
15506
  const finalAllTasksCompleted = finalPendingTasks.length === 0;
17789
15507
  const success = finalAllTasksCompleted && !finalResult.error;
17790
15508
  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`;
17791
- console.log(message);
15509
+ console.info(message);
17792
15510
  const missingTasks = finalPendingTasks.map((task) => task.id);
17793
15511
  const validationErrors = [];
17794
15512
  if (finalResult.error) {
@@ -17856,7 +15574,7 @@ var workflowBuilderWorkflow = createWorkflow({
17856
15574
  userAnswers: void 0
17857
15575
  };
17858
15576
  }).dountil(planningAndApprovalWorkflow, async ({ inputData }) => {
17859
- console.log(`Sub-workflow check: approved=${inputData.approved}`);
15577
+ console.info(`Sub-workflow check: approved=${inputData.approved}`);
17860
15578
  return inputData.approved === true;
17861
15579
  }).map(async ({ getStepResult, getInitData }) => {
17862
15580
  const initData = getInitData();
@@ -17989,5 +15707,5 @@ var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
17989
15707
  );
17990
15708
 
17991
15709
  export { agent_builder_exports, cancelAgentBuilderActionRunHandler, createAgentBuilderActionRunHandler, getAgentBuilderActionByIdHandler, getAgentBuilderActionRunByIdHandler, getAgentBuilderActionRunExecutionResultHandler, getAgentBuilderActionRunsHandler, getAgentBuilderActionsHandler, resumeAgentBuilderActionHandler, resumeAsyncAgentBuilderActionHandler, sendAgentBuilderActionRunEventHandler, startAgentBuilderActionRunHandler, startAsyncAgentBuilderActionHandler, streamAgentBuilderActionHandler, streamVNextAgentBuilderActionHandler, watchAgentBuilderActionHandler };
17992
- //# sourceMappingURL=chunk-7XNKAVVA.js.map
17993
- //# sourceMappingURL=chunk-7XNKAVVA.js.map
15710
+ //# sourceMappingURL=chunk-6PP4JPW2.js.map
15711
+ //# sourceMappingURL=chunk-6PP4JPW2.js.map