dsh-compact-pi 0.2.3-b3 → 0.2.3-b5

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.
@@ -47,29 +47,29 @@ var __runInitializers = (array2, flags, self, value) => {
47
47
  for (var i = 0, fns = array2[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
48
48
  return value;
49
49
  };
50
- var __decorateElement = (array2, flags, name2, decorators, target, extra22) => {
50
+ var __decorateElement = (array2, flags, name2, decorators, target, extra2) => {
51
51
  var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
52
52
  var j = k > 3 ? array2.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
53
53
  var initializers = k > 3 && (array2[j - 1] = []), extraInitializers = array2[j] || (array2[j] = []);
54
54
  var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name2]() {
55
- return __privateGet(this, extra22);
55
+ return __privateGet(this, extra2);
56
56
  }, set [name2](x) {
57
- return __privateSet(this, extra22, x);
57
+ return __privateSet(this, extra2, x);
58
58
  } }, name2));
59
- k ? p && k < 4 && __name(extra22, (k > 2 ? "set " : k > 1 ? "get " : "") + name2) : __name(target, name2);
59
+ k ? p && k < 4 && __name(extra2, (k > 2 ? "set " : k > 1 ? "get " : "") + name2) : __name(target, name2);
60
60
  for (var i = decorators.length - 1; i >= 0; i--) {
61
61
  ctx = __decoratorContext(k, name2, done = {}, array2[3], extraInitializers);
62
62
  if (k) {
63
63
  ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name2 in x };
64
- if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra22 : desc.get) : (x) => x[name2];
65
- if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra22 : desc.set) : (x, y) => x[name2] = y;
64
+ if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra2 : desc.get) : (x) => x[name2];
65
+ if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra2 : desc.set) : (x, y) => x[name2] = y;
66
66
  }
67
- it = (0, decorators[i])(k ? k < 4 ? p ? extra22 : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
68
- if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra22 = it : desc[key] = it : target = it);
67
+ it = (0, decorators[i])(k ? k < 4 ? p ? extra2 : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
68
+ if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra2 = it : desc[key] = it : target = it);
69
69
  else if (typeof it !== "object" || it === null) __typeError("Object expected");
70
70
  else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
71
71
  }
72
- return k || __decoratorMetadata(array2, target), desc && __defProp(target, name2, desc), p ? k ^ 4 ? extra22 : desc : target;
72
+ return k || __decoratorMetadata(array2, target), desc && __defProp(target, name2, desc), p ? k ^ 4 ? extra2 : desc : target;
73
73
  };
74
74
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
75
75
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
@@ -251,7 +251,7 @@ function deepEqual(a, b, strict) {
251
251
  return compare(a, b);
252
252
  }
253
253
  function tokenize(source, delimiters, delimiter) {
254
- const output22 = [];
254
+ const output2 = [];
255
255
  let state = 0;
256
256
  for (let i = 0; i < source.length; i++) {
257
257
  const code = source.charCodeAt(i);
@@ -259,29 +259,29 @@ function tokenize(source, delimiters, delimiter) {
259
259
  if (state === 1) {
260
260
  const next = source.charCodeAt(i + 1);
261
261
  if (next >= 97 && next <= 122) {
262
- output22.push(delimiter);
262
+ output2.push(delimiter);
263
263
  }
264
- output22.push(code + 32);
264
+ output2.push(code + 32);
265
265
  } else {
266
266
  if (state !== 0) {
267
- output22.push(delimiter);
267
+ output2.push(delimiter);
268
268
  }
269
- output22.push(code + 32);
269
+ output2.push(code + 32);
270
270
  }
271
271
  state = 1;
272
272
  } else if (code >= 97 && code <= 122) {
273
- output22.push(code);
273
+ output2.push(code);
274
274
  state = 2;
275
275
  } else if (delimiters.includes(code)) {
276
276
  if (state !== 0) {
277
- output22.push(delimiter);
277
+ output2.push(delimiter);
278
278
  }
279
279
  state = 0;
280
280
  } else {
281
- output22.push(code);
281
+ output2.push(code);
282
282
  }
283
283
  }
284
- return String.fromCharCode(...output22);
284
+ return String.fromCharCode(...output2);
285
285
  }
286
286
  function paramCase(source) {
287
287
  return tokenize(source, [45, 95], 45);
@@ -486,9 +486,9 @@ function createShadow(useSite, target, property2, receiver) {
486
486
  }
487
487
  function createShadowMethod(ctx, value, outer, shadow) {
488
488
  return new Proxy(value, {
489
- apply: (target, thisArg, args2) => {
489
+ apply: (target, thisArg, args) => {
490
490
  if (thisArg === outer) thisArg = shadow;
491
- return getTraceable(ctx, Reflect.apply(target, thisArg, args2));
491
+ return getTraceable(ctx, Reflect.apply(target, thisArg, args));
492
492
  }
493
493
  });
494
494
  }
@@ -537,21 +537,21 @@ function createTraceable(ctx, value, tracker) {
537
537
  const shadow = createShadow(useSite, target, tracker.property, receiver);
538
538
  return Reflect.set(target, prop, value2, shadow);
539
539
  },
540
- apply: (target, thisArg, args2) => {
540
+ apply: (target, thisArg, args) => {
541
541
  const receiver = tracker.noShadow ? proxy : createShadow(useSite, target, tracker.property, proxy);
542
- return applyTraceable(receiver, target, thisArg, args2);
542
+ return applyTraceable(receiver, target, thisArg, args);
543
543
  }
544
544
  });
545
545
  return proxy;
546
546
  }
547
- function applyTraceable(proxy, value, thisArg, args2) {
548
- if (!value[symbols.invoke]) return Reflect.apply(value, thisArg, args2);
549
- return value[symbols.invoke].apply(proxy, args2);
547
+ function applyTraceable(proxy, value, thisArg, args) {
548
+ if (!value[symbols.invoke]) return Reflect.apply(value, thisArg, args);
549
+ return value[symbols.invoke].apply(proxy, args);
550
550
  }
551
551
  function createCallable(name2, proto, tracker) {
552
- const self = function(...args2) {
552
+ const self = function(...args) {
553
553
  const proxy = createTraceable(self["ctx"], self, tracker);
554
- return Reflect.apply(proxy, this, args2);
554
+ return Reflect.apply(proxy, this, args);
555
555
  };
556
556
  defineProperty(self, "name", name2);
557
557
  return Object.setPrototypeOf(self, proto);
@@ -629,8 +629,8 @@ var ValidationError = class _ValidationError extends TypeError {
629
629
  * @param path — the standard-schema issue path; segments may be `{ key }` objects.
630
630
  * @returns the property keys, or an empty array when the issue has no path.
631
631
  */
632
- static normalizePath(path4 = []) {
633
- return path4.map((segment) => typeof segment === "object" ? segment.key : segment);
632
+ static normalizePath(path6 = []) {
633
+ return path6.map((segment) => typeof segment === "object" ? segment.key : segment);
634
634
  }
635
635
  /**
636
636
  * Format an issue path as a dotted string.
@@ -638,8 +638,8 @@ var ValidationError = class _ValidationError extends TypeError {
638
638
  * @param path — the standard-schema issue path.
639
639
  * @returns the keys joined with `.`.
640
640
  */
641
- static formatPath(path4) {
642
- return _ValidationError.normalizePath(path4).map(String).join(".");
641
+ static formatPath(path6) {
642
+ return _ValidationError.normalizePath(path6).map(String).join(".");
643
643
  }
644
644
  };
645
645
  Object.defineProperty(ValidationError.prototype, kValidationError, {
@@ -663,17 +663,17 @@ function runDisposable(dispose) {
663
663
  return effectInertia.get(dispose)?.() ?? result;
664
664
  }
665
665
  function emitPluginDisposed(context, fiber) {
666
- const args2 = ["internal/plugin", fiber];
666
+ const args = ["internal/plugin", fiber];
667
667
  let callbacks;
668
668
  try {
669
- callbacks = context.events.dispatch("emit", args2);
669
+ callbacks = context.events.dispatch("emit", args);
670
670
  } catch (error62) {
671
671
  context.logger.error(error62);
672
672
  return;
673
673
  }
674
674
  for (const callback of callbacks) {
675
675
  try {
676
- const returned = callback(...args2);
676
+ const returned = callback(...args);
677
677
  void Promise.resolve(returned).catch((error62) => context.logger.error(error62));
678
678
  } catch (error62) {
679
679
  context.logger.error(error62);
@@ -1257,11 +1257,11 @@ var EventsService = class {
1257
1257
  }
1258
1258
  ctx;
1259
1259
  _hooks = /* @__PURE__ */ Object.create(null);
1260
- _resolve(type, args2) {
1261
- const thisArg = typeof args2[0] === "object" || typeof args2[0] === "function" ? args2.shift() : null;
1262
- const name2 = args2.shift();
1260
+ _resolve(type, args) {
1261
+ const thisArg = typeof args[0] === "object" || typeof args[0] === "function" ? args.shift() : null;
1262
+ const name2 = args.shift();
1263
1263
  if ((typeof name2 !== "string" || !name2.startsWith("internal/")) && this._hooks["internal/dispatch"]?.length) {
1264
- this.emit("internal/dispatch", type, name2, args2, thisArg);
1264
+ this.emit("internal/dispatch", type, name2, args, thisArg);
1265
1265
  }
1266
1266
  const filter = thisArg?.[Context.filter];
1267
1267
  const callbacks = (this._hooks[name2] || []).filter((hook) => hook.global || !filter || filter.call(thisArg, hook.ctx)).map((hook) => hook.callback);
@@ -1274,8 +1274,8 @@ var EventsService = class {
1274
1274
  * @returns Matching callbacks bound to the dispatch receiver.
1275
1275
  * DSH retains callback enumeration for per-listener error containment.
1276
1276
  */
1277
- dispatch(type, args2) {
1278
- const [thisArg, callbacks] = this._resolve(type, args2);
1277
+ dispatch(type, args) {
1278
+ const [thisArg, callbacks] = this._resolve(type, args);
1279
1279
  return callbacks.map((callback) => callback.bind(thisArg));
1280
1280
  }
1281
1281
  /**
@@ -1284,9 +1284,9 @@ var EventsService = class {
1284
1284
  * @param args — optional `this`, the event name, then listener arguments.
1285
1285
  * @returns a promise resolving once every listener has settled.
1286
1286
  */
1287
- async parallel(...args2) {
1288
- const [thisArg, callbacks, name2] = this._resolve("parallel", args2);
1289
- const results = await Promise.allSettled(callbacks.map(async (callback) => Reflect.apply(callback, thisArg, args2)));
1287
+ async parallel(...args) {
1288
+ const [thisArg, callbacks, name2] = this._resolve("parallel", args);
1289
+ const results = await Promise.allSettled(callbacks.map(async (callback) => Reflect.apply(callback, thisArg, args)));
1290
1290
  const errors = results.filter((result) => result.status === "rejected");
1291
1291
  if (!errors.length) return;
1292
1292
  const label = typeof name2 === "symbol" ? String(name2) : `"${name2}"`;
@@ -1297,9 +1297,9 @@ var EventsService = class {
1297
1297
  *
1298
1298
  * @param args — optional `this`, the event name, then listener arguments.
1299
1299
  */
1300
- emit(...args2) {
1301
- const [thisArg, callbacks] = this._resolve("emit", args2);
1302
- for (const callback of callbacks) Reflect.apply(callback, thisArg, args2);
1300
+ emit(...args) {
1301
+ const [thisArg, callbacks] = this._resolve("emit", args);
1302
+ for (const callback of callbacks) Reflect.apply(callback, thisArg, args);
1303
1303
  }
1304
1304
  /**
1305
1305
  * Run listeners in order, awaiting each, until one returns a bail value.
@@ -1307,10 +1307,10 @@ var EventsService = class {
1307
1307
  * @param args — optional `this`, the event name, then listener arguments.
1308
1308
  * @returns the first bail value (see {@link isBailed}), if any.
1309
1309
  */
1310
- async serial(...args2) {
1311
- const [thisArg, callbacks] = this._resolve("serial", args2);
1310
+ async serial(...args) {
1311
+ const [thisArg, callbacks] = this._resolve("serial", args);
1312
1312
  for (const callback of callbacks) {
1313
- const result = await Reflect.apply(callback, thisArg, args2);
1313
+ const result = await Reflect.apply(callback, thisArg, args);
1314
1314
  if (isBailed(result)) return result;
1315
1315
  }
1316
1316
  }
@@ -1320,10 +1320,10 @@ var EventsService = class {
1320
1320
  * @param args — optional `this`, the event name, then listener arguments.
1321
1321
  * @returns the first bail value (see {@link isBailed}), if any.
1322
1322
  */
1323
- bail(...args2) {
1324
- const [thisArg, callbacks] = this._resolve("bail", args2);
1323
+ bail(...args) {
1324
+ const [thisArg, callbacks] = this._resolve("bail", args);
1325
1325
  for (const callback of callbacks) {
1326
- const result = Reflect.apply(callback, thisArg, args2);
1326
+ const result = Reflect.apply(callback, thisArg, args);
1327
1327
  if (isBailed(result)) return result;
1328
1328
  }
1329
1329
  }
@@ -1337,9 +1337,9 @@ var EventsService = class {
1337
1337
  * @param args — optional `this`, the event name, listener arguments, then `next`.
1338
1338
  * @returns the outermost listener's return value.
1339
1339
  */
1340
- waterfall(...args2) {
1341
- const [thisArg, callbacks] = this._resolve("waterfall", args2);
1342
- const inner = args2.pop();
1340
+ waterfall(...args) {
1341
+ const [thisArg, callbacks] = this._resolve("waterfall", args);
1342
+ const inner = args.pop();
1343
1343
  const dispatch = () => {
1344
1344
  const callback = callbacks.shift();
1345
1345
  if (!callback) return inner();
@@ -1349,7 +1349,7 @@ var EventsService = class {
1349
1349
  called = true;
1350
1350
  return dispatch();
1351
1351
  };
1352
- return Reflect.apply(callback, thisArg, [...args2, next]);
1352
+ return Reflect.apply(callback, thisArg, [...args, next]);
1353
1353
  };
1354
1354
  return dispatch();
1355
1355
  }
@@ -1402,9 +1402,9 @@ var EventsService = class {
1402
1402
  * @returns a disposer removing the listener; `true` if it was still registered.
1403
1403
  */
1404
1404
  once(name2, listener, options) {
1405
- const dispose = this.on(name2, function(...args2) {
1405
+ const dispose = this.on(name2, function(...args) {
1406
1406
  dispose();
1407
- return listener.apply(this, args2);
1407
+ return listener.apply(this, args);
1408
1408
  }, options);
1409
1409
  return dispose;
1410
1410
  }
@@ -1689,11 +1689,11 @@ var ReflectService = class {
1689
1689
  */
1690
1690
  bind(callback) {
1691
1691
  return new Proxy(callback, {
1692
- apply: (target, thisArg, args2) => {
1693
- return Reflect.apply(target, this.trace(thisArg), args2.map((arg) => this.trace(arg)));
1692
+ apply: (target, thisArg, args) => {
1693
+ return Reflect.apply(target, this.trace(thisArg), args.map((arg) => this.trace(arg)));
1694
1694
  },
1695
- construct: (target, args2, newTarget) => {
1696
- return Reflect.construct(target, args2.map((arg) => this.trace(arg)), newTarget);
1695
+ construct: (target, args, newTarget) => {
1696
+ return Reflect.construct(target, args.map((arg) => this.trace(arg)), newTarget);
1697
1697
  }
1698
1698
  });
1699
1699
  }
@@ -1857,25 +1857,25 @@ var Logger = class {
1857
1857
  return colors[Math.abs(hash2) % colors.length];
1858
1858
  }
1859
1859
  static format(exporter, message) {
1860
- const args2 = message.args.slice();
1861
- if (args2[0] instanceof Error) {
1862
- args2[0] = args2[0].stack || args2[0].message;
1863
- args2.unshift("%s");
1864
- } else if (typeof args2[0] !== "string") {
1865
- args2.unshift("%o");
1866
- }
1867
- let format = args2.shift();
1860
+ const args = message.args.slice();
1861
+ if (args[0] instanceof Error) {
1862
+ args[0] = args[0].stack || args[0].message;
1863
+ args.unshift("%s");
1864
+ } else if (typeof args[0] !== "string") {
1865
+ args.unshift("%o");
1866
+ }
1867
+ let format = args.shift();
1868
1868
  format = format.replace(/%([a-zA-Z%])/g, (match, char) => {
1869
1869
  if (match === "%%") return "%";
1870
1870
  const formatter = exporter.formatters?.[char] ?? defaultFormatters[char];
1871
1871
  if (typeof formatter === "function") {
1872
- const value = args2.shift();
1872
+ const value = args.shift();
1873
1873
  return formatter(value, exporter, message);
1874
1874
  }
1875
1875
  return match;
1876
1876
  });
1877
1877
  const oFormatter = exporter.formatters?.o ?? defaultFormatters.o;
1878
- for (let arg of args2) {
1878
+ for (let arg of args) {
1879
1879
  if (typeof arg === "object" && arg) {
1880
1880
  arg = oFormatter(arg, exporter, message);
1881
1881
  }
@@ -1887,12 +1887,12 @@ var Logger = class {
1887
1887
  }).join("\n");
1888
1888
  }
1889
1889
  _method(type, level) {
1890
- return (...args2) => {
1891
- if (args2.length === 1 && args2[0] instanceof Error) {
1892
- if (args2[0].cause) {
1893
- this[type](args2[0].cause);
1894
- } else if (isAggregateError(args2[0]) && args2[0].errors.length) {
1895
- args2[0].errors.forEach((error62) => this[type](error62));
1890
+ return (...args) => {
1891
+ if (args.length === 1 && args[0] instanceof Error) {
1892
+ if (args[0].cause) {
1893
+ this[type](args[0].cause);
1894
+ } else if (isAggregateError(args[0]) && args[0].errors.length) {
1895
+ args[0].errors.forEach((error62) => this[type](error62));
1896
1896
  return;
1897
1897
  }
1898
1898
  }
@@ -1901,7 +1901,7 @@ var Logger = class {
1901
1901
  for (const exporter of this.service.exporters.values()) {
1902
1902
  const targetLevel = exporter.levels?.[this.name] ?? exporter.levels?.default ?? this.level ?? 2;
1903
1903
  if (targetLevel < level) continue;
1904
- const message = { sn, ts, type, level, name: this.name, ...this.meta, args: args2 };
1904
+ const message = { sn, ts, type, level, name: this.name, ...this.meta, args };
1905
1905
  exporter.export(message);
1906
1906
  }
1907
1907
  };
@@ -2043,8 +2043,8 @@ var LoggerService = class _LoggerService {
2043
2043
  static {
2044
2044
  for (const type of ["error", "info", "warn", "debug"]) {
2045
2045
  ;
2046
- _LoggerService.prototype[type] = function(...args2) {
2047
- return this()[type](...args2);
2046
+ _LoggerService.prototype[type] = function(...args) {
2047
+ return this()[type](...args);
2048
2048
  };
2049
2049
  }
2050
2050
  }
@@ -2853,9 +2853,9 @@ var PartialArguments = class _PartialArguments {
2853
2853
  if (remaining[0] === "\\" && type === void 0 && entry.end < 0) return;
2854
2854
  if (remaining[0] === "\\" && type === "u") {
2855
2855
  const hex3 = this.slice(read.at + 2, Math.min(end, read.at + 6));
2856
- let valid2 = true;
2857
- for (let i = 0; i < hex3.length; i++) if (!isHex(hex3[i])) valid2 = false;
2858
- if (valid2) {
2856
+ let valid = true;
2857
+ for (let i = 0; i < hex3.length; i++) if (!isHex(hex3[i])) valid = false;
2858
+ if (valid) {
2859
2859
  if (hex3.length < 4 && entry.end < 0) return;
2860
2860
  if (hex3.length === 4) decoded = String.fromCharCode(Number.parseInt(hex3, 16));
2861
2861
  }
@@ -3328,10 +3328,10 @@ var EXCEEDS_MODEL_CONTEXT = new RegExp(
3328
3328
  "i"
3329
3329
  );
3330
3330
  function errorChain(value) {
3331
- const path4 = /* @__PURE__ */ new Set();
3331
+ const path6 = /* @__PURE__ */ new Set();
3332
3332
  const render = (current) => {
3333
- if (path4.has(current)) return "<circular cause>";
3334
- path4.add(current);
3333
+ if (path6.has(current)) return "<circular cause>";
3334
+ path6.add(current);
3335
3335
  try {
3336
3336
  if (!(current instanceof Error)) {
3337
3337
  if (typeof current === "object" && current !== null) {
@@ -3350,7 +3350,7 @@ function errorChain(value) {
3350
3350
  } catch {
3351
3351
  return "<unrenderable value>";
3352
3352
  } finally {
3353
- path4.delete(current);
3353
+ path6.delete(current);
3354
3354
  }
3355
3355
  };
3356
3356
  return render(value);
@@ -3396,25 +3396,25 @@ function requiredImageOffload(messages, budget2, versionBytes) {
3396
3396
  function freezeMessage(message) {
3397
3397
  return deepFreeze(structuredClone(message));
3398
3398
  }
3399
- function createMessage(input22) {
3399
+ function createMessage(input2) {
3400
3400
  return deepFreeze(structuredClone({
3401
- ...input22,
3401
+ ...input2,
3402
3402
  id: brandString(randomUUID())
3403
3403
  }));
3404
3404
  }
3405
- function createUserMessage(input22) {
3405
+ function createUserMessage(input2) {
3406
3406
  return createMessage({
3407
- ...input22,
3407
+ ...input2,
3408
3408
  role: "user"
3409
3409
  });
3410
3410
  }
3411
- function createAssistantMessage(input22) {
3411
+ function createAssistantMessage(input2) {
3412
3412
  return createMessage({
3413
3413
  role: "assistant",
3414
- content: input22.content,
3414
+ content: input2.content,
3415
3415
  source: {
3416
3416
  kind: "model",
3417
- ...input22.source
3417
+ ...input2.source
3418
3418
  }
3419
3419
  });
3420
3420
  }
@@ -3636,9 +3636,9 @@ Schema.prototype.simplify = function simplify(value) {
3636
3636
  Schema.prototype.toString = function toString(inline) {
3637
3637
  return formatters[this.type]?.(this, inline) ?? `Schema<${this.type}>`;
3638
3638
  };
3639
- Schema.prototype.role = function role(role, extra22) {
3639
+ Schema.prototype.role = function role(role, extra2) {
3640
3640
  const schema = Schema(this);
3641
- schema.meta = { ...schema.meta, role, extra: extra22 };
3641
+ schema.meta = { ...schema.meta, role, extra: extra2 };
3642
3642
  return schema;
3643
3643
  };
3644
3644
  for (const key of ["default", "link", "comment", "description", "max", "min", "step"]) {
@@ -3656,25 +3656,25 @@ Schema.prototype.volatile = function volatile() {
3656
3656
  };
3657
3657
  var resolvers = {};
3658
3658
  var checkedVolatile = /* @__PURE__ */ Symbol("checked-volatile-schema");
3659
- function validateVolatileSchema(schema, path4 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
3659
+ function validateVolatileSchema(schema, path6 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
3660
3660
  const states = seen.get(schema) ?? /* @__PURE__ */ new Set();
3661
3661
  if (states.has(blocked)) return;
3662
3662
  states.add(blocked);
3663
3663
  seen.set(schema, states);
3664
3664
  if (schema.meta?.volatile && blocked) {
3665
- throw new ValidationError2("volatile fields require a fixed object path without an enclosing volatile field", { path: path4 });
3665
+ throw new ValidationError2("volatile fields require a fixed object path without an enclosing volatile field", { path: path6 });
3666
3666
  }
3667
3667
  const nested = blocked || !!schema.meta?.volatile;
3668
3668
  if (schema.dict) {
3669
- for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path4, key], nested, seen);
3669
+ for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path6, key], nested, seen);
3670
3670
  }
3671
- if (schema.sKey) validateVolatileSchema(schema.sKey, [...path4, "<key>"], true, seen);
3671
+ if (schema.sKey) validateVolatileSchema(schema.sKey, [...path6, "<key>"], true, seen);
3672
3672
  if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) {
3673
- validateVolatileSchema(schema.inner, [...path4, "*"], true, seen);
3673
+ validateVolatileSchema(schema.inner, [...path6, "*"], true, seen);
3674
3674
  }
3675
3675
  if (schema.list) {
3676
3676
  for (let index = 0; index < schema.list.length; index++) {
3677
- validateVolatileSchema(schema.list[index], [...path4, String(index)], true, seen);
3677
+ validateVolatileSchema(schema.list[index], [...path6, String(index)], true, seen);
3678
3678
  }
3679
3679
  }
3680
3680
  }
@@ -4006,37 +4006,37 @@ var formatters = {};
4006
4006
  function defineMethod(name2, keys, format) {
4007
4007
  formatters[name2] = format;
4008
4008
  Object.assign(Schema, {
4009
- [name2](...args2) {
4009
+ [name2](...args) {
4010
4010
  const schema = new Schema({ type: name2 });
4011
4011
  keys.forEach((key, index) => {
4012
4012
  switch (key) {
4013
4013
  case "sKey":
4014
- schema.sKey = args2[index] ?? Schema.string();
4014
+ schema.sKey = args[index] ?? Schema.string();
4015
4015
  break;
4016
4016
  case "inner":
4017
- schema.inner = Schema.from(args2[index]);
4017
+ schema.inner = Schema.from(args[index]);
4018
4018
  break;
4019
4019
  case "list":
4020
- schema.list = args2[index].map(Schema.from);
4020
+ schema.list = args[index].map(Schema.from);
4021
4021
  break;
4022
4022
  case "dict":
4023
- schema.dict = mapValues(args2[index], Schema.from);
4023
+ schema.dict = mapValues(args[index], Schema.from);
4024
4024
  break;
4025
4025
  case "bits": {
4026
4026
  schema.bits = {};
4027
- for (const key2 in args2[index]) {
4028
- if (typeof args2[index][key2] !== "number") continue;
4029
- schema.bits[key2] = args2[index][key2];
4027
+ for (const key2 in args[index]) {
4028
+ if (typeof args[index][key2] !== "number") continue;
4029
+ schema.bits[key2] = args[index][key2];
4030
4030
  }
4031
4031
  break;
4032
4032
  }
4033
4033
  case "callback": {
4034
- const callback = schema.callback = args2[index];
4034
+ const callback = schema.callback = args[index];
4035
4035
  callback["toJSON"] ||= () => callback.toString();
4036
4036
  break;
4037
4037
  }
4038
4038
  case "constructor": {
4039
- const constructor = schema.constructor = args2[index];
4039
+ const constructor = schema.constructor = args[index];
4040
4040
  if (typeof constructor === "function") {
4041
4041
  ;
4042
4042
  constructor["toJSON"] ||= () => constructor["name"];
@@ -4044,7 +4044,7 @@ function defineMethod(name2, keys, format) {
4044
4044
  break;
4045
4045
  }
4046
4046
  default:
4047
- schema[key] = args2[index];
4047
+ schema[key] = args[index];
4048
4048
  }
4049
4049
  });
4050
4050
  if (name2 === "object" || name2 === "dict") {
@@ -4137,71 +4137,71 @@ var ALWAYS_POLICY_KEYS = /* @__PURE__ */ new Set([
4137
4137
  "backoff"
4138
4138
  ]);
4139
4139
  var BACKOFF_KEYS = /* @__PURE__ */ new Set(["initialDelayMs", "maxDelayMs", "jitterRatio"]);
4140
- function validateKeys(value, allowed, path4) {
4140
+ function validateKeys(value, allowed, path6) {
4141
4141
  for (const key of Object.keys(value)) {
4142
- if (!allowed.has(key)) throw new Error(`${path4}: unknown key "${key}"`);
4142
+ if (!allowed.has(key)) throw new Error(`${path6}: unknown key "${key}"`);
4143
4143
  }
4144
4144
  }
4145
- function resolveBackoff(config2, path4) {
4146
- if (config2 !== void 0) validateKeys(config2, BACKOFF_KEYS, path4);
4145
+ function resolveBackoff(config2, path6) {
4146
+ if (config2 !== void 0) validateKeys(config2, BACKOFF_KEYS, path6);
4147
4147
  const initialDelayMs = config2?.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;
4148
4148
  const maxDelayMs = config2?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
4149
4149
  const jitterRatio = config2?.jitterRatio ?? DEFAULT_JITTER_RATIO;
4150
4150
  if (!Number.isFinite(initialDelayMs) || initialDelayMs <= 0 || initialDelayMs > MAX_TIMER_DELAY_MS) {
4151
- throw new Error(`${path4}.initialDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4151
+ throw new Error(`${path6}.initialDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4152
4152
  }
4153
4153
  if (!Number.isFinite(maxDelayMs) || maxDelayMs <= 0 || maxDelayMs > MAX_TIMER_DELAY_MS) {
4154
- throw new Error(`${path4}.maxDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4154
+ throw new Error(`${path6}.maxDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4155
4155
  }
4156
4156
  if (initialDelayMs > maxDelayMs) {
4157
- throw new Error(`${path4}.initialDelayMs must be less than or equal to maxDelayMs`);
4157
+ throw new Error(`${path6}.initialDelayMs must be less than or equal to maxDelayMs`);
4158
4158
  }
4159
4159
  if (!Number.isFinite(jitterRatio) || jitterRatio < 0 || jitterRatio > 1) {
4160
- throw new Error(`${path4}.jitterRatio must be between 0 and 1`);
4160
+ throw new Error(`${path6}.jitterRatio must be between 0 and 1`);
4161
4161
  }
4162
4162
  return Object.freeze({ initialDelayMs, maxDelayMs, jitterRatio });
4163
4163
  }
4164
- function resolveRetryPolicy(config2, path4) {
4164
+ function resolveRetryPolicy(config2, path6) {
4165
4165
  if (config2 === void 0) {
4166
4166
  return Object.freeze({
4167
4167
  mode: "normal",
4168
4168
  maxRetries: DEFAULT_MAX_RETRIES,
4169
4169
  retryableCodes: DEFAULT_RETRYABLE_CODES,
4170
- ...resolveBackoff(void 0, `${path4}.backoff`)
4170
+ ...resolveBackoff(void 0, `${path6}.backoff`)
4171
4171
  });
4172
4172
  }
4173
4173
  switch (config2.mode) {
4174
4174
  case "normal": {
4175
- validateKeys(config2, NORMAL_POLICY_KEYS, path4);
4175
+ validateKeys(config2, NORMAL_POLICY_KEYS, path6);
4176
4176
  const maxRetries = config2.maxRetries ?? DEFAULT_MAX_RETRIES;
4177
4177
  const retryableCodes = config2.retryableCodes ?? [...DEFAULT_RETRYABLE_CODES];
4178
4178
  if (!Number.isSafeInteger(maxRetries) || maxRetries < 0) {
4179
- throw new Error(`${path4}.maxRetries must be a non-negative safe integer`);
4179
+ throw new Error(`${path6}.maxRetries must be a non-negative safe integer`);
4180
4180
  }
4181
4181
  if (retryableCodes.length === 0) {
4182
- throw new Error(`${path4}.retryableCodes must not be empty`);
4182
+ throw new Error(`${path6}.retryableCodes must not be empty`);
4183
4183
  }
4184
4184
  if (retryableCodes.some((code) => typeof code !== "string" || code.length === 0)) {
4185
- throw new Error(`${path4}.retryableCodes must contain only non-empty strings`);
4185
+ throw new Error(`${path6}.retryableCodes must contain only non-empty strings`);
4186
4186
  }
4187
4187
  if (new Set(retryableCodes).size !== retryableCodes.length) {
4188
- throw new Error(`${path4}.retryableCodes must not contain duplicates`);
4188
+ throw new Error(`${path6}.retryableCodes must not contain duplicates`);
4189
4189
  }
4190
4190
  return Object.freeze({
4191
4191
  mode: "normal",
4192
4192
  maxRetries,
4193
4193
  retryableCodes: Object.freeze([...retryableCodes]),
4194
- ...resolveBackoff(config2.backoff, `${path4}.backoff`)
4194
+ ...resolveBackoff(config2.backoff, `${path6}.backoff`)
4195
4195
  });
4196
4196
  }
4197
4197
  case "always":
4198
- validateKeys(config2, ALWAYS_POLICY_KEYS, path4);
4198
+ validateKeys(config2, ALWAYS_POLICY_KEYS, path6);
4199
4199
  return Object.freeze({
4200
4200
  mode: "always",
4201
- ...resolveBackoff(config2.backoff, `${path4}.backoff`)
4201
+ ...resolveBackoff(config2.backoff, `${path6}.backoff`)
4202
4202
  });
4203
4203
  default:
4204
- throw new Error(`${path4}.mode must be "normal" or "always"`);
4204
+ throw new Error(`${path6}.mode must be "normal" or "always"`);
4205
4205
  }
4206
4206
  }
4207
4207
  function callConfigEquals(a, b) {
@@ -4301,8 +4301,8 @@ function normalizedAccessText(ref, access) {
4301
4301
  return ` Normalized copy (read-only; may be resized or re-encoded): ${quoted(access.readonlyPath)} (${ref.width}x${ref.height}px, ${ref.mediaType}). Source dimensions, format, and byte size may differ. Copy to a writable path ending in ${extension(ref.mediaType)} before editing.`;
4302
4302
  }
4303
4303
  function textOnlyImageText(ref) {
4304
- const digest3 = String(ref.attachmentId).slice("sha256:".length, "sha256:".length + 8);
4305
- return `[image omitted because this model accepts text only; attachment sha256:${digest3}]`;
4304
+ const digest32 = String(ref.attachmentId).slice("sha256:".length, "sha256:".length + 8);
4305
+ return `[image omitted because this model accepts text only; attachment sha256:${digest32}]`;
4306
4306
  }
4307
4307
  function requestImageHandleText(ref, version3, access) {
4308
4308
  const preview = `Image ${imageIdentity(ref)}; request preview ${version3.width}x${version3.height}px.`;
@@ -4325,8 +4325,8 @@ function contentHasFile(content) {
4325
4325
  return false;
4326
4326
  }
4327
4327
  function fileHandleText(ref, readonlyPath) {
4328
- const digest3 = String(ref.attachmentId).slice("sha256:".length, "sha256:".length + 8);
4329
- const identity2 = `File ${quoted(ref.name)} (${ref.bytes} bytes, sha256:${digest3})`;
4328
+ const digest32 = String(ref.attachmentId).slice("sha256:".length, "sha256:".length + 8);
4329
+ const identity2 = `File ${quoted(ref.name)} (${ref.bytes} bytes, sha256:${digest32})`;
4330
4330
  if (readonlyPath === void 0) {
4331
4331
  return `[${identity2} was uploaded, but the current execution environment cannot access a readable path. Report that limitation if its contents are needed; do not claim to have read it.]`;
4332
4332
  }
@@ -5245,8 +5245,8 @@ var LlmRuntime = class extends (_a = TypertRemoteService, _listProviders_dec = [
5245
5245
  return void 0;
5246
5246
  }
5247
5247
  if (hostPath === void 0) return void 0;
5248
- const fs4 = this.ctx.get("fs");
5249
- return fs4?.processPathFromHostPath(hostPath);
5248
+ const fs7 = this.ctx.get("fs");
5249
+ return fs7?.processPathFromHostPath(hostPath);
5250
5250
  }
5251
5251
  /**
5252
5252
  * Final adapter boundary. Adapter selection, dispatch, iterator construction,
@@ -5494,10 +5494,10 @@ var AttachmentStore = class extends Service {
5494
5494
  */
5495
5495
  validateImageBatch(inputs) {
5496
5496
  const limits = this.imageLimits;
5497
- assertMessageImages(limits, inputs.length, inputs.reduce((sum, input22) => sum + input22.data.byteLength, 0));
5498
- for (const input22 of inputs) {
5499
- if (!limits.mediaTypes.includes(input22.mediaType)) {
5500
- throw new AttachmentError(`Image type ${input22.mediaType} is not accepted by this deployment.`, "UNSUPPORTED_IMAGE_TYPE");
5497
+ assertMessageImages(limits, inputs.length, inputs.reduce((sum, input2) => sum + input2.data.byteLength, 0));
5498
+ for (const input2 of inputs) {
5499
+ if (!limits.mediaTypes.includes(input2.mediaType)) {
5500
+ throw new AttachmentError(`Image type ${input2.mediaType} is not accepted by this deployment.`, "UNSUPPORTED_IMAGE_TYPE");
5501
5501
  }
5502
5502
  }
5503
5503
  }
@@ -5508,9 +5508,9 @@ var AttachmentStore = class extends Service {
5508
5508
  */
5509
5509
  async saveImages(inputs) {
5510
5510
  this.validateImageBatch(inputs);
5511
- for (const input22 of inputs) await this.validateImage(input22);
5511
+ for (const input2 of inputs) await this.validateImage(input2);
5512
5512
  const refs = [];
5513
- for (const input22 of inputs) refs.push(await this.saveImage(input22));
5513
+ for (const input2 of inputs) refs.push(await this.saveImage(input2));
5514
5514
  return refs;
5515
5515
  }
5516
5516
  /**
@@ -5548,8 +5548,8 @@ var AttachmentStore = class extends Service {
5548
5548
  * @returns the durable content-addressed file reference.
5549
5549
  * @throws AttachmentError when the encoding or storage operation is refused.
5550
5550
  */
5551
- admitEncodedFile(input22) {
5552
- return admitEncodedFile(this, input22);
5551
+ admitEncodedFile(input2) {
5552
+ return admitEncodedFile(this, input2);
5553
5553
  }
5554
5554
  /**
5555
5555
  * Identify a failure emitted by this attachment capability by its stable code.
@@ -5577,8 +5577,8 @@ var AttachmentStore = class extends Service {
5577
5577
  * @param input - exact bytes and optional display name.
5578
5578
  * @returns the durable content-addressed file reference.
5579
5579
  */
5580
- saveFile(input22) {
5581
- void input22;
5580
+ saveFile(input2) {
5581
+ void input2;
5582
5582
  return Promise.reject(new AttachmentError(
5583
5583
  "The mounted attachment provider cannot store verbatim files.",
5584
5584
  "ATTACHMENT_FILES_UNSUPPORTED"
@@ -5591,8 +5591,8 @@ var AttachmentStore = class extends Service {
5591
5591
  * @param input - ordered exact bytes, optional cancellation, and display name.
5592
5592
  * @returns the durable content-addressed file reference.
5593
5593
  */
5594
- saveFileStream(input22) {
5595
- void input22;
5594
+ saveFileStream(input2) {
5595
+ void input2;
5596
5596
  return Promise.reject(new AttachmentError(
5597
5597
  "The mounted attachment provider cannot stream verbatim files.",
5598
5598
  "ATTACHMENT_FILES_UNSUPPORTED"
@@ -5649,10 +5649,10 @@ var DEFAULT_AGENTS_HOME_DISPLAY = `~/${AGENTS_HOME_DIR_NAME}`;
5649
5649
  function defaultDshHome() {
5650
5650
  return join(homedir(), DSH_HOME_DIR_NAME);
5651
5651
  }
5652
- function expandHomePath(path4) {
5653
- if (path4 === "~") return homedir();
5654
- if (path4.startsWith("~/") || path4.startsWith("~\\")) return join(homedir(), path4.slice(2));
5655
- return path4;
5652
+ function expandHomePath(path6) {
5653
+ if (path6 === "~") return homedir();
5654
+ if (path6.startsWith("~/") || path6.startsWith("~\\")) return join(homedir(), path6.slice(2));
5655
+ return path6;
5656
5656
  }
5657
5657
  function resolveRoot(configured, env, envName, fallback) {
5658
5658
  const fromEnv = env[envName];
@@ -5753,8 +5753,8 @@ function createLazyRequire(specifier, parentURL) {
5753
5753
  };
5754
5754
  }
5755
5755
  var requireSharp = createLazyRequire("sharp", import.meta.url);
5756
- function encodedAlphaIsCompatible(sourceHasAlpha, output22) {
5757
- return sourceHasAlpha === void 0 || output22.hasAlpha === sourceHasAlpha || sourceHasAlpha && !output22.hasAlpha && output22.mediaType === "image/webp";
5756
+ function encodedAlphaIsCompatible(sourceHasAlpha, output2) {
5757
+ return sourceHasAlpha === void 0 || output2.hasAlpha === sourceHasAlpha || sourceHasAlpha && !output2.hasAlpha && output2.mediaType === "image/webp";
5758
5758
  }
5759
5759
  var MEDIA_TYPES = {
5760
5760
  png: "image/png",
@@ -5885,17 +5885,17 @@ async function inspectMetadata(data, declaredMediaType, limits) {
5885
5885
  if (detected.mediaType !== declaredMediaType) throw new AttachmentError("Declared image type does not match its bytes.", "IMAGE_TYPE_MISMATCH");
5886
5886
  return detected;
5887
5887
  }
5888
- async function validateImageFile(input22, limits, policy) {
5889
- await prepareImageFile(input22, limits, policy);
5888
+ async function validateImageFile(input2, limits, policy) {
5889
+ await prepareImageFile(input2, limits, policy);
5890
5890
  }
5891
- async function prepareImageFile(input22, limits, policy) {
5892
- if (input22.data.byteLength > limits.maxImageBytes) {
5891
+ async function prepareImageFile(input2, limits, policy) {
5892
+ if (input2.data.byteLength > limits.maxImageBytes) {
5893
5893
  throw new AttachmentError("Image exceeds the configured byte limit.", "IMAGE_TOO_LARGE");
5894
5894
  }
5895
- const detected = await inspectMetadata(input22.data, input22.mediaType, limits);
5896
- const normalized = await normalizeImage(input22.data, detected, policy);
5895
+ const detected = await inspectMetadata(input2.data, input2.mediaType, limits);
5896
+ const normalized = await normalizeImage(input2.data, detected, policy);
5897
5897
  const sha256 = digest(normalized.data);
5898
- const name2 = displayName(input22.name);
5898
+ const name2 = displayName(input2.name);
5899
5899
  const downscaled = detected.width !== normalized.width || detected.height !== normalized.height;
5900
5900
  return {
5901
5901
  data: normalized.data,
@@ -5910,17 +5910,17 @@ async function prepareImageFile(input22, limits, policy) {
5910
5910
  }
5911
5911
  };
5912
5912
  }
5913
- async function syncDirectory(path4) {
5913
+ async function syncDirectory(path6) {
5914
5914
  if (process.platform === "win32") return;
5915
- const handle = await open(path4, constants.O_RDONLY);
5915
+ const handle = await open(path6, constants.O_RDONLY);
5916
5916
  try {
5917
5917
  await handle.sync();
5918
5918
  } finally {
5919
5919
  await handle.close();
5920
5920
  }
5921
5921
  }
5922
- async function ensureDurableDirectory(path4, boundary) {
5923
- const target = resolve3(path4);
5922
+ async function ensureDurableDirectory(path6, boundary) {
5923
+ const target = resolve3(path6);
5924
5924
  const stop = resolve3(boundary);
5925
5925
  await mkdir(target, { recursive: true, mode: 448 });
5926
5926
  await chmod(target, 448);
@@ -5932,8 +5932,8 @@ async function ensureDurableDirectory(path4, boundary) {
5932
5932
  level = parent;
5933
5933
  }
5934
5934
  }
5935
- async function ensureDurableHome(path4) {
5936
- const home = resolve3(path4);
5935
+ async function ensureDurableHome(path6) {
5936
+ const home = resolve3(path6);
5937
5937
  if (!durableHomes.has(home)) {
5938
5938
  await ensureDurableDirectory(home, parse(home).root);
5939
5939
  durableHomes.add(home);
@@ -6053,13 +6053,13 @@ async function publishStagedObject(root, target, staged) {
6053
6053
  throw new AttachmentError("Unable to persist attachment.", "ATTACHMENT_WRITE_FAILED", { cause: error62 });
6054
6054
  }
6055
6055
  }
6056
- async function digestFile(path4) {
6056
+ async function digestFile(path6) {
6057
6057
  const hash2 = createHash("sha256");
6058
- for await (const chunk of createReadStream(path4)) hash2.update(chunk);
6058
+ for await (const chunk of createReadStream(path6)) hash2.update(chunk);
6059
6059
  return hash2.digest("hex");
6060
6060
  }
6061
- async function removeTemporary(path4) {
6062
- await unlink(path4).catch(
6061
+ async function removeTemporary(path6) {
6062
+ await unlink(path6).catch(
6063
6063
  /* v8 ignore next -- Cleanup can observe a staging name already removed after successful linking. */
6064
6064
  (cleanupError) => {
6065
6065
  if (!(cleanupError instanceof Error && "code" in cleanupError && cleanupError.code === "ENOENT")) throw cleanupError;
@@ -6126,39 +6126,39 @@ function storedFilePath(root, ref) {
6126
6126
  function storedFileObjectPath(root, sha256) {
6127
6127
  return join3(root, "file-objects", sha256.slice(0, 2), sha256);
6128
6128
  }
6129
- async function saveFileVerbatim(root, input22) {
6130
- const sha256 = createHash2("sha256").update(input22.data).digest("hex");
6129
+ async function saveFileVerbatim(root, input2) {
6130
+ const sha256 = createHash2("sha256").update(input2.data).digest("hex");
6131
6131
  const ref = {
6132
6132
  attachmentId: brandString(`sha256:${sha256}`),
6133
- name: fileLeafName(input22.name),
6134
- bytes: input22.data.byteLength
6133
+ name: fileLeafName(input2.name),
6134
+ bytes: input2.data.byteLength
6135
6135
  };
6136
6136
  const objectPath = storedFileObjectPath(root, sha256);
6137
- await publishImmutableObject(root, objectPath, input22.data, sha256);
6137
+ await publishImmutableObject(root, objectPath, input2.data, sha256);
6138
6138
  await publishImmutableAlias(root, objectPath, storedFilePath(root, ref), sha256);
6139
6139
  return ref;
6140
6140
  }
6141
- async function saveFileStreamVerbatim(root, input22) {
6142
- const name2 = fileLeafName(input22.name);
6141
+ async function saveFileStreamVerbatim(root, input2) {
6142
+ const name2 = fileLeafName(input2.name);
6143
6143
  const stored = await publishImmutableObjectStream(
6144
6144
  root,
6145
- input22.data,
6145
+ input2.data,
6146
6146
  (sha256) => storedFileObjectPath(root, sha256),
6147
- input22.signal
6147
+ input2.signal
6148
6148
  );
6149
6149
  const ref = {
6150
6150
  attachmentId: brandString(`sha256:${stored.sha256}`),
6151
6151
  name: name2,
6152
6152
  bytes: stored.bytes
6153
6153
  };
6154
- input22.signal?.throwIfAborted();
6154
+ input2.signal?.throwIfAborted();
6155
6155
  await publishImmutableAlias(
6156
6156
  root,
6157
6157
  storedFileObjectPath(root, stored.sha256),
6158
6158
  storedFilePath(root, ref),
6159
6159
  stored.sha256
6160
6160
  );
6161
- input22.signal?.throwIfAborted();
6161
+ input2.signal?.throwIfAborted();
6162
6162
  return ref;
6163
6163
  }
6164
6164
  async function* readFileStreamVerbatim(root, ref, signal) {
@@ -6278,9 +6278,9 @@ async function createRequestImage(attachment, target, hasAlpha, policy, signal)
6278
6278
  function cachePath(root, hash2) {
6279
6279
  return join4(root, "request-images", hash2.slice(0, 2), hash2);
6280
6280
  }
6281
- async function readCached(path4, target, expectedAlpha, signal) {
6281
+ async function readCached(path6, target, expectedAlpha, signal) {
6282
6282
  try {
6283
- const data = new Uint8Array(await readFile2(path4, { signal }));
6283
+ const data = new Uint8Array(await readFile2(path6, { signal }));
6284
6284
  if (data.byteLength > target.maxImageBytes) return void 0;
6285
6285
  const detected = await probeImage(data);
6286
6286
  if (detected.depth !== "uchar" || detected.space !== "srgb" || detected.width > target.width || detected.height > target.height || !encodedAlphaIsCompatible(expectedAlpha, detected)) return void 0;
@@ -6301,12 +6301,12 @@ async function verifyRequestImage(image, expectedAlpha) {
6301
6301
  }
6302
6302
  return { ...image, hasAlpha: detected.hasAlpha };
6303
6303
  }
6304
- async function writeCached(path4, data) {
6305
- await mkdir2(dirname3(path4), { recursive: true, mode: 448 });
6306
- const temporary = `${path4}.${randomUUID3()}.tmp`;
6304
+ async function writeCached(path6, data) {
6305
+ await mkdir2(dirname3(path6), { recursive: true, mode: 448 });
6306
+ const temporary = `${path6}.${randomUUID3()}.tmp`;
6307
6307
  try {
6308
6308
  await writeFile(temporary, data, { mode: 384, flag: "wx" });
6309
- await rename(temporary, path4);
6309
+ await rename(temporary, path6);
6310
6310
  } finally {
6311
6311
  await rm(temporary, { force: true });
6312
6312
  }
@@ -6317,12 +6317,12 @@ async function readRequestImageFile(root, attachment, target, policy, signal) {
6317
6317
  const source = await probeImage(attachment.data);
6318
6318
  const variantId = requestImageVariantId(attachment.ref, target, policy);
6319
6319
  const hash2 = String(variantId).slice("sha256:".length);
6320
- const path4 = cachePath(root, hash2);
6321
- const cached2 = await readCached(path4, target, source.hasAlpha, signal);
6320
+ const path6 = cachePath(root, hash2);
6321
+ const cached2 = await readCached(path6, target, source.hasAlpha, signal);
6322
6322
  const created = cached2 ?? await createRequestImage(attachment, target, source.hasAlpha, policy, signal);
6323
6323
  const version3 = cached2 ?? (created.data === attachment.data ? { ...created, hasAlpha: source.hasAlpha } : await verifyRequestImage(created, source.hasAlpha));
6324
6324
  signal?.throwIfAborted();
6325
- if (cached2 === void 0 && version3.data !== attachment.data) await writeCached(path4, version3.data);
6325
+ if (cached2 === void 0 && version3.data !== attachment.data) await writeCached(path6, version3.data);
6326
6326
  return {
6327
6327
  variantId,
6328
6328
  attachment: attachment.ref,
@@ -6462,21 +6462,21 @@ var LocalAttachmentStore = class extends AttachmentStore {
6462
6462
  this.imageCompressionConcurrency = compressionConcurrency;
6463
6463
  this.compression = new CompressionLimiter(compressionConcurrency);
6464
6464
  }
6465
- async validateImage(input22) {
6466
- await this.compression.run(() => validateImageFile(input22, this.imageLimits, this.normalizationPolicy));
6465
+ async validateImage(input2) {
6466
+ await this.compression.run(() => validateImageFile(input2, this.imageLimits, this.normalizationPolicy));
6467
6467
  }
6468
6468
  async saveImages(inputs) {
6469
6469
  this.validateImageBatch(inputs);
6470
- const prepared = await Promise.all(inputs.map((input22) => this.compression.run(
6471
- () => prepareImageFile(input22, this.imageLimits, this.normalizationPolicy)
6470
+ const prepared = await Promise.all(inputs.map((input2) => this.compression.run(
6471
+ () => prepareImageFile(input2, this.imageLimits, this.normalizationPolicy)
6472
6472
  )));
6473
6473
  const refs = [];
6474
6474
  for (const image of prepared) refs.push(await commitPreparedImageFile(this.root, image));
6475
6475
  return refs;
6476
6476
  }
6477
- async saveImage(input22) {
6477
+ async saveImage(input2) {
6478
6478
  const prepared = await this.compression.run(
6479
- () => prepareImageFile(input22, this.imageLimits, this.normalizationPolicy)
6479
+ () => prepareImageFile(input2, this.imageLimits, this.normalizationPolicy)
6480
6480
  );
6481
6481
  return commitPreparedImageFile(this.root, prepared);
6482
6482
  }
@@ -6486,11 +6486,11 @@ var LocalAttachmentStore = class extends AttachmentStore {
6486
6486
  imageHostPath(ref) {
6487
6487
  return normalizedImagePath(this.root, ref);
6488
6488
  }
6489
- async saveFile(input22) {
6490
- return saveFileVerbatim(this.root, input22);
6489
+ async saveFile(input2) {
6490
+ return saveFileVerbatim(this.root, input2);
6491
6491
  }
6492
- async saveFileStream(input22) {
6493
- return saveFileStreamVerbatim(this.root, input22);
6492
+ async saveFileStream(input2) {
6493
+ return saveFileStreamVerbatim(this.root, input2);
6494
6494
  }
6495
6495
  readFileStream(ref, signal) {
6496
6496
  return readFileStreamVerbatim(this.root, ref, signal);
@@ -7436,8 +7436,8 @@ var Cached = class {
7436
7436
  function cached(getter) {
7437
7437
  return new Cached(getter);
7438
7438
  }
7439
- function nullish(input22) {
7440
- return input22 === null || input22 === void 0;
7439
+ function nullish(input2) {
7440
+ return input2 === null || input2 === void 0;
7441
7441
  }
7442
7442
  function cleanRegex(source) {
7443
7443
  const start = source.startsWith("^") ? 1 : 0;
@@ -7547,10 +7547,10 @@ function mergeDefs(...defs) {
7547
7547
  function cloneDef(schema) {
7548
7548
  return mergeDefs(schema._zod.def);
7549
7549
  }
7550
- function getElementAtPath(obj, path4) {
7551
- if (!path4)
7550
+ function getElementAtPath(obj, path6) {
7551
+ if (!path6)
7552
7552
  return obj;
7553
- return path4.reduce((acc, key) => acc?.[key], obj);
7553
+ return path6.reduce((acc, key) => acc?.[key], obj);
7554
7554
  }
7555
7555
  function promiseAllObject(promisesObj) {
7556
7556
  const keys = Object.keys(promisesObj);
@@ -7574,8 +7574,8 @@ function randomString(length = 10) {
7574
7574
  function esc(str) {
7575
7575
  return JSON.stringify(str);
7576
7576
  }
7577
- function slugify(input22) {
7578
- return input22.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
7577
+ function slugify(input2) {
7578
+ return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
7579
7579
  }
7580
7580
  var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
7581
7581
  };
@@ -7890,11 +7890,11 @@ function explicitlyAborted(x, startIndex = 0) {
7890
7890
  }
7891
7891
  return false;
7892
7892
  }
7893
- function prefixIssues(path4, issues) {
7893
+ function prefixIssues(path6, issues) {
7894
7894
  return issues.map((iss) => {
7895
7895
  var _a4;
7896
7896
  (_a4 = iss).path ?? (_a4.path = []);
7897
- iss.path.unshift(path4);
7897
+ iss.path.unshift(path6);
7898
7898
  return iss;
7899
7899
  });
7900
7900
  }
@@ -7943,12 +7943,12 @@ function finalizeIssue(iss, ctx, config2) {
7943
7943
  }
7944
7944
  return full;
7945
7945
  }
7946
- function getSizableOrigin(input22) {
7947
- if (input22 instanceof Set)
7946
+ function getSizableOrigin(input2) {
7947
+ if (input2 instanceof Set)
7948
7948
  return "set";
7949
- if (input22 instanceof Map)
7949
+ if (input2 instanceof Map)
7950
7950
  return "map";
7951
- if (input22 instanceof File)
7951
+ if (input2 instanceof File)
7952
7952
  return "file";
7953
7953
  return "unknown";
7954
7954
  }
@@ -7966,10 +7966,10 @@ function codePointLength(str) {
7966
7966
  }
7967
7967
  return count;
7968
7968
  }
7969
- function getLengthableOrigin(input22) {
7970
- if (Array.isArray(input22))
7969
+ function getLengthableOrigin(input2) {
7970
+ if (Array.isArray(input2))
7971
7971
  return "array";
7972
- if (typeof input22 === "string")
7972
+ if (typeof input2 === "string")
7973
7973
  return "string";
7974
7974
  return "unknown";
7975
7975
  }
@@ -7994,13 +7994,13 @@ function parsedType(data) {
7994
7994
  }
7995
7995
  return t;
7996
7996
  }
7997
- function issue(...args2) {
7998
- const [iss, input22, inst] = args2;
7997
+ function issue(...args) {
7998
+ const [iss, input2, inst] = args;
7999
7999
  if (typeof iss === "string") {
8000
8000
  return {
8001
8001
  message: iss,
8002
8002
  code: "custom",
8003
- input: input22,
8003
+ input: input2,
8004
8004
  inst
8005
8005
  };
8006
8006
  }
@@ -8352,16 +8352,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
8352
8352
  }
8353
8353
  function formatError(error62, mapper = (issue2) => issue2.message) {
8354
8354
  const fieldErrors = { _errors: [] };
8355
- const processError = (error63, path4 = []) => {
8355
+ const processError = (error63, path6 = []) => {
8356
8356
  for (const issue2 of error63.issues) {
8357
8357
  if (issue2.code === "invalid_union" && issue2.errors.length) {
8358
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
8358
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
8359
8359
  } else if (issue2.code === "invalid_key") {
8360
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8360
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
8361
8361
  } else if (issue2.code === "invalid_element") {
8362
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8362
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
8363
8363
  } else {
8364
- const fullpath = [...path4, ...issue2.path];
8364
+ const fullpath = [...path6, ...issue2.path];
8365
8365
  if (fullpath.length === 0) {
8366
8366
  fieldErrors._errors.push(mapper(issue2));
8367
8367
  } else {
@@ -8400,17 +8400,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
8400
8400
  }
8401
8401
  function treeifyError(error62, mapper = (issue2) => issue2.message) {
8402
8402
  const result = { errors: [] };
8403
- const processError = (error63, path4 = []) => {
8403
+ const processError = (error63, path6 = []) => {
8404
8404
  var _a4;
8405
8405
  for (const issue2 of error63.issues) {
8406
8406
  if (issue2.code === "invalid_union" && issue2.errors.length) {
8407
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
8407
+ issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
8408
8408
  } else if (issue2.code === "invalid_key") {
8409
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8409
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
8410
8410
  } else if (issue2.code === "invalid_element") {
8411
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8411
+ processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
8412
8412
  } else {
8413
- const fullpath = [...path4, ...issue2.path];
8413
+ const fullpath = [...path6, ...issue2.path];
8414
8414
  if (fullpath.length === 0) {
8415
8415
  result.errors.push(mapper(issue2));
8416
8416
  continue;
@@ -8449,8 +8449,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
8449
8449
  }
8450
8450
  function toDotPath(_path) {
8451
8451
  const segs = [];
8452
- const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
8453
- for (const seg of path4) {
8452
+ const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
8453
+ for (const seg of path6) {
8454
8454
  if (typeof seg === "number")
8455
8455
  segs.push(`[${seg}]`);
8456
8456
  else if (typeof seg === "symbol")
@@ -8752,20 +8752,20 @@ function anchor(source) {
8752
8752
  return new RegExp(`^${source}$`);
8753
8753
  }
8754
8754
  var date2 = /* @__PURE__ */ anchor(dateSource);
8755
- function timeSource(args2) {
8755
+ function timeSource(args) {
8756
8756
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
8757
- const regex = typeof args2.precision === "number" ? args2.precision === -1 ? `${hhmm}` : args2.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args2.precision}}` : args2.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
8757
+ const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
8758
8758
  return regex;
8759
8759
  }
8760
- function time(args2) {
8761
- return new RegExp(`^${timeSource(args2)}$`);
8760
+ function time(args) {
8761
+ return new RegExp(`^${timeSource(args)}$`);
8762
8762
  }
8763
- function datetime(args2) {
8763
+ function datetime(args) {
8764
8764
  const opts = ["Z"];
8765
- if (args2.offset)
8765
+ if (args.offset)
8766
8766
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
8767
- const qualified = `${timeSource({ precision: args2.precision, seconds: true })}(?:${opts.join("|")})`;
8768
- const timeRegex = args2.local ? `${qualified}|${timeSource({ precision: args2.precision })}` : qualified;
8767
+ const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
8768
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
8769
8769
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
8770
8770
  }
8771
8771
  var anyString = /^[\s\S]{0,}$/;
@@ -8886,23 +8886,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8886
8886
  const origin = isInt ? "int" : "number";
8887
8887
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
8888
8888
  inst._zod.check = (payload) => {
8889
- const input22 = payload.value;
8889
+ const input2 = payload.value;
8890
8890
  if (isInt) {
8891
- if (!Number.isInteger(input22)) {
8891
+ if (!Number.isInteger(input2)) {
8892
8892
  payload.issues.push({
8893
8893
  expected: origin,
8894
8894
  format: def.format,
8895
8895
  code: "invalid_type",
8896
8896
  continue: false,
8897
- input: input22,
8897
+ input: input2,
8898
8898
  inst
8899
8899
  });
8900
8900
  return;
8901
8901
  }
8902
- if (!Number.isSafeInteger(input22)) {
8903
- if (input22 > 0) {
8902
+ if (!Number.isSafeInteger(input2)) {
8903
+ if (input2 > 0) {
8904
8904
  payload.issues.push({
8905
- input: input22,
8905
+ input: input2,
8906
8906
  code: "too_big",
8907
8907
  maximum: Number.MAX_SAFE_INTEGER,
8908
8908
  note: "Integers must be within the safe integer range.",
@@ -8913,7 +8913,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8913
8913
  });
8914
8914
  } else {
8915
8915
  payload.issues.push({
8916
- input: input22,
8916
+ input: input2,
8917
8917
  code: "too_small",
8918
8918
  minimum: Number.MIN_SAFE_INTEGER,
8919
8919
  note: "Integers must be within the safe integer range.",
@@ -8926,10 +8926,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8926
8926
  return;
8927
8927
  }
8928
8928
  }
8929
- if (input22 < minimum) {
8929
+ if (input2 < minimum) {
8930
8930
  payload.issues.push({
8931
8931
  origin: "number",
8932
- input: input22,
8932
+ input: input2,
8933
8933
  code: "too_small",
8934
8934
  minimum,
8935
8935
  inclusive: true,
@@ -8937,10 +8937,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8937
8937
  continue: !def.abort
8938
8938
  });
8939
8939
  }
8940
- if (input22 > maximum) {
8940
+ if (input2 > maximum) {
8941
8941
  payload.issues.push({
8942
8942
  origin: "number",
8943
- input: input22,
8943
+ input: input2,
8944
8944
  code: "too_big",
8945
8945
  maximum,
8946
8946
  inclusive: true,
@@ -8954,11 +8954,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
8954
8954
  $ZodCheck.init(inst, def);
8955
8955
  const [minimum, maximum] = BIGINT_FORMAT_RANGES[def.format];
8956
8956
  inst._zod.check = (payload) => {
8957
- const input22 = payload.value;
8958
- if (input22 < minimum) {
8957
+ const input2 = payload.value;
8958
+ if (input2 < minimum) {
8959
8959
  payload.issues.push({
8960
8960
  origin: "bigint",
8961
- input: input22,
8961
+ input: input2,
8962
8962
  code: "too_small",
8963
8963
  minimum,
8964
8964
  inclusive: true,
@@ -8966,10 +8966,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
8966
8966
  continue: !def.abort
8967
8967
  });
8968
8968
  }
8969
- if (input22 > maximum) {
8969
+ if (input2 > maximum) {
8970
8970
  payload.issues.push({
8971
8971
  origin: "bigint",
8972
- input: input22,
8972
+ input: input2,
8973
8973
  code: "too_big",
8974
8974
  maximum,
8975
8975
  inclusive: true,
@@ -8984,16 +8984,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
8984
8984
  $ZodCheck.init(inst, def);
8985
8985
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasSize);
8986
8986
  inst._zod.check = (payload) => {
8987
- const input22 = payload.value;
8988
- const size = input22.size;
8987
+ const input2 = payload.value;
8988
+ const size = input2.size;
8989
8989
  if (size <= def.maximum)
8990
8990
  return;
8991
8991
  payload.issues.push({
8992
- origin: getSizableOrigin(input22),
8992
+ origin: getSizableOrigin(input2),
8993
8993
  code: "too_big",
8994
8994
  maximum: def.maximum,
8995
8995
  inclusive: true,
8996
- input: input22,
8996
+ input: input2,
8997
8997
  inst,
8998
8998
  continue: !def.abort
8999
8999
  });
@@ -9004,16 +9004,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
9004
9004
  $ZodCheck.init(inst, def);
9005
9005
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasSize);
9006
9006
  inst._zod.check = (payload) => {
9007
- const input22 = payload.value;
9008
- const size = input22.size;
9007
+ const input2 = payload.value;
9008
+ const size = input2.size;
9009
9009
  if (size >= def.minimum)
9010
9010
  return;
9011
9011
  payload.issues.push({
9012
- origin: getSizableOrigin(input22),
9012
+ origin: getSizableOrigin(input2),
9013
9013
  code: "too_small",
9014
9014
  minimum: def.minimum,
9015
9015
  inclusive: true,
9016
- input: input22,
9016
+ input: input2,
9017
9017
  inst,
9018
9018
  continue: !def.abort
9019
9019
  });
@@ -9024,13 +9024,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
9024
9024
  $ZodCheck.init(inst, def);
9025
9025
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasSize);
9026
9026
  inst._zod.check = (payload) => {
9027
- const input22 = payload.value;
9028
- const size = input22.size;
9027
+ const input2 = payload.value;
9028
+ const size = input2.size;
9029
9029
  if (size === def.size)
9030
9030
  return;
9031
9031
  const tooBig = size > def.size;
9032
9032
  payload.issues.push({
9033
- origin: getSizableOrigin(input22),
9033
+ origin: getSizableOrigin(input2),
9034
9034
  ...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
9035
9035
  inclusive: true,
9036
9036
  exact: true,
@@ -9045,18 +9045,18 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
9045
9045
  $ZodCheck.init(inst, def);
9046
9046
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasLength);
9047
9047
  inst._zod.check = (payload) => {
9048
- const input22 = payload.value;
9049
- const units = input22.length;
9050
- const length = typeof input22 === "string" && units > def.maximum ? codePointLength(input22) : units;
9048
+ const input2 = payload.value;
9049
+ const units = input2.length;
9050
+ const length = typeof input2 === "string" && units > def.maximum ? codePointLength(input2) : units;
9051
9051
  if (length <= def.maximum)
9052
9052
  return;
9053
- const origin = getLengthableOrigin(input22);
9053
+ const origin = getLengthableOrigin(input2);
9054
9054
  payload.issues.push({
9055
9055
  origin,
9056
9056
  code: "too_big",
9057
9057
  maximum: def.maximum,
9058
9058
  inclusive: true,
9059
- input: input22,
9059
+ input: input2,
9060
9060
  inst,
9061
9061
  continue: !def.abort
9062
9062
  });
@@ -9067,18 +9067,18 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
9067
9067
  $ZodCheck.init(inst, def);
9068
9068
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasLength);
9069
9069
  inst._zod.check = (payload) => {
9070
- const input22 = payload.value;
9071
- const units = input22.length;
9072
- const length = typeof input22 === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input22) : units;
9070
+ const input2 = payload.value;
9071
+ const units = input2.length;
9072
+ const length = typeof input2 === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input2) : units;
9073
9073
  if (length >= def.minimum)
9074
9074
  return;
9075
- const origin = getLengthableOrigin(input22);
9075
+ const origin = getLengthableOrigin(input2);
9076
9076
  payload.issues.push({
9077
9077
  origin,
9078
9078
  code: "too_small",
9079
9079
  minimum: def.minimum,
9080
9080
  inclusive: true,
9081
- input: input22,
9081
+ input: input2,
9082
9082
  inst,
9083
9083
  continue: !def.abort
9084
9084
  });
@@ -9089,12 +9089,12 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
9089
9089
  $ZodCheck.init(inst, def);
9090
9090
  (_a4 = inst._zod.def).when ?? (_a4.when = _whenHasLength);
9091
9091
  inst._zod.check = (payload) => {
9092
- const input22 = payload.value;
9093
- const units = input22.length;
9094
- const length = typeof input22 === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input22) : units;
9092
+ const input2 = payload.value;
9093
+ const units = input2.length;
9094
+ const length = typeof input2 === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input2) : units;
9095
9095
  if (length === def.length)
9096
9096
  return;
9097
- const origin = getLengthableOrigin(input22);
9097
+ const origin = getLengthableOrigin(input2);
9098
9098
  const tooBig = length > def.length;
9099
9099
  payload.issues.push({
9100
9100
  origin,
@@ -9240,10 +9240,10 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
9240
9240
  return void 0;
9241
9241
  }
9242
9242
  entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
9243
- const input22 = payload.value;
9243
+ const input2 = payload.value;
9244
9244
  let proms;
9245
9245
  for (const [key, schema] of entries) {
9246
- const result = schema._zod.run({ value: input22[key], issues: [] }, {});
9246
+ const result = schema._zod.run({ value: input2[key], issues: [] }, {});
9247
9247
  if (result instanceof Promise) {
9248
9248
  proms ?? (proms = []);
9249
9249
  proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key)));
@@ -9278,10 +9278,10 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
9278
9278
  };
9279
9279
  });
9280
9280
  var Doc = class {
9281
- constructor(args2 = [], closed = {}) {
9281
+ constructor(args = [], closed = {}) {
9282
9282
  this.content = [];
9283
9283
  this.indent = 0;
9284
- this.args = args2;
9284
+ this.args = args;
9285
9285
  this.closed = closed;
9286
9286
  }
9287
9287
  // the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
@@ -9505,11 +9505,11 @@ var $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
9505
9505
  });
9506
9506
  var URL_BAD_FORMAT = 1;
9507
9507
  var URL_UNPARSEABLE = 2;
9508
- function canParseURL(input22) {
9508
+ function canParseURL(input2) {
9509
9509
  try {
9510
9510
  if (typeof URL !== "undefined" && typeof URL.canParse === "function")
9511
- return URL.canParse(input22);
9512
- new URL(input22);
9511
+ return URL.canParse(input2);
9512
+ new URL(input2);
9513
9513
  return true;
9514
9514
  } catch {
9515
9515
  return false;
@@ -9540,9 +9540,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
9540
9540
  function stripTabAndNewline(value) {
9541
9541
  return value.replace(asciiTabOrNewline, "");
9542
9542
  }
9543
- function urlHostnameOk(url2, hostname3) {
9544
- hostname3.lastIndex = 0;
9545
- return hostname3.test(url2.hostname);
9543
+ function urlHostnameOk(url2, hostname32) {
9544
+ hostname32.lastIndex = 0;
9545
+ return hostname32.test(url2.hostname);
9546
9546
  }
9547
9547
  function urlProtocolOk(url2, protocol) {
9548
9548
  protocol.lastIndex = 0;
@@ -9791,10 +9791,10 @@ function isLuhnAlgo(digits) {
9791
9791
  }
9792
9792
  return sum % 10 === 0;
9793
9793
  }
9794
- function isValidCreditCard(input22) {
9795
- if (!creditCard.test(input22))
9794
+ function isValidCreditCard(input2) {
9795
+ if (!creditCard.test(input2))
9796
9796
  return false;
9797
- return isLuhnAlgo(input22.replace(CC_SANITIZE, ""));
9797
+ return isLuhnAlgo(input2.replace(CC_SANITIZE, ""));
9798
9798
  }
9799
9799
  var $ZodCreditCard = /* @__PURE__ */ $constructor("$ZodCreditCard", (inst, def) => {
9800
9800
  def.pattern ?? (def.pattern = creditCard);
@@ -9824,10 +9824,10 @@ function isIso7064Mod97(iban3) {
9824
9824
  }
9825
9825
  return remainder === 1;
9826
9826
  }
9827
- function isValidIBAN(input22) {
9828
- if (!iban.test(input22))
9827
+ function isValidIBAN(input2) {
9828
+ if (!iban.test(input2))
9829
9829
  return false;
9830
- return isIso7064Mod97(input22);
9830
+ return isIso7064Mod97(input2);
9831
9831
  }
9832
9832
  var $ZodIBAN = /* @__PURE__ */ $constructor("$ZodIBAN", (inst, def) => {
9833
9833
  def.pattern ?? (def.pattern = iban);
@@ -9901,15 +9901,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
9901
9901
  payload.value = Number(payload.value);
9902
9902
  } catch (_) {
9903
9903
  }
9904
- const input22 = payload.value;
9905
- if (typeof input22 === "number" && !Number.isNaN(input22) && Number.isFinite(input22)) {
9904
+ const input2 = payload.value;
9905
+ if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
9906
9906
  return payload;
9907
9907
  }
9908
- const received = typeof input22 === "number" ? Number.isNaN(input22) ? "NaN" : !Number.isFinite(input22) ? String(input22) : void 0 : void 0;
9908
+ const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? String(input2) : void 0 : void 0;
9909
9909
  payload.issues.push({
9910
9910
  expected: "number",
9911
9911
  code: "invalid_type",
9912
- input: input22,
9912
+ input: input2,
9913
9913
  inst,
9914
9914
  ...received ? { received } : {}
9915
9915
  });
@@ -9929,13 +9929,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
9929
9929
  payload.value = Boolean(payload.value);
9930
9930
  } catch (_) {
9931
9931
  }
9932
- const input22 = payload.value;
9933
- if (typeof input22 === "boolean")
9932
+ const input2 = payload.value;
9933
+ if (typeof input2 === "boolean")
9934
9934
  return payload;
9935
9935
  payload.issues.push({
9936
9936
  expected: "boolean",
9937
9937
  code: "invalid_type",
9938
- input: input22,
9938
+ input: input2,
9939
9939
  inst
9940
9940
  });
9941
9941
  return payload;
@@ -9968,13 +9968,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, d
9968
9968
  var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
9969
9969
  $ZodType.init(inst, def);
9970
9970
  inst._zod.parse = (payload, _ctx) => {
9971
- const input22 = payload.value;
9972
- if (typeof input22 === "symbol")
9971
+ const input2 = payload.value;
9972
+ if (typeof input2 === "symbol")
9973
9973
  return payload;
9974
9974
  payload.issues.push({
9975
9975
  expected: "symbol",
9976
9976
  code: "invalid_type",
9977
- input: input22,
9977
+ input: input2,
9978
9978
  inst
9979
9979
  });
9980
9980
  return payload;
@@ -9985,13 +9985,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
9985
9985
  inst._zod.pattern = _undefined;
9986
9986
  inst._zod.values = /* @__PURE__ */ new Set([void 0]);
9987
9987
  inst._zod.parse = (payload, _ctx) => {
9988
- const input22 = payload.value;
9989
- if (typeof input22 === "undefined")
9988
+ const input2 = payload.value;
9989
+ if (typeof input2 === "undefined")
9990
9990
  return payload;
9991
9991
  payload.issues.push({
9992
9992
  expected: "undefined",
9993
9993
  code: "invalid_type",
9994
- input: input22,
9994
+ input: input2,
9995
9995
  inst
9996
9996
  });
9997
9997
  return payload;
@@ -10002,13 +10002,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
10002
10002
  inst._zod.pattern = _null;
10003
10003
  inst._zod.values = /* @__PURE__ */ new Set([null]);
10004
10004
  inst._zod.parse = (payload, _ctx) => {
10005
- const input22 = payload.value;
10006
- if (input22 === null)
10005
+ const input2 = payload.value;
10006
+ if (input2 === null)
10007
10007
  return payload;
10008
10008
  payload.issues.push({
10009
10009
  expected: "null",
10010
10010
  code: "invalid_type",
10011
- input: input22,
10011
+ input: input2,
10012
10012
  inst
10013
10013
  });
10014
10014
  return payload;
@@ -10037,13 +10037,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
10037
10037
  var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
10038
10038
  $ZodType.init(inst, def);
10039
10039
  inst._zod.parse = (payload, _ctx) => {
10040
- const input22 = payload.value;
10041
- if (typeof input22 === "undefined")
10040
+ const input2 = payload.value;
10041
+ if (typeof input2 === "undefined")
10042
10042
  return payload;
10043
10043
  payload.issues.push({
10044
10044
  expected: "void",
10045
10045
  code: "invalid_type",
10046
- input: input22,
10046
+ input: input2,
10047
10047
  inst
10048
10048
  });
10049
10049
  return payload;
@@ -10058,15 +10058,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
10058
10058
  } catch (_err) {
10059
10059
  }
10060
10060
  }
10061
- const input22 = payload.value;
10062
- const isDate = input22 instanceof Date;
10063
- const isValidDate = isDate && !Number.isNaN(input22.getTime());
10061
+ const input2 = payload.value;
10062
+ const isDate = input2 instanceof Date;
10063
+ const isValidDate = isDate && !Number.isNaN(input2.getTime());
10064
10064
  if (isValidDate)
10065
10065
  return payload;
10066
10066
  payload.issues.push({
10067
10067
  expected: "date",
10068
10068
  code: "invalid_type",
10069
- input: input22,
10069
+ input: input2,
10070
10070
  ...isDate ? { received: "Invalid Date" } : {},
10071
10071
  inst
10072
10072
  });
@@ -10095,9 +10095,9 @@ function capSize(inst, size) {
10095
10095
  return parse4(payload, ctx);
10096
10096
  };
10097
10097
  }
10098
- var arraySize = (input22) => Array.isArray(input22) ? input22.length : -1;
10099
- var mapSize = (input22) => input22 instanceof Map ? input22.size : -1;
10100
- var setSize = (input22) => input22 instanceof Set ? input22.size : -1;
10098
+ var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
10099
+ var mapSize = (input2) => input2 instanceof Map ? input2.size : -1;
10100
+ var setSize = (input2) => input2 instanceof Set ? input2.size : -1;
10101
10101
  function handleArrayResult(result, final, index) {
10102
10102
  if (result.issues.length) {
10103
10103
  final.issues.push(...prefixIssues(index, result.issues));
@@ -10109,21 +10109,21 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
10109
10109
  const memo2 = globalConfig.memoizer;
10110
10110
  memo2?.attach(inst);
10111
10111
  inst._zod.parse = (payload, ctx) => {
10112
- const input22 = payload.value;
10113
- if (!Array.isArray(input22)) {
10112
+ const input2 = payload.value;
10113
+ if (!Array.isArray(input2)) {
10114
10114
  payload.issues.push({
10115
10115
  expected: "array",
10116
10116
  code: "invalid_type",
10117
- input: input22,
10117
+ input: input2,
10118
10118
  inst
10119
10119
  });
10120
10120
  return payload;
10121
10121
  }
10122
- payload.value = memo2 ? memo2.alloc(inst, payload, Array(input22.length), ctx) : Array(input22.length);
10122
+ payload.value = memo2 ? memo2.alloc(inst, payload, Array(input2.length), ctx) : Array(input2.length);
10123
10123
  const proms = [];
10124
10124
  const abortEarly = ctx?.abortEarly;
10125
- for (let i = 0; i < input22.length; i++) {
10126
- const item = input22[i];
10125
+ for (let i = 0; i < input2.length; i++) {
10126
+ const item = input2[i];
10127
10127
  const result = def.element._zod.run({
10128
10128
  value: item,
10129
10129
  issues: []
@@ -10143,8 +10143,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
10143
10143
  };
10144
10144
  capSize(inst, arraySize);
10145
10145
  });
10146
- function handlePropertyResult(result, final, key, input22, optin, optout) {
10147
- const isPresent = key in input22;
10146
+ function handlePropertyResult(result, final, key, input2, optin, optout) {
10147
+ const isPresent = key in input2;
10148
10148
  const isOptionalOut = optout === "optional";
10149
10149
  if (!isPresent && isOptionalOut && optin === "optional") {
10150
10150
  return;
@@ -10196,7 +10196,7 @@ function normalizeDef(def) {
10196
10196
  optionalKeys: new Set(okeys)
10197
10197
  };
10198
10198
  }
10199
- function handleCatchall(proms, input22, payload, ctx, def, inst, abortEarly) {
10199
+ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
10200
10200
  const unrecognized = [];
10201
10201
  const keySet = def.keySet;
10202
10202
  const _catchall = def.catchall._zod;
@@ -10204,7 +10204,7 @@ function handleCatchall(proms, input22, payload, ctx, def, inst, abortEarly) {
10204
10204
  const optin = _catchall.optin;
10205
10205
  const optout = _catchall.optout;
10206
10206
  let seen = 0;
10207
- for (const key in input22) {
10207
+ for (const key in input2) {
10208
10208
  if (abortEarly && payload.issues.length !== seen) {
10209
10209
  if (aborted(payload, seen))
10210
10210
  break;
@@ -10221,18 +10221,18 @@ function handleCatchall(proms, input22, payload, ctx, def, inst, abortEarly) {
10221
10221
  unrecognized.push(key);
10222
10222
  continue;
10223
10223
  }
10224
- const r = _catchall.run({ value: input22[key], issues: [] }, ctx);
10224
+ const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
10225
10225
  if (r instanceof Promise) {
10226
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input22, optin, optout)));
10226
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, optin, optout)));
10227
10227
  } else {
10228
- handlePropertyResult(r, payload, key, input22, optin, optout);
10228
+ handlePropertyResult(r, payload, key, input2, optin, optout);
10229
10229
  }
10230
10230
  }
10231
10231
  if (unrecognized.length) {
10232
10232
  payload.issues.push({
10233
10233
  code: "unrecognized_keys",
10234
10234
  keys: unrecognized,
10235
- input: input22,
10235
+ input: input2,
10236
10236
  inst,
10237
10237
  // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
10238
10238
  continue: true
@@ -10283,12 +10283,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
10283
10283
  memo2?.attach(inst);
10284
10284
  inst._zod.parse = (payload, ctx) => {
10285
10285
  value ?? (value = _normalized.value);
10286
- const input22 = payload.value;
10287
- if (!isObject3(input22)) {
10286
+ const input2 = payload.value;
10287
+ if (!isObject3(input2)) {
10288
10288
  payload.issues.push({
10289
10289
  expected: "object",
10290
10290
  code: "invalid_type",
10291
- input: input22,
10291
+ input: input2,
10292
10292
  inst
10293
10293
  });
10294
10294
  return payload;
@@ -10309,17 +10309,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
10309
10309
  const el = shape[key];
10310
10310
  const optin = el._zod.optin;
10311
10311
  const optout = el._zod.optout;
10312
- const r = el._zod.run({ value: input22[key], issues: [] }, ctx);
10312
+ const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
10313
10313
  if (r instanceof Promise) {
10314
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input22, optin, optout)));
10314
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, optin, optout)));
10315
10315
  } else {
10316
- handlePropertyResult(r, payload, key, input22, optin, optout);
10316
+ handlePropertyResult(r, payload, key, input2, optin, optout);
10317
10317
  }
10318
10318
  }
10319
10319
  if (!catchall) {
10320
10320
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
10321
10321
  }
10322
- return handleCatchall(proms, input22, payload, ctx, _normalized.value, inst, abortEarly === true);
10322
+ return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst, abortEarly === true);
10323
10323
  };
10324
10324
  });
10325
10325
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -10428,12 +10428,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10428
10428
  let value;
10429
10429
  inst._zod.parse = (payload, ctx) => {
10430
10430
  value ?? (value = _normalized.value);
10431
- const input22 = payload.value;
10432
- if (!isObject3(input22)) {
10431
+ const input2 = payload.value;
10432
+ if (!isObject3(input2)) {
10433
10433
  payload.issues.push({
10434
10434
  expected: "object",
10435
10435
  code: "invalid_type",
10436
- input: input22,
10436
+ input: input2,
10437
10437
  inst
10438
10438
  });
10439
10439
  return payload;
@@ -10444,7 +10444,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10444
10444
  payload = fastpass(payload, ctx);
10445
10445
  if (!catchall)
10446
10446
  return payload;
10447
- return handleCatchall([], input22, payload, ctx, value, inst, ctx?.abortEarly === true);
10447
+ return handleCatchall([], input2, payload, ctx, value, inst, ctx?.abortEarly === true);
10448
10448
  }
10449
10449
  return superParse(payload, ctx);
10450
10450
  };
@@ -10636,17 +10636,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10636
10636
  });
10637
10637
  const disc = cached(() => discriminatorMap(def));
10638
10638
  inst._zod.parse = (payload, ctx) => {
10639
- const input22 = payload.value;
10640
- if (!isObject2(input22)) {
10639
+ const input2 = payload.value;
10640
+ if (!isObject2(input2)) {
10641
10641
  payload.issues.push({
10642
10642
  code: "invalid_type",
10643
10643
  expected: "object",
10644
- input: input22,
10644
+ input: input2,
10645
10645
  inst
10646
10646
  });
10647
10647
  return payload;
10648
10648
  }
10649
- const value = input22?.[def.discriminator];
10649
+ const value = input2?.[def.discriminator];
10650
10650
  const opt = disc.value.get(value);
10651
10651
  if (opt && (value !== void 0 || ctx.direction !== "backward")) {
10652
10652
  return opt._zod.run(payload, ctx);
@@ -10660,7 +10660,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10660
10660
  note: "No matching discriminator",
10661
10661
  discriminator: def.discriminator,
10662
10662
  options: Array.from(disc.value.keys()).filter((value2) => disc.value.get(value2) !== null),
10663
- input: input22,
10663
+ input: input2,
10664
10664
  path: [def.discriminator],
10665
10665
  inst
10666
10666
  });
@@ -10670,9 +10670,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10670
10670
  var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
10671
10671
  $ZodType.init(inst, def);
10672
10672
  inst._zod.parse = (payload, ctx) => {
10673
- const input22 = payload.value;
10674
- const left = def.left._zod.run({ value: input22, issues: [] }, ctx);
10675
- const right = def.right._zod.run({ value: input22, issues: [] }, ctx);
10673
+ const input2 = payload.value;
10674
+ const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
10675
+ const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
10676
10676
  const async = left instanceof Promise || right instanceof Promise;
10677
10677
  if (async) {
10678
10678
  return Promise.all([left, right]).then(([left2, right2]) => {
@@ -10787,10 +10787,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10787
10787
  const memo2 = globalConfig.memoizer;
10788
10788
  memo2?.attach(inst);
10789
10789
  inst._zod.parse = (payload, ctx) => {
10790
- const input22 = payload.value;
10791
- if (!Array.isArray(input22)) {
10790
+ const input2 = payload.value;
10791
+ if (!Array.isArray(input2)) {
10792
10792
  payload.issues.push({
10793
- input: input22,
10793
+ input: input2,
10794
10794
  inst,
10795
10795
  expected: "tuple",
10796
10796
  code: "invalid_type"
@@ -10802,23 +10802,23 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10802
10802
  const optinStart = getTupleOptStart(items, "optin");
10803
10803
  const optoutStart = getTupleOptStart(items, "optout");
10804
10804
  if (!def.rest) {
10805
- if (input22.length < optinStart) {
10805
+ if (input2.length < optinStart) {
10806
10806
  payload.issues.push({
10807
10807
  code: "too_small",
10808
10808
  minimum: optinStart,
10809
10809
  inclusive: true,
10810
- input: input22,
10810
+ input: input2,
10811
10811
  inst,
10812
10812
  origin: "array"
10813
10813
  });
10814
10814
  return payload;
10815
10815
  }
10816
- if (input22.length > items.length) {
10816
+ if (input2.length > items.length) {
10817
10817
  payload.issues.push({
10818
10818
  code: "too_big",
10819
10819
  maximum: items.length,
10820
10820
  inclusive: true,
10821
- input: input22,
10821
+ input: input2,
10822
10822
  inst,
10823
10823
  origin: "array"
10824
10824
  });
@@ -10828,7 +10828,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10828
10828
  const abortEarly = def.rest ? ctx?.abortEarly : void 0;
10829
10829
  let itemAborted = false;
10830
10830
  for (let i = 0; i < items.length; i++) {
10831
- const r = items[i]._zod.run({ value: input22[i], issues: [] }, ctx);
10831
+ const r = items[i]._zod.run({ value: input2[i], issues: [] }, ctx);
10832
10832
  if (r instanceof Promise) {
10833
10833
  proms.push(r.then((rr) => {
10834
10834
  itemResults[i] = rr;
@@ -10841,7 +10841,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10841
10841
  }
10842
10842
  if (def.rest && !itemAborted) {
10843
10843
  let i = items.length - 1;
10844
- const rest = input22.slice(items.length);
10844
+ const rest = input2.slice(items.length);
10845
10845
  let seen = payload.issues.length;
10846
10846
  for (const el of rest) {
10847
10847
  if (abortEarly && payload.issues.length !== seen) {
@@ -10859,9 +10859,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10859
10859
  }
10860
10860
  }
10861
10861
  if (proms.length) {
10862
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input22, optoutStart));
10862
+ return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input2, optoutStart));
10863
10863
  }
10864
- return handleTupleResults(itemResults, payload, items, input22, optoutStart);
10864
+ return handleTupleResults(itemResults, payload, items, input2, optoutStart);
10865
10865
  };
10866
10866
  });
10867
10867
  function getTupleOptStart(items, key) {
@@ -10878,10 +10878,10 @@ function handleTupleResult(result, final, index) {
10878
10878
  }
10879
10879
  final.value[index] = result.value;
10880
10880
  }
10881
- function handleTupleResults(itemResults, final, items, input22, optoutStart) {
10881
+ function handleTupleResults(itemResults, final, items, input2, optoutStart) {
10882
10882
  for (let i = 0; i < items.length; i++) {
10883
10883
  const r = itemResults[i];
10884
- const isPresent = i < input22.length;
10884
+ const isPresent = i < input2.length;
10885
10885
  if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
10886
10886
  final.value.length = i;
10887
10887
  break;
@@ -10895,7 +10895,7 @@ function handleTupleResults(itemResults, final, items, input22, optoutStart) {
10895
10895
  }
10896
10896
  final.value[i] = r.value;
10897
10897
  }
10898
- for (let i = final.value.length - 1; i >= input22.length; i--) {
10898
+ for (let i = final.value.length - 1; i >= input2.length; i--) {
10899
10899
  if (items[i]._zod.optout === "optional" && final.value[i] === void 0) {
10900
10900
  final.value.length = i;
10901
10901
  } else {
@@ -10909,12 +10909,12 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10909
10909
  const memo2 = globalConfig.memoizer;
10910
10910
  memo2?.attach(inst);
10911
10911
  inst._zod.parse = (payload, ctx) => {
10912
- const input22 = payload.value;
10913
- if (!isPlainObject2(input22)) {
10912
+ const input2 = payload.value;
10913
+ if (!isPlainObject2(input2)) {
10914
10914
  payload.issues.push({
10915
10915
  expected: "record",
10916
10916
  code: "invalid_type",
10917
- input: input22,
10917
+ input: input2,
10918
10918
  inst
10919
10919
  });
10920
10920
  return payload;
@@ -10947,7 +10947,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10947
10947
  const outKey = keyResult.value;
10948
10948
  if (outKey === "__proto__")
10949
10949
  continue;
10950
- const result = def.valueType._zod.run({ value: input22[key], issues: [] }, ctx);
10950
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
10951
10951
  if (result instanceof Promise) {
10952
10952
  proms.push(result.then((result2) => {
10953
10953
  if (result2.issues.length) {
@@ -10964,12 +10964,12 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10964
10964
  }
10965
10965
  }
10966
10966
  let unrecognized;
10967
- for (const key in input22) {
10967
+ for (const key in input2) {
10968
10968
  if (!recordKeys.has(key)) {
10969
10969
  if (def.mode === "loose") {
10970
10970
  if (key === "__proto__")
10971
10971
  continue;
10972
- payload.value[key] = input22[key];
10972
+ payload.value[key] = input2[key];
10973
10973
  } else {
10974
10974
  unrecognized = unrecognized ?? [];
10975
10975
  unrecognized.push(key);
@@ -10979,7 +10979,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10979
10979
  if (unrecognized && unrecognized.length > 0) {
10980
10980
  payload.issues.push({
10981
10981
  code: "unrecognized_keys",
10982
- input: input22,
10982
+ input: input2,
10983
10983
  inst,
10984
10984
  keys: unrecognized,
10985
10985
  continue: true
@@ -10988,10 +10988,10 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10988
10988
  } else {
10989
10989
  payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
10990
10990
  let unrecognized;
10991
- for (const key of Reflect.ownKeys(input22)) {
10991
+ for (const key of Reflect.ownKeys(input2)) {
10992
10992
  if (key === "__proto__")
10993
10993
  continue;
10994
- if (!Object.prototype.propertyIsEnumerable.call(input22, key))
10994
+ if (!Object.prototype.propertyIsEnumerable.call(input2, key))
10995
10995
  continue;
10996
10996
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
10997
10997
  if (keyResult instanceof Promise) {
@@ -11009,7 +11009,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11009
11009
  }
11010
11010
  if (keyResult.issues.length) {
11011
11011
  if (def.mode === "loose") {
11012
- payload.value[key] = input22[key];
11012
+ payload.value[key] = input2[key];
11013
11013
  } else if (values) {
11014
11014
  unrecognized = unrecognized ?? [];
11015
11015
  unrecognized.push(key);
@@ -11028,7 +11028,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11028
11028
  const outKey = keyResult.value;
11029
11029
  if (outKey === "__proto__")
11030
11030
  continue;
11031
- const result = def.valueType._zod.run({ value: input22[key], issues: [] }, ctx);
11031
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
11032
11032
  if (result instanceof Promise) {
11033
11033
  proms.push(result.then((result2) => {
11034
11034
  if (result2.issues.length) {
@@ -11046,7 +11046,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
11046
11046
  if (unrecognized && unrecognized.length > 0) {
11047
11047
  payload.issues.push({
11048
11048
  code: "unrecognized_keys",
11049
- input: input22,
11049
+ input: input2,
11050
11050
  inst,
11051
11051
  keys: unrecognized,
11052
11052
  continue: true
@@ -11064,12 +11064,12 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
11064
11064
  const memo2 = globalConfig.memoizer;
11065
11065
  memo2?.attach(inst);
11066
11066
  inst._zod.parse = (payload, ctx) => {
11067
- const input22 = payload.value;
11068
- if (!(input22 instanceof Map)) {
11067
+ const input2 = payload.value;
11068
+ if (!(input2 instanceof Map)) {
11069
11069
  payload.issues.push({
11070
11070
  expected: "map",
11071
11071
  code: "invalid_type",
11072
- input: input22,
11072
+ input: input2,
11073
11073
  inst
11074
11074
  });
11075
11075
  return payload;
@@ -11078,7 +11078,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
11078
11078
  payload.value = memo2 ? memo2.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
11079
11079
  const abortEarly = ctx?.abortEarly;
11080
11080
  let seen = payload.issues.length;
11081
- for (const [key, value] of input22) {
11081
+ for (const [key, value] of input2) {
11082
11082
  if (abortEarly && payload.issues.length !== seen) {
11083
11083
  if (aborted(payload, seen))
11084
11084
  break;
@@ -11088,10 +11088,10 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
11088
11088
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
11089
11089
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
11090
11090
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
11091
- handleMapResult(keyResult2, valueResult2, payload, key, input22, inst, ctx);
11091
+ handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
11092
11092
  }));
11093
11093
  } else {
11094
- handleMapResult(keyResult, valueResult, payload, key, input22, inst, ctx);
11094
+ handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
11095
11095
  }
11096
11096
  }
11097
11097
  if (proms.length)
@@ -11100,7 +11100,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
11100
11100
  };
11101
11101
  capSize(inst, mapSize);
11102
11102
  });
11103
- function handleMapResult(keyResult, valueResult, final, key, input22, inst, ctx) {
11103
+ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
11104
11104
  if (keyResult.issues.length) {
11105
11105
  if (propertyKeyTypes.has(typeof key)) {
11106
11106
  final.issues.push(...prefixIssues(key, keyResult.issues));
@@ -11108,7 +11108,7 @@ function handleMapResult(keyResult, valueResult, final, key, input22, inst, ctx)
11108
11108
  final.issues.push({
11109
11109
  code: "invalid_key",
11110
11110
  origin: "map",
11111
- input: input22,
11111
+ input: input2,
11112
11112
  inst,
11113
11113
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
11114
11114
  });
@@ -11121,7 +11121,7 @@ function handleMapResult(keyResult, valueResult, final, key, input22, inst, ctx)
11121
11121
  final.issues.push({
11122
11122
  origin: "map",
11123
11123
  code: "invalid_element",
11124
- input: input22,
11124
+ input: input2,
11125
11125
  inst,
11126
11126
  key,
11127
11127
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
@@ -11135,10 +11135,10 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
11135
11135
  const memo2 = globalConfig.memoizer;
11136
11136
  memo2?.attach(inst);
11137
11137
  inst._zod.parse = (payload, ctx) => {
11138
- const input22 = payload.value;
11139
- if (!(input22 instanceof Set)) {
11138
+ const input2 = payload.value;
11139
+ if (!(input2 instanceof Set)) {
11140
11140
  payload.issues.push({
11141
- input: input22,
11141
+ input: input2,
11142
11142
  inst,
11143
11143
  expected: "set",
11144
11144
  code: "invalid_type"
@@ -11149,7 +11149,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
11149
11149
  payload.value = memo2 ? memo2.alloc(inst, payload, /* @__PURE__ */ new Set(), ctx) : /* @__PURE__ */ new Set();
11150
11150
  const abortEarly = ctx?.abortEarly;
11151
11151
  let seen = payload.issues.length;
11152
- for (const item of input22) {
11152
+ for (const item of input2) {
11153
11153
  if (abortEarly && payload.issues.length !== seen) {
11154
11154
  if (aborted(payload, seen))
11155
11155
  break;
@@ -11183,14 +11183,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
11183
11183
  return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
11184
11184
  });
11185
11185
  inst._zod.parse = (payload, _ctx) => {
11186
- const input22 = payload.value;
11187
- if (valuesSet.has(input22)) {
11186
+ const input2 = payload.value;
11187
+ if (valuesSet.has(input2)) {
11188
11188
  return payload;
11189
11189
  }
11190
11190
  payload.issues.push({
11191
11191
  code: "invalid_value",
11192
11192
  values,
11193
- input: input22,
11193
+ input: input2,
11194
11194
  inst
11195
11195
  });
11196
11196
  return payload;
@@ -11205,14 +11205,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
11205
11205
  return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
11206
11206
  });
11207
11207
  inst._zod.parse = (payload, _ctx) => {
11208
- const input22 = payload.value;
11209
- if (values.has(input22)) {
11208
+ const input2 = payload.value;
11209
+ if (values.has(input2)) {
11210
11210
  return payload;
11211
11211
  }
11212
11212
  payload.issues.push({
11213
11213
  code: "invalid_value",
11214
11214
  values: def.values,
11215
- input: input22,
11215
+ input: input2,
11216
11216
  inst
11217
11217
  });
11218
11218
  return payload;
@@ -11221,13 +11221,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
11221
11221
  var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
11222
11222
  $ZodType.init(inst, def);
11223
11223
  inst._zod.parse = (payload, _ctx) => {
11224
- const input22 = payload.value;
11225
- if (input22 instanceof File)
11224
+ const input2 = payload.value;
11225
+ if (input2 instanceof File)
11226
11226
  return payload;
11227
11227
  payload.issues.push({
11228
11228
  expected: "file",
11229
11229
  code: "invalid_type",
11230
- input: input22,
11230
+ input: input2,
11231
11231
  inst
11232
11232
  });
11233
11233
  return payload;
@@ -11243,8 +11243,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
11243
11243
  }
11244
11244
  const _out = def.transform(payload.value, payload);
11245
11245
  if (ctx.async) {
11246
- const output22 = _out instanceof Promise ? _out : Promise.resolve(_out);
11247
- return output22.then((output3) => {
11246
+ const output2 = _out instanceof Promise ? _out : Promise.resolve(_out);
11247
+ return output2.then((output3) => {
11248
11248
  payload.value = output3;
11249
11249
  return payload;
11250
11250
  });
@@ -11636,8 +11636,8 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11636
11636
  if (typeof func !== "function") {
11637
11637
  throw new Error("implement() must be called with a function");
11638
11638
  }
11639
- return Object.defineProperty(function(...args2) {
11640
- const parsedArgs = inst._def.input ? parse2(inst._def.input, args2) : args2;
11639
+ return Object.defineProperty(function(...args) {
11640
+ const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
11641
11641
  const result = Reflect.apply(func, this, parsedArgs);
11642
11642
  if (inst._def.output) {
11643
11643
  return parse2(inst._def.output, result);
@@ -11649,8 +11649,8 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11649
11649
  if (typeof func !== "function") {
11650
11650
  throw new Error("implementAsync() must be called with a function");
11651
11651
  }
11652
- return Object.defineProperty(async function(...args2) {
11653
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args2) : args2;
11652
+ return Object.defineProperty(async function(...args) {
11653
+ const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
11654
11654
  const result = await Reflect.apply(func, this, parsedArgs);
11655
11655
  if (inst._def.output) {
11656
11656
  return await parseAsync(inst._def.output, result);
@@ -11676,31 +11676,31 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11676
11676
  }
11677
11677
  return payload;
11678
11678
  };
11679
- inst.input = (...args2) => {
11679
+ inst.input = (...args) => {
11680
11680
  const F = inst.constructor;
11681
- if (Array.isArray(args2[0])) {
11681
+ if (Array.isArray(args[0])) {
11682
11682
  return new F({
11683
11683
  type: "function",
11684
11684
  input: new $ZodTuple({
11685
11685
  type: "tuple",
11686
- items: args2[0],
11687
- rest: args2[1]
11686
+ items: args[0],
11687
+ rest: args[1]
11688
11688
  }),
11689
11689
  output: inst._def.output
11690
11690
  });
11691
11691
  }
11692
11692
  return new F({
11693
11693
  type: "function",
11694
- input: args2[0],
11694
+ input: args[0],
11695
11695
  output: inst._def.output
11696
11696
  });
11697
11697
  };
11698
- inst.output = (output22) => {
11698
+ inst.output = (output2) => {
11699
11699
  const F = inst.constructor;
11700
11700
  return new F({
11701
11701
  type: "function",
11702
11702
  input: inst._def.input,
11703
- output: output22
11703
+ output: output2
11704
11704
  });
11705
11705
  };
11706
11706
  return inst;
@@ -11735,20 +11735,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
11735
11735
  return payload;
11736
11736
  };
11737
11737
  inst._zod.check = (payload) => {
11738
- const input22 = payload.value;
11739
- const r = def.fn(input22);
11738
+ const input2 = payload.value;
11739
+ const r = def.fn(input2);
11740
11740
  if (r instanceof Promise) {
11741
- return r.then((r2) => handleRefineResult(r2, payload, input22, inst));
11741
+ return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
11742
11742
  }
11743
- handleRefineResult(r, payload, input22, inst);
11743
+ handleRefineResult(r, payload, input2, inst);
11744
11744
  return;
11745
11745
  };
11746
11746
  });
11747
- function handleRefineResult(result, payload, input22, inst) {
11747
+ function handleRefineResult(result, payload, input2, inst) {
11748
11748
  if (!result) {
11749
11749
  const _iss = {
11750
11750
  code: "custom",
11751
- input: input22,
11751
+ input: input2,
11752
11752
  inst,
11753
11753
  // incorporates params.error into issue reporting
11754
11754
  path: [...inst._zod.def.path ?? []],
@@ -11978,8 +11978,8 @@ var memo = {
11978
11978
  else
11979
11979
  rechecked = true;
11980
11980
  }
11981
- const input22 = payload.value;
11982
- if (!isRef(input22))
11981
+ const input2 = payload.value;
11982
+ if (!isRef(input2))
11983
11983
  return base(payload, ctx);
11984
11984
  let state = ctx[STATE];
11985
11985
  if (!state) {
@@ -11994,7 +11994,7 @@ var memo = {
11994
11994
  lastCtx = ctx;
11995
11995
  lastBucket = bucket;
11996
11996
  }
11997
- const hit = bucket.get(input22);
11997
+ const hit = bucket.get(input2);
11998
11998
  if (hit) {
11999
11999
  payload.value = hit.value;
12000
12000
  if (hit.issues) {
@@ -13474,9 +13474,9 @@ var error12 = () => {
13474
13474
  nan: "NaN"
13475
13475
  // All other type names omitted - they fall back to raw values via ?? operator
13476
13476
  };
13477
- function getTypeName(type, input22) {
13478
- if (type === "number" && typeof input22 === "number" && !Number.isFinite(input22)) {
13479
- return String(input22);
13477
+ function getTypeName(type, input2) {
13478
+ if (type === "number" && typeof input2 === "number" && !Number.isFinite(input2)) {
13479
+ return String(input2);
13480
13480
  }
13481
13481
  return TypeDictionary[type] ?? type;
13482
13482
  }
@@ -21816,23 +21816,23 @@ function _overwrite(tx) {
21816
21816
  }
21817
21817
  // @__NO_SIDE_EFFECTS__
21818
21818
  function _normalize(form) {
21819
- return /* @__PURE__ */ _overwrite((input22) => input22.normalize(form));
21819
+ return /* @__PURE__ */ _overwrite((input2) => input2.normalize(form));
21820
21820
  }
21821
21821
  // @__NO_SIDE_EFFECTS__
21822
21822
  function _trim() {
21823
- return /* @__PURE__ */ _overwrite((input22) => input22.trim());
21823
+ return /* @__PURE__ */ _overwrite((input2) => input2.trim());
21824
21824
  }
21825
21825
  // @__NO_SIDE_EFFECTS__
21826
21826
  function _toLowerCase() {
21827
- return /* @__PURE__ */ _overwrite((input22) => input22.toLowerCase());
21827
+ return /* @__PURE__ */ _overwrite((input2) => input2.toLowerCase());
21828
21828
  }
21829
21829
  // @__NO_SIDE_EFFECTS__
21830
21830
  function _toUpperCase() {
21831
- return /* @__PURE__ */ _overwrite((input22) => input22.toUpperCase());
21831
+ return /* @__PURE__ */ _overwrite((input2) => input2.toUpperCase());
21832
21832
  }
21833
21833
  // @__NO_SIDE_EFFECTS__
21834
21834
  function _slugify() {
21835
- return /* @__PURE__ */ _overwrite((input22) => slugify(input22));
21835
+ return /* @__PURE__ */ _overwrite((input2) => slugify(input2));
21836
21836
  }
21837
21837
  // @__NO_SIDE_EFFECTS__
21838
21838
  function _array(Class2, element, params) {
@@ -22138,8 +22138,8 @@ function _stringbool(Classes, _params) {
22138
22138
  type: "pipe",
22139
22139
  in: stringSchema,
22140
22140
  out: booleanSchema,
22141
- transform: ((input22, payload) => {
22142
- let data = input22;
22141
+ transform: ((input2, payload) => {
22142
+ let data = input2;
22143
22143
  if (params.case !== "sensitive")
22144
22144
  data = data.toLowerCase();
22145
22145
  if (truthySet.has(data)) {
@@ -22158,8 +22158,8 @@ function _stringbool(Classes, _params) {
22158
22158
  return {};
22159
22159
  }
22160
22160
  }),
22161
- reverseTransform: ((input22, _payload) => {
22162
- if (input22 === true) {
22161
+ reverseTransform: ((input2, _payload) => {
22162
+ if (input2 === true) {
22163
22163
  return truthyArray[0] || "true";
22164
22164
  } else {
22165
22165
  return falsyArray[0] || "false";
@@ -22410,10 +22410,10 @@ function compactTypeUnion(schema) {
22410
22410
  var FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
22411
22411
  var UNION_KEYS = ["oneOf", "anyOf"];
22412
22412
  function undeclaredConstraint(member) {
22413
- const extra22 = member.additionalProperties;
22414
- if (extra22 === void 0 || extra22 === false || typeof extra22 !== "object" || extra22 === null)
22413
+ const extra2 = member.additionalProperties;
22414
+ if (extra2 === void 0 || extra2 === false || typeof extra2 !== "object" || extra2 === null)
22415
22415
  return null;
22416
- return Object.keys(extra22).length ? extra22 : null;
22416
+ return Object.keys(extra2).length ? extra2 : null;
22417
22417
  }
22418
22418
  function foldObjects(members2) {
22419
22419
  const objects = [];
@@ -23428,9 +23428,9 @@ var allProcessors = {
23428
23428
  optional: optionalProcessor,
23429
23429
  lazy: lazyProcessor
23430
23430
  };
23431
- function toJSONSchema(input22, params) {
23432
- if ("_idmap" in input22) {
23433
- const registry2 = input22;
23431
+ function toJSONSchema(input2, params) {
23432
+ if ("_idmap" in input2) {
23433
+ const registry2 = input2;
23434
23434
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
23435
23435
  const defs = {};
23436
23436
  for (const entry of registry2._idmap.entries()) {
@@ -23458,9 +23458,9 @@ function toJSONSchema(input22, params) {
23458
23458
  return { schemas };
23459
23459
  }
23460
23460
  const ctx = initializeContext({ ...params, processors: allProcessors });
23461
- processSchema(input22, ctx);
23462
- extractDefs(ctx, input22);
23463
- return finalize(ctx, input22);
23461
+ processSchema(input2, ctx);
23462
+ extractDefs(ctx, input2);
23463
+ return finalize(ctx, input2);
23464
23464
  }
23465
23465
  var JSONSchemaGenerator = class {
23466
23466
  /** @deprecated Access via ctx instead */
@@ -23900,11 +23900,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
23900
23900
  globalRegistry.add(cl, { description });
23901
23901
  return cl;
23902
23902
  },
23903
- meta(...args2) {
23904
- if (args2.length === 0)
23903
+ meta(...args) {
23904
+ if (args.length === 0)
23905
23905
  return globalRegistry.get(this);
23906
23906
  const cl = this.clone();
23907
- globalRegistry.add(cl, args2[0]);
23907
+ globalRegistry.add(cl, args[0]);
23908
23908
  return cl;
23909
23909
  },
23910
23910
  isOptional() {
@@ -23913,8 +23913,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
23913
23913
  isNullable() {
23914
23914
  return this.safeParse(null).success;
23915
23915
  },
23916
- apply(fn, ...args2) {
23917
- return args2.length === 0 ? fn(this) : fn(this, ...args2);
23916
+ apply(fn, ...args) {
23917
+ return args.length === 0 ? fn(this) : fn(this, ...args);
23918
23918
  },
23919
23919
  // Overrides core's `~standard` to add `jsonSchema`. Must stay a prototype entry: redefining it per instance demotes instances to dictionary mode.
23920
23920
  get "~standard"() {
@@ -24002,29 +24002,29 @@ var _ZodString = /* @__PURE__ */ $constructor(
24002
24002
  minLength: (inst) => aggregateChecks(inst).minimum ?? null,
24003
24003
  maxLength: (inst) => aggregateChecks(inst).maximum ?? null
24004
24004
  }, {
24005
- regex(...args2) {
24006
- return this.check(/* @__PURE__ */ _regex(...args2));
24005
+ regex(...args) {
24006
+ return this.check(/* @__PURE__ */ _regex(...args));
24007
24007
  },
24008
- includes(...args2) {
24009
- return this.check(/* @__PURE__ */ _includes(...args2));
24008
+ includes(...args) {
24009
+ return this.check(/* @__PURE__ */ _includes(...args));
24010
24010
  },
24011
- startsWith(...args2) {
24012
- return this.check(/* @__PURE__ */ _startsWith(...args2));
24011
+ startsWith(...args) {
24012
+ return this.check(/* @__PURE__ */ _startsWith(...args));
24013
24013
  },
24014
- endsWith(...args2) {
24015
- return this.check(/* @__PURE__ */ _endsWith(...args2));
24014
+ endsWith(...args) {
24015
+ return this.check(/* @__PURE__ */ _endsWith(...args));
24016
24016
  },
24017
- min(...args2) {
24018
- return this.check(/* @__PURE__ */ _minLength(...args2));
24017
+ min(...args) {
24018
+ return this.check(/* @__PURE__ */ _minLength(...args));
24019
24019
  },
24020
- max(...args2) {
24021
- return this.check(/* @__PURE__ */ _maxLength(...args2));
24020
+ max(...args) {
24021
+ return this.check(/* @__PURE__ */ _maxLength(...args));
24022
24022
  },
24023
- length(...args2) {
24024
- return this.check(/* @__PURE__ */ _length(...args2));
24023
+ length(...args) {
24024
+ return this.check(/* @__PURE__ */ _length(...args));
24025
24025
  },
24026
- nonempty(...args2) {
24027
- return this.check(/* @__PURE__ */ _minLength(1, ...args2));
24026
+ nonempty(...args) {
24027
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
24028
24028
  },
24029
24029
  lowercase(params) {
24030
24030
  return this.check(/* @__PURE__ */ _lowercase(params));
@@ -24035,8 +24035,8 @@ var _ZodString = /* @__PURE__ */ $constructor(
24035
24035
  trim() {
24036
24036
  return this.check(/* @__PURE__ */ _trim());
24037
24037
  },
24038
- normalize(...args2) {
24039
- return this.check(/* @__PURE__ */ _normalize(...args2));
24038
+ normalize(...args) {
24039
+ return this.check(/* @__PURE__ */ _normalize(...args));
24040
24040
  },
24041
24041
  toLowerCase() {
24042
24042
  return this.check(/* @__PURE__ */ _toLowerCase());
@@ -24658,14 +24658,14 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
24658
24658
  omit(mask) {
24659
24659
  return util_exports.omit(this, mask);
24660
24660
  },
24661
- partial(...args2) {
24662
- return util_exports.partial(ZodOptional, this, args2[0]);
24661
+ partial(...args) {
24662
+ return util_exports.partial(ZodOptional, this, args[0]);
24663
24663
  },
24664
- exactPartial(...args2) {
24665
- return util_exports.partial(ZodExactOptional, this, args2[0], "exactPartial");
24664
+ exactPartial(...args) {
24665
+ return util_exports.partial(ZodExactOptional, this, args[0], "exactPartial");
24666
24666
  },
24667
- required(...args2) {
24668
- return util_exports.required(ZodNonOptional, this, args2[0]);
24667
+ required(...args) {
24668
+ return util_exports.required(ZodNonOptional, this, args[0]);
24669
24669
  }
24670
24670
  });
24671
24671
  function object(shape, params) {
@@ -24825,10 +24825,10 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
24825
24825
  inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
24826
24826
  inst.keyType = def.keyType;
24827
24827
  inst.valueType = def.valueType;
24828
- inst.min = (...args2) => inst.check(/* @__PURE__ */ _minSize(...args2));
24828
+ inst.min = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
24829
24829
  inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
24830
- inst.max = (...args2) => inst.check(/* @__PURE__ */ _maxSize(...args2));
24831
- inst.size = (...args2) => inst.check(/* @__PURE__ */ _size(...args2));
24830
+ inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
24831
+ inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
24832
24832
  });
24833
24833
  function map(keyType, valueType, params) {
24834
24834
  return new ZodMap({
@@ -24843,10 +24843,10 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
24843
24843
  $ZodSet.init(inst, def);
24844
24844
  ZodType.init(inst, def);
24845
24845
  inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
24846
- inst.min = (...args2) => inst.check(/* @__PURE__ */ _minSize(...args2));
24846
+ inst.min = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
24847
24847
  inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
24848
- inst.max = (...args2) => inst.check(/* @__PURE__ */ _maxSize(...args2));
24849
- inst.size = (...args2) => inst.check(/* @__PURE__ */ _size(...args2));
24848
+ inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
24849
+ inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
24850
24850
  });
24851
24851
  function set2(valueType, params) {
24852
24852
  return new ZodSet({
@@ -24963,14 +24963,14 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
24963
24963
  payload.issues.push(util_exports.issue(_issue));
24964
24964
  }
24965
24965
  };
24966
- const output22 = def.transform(payload.value, payload);
24967
- if (output22 instanceof Promise) {
24968
- return output22.then((output3) => {
24966
+ const output2 = def.transform(payload.value, payload);
24967
+ if (output2 instanceof Promise) {
24968
+ return output2.then((output3) => {
24969
24969
  payload.value = output3;
24970
24970
  return payload;
24971
24971
  });
24972
24972
  }
24973
- payload.value = output22;
24973
+ payload.value = output2;
24974
24974
  return payload;
24975
24975
  };
24976
24976
  });
@@ -25252,11 +25252,11 @@ function _instanceof(cls, params = {}) {
25252
25252
  };
25253
25253
  return inst;
25254
25254
  }
25255
- var stringbool = (...args2) => /* @__PURE__ */ _stringbool({
25255
+ var stringbool = (...args) => /* @__PURE__ */ _stringbool({
25256
25256
  Codec: ZodCodec,
25257
25257
  Boolean: ZodBoolean,
25258
25258
  String: ZodString
25259
- }, ...args2);
25259
+ }, ...args);
25260
25260
  function json(params) {
25261
25261
  const jsonSchema = lazy2(() => {
25262
25262
  return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
@@ -25416,13 +25416,13 @@ function resolveRef(ref, ctx) {
25416
25416
  if (!ref.startsWith("#")) {
25417
25417
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
25418
25418
  }
25419
- const path4 = ref.slice(1).split("/").filter(Boolean);
25420
- if (path4.length === 0) {
25419
+ const path6 = ref.slice(1).split("/").filter(Boolean);
25420
+ if (path6.length === 0) {
25421
25421
  return ctx.rootSchema;
25422
25422
  }
25423
25423
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
25424
- if (path4[0] === defsKey) {
25425
- const key = path4[1] === void 0 ? void 0 : decodeJSONPointerSegment(path4[1]);
25424
+ if (path6[0] === defsKey) {
25425
+ const key = path6[1] === void 0 ? void 0 : decodeJSONPointerSegment(path6[1]);
25426
25426
  if (!key || !ctx.defs[key]) {
25427
25427
  throw new Error(`Reference not found: ${ref}`);
25428
25428
  }
@@ -27161,11 +27161,11 @@ var ToolHistoryProjection = class {
27161
27161
  return this.history;
27162
27162
  }
27163
27163
  };
27164
- function validateSessionHeader(id, input22) {
27165
- if (input22 === null || typeof input22 !== "object" || Array.isArray(input22)) {
27164
+ function validateSessionHeader(id, input2) {
27165
+ if (input2 === null || typeof input2 !== "object" || Array.isArray(input2)) {
27166
27166
  throw new Error("session header is not a plain JSON record");
27167
27167
  }
27168
- const record2 = input22;
27168
+ const record2 = input2;
27169
27169
  if (Object.hasOwn(record2, "seedLength")) {
27170
27170
  throw new Error('session header has invalid field "seedLength"');
27171
27171
  }
@@ -27201,18 +27201,18 @@ function validateSessionHeader(id, input22) {
27201
27201
  }
27202
27202
  return deepFreeze(record2);
27203
27203
  }
27204
- function validateRestoredSessionHeader(id, input22) {
27205
- if (input22 !== null && typeof input22 === "object" && !Array.isArray(input22)) {
27206
- const prototype = Reflect.getPrototypeOf(input22);
27204
+ function validateRestoredSessionHeader(id, input2) {
27205
+ if (input2 !== null && typeof input2 === "object" && !Array.isArray(input2)) {
27206
+ const prototype = Reflect.getPrototypeOf(input2);
27207
27207
  if (prototype !== Object.prototype && prototype !== null) {
27208
27208
  throw new Error("session header is not a plain JSON record");
27209
27209
  }
27210
27210
  }
27211
- return validateSessionHeader(id, input22);
27211
+ return validateSessionHeader(id, input2);
27212
27212
  }
27213
27213
  function snapshotSessionHeader(id, source) {
27214
- const input22 = source === void 0 ? { version: SESSION_FORMAT_VERSION, id, createdAt: Date.now(), isSeeded: false } : source;
27215
- const snapshot2 = snapshotJsonValue(input22);
27214
+ const input2 = source === void 0 ? { version: SESSION_FORMAT_VERSION, id, createdAt: Date.now(), isSeeded: false } : source;
27215
+ const snapshot2 = snapshotJsonValue(input2);
27216
27216
  if (snapshot2 === void 0) throw new Error("session header is not losslessly JSON-serializable");
27217
27217
  return validateSessionHeader(id, snapshot2);
27218
27218
  }
@@ -27475,13 +27475,13 @@ function checkSessionLog(id, header, seed, inheritedEventCount, mode, events, su
27475
27475
  inheritedEventCount: validateInheritedCut(checkedHeader, seed !== void 0, inheritedEventCount, events, mode)
27476
27476
  };
27477
27477
  }
27478
- function collectSessionCallbacks(ctx, args2) {
27479
- return [...ctx.events.dispatch("emit", args2)];
27478
+ function collectSessionCallbacks(ctx, args) {
27479
+ return [...ctx.events.dispatch("emit", args)];
27480
27480
  }
27481
- function invokeContainedSessionObservers(ctx, name2, id, args2, callbacks) {
27481
+ function invokeContainedSessionObservers(ctx, name2, id, args, callbacks) {
27482
27482
  for (const callback of callbacks) {
27483
27483
  try {
27484
- const returned = callback(...args2);
27484
+ const returned = callback(...args);
27485
27485
  void Promise.resolve(returned).catch((error62) => {
27486
27486
  ctx.logger.warn(`session "${id}": ${name2} listener rejected: ${String(error62)}`);
27487
27487
  });
@@ -27693,9 +27693,9 @@ var Session = class _Session {
27693
27693
  this.publicationEntry();
27694
27694
  if (inputs.length === 0) return [];
27695
27695
  const snapshots = Array.from({ length: inputs.length }, (_, index) => {
27696
- const input22 = inputs.at(index);
27697
- if (input22 === void 0) throw new Error(`session batch has an empty member at index ${index}`);
27698
- const [type, data, surfaceOpts] = input22;
27696
+ const input2 = inputs.at(index);
27697
+ if (input2 === void 0) throw new Error(`session batch has an empty member at index ${index}`);
27698
+ const [type, data, surfaceOpts] = input2;
27699
27699
  return snapshotAppend(type, data, surfaceOpts, `session batch member ${index} ("${type}")`);
27700
27700
  });
27701
27701
  const entry = this.publicationEntry();
@@ -27705,17 +27705,17 @@ var Session = class _Session {
27705
27705
  if (entry !== void 0) entry.appending = true;
27706
27706
  try {
27707
27707
  const publications = entry === void 0 ? [] : events.map((event) => {
27708
- const args2 = [this, event];
27709
- const callbacks = collectSessionCallbacks(entry.emitCtx, [entry.carrier, "session/event", ...args2]);
27710
- return { event, args: args2, callbacks };
27708
+ const args = [this, event];
27709
+ const callbacks = collectSessionCallbacks(entry.emitCtx, [entry.carrier, "session/event", ...args]);
27710
+ return { event, args, callbacks };
27711
27711
  });
27712
27712
  for (const event of events) this.log.push(event);
27713
27713
  this.eventsSnapshot = void 0;
27714
27714
  acceptSurface();
27715
27715
  if (entry !== void 0) {
27716
- for (const { event, args: args2, callbacks } of publications) {
27716
+ for (const { event, args, callbacks } of publications) {
27717
27717
  this.batchPublication = event;
27718
- invokeContainedSessionObservers(entry.emitCtx, "session/event", entry.id, args2, callbacks);
27718
+ invokeContainedSessionObservers(entry.emitCtx, "session/event", entry.id, args, callbacks);
27719
27719
  }
27720
27720
  }
27721
27721
  } finally {
@@ -27934,7 +27934,7 @@ var COMPACTION_INSTRUCTION = [
27934
27934
  `- If the conversation already contains a ${SUMMARY_OPEN_TAG} block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts, drop stale ones, and merge newer information into a single consolidated summary under the same structure.`
27935
27935
  ].join("\n");
27936
27936
  var CHECKPOINT_PREAMBLE = "This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.";
27937
- async function summarizeWithLlm(ctx, config2, input22, agent, conversation, signal) {
27937
+ async function summarizeWithLlm(ctx, config2, input2, agent, conversation, signal) {
27938
27938
  const configured = config2.summarizationProvider.length === 0 ? void 0 : { provider: config2.summarizationProvider, model: config2.summarizationModel };
27939
27939
  const target = configured ?? conversation;
27940
27940
  if (target === void 0) {
@@ -27944,7 +27944,7 @@ async function summarizeWithLlm(ctx, config2, input22, agent, conversation, sign
27944
27944
  }
27945
27945
  const assembler = new BlockAssembler();
27946
27946
  const messages = [
27947
- ...input22.messages,
27947
+ ...input2.messages,
27948
27948
  deepFreeze({
27949
27949
  role: "user",
27950
27950
  content: [{ type: "text", text: COMPACTION_INSTRUCTION }]
@@ -27955,7 +27955,7 @@ async function summarizeWithLlm(ctx, config2, input22, agent, conversation, sign
27955
27955
  model: target.model,
27956
27956
  messages,
27957
27957
  toolHistory: agent.session.toolHistory(),
27958
- ...input22.tools === void 0 ? {} : { tools: [...input22.tools] },
27958
+ ...input2.tools === void 0 ? {} : { tools: [...input2.tools] },
27959
27959
  maxTokens: config2.maxTokens,
27960
27960
  sessionId: agent.session.id,
27961
27961
  purpose: "compaction",
@@ -28517,10 +28517,10 @@ var BasicCompactionEngine = class extends CompactionEngine {
28517
28517
  * @param signal - optional cancellation forwarded to the adapter.
28518
28518
  * @returns safe text summary blocks and the exact auxiliary call envelope and output.
28519
28519
  */
28520
- async summarize(input22, agent, signal) {
28520
+ async summarize(input2, agent, signal) {
28521
28521
  const target = conversationTarget(agent, (await this.answeredRoute).stateOf(agent.session));
28522
28522
  const config2 = target === void 0 ? this.config : resolveTargetPolicy(this.config, target);
28523
- return summarizeWithLlm(this.ctx, config2, input22, agent, target, signal);
28523
+ return summarizeWithLlm(this.ctx, config2, input2, agent, target, signal);
28524
28524
  }
28525
28525
  /**
28526
28526
  * Compact for replayed step-boundary pressure or one provider-confirmed context
@@ -28675,7 +28675,7 @@ var BasicCompactionEngine = class extends CompactionEngine {
28675
28675
  regionDependencies() {
28676
28676
  return {
28677
28677
  meter: this.ctx.tokenMeter,
28678
- summarize: (input22, owner, abort) => this.summarize(input22, owner, abort),
28678
+ summarize: (input2, owner, abort) => this.summarize(input2, owner, abort),
28679
28679
  recover: (error62, agent, sourceEventSeqs, signal) => this.ctx.waterfall("compaction/summary-error", {
28680
28680
  session: agent.session,
28681
28681
  sourceEventSeqs,
@@ -29591,17 +29591,17 @@ function dshContentToPi(content, imageToPi) {
29591
29591
  });
29592
29592
  break;
29593
29593
  case "tool-call": {
29594
- let args2 = {};
29594
+ let args = {};
29595
29595
  try {
29596
- args2 = JSON.parse(String(block.arguments ?? "{}"));
29596
+ args = JSON.parse(String(block.arguments ?? "{}"));
29597
29597
  } catch {
29598
- args2 = {};
29598
+ args = {};
29599
29599
  }
29600
29600
  out.push({
29601
29601
  type: "toolCall",
29602
29602
  id: String(block.id ?? ""),
29603
29603
  name: String(block.name ?? ""),
29604
- arguments: args2
29604
+ arguments: args
29605
29605
  });
29606
29606
  break;
29607
29607
  }
@@ -29669,13 +29669,14 @@ function dshMessageToPi(message, time3, toolNames, imageToPi) {
29669
29669
  }
29670
29670
 
29671
29671
  // src/dsh/sync.ts
29672
- function createSyncState() {
29672
+ function createSyncState({ persistent = false } = {}) {
29673
29673
  return {
29674
29674
  turn: 1,
29675
29675
  step: 0,
29676
29676
  turnStarted: false,
29677
29677
  systemSeq: void 0,
29678
29678
  stepOpen: false,
29679
+ persistent,
29679
29680
  seen: /* @__PURE__ */ new Set(),
29680
29681
  toolCalls: /* @__PURE__ */ new Map(),
29681
29682
  appended: 0
@@ -29698,6 +29699,11 @@ function ensureTurn(session, state) {
29698
29699
  function appendSystem(session, state, entry, message, systemPrompt) {
29699
29700
  if (state.systemSeq !== void 0) return;
29700
29701
  ensureTurn(session, state);
29702
+ if (state.persistent && !state.stepOpen) {
29703
+ state.step += 1;
29704
+ append(session, "step/start", { turn: state.turn, step: state.step });
29705
+ state.stepOpen = true;
29706
+ }
29701
29707
  let content = piContentToDsh(
29702
29708
  systemPrompt && systemPrompt.trim().length > 0 ? systemPrompt : typeof message.content === "string" ? message.content : []
29703
29709
  );
@@ -30295,19 +30301,19 @@ function buildSessionPath(entries, leafId, byId) {
30295
30301
  if (!leaf) {
30296
30302
  return [];
30297
30303
  }
30298
- const path4 = [];
30304
+ const path6 = [];
30299
30305
  let current = leaf;
30300
30306
  while (current) {
30301
- path4.push(current);
30307
+ path6.push(current);
30302
30308
  current = current.parentId ? index.get(current.parentId) : void 0;
30303
30309
  }
30304
- path4.reverse();
30305
- return path4;
30310
+ path6.reverse();
30311
+ return path6;
30306
30312
  }
30307
- function getSessionContextSettings(path4) {
30313
+ function getSessionContextSettings(path6) {
30308
30314
  let thinkingLevel = "off";
30309
30315
  let model = null;
30310
- for (const entry of path4) {
30316
+ for (const entry of path6) {
30311
30317
  if (entry.type === "thinking_level_change") {
30312
30318
  thinkingLevel = entry.thinkingLevel;
30313
30319
  } else if (entry.type === "model_change") {
@@ -30343,24 +30349,24 @@ function sessionEntryToContextMessages(entry) {
30343
30349
  return [];
30344
30350
  }
30345
30351
  function buildContextEntries(entries, leafId, byId) {
30346
- const path4 = buildSessionPath(entries, leafId, byId);
30352
+ const path6 = buildSessionPath(entries, leafId, byId);
30347
30353
  let compaction = null;
30348
- for (const entry of path4) {
30354
+ for (const entry of path6) {
30349
30355
  if (entry.type === "compaction") {
30350
30356
  compaction = entry;
30351
30357
  }
30352
30358
  }
30353
30359
  if (!compaction) {
30354
- return path4;
30360
+ return path6;
30355
30361
  }
30356
- const compactionIdx = path4.findIndex((entry) => entry.id === compaction.id);
30362
+ const compactionIdx = path6.findIndex((entry) => entry.id === compaction.id);
30357
30363
  if (compactionIdx < 0) {
30358
- return path4;
30364
+ return path6;
30359
30365
  }
30360
30366
  const contextEntries = [compaction];
30361
30367
  let foundFirstKept = false;
30362
30368
  for (let i = 0; i < compactionIdx; i++) {
30363
- const entry = path4[i];
30369
+ const entry = path6[i];
30364
30370
  if (entry.id === compaction.firstKeptEntryId) {
30365
30371
  foundFirstKept = true;
30366
30372
  }
@@ -30368,7 +30374,7 @@ function buildContextEntries(entries, leafId, byId) {
30368
30374
  contextEntries.push(entry);
30369
30375
  }
30370
30376
  }
30371
- contextEntries.push(...path4.slice(compactionIdx + 1));
30377
+ contextEntries.push(...path6.slice(compactionIdx + 1));
30372
30378
  return contextEntries;
30373
30379
  }
30374
30380
  function projectContextEntry(entry, edit) {
@@ -30387,8 +30393,8 @@ function projectContextEntry(entry, edit) {
30387
30393
  });
30388
30394
  }
30389
30395
  function buildSessionProjection(entries, leafId, byId) {
30390
- const path4 = buildSessionPath(entries, leafId, byId);
30391
- const { thinkingLevel, model } = getSessionContextSettings(path4);
30396
+ const path6 = buildSessionPath(entries, leafId, byId);
30397
+ const { thinkingLevel, model } = getSessionContextSettings(path6);
30392
30398
  const contextEntries = buildContextEntries(entries, leafId, byId);
30393
30399
  const edits = /* @__PURE__ */ new Map();
30394
30400
  for (const entry of contextEntries) {
@@ -30487,6 +30493,36 @@ function projectPiForDsh(entries) {
30487
30493
  );
30488
30494
  return convertToLlm(system ? [system, ...conversation] : conversation).map((message, index) => ({ type: "message", id: `projected-${index}`, message }));
30489
30495
  }
30496
+ function settledTools(projected) {
30497
+ const result = [];
30498
+ const pending = /* @__PURE__ */ new Set();
30499
+ for (const [index, entry] of projected.entries()) {
30500
+ const { message } = entry;
30501
+ if (message.role === "toolResult") {
30502
+ if (pending.delete(message.toolCallId)) result.push(entry);
30503
+ continue;
30504
+ }
30505
+ pending.clear();
30506
+ if (message.role !== "assistant" || message.stopReason === "error" || message.stopReason === "aborted") {
30507
+ result.push(entry);
30508
+ continue;
30509
+ }
30510
+ const followingResults = /* @__PURE__ */ new Set();
30511
+ for (let next = index + 1; next < projected.length; next++) {
30512
+ const following = projected[next].message;
30513
+ if (following.role !== "toolResult") break;
30514
+ followingResults.add(following.toolCallId);
30515
+ }
30516
+ const content = message.content.filter((block) => {
30517
+ if (block.type !== "toolCall") return true;
30518
+ if (!block.id || !followingResults.delete(block.id)) return false;
30519
+ pending.add(block.id);
30520
+ return true;
30521
+ });
30522
+ if (content.length) result.push({ ...entry, message: { ...message, content } });
30523
+ }
30524
+ return result;
30525
+ }
30490
30526
  function piHeader(header) {
30491
30527
  return {
30492
30528
  type: "session",
@@ -30497,21 +30533,21 @@ function piHeader(header) {
30497
30533
  ...header.parentSession ? { parentSession: header.parentSession } : {}
30498
30534
  };
30499
30535
  }
30500
- function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiForDsh(entries)) {
30536
+ function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiForDsh(entries), destination) {
30501
30537
  const header = {
30502
30538
  type: "session",
30503
30539
  version: SESSION_FORMAT_VERSION,
30504
- id: pi.id,
30540
+ id: destination?.id ?? pi.id,
30505
30541
  createdAt: Date.parse(pi.timestamp),
30506
- cwd: pi.cwd,
30542
+ cwd: destination?.cwd ?? pi.cwd,
30507
30543
  isSeeded: false,
30508
30544
  delegationDepth: 0,
30509
- ...pi.parentSession ? { parentSession: pi.parentSession } : {}
30545
+ ...!destination && pi.parentSession ? { parentSession: pi.parentSession } : {}
30510
30546
  };
30511
30547
  const session = Session.create(header.id, [], headerForSession(header));
30512
30548
  appendPluginRecord(session, PI_HEADER, JSON.parse(JSON.stringify(pi)));
30513
- const state = createSyncState();
30514
- syncPiEntries(session, projected, state, { imageToDsh });
30549
+ const state = createSyncState({ persistent: true });
30550
+ syncPiEntries(session, settledTools(projected), state, { imageToDsh });
30515
30551
  closeTurn(session, state);
30516
30552
  for (const entry of entries) {
30517
30553
  appendPluginRecord(session, PI_ARCHIVE, JSON.parse(JSON.stringify(entry)));
@@ -30521,9 +30557,9 @@ function dshRowsFromPi(pi, entries, _file2, imageToDsh, projected = projectPiFor
30521
30557
  ...session.snapshotEvents().map((event) => JSON.stringify(event))
30522
30558
  ].join("\n") + "\n";
30523
30559
  }
30524
- function writeDshFromPi(file2, header, entries, imageToDsh, projected) {
30560
+ function writeDshFromPi(file2, header, entries, imageToDsh, projected, destination) {
30525
30561
  mkdirSync(path.dirname(file2), { recursive: true });
30526
- const body = dshRowsFromPi(header, entries, file2, imageToDsh, projected);
30562
+ const body = dshRowsFromPi(header, entries, file2, imageToDsh, projected, destination);
30527
30563
  const tmp = `${file2}.${process.pid}.tmp`;
30528
30564
  writeFileSync(tmp, body);
30529
30565
  renameSync(tmp, file2);
@@ -30584,39 +30620,40 @@ function messageEntry(id, parentId, time3, message) {
30584
30620
  }
30585
30621
  return { ...base, message: { ...message, timestamp: time3 } };
30586
30622
  }
30587
- async function piToDsh(input3, output3) {
30588
- if (path2.resolve(input3) === path2.resolve(output3))
30623
+ async function piToDsh(input2, output2) {
30624
+ if (path2.resolve(input2) === path2.resolve(output2))
30589
30625
  throw new Error("Choose a separate output file for session conversion");
30590
- const pi = await readPiSession(input3);
30626
+ const pi = await readPiSession(input2);
30627
+ return { input: input2, output: output2, ...await exportPiSession(pi, output2) };
30628
+ }
30629
+ async function exportPiSession(pi, output2, options = {}) {
30591
30630
  const projected = projectPiForDsh(pi.entries);
30592
- const carrier = await openImageBridge();
30631
+ const carrier = await openImageBridge(options.dshHome);
30593
30632
  try {
30594
30633
  await carrier.images.prepare(
30595
30634
  projected.map((entry) => entry.message)
30596
30635
  );
30597
- writeDshFromPi(output3, pi.header, pi.entries, carrier.images.toDsh, projected);
30636
+ writeDshFromPi(output2, pi.header, pi.entries, carrier.images.toDsh, projected, options.destination);
30598
30637
  } finally {
30599
30638
  await carrier.close();
30600
30639
  }
30601
- const parsed = await readDshFile(output3);
30640
+ const parsed = await readDshFile(output2);
30602
30641
  return {
30603
- input: input3,
30604
- output: output3,
30605
30642
  messages: pi.entries.filter((entry) => entry.type === "message").length,
30606
30643
  events: parsed.events.length
30607
30644
  };
30608
30645
  }
30609
- async function dshToPi(input3, output3) {
30610
- if (path2.resolve(input3) === path2.resolve(output3))
30646
+ async function dshToPi(input2, output2) {
30647
+ if (path2.resolve(input2) === path2.resolve(output2))
30611
30648
  throw new Error("Choose a separate output file for session conversion");
30612
- const dsh = await readDshFile(input3);
30613
- if (!dsh) throw new Error(`${input3}: not a DSH session file`);
30649
+ const dsh = await readDshFile(input2);
30650
+ if (!dsh) throw new Error(`${input2}: not a DSH session file`);
30614
30651
  const archived = archivedPi(dsh.header, dsh.events);
30615
30652
  if (archived) {
30616
- await writePiSession(output3, archived.header, archived.entries);
30653
+ await writePiSession(output2, archived.header, archived.entries);
30617
30654
  return {
30618
- input: input3,
30619
- output: output3,
30655
+ input: input2,
30656
+ output: output2,
30620
30657
  messages: archived.entries.filter((entry) => entry.type === "message").length,
30621
30658
  events: dsh.events.length
30622
30659
  };
@@ -30648,8 +30685,8 @@ async function dshToPi(input3, output3) {
30648
30685
  );
30649
30686
  parentId = id;
30650
30687
  }
30651
- await writePiSession(output3, header, entries);
30652
- return { input: input3, output: output3, messages: messages.length, events: dsh.events.length };
30688
+ await writePiSession(output2, header, entries);
30689
+ return { input: input2, output: output2, messages: messages.length, events: dsh.events.length };
30653
30690
  }
30654
30691
 
30655
30692
  // src/dsh/import.ts
@@ -30666,62 +30703,485 @@ function escapeSegment(value) {
30666
30703
  (char) => "~" + char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")
30667
30704
  );
30668
30705
  }
30706
+ var DestinationConflict = class extends Error {
30707
+ };
30708
+ async function nativeDestination(root, sessionId, cwd, plaintext) {
30709
+ try {
30710
+ if (!(await fs3.stat(root)).isDirectory()) throw new Error(`DSH session root is not a directory: ${root}`);
30711
+ } catch (error62) {
30712
+ if (error62.code !== "ENOENT") throw error62;
30713
+ }
30714
+ const id = sessionId === "." || sessionId === ".." ? sessionId.replaceAll(".", "~002E") : escapeSegment(sessionId);
30715
+ const project = path3.join(root, projectKey(cwd));
30716
+ const destination = path3.join(project, id);
30717
+ const output2 = path3.join(destination, `session.v${DSH_FORMAT_VERSION}.jsonl${plaintext ? "" : ".zstd"}`);
30718
+ let conflict;
30719
+ for await (const existing of fs3.glob("*/*/session{,.v*}.jsonl{,.zstd}", { cwd: root })) {
30720
+ const filename = path3.basename(existing);
30721
+ if (!/^session(?:\.v[1-9]\d*)?\.jsonl(?:\.zstd)?$/.test(filename)) continue;
30722
+ if (filename.endsWith(".zstd") === plaintext)
30723
+ throw new Error(`DSH session root uses a different encoding: ${root}`);
30724
+ if (path3.basename(path3.dirname(existing)) === id) conflict = path3.join(root, existing);
30725
+ }
30726
+ try {
30727
+ await fs3.lstat(destination);
30728
+ conflict ??= destination;
30729
+ } catch (error62) {
30730
+ if (error62.code !== "ENOENT") throw error62;
30731
+ }
30732
+ if (conflict)
30733
+ throw new DestinationConflict(`DSH session already exists: ${sessionId} (${conflict})`);
30734
+ return output2;
30735
+ }
30669
30736
  function projectKey(cwd) {
30670
30737
  const readable = escapeSegment(cwd.replace(/[/\\:]+/g, "-")).replace(/^-+/, "");
30671
30738
  return `--${(readable || "root").slice(0, 251)}--`;
30672
30739
  }
30673
- async function importPiToDsh(input3, root = path3.join(process.env.DSH_HOME || path3.join(homedir2(), ".dsh"), "sessions"), plaintext = false) {
30740
+ async function importPiToDsh(input2, root = path3.join(process.env.DSH_HOME || path3.join(homedir2(), ".dsh"), "sessions"), plaintext = false, options = {}) {
30674
30741
  root = path3.resolve(root);
30742
+ const pi = options.pi ?? await readPiSession(input2);
30743
+ const sessionId = options.sessionId ?? pi.header.id;
30744
+ const cwd = options.cwd ?? pi.header.cwd;
30745
+ if (!sessionId || !cwd || !path3.isAbsolute(cwd))
30746
+ throw new Error("Import requires a native pi session with an ID and an absolute local project path");
30747
+ const output2 = await nativeDestination(root, sessionId, cwd, plaintext);
30748
+ const destination = path3.dirname(output2);
30675
30749
  const stage = await fs3.mkdtemp(path3.join(tmpdir(), "dcp-import-"));
30676
30750
  try {
30677
30751
  const raw = path3.join(stage, "session.jsonl");
30678
- const report = await piToDsh(input3, raw);
30752
+ const report = await exportPiSession(pi, raw, {
30753
+ dshHome: options.dshHome,
30754
+ destination: options.sessionId !== void 0 || options.cwd !== void 0 ? { id: sessionId, cwd } : void 0
30755
+ });
30679
30756
  const bytes = await fs3.readFile(raw);
30680
30757
  const headerEnd = bytes.indexOf(10) + 1;
30681
- const header = JSON.parse(bytes.subarray(0, headerEnd).toString("utf8"));
30682
- if (header.version !== DSH_FORMAT_VERSION || !header.id || !header.cwd || !path3.isAbsolute(header.cwd))
30683
- throw new Error("Import requires a native pi session with an ID and an absolute local project path");
30684
- const id = header.id === "." || header.id === ".." ? header.id.replaceAll(".", "~002E") : escapeSegment(header.id);
30685
- for await (const existing of fs3.glob("*/*/session{,.v*}.jsonl{,.zstd}", { cwd: root })) {
30686
- const filename = path3.basename(existing);
30687
- if (!/^session(?:\.v[1-9]\d*)?\.jsonl(?:\.zstd)?$/.test(filename)) continue;
30688
- if (filename.endsWith(".zstd") === plaintext)
30689
- throw new Error(`DSH session root uses a different encoding: ${root}`);
30690
- if (path3.basename(path3.dirname(existing)) === id)
30691
- throw new Error(`DSH session already exists: ${header.id} (${path3.join(root, existing)})`);
30692
- }
30693
- const project = path3.join(root, projectKey(header.cwd));
30694
- const destination = path3.join(project, id);
30695
- const output3 = path3.join(destination, `session.v${header.version}.jsonl${plaintext ? "" : ".zstd"}`);
30696
30758
  const stored = plaintext ? bytes : Buffer.concat(await Promise.all([
30697
30759
  compress(bytes.subarray(0, headerEnd), zstdOptions),
30698
30760
  compress(bytes.subarray(headerEnd), zstdOptions)
30699
30761
  ]));
30700
- await fs3.mkdir(project, { recursive: true, mode: 448 });
30762
+ await fs3.mkdir(path3.dirname(destination), { recursive: true, mode: 448 });
30701
30763
  try {
30702
30764
  await fs3.mkdir(destination, { mode: 448 });
30703
30765
  } catch (error62) {
30704
30766
  if (error62.code === "EEXIST")
30705
- throw new Error(`DSH session already exists: ${header.id} (${destination})`);
30767
+ throw new DestinationConflict(`DSH session already exists: ${sessionId} (${destination})`);
30706
30768
  throw error62;
30707
30769
  }
30708
30770
  const pending = path3.join(destination, ".dcp-import.tmp");
30709
30771
  try {
30710
30772
  await fs3.writeFile(pending, stored, { flag: "wx", mode: 384 });
30711
- await fs3.rename(pending, output3);
30773
+ await fs3.rename(pending, output2);
30712
30774
  } catch (error62) {
30713
30775
  await fs3.rm(pending, { force: true });
30714
30776
  await fs3.rmdir(destination);
30715
30777
  throw error62;
30716
30778
  }
30717
- return { ...report, output: output3, sessionId: header.id, cwd: header.cwd };
30779
+ return { ...report, input: input2, output: output2, sessionId, cwd };
30718
30780
  } finally {
30719
30781
  await fs3.rm(stage, { recursive: true, force: true });
30720
30782
  }
30721
30783
  }
30722
30784
 
30723
- // bin/dcp-session.ts
30785
+ // src/dsh/migration-cli.ts
30786
+ import { promises as fs6 } from "node:fs";
30787
+ import { createInterface } from "node:readline/promises";
30788
+ import path5 from "node:path";
30789
+ import { parseArgs } from "node:util";
30790
+
30791
+ // src/dsh/migration.ts
30792
+ import { createHash as createHash6, randomUUID as randomUUID5 } from "node:crypto";
30793
+ import { promises as fs4 } from "node:fs";
30794
+ import { homedir as homedir3, hostname as hostname3 } from "node:os";
30795
+ import path4 from "node:path";
30796
+ var migrationTargets = ["portable", "windows-desktop", "linux-desktop", "web", "tui"];
30797
+ var dshVersions = ["0.2.2-rc.1", "0.2.2-rc.5", "0.2.3-alpha.2"];
30798
+ function migrationEnvironment() {
30799
+ const piHome = path4.resolve(process.env.PI_CODING_AGENT_DIR ?? path4.join(homedir3(), ".pi", "agent"));
30800
+ const dshHome = path4.resolve(process.env.DSH_HOME ?? path4.join(homedir3(), ".dsh"));
30801
+ return { host: hostname3(), platform: process.platform, piHome, suggestedDshHome: dshHome, suggestedSessionRoot: path4.join(dshHome, "sessions") };
30802
+ }
30803
+ var MixedSession = class extends Error {
30804
+ };
30805
+ var piEntryTypes = /* @__PURE__ */ new Set([
30806
+ "message",
30807
+ "model_change",
30808
+ "thinking_level_change",
30809
+ "custom",
30810
+ "custom_message",
30811
+ "context_edit",
30812
+ "compaction",
30813
+ "branch_summary",
30814
+ "session_info",
30815
+ "label"
30816
+ ]);
30817
+ function absolute(value, label) {
30818
+ if (!value || !path4.isAbsolute(value)) throw new Error(`${label} must be an absolute path on this host`);
30819
+ return path4.resolve(value);
30820
+ }
30821
+ async function directory(value, label) {
30822
+ const dir = absolute(value, label);
30823
+ if (!(await fs4.stat(dir)).isDirectory()) throw new Error(`${label} must be a directory: ${dir}`);
30824
+ return fs4.realpath(dir);
30825
+ }
30826
+ async function targetRoot(value) {
30827
+ const root = absolute(value, "Target session root");
30828
+ const remaining = [];
30829
+ for (let current = root; ; current = path4.dirname(current)) {
30830
+ try {
30831
+ return path4.join(await directory(current, "Target session root"), ...remaining);
30832
+ } catch (error62) {
30833
+ if (error62.code !== "ENOENT" || current === path4.dirname(current)) throw error62;
30834
+ remaining.unshift(path4.basename(current));
30835
+ }
30836
+ }
30837
+ }
30838
+ function digest3(value) {
30839
+ return createHash6("sha256").update(value).digest("hex");
30840
+ }
30841
+ async function findPiSources({ piHome, cwd, id }) {
30842
+ if (!cwd && !id) throw new Error("Pass --cwd or --id to select Pi sessions");
30843
+ const root = path4.join(absolute(piHome ?? process.env.PI_CODING_AGENT_DIR ?? path4.join(homedir3(), ".pi", "agent"), "Pi agent directory"), "sessions");
30844
+ const matches = [];
30845
+ for await (const file2 of fs4.glob("*/*.jsonl", { cwd: root })) {
30846
+ const input2 = path4.join(root, file2);
30847
+ const handle = await fs4.open(input2, "r");
30848
+ try {
30849
+ const buffer = Buffer.alloc(65536);
30850
+ const { bytesRead } = await handle.read(buffer);
30851
+ const header = JSON.parse(buffer.subarray(0, bytesRead).toString("utf8").split("\n", 1)[0]);
30852
+ if (header.type !== "session" || !header.id || id && header.id !== id || cwd && header.cwd !== cwd) continue;
30853
+ matches.push({ path: input2, id: header.id, cwd: header.cwd, timestamp: header.timestamp ?? header.createdAt, updated: (await handle.stat()).mtimeMs });
30854
+ } catch (error62) {
30855
+ if (!(error62 instanceof SyntaxError)) throw error62;
30856
+ } finally {
30857
+ await handle.close();
30858
+ }
30859
+ }
30860
+ return matches.sort((a, b) => b.updated - a.updated);
30861
+ }
30862
+ async function loadSource(input2, recover) {
30863
+ const bytes = await fs4.readFile(input2);
30864
+ const [header, ...entries] = bytes.toString("utf8").split("\n").filter((line) => line.trim()).map((line) => JSON.parse(line));
30865
+ if (header?.type !== "session" || typeof header.id !== "string" || !header.id)
30866
+ throw new Error("Source must have a session header with an ID");
30867
+ if (entries.some((row) => !row || typeof row !== "object" || Array.isArray(row)))
30868
+ throw new Error("Source contains an invalid session row");
30869
+ const mirrors = entries.filter((row) => "seq" in row);
30870
+ if (mirrors.length && !recover) throw new MixedSession(
30871
+ `Source contains ${mirrors.length} DSH event rows. Choose a native Pi file or explicitly approve --recover-pi-entries.`
30872
+ );
30873
+ const native = entries.filter((row) => !("seq" in row));
30874
+ if (!mirrors.length && header.version !== 3)
30875
+ throw new Error("This workflow requires a Pi v3 header or a supported mixed log");
30876
+ if (mirrors.length && (header.version !== 4 || !mirrors.every(
30877
+ (row) => Number.isSafeInteger(row.seq) && row.seq >= 0 && typeof row.type === "string" && "data" in row
30878
+ ))) throw new Error("Mixed source has an unsupported header or event shapes");
30879
+ const ids = /* @__PURE__ */ new Set();
30880
+ for (const row of native) {
30881
+ const legacyRoot = mirrors.length && ids.size === 0 && row.type === "model_change" && row.parentId === void 0;
30882
+ if (!piEntryTypes.has(row.type) || typeof row.id !== "string" || !row.id || ids.has(row.id) || !legacyRoot && row.parentId !== null && !ids.has(row.parentId))
30883
+ throw new Error("Source has ambiguous Pi entries or parent links");
30884
+ ids.add(row.id);
30885
+ }
30886
+ if (!native.some((row) => row.type === "message")) throw new Error("Source has no native Pi messages");
30887
+ const timestamp = header.timestamp ?? (mirrors.length && Number.isFinite(header.createdAt) ? new Date(header.createdAt).toISOString() : void 0);
30888
+ if (typeof timestamp !== "string" || !Number.isFinite(Date.parse(timestamp))) throw new Error("Source has no valid creation time");
30889
+ const pi = {
30890
+ header: mirrors.length ? { type: "session", version: 3, id: header.id, timestamp, cwd: header.cwd } : header,
30891
+ entries: native
30892
+ };
30893
+ return { pi, sha256: digest3(bytes), mirrorRows: mirrors.length };
30894
+ }
30895
+ async function portableOutput(dir, sessionId) {
30896
+ const folder = path4.join(dir, "dcp-" + escapeSegment(sessionId));
30897
+ try {
30898
+ await fs4.lstat(folder);
30899
+ throw new DestinationConflict(`Export directory already exists: ${folder}`);
30900
+ } catch (error62) {
30901
+ if (error62.code !== "ENOENT") throw error62;
30902
+ }
30903
+ return path4.join(folder, "session.dsh.jsonl");
30904
+ }
30905
+ async function prepare(options, copyId) {
30906
+ const { target, dshVersion, profile, encoding } = options;
30907
+ if (!migrationTargets.includes(target)) throw new Error("Choose an explicit migration target");
30908
+ if (target === "windows-desktop" && process.platform !== "win32" || target === "linux-desktop" && process.platform !== "linux")
30909
+ throw new Error(`Run this migration on the native host for ${target}`);
30910
+ const source = await fs4.realpath(absolute(options.source, "Pi source"));
30911
+ const { pi, sha256, mirrorRows } = await loadSource(source, options.recoverPiEntries === true);
30912
+ const portable = target === "portable";
30913
+ if (portable && [dshVersion, profile, encoding, options.dshHome, options.sessionRoot, options.workspace].some(Boolean))
30914
+ throw new Error("A portable export only takes --export-dir for its target");
30915
+ if (!portable && options.exportDir) throw new Error("Use --session-root for a direct import");
30916
+ if (!portable && (!dshVersion || !dshVersions.includes(dshVersion)))
30917
+ throw new Error(`Confirm an exact tested DSH backend version: ${dshVersions.join(", ")}`);
30918
+ if (!portable && (!profile?.trim() || encoding !== "zstd" && encoding !== "plain"))
30919
+ throw new Error("Confirm the target profile or instance and its encoding (zstd or plain)");
30920
+ if (options.onConflict && options.onConflict !== "stop" && options.onConflict !== "copy")
30921
+ throw new Error("Choose a conflict policy of stop or copy");
30922
+ const cwd = portable ? pi.header.cwd : await directory(options.workspace, "Target workspace");
30923
+ if (typeof cwd !== "string" || !cwd) throw new Error("Source does not name a project directory");
30924
+ const dshHome = portable ? void 0 : await directory(options.dshHome, "Target DSH home");
30925
+ const sessionRoot = portable ? void 0 : await targetRoot(options.sessionRoot);
30926
+ const exportDir = portable ? await directory(options.exportDir, "Export directory") : void 0;
30927
+ const resolveOutput = (id) => portable ? portableOutput(exportDir, id) : nativeDestination(sessionRoot, id, cwd, encoding === "plain");
30928
+ let sessionId = pi.header.id;
30929
+ let output2;
30930
+ let conflict;
30931
+ try {
30932
+ output2 = await resolveOutput(sessionId);
30933
+ } catch (error62) {
30934
+ if (!(error62 instanceof DestinationConflict) || options.onConflict !== "copy") throw error62;
30935
+ conflict = error62.message;
30936
+ sessionId = copyId ?? randomUUID5();
30937
+ if (!/^[0-9a-f-]{36}$/i.test(sessionId) || sessionId === pi.header.id)
30938
+ throw new Error("Invalid new session ID in the migration plan");
30939
+ output2 = await resolveOutput(sessionId);
30940
+ }
30941
+ const plan = {
30942
+ host: hostname3(),
30943
+ platform: process.platform,
30944
+ source,
30945
+ sourceSessionId: pi.header.id,
30946
+ sourceCwd: pi.header.cwd,
30947
+ sha256,
30948
+ sourceMessages: pi.entries.filter((row) => row.type === "message").length,
30949
+ mirrorRows,
30950
+ target,
30951
+ dshVersion,
30952
+ profile,
30953
+ encoding,
30954
+ dshHome,
30955
+ sessionRoot,
30956
+ exportDir,
30957
+ sessionId,
30958
+ cwd,
30959
+ output: output2,
30960
+ conflict,
30961
+ attachmentHome: dshHome ?? path4.dirname(output2)
30962
+ };
30963
+ return { pi, plan };
30964
+ }
30965
+ async function planMigration(options) {
30966
+ const { plan } = await prepare(options);
30967
+ return { schema: 1, options, ...plan, confirmation: digest3(JSON.stringify(plan)).slice(0, 12) };
30968
+ }
30969
+ async function applyMigration(saved, confirmation) {
30970
+ if (saved.schema !== 1 || !confirmation || confirmation !== saved.confirmation)
30971
+ throw new Error("Apply requires the confirmation code from the approved plan");
30972
+ const { plan, pi } = await prepare(saved.options, saved.sessionId);
30973
+ if (digest3(JSON.stringify(plan)).slice(0, 12) !== confirmation)
30974
+ throw new Error("The source, target, or conflict changed. Generate and confirm a new plan.");
30975
+ const { source, sessionId, cwd, output: output2, dshHome, sessionRoot, encoding } = plan;
30976
+ const destination = { id: sessionId, cwd };
30977
+ if (sessionRoot && dshHome) {
30978
+ const report = await importPiToDsh(source, sessionRoot, encoding === "plain", { pi, sessionId, cwd, dshHome });
30979
+ return { ...report, target: plan.target, attachmentHome: plan.attachmentHome, status: "written", verification: "open-and-check-target-history" };
30980
+ }
30981
+ const folder = path4.dirname(output2);
30982
+ await fs4.mkdir(folder, { mode: 448 });
30983
+ try {
30984
+ const report = await exportPiSession(pi, output2, { dshHome: folder, destination });
30985
+ return { ...report, output: output2, sessionId, cwd, target: plan.target, attachmentHome: folder, status: "exported" };
30986
+ } catch (error62) {
30987
+ await fs4.rm(folder, { recursive: true, force: true });
30988
+ throw error62;
30989
+ }
30990
+ }
30991
+
30992
+ // src/dsh/migration-web.ts
30993
+ import { randomUUID as randomUUID6 } from "node:crypto";
30994
+ import { promises as fs5 } from "node:fs";
30995
+ async function verifyWebSession(urlFile, sessionId, events) {
30996
+ if (!sessionId || !Number.isSafeInteger(events) || events < 1)
30997
+ throw new Error("Pass the sessionId and event count from the migration receipt");
30998
+ let url2;
30999
+ try {
31000
+ url2 = new URL((await fs5.readFile(urlFile, "utf8")).trim());
31001
+ } catch {
31002
+ throw new Error("The URL file must contain one DSH Web launch URL");
31003
+ }
31004
+ if (!["http:", "https:"].includes(url2.protocol) || url2.username || url2.password || !url2.searchParams.has("token"))
31005
+ throw new Error("The URL file must contain one DSH Web launch URL");
31006
+ const send = async (target, options) => {
31007
+ try {
31008
+ return await fetch(target, { ...options, redirect: "manual", signal: AbortSignal.timeout(2e4) });
31009
+ } catch {
31010
+ throw new Error("The confirmed DSH Web instance is unreachable");
31011
+ }
31012
+ };
31013
+ const auth = await send(url2, {});
31014
+ const cookie = auth.headers.get("set-cookie")?.split(";", 1)[0];
31015
+ if (!cookie || auth.status !== 303) throw new Error(`DSH Web authentication failed (HTTP ${auth.status})`);
31016
+ const headers = { "content-type": "application/json", cookie };
31017
+ async function rpc(method, args) {
31018
+ const response = await send(new URL(`./api/${method}`, url2), {
31019
+ method: "POST",
31020
+ headers,
31021
+ body: JSON.stringify({ type: "client-request", rpcId: randomUUID6(), method, payload: { args } })
31022
+ });
31023
+ const body = await response.json().catch(() => void 0);
31024
+ if (!body?.result?.ok) throw new Error(`DSH Web ${method} failed (HTTP ${response.status}, ${body?.result?.error?.code ?? "no result"})`);
31025
+ return body.result.value;
31026
+ }
31027
+ const list = await rpc("session/list", { _request: {} });
31028
+ if (!Array.isArray(list?.items) || !list.items.some((item) => item.sessionId === sessionId))
31029
+ throw new Error("The imported ID is missing from the target DSH session list");
31030
+ await rpc("session/page", {
31031
+ request: { address: { kind: "session", sessionId }, throughSeq: events - 1, maxMessages: 3 }
31032
+ });
31033
+ return { sessionId, origin: url2.origin, status: "verified", checks: ["session/list", "session/page"] };
31034
+ }
31035
+
31036
+ // src/dsh/migration-cli.ts
30724
31037
  var help = `Usage:
31038
+ dcp-session migrate [<absolute-pi-session>] Interactive terminal
31039
+ dcp-session migrate environment
31040
+ dcp-session migrate sources [--pi-home <dir>] [--id <id>] [--cwd <dir>]
31041
+ dcp-session migrate plan --source <file> --target <target> --plan-file <file> [options]
31042
+ dcp-session migrate apply --plan-file <file> --confirm <code>
31043
+ dcp-session migrate verify-web --url-file <file> --session-id <id> --events <count>
31044
+
31045
+ Targets: ${migrationTargets.join(", ")}
31046
+ Portable target: --export-dir <directory>
31047
+ Direct targets: --profile <name> --dsh-version <version> --dsh-home <directory>
31048
+ --session-root <directory> --workspace <directory> --encoding <zstd|plain>
31049
+ Conflict options: --on-conflict <stop|copy>, --recover-pi-entries
31050
+ Tested DSH versions: ${dshVersions.join(", ")}
31051
+ Plans preview the exact host and paths. Apply rechecks the source and destination before writing.`;
31052
+ var print = (value) => console.log(JSON.stringify(value, null, 2));
31053
+ async function interactive(source) {
31054
+ if (!process.stdin.isTTY || !process.stdout.isTTY)
31055
+ throw new Error("Interactive mode needs a terminal. Use migrate plan and apply from an agent.");
31056
+ const reader = createInterface({ input: process.stdin, output: process.stdout });
31057
+ const ask = async (prompt) => (await reader.question(prompt + " ")).trim();
31058
+ try {
31059
+ const target = await ask(`Target (${migrationTargets.join(", ")}):`);
31060
+ if (!migrationTargets.includes(target)) throw new Error("Choose a listed target");
31061
+ const options = { source: source ?? await ask("Absolute Pi session path:"), target };
31062
+ if (target === "portable") options.exportDir = await ask("Absolute export directory:");
31063
+ else {
31064
+ options.profile = await ask("Target profile or instance name:");
31065
+ options.dshVersion = await ask(`Target DSH backend version (${dshVersions.join(", ")}):`);
31066
+ options.dshHome = await ask("Absolute target DSH home (attachment store):");
31067
+ options.sessionRoot = await ask("Absolute target session directory:");
31068
+ options.workspace = await ask("Absolute target workspace:");
31069
+ options.encoding = await ask("Target session encoding (zstd or plain):");
31070
+ }
31071
+ let plan;
31072
+ for (; ; ) {
31073
+ try {
31074
+ plan = await planMigration(options);
31075
+ break;
31076
+ } catch (error62) {
31077
+ if (error62 instanceof MixedSession && !options.recoverPiEntries) {
31078
+ console.log(error62.message);
31079
+ if (await ask("Use only the native Pi entries and preserve the source file? Type recover or press Enter to cancel.") !== "recover") return;
31080
+ options.recoverPiEntries = true;
31081
+ } else if (error62 instanceof DestinationConflict && options.onConflict !== "copy") {
31082
+ console.log(error62.message);
31083
+ if (await ask("Keep the existing session and use a new ID? Type copy or press Enter to cancel.") !== "copy") return;
31084
+ options.onConflict = "copy";
31085
+ } else throw error62;
31086
+ }
31087
+ }
31088
+ console.log(`Session ${plan.sourceSessionId} \u2192 ${plan.target} on ${plan.host}`);
31089
+ console.log(`Output: ${plan.output}`);
31090
+ if (plan.attachmentHome !== path5.dirname(plan.output))
31091
+ console.log(`Attachments: ${plan.attachmentHome}`);
31092
+ if (plan.sessionId !== plan.sourceSessionId)
31093
+ console.log(`New session ID: ${plan.sessionId}`);
31094
+ if (plan.mirrorRows)
31095
+ console.log(`Recover Pi entries only, leaving ${plan.mirrorRows} DSH rows in the source.`);
31096
+ const code = await ask(`Write to this location? Enter ${plan.confirmation} to confirm, or press Enter to cancel.`);
31097
+ if (!code) return;
31098
+ print(await applyMigration(plan, code));
31099
+ } finally {
31100
+ reader.close();
31101
+ }
31102
+ }
31103
+ async function runMigration(args) {
31104
+ const [mode, ...rest] = args;
31105
+ switch (mode) {
31106
+ case "--help":
31107
+ case "-h":
31108
+ console.log(help);
31109
+ return;
31110
+ case "environment":
31111
+ if (rest.length) throw new Error("migrate environment takes no arguments");
31112
+ print(migrationEnvironment());
31113
+ return;
31114
+ case "sources": {
31115
+ const { values } = parseArgs({ args: rest, options: {
31116
+ "pi-home": { type: "string" },
31117
+ id: { type: "string" },
31118
+ cwd: { type: "string" }
31119
+ } });
31120
+ print(await findPiSources({ piHome: values["pi-home"], id: values.id, cwd: values.cwd }));
31121
+ return;
31122
+ }
31123
+ case "plan": {
31124
+ const { values: v } = parseArgs({ args: rest, options: {
31125
+ source: { type: "string" },
31126
+ target: { type: "string" },
31127
+ "plan-file": { type: "string" },
31128
+ "export-dir": { type: "string" },
31129
+ profile: { type: "string" },
31130
+ "dsh-version": { type: "string" },
31131
+ "dsh-home": { type: "string" },
31132
+ "session-root": { type: "string" },
31133
+ workspace: { type: "string" },
31134
+ encoding: { type: "string" },
31135
+ "on-conflict": { type: "string" },
31136
+ "recover-pi-entries": { type: "boolean" }
31137
+ } });
31138
+ if (!v.source || !v.target || !v["plan-file"]) throw new Error("Pass --source, --target and --plan-file");
31139
+ const plan = await planMigration({
31140
+ source: v.source,
31141
+ target: v.target,
31142
+ workspace: v.workspace,
31143
+ profile: v.profile,
31144
+ dshVersion: v["dsh-version"],
31145
+ dshHome: v["dsh-home"],
31146
+ sessionRoot: v["session-root"],
31147
+ exportDir: v["export-dir"],
31148
+ encoding: v.encoding,
31149
+ onConflict: v["on-conflict"],
31150
+ recoverPiEntries: v["recover-pi-entries"]
31151
+ });
31152
+ await fs6.writeFile(v["plan-file"], JSON.stringify(plan, null, 2) + "\n", { mode: 384, flag: "wx" });
31153
+ print(plan);
31154
+ return;
31155
+ }
31156
+ case "apply": {
31157
+ const { values } = parseArgs({ args: rest, options: {
31158
+ "plan-file": { type: "string" },
31159
+ confirm: { type: "string" }
31160
+ } });
31161
+ if (!values["plan-file"] || !values.confirm) throw new Error("Pass --plan-file and the approved --confirm code");
31162
+ print(await applyMigration(JSON.parse(await fs6.readFile(values["plan-file"], "utf8")), values.confirm));
31163
+ return;
31164
+ }
31165
+ case "verify-web": {
31166
+ const { values } = parseArgs({ args: rest, options: {
31167
+ "url-file": { type: "string" },
31168
+ "session-id": { type: "string" },
31169
+ events: { type: "string" }
31170
+ } });
31171
+ if (!values["url-file"] || !values["session-id"] || !values.events)
31172
+ throw new Error("Pass --url-file, --session-id, and --events from the migration receipt");
31173
+ print(await verifyWebSession(values["url-file"], values["session-id"], Number(values.events)));
31174
+ return;
31175
+ }
31176
+ default:
31177
+ if (rest.length || mode?.startsWith("--")) throw new Error(help);
31178
+ await interactive(mode);
31179
+ }
31180
+ }
31181
+
31182
+ // bin/dcp-session.ts
31183
+ var help2 = `Usage:
31184
+ dcp-session migrate --help
30725
31185
  dcp-session pi2dsh <pi-session.jsonl> <out.dsh.jsonl>
30726
31186
  dcp-session pi2dsh-import <pi-session.jsonl> [dsh-session-root] [--plain]
30727
31187
  dcp-session dsh2pi <dsh-session.jsonl> <out.pi.jsonl>
@@ -30736,24 +31196,28 @@ continued DSH session it imports the active DSH context.
30736
31196
 
30737
31197
  Use a separate output path. DSH input may be .jsonl or .zstd (requires zstd).
30738
31198
  Image references are resolved under DSH_HOME (default ~/.dsh).`;
30739
- var [command, input2, ...args] = process.argv.slice(2);
30740
- if (command === "--help" || command === "-h") {
30741
- console.log(help);
30742
- process.exit(0);
30743
- }
30744
- var importing = command === "pi2dsh-import";
30745
- var plain = importing && args.at(-1) === "--plain";
30746
- if (plain) args.pop();
30747
- var [output2, ...extra2] = args;
30748
- var valid = importing ? !output2?.startsWith("--") : (command === "pi2dsh" || command === "dsh2pi") && output2 && extra2.length === 0;
30749
- if (!input2 || !valid || extra2.length) {
30750
- console.error(help);
30751
- process.exit(2);
30752
- }
30753
- try {
31199
+ async function main([command, input2, ...args]) {
31200
+ if (command === "--help" || command === "-h") {
31201
+ console.log(help2);
31202
+ return;
31203
+ }
31204
+ if (command === "migrate") return runMigration(input2 === void 0 ? [] : [input2, ...args]);
31205
+ const importing = command === "pi2dsh-import";
31206
+ const plain = importing && args.at(-1) === "--plain";
31207
+ if (plain) args.pop();
31208
+ const [output2, ...extra2] = args;
31209
+ const valid = importing ? !output2?.startsWith("--") : (command === "pi2dsh" || command === "dsh2pi") && output2;
31210
+ if (!input2 || !valid || extra2.length) {
31211
+ console.error(help2);
31212
+ process.exitCode = 2;
31213
+ return;
31214
+ }
30754
31215
  const report = importing ? await importPiToDsh(input2, output2, plain) : command === "pi2dsh" ? await piToDsh(input2, output2) : await dshToPi(input2, output2);
30755
31216
  console.log(JSON.stringify(report, null, 2));
31217
+ }
31218
+ try {
31219
+ await main(process.argv.slice(2));
30756
31220
  } catch (error62) {
30757
31221
  console.error(error62 instanceof Error ? error62.message : String(error62));
30758
- process.exit(1);
31222
+ process.exitCode = 1;
30759
31223
  }