dsh-compact-pi 0.2.3-b2 → 0.2.3-b3

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.
@@ -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, args) => {
489
+ apply: (target, thisArg, args2) => {
490
490
  if (thisArg === outer) thisArg = shadow;
491
- return getTraceable(ctx, Reflect.apply(target, thisArg, args));
491
+ return getTraceable(ctx, Reflect.apply(target, thisArg, args2));
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, args) => {
540
+ apply: (target, thisArg, args2) => {
541
541
  const receiver = tracker.noShadow ? proxy : createShadow(useSite, target, tracker.property, proxy);
542
- return applyTraceable(receiver, target, thisArg, args);
542
+ return applyTraceable(receiver, target, thisArg, args2);
543
543
  }
544
544
  });
545
545
  return proxy;
546
546
  }
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);
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);
550
550
  }
551
551
  function createCallable(name2, proto, tracker) {
552
- const self = function(...args) {
552
+ const self = function(...args2) {
553
553
  const proxy = createTraceable(self["ctx"], self, tracker);
554
- return Reflect.apply(proxy, this, args);
554
+ return Reflect.apply(proxy, this, args2);
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(path3 = []) {
633
- return path3.map((segment) => typeof segment === "object" ? segment.key : segment);
632
+ static normalizePath(path4 = []) {
633
+ return path4.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(path3) {
642
- return _ValidationError.normalizePath(path3).map(String).join(".");
641
+ static formatPath(path4) {
642
+ return _ValidationError.normalizePath(path4).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 args = ["internal/plugin", fiber];
666
+ const args2 = ["internal/plugin", fiber];
667
667
  let callbacks;
668
668
  try {
669
- callbacks = context.events.dispatch("emit", args);
669
+ callbacks = context.events.dispatch("emit", args2);
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(...args);
676
+ const returned = callback(...args2);
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, args) {
1261
- const thisArg = typeof args[0] === "object" || typeof args[0] === "function" ? args.shift() : null;
1262
- const name2 = args.shift();
1260
+ _resolve(type, args2) {
1261
+ const thisArg = typeof args2[0] === "object" || typeof args2[0] === "function" ? args2.shift() : null;
1262
+ const name2 = args2.shift();
1263
1263
  if ((typeof name2 !== "string" || !name2.startsWith("internal/")) && this._hooks["internal/dispatch"]?.length) {
1264
- this.emit("internal/dispatch", type, name2, args, thisArg);
1264
+ this.emit("internal/dispatch", type, name2, args2, 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, args) {
1278
- const [thisArg, callbacks] = this._resolve(type, args);
1277
+ dispatch(type, args2) {
1278
+ const [thisArg, callbacks] = this._resolve(type, args2);
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(...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)));
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)));
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(...args) {
1301
- const [thisArg, callbacks] = this._resolve("emit", args);
1302
- for (const callback of callbacks) Reflect.apply(callback, thisArg, args);
1300
+ emit(...args2) {
1301
+ const [thisArg, callbacks] = this._resolve("emit", args2);
1302
+ for (const callback of callbacks) Reflect.apply(callback, thisArg, args2);
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(...args) {
1311
- const [thisArg, callbacks] = this._resolve("serial", args);
1310
+ async serial(...args2) {
1311
+ const [thisArg, callbacks] = this._resolve("serial", args2);
1312
1312
  for (const callback of callbacks) {
1313
- const result = await Reflect.apply(callback, thisArg, args);
1313
+ const result = await Reflect.apply(callback, thisArg, args2);
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(...args) {
1324
- const [thisArg, callbacks] = this._resolve("bail", args);
1323
+ bail(...args2) {
1324
+ const [thisArg, callbacks] = this._resolve("bail", args2);
1325
1325
  for (const callback of callbacks) {
1326
- const result = Reflect.apply(callback, thisArg, args);
1326
+ const result = Reflect.apply(callback, thisArg, args2);
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(...args) {
1341
- const [thisArg, callbacks] = this._resolve("waterfall", args);
1342
- const inner = args.pop();
1340
+ waterfall(...args2) {
1341
+ const [thisArg, callbacks] = this._resolve("waterfall", args2);
1342
+ const inner = args2.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, [...args, next]);
1352
+ return Reflect.apply(callback, thisArg, [...args2, 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(...args) {
1405
+ const dispose = this.on(name2, function(...args2) {
1406
1406
  dispose();
1407
- return listener.apply(this, args);
1407
+ return listener.apply(this, args2);
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, args) => {
1693
- return Reflect.apply(target, this.trace(thisArg), args.map((arg) => this.trace(arg)));
1692
+ apply: (target, thisArg, args2) => {
1693
+ return Reflect.apply(target, this.trace(thisArg), args2.map((arg) => this.trace(arg)));
1694
1694
  },
1695
- construct: (target, args, newTarget) => {
1696
- return Reflect.construct(target, args.map((arg) => this.trace(arg)), newTarget);
1695
+ construct: (target, args2, newTarget) => {
1696
+ return Reflect.construct(target, args2.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 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();
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();
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 = args.shift();
1872
+ const value = args2.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 args) {
1878
+ for (let arg of args2) {
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 (...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));
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));
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 };
1904
+ const message = { sn, ts, type, level, name: this.name, ...this.meta, args: args2 };
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(...args) {
2047
- return this()[type](...args);
2046
+ _LoggerService.prototype[type] = function(...args2) {
2047
+ return this()[type](...args2);
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 valid = true;
2857
- for (let i = 0; i < hex3.length; i++) if (!isHex(hex3[i])) valid = false;
2858
- if (valid) {
2856
+ let valid2 = true;
2857
+ for (let i = 0; i < hex3.length; i++) if (!isHex(hex3[i])) valid2 = false;
2858
+ if (valid2) {
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 path3 = /* @__PURE__ */ new Set();
3331
+ const path4 = /* @__PURE__ */ new Set();
3332
3332
  const render = (current) => {
3333
- if (path3.has(current)) return "<circular cause>";
3334
- path3.add(current);
3333
+ if (path4.has(current)) return "<circular cause>";
3334
+ path4.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
- path3.delete(current);
3353
+ path4.delete(current);
3354
3354
  }
3355
3355
  };
3356
3356
  return render(value);
@@ -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, path3 = [], blocked = false, seen = /* @__PURE__ */ new Map()) {
3659
+ function validateVolatileSchema(schema, path4 = [], 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: path3 });
3665
+ throw new ValidationError2("volatile fields require a fixed object path without an enclosing volatile field", { path: path4 });
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, [...path3, key], nested, seen);
3669
+ for (const [key, child] of Object.entries(schema.dict)) validateVolatileSchema(child, [...path4, key], nested, seen);
3670
3670
  }
3671
- if (schema.sKey) validateVolatileSchema(schema.sKey, [...path3, "<key>"], true, seen);
3671
+ if (schema.sKey) validateVolatileSchema(schema.sKey, [...path4, "<key>"], true, seen);
3672
3672
  if (schema.inner && (schema.type !== "lazy" || schema.inner[kSchema])) {
3673
- validateVolatileSchema(schema.inner, [...path3, "*"], true, seen);
3673
+ validateVolatileSchema(schema.inner, [...path4, "*"], 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], [...path3, String(index)], true, seen);
3677
+ validateVolatileSchema(schema.list[index], [...path4, 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](...args) {
4009
+ [name2](...args2) {
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 = args[index] ?? Schema.string();
4014
+ schema.sKey = args2[index] ?? Schema.string();
4015
4015
  break;
4016
4016
  case "inner":
4017
- schema.inner = Schema.from(args[index]);
4017
+ schema.inner = Schema.from(args2[index]);
4018
4018
  break;
4019
4019
  case "list":
4020
- schema.list = args[index].map(Schema.from);
4020
+ schema.list = args2[index].map(Schema.from);
4021
4021
  break;
4022
4022
  case "dict":
4023
- schema.dict = mapValues(args[index], Schema.from);
4023
+ schema.dict = mapValues(args2[index], Schema.from);
4024
4024
  break;
4025
4025
  case "bits": {
4026
4026
  schema.bits = {};
4027
- for (const key2 in args[index]) {
4028
- if (typeof args[index][key2] !== "number") continue;
4029
- schema.bits[key2] = args[index][key2];
4027
+ for (const key2 in args2[index]) {
4028
+ if (typeof args2[index][key2] !== "number") continue;
4029
+ schema.bits[key2] = args2[index][key2];
4030
4030
  }
4031
4031
  break;
4032
4032
  }
4033
4033
  case "callback": {
4034
- const callback = schema.callback = args[index];
4034
+ const callback = schema.callback = args2[index];
4035
4035
  callback["toJSON"] ||= () => callback.toString();
4036
4036
  break;
4037
4037
  }
4038
4038
  case "constructor": {
4039
- const constructor = schema.constructor = args[index];
4039
+ const constructor = schema.constructor = args2[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] = args[index];
4047
+ schema[key] = args2[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, path3) {
4140
+ function validateKeys(value, allowed, path4) {
4141
4141
  for (const key of Object.keys(value)) {
4142
- if (!allowed.has(key)) throw new Error(`${path3}: unknown key "${key}"`);
4142
+ if (!allowed.has(key)) throw new Error(`${path4}: unknown key "${key}"`);
4143
4143
  }
4144
4144
  }
4145
- function resolveBackoff(config2, path3) {
4146
- if (config2 !== void 0) validateKeys(config2, BACKOFF_KEYS, path3);
4145
+ function resolveBackoff(config2, path4) {
4146
+ if (config2 !== void 0) validateKeys(config2, BACKOFF_KEYS, path4);
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(`${path3}.initialDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4151
+ throw new Error(`${path4}.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(`${path3}.maxDelayMs must be a positive finite number no greater than ${MAX_TIMER_DELAY_MS}`);
4154
+ throw new Error(`${path4}.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(`${path3}.initialDelayMs must be less than or equal to maxDelayMs`);
4157
+ throw new Error(`${path4}.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(`${path3}.jitterRatio must be between 0 and 1`);
4160
+ throw new Error(`${path4}.jitterRatio must be between 0 and 1`);
4161
4161
  }
4162
4162
  return Object.freeze({ initialDelayMs, maxDelayMs, jitterRatio });
4163
4163
  }
4164
- function resolveRetryPolicy(config2, path3) {
4164
+ function resolveRetryPolicy(config2, path4) {
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, `${path3}.backoff`)
4170
+ ...resolveBackoff(void 0, `${path4}.backoff`)
4171
4171
  });
4172
4172
  }
4173
4173
  switch (config2.mode) {
4174
4174
  case "normal": {
4175
- validateKeys(config2, NORMAL_POLICY_KEYS, path3);
4175
+ validateKeys(config2, NORMAL_POLICY_KEYS, path4);
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(`${path3}.maxRetries must be a non-negative safe integer`);
4179
+ throw new Error(`${path4}.maxRetries must be a non-negative safe integer`);
4180
4180
  }
4181
4181
  if (retryableCodes.length === 0) {
4182
- throw new Error(`${path3}.retryableCodes must not be empty`);
4182
+ throw new Error(`${path4}.retryableCodes must not be empty`);
4183
4183
  }
4184
4184
  if (retryableCodes.some((code) => typeof code !== "string" || code.length === 0)) {
4185
- throw new Error(`${path3}.retryableCodes must contain only non-empty strings`);
4185
+ throw new Error(`${path4}.retryableCodes must contain only non-empty strings`);
4186
4186
  }
4187
4187
  if (new Set(retryableCodes).size !== retryableCodes.length) {
4188
- throw new Error(`${path3}.retryableCodes must not contain duplicates`);
4188
+ throw new Error(`${path4}.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, `${path3}.backoff`)
4194
+ ...resolveBackoff(config2.backoff, `${path4}.backoff`)
4195
4195
  });
4196
4196
  }
4197
4197
  case "always":
4198
- validateKeys(config2, ALWAYS_POLICY_KEYS, path3);
4198
+ validateKeys(config2, ALWAYS_POLICY_KEYS, path4);
4199
4199
  return Object.freeze({
4200
4200
  mode: "always",
4201
- ...resolveBackoff(config2.backoff, `${path3}.backoff`)
4201
+ ...resolveBackoff(config2.backoff, `${path4}.backoff`)
4202
4202
  });
4203
4203
  default:
4204
- throw new Error(`${path3}.mode must be "normal" or "always"`);
4204
+ throw new Error(`${path4}.mode must be "normal" or "always"`);
4205
4205
  }
4206
4206
  }
4207
4207
  function callConfigEquals(a, b) {
@@ -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 fs3 = this.ctx.get("fs");
5249
- return fs3?.processPathFromHostPath(hostPath);
5248
+ const fs4 = this.ctx.get("fs");
5249
+ return fs4?.processPathFromHostPath(hostPath);
5250
5250
  }
5251
5251
  /**
5252
5252
  * Final adapter boundary. Adapter selection, dispatch, iterator construction,
@@ -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(path3) {
5653
- if (path3 === "~") return homedir();
5654
- if (path3.startsWith("~/") || path3.startsWith("~\\")) return join(homedir(), path3.slice(2));
5655
- return path3;
5652
+ function expandHomePath(path4) {
5653
+ if (path4 === "~") return homedir();
5654
+ if (path4.startsWith("~/") || path4.startsWith("~\\")) return join(homedir(), path4.slice(2));
5655
+ return path4;
5656
5656
  }
5657
5657
  function resolveRoot(configured, env, envName, fallback) {
5658
5658
  const fromEnv = env[envName];
@@ -5910,17 +5910,17 @@ async function prepareImageFile(input22, limits, policy) {
5910
5910
  }
5911
5911
  };
5912
5912
  }
5913
- async function syncDirectory(path3) {
5913
+ async function syncDirectory(path4) {
5914
5914
  if (process.platform === "win32") return;
5915
- const handle = await open(path3, constants.O_RDONLY);
5915
+ const handle = await open(path4, 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(path3, boundary) {
5923
- const target = resolve3(path3);
5922
+ async function ensureDurableDirectory(path4, boundary) {
5923
+ const target = resolve3(path4);
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(path3, boundary) {
5932
5932
  level = parent;
5933
5933
  }
5934
5934
  }
5935
- async function ensureDurableHome(path3) {
5936
- const home = resolve3(path3);
5935
+ async function ensureDurableHome(path4) {
5936
+ const home = resolve3(path4);
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(path3) {
6056
+ async function digestFile(path4) {
6057
6057
  const hash2 = createHash("sha256");
6058
- for await (const chunk of createReadStream(path3)) hash2.update(chunk);
6058
+ for await (const chunk of createReadStream(path4)) hash2.update(chunk);
6059
6059
  return hash2.digest("hex");
6060
6060
  }
6061
- async function removeTemporary(path3) {
6062
- await unlink(path3).catch(
6061
+ async function removeTemporary(path4) {
6062
+ await unlink(path4).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;
@@ -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(path3, target, expectedAlpha, signal) {
6281
+ async function readCached(path4, target, expectedAlpha, signal) {
6282
6282
  try {
6283
- const data = new Uint8Array(await readFile2(path3, { signal }));
6283
+ const data = new Uint8Array(await readFile2(path4, { 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(path3, data) {
6305
- await mkdir2(dirname3(path3), { recursive: true, mode: 448 });
6306
- const temporary = `${path3}.${randomUUID3()}.tmp`;
6304
+ async function writeCached(path4, data) {
6305
+ await mkdir2(dirname3(path4), { recursive: true, mode: 448 });
6306
+ const temporary = `${path4}.${randomUUID3()}.tmp`;
6307
6307
  try {
6308
6308
  await writeFile(temporary, data, { mode: 384, flag: "wx" });
6309
- await rename(temporary, path3);
6309
+ await rename(temporary, path4);
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 path3 = cachePath(root, hash2);
6321
- const cached2 = await readCached(path3, target, source.hasAlpha, signal);
6320
+ const path4 = cachePath(root, hash2);
6321
+ const cached2 = await readCached(path4, 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(path3, version3.data);
6325
+ if (cached2 === void 0 && version3.data !== attachment.data) await writeCached(path4, version3.data);
6326
6326
  return {
6327
6327
  variantId,
6328
6328
  attachment: attachment.ref,
@@ -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, path3) {
7551
- if (!path3)
7550
+ function getElementAtPath(obj, path4) {
7551
+ if (!path4)
7552
7552
  return obj;
7553
- return path3.reduce((acc, key) => acc?.[key], obj);
7553
+ return path4.reduce((acc, key) => acc?.[key], obj);
7554
7554
  }
7555
7555
  function promiseAllObject(promisesObj) {
7556
7556
  const keys = Object.keys(promisesObj);
@@ -7890,11 +7890,11 @@ function explicitlyAborted(x, startIndex = 0) {
7890
7890
  }
7891
7891
  return false;
7892
7892
  }
7893
- function prefixIssues(path3, issues) {
7893
+ function prefixIssues(path4, issues) {
7894
7894
  return issues.map((iss) => {
7895
7895
  var _a4;
7896
7896
  (_a4 = iss).path ?? (_a4.path = []);
7897
- iss.path.unshift(path3);
7897
+ iss.path.unshift(path4);
7898
7898
  return iss;
7899
7899
  });
7900
7900
  }
@@ -7994,8 +7994,8 @@ function parsedType(data) {
7994
7994
  }
7995
7995
  return t;
7996
7996
  }
7997
- function issue(...args) {
7998
- const [iss, input22, inst] = args;
7997
+ function issue(...args2) {
7998
+ const [iss, input22, inst] = args2;
7999
7999
  if (typeof iss === "string") {
8000
8000
  return {
8001
8001
  message: iss,
@@ -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, path3 = []) => {
8355
+ const processError = (error63, path4 = []) => {
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 }, [...path3, ...issue2.path]));
8358
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
8359
8359
  } else if (issue2.code === "invalid_key") {
8360
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
8360
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8361
8361
  } else if (issue2.code === "invalid_element") {
8362
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
8362
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8363
8363
  } else {
8364
- const fullpath = [...path3, ...issue2.path];
8364
+ const fullpath = [...path4, ...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, path3 = []) => {
8403
+ const processError = (error63, path4 = []) => {
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 }, [...path3, ...issue2.path]));
8407
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
8408
8408
  } else if (issue2.code === "invalid_key") {
8409
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
8409
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8410
8410
  } else if (issue2.code === "invalid_element") {
8411
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
8411
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
8412
8412
  } else {
8413
- const fullpath = [...path3, ...issue2.path];
8413
+ const fullpath = [...path4, ...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 path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
8453
- for (const seg of path3) {
8452
+ const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
8453
+ for (const seg of path4) {
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(args) {
8755
+ function timeSource(args2) {
8756
8756
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\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+)?)?`;
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+)?)?`;
8758
8758
  return regex;
8759
8759
  }
8760
- function time(args) {
8761
- return new RegExp(`^${timeSource(args)}$`);
8760
+ function time(args2) {
8761
+ return new RegExp(`^${timeSource(args2)}$`);
8762
8762
  }
8763
- function datetime(args) {
8763
+ function datetime(args2) {
8764
8764
  const opts = ["Z"];
8765
- if (args.offset)
8765
+ if (args2.offset)
8766
8766
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
8767
- const qualified = `${timeSource({ precision: args.precision, seconds: true })}(?:${opts.join("|")})`;
8768
- const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
8767
+ const qualified = `${timeSource({ precision: args2.precision, seconds: true })}(?:${opts.join("|")})`;
8768
+ const timeRegex = args2.local ? `${qualified}|${timeSource({ precision: args2.precision })}` : qualified;
8769
8769
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
8770
8770
  }
8771
8771
  var anyString = /^[\s\S]{0,}$/;
@@ -9278,10 +9278,10 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
9278
9278
  };
9279
9279
  });
9280
9280
  var Doc = class {
9281
- constructor(args = [], closed = {}) {
9281
+ constructor(args2 = [], closed = {}) {
9282
9282
  this.content = [];
9283
9283
  this.indent = 0;
9284
- this.args = args;
9284
+ this.args = args2;
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
@@ -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(...args) {
11640
- const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
11639
+ return Object.defineProperty(function(...args2) {
11640
+ const parsedArgs = inst._def.input ? parse2(inst._def.input, args2) : args2;
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(...args) {
11653
- const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args) : args;
11652
+ return Object.defineProperty(async function(...args2) {
11653
+ const parsedArgs = inst._def.input ? await parseAsync(inst._def.input, args2) : args2;
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,22 +11676,22 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
11676
11676
  }
11677
11677
  return payload;
11678
11678
  };
11679
- inst.input = (...args) => {
11679
+ inst.input = (...args2) => {
11680
11680
  const F = inst.constructor;
11681
- if (Array.isArray(args[0])) {
11681
+ if (Array.isArray(args2[0])) {
11682
11682
  return new F({
11683
11683
  type: "function",
11684
11684
  input: new $ZodTuple({
11685
11685
  type: "tuple",
11686
- items: args[0],
11687
- rest: args[1]
11686
+ items: args2[0],
11687
+ rest: args2[1]
11688
11688
  }),
11689
11689
  output: inst._def.output
11690
11690
  });
11691
11691
  }
11692
11692
  return new F({
11693
11693
  type: "function",
11694
- input: args[0],
11694
+ input: args2[0],
11695
11695
  output: inst._def.output
11696
11696
  });
11697
11697
  };
@@ -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(...args) {
23904
- if (args.length === 0)
23903
+ meta(...args2) {
23904
+ if (args2.length === 0)
23905
23905
  return globalRegistry.get(this);
23906
23906
  const cl = this.clone();
23907
- globalRegistry.add(cl, args[0]);
23907
+ globalRegistry.add(cl, args2[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, ...args) {
23917
- return args.length === 0 ? fn(this) : fn(this, ...args);
23916
+ apply(fn, ...args2) {
23917
+ return args2.length === 0 ? fn(this) : fn(this, ...args2);
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(...args) {
24006
- return this.check(/* @__PURE__ */ _regex(...args));
24005
+ regex(...args2) {
24006
+ return this.check(/* @__PURE__ */ _regex(...args2));
24007
24007
  },
24008
- includes(...args) {
24009
- return this.check(/* @__PURE__ */ _includes(...args));
24008
+ includes(...args2) {
24009
+ return this.check(/* @__PURE__ */ _includes(...args2));
24010
24010
  },
24011
- startsWith(...args) {
24012
- return this.check(/* @__PURE__ */ _startsWith(...args));
24011
+ startsWith(...args2) {
24012
+ return this.check(/* @__PURE__ */ _startsWith(...args2));
24013
24013
  },
24014
- endsWith(...args) {
24015
- return this.check(/* @__PURE__ */ _endsWith(...args));
24014
+ endsWith(...args2) {
24015
+ return this.check(/* @__PURE__ */ _endsWith(...args2));
24016
24016
  },
24017
- min(...args) {
24018
- return this.check(/* @__PURE__ */ _minLength(...args));
24017
+ min(...args2) {
24018
+ return this.check(/* @__PURE__ */ _minLength(...args2));
24019
24019
  },
24020
- max(...args) {
24021
- return this.check(/* @__PURE__ */ _maxLength(...args));
24020
+ max(...args2) {
24021
+ return this.check(/* @__PURE__ */ _maxLength(...args2));
24022
24022
  },
24023
- length(...args) {
24024
- return this.check(/* @__PURE__ */ _length(...args));
24023
+ length(...args2) {
24024
+ return this.check(/* @__PURE__ */ _length(...args2));
24025
24025
  },
24026
- nonempty(...args) {
24027
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
24026
+ nonempty(...args2) {
24027
+ return this.check(/* @__PURE__ */ _minLength(1, ...args2));
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(...args) {
24039
- return this.check(/* @__PURE__ */ _normalize(...args));
24038
+ normalize(...args2) {
24039
+ return this.check(/* @__PURE__ */ _normalize(...args2));
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(...args) {
24662
- return util_exports.partial(ZodOptional, this, args[0]);
24661
+ partial(...args2) {
24662
+ return util_exports.partial(ZodOptional, this, args2[0]);
24663
24663
  },
24664
- exactPartial(...args) {
24665
- return util_exports.partial(ZodExactOptional, this, args[0], "exactPartial");
24664
+ exactPartial(...args2) {
24665
+ return util_exports.partial(ZodExactOptional, this, args2[0], "exactPartial");
24666
24666
  },
24667
- required(...args) {
24668
- return util_exports.required(ZodNonOptional, this, args[0]);
24667
+ required(...args2) {
24668
+ return util_exports.required(ZodNonOptional, this, args2[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 = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
24828
+ inst.min = (...args2) => inst.check(/* @__PURE__ */ _minSize(...args2));
24829
24829
  inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
24830
- inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
24831
- inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
24830
+ inst.max = (...args2) => inst.check(/* @__PURE__ */ _maxSize(...args2));
24831
+ inst.size = (...args2) => inst.check(/* @__PURE__ */ _size(...args2));
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 = (...args) => inst.check(/* @__PURE__ */ _minSize(...args));
24846
+ inst.min = (...args2) => inst.check(/* @__PURE__ */ _minSize(...args2));
24847
24847
  inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minSize(1, params));
24848
- inst.max = (...args) => inst.check(/* @__PURE__ */ _maxSize(...args));
24849
- inst.size = (...args) => inst.check(/* @__PURE__ */ _size(...args));
24848
+ inst.max = (...args2) => inst.check(/* @__PURE__ */ _maxSize(...args2));
24849
+ inst.size = (...args2) => inst.check(/* @__PURE__ */ _size(...args2));
24850
24850
  });
24851
24851
  function set2(valueType, params) {
24852
24852
  return new ZodSet({
@@ -25252,11 +25252,11 @@ function _instanceof(cls, params = {}) {
25252
25252
  };
25253
25253
  return inst;
25254
25254
  }
25255
- var stringbool = (...args) => /* @__PURE__ */ _stringbool({
25255
+ var stringbool = (...args2) => /* @__PURE__ */ _stringbool({
25256
25256
  Codec: ZodCodec,
25257
25257
  Boolean: ZodBoolean,
25258
25258
  String: ZodString
25259
- }, ...args);
25259
+ }, ...args2);
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 path3 = ref.slice(1).split("/").filter(Boolean);
25420
- if (path3.length === 0) {
25419
+ const path4 = ref.slice(1).split("/").filter(Boolean);
25420
+ if (path4.length === 0) {
25421
25421
  return ctx.rootSchema;
25422
25422
  }
25423
25423
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
25424
- if (path3[0] === defsKey) {
25425
- const key = path3[1] === void 0 ? void 0 : decodeJSONPointerSegment(path3[1]);
25424
+ if (path4[0] === defsKey) {
25425
+ const key = path4[1] === void 0 ? void 0 : decodeJSONPointerSegment(path4[1]);
25426
25426
  if (!key || !ctx.defs[key]) {
25427
25427
  throw new Error(`Reference not found: ${ref}`);
25428
25428
  }
@@ -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, args) {
27479
- return [...ctx.events.dispatch("emit", args)];
27478
+ function collectSessionCallbacks(ctx, args2) {
27479
+ return [...ctx.events.dispatch("emit", args2)];
27480
27480
  }
27481
- function invokeContainedSessionObservers(ctx, name2, id, args, callbacks) {
27481
+ function invokeContainedSessionObservers(ctx, name2, id, args2, callbacks) {
27482
27482
  for (const callback of callbacks) {
27483
27483
  try {
27484
- const returned = callback(...args);
27484
+ const returned = callback(...args2);
27485
27485
  void Promise.resolve(returned).catch((error62) => {
27486
27486
  ctx.logger.warn(`session "${id}": ${name2} listener rejected: ${String(error62)}`);
27487
27487
  });
@@ -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 args = [this, event];
27709
- const callbacks = collectSessionCallbacks(entry.emitCtx, [entry.carrier, "session/event", ...args]);
27710
- return { event, args, callbacks };
27708
+ const args2 = [this, event];
27709
+ const callbacks = collectSessionCallbacks(entry.emitCtx, [entry.carrier, "session/event", ...args2]);
27710
+ return { event, args: args2, 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, callbacks } of publications) {
27716
+ for (const { event, args: args2, callbacks } of publications) {
27717
27717
  this.batchPublication = event;
27718
- invokeContainedSessionObservers(entry.emitCtx, "session/event", entry.id, args, callbacks);
27718
+ invokeContainedSessionObservers(entry.emitCtx, "session/event", entry.id, args2, callbacks);
27719
27719
  }
27720
27720
  }
27721
27721
  } finally {
@@ -29591,17 +29591,17 @@ function dshContentToPi(content, imageToPi) {
29591
29591
  });
29592
29592
  break;
29593
29593
  case "tool-call": {
29594
- let args = {};
29594
+ let args2 = {};
29595
29595
  try {
29596
- args = JSON.parse(String(block.arguments ?? "{}"));
29596
+ args2 = JSON.parse(String(block.arguments ?? "{}"));
29597
29597
  } catch {
29598
- args = {};
29598
+ args2 = {};
29599
29599
  }
29600
29600
  out.push({
29601
29601
  type: "toolCall",
29602
29602
  id: String(block.id ?? ""),
29603
29603
  name: String(block.name ?? ""),
29604
- arguments: args
29604
+ arguments: args2
29605
29605
  });
29606
29606
  break;
29607
29607
  }
@@ -30295,19 +30295,19 @@ function buildSessionPath(entries, leafId, byId) {
30295
30295
  if (!leaf) {
30296
30296
  return [];
30297
30297
  }
30298
- const path3 = [];
30298
+ const path4 = [];
30299
30299
  let current = leaf;
30300
30300
  while (current) {
30301
- path3.push(current);
30301
+ path4.push(current);
30302
30302
  current = current.parentId ? index.get(current.parentId) : void 0;
30303
30303
  }
30304
- path3.reverse();
30305
- return path3;
30304
+ path4.reverse();
30305
+ return path4;
30306
30306
  }
30307
- function getSessionContextSettings(path3) {
30307
+ function getSessionContextSettings(path4) {
30308
30308
  let thinkingLevel = "off";
30309
30309
  let model = null;
30310
- for (const entry of path3) {
30310
+ for (const entry of path4) {
30311
30311
  if (entry.type === "thinking_level_change") {
30312
30312
  thinkingLevel = entry.thinkingLevel;
30313
30313
  } else if (entry.type === "model_change") {
@@ -30343,24 +30343,24 @@ function sessionEntryToContextMessages(entry) {
30343
30343
  return [];
30344
30344
  }
30345
30345
  function buildContextEntries(entries, leafId, byId) {
30346
- const path3 = buildSessionPath(entries, leafId, byId);
30346
+ const path4 = buildSessionPath(entries, leafId, byId);
30347
30347
  let compaction = null;
30348
- for (const entry of path3) {
30348
+ for (const entry of path4) {
30349
30349
  if (entry.type === "compaction") {
30350
30350
  compaction = entry;
30351
30351
  }
30352
30352
  }
30353
30353
  if (!compaction) {
30354
- return path3;
30354
+ return path4;
30355
30355
  }
30356
- const compactionIdx = path3.findIndex((entry) => entry.id === compaction.id);
30356
+ const compactionIdx = path4.findIndex((entry) => entry.id === compaction.id);
30357
30357
  if (compactionIdx < 0) {
30358
- return path3;
30358
+ return path4;
30359
30359
  }
30360
30360
  const contextEntries = [compaction];
30361
30361
  let foundFirstKept = false;
30362
30362
  for (let i = 0; i < compactionIdx; i++) {
30363
- const entry = path3[i];
30363
+ const entry = path4[i];
30364
30364
  if (entry.id === compaction.firstKeptEntryId) {
30365
30365
  foundFirstKept = true;
30366
30366
  }
@@ -30368,7 +30368,7 @@ function buildContextEntries(entries, leafId, byId) {
30368
30368
  contextEntries.push(entry);
30369
30369
  }
30370
30370
  }
30371
- contextEntries.push(...path3.slice(compactionIdx + 1));
30371
+ contextEntries.push(...path4.slice(compactionIdx + 1));
30372
30372
  return contextEntries;
30373
30373
  }
30374
30374
  function projectContextEntry(entry, edit) {
@@ -30387,8 +30387,8 @@ function projectContextEntry(entry, edit) {
30387
30387
  });
30388
30388
  }
30389
30389
  function buildSessionProjection(entries, leafId, byId) {
30390
- const path3 = buildSessionPath(entries, leafId, byId);
30391
- const { thinkingLevel, model } = getSessionContextSettings(path3);
30390
+ const path4 = buildSessionPath(entries, leafId, byId);
30391
+ const { thinkingLevel, model } = getSessionContextSettings(path4);
30392
30392
  const contextEntries = buildContextEntries(entries, leafId, byId);
30393
30393
  const edits = /* @__PURE__ */ new Map();
30394
30394
  for (const entry of contextEntries) {
@@ -30652,29 +30652,106 @@ async function dshToPi(input3, output3) {
30652
30652
  return { input: input3, output: output3, messages: messages.length, events: dsh.events.length };
30653
30653
  }
30654
30654
 
30655
+ // src/dsh/import.ts
30656
+ import { promises as fs3 } from "node:fs";
30657
+ import { homedir as homedir2, tmpdir } from "node:os";
30658
+ import * as path3 from "node:path";
30659
+ import { promisify } from "node:util";
30660
+ import { constants as constants2, zstdCompress } from "node:zlib";
30661
+ var compress = promisify(zstdCompress);
30662
+ var zstdOptions = { params: { [constants2.ZSTD_c_checksumFlag]: 1 } };
30663
+ function escapeSegment(value) {
30664
+ return value.replace(
30665
+ /[^A-Za-z0-9._-]/g,
30666
+ (char) => "~" + char.charCodeAt(0).toString(16).toUpperCase().padStart(4, "0")
30667
+ );
30668
+ }
30669
+ function projectKey(cwd) {
30670
+ const readable = escapeSegment(cwd.replace(/[/\\:]+/g, "-")).replace(/^-+/, "");
30671
+ return `--${(readable || "root").slice(0, 251)}--`;
30672
+ }
30673
+ async function importPiToDsh(input3, root = path3.join(process.env.DSH_HOME || path3.join(homedir2(), ".dsh"), "sessions"), plaintext = false) {
30674
+ root = path3.resolve(root);
30675
+ const stage = await fs3.mkdtemp(path3.join(tmpdir(), "dcp-import-"));
30676
+ try {
30677
+ const raw = path3.join(stage, "session.jsonl");
30678
+ const report = await piToDsh(input3, raw);
30679
+ const bytes = await fs3.readFile(raw);
30680
+ 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
+ const stored = plaintext ? bytes : Buffer.concat(await Promise.all([
30697
+ compress(bytes.subarray(0, headerEnd), zstdOptions),
30698
+ compress(bytes.subarray(headerEnd), zstdOptions)
30699
+ ]));
30700
+ await fs3.mkdir(project, { recursive: true, mode: 448 });
30701
+ try {
30702
+ await fs3.mkdir(destination, { mode: 448 });
30703
+ } catch (error62) {
30704
+ if (error62.code === "EEXIST")
30705
+ throw new Error(`DSH session already exists: ${header.id} (${destination})`);
30706
+ throw error62;
30707
+ }
30708
+ const pending = path3.join(destination, ".dcp-import.tmp");
30709
+ try {
30710
+ await fs3.writeFile(pending, stored, { flag: "wx", mode: 384 });
30711
+ await fs3.rename(pending, output3);
30712
+ } catch (error62) {
30713
+ await fs3.rm(pending, { force: true });
30714
+ await fs3.rmdir(destination);
30715
+ throw error62;
30716
+ }
30717
+ return { ...report, output: output3, sessionId: header.id, cwd: header.cwd };
30718
+ } finally {
30719
+ await fs3.rm(stage, { recursive: true, force: true });
30720
+ }
30721
+ }
30722
+
30655
30723
  // bin/dcp-session.ts
30656
30724
  var help = `Usage:
30657
30725
  dcp-session pi2dsh <pi-session.jsonl> <out.dsh.jsonl>
30726
+ dcp-session pi2dsh-import <pi-session.jsonl> [dsh-session-root] [--plain]
30658
30727
  dcp-session dsh2pi <dsh-session.jsonl> <out.pi.jsonl>
30659
30728
  dcp-session --help
30660
30729
 
30661
30730
  pi2dsh exports the active pi context and archives the original pi entries.
30731
+ pi2dsh-import installs that export as a new DSH session. The default root is
30732
+ $DSH_HOME/sessions with Zstandard encoding. Use --plain only for a DSH profile
30733
+ configured with plaintext session storage.
30662
30734
  dsh2pi restores those entries from an unchanged export. For a native or
30663
30735
  continued DSH session it imports the active DSH context.
30664
30736
 
30665
30737
  Use a separate output path. DSH input may be .jsonl or .zstd (requires zstd).
30666
30738
  Image references are resolved under DSH_HOME (default ~/.dsh).`;
30667
- var [command, input2, output2, ...extra2] = process.argv.slice(2);
30739
+ var [command, input2, ...args] = process.argv.slice(2);
30668
30740
  if (command === "--help" || command === "-h") {
30669
30741
  console.log(help);
30670
30742
  process.exit(0);
30671
30743
  }
30672
- if (command !== "pi2dsh" && command !== "dsh2pi" || !input2 || !output2 || extra2.length) {
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) {
30673
30750
  console.error(help);
30674
30751
  process.exit(2);
30675
30752
  }
30676
30753
  try {
30677
- const report = command === "pi2dsh" ? await piToDsh(input2, output2) : await dshToPi(input2, output2);
30754
+ const report = importing ? await importPiToDsh(input2, output2, plain) : command === "pi2dsh" ? await piToDsh(input2, output2) : await dshToPi(input2, output2);
30678
30755
  console.log(JSON.stringify(report, null, 2));
30679
30756
  } catch (error62) {
30680
30757
  console.error(error62 instanceof Error ? error62.message : String(error62));