@ifrankwang/openspec-agents 0.133.2 → 0.135.0

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.
@@ -6919,7 +6919,7 @@ var require_dist = __commonJS(function(exports, module) {
6919
6919
  });
6920
6920
 
6921
6921
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
6922
- import process3 from "node:process";
6922
+ import process2 from "node:process";
6923
6923
 
6924
6924
  // node_modules/zod/v4/core/util.js
6925
6925
  function getEnumValues(entries) {
@@ -6935,18 +6935,23 @@ function jsonStringifyReplacer(_, value) {
6935
6935
  return value.toString();
6936
6936
  return value;
6937
6937
  }
6938
- function cached(getter) {
6939
- const set = false;
6940
- return {
6941
- get value() {
6942
- if (!set) {
6943
- const value = getter();
6944
- Object.defineProperty(this, "value", { value });
6945
- return value;
6946
- }
6947
- throw new Error("cached value already set");
6938
+
6939
+ class Cached {
6940
+ constructor(getter) {
6941
+ this._getter = getter;
6942
+ this._value = undefined;
6943
+ }
6944
+ get value() {
6945
+ const getter = this._getter;
6946
+ if (getter !== undefined) {
6947
+ this._value = getter();
6948
+ this._getter = undefined;
6948
6949
  }
6949
- };
6950
+ return this._value;
6951
+ }
6952
+ }
6953
+ function cached(getter) {
6954
+ return new Cached(getter);
6950
6955
  }
6951
6956
  function nullish(input) {
6952
6957
  return input === null || input === undefined;
@@ -6972,6 +6977,56 @@ function assignProp(target, prop, value) {
6972
6977
  configurable: true
6973
6978
  });
6974
6979
  }
6980
+ function rawShape(def) {
6981
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
6982
+ return desc?.get ? desc.get.raw : desc?.value;
6983
+ }
6984
+ function sourceShape(schema) {
6985
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
6986
+ }
6987
+ function deferProp(target, key, getter) {
6988
+ Object.defineProperty(target, key, {
6989
+ get() {
6990
+ const value = getter();
6991
+ assignProp(this, key, value);
6992
+ return value;
6993
+ },
6994
+ enumerable: true,
6995
+ configurable: true
6996
+ });
6997
+ }
6998
+ function putProp(target, key, value) {
6999
+ if (key in target)
7000
+ assignProp(target, key, value);
7001
+ else
7002
+ target[key] = value;
7003
+ }
7004
+ function mirrorShape(target, source, keys, wrap) {
7005
+ const raw = sourceShape(source);
7006
+ for (const key of keys) {
7007
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
7008
+ if (!desc.enumerable)
7009
+ continue;
7010
+ if (desc.get) {
7011
+ deferProp(target, key, () => {
7012
+ const value = source._zod.def.shape[key];
7013
+ return wrap ? wrap(value, key) : value;
7014
+ });
7015
+ } else
7016
+ putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
7017
+ }
7018
+ }
7019
+ function mirrorProps(target, source) {
7020
+ for (const key of Reflect.ownKeys(source)) {
7021
+ const desc = Object.getOwnPropertyDescriptor(source, key);
7022
+ if (!desc.enumerable)
7023
+ continue;
7024
+ if (desc.get)
7025
+ deferProp(target, key, () => source[key]);
7026
+ else
7027
+ putProp(target, key, desc.value);
7028
+ }
7029
+ }
6975
7030
  function mergeDefs(...defs) {
6976
7031
  const mergedDescriptors = {};
6977
7032
  for (const def of defs) {
@@ -7077,6 +7132,10 @@ var NUMBER_FORMAT_RANGES = /* @__PURE__ */ (() => ({
7077
7132
  float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
7078
7133
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
7079
7134
  }))();
7135
+ var BIGINT_FORMAT_RANGES = {
7136
+ int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
7137
+ uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
7138
+ };
7080
7139
  function pick(schema, mask) {
7081
7140
  const currDef = schema._zod.def;
7082
7141
  const checks = currDef.checks;
@@ -7084,23 +7143,21 @@ function pick(schema, mask) {
7084
7143
  if (hasChecks) {
7085
7144
  throw new Error(".pick() cannot be used on object schemas containing refinements");
7086
7145
  }
7087
- const def = mergeDefs(schema._zod.def, {
7088
- get shape() {
7089
- const newShape = {};
7090
- for (const key of Reflect.ownKeys(mask)) {
7091
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
7092
- throw new Error(`Unrecognized key: "${String(key)}"`);
7093
- }
7094
- if (!mask[key])
7095
- continue;
7096
- assignProp(newShape, key, currDef.shape[key]);
7097
- }
7098
- assignProp(this, "shape", newShape);
7099
- return newShape;
7100
- },
7101
- checks: []
7102
- });
7103
- return clone(schema, def);
7146
+ const newShape = {};
7147
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
7148
+ return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
7149
+ }
7150
+ function maskedKeys(schema, mask) {
7151
+ const raw = sourceShape(schema);
7152
+ const keys = [];
7153
+ for (const key of Reflect.ownKeys(mask)) {
7154
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
7155
+ throw new Error(`Unrecognized key: "${String(key)}"`);
7156
+ }
7157
+ if (mask[key])
7158
+ keys.push(key);
7159
+ }
7160
+ return keys;
7104
7161
  }
7105
7162
  function omit(schema, mask) {
7106
7163
  const currDef = schema._zod.def;
@@ -7109,23 +7166,10 @@ function omit(schema, mask) {
7109
7166
  if (hasChecks) {
7110
7167
  throw new Error(".omit() cannot be used on object schemas containing refinements");
7111
7168
  }
7112
- const def = mergeDefs(schema._zod.def, {
7113
- get shape() {
7114
- const newShape = { ...schema._zod.def.shape };
7115
- for (const key of Reflect.ownKeys(mask)) {
7116
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
7117
- throw new Error(`Unrecognized key: "${String(key)}"`);
7118
- }
7119
- if (!mask[key])
7120
- continue;
7121
- delete newShape[key];
7122
- }
7123
- assignProp(this, "shape", newShape);
7124
- return newShape;
7125
- },
7126
- checks: []
7127
- });
7128
- return clone(schema, def);
7169
+ const omitted = new Set(maskedKeys(schema, mask));
7170
+ const newShape = {};
7171
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
7172
+ return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
7129
7173
  }
7130
7174
  function extend(schema, shape) {
7131
7175
  if (!isPlainObject(shape)) {
@@ -7134,34 +7178,26 @@ function extend(schema, shape) {
7134
7178
  const checks = schema._zod.def.checks;
7135
7179
  const hasChecks = checks && checks.length > 0;
7136
7180
  if (hasChecks) {
7137
- const existingShape = schema._zod.def.shape;
7181
+ const existingShape = sourceShape(schema);
7138
7182
  for (const key of Reflect.ownKeys(shape)) {
7139
7183
  if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
7140
7184
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
7141
7185
  }
7142
7186
  }
7143
7187
  }
7144
- const def = mergeDefs(schema._zod.def, {
7145
- get shape() {
7146
- const _shape = { ...schema._zod.def.shape, ...shape };
7147
- assignProp(this, "shape", _shape);
7148
- return _shape;
7149
- }
7150
- });
7151
- return clone(schema, def);
7188
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
7189
+ }
7190
+ function extended(schema, shape) {
7191
+ const newShape = {};
7192
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
7193
+ mirrorProps(newShape, shape);
7194
+ return newShape;
7152
7195
  }
7153
7196
  function safeExtend(schema, shape) {
7154
7197
  if (!isPlainObject(shape)) {
7155
7198
  throw new Error("Invalid input to safeExtend: expected a plain object");
7156
7199
  }
7157
- const def = mergeDefs(schema._zod.def, {
7158
- get shape() {
7159
- const _shape = { ...schema._zod.def.shape, ...shape };
7160
- assignProp(this, "shape", _shape);
7161
- return _shape;
7162
- }
7163
- });
7164
- return clone(schema, def);
7200
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
7165
7201
  }
7166
7202
  function merge(a, b) {
7167
7203
  if (!b?._zod?.def) {
@@ -7170,12 +7206,11 @@ function merge(a, b) {
7170
7206
  if (a._zod.def.checks?.length) {
7171
7207
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
7172
7208
  }
7209
+ const newShape = {};
7210
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
7211
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
7173
7212
  const def = mergeDefs(a._zod.def, {
7174
- get shape() {
7175
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
7176
- assignProp(this, "shape", _shape);
7177
- return _shape;
7178
- },
7213
+ shape: newShape,
7179
7214
  get catchall() {
7180
7215
  return b._zod.def.catchall;
7181
7216
  },
@@ -7190,67 +7225,16 @@ function partial(Class, schema, mask, name = "partial") {
7190
7225
  if (hasChecks) {
7191
7226
  throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
7192
7227
  }
7193
- const def = mergeDefs(schema._zod.def, {
7194
- get shape() {
7195
- const oldShape = schema._zod.def.shape;
7196
- const shape = { ...oldShape };
7197
- if (mask) {
7198
- for (const key of Reflect.ownKeys(mask)) {
7199
- if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
7200
- throw new Error(`Unrecognized key: "${String(key)}"`);
7201
- }
7202
- if (!mask[key])
7203
- continue;
7204
- shape[key] = Class ? new Class({
7205
- type: "optional",
7206
- innerType: oldShape[key]
7207
- }) : oldShape[key];
7208
- }
7209
- } else {
7210
- for (const key of Reflect.ownKeys(oldShape)) {
7211
- shape[key] = Class ? new Class({
7212
- type: "optional",
7213
- innerType: oldShape[key]
7214
- }) : oldShape[key];
7215
- }
7216
- }
7217
- assignProp(this, "shape", shape);
7218
- return shape;
7219
- },
7220
- checks: []
7221
- });
7222
- return clone(schema, def);
7228
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
7229
+ const newShape = {};
7230
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value })));
7231
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
7223
7232
  }
7224
7233
  function required(Class, schema, mask) {
7225
- const def = mergeDefs(schema._zod.def, {
7226
- get shape() {
7227
- const oldShape = schema._zod.def.shape;
7228
- const shape = { ...oldShape };
7229
- if (mask) {
7230
- for (const key of Reflect.ownKeys(mask)) {
7231
- if (!Object.prototype.hasOwnProperty.call(shape, key)) {
7232
- throw new Error(`Unrecognized key: "${String(key)}"`);
7233
- }
7234
- if (!mask[key])
7235
- continue;
7236
- shape[key] = new Class({
7237
- type: "nonoptional",
7238
- innerType: oldShape[key]
7239
- });
7240
- }
7241
- } else {
7242
- for (const key of Reflect.ownKeys(oldShape)) {
7243
- shape[key] = new Class({
7244
- type: "nonoptional",
7245
- innerType: oldShape[key]
7246
- });
7247
- }
7248
- }
7249
- assignProp(this, "shape", shape);
7250
- return shape;
7251
- }
7252
- });
7253
- return clone(schema, def);
7234
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
7235
+ const newShape = {};
7236
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
7237
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
7254
7238
  }
7255
7239
  function aborted(x, startIndex = 0) {
7256
7240
  if (x.aborted === true)
@@ -7300,13 +7284,18 @@ function finalizeIssue(iss, ctx, config) {
7300
7284
  }
7301
7285
  const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : undefined;
7302
7286
  const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
7303
- const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
7304
- rest.path ?? (rest.path = []);
7305
- rest.message = message;
7287
+ const full = {};
7288
+ for (const k of Object.keys(iss)) {
7289
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
7290
+ continue;
7291
+ full[k] = iss[k];
7292
+ }
7293
+ full.path ?? (full.path = []);
7294
+ full.message = message;
7306
7295
  if (ctx?.reportInput) {
7307
- rest.input = _input;
7296
+ full.input = iss.input;
7308
7297
  }
7309
- return rest;
7298
+ return full;
7310
7299
  }
7311
7300
  var highSurrogate = /[\uD800-\uDBFF]/;
7312
7301
  function codePointLength(str) {
@@ -7378,6 +7367,22 @@ function own(inst, key, value, enumerable = true) {
7378
7367
  function hide(inst, key, value) {
7379
7368
  return own(inst, key, value, false);
7380
7369
  }
7370
+ function derived(computes, table) {
7371
+ for (const key in computes) {
7372
+ const compute = computes[key];
7373
+ Object.defineProperty(table, key, {
7374
+ configurable: true,
7375
+ enumerable: true,
7376
+ get() {
7377
+ return own(this, key, compute(this));
7378
+ },
7379
+ set(value) {
7380
+ own(this, key, value);
7381
+ }
7382
+ });
7383
+ }
7384
+ return table;
7385
+ }
7381
7386
  function defineBound(proto, key, fn) {
7382
7387
  Object.defineProperty(proto, key, {
7383
7388
  configurable: true,
@@ -7501,8 +7506,7 @@ function $constructor(name, initializer, proto, params) {
7501
7506
  } finally {
7502
7507
  _zodDesc.value = undefined;
7503
7508
  }
7504
- }
7505
- if (inst._zod.traits.has(name)) {
7509
+ } else if (inst._zod.traits.has(name)) {
7506
7510
  return;
7507
7511
  }
7508
7512
  inst._zod.traits.add(name);
@@ -7593,16 +7597,12 @@ var _messageDesc = {
7593
7597
  enumerable: true,
7594
7598
  configurable: true
7595
7599
  };
7596
- var _zodDesc2 = { value: undefined, enumerable: false };
7597
7600
  var _issuesDesc = { value: undefined, enumerable: false };
7598
7601
  var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
7599
7602
  var initializer = (inst, def) => {
7600
7603
  inst.name = "$ZodError";
7601
- _zodDesc2.value = inst._zod;
7602
- Object.defineProperty(inst, "_zod", _zodDesc2);
7603
7604
  _issuesDesc.value = def;
7604
7605
  Object.defineProperty(inst, "issues", _issuesDesc);
7605
- _zodDesc2.value = undefined;
7606
7606
  _issuesDesc.value = undefined;
7607
7607
  Object.defineProperty(inst, "message", _messageDesc);
7608
7608
  const proto = Object.getPrototypeOf(inst);
@@ -7740,23 +7740,70 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
7740
7740
  if (result instanceof Promise) {
7741
7741
  throw new $ZodAsyncError;
7742
7742
  }
7743
- return result.issues.length ? {
7744
- success: false,
7745
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
7746
- } : { success: true, data: result.value };
7743
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
7747
7744
  };
7748
7745
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
7746
+ function failure(Err, issues, ctx) {
7747
+ let error;
7748
+ return {
7749
+ success: false,
7750
+ get error() {
7751
+ if (!error) {
7752
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
7753
+ issues = undefined;
7754
+ ctx = undefined;
7755
+ }
7756
+ return error;
7757
+ },
7758
+ set error(e) {
7759
+ error = e;
7760
+ issues = undefined;
7761
+ ctx = undefined;
7762
+ }
7763
+ };
7764
+ }
7749
7765
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
7750
7766
  const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
7751
7767
  let result = schema._zod.run({ value, issues: [] }, ctx);
7752
7768
  if (result instanceof Promise)
7753
7769
  result = await result;
7754
- return result.issues.length ? {
7755
- success: false,
7756
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
7757
- } : { success: true, data: result.value };
7770
+ return result.issues.length ? failure(_Err, result.issues, ctx) : { success: true, data: result.value };
7758
7771
  };
7759
7772
  var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
7773
+ var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
7774
+ var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
7775
+ var validate = (schema, value, _ctx) => {
7776
+ const validator = schema._zod.bag.validator;
7777
+ if (validator !== undefined) {
7778
+ if (validator(value) !== COMPILE_INVALID)
7779
+ return true;
7780
+ if (validator.definite === true && _ctx === undefined)
7781
+ return false;
7782
+ }
7783
+ return validateFallback(schema, value, _ctx);
7784
+ };
7785
+ function validateFallback(schema, value, _ctx) {
7786
+ const ctx = _ctx ? { ..._ctx, async: false, abortEarly: true } : { async: false, abortEarly: true };
7787
+ const fallbackRun = schema._zod.bag.fallbackRun;
7788
+ let result;
7789
+ if (fallbackRun) {
7790
+ ctx[COMPILE_FALLBACK] = true;
7791
+ result = fallbackRun({ value, issues: [] }, ctx);
7792
+ } else {
7793
+ result = schema._zod.run({ value, issues: [] }, ctx);
7794
+ }
7795
+ if (result instanceof Promise) {
7796
+ throw new $ZodAsyncError;
7797
+ }
7798
+ return result.issues.length === 0;
7799
+ }
7800
+ var validateAsync = async (schema, value, _ctx) => {
7801
+ const ctx = _ctx ? { ..._ctx, async: true, abortEarly: true } : { async: true, abortEarly: true };
7802
+ let result = schema._zod.run({ value, issues: [] }, ctx);
7803
+ if (result instanceof Promise)
7804
+ result = await result;
7805
+ return result.issues.length === 0;
7806
+ };
7760
7807
  var _encode = (_Err) => {
7761
7808
  const parse = _parse(_Err);
7762
7809
  const fn = (schema, value, _ctx, _params) => {
@@ -7818,8 +7865,8 @@ var uuid = (version) => {
7818
7865
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
7819
7866
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
7820
7867
  };
7821
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
7822
- var _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
7868
+ var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
7869
+ var _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
7823
7870
  function emoji() {
7824
7871
  return new RegExp(_emoji, "u");
7825
7872
  }
@@ -7828,7 +7875,7 @@ var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|(
7828
7875
  var cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
7829
7876
  var cidrv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
7830
7877
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
7831
- var base64url = /^[A-Za-z0-9_-]*$/;
7878
+ var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
7832
7879
  var httpProtocol = /^https?$/;
7833
7880
  var e164 = /^\+[1-9]\d{6,14}$/;
7834
7881
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
@@ -7852,10 +7899,7 @@ function datetime(args) {
7852
7899
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
7853
7900
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
7854
7901
  }
7855
- var string = (params) => {
7856
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
7857
- return new RegExp(`^${regex}$`);
7858
- };
7902
+ var anyString = /^[\s\S]{0,}$/;
7859
7903
  var integer = /^-?\d+$/;
7860
7904
  var number = /^-?\d+(?:\.\d+)?$/;
7861
7905
  var boolean = /^(?:true|false)$/i;
@@ -7882,16 +7926,6 @@ var numericOriginMap = {
7882
7926
  var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
7883
7927
  $ZodCheck.init(inst, def);
7884
7928
  const origin = numericOriginMap[typeof def.value];
7885
- inst._zod.onattach.push((inst) => {
7886
- const bag = inst._zod.bag;
7887
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
7888
- if (def.value < curr) {
7889
- if (def.inclusive)
7890
- bag.maximum = def.value;
7891
- else
7892
- bag.exclusiveMaximum = def.value;
7893
- }
7894
- });
7895
7929
  inst._zod.check = (payload) => {
7896
7930
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
7897
7931
  return;
@@ -7910,16 +7944,6 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
7910
7944
  var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
7911
7945
  $ZodCheck.init(inst, def);
7912
7946
  const origin = numericOriginMap[typeof def.value];
7913
- inst._zod.onattach.push((inst) => {
7914
- const bag = inst._zod.bag;
7915
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
7916
- if (def.value > curr) {
7917
- if (def.inclusive)
7918
- bag.minimum = def.value;
7919
- else
7920
- bag.exclusiveMinimum = def.value;
7921
- }
7922
- });
7923
7947
  inst._zod.check = (payload) => {
7924
7948
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
7925
7949
  return;
@@ -7937,10 +7961,6 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
7937
7961
  });
7938
7962
  var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
7939
7963
  $ZodCheck.init(inst, def);
7940
- inst._zod.onattach.push((inst) => {
7941
- var _a;
7942
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
7943
- });
7944
7964
  inst._zod.check = (payload) => {
7945
7965
  if (typeof payload.value !== typeof def.value)
7946
7966
  throw new Error("Cannot mix number and bigint in multiple_of check.");
@@ -7963,14 +7983,6 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
7963
7983
  const isInt = def.format?.includes("int");
7964
7984
  const origin = isInt ? "int" : "number";
7965
7985
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
7966
- inst._zod.onattach.push((inst) => {
7967
- const bag = inst._zod.bag;
7968
- bag.format = def.format;
7969
- bag.minimum = minimum;
7970
- bag.maximum = maximum;
7971
- if (isInt)
7972
- bag.pattern = integer;
7973
- });
7974
7986
  inst._zod.check = (payload) => {
7975
7987
  const input = payload.value;
7976
7988
  if (isInt) {
@@ -8040,11 +8052,6 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
8040
8052
  var _a;
8041
8053
  $ZodCheck.init(inst, def);
8042
8054
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
8043
- inst._zod.onattach.push((inst) => {
8044
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
8045
- if (def.maximum < curr)
8046
- inst._zod.bag.maximum = def.maximum;
8047
- });
8048
8055
  inst._zod.check = (payload) => {
8049
8056
  const input = payload.value;
8050
8057
  const units = input.length;
@@ -8067,11 +8074,6 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
8067
8074
  var _a;
8068
8075
  $ZodCheck.init(inst, def);
8069
8076
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
8070
- inst._zod.onattach.push((inst) => {
8071
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
8072
- if (def.minimum > curr)
8073
- inst._zod.bag.minimum = def.minimum;
8074
- });
8075
8077
  inst._zod.check = (payload) => {
8076
8078
  const input = payload.value;
8077
8079
  const units = input.length;
@@ -8094,12 +8096,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
8094
8096
  var _a;
8095
8097
  $ZodCheck.init(inst, def);
8096
8098
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
8097
- inst._zod.onattach.push((inst) => {
8098
- const bag = inst._zod.bag;
8099
- bag.minimum = def.length;
8100
- bag.maximum = def.length;
8101
- bag.length = def.length;
8102
- });
8103
8099
  inst._zod.check = (payload) => {
8104
8100
  const input = payload.value;
8105
8101
  const units = input.length;
@@ -8122,14 +8118,6 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
8122
8118
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
8123
8119
  var _a, _b;
8124
8120
  $ZodCheck.init(inst, def);
8125
- inst._zod.onattach.push((inst) => {
8126
- const bag = inst._zod.bag;
8127
- bag.format = def.format;
8128
- if (def.pattern) {
8129
- bag.patterns ?? (bag.patterns = new Set);
8130
- bag.patterns.add(def.pattern);
8131
- }
8132
- });
8133
8121
  if (def.pattern)
8134
8122
  (_a = inst._zod).check ?? (_a.check = (payload) => {
8135
8123
  def.pattern.lastIndex = 0;
@@ -8178,11 +8166,6 @@ var $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst,
8178
8166
  const escapedRegex = escapeRegex(def.includes);
8179
8167
  const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
8180
8168
  def.pattern = pattern;
8181
- inst._zod.onattach.push((inst) => {
8182
- const bag = inst._zod.bag;
8183
- bag.patterns ?? (bag.patterns = new Set);
8184
- bag.patterns.add(pattern);
8185
- });
8186
8169
  inst._zod.check = (payload) => {
8187
8170
  if (payload.value.includes(def.includes, def.position))
8188
8171
  return;
@@ -8201,11 +8184,6 @@ var $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (i
8201
8184
  $ZodCheck.init(inst, def);
8202
8185
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
8203
8186
  def.pattern ?? (def.pattern = pattern);
8204
- inst._zod.onattach.push((inst) => {
8205
- const bag = inst._zod.bag;
8206
- bag.patterns ?? (bag.patterns = new Set);
8207
- bag.patterns.add(pattern);
8208
- });
8209
8187
  inst._zod.check = (payload) => {
8210
8188
  if (payload.value.startsWith(def.prefix))
8211
8189
  return;
@@ -8224,11 +8202,6 @@ var $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst,
8224
8202
  $ZodCheck.init(inst, def);
8225
8203
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
8226
8204
  def.pattern ?? (def.pattern = pattern);
8227
- inst._zod.onattach.push((inst) => {
8228
- const bag = inst._zod.bag;
8229
- bag.patterns ?? (bag.patterns = new Set);
8230
- bag.patterns.add(pattern);
8231
- });
8232
8205
  inst._zod.check = (payload) => {
8233
8206
  if (payload.value.endsWith(def.suffix))
8234
8207
  return;
@@ -8260,8 +8233,11 @@ class Doc {
8260
8233
  }
8261
8234
  indented(fn) {
8262
8235
  this.indent += 1;
8263
- fn(this);
8264
- this.indent -= 1;
8236
+ try {
8237
+ fn(this);
8238
+ } finally {
8239
+ this.indent -= 1;
8240
+ }
8265
8241
  }
8266
8242
  write(arg) {
8267
8243
  if (typeof arg === "function") {
@@ -8292,8 +8268,8 @@ ${content.join(`
8292
8268
  // node_modules/zod/v4/core/versions.js
8293
8269
  var version = {
8294
8270
  major: 4,
8295
- minor: 5,
8296
- patch: 4
8271
+ minor: 6,
8272
+ patch: 5
8297
8273
  };
8298
8274
 
8299
8275
  // node_modules/zod/v4/core/schemas.js
@@ -8405,15 +8381,21 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
8405
8381
  own(this, "~standard", value);
8406
8382
  }
8407
8383
  });
8408
- var toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
8384
+ var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
8385
+ async function validateAsync2(inst, value) {
8386
+ const ctx = { async: true };
8387
+ return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
8388
+ }
8409
8389
  function standardProps(inst) {
8410
8390
  return {
8411
8391
  validate: (value) => {
8392
+ const ctx = { async: false };
8412
8393
  try {
8413
- return toStandardResult(safeParse(inst, value));
8414
- } catch (_) {
8415
- return safeParseAsync(inst, value).then(toStandardResult);
8416
- }
8394
+ const r = inst._zod.run({ value, issues: [] }, ctx);
8395
+ if (!(r instanceof Promise))
8396
+ return toStandardResult(r, ctx);
8397
+ } catch (_) {}
8398
+ return validateAsync2(inst, value);
8417
8399
  },
8418
8400
  vendor: "zod",
8419
8401
  version: 1
@@ -8421,7 +8403,7 @@ function standardProps(inst) {
8421
8403
  }
8422
8404
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
8423
8405
  $ZodType.init(inst, def);
8424
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
8406
+ inst._zod.pattern = def.pattern ?? anyString;
8425
8407
  inst._zod.parse = (payload, _) => {
8426
8408
  if (def.coerce)
8427
8409
  try {
@@ -8472,11 +8454,32 @@ var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
8472
8454
  });
8473
8455
  var URL_BAD_FORMAT = 1;
8474
8456
  var URL_UNPARSEABLE = 2;
8457
+ function canParseURL(input) {
8458
+ try {
8459
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function")
8460
+ return URL.canParse(input);
8461
+ new URL(input);
8462
+ return true;
8463
+ } catch {
8464
+ return false;
8465
+ }
8466
+ }
8467
+ function validateURL(trimmed, def) {
8468
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
8469
+ return canParseURL(trimmed) || URL_UNPARSEABLE;
8470
+ }
8471
+ return parseURLObject(trimmed, def);
8472
+ }
8475
8473
  function parseURLObject(trimmed, def) {
8476
8474
  if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
8477
8475
  return URL_BAD_FORMAT;
8478
8476
  }
8479
8477
  try {
8478
+ if (typeof URL !== "undefined") {
8479
+ const URLStatic = URL;
8480
+ if (typeof URLStatic.parse === "function")
8481
+ return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
8482
+ }
8480
8483
  return new URL(trimmed);
8481
8484
  } catch {
8482
8485
  return URL_UNPARSEABLE;
@@ -8499,7 +8502,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
8499
8502
  inst._zod.check = (payload) => {
8500
8503
  try {
8501
8504
  const trimmed = payload.value.trim();
8502
- const url = parseURLObject(trimmed, def);
8505
+ const url = validateURL(trimmed, def);
8503
8506
  if (url === URL_BAD_FORMAT) {
8504
8507
  payload.issues.push({
8505
8508
  code: "invalid_format",
@@ -8521,6 +8524,10 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
8521
8524
  });
8522
8525
  return;
8523
8526
  }
8527
+ if (url === true) {
8528
+ payload.value = stripTabAndNewline(trimmed);
8529
+ return;
8530
+ }
8524
8531
  if (def.hostname && !urlHostnameOk(url, def.hostname)) {
8525
8532
  payload.issues.push({
8526
8533
  code: "invalid_format",
@@ -8589,12 +8596,6 @@ var $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
8589
8596
  var $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
8590
8597
  def.pattern ?? (def.pattern = datetime(def));
8591
8598
  $ZodStringFormat.init(inst, def);
8592
- if (def.local || def.precision === -1) {
8593
- inst._zod.bag.laxFormat = true;
8594
- inst._zod.onattach.push((s) => {
8595
- s._zod.bag.laxFormat = true;
8596
- });
8597
- }
8598
8599
  });
8599
8600
  var $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
8600
8601
  def.pattern ?? (def.pattern = date);
@@ -8611,23 +8612,16 @@ var $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def
8611
8612
  var $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
8612
8613
  def.pattern ?? (def.pattern = ipv4);
8613
8614
  $ZodStringFormat.init(inst, def);
8614
- inst._zod.bag.format = `ipv4`;
8615
8615
  });
8616
8616
  var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
8617
8617
  function isValidIPv6(value) {
8618
8618
  if (!ipv6Alphabet.test(value))
8619
8619
  return false;
8620
- try {
8621
- new URL(`http://[${value}]`);
8622
- return true;
8623
- } catch {
8624
- return false;
8625
- }
8620
+ return canParseURL(`http://[${value}]`);
8626
8621
  }
8627
8622
  var $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
8628
8623
  def.pattern ?? (def.pattern = ipv6);
8629
8624
  $ZodStringFormat.init(inst, def);
8630
- inst._zod.bag.format = `ipv6`;
8631
8625
  inst._zod.check = (payload) => {
8632
8626
  if (!isValidIPv6(payload.value)) {
8633
8627
  payload.issues.push({
@@ -8687,10 +8681,10 @@ function isValidBase64(data) {
8687
8681
  return false;
8688
8682
  }
8689
8683
  }
8684
+ var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
8690
8685
  var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
8691
- def.pattern ?? (def.pattern = base64);
8686
+ def.pattern ?? (def.pattern = base64Charset);
8692
8687
  $ZodStringFormat.init(inst, def);
8693
- inst._zod.bag.contentEncoding = "base64";
8694
8688
  inst._zod.check = (payload) => {
8695
8689
  if (isValidBase64(payload.value))
8696
8690
  return;
@@ -8703,17 +8697,17 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
8703
8697
  });
8704
8698
  };
8705
8699
  });
8700
+ var base64urlCharset = /^[A-Za-z0-9_-]*$/;
8706
8701
  function isValidBase64URL(data) {
8707
- if (!base64url.test(data))
8702
+ if (!base64urlCharset.test(data))
8708
8703
  return false;
8709
8704
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
8710
8705
  const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
8711
8706
  return isValidBase64(padded);
8712
8707
  }
8713
8708
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
8714
- def.pattern ?? (def.pattern = base64url);
8709
+ def.pattern ?? (def.pattern = base64urlCharset);
8715
8710
  $ZodStringFormat.init(inst, def);
8716
- inst._zod.bag.contentEncoding = "base64url";
8717
8711
  inst._zod.check = (payload) => {
8718
8712
  if (isValidBase64URL(payload.value))
8719
8713
  return;
@@ -8766,7 +8760,7 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
8766
8760
  });
8767
8761
  var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
8768
8762
  $ZodType.init(inst, def);
8769
- inst._zod.pattern = inst._zod.bag.pattern ?? number;
8763
+ inst._zod.pattern = number;
8770
8764
  inst._zod.parse = (payload, _ctx) => {
8771
8765
  if (def.coerce)
8772
8766
  try {
@@ -8871,6 +8865,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
8871
8865
  }
8872
8866
  payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
8873
8867
  const proms = [];
8868
+ const abortEarly = ctx?.abortEarly;
8874
8869
  for (let i = 0;i < input.length; i++) {
8875
8870
  const item = input[i];
8876
8871
  const result = def.element._zod.run({
@@ -8881,6 +8876,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
8881
8876
  proms.push(result.then((result) => handleArrayResult(result, payload, i)));
8882
8877
  } else {
8883
8878
  handleArrayResult(result, payload, i);
8879
+ if (abortEarly && result.issues.length !== 0 && aborted(result))
8880
+ break;
8884
8881
  }
8885
8882
  }
8886
8883
  if (proms.length) {
@@ -8913,7 +8910,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
8913
8910
  return;
8914
8911
  }
8915
8912
  if (result.value === undefined) {
8916
- if (isPresent) {
8913
+ if (isPresent || optin === "defaulted" && !isOptionalOut) {
8917
8914
  final.value[key] = undefined;
8918
8915
  }
8919
8916
  } else {
@@ -8941,14 +8938,20 @@ function normalizeDef(def) {
8941
8938
  optionalKeys: new Set(okeys)
8942
8939
  };
8943
8940
  }
8944
- function handleCatchall(proms, input, payload, ctx, def, inst) {
8941
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
8945
8942
  const unrecognized = [];
8946
8943
  const keySet = def.keySet;
8947
8944
  const _catchall = def.catchall._zod;
8948
8945
  const t = _catchall.def.type;
8949
8946
  const optin = _catchall.optin;
8950
8947
  const optout = _catchall.optout;
8948
+ let seen = 0;
8951
8949
  for (const key in input) {
8950
+ if (abortEarly && payload.issues.length !== seen) {
8951
+ if (aborted(payload, seen))
8952
+ break;
8953
+ seen = payload.issues.length;
8954
+ }
8952
8955
  if (keySet.has(key))
8953
8956
  continue;
8954
8957
  if (key === "__proto__") {
@@ -8982,23 +8985,19 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
8982
8985
  return payload;
8983
8986
  });
8984
8987
  }
8985
- var propShapes = new WeakMap;
8986
8988
  var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8987
8989
  $ZodType.init(inst, def);
8988
8990
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
8989
- if (!desc?.get) {
8990
- const sh = def.shape;
8991
- propShapes.set(def, sh);
8992
- Object.defineProperty(def, "shape", {
8993
- get: () => {
8994
- const newSh = { ...sh };
8995
- Object.defineProperty(def, "shape", {
8996
- value: newSh
8997
- });
8998
- propShapes.set(def, newSh);
8999
- return newSh;
9000
- }
9001
- });
8991
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
8992
+ if (sh) {
8993
+ const get = () => {
8994
+ const newSh = { ...sh };
8995
+ Object.defineProperty(def, "shape", { value: newSh });
8996
+ get.raw = newSh;
8997
+ return newSh;
8998
+ };
8999
+ get.raw = sh;
9000
+ Object.defineProperty(def, "shape", { get });
9002
9001
  }
9003
9002
  const _normalized = cached(() => normalizeDef(def));
9004
9003
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -9038,7 +9037,14 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9038
9037
  payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
9039
9038
  const proms = [];
9040
9039
  const shape = value.shape;
9040
+ const abortEarly = ctx?.abortEarly;
9041
+ let seen = payload.issues.length;
9041
9042
  for (const key of value.allKeys) {
9043
+ if (abortEarly && payload.issues.length !== seen) {
9044
+ if (aborted(payload, seen))
9045
+ break;
9046
+ seen = payload.issues.length;
9047
+ }
9042
9048
  if (key === "__proto__")
9043
9049
  continue;
9044
9050
  const el = shape[key];
@@ -9054,7 +9060,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9054
9060
  if (!catchall) {
9055
9061
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
9056
9062
  }
9057
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
9063
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
9058
9064
  };
9059
9065
  });
9060
9066
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -9068,10 +9074,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9068
9074
  const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
9069
9075
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
9070
9076
  const prefixStr = (id, k) => `
9077
+ let ${id}_ab = false;
9071
9078
  for (let i = 0; i < ${id}.issues.length; i++) {
9072
9079
  const iss = ${id}.issues[i];
9073
9080
  iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
9074
9081
  payload.issues.push(iss);
9082
+ if (iss.continue !== true) ${id}_ab = true;
9083
+ }
9084
+ if (${id}_ab && ctx && ctx.abortEarly) {
9085
+ payload.value = newResult;
9086
+ return payload;
9075
9087
  }`;
9076
9088
  doc.write(`const input = payload.value;`);
9077
9089
  const ids = Object.create(null);
@@ -9117,6 +9129,10 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9117
9129
  input: undefined,
9118
9130
  path: [${k}]
9119
9131
  });
9132
+ if (ctx && ctx.abortEarly) {
9133
+ payload.value = newResult;
9134
+ return payload;
9135
+ }
9120
9136
  }
9121
9137
 
9122
9138
  if (${id}_present) {
@@ -9128,16 +9144,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9128
9144
  doc.write(`
9129
9145
  if (${id}.issues.length) {${prefixStr(id, k)}
9130
9146
  }
9131
-
9132
- if (${id}.value === undefined) {
9133
- if (${isPresent}) {
9134
- newResult[${k}] = undefined;
9135
- }
9147
+ `);
9148
+ if (optin === "defaulted") {
9149
+ doc.write(`newResult[${k}] = ${id}.value;`);
9136
9150
  } else {
9151
+ doc.write(`
9152
+ if (${id}.value !== undefined || ${isPresent}) {
9137
9153
  newResult[${k}] = ${id}.value;
9138
9154
  }
9139
-
9140
9155
  `);
9156
+ }
9141
9157
  }
9142
9158
  }
9143
9159
  doc.write(`payload.value = newResult;`);
@@ -9169,7 +9185,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9169
9185
  payload = fastpass(payload, ctx);
9170
9186
  if (!catchall)
9171
9187
  return payload;
9172
- return handleCatchall([], input, payload, ctx, value, inst);
9188
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
9173
9189
  }
9174
9190
  return superParse(payload, ctx);
9175
9191
  };
@@ -9239,16 +9255,37 @@ var $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
9239
9255
  });
9240
9256
  };
9241
9257
  });
9258
+ function discriminatorMap(def) {
9259
+ const map = new Map;
9260
+ for (const option of def.options) {
9261
+ const values = option._zod.propValues?.[def.discriminator];
9262
+ if (!values || values.size === 0)
9263
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
9264
+ for (const value of values) {
9265
+ if (map.has(value)) {
9266
+ if (value !== undefined)
9267
+ throw new Error(`Duplicate discriminator value "${String(value)}"`);
9268
+ map.set(value, null);
9269
+ } else {
9270
+ map.set(value, option);
9271
+ }
9272
+ }
9273
+ }
9274
+ return map;
9275
+ }
9242
9276
  var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
9243
9277
  def.inclusive = false;
9244
9278
  $ZodUnion.init(inst, def);
9245
9279
  const _super = inst._zod.parse;
9246
9280
  defineLazyInternal(inst, "propValues", (zod) => {
9247
9281
  const propValues = {};
9282
+ let undefinedCount = 0;
9248
9283
  for (const option of zod.def.options) {
9249
9284
  const pv = option._zod.propValues;
9250
9285
  if (!pv || Object.keys(pv).length === 0)
9251
9286
  throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
9287
+ if (pv[zod.def.discriminator]?.has(undefined))
9288
+ undefinedCount++;
9252
9289
  for (const [k, v] of Object.entries(pv)) {
9253
9290
  if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
9254
9291
  assignProp(propValues, k, new Set);
@@ -9258,30 +9295,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
9258
9295
  }
9259
9296
  }
9260
9297
  }
9298
+ if (!zod.def.unionFallback && undefinedCount > 1)
9299
+ propValues[zod.def.discriminator]?.delete(undefined);
9261
9300
  return propValues;
9262
9301
  });
9263
9302
  def.options.forEach((option, i) => {
9264
- const propShape = propShapes.get(option._zod.def);
9303
+ const propShape = rawShape(option._zod.def);
9265
9304
  if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
9266
9305
  throw new Error(`Invalid discriminated union option at index "${i}"`);
9267
9306
  }
9268
9307
  });
9269
- const disc = cached(() => {
9270
- const opts = def.options;
9271
- const map = new Map;
9272
- for (const o of opts) {
9273
- const values = o._zod.propValues?.[def.discriminator];
9274
- if (!values || values.size === 0)
9275
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
9276
- for (const v of values) {
9277
- if (map.has(v)) {
9278
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
9279
- }
9280
- map.set(v, o);
9281
- }
9282
- }
9283
- return map;
9284
- });
9308
+ const disc = cached(() => discriminatorMap(def));
9285
9309
  inst._zod.parse = (payload, ctx) => {
9286
9310
  const input = payload.value;
9287
9311
  if (!isObject(input)) {
@@ -9293,8 +9317,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
9293
9317
  });
9294
9318
  return payload;
9295
9319
  }
9296
- const opt = disc.value.get(input?.[def.discriminator]);
9297
- if (opt) {
9320
+ const value = input?.[def.discriminator];
9321
+ const opt = disc.value.get(value);
9322
+ if (opt && (value !== undefined || ctx.direction !== "backward")) {
9298
9323
  return opt._zod.run(payload, ctx);
9299
9324
  }
9300
9325
  if (def.unionFallback || ctx.direction === "backward") {
@@ -9305,7 +9330,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
9305
9330
  errors: [],
9306
9331
  note: "No matching discriminator",
9307
9332
  discriminator: def.discriminator,
9308
- options: Array.from(disc.value.keys()),
9333
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
9309
9334
  input,
9310
9335
  path: [def.discriminator],
9311
9336
  inst
@@ -9587,8 +9612,10 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
9587
9612
  const values = getEnumValues(def.entries);
9588
9613
  const valuesSet = new Set(values);
9589
9614
  inst._zod.values = valuesSet;
9590
- const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
9591
- inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
9615
+ defineLazyInternal(inst, "pattern", (zod) => {
9616
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
9617
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
9618
+ });
9592
9619
  inst._zod.parse = (payload, _ctx) => {
9593
9620
  const input = payload.value;
9594
9621
  if (valuesSet.has(input)) {
@@ -9607,7 +9634,10 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
9607
9634
  $ZodType.init(inst, def);
9608
9635
  const values = new Set(def.values);
9609
9636
  inst._zod.values = values;
9610
- inst._zod.pattern = new RegExp(def.values.length ? `^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
9637
+ defineLazyInternal(inst, "pattern", (zod) => {
9638
+ const vals = zod.def.values;
9639
+ return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
9640
+ });
9611
9641
  inst._zod.parse = (payload, _ctx) => {
9612
9642
  const input = payload.value;
9613
9643
  if (values.has(input)) {
@@ -9887,28 +9917,53 @@ class $ZodCyclicError extends Error {
9887
9917
  }
9888
9918
  var STATE = "~memo";
9889
9919
  var NO_ISSUES = [];
9920
+ function isRef(value) {
9921
+ return value !== null && typeof value === "object";
9922
+ }
9890
9923
  function cloneIssues(issues) {
9891
9924
  return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
9892
9925
  }
9893
9926
  var recursive = /* @__PURE__ */ new WeakMap;
9894
- function isRecursive(inst, stack) {
9927
+ var NONE = 0;
9928
+ var ASSUMED = 1;
9929
+ var PROVEN = 2;
9930
+ function isRecursive(inst, stack, resolve) {
9895
9931
  const cached = recursive.get(inst);
9896
9932
  if (cached !== undefined)
9897
- return cached;
9933
+ return cached ? PROVEN : NONE;
9898
9934
  if (stack.has(inst))
9899
- return true;
9935
+ return PROVEN;
9900
9936
  stack.add(inst);
9901
- let result = false;
9937
+ let result = NONE;
9902
9938
  const check = (child) => {
9903
- if (!result && child?._zod && isRecursive(child, stack))
9904
- result = true;
9939
+ if (result !== PROVEN && child?._zod) {
9940
+ const answer = isRecursive(child, stack, resolve);
9941
+ if (answer > result)
9942
+ result = answer;
9943
+ }
9944
+ };
9945
+ const shape = (sh, spread) => {
9946
+ let answer = NONE;
9947
+ for (const key of Reflect.ownKeys(sh)) {
9948
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
9949
+ if (spread && !desc.enumerable)
9950
+ continue;
9951
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
9952
+ if (child > answer)
9953
+ answer = child;
9954
+ }
9955
+ return answer;
9956
+ };
9957
+ const merge = (answer) => {
9958
+ if (answer > result)
9959
+ result = answer;
9905
9960
  };
9906
9961
  const def = inst._zod.def;
9907
9962
  const kind = def.type;
9908
9963
  switch (kind) {
9909
9964
  case "object": {
9910
- for (const key of Reflect.ownKeys(def.shape))
9911
- check(def.shape[key]);
9965
+ const raw = rawShape(def);
9966
+ merge(raw ? shape(raw, true) : ASSUMED);
9912
9967
  check(def.catchall);
9913
9968
  break;
9914
9969
  }
@@ -9955,9 +10010,11 @@ function isRecursive(inst, stack) {
9955
10010
  check(def.input);
9956
10011
  check(def.output);
9957
10012
  break;
9958
- case "lazy":
9959
- check(inst._zod.innerType);
10013
+ case "lazy": {
10014
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);
10015
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
9960
10016
  break;
10017
+ }
9961
10018
  case "template_literal":
9962
10019
  case "string":
9963
10020
  case "number":
@@ -9996,13 +10053,17 @@ function isRecursive(inst, stack) {
9996
10053
  }
9997
10054
  }
9998
10055
  stack.delete(inst);
9999
- recursive.set(inst, result);
10000
- return result;
10056
+ return settle(inst, result);
10057
+ }
10058
+ function settle(inst, answer) {
10059
+ if (answer !== ASSUMED)
10060
+ recursive.set(inst, answer === PROVEN);
10061
+ return answer;
10001
10062
  }
10002
10063
  function bucketFor(state, inst) {
10003
10064
  let bucket = state.buckets.get(inst);
10004
10065
  if (!bucket) {
10005
- bucket = new Map;
10066
+ bucket = new WeakMap;
10006
10067
  state.buckets.set(inst, bucket);
10007
10068
  }
10008
10069
  return bucket;
@@ -10038,6 +10099,7 @@ var memo = {
10038
10099
  attach(inst) {
10039
10100
  var _a;
10040
10101
  let isRecursiveInst;
10102
+ let rechecked = false;
10041
10103
  let lastCtx;
10042
10104
  let lastBucket;
10043
10105
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -10045,20 +10107,24 @@ var memo = {
10045
10107
  const base = inst._zod.parse;
10046
10108
  const wrapped = (payload, ctx) => {
10047
10109
  if (isRecursiveInst === undefined) {
10048
- isRecursiveInst = isRecursive(inst, new Set);
10049
- if (!isRecursiveInst) {
10110
+ const walked = isRecursive(inst, new Set, false);
10111
+ if (walked === NONE) {
10050
10112
  inst._zod.parse = base;
10051
10113
  if (inst._zod.run === wrapped)
10052
10114
  inst._zod.run = base;
10053
10115
  return base(payload, ctx);
10054
10116
  }
10117
+ if (walked === PROVEN || rechecked)
10118
+ isRecursiveInst = true;
10119
+ else
10120
+ rechecked = true;
10055
10121
  }
10056
10122
  const input = payload.value;
10057
- if (input === null || typeof input !== "object")
10123
+ if (!isRef(input))
10058
10124
  return base(payload, ctx);
10059
10125
  let state = ctx[STATE];
10060
10126
  if (!state) {
10061
- state = { buckets: new Map, backEdges: undefined };
10127
+ state = { buckets: new WeakMap, backEdges: undefined };
10062
10128
  ctx[STATE] = state;
10063
10129
  }
10064
10130
  let bucket;
@@ -10077,7 +10143,7 @@ var memo = {
10077
10143
  payload.issues.push(...cloneIssues(hit.issues));
10078
10144
  } else {
10079
10145
  payload.memo = true;
10080
- state.backEdges ?? (state.backEdges = new Set);
10146
+ state.backEdges ?? (state.backEdges = new WeakSet);
10081
10147
  state.backEdges.add(hit.value);
10082
10148
  }
10083
10149
  return payload;
@@ -10109,7 +10175,7 @@ function memoizer() {
10109
10175
  }
10110
10176
  function isBackEdge(ctx, value) {
10111
10177
  const backEdges = ctx[STATE]?.backEdges;
10112
- return backEdges !== undefined && value !== null && typeof value === "object" && backEdges.has(value);
10178
+ return backEdges !== undefined && isRef(value) && backEdges.has(value);
10113
10179
  }
10114
10180
  // node_modules/zod/v4/locales/en.js
10115
10181
  var error = () => {
@@ -10151,7 +10217,9 @@ var error = () => {
10151
10217
  base64url: "base64url-encoded string",
10152
10218
  json_string: "JSON string",
10153
10219
  e164: "E.164 number",
10220
+ currency_code: "currency code",
10154
10221
  credit_card: "credit card number",
10222
+ iban: "IBAN",
10155
10223
  jwt: "JWT",
10156
10224
  template_literal: "input"
10157
10225
  };
@@ -10279,11 +10347,13 @@ function registry() {
10279
10347
  (_a2 = globalThis).__zod_globalRegistry ?? (_a2.__zod_globalRegistry = registry());
10280
10348
  var globalRegistry = globalThis.__zod_globalRegistry;
10281
10349
  // node_modules/zod/v4/core/api.js
10350
+ function snapshotChecks(def) {
10351
+ if (def.checks)
10352
+ def.checks = [...def.checks];
10353
+ return def;
10354
+ }
10282
10355
  function _string(Class, params) {
10283
- return new Class({
10284
- type: "string",
10285
- ...normalizeParams(params)
10286
- });
10356
+ return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
10287
10357
  }
10288
10358
  function _email(Class, params) {
10289
10359
  return new Class({
@@ -10523,11 +10593,7 @@ function _isoDuration(Class, params) {
10523
10593
  });
10524
10594
  }
10525
10595
  function _number(Class, params) {
10526
- return new Class({
10527
- type: "number",
10528
- checks: [],
10529
- ...normalizeParams(params)
10530
- });
10596
+ return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
10531
10597
  }
10532
10598
  function _int(Class, params) {
10533
10599
  return new Class({
@@ -10794,7 +10860,7 @@ function handleUnrepresentable(schema, ctx, json, params, message) {
10794
10860
  Object.assign(json, result);
10795
10861
  return true;
10796
10862
  }
10797
- function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10863
+ function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
10798
10864
  var _a;
10799
10865
  const def = schema._zod.def;
10800
10866
  const seen = ctx.seen.get(schema);
@@ -10833,7 +10899,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10833
10899
  if (parent) {
10834
10900
  if (!result.ref)
10835
10901
  result.ref = parent;
10836
- process2(parent, ctx, params);
10902
+ processSchema(parent, ctx, params);
10837
10903
  ctx.seen.get(parent).isParent = true;
10838
10904
  }
10839
10905
  }
@@ -10938,7 +11004,6 @@ function extractDefs(ctx, schema) {
10938
11004
  if (seen.count > 1) {
10939
11005
  if (ctx.reused === "ref") {
10940
11006
  extractToDef(entry);
10941
- continue;
10942
11007
  }
10943
11008
  }
10944
11009
  }
@@ -11263,18 +11328,106 @@ function isTransforming(_schema, _ctx) {
11263
11328
  }
11264
11329
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11265
11330
  const ctx = initializeContext({ ...params, processors });
11266
- process2(schema, ctx);
11331
+ processSchema(schema, ctx);
11267
11332
  extractDefs(ctx, schema);
11268
11333
  return finalize(ctx, schema);
11269
11334
  };
11270
11335
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11271
11336
  const { libraryOptions, target } = params ?? {};
11272
11337
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11273
- process2(schema, ctx);
11338
+ processSchema(schema, ctx);
11274
11339
  extractDefs(ctx, schema);
11275
11340
  return finalize(ctx, schema);
11276
11341
  };
11277
11342
  // node_modules/zod/v4/core/json-schema-processors.js
11343
+ var narrowMin = (agg, key, value) => {
11344
+ if (agg[key] === undefined || value > agg[key])
11345
+ agg[key] = value;
11346
+ };
11347
+ var narrowMax = (agg, key, value) => {
11348
+ if (agg[key] === undefined || value < agg[key])
11349
+ agg[key] = value;
11350
+ };
11351
+ var narrowBoth = (agg, value) => {
11352
+ narrowMin(agg, "minimum", value);
11353
+ narrowMax(agg, "maximum", value);
11354
+ };
11355
+ var addDivisor = (agg, value) => {
11356
+ agg.multipleOf ?? (agg.multipleOf = []);
11357
+ if (!agg.multipleOf.includes(value))
11358
+ agg.multipleOf.push(value);
11359
+ };
11360
+ var addPattern = (agg, pattern) => {
11361
+ agg.patterns ?? (agg.patterns = new Set);
11362
+ agg.patterns.add(pattern);
11363
+ };
11364
+ var intersectMime = (agg, mime) => {
11365
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
11366
+ };
11367
+ var setFormat = (agg, format) => {
11368
+ agg.format = format;
11369
+ if (format.includes("int"))
11370
+ agg.isInt = true;
11371
+ };
11372
+ var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
11373
+ var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
11374
+ var formatContributor = (ranges) => (agg, def) => {
11375
+ setFormat(agg, def.format);
11376
+ const [minimum, maximum] = ranges[def.format];
11377
+ narrowMin(agg, "minimum", minimum);
11378
+ narrowMax(agg, "maximum", maximum);
11379
+ };
11380
+ var contributors = {
11381
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
11382
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
11383
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
11384
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
11385
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
11386
+ min_length: minContributor,
11387
+ max_length: maxContributor,
11388
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
11389
+ min_size: minContributor,
11390
+ max_size: maxContributor,
11391
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
11392
+ string_format: (agg, def) => {
11393
+ setFormat(agg, def.format);
11394
+ if (def.pattern)
11395
+ addPattern(agg, def.pattern);
11396
+ if (def.format === "base64" || def.format === "base64url")
11397
+ agg.contentEncoding = def.format;
11398
+ if (def.local || def.precision === -1)
11399
+ agg.laxFormat = true;
11400
+ },
11401
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
11402
+ };
11403
+ function aggregateChecks(schema) {
11404
+ const agg = {};
11405
+ const def = schema._zod.def;
11406
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
11407
+ for (const ch of list)
11408
+ contributors[ch._zod.def.check]?.(agg, ch._zod.def);
11409
+ const bag = schema._zod.bag;
11410
+ if (bag.minimum !== undefined)
11411
+ narrowMin(agg, "minimum", bag.minimum);
11412
+ if (bag.exclusiveMinimum !== undefined)
11413
+ narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
11414
+ if (bag.maximum !== undefined)
11415
+ narrowMax(agg, "maximum", bag.maximum);
11416
+ if (bag.exclusiveMaximum !== undefined)
11417
+ narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
11418
+ if (bag.multipleOf !== undefined)
11419
+ addDivisor(agg, bag.multipleOf);
11420
+ if (bag.format !== undefined) {
11421
+ agg.format ?? (agg.format = bag.format);
11422
+ if (bag.format.includes("int"))
11423
+ agg.isInt = true;
11424
+ }
11425
+ if (bag.mime)
11426
+ intersectMime(agg, bag.mime);
11427
+ for (const pattern of bag.patterns ?? [])
11428
+ addPattern(agg, pattern);
11429
+ return agg;
11430
+ }
11278
11431
  var formatMap = {
11279
11432
  guid: "uuid",
11280
11433
  url: "uri",
@@ -11282,10 +11435,15 @@ var formatMap = {
11282
11435
  json_string: "json-string",
11283
11436
  regex: ""
11284
11437
  };
11438
+ var exactPatterns = new Map([
11439
+ [base64Charset, base64],
11440
+ [base64urlCharset, base64url]
11441
+ ]);
11442
+ var exactPattern = (p) => exactPatterns.get(p) ?? p;
11285
11443
  var stringProcessor = (schema, ctx, _json, _params) => {
11286
11444
  const json = _json;
11287
11445
  json.type = "string";
11288
- const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema._zod.bag;
11446
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
11289
11447
  if (typeof minimum === "number")
11290
11448
  json.minLength = minimum;
11291
11449
  if (typeof maximum === "number")
@@ -11301,7 +11459,7 @@ var stringProcessor = (schema, ctx, _json, _params) => {
11301
11459
  if (contentEncoding)
11302
11460
  json.contentEncoding = contentEncoding;
11303
11461
  if (patterns && patterns.size > 0) {
11304
- const patternList = [...patterns];
11462
+ const patternList = [...patterns].map(exactPattern);
11305
11463
  if (patternList.length === 1)
11306
11464
  json.pattern = patternList[0].source;
11307
11465
  else if (patternList.length > 1) {
@@ -11316,11 +11474,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
11316
11474
  };
11317
11475
  var numberProcessor = (schema, ctx, _json, params) => {
11318
11476
  const json = _json;
11319
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
11320
- if (typeof format === "string" && format.includes("int"))
11321
- json.type = "integer";
11322
- else
11323
- json.type = "number";
11477
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
11478
+ json.type = isInt ? "integer" : "number";
11324
11479
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
11325
11480
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
11326
11481
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -11344,11 +11499,19 @@ var numberProcessor = (schema, ctx, _json, params) => {
11344
11499
  } else if (typeof maximum === "number") {
11345
11500
  json.maximum = maximum;
11346
11501
  }
11347
- if (typeof multipleOf === "number") {
11348
- if (Number.isFinite(multipleOf) && multipleOf !== 0)
11349
- json.multipleOf = Math.abs(multipleOf);
11350
- else
11351
- handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`);
11502
+ if (multipleOf) {
11503
+ const divisors = new Set;
11504
+ for (const divisor of multipleOf) {
11505
+ if (Number.isFinite(divisor) && divisor !== 0)
11506
+ divisors.add(Math.abs(divisor));
11507
+ else
11508
+ handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
11509
+ }
11510
+ const [first, ...rest] = divisors;
11511
+ if (first !== undefined)
11512
+ json.multipleOf = first;
11513
+ if (rest.length)
11514
+ json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
11352
11515
  }
11353
11516
  };
11354
11517
  var booleanProcessor = (_schema, _ctx, json, _params) => {
@@ -11448,27 +11611,22 @@ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
11448
11611
  };
11449
11612
  var fileProcessor = (schema, _ctx, json, _params) => {
11450
11613
  const _json = json;
11451
- const file = {
11452
- type: "string",
11453
- format: "binary",
11454
- contentEncoding: "binary"
11455
- };
11456
- const { minimum, maximum, mime } = schema._zod.bag;
11614
+ _json.type = "string";
11615
+ _json.format = "binary";
11616
+ _json.contentEncoding = "binary";
11617
+ const { minimum, maximum, mime } = aggregateChecks(schema);
11457
11618
  if (minimum !== undefined)
11458
- file.minLength = minimum;
11619
+ _json.minLength = minimum;
11459
11620
  if (maximum !== undefined)
11460
- file.maxLength = maximum;
11461
- if (mime) {
11462
- if (mime.length === 1) {
11463
- file.contentMediaType = mime[0];
11464
- Object.assign(_json, file);
11465
- } else {
11466
- Object.assign(_json, file);
11467
- _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
11468
- }
11469
- } else {
11470
- Object.assign(_json, file);
11471
- }
11621
+ _json.maxLength = maximum;
11622
+ if (!mime)
11623
+ return;
11624
+ if (mime.length === 0)
11625
+ _json.not = {};
11626
+ else if (mime.length === 1)
11627
+ _json.contentMediaType = mime[0];
11628
+ else
11629
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
11472
11630
  };
11473
11631
  var successProcessor = (_schema, _ctx, json, _params) => {
11474
11632
  json.type = "boolean";
@@ -11491,13 +11649,13 @@ var setProcessor = (schema, ctx, json, params) => {
11491
11649
  var arrayProcessor = (schema, ctx, _json, params) => {
11492
11650
  const json = _json;
11493
11651
  const def = schema._zod.def;
11494
- const { minimum, maximum } = schema._zod.bag;
11652
+ const { minimum, maximum } = aggregateChecks(schema);
11495
11653
  if (typeof minimum === "number")
11496
11654
  json.minItems = minimum;
11497
11655
  if (typeof maximum === "number")
11498
11656
  json.maxItems = maximum;
11499
11657
  json.type = "array";
11500
- json.items = process2(def.element, ctx, {
11658
+ json.items = processSchema(def.element, ctx, {
11501
11659
  ...params,
11502
11660
  path: [...params.path, "items"]
11503
11661
  });
@@ -11523,22 +11681,20 @@ var objectProcessor = (schema, ctx, _json, params) => {
11523
11681
  json.type = "object";
11524
11682
  json.properties = {};
11525
11683
  for (const key in shape) {
11526
- assignProp(json.properties, key, process2(shape[key], ctx, {
11684
+ assignProp(json.properties, key, processSchema(shape[key], ctx, {
11527
11685
  ...params,
11528
11686
  path: [...params.path, "properties", key]
11529
11687
  }));
11530
11688
  }
11531
- const allKeys = new Set(Object.keys(shape));
11532
- const requiredKeys = new Set([...allKeys].filter((key) => {
11689
+ const requiredKeys = [];
11690
+ for (const key of Object.keys(shape)) {
11533
11691
  const field = def.shape[key];
11534
- if (ctx.io === "input") {
11535
- return inputOptin(field) === undefined;
11536
- } else {
11537
- return field._zod.optout === undefined;
11692
+ if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
11693
+ requiredKeys.push(key);
11538
11694
  }
11539
- }));
11540
- if (requiredKeys.size > 0) {
11541
- json.required = Array.from(requiredKeys);
11695
+ }
11696
+ if (requiredKeys.length > 0) {
11697
+ json.required = requiredKeys;
11542
11698
  }
11543
11699
  if (def.catchall?._zod.def.type === "never") {
11544
11700
  json.additionalProperties = false;
@@ -11546,7 +11702,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11546
11702
  if (ctx.io === "output")
11547
11703
  json.additionalProperties = false;
11548
11704
  } else if (def.catchall) {
11549
- json.additionalProperties = process2(def.catchall, ctx, {
11705
+ json.additionalProperties = processSchema(def.catchall, ctx, {
11550
11706
  ...params,
11551
11707
  path: [...params.path, "additionalProperties"]
11552
11708
  });
@@ -11555,7 +11711,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11555
11711
  var unionProcessor = (schema, ctx, json, params) => {
11556
11712
  const def = schema._zod.def;
11557
11713
  const isExclusive = def.inclusive === false;
11558
- const options = def.options.map((x, i) => process2(x, ctx, {
11714
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
11559
11715
  ...params,
11560
11716
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
11561
11717
  }));
@@ -11567,11 +11723,11 @@ var unionProcessor = (schema, ctx, json, params) => {
11567
11723
  };
11568
11724
  var intersectionProcessor = (schema, ctx, json, params) => {
11569
11725
  const def = schema._zod.def;
11570
- const a = process2(def.left, ctx, {
11726
+ const a = processSchema(def.left, ctx, {
11571
11727
  ...params,
11572
11728
  path: [...params.path, "allOf", 0]
11573
11729
  });
11574
- const b = process2(def.right, ctx, {
11730
+ const b = processSchema(def.right, ctx, {
11575
11731
  ...params,
11576
11732
  path: [...params.path, "allOf", 1]
11577
11733
  });
@@ -11589,11 +11745,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
11589
11745
  json.type = "array";
11590
11746
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
11591
11747
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
11592
- const prefixItems = def.items.map((x, i) => process2(x, ctx, {
11748
+ const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
11593
11749
  ...params,
11594
11750
  path: [...params.path, prefixPath, i]
11595
11751
  }));
11596
- const rest = def.rest ? process2(def.rest, ctx, {
11752
+ const rest = def.rest ? processSchema(def.rest, ctx, {
11597
11753
  ...params,
11598
11754
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
11599
11755
  }) : null;
@@ -11641,7 +11797,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
11641
11797
  if (isClosed)
11642
11798
  json.maxItems = maxItems;
11643
11799
  }
11644
- const { minimum, maximum } = schema._zod.bag;
11800
+ const { minimum, maximum } = aggregateChecks(schema);
11645
11801
  if (typeof minimum === "number")
11646
11802
  json.minItems = minimum;
11647
11803
  if (typeof maximum === "number")
@@ -11715,20 +11871,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
11715
11871
  const def = schema._zod.def;
11716
11872
  json.type = "object";
11717
11873
  const keyType = def.keyType;
11718
- const keyBag = keyType._zod.bag;
11719
- const patterns = keyBag?.patterns;
11874
+ const patterns = aggregateChecks(keyType).patterns;
11720
11875
  if (def.mode === "loose" && patterns && patterns.size > 0) {
11721
- const valueSchema = process2(def.valueType, ctx, {
11876
+ const valueSchema = processSchema(def.valueType, ctx, {
11722
11877
  ...params,
11723
11878
  path: [...params.path, "patternProperties", "*"]
11724
11879
  });
11725
11880
  json.patternProperties = {};
11726
11881
  for (const pattern of patterns) {
11727
- assignProp(json.patternProperties, pattern.source, valueSchema);
11882
+ assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
11728
11883
  }
11729
11884
  } else {
11730
11885
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
11731
- json.propertyNames = process2(def.keyType, ctx, {
11886
+ json.propertyNames = processSchema(def.keyType, ctx, {
11732
11887
  ...params,
11733
11888
  path: [...params.path, "propertyNames"]
11734
11889
  });
@@ -11740,7 +11895,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11740
11895
  }
11741
11896
  pending.push(schema);
11742
11897
  }
11743
- json.additionalProperties = process2(def.valueType, ctx, {
11898
+ json.additionalProperties = processSchema(def.valueType, ctx, {
11744
11899
  ...params,
11745
11900
  path: [...params.path, "additionalProperties"]
11746
11901
  });
@@ -11756,7 +11911,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11756
11911
  };
11757
11912
  var nullableProcessor = (schema, ctx, json, params) => {
11758
11913
  const def = schema._zod.def;
11759
- const inner = process2(def.innerType, ctx, params);
11914
+ const inner = processSchema(def.innerType, ctx, params);
11760
11915
  const seen = ctx.seen.get(schema);
11761
11916
  if (ctx.target === "openapi-3.0") {
11762
11917
  seen.ref = def.innerType;
@@ -11767,7 +11922,7 @@ var nullableProcessor = (schema, ctx, json, params) => {
11767
11922
  };
11768
11923
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
11769
11924
  const def = schema._zod.def;
11770
- process2(def.innerType, ctx, params);
11925
+ processSchema(def.innerType, ctx, params);
11771
11926
  const seen = ctx.seen.get(schema);
11772
11927
  seen.ref = def.innerType;
11773
11928
  };
@@ -11787,7 +11942,7 @@ function serializeDefaultValue(value, schema, ctx, json, params) {
11787
11942
  }
11788
11943
  var defaultProcessor = (schema, ctx, json, params) => {
11789
11944
  const def = schema._zod.def;
11790
- process2(def.innerType, ctx, params);
11945
+ processSchema(def.innerType, ctx, params);
11791
11946
  const seen = ctx.seen.get(schema);
11792
11947
  seen.ref = def.innerType;
11793
11948
  const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
@@ -11796,7 +11951,7 @@ var defaultProcessor = (schema, ctx, json, params) => {
11796
11951
  };
11797
11952
  var prefaultProcessor = (schema, ctx, json, params) => {
11798
11953
  const def = schema._zod.def;
11799
- process2(def.innerType, ctx, params);
11954
+ processSchema(def.innerType, ctx, params);
11800
11955
  const seen = ctx.seen.get(schema);
11801
11956
  seen.ref = def.innerType;
11802
11957
  if (ctx.io !== "input")
@@ -11807,7 +11962,7 @@ var prefaultProcessor = (schema, ctx, json, params) => {
11807
11962
  };
11808
11963
  var catchProcessor = (schema, ctx, json, params) => {
11809
11964
  const def = schema._zod.def;
11810
- process2(def.innerType, ctx, params);
11965
+ processSchema(def.innerType, ctx, params);
11811
11966
  const seen = ctx.seen.get(schema);
11812
11967
  seen.ref = def.innerType;
11813
11968
  let catchValue;
@@ -11823,32 +11978,32 @@ var pipeProcessor = (schema, ctx, _json, params) => {
11823
11978
  const def = schema._zod.def;
11824
11979
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
11825
11980
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
11826
- process2(innerType, ctx, params);
11981
+ processSchema(innerType, ctx, params);
11827
11982
  const seen = ctx.seen.get(schema);
11828
11983
  seen.ref = innerType;
11829
11984
  };
11830
11985
  var readonlyProcessor = (schema, ctx, json, params) => {
11831
11986
  const def = schema._zod.def;
11832
- process2(def.innerType, ctx, params);
11987
+ processSchema(def.innerType, ctx, params);
11833
11988
  const seen = ctx.seen.get(schema);
11834
11989
  seen.ref = def.innerType;
11835
11990
  json.readOnly = true;
11836
11991
  };
11837
11992
  var promiseProcessor = (schema, ctx, _json, params) => {
11838
11993
  const def = schema._zod.def;
11839
- process2(def.innerType, ctx, params);
11994
+ processSchema(def.innerType, ctx, params);
11840
11995
  const seen = ctx.seen.get(schema);
11841
11996
  seen.ref = def.innerType;
11842
11997
  };
11843
11998
  var optionalProcessor = (schema, ctx, _json, params) => {
11844
11999
  const def = schema._zod.def;
11845
- process2(def.innerType, ctx, params);
12000
+ processSchema(def.innerType, ctx, params);
11846
12001
  const seen = ctx.seen.get(schema);
11847
12002
  seen.ref = def.innerType;
11848
12003
  };
11849
12004
  var lazyProcessor = (schema, ctx, _json, params) => {
11850
12005
  const innerType = schema._zod.innerType;
11851
- process2(innerType, ctx, params);
12006
+ processSchema(innerType, ctx, params);
11852
12007
  const seen = ctx.seen.get(schema);
11853
12008
  seen.ref = innerType;
11854
12009
  };
@@ -11900,7 +12055,7 @@ function toJSONSchema(input, params) {
11900
12055
  const defs = {};
11901
12056
  for (const entry of registry._idmap.entries()) {
11902
12057
  const [_, schema] = entry;
11903
- process2(schema, ctx);
12058
+ processSchema(schema, ctx);
11904
12059
  }
11905
12060
  const schemas = {};
11906
12061
  const external = {
@@ -11923,7 +12078,7 @@ function toJSONSchema(input, params) {
11923
12078
  return { schemas };
11924
12079
  }
11925
12080
  const ctx = initializeContext({ ...params, processors: allProcessors });
11926
- process2(input, ctx);
12081
+ processSchema(input, ctx);
11927
12082
  extractDefs(ctx, input);
11928
12083
  return finalize(ctx, input);
11929
12084
  }
@@ -12126,6 +12281,12 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
12126
12281
  set spa(value) {
12127
12282
  own(this, "spa", value);
12128
12283
  },
12284
+ validate(data, params) {
12285
+ return validate(this, data, params);
12286
+ },
12287
+ validateAsync(data, params) {
12288
+ return validateAsync(this, data, params);
12289
+ },
12129
12290
  encode: function _encode(data, params) {
12130
12291
  return encode(this, data, params, { callee: _encode });
12131
12292
  },
@@ -12164,10 +12325,10 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
12164
12325
  $ZodString.init(inst, def);
12165
12326
  ZodType.init(inst, def);
12166
12327
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
12167
- const bag = inst._zod.bag;
12168
- inst.format = bag.format ?? null;
12169
- inst.minLength = bag.minimum ?? null;
12170
- inst.maxLength = bag.maximum ?? null;
12328
+ }, /* @__PURE__ */ derived({
12329
+ format: (inst) => aggregateChecks(inst).format ?? null,
12330
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
12331
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
12171
12332
  }, {
12172
12333
  regex(...args) {
12173
12334
  return this.check(_regex(...args));
@@ -12214,7 +12375,7 @@ var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
12214
12375
  slugify() {
12215
12376
  return this.check(_slugify());
12216
12377
  }
12217
- });
12378
+ }));
12218
12379
  var ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
12219
12380
  $ZodString.init(inst, def);
12220
12381
  _ZodString.init(inst, def);
@@ -12401,12 +12562,21 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
12401
12562
  $ZodNumber.init(inst, def);
12402
12563
  ZodType.init(inst, def);
12403
12564
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
12404
- const bag = inst._zod.bag;
12405
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
12406
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
12407
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
12408
12565
  inst.isFinite = true;
12409
- inst.format = bag.format ?? null;
12566
+ }, /* @__PURE__ */ derived({
12567
+ minValue: (inst) => {
12568
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
12569
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
12570
+ },
12571
+ maxValue: (inst) => {
12572
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
12573
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
12574
+ },
12575
+ isInt: (inst) => {
12576
+ const { isInt, multipleOf } = aggregateChecks(inst);
12577
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
12578
+ },
12579
+ format: (inst) => aggregateChecks(inst).format ?? null
12410
12580
  }, {
12411
12581
  gt(value, params) {
12412
12582
  return this.check(_gt(value, params));
@@ -12453,7 +12623,7 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
12453
12623
  finite() {
12454
12624
  return this;
12455
12625
  }
12456
- });
12626
+ }));
12457
12627
  function number2(params) {
12458
12628
  return _number(ZodNumber, params);
12459
12629
  }
@@ -12541,19 +12711,19 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
12541
12711
  return _enum(Object.keys(this._zod.def.shape));
12542
12712
  },
12543
12713
  catchall(catchall) {
12544
- return this.clone({ ...this._zod.def, catchall });
12714
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
12545
12715
  },
12546
12716
  passthrough() {
12547
- return this.clone({ ...this._zod.def, catchall: unknown() });
12717
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
12548
12718
  },
12549
12719
  loose() {
12550
- return this.clone({ ...this._zod.def, catchall: unknown() });
12720
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
12551
12721
  },
12552
12722
  strict() {
12553
- return this.clone({ ...this._zod.def, catchall: never() });
12723
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
12554
12724
  },
12555
12725
  strip() {
12556
- return this.clone({ ...this._zod.def, catchall: undefined });
12726
+ return this.clone(mergeDefs(this._zod.def, { catchall: undefined }));
12557
12727
  },
12558
12728
  extend(incoming) {
12559
12729
  return extend(this, incoming);
@@ -12662,7 +12832,7 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
12662
12832
  ZodType.init(inst, def);
12663
12833
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
12664
12834
  inst.enum = def.entries;
12665
- inst.options = Object.values(def.entries);
12835
+ inst.options = [...inst._zod.values];
12666
12836
  const keys = new Set(Object.keys(def.entries));
12667
12837
  inst.extract = (values, params) => {
12668
12838
  const newEntries = {};
@@ -13802,7 +13972,7 @@ function serializeMessage(message) {
13802
13972
 
13803
13973
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
13804
13974
  class StdioServerTransport {
13805
- constructor(_stdin = process3.stdin, _stdout = process3.stdout, options) {
13975
+ constructor(_stdin = process2.stdin, _stdout = process2.stdout, options) {
13806
13976
  this._stdin = _stdin;
13807
13977
  this._stdout = _stdout;
13808
13978
  this._started = false;
@@ -18273,7 +18443,7 @@ function parseStringDef(def, refs) {
18273
18443
  addFormat(res, "idn-email", check.message, refs);
18274
18444
  break;
18275
18445
  case "pattern:zod":
18276
- addPattern(res, zodPatterns.email, check.message, refs);
18446
+ addPattern2(res, zodPatterns.email, check.message, refs);
18277
18447
  break;
18278
18448
  }
18279
18449
  break;
@@ -18284,19 +18454,19 @@ function parseStringDef(def, refs) {
18284
18454
  addFormat(res, "uuid", check.message, refs);
18285
18455
  break;
18286
18456
  case "regex":
18287
- addPattern(res, check.regex, check.message, refs);
18457
+ addPattern2(res, check.regex, check.message, refs);
18288
18458
  break;
18289
18459
  case "cuid":
18290
- addPattern(res, zodPatterns.cuid, check.message, refs);
18460
+ addPattern2(res, zodPatterns.cuid, check.message, refs);
18291
18461
  break;
18292
18462
  case "cuid2":
18293
- addPattern(res, zodPatterns.cuid2, check.message, refs);
18463
+ addPattern2(res, zodPatterns.cuid2, check.message, refs);
18294
18464
  break;
18295
18465
  case "startsWith":
18296
- addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
18466
+ addPattern2(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
18297
18467
  break;
18298
18468
  case "endsWith":
18299
- addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
18469
+ addPattern2(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
18300
18470
  break;
18301
18471
  case "datetime":
18302
18472
  addFormat(res, "date-time", check.message, refs);
@@ -18315,7 +18485,7 @@ function parseStringDef(def, refs) {
18315
18485
  setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
18316
18486
  break;
18317
18487
  case "includes": {
18318
- addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
18488
+ addPattern2(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
18319
18489
  break;
18320
18490
  }
18321
18491
  case "ip": {
@@ -18328,25 +18498,25 @@ function parseStringDef(def, refs) {
18328
18498
  break;
18329
18499
  }
18330
18500
  case "base64url":
18331
- addPattern(res, zodPatterns.base64url, check.message, refs);
18501
+ addPattern2(res, zodPatterns.base64url, check.message, refs);
18332
18502
  break;
18333
18503
  case "jwt":
18334
- addPattern(res, zodPatterns.jwt, check.message, refs);
18504
+ addPattern2(res, zodPatterns.jwt, check.message, refs);
18335
18505
  break;
18336
18506
  case "cidr": {
18337
18507
  if (check.version !== "v6") {
18338
- addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
18508
+ addPattern2(res, zodPatterns.ipv4Cidr, check.message, refs);
18339
18509
  }
18340
18510
  if (check.version !== "v4") {
18341
- addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
18511
+ addPattern2(res, zodPatterns.ipv6Cidr, check.message, refs);
18342
18512
  }
18343
18513
  break;
18344
18514
  }
18345
18515
  case "emoji":
18346
- addPattern(res, zodPatterns.emoji(), check.message, refs);
18516
+ addPattern2(res, zodPatterns.emoji(), check.message, refs);
18347
18517
  break;
18348
18518
  case "ulid": {
18349
- addPattern(res, zodPatterns.ulid, check.message, refs);
18519
+ addPattern2(res, zodPatterns.ulid, check.message, refs);
18350
18520
  break;
18351
18521
  }
18352
18522
  case "base64": {
@@ -18360,14 +18530,14 @@ function parseStringDef(def, refs) {
18360
18530
  break;
18361
18531
  }
18362
18532
  case "pattern:zod": {
18363
- addPattern(res, zodPatterns.base64, check.message, refs);
18533
+ addPattern2(res, zodPatterns.base64, check.message, refs);
18364
18534
  break;
18365
18535
  }
18366
18536
  }
18367
18537
  break;
18368
18538
  }
18369
18539
  case "nanoid": {
18370
- addPattern(res, zodPatterns.nanoid, check.message, refs);
18540
+ addPattern2(res, zodPatterns.nanoid, check.message, refs);
18371
18541
  }
18372
18542
  case "toLowerCase":
18373
18543
  case "toUpperCase":
@@ -18422,7 +18592,7 @@ function addFormat(schema, value, message, refs) {
18422
18592
  setResponseValueAndErrors(schema, "format", value, message, refs);
18423
18593
  }
18424
18594
  }
18425
- function addPattern(schema, regex, message, refs) {
18595
+ function addPattern2(schema, regex, message, refs) {
18426
18596
  if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
18427
18597
  if (!schema.allOf) {
18428
18598
  schema.allOf = [];
@@ -21545,6 +21715,45 @@ async function markTaskGroupCheckboxesComplete(worktree, changeId, taskGroupId)
21545
21715
  throw new Error(`git commit tasks.md 失败:${commitResult.stderr}`);
21546
21716
  }
21547
21717
  }
21718
+ function unquotePath(p) {
21719
+ const t = p.trim();
21720
+ return t.startsWith('"') && t.endsWith('"') && t.length >= 2 ? t.slice(1, -1) : t;
21721
+ }
21722
+ function parseStatusEntries(out) {
21723
+ const entries = [];
21724
+ for (const raw of out.split(`
21725
+ `)) {
21726
+ if (raw.length < 4)
21727
+ continue;
21728
+ let line = raw;
21729
+ if (line[2] !== " ") {
21730
+ if (line[1] !== " ")
21731
+ continue;
21732
+ line = ` ${line}`;
21733
+ }
21734
+ if (line[0] === " " && line[1] === " ")
21735
+ continue;
21736
+ const pathPart = line.slice(3);
21737
+ const arrow = pathPart.indexOf(" -> ");
21738
+ const paths = arrow >= 0 ? [unquotePath(pathPart.slice(0, arrow)), unquotePath(pathPart.slice(arrow + 4))] : [unquotePath(pathPart)];
21739
+ if (paths.every((p) => p !== ""))
21740
+ entries.push({ x: line[0], y: line[1], paths });
21741
+ }
21742
+ return entries;
21743
+ }
21744
+ function parseDiffNameOnly(out) {
21745
+ return out.split(`
21746
+ `).map(unquotePath).filter(Boolean);
21747
+ }
21748
+ function pathsOverlap(a, b) {
21749
+ const na = a.replace(/\/+$/, "");
21750
+ const nb = b.replace(/\/+$/, "");
21751
+ if (!na || !nb)
21752
+ return false;
21753
+ if (na === nb)
21754
+ return true;
21755
+ return na.startsWith(`${nb}/`) || nb.startsWith(`${na}/`);
21756
+ }
21548
21757
  async function mergeBranchToTarget(repoDir, sourceBranch, targetBranch) {
21549
21758
  const mainRepo = await resolveMainRepoRoot(repoDir) ?? repoDir;
21550
21759
  const ancestor = await runGitChecked(mainRepo, ["merge-base", "--is-ancestor", sourceBranch, targetBranch]);
@@ -21563,18 +21772,6 @@ async function mergeBranchToTarget(repoDir, sourceBranch, targetBranch) {
21563
21772
  `- **原因**: 目标分支 \`${targetBranch}\` 正被工作树 \`${checkedOutPath}\` 检出;自动推进分支指针会使该工作树的暂存区/工作区与分支引用失步,本次未执行任何合并动作。`,
21564
21773
  `- **处理**: 请在该工作树手动执行 \`git merge ${sourceBranch}\`,或移除该工作树(\`git worktree remove ${checkedOutPath}\`)后重试。`
21565
21774
  ].join(`
21566
- `)
21567
- };
21568
- }
21569
- const status = await runGit(mainRepo, ["status", "--porcelain"]);
21570
- if (status.trim().length > 0) {
21571
- return {
21572
- success: false,
21573
- conflict: false,
21574
- blockedMessage: [
21575
- `- **原因**: 目标分支 \`${targetBranch}\` 正被主仓库检出,且主仓库存在未提交改动;为避免覆盖本地改动,本次未执行任何合并动作(分支引用未动、无半成品)。`,
21576
- `- **处理**: 请先 commit 或 stash 主仓库改动后重试;或自行执行 \`git merge ${sourceBranch}\`(真实合并自带脏工作区保护)。`
21577
- ].join(`
21578
21775
  `)
21579
21776
  };
21580
21777
  }
@@ -21585,6 +21782,65 @@ async function mergeBranchToTarget(repoDir, sourceBranch, targetBranch) {
21585
21782
  }
21586
21783
  return { success: false, conflict: true };
21587
21784
  }
21785
+ const mergedTreeOid = mergeTree.stdout.split(`
21786
+ `)[0].trim();
21787
+ const statusRes = await runGitChecked(mainRepo, ["status", "--porcelain"]);
21788
+ if (!statusRes.success) {
21789
+ throw new Error(`无法读取主仓库工作区状态:${statusRes.stderr}`);
21790
+ }
21791
+ const entries = parseStatusEntries(statusRes.stdout);
21792
+ if (entries.length > 0) {
21793
+ const dirtyPaths = [...new Set(entries.flatMap((e) => e.paths))];
21794
+ const written = parseDiffNameOnly(await runGit(mainRepo, ["diff", "--name-only", "--no-renames", targetBranch, mergedTreeOid]));
21795
+ const overlap = written.filter((w) => dirtyPaths.some((d) => pathsOverlap(d, w)));
21796
+ if (overlap.length > 0) {
21797
+ return {
21798
+ success: false,
21799
+ conflict: false,
21800
+ blockedMessage: [
21801
+ `- **原因**: 目标分支 \`${targetBranch}\` 正被主仓库检出,且以下本地改动文件与任务组合并将写入的文件重合;为避免覆盖本地改动,本次未执行任何合并动作(分支引用未动、无半成品):`,
21802
+ ...overlap.map((f) => ` - \`${f}\``),
21803
+ `- **处理**: 请先 commit/stash/移除上述文件的本地改动后重试;或自行执行 \`git merge ${sourceBranch}\`(真实合并自带脏工作区保护)。`
21804
+ ].join(`
21805
+ `)
21806
+ };
21807
+ }
21808
+ const stagedPaths = [...new Set(entries.filter((e) => e.x !== " " && e.x !== "?").flatMap((e) => e.paths))];
21809
+ if (stagedPaths.length > 0) {
21810
+ const unstagedDelta = await runGit(mainRepo, ["diff", "--name-only", "--", ...stagedPaths]);
21811
+ if (parseDiffNameOnly(unstagedDelta).length > 0) {
21812
+ return {
21813
+ success: false,
21814
+ conflict: false,
21815
+ blockedMessage: [
21816
+ `- **原因**: 主仓库存在部分暂存文件(同一文件既有已暂存又有未暂存改动),自动合并会改变暂存粒度;本次未执行任何合并动作(分支引用未动、无半成品)。`,
21817
+ `- **处理**: 请先 commit 或 stash,或补全/取消暂存后重试;或自行执行 \`git merge ${sourceBranch}\`。`
21818
+ ].join(`
21819
+ `)
21820
+ };
21821
+ }
21822
+ let unstagedByUs = false;
21823
+ try {
21824
+ const restore = await runGitChecked(mainRepo, ["restore", "--staged", "--", ...stagedPaths]);
21825
+ if (!restore.success)
21826
+ throw new Error(`git restore --staged 失败(未执行合并):${restore.stderr}`);
21827
+ unstagedByUs = true;
21828
+ const mergeResult = await runGitChecked(mainRepo, ["merge", "--no-ff", sourceBranch]);
21829
+ if (!mergeResult.success) {
21830
+ await runGitChecked(mainRepo, ["merge", "--abort"]);
21831
+ return { success: false, conflict: true };
21832
+ }
21833
+ return { success: true, conflict: false };
21834
+ } finally {
21835
+ if (unstagedByUs) {
21836
+ const readd = await runGitChecked(mainRepo, ["add", "--", ...stagedPaths]);
21837
+ if (!readd.success) {
21838
+ throw new Error(`合并后还原暂存态失败(git add):${readd.stderr};请人工核对这些文件的暂存状态`);
21839
+ }
21840
+ }
21841
+ }
21842
+ }
21843
+ }
21588
21844
  const mergeResult = await runGitChecked(mainRepo, ["merge", "--no-ff", sourceBranch]);
21589
21845
  if (!mergeResult.success) {
21590
21846
  await runGitChecked(mainRepo, ["merge", "--abort"]);
@@ -21931,6 +22187,13 @@ function childSourcePhase(child) {
21931
22187
  function isTerminalPhase(phase) {
21932
22188
  return phase === "done" || phase === "cancelled";
21933
22189
  }
22190
+ function isTaskGroupSettled(item) {
22191
+ if (item.phase === "done" || item.metadata["completed_at"] !== undefined)
22192
+ return true;
22193
+ const noTags = Object.keys(item.tags).length === 0;
22194
+ const childrenSettled = item.children.filter((c) => c.type === "task").every((c) => c.phase === "todo" || isTerminalPhase(c.phase));
22195
+ return noTags && childrenSettled;
22196
+ }
21934
22197
  function isBlockingSeverity(severity) {
21935
22198
  return severity !== undefined && BLOCKING_SEVERITIES.includes(severity);
21936
22199
  }
@@ -26844,6 +27107,20 @@ function renderDevSelfCheckDeclaration(metadata) {
26844
27107
  }
26845
27108
  return lines;
26846
27109
  }
27110
+ var DEPLOYMENT_NOTE_PREFIX = "部署注意点:";
27111
+ function extractDeploymentNoteLines(metadata) {
27112
+ const raw = metadata["self_check_results"];
27113
+ if (typeof raw !== "string" || raw.trim() === "")
27114
+ return [];
27115
+ const hits = [];
27116
+ for (const line of raw.split(`
27117
+ `)) {
27118
+ const trimmed = line.trim();
27119
+ if (trimmed.startsWith(DEPLOYMENT_NOTE_PREFIX))
27120
+ hits.push(trimmed);
27121
+ }
27122
+ return hits;
27123
+ }
26847
27124
  var INTERPOLATION_ALLOWED_KEYS = new Set([
26848
27125
  "worktree_path",
26849
27126
  "change_id",
@@ -26969,7 +27246,7 @@ function renderWorkflowStatusView(item, workflow, rec, caller, options) {
26969
27246
  return renderSuspended(item);
26970
27247
  }
26971
27248
  if (item.phase === "done" || item.phase === "cancelled") {
26972
- return renderTerminalPhase(item, options.state);
27249
+ return renderTerminalPhase(item, options.state, caller);
26973
27250
  }
26974
27251
  if (rec.status === "blocked") {
26975
27252
  if (caller.orchestrator) {
@@ -27037,7 +27314,7 @@ function renderSuspended(item) {
27037
27314
  ].join(`
27038
27315
  `);
27039
27316
  }
27040
- function renderTerminalPhase(item, state) {
27317
+ function renderTerminalPhase(item, state, caller) {
27041
27318
  if (item.phase === "cancelled") {
27042
27319
  return [
27043
27320
  "# \uD83D\uDEAB 任务组已取消",
@@ -27077,7 +27354,8 @@ function renderTerminalPhase(item, state) {
27077
27354
  `- **完成时间**: ${item.metadata["completed_at"]}`,
27078
27355
  "",
27079
27356
  "编排已完成并收尾。",
27080
- ""
27357
+ "",
27358
+ ...renderDeploymentNotesSection(state, caller)
27081
27359
  ].join(`
27082
27360
  `);
27083
27361
  }
@@ -27085,10 +27363,40 @@ function renderTerminalPhase(item, state) {
27085
27363
  "# \uD83C\uDFC1 任务组已完成,待收尾",
27086
27364
  "",
27087
27365
  "全部审核层已通过。调用 `opx_orch_complete_task_group` 合并分支并完成收尾。",
27088
- ""
27366
+ "",
27367
+ ...renderDeploymentNotesSection(state, caller)
27089
27368
  ].join(`
27090
27369
  `);
27091
27370
  }
27371
+ function renderDeploymentNotesSection(state, caller) {
27372
+ if (!caller?.orchestrator || !state || state.kind === "review")
27373
+ return [];
27374
+ const taskGroups = state.workItems.filter((w) => w.id.startsWith("task:"));
27375
+ if (!taskGroups.every(isTaskGroupSettled))
27376
+ return [];
27377
+ const lines = [
27378
+ "## 部署注意事项汇报",
27379
+ "",
27380
+ "向用户汇报本次变更的部署注意事项:",
27381
+ "",
27382
+ `- 阅读主仓库 \`openspec/changes/${state.changeId}/\` 下规划文档(design.md、tasks.md、proposal.md、specs/)提取部署要点:数据/结构变更脚本执行、消息队列/缓存等中间件配置调整、新增配置项或功能开关、外部接口契约变化`,
27383
+ "- 无规划文档时跳过文档提取,仅转述下方实施补充点",
27384
+ ""
27385
+ ];
27386
+ const supplementary = taskGroups.flatMap((g) => {
27387
+ const notes = extractDeploymentNoteLines(g.metadata);
27388
+ if (notes.length === 0)
27389
+ return [];
27390
+ const tg = taskGroupFromWorkItem(g);
27391
+ return [`- ${tg.name}(${tg.id}):`, ...notes.map((n) => ` - ${n}`)];
27392
+ });
27393
+ if (supplementary.length > 0) {
27394
+ lines.push("实施补充点(开发者实施时申报,原样转述):", "");
27395
+ lines.push(...supplementary);
27396
+ lines.push("");
27397
+ }
27398
+ return lines;
27399
+ }
27092
27400
  function renderReviewReport(item) {
27093
27401
  const issues = issueChildrenOf(item);
27094
27402
  if (issues.length === 0)
@@ -28104,13 +28412,7 @@ function assertValidResetStepValues(recovery, state) {
28104
28412
  }
28105
28413
  }
28106
28414
  function otherTaskGroupsSettled(state, targetGroupId) {
28107
- return state.workItems.filter((w) => w.id.startsWith("task:") && w.id !== `task:${targetGroupId}`).every((item) => {
28108
- if (item.phase === "done" || item.metadata["completed_at"] !== undefined)
28109
- return true;
28110
- const noTags = Object.keys(item.tags).length === 0;
28111
- const childrenSettled = item.children.filter((c) => c.type === "task").every((c) => c.phase === "todo" || isTerminalPhase(c.phase));
28112
- return noTags && childrenSettled;
28113
- });
28415
+ return state.workItems.filter((w) => w.id.startsWith("task:") && w.id !== `task:${targetGroupId}`).every(isTaskGroupSettled);
28114
28416
  }
28115
28417
  function normalizeSessionToken(s) {
28116
28418
  return s.replace(/[^A-Za-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "") || "head";
@@ -29859,7 +30161,7 @@ var TOOL_SPECS = {
29859
30161
  execute: (args, ctx) => statusExecute({ change_id: args.change_id }, ctx)
29860
30162
  },
29861
30163
  opx_orch_complete_task_group: {
29862
- description: "完成任务组收尾:合并 task-group 分支到 baseBranch → 清理 worktree 与分支。须在收尾验证(verify_cleanup)通过后调用。合并冲突时中止并返回 blocked(保留 worktree/分支)。",
30164
+ description: "完成任务组收尾:合并 task-group 分支到 baseBranch → 清理 worktree 与分支。须在收尾验证(verify_cleanup)通过后调用。合并冲突、主仓库本地改动文件与合并写入文件重合、或存在部分暂存文件时中止并返回 blocked(保留 worktree/分支);主仓库无关脏文件不阻塞合并。",
29863
30165
  schema: completeTaskGroupSchema,
29864
30166
  execute: (args, ctx) => completeTaskGroupExecute(args, ctx)
29865
30167
  },
@@ -29904,7 +30206,7 @@ async function ensureDefaultUnattended(args, ctx) {
29904
30206
  }
29905
30207
  } catch {}
29906
30208
  }
29907
- var PKG_VERSION = "0.133.2";
30209
+ var PKG_VERSION = "0.135.0";
29908
30210
  function buildMcpServer(worktree, opts = {}) {
29909
30211
  const mcp = new McpServer({ name: "openspec-agents", version: PKG_VERSION });
29910
30212
  for (const [name, spec] of Object.entries(TOOL_SPECS)) {