ofw-mcp 2.27.3 → 2.27.5

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.
package/dist/bundle.js CHANGED
@@ -25,9 +25,9 @@ var __export = (target, all) => {
25
25
  };
26
26
  var __copyProps = (to, from, except, desc) => {
27
27
  if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key2 of __getOwnPropNames(from))
29
- if (!__hasOwnProp.call(to, key2) && key2 !== except)
30
- __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
28
+ for (let key3 of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key3) && key3 !== except)
30
+ __defProp(to, key3, { get: () => from[key3], enumerable: !(desc = __getOwnPropDesc(from, key3)) || desc.enumerable });
31
31
  }
32
32
  return to;
33
33
  };
@@ -373,44 +373,44 @@ var require_permessage_deflate = __commonJS({
373
373
  */
374
374
  normalizeParams(configurations) {
375
375
  configurations.forEach((params) => {
376
- Object.keys(params).forEach((key2) => {
377
- let value = params[key2];
376
+ Object.keys(params).forEach((key3) => {
377
+ let value = params[key3];
378
378
  if (value.length > 1) {
379
- throw new Error(`Parameter "${key2}" must have only a single value`);
379
+ throw new Error(`Parameter "${key3}" must have only a single value`);
380
380
  }
381
381
  value = value[0];
382
- if (key2 === "client_max_window_bits") {
382
+ if (key3 === "client_max_window_bits") {
383
383
  if (value !== true) {
384
384
  const num = +value;
385
385
  if (!Number.isInteger(num) || num < 8 || num > 15) {
386
386
  throw new TypeError(
387
- `Invalid value for parameter "${key2}": ${value}`
387
+ `Invalid value for parameter "${key3}": ${value}`
388
388
  );
389
389
  }
390
390
  value = num;
391
391
  } else if (!this._isServer) {
392
392
  throw new TypeError(
393
- `Invalid value for parameter "${key2}": ${value}`
393
+ `Invalid value for parameter "${key3}": ${value}`
394
394
  );
395
395
  }
396
- } else if (key2 === "server_max_window_bits") {
396
+ } else if (key3 === "server_max_window_bits") {
397
397
  const num = +value;
398
398
  if (!Number.isInteger(num) || num < 8 || num > 15) {
399
399
  throw new TypeError(
400
- `Invalid value for parameter "${key2}": ${value}`
400
+ `Invalid value for parameter "${key3}": ${value}`
401
401
  );
402
402
  }
403
403
  value = num;
404
- } else if (key2 === "client_no_context_takeover" || key2 === "server_no_context_takeover") {
404
+ } else if (key3 === "client_no_context_takeover" || key3 === "server_no_context_takeover") {
405
405
  if (value !== true) {
406
406
  throw new TypeError(
407
- `Invalid value for parameter "${key2}": ${value}`
407
+ `Invalid value for parameter "${key3}": ${value}`
408
408
  );
409
409
  }
410
410
  } else {
411
- throw new Error(`Unknown parameter "${key2}"`);
411
+ throw new Error(`Unknown parameter "${key3}"`);
412
412
  }
413
- params[key2] = value;
413
+ params[key3] = value;
414
414
  });
415
415
  });
416
416
  return configurations;
@@ -458,8 +458,8 @@ var require_permessage_deflate = __commonJS({
458
458
  _decompress(data, fin, callback) {
459
459
  const endpoint = this._isServer ? "client" : "server";
460
460
  if (!this._inflate) {
461
- const key2 = `${endpoint}_max_window_bits`;
462
- const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
461
+ const key3 = `${endpoint}_max_window_bits`;
462
+ const windowBits = typeof this.params[key3] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key3];
463
463
  this._inflate = zlib.createInflateRaw({
464
464
  ...this._options.zlibInflateOptions,
465
465
  windowBits
@@ -509,8 +509,8 @@ var require_permessage_deflate = __commonJS({
509
509
  _compress(data, fin, callback) {
510
510
  const endpoint = this._isServer ? "server" : "client";
511
511
  if (!this._deflate) {
512
- const key2 = `${endpoint}_max_window_bits`;
513
- const windowBits = typeof this.params[key2] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key2];
512
+ const key3 = `${endpoint}_max_window_bits`;
513
+ const windowBits = typeof this.params[key3] !== "number" ? zlib.Z_DEFAULT_WINDOWBITS : this.params[key3];
514
514
  this._deflate = zlib.createDeflateRaw({
515
515
  ...this._options.zlibDeflateOptions,
516
516
  windowBits
@@ -2279,7 +2279,7 @@ var require_websocket = __commonJS({
2279
2279
  var http = __require("http");
2280
2280
  var net = __require("net");
2281
2281
  var tls = __require("tls");
2282
- var { randomBytes: randomBytes7, createHash: createHash7 } = __require("crypto");
2282
+ var { randomBytes: randomBytes7, createHash: createHash8 } = __require("crypto");
2283
2283
  var { Duplex, Readable } = __require("stream");
2284
2284
  var { URL: URL2 } = __require("url");
2285
2285
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -2830,7 +2830,7 @@ var require_websocket = __commonJS({
2830
2830
  }
2831
2831
  }
2832
2832
  const defaultPort = isSecure ? 443 : 80;
2833
- const key2 = randomBytes7(16).toString("base64");
2833
+ const key3 = randomBytes7(16).toString("base64");
2834
2834
  const request = isSecure ? https.request : http.request;
2835
2835
  const protocolSet = /* @__PURE__ */ new Set();
2836
2836
  let perMessageDeflate;
@@ -2841,7 +2841,7 @@ var require_websocket = __commonJS({
2841
2841
  opts.headers = {
2842
2842
  ...opts.headers,
2843
2843
  "Sec-WebSocket-Version": opts.protocolVersion,
2844
- "Sec-WebSocket-Key": key2,
2844
+ "Sec-WebSocket-Key": key3,
2845
2845
  Connection: "Upgrade",
2846
2846
  Upgrade: "websocket"
2847
2847
  };
@@ -2892,8 +2892,8 @@ var require_websocket = __commonJS({
2892
2892
  const headers = options && options.headers;
2893
2893
  options = { ...options, headers: {} };
2894
2894
  if (headers) {
2895
- for (const [key3, value] of Object.entries(headers)) {
2896
- options.headers[key3.toLowerCase()] = value;
2895
+ for (const [key4, value] of Object.entries(headers)) {
2896
+ options.headers[key4.toLowerCase()] = value;
2897
2897
  }
2898
2898
  }
2899
2899
  } else if (websocket.listenerCount("redirect") === 0) {
@@ -2960,7 +2960,7 @@ var require_websocket = __commonJS({
2960
2960
  abortHandshake(websocket, socket, "Invalid Upgrade header");
2961
2961
  return;
2962
2962
  }
2963
- const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
2963
+ const digest = createHash8("sha1").update(key3 + GUID).digest("base64");
2964
2964
  if (res.headers["sec-websocket-accept"] !== digest) {
2965
2965
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
2966
2966
  return;
@@ -3329,7 +3329,7 @@ var require_websocket_server = __commonJS({
3329
3329
  var EventEmitter = __require("events");
3330
3330
  var http = __require("http");
3331
3331
  var { Duplex } = __require("stream");
3332
- var { createHash: createHash7 } = __require("crypto");
3332
+ var { createHash: createHash8 } = __require("crypto");
3333
3333
  var extension2 = require_extension();
3334
3334
  var PerMessageDeflate2 = require_permessage_deflate();
3335
3335
  var subprotocol2 = require_subprotocol();
@@ -3528,7 +3528,7 @@ var require_websocket_server = __commonJS({
3528
3528
  */
3529
3529
  handleUpgrade(req, socket, head, cb) {
3530
3530
  socket.on("error", socketOnError);
3531
- const key2 = req.headers["sec-websocket-key"];
3531
+ const key3 = req.headers["sec-websocket-key"];
3532
3532
  const upgrade = req.headers.upgrade;
3533
3533
  const version2 = +req.headers["sec-websocket-version"];
3534
3534
  if (req.method !== "GET") {
@@ -3541,7 +3541,7 @@ var require_websocket_server = __commonJS({
3541
3541
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3542
3542
  return;
3543
3543
  }
3544
- if (key2 === void 0 || !keyRegex.test(key2)) {
3544
+ if (key3 === void 0 || !keyRegex.test(key3)) {
3545
3545
  const message = "Missing or invalid Sec-WebSocket-Key header";
3546
3546
  abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
3547
3547
  return;
@@ -3601,7 +3601,7 @@ var require_websocket_server = __commonJS({
3601
3601
  }
3602
3602
  this.completeUpgrade(
3603
3603
  extensions,
3604
- key2,
3604
+ key3,
3605
3605
  protocols,
3606
3606
  req,
3607
3607
  socket,
@@ -3613,7 +3613,7 @@ var require_websocket_server = __commonJS({
3613
3613
  }
3614
3614
  if (!this.options.verifyClient(info)) return abortHandshake(socket, 401);
3615
3615
  }
3616
- this.completeUpgrade(extensions, key2, protocols, req, socket, head, cb);
3616
+ this.completeUpgrade(extensions, key3, protocols, req, socket, head, cb);
3617
3617
  }
3618
3618
  /**
3619
3619
  * Upgrade the connection to WebSocket.
@@ -3628,7 +3628,7 @@ var require_websocket_server = __commonJS({
3628
3628
  * @throws {Error} If called more than once with the same socket
3629
3629
  * @private
3630
3630
  */
3631
- completeUpgrade(extensions, key2, protocols, req, socket, head, cb) {
3631
+ completeUpgrade(extensions, key3, protocols, req, socket, head, cb) {
3632
3632
  if (!socket.readable || !socket.writable) return socket.destroy();
3633
3633
  if (socket[kWebSocket]) {
3634
3634
  throw new Error(
@@ -3636,7 +3636,7 @@ var require_websocket_server = __commonJS({
3636
3636
  );
3637
3637
  }
3638
3638
  if (this._state > RUNNING) return abortHandshake(socket, 503);
3639
- const digest = createHash7("sha1").update(key2 + GUID).digest("base64");
3639
+ const digest = createHash8("sha1").update(key3 + GUID).digest("base64");
3640
3640
  const headers = [
3641
3641
  "HTTP/1.1 101 Switching Protocols",
3642
3642
  "Upgrade: websocket",
@@ -3798,12 +3798,12 @@ var __exportAll = (all, symbols) => {
3798
3798
  };
3799
3799
  var __copyProps2 = (to, from, except, desc) => {
3800
3800
  if (from && typeof from === "object" || typeof from === "function") {
3801
- for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key2; i < n; i++) {
3802
- key2 = keys[i];
3803
- if (!__hasOwnProp2.call(to, key2) && key2 !== except) {
3804
- __defProp2(to, key2, {
3805
- get: ((k) => from[k]).bind(null, key2),
3806
- enumerable: !(desc = __getOwnPropDesc2(from, key2)) || desc.enumerable
3801
+ for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key3; i < n; i++) {
3802
+ key3 = keys[i];
3803
+ if (!__hasOwnProp2.call(to, key3) && key3 !== except) {
3804
+ __defProp2(to, key3, {
3805
+ get: ((k) => from[k]).bind(null, key3),
3806
+ enumerable: !(desc = __getOwnPropDesc2(from, key3)) || desc.enumerable
3807
3807
  });
3808
3808
  }
3809
3809
  }
@@ -4555,9 +4555,9 @@ function floatSafeRemainder(val, step) {
4555
4555
  return ratio - roundedRatio;
4556
4556
  }
4557
4557
  var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
4558
- function defineLazy(object2, key2, getter) {
4558
+ function defineLazy(object2, key3, getter) {
4559
4559
  let value = void 0;
4560
- Object.defineProperty(object2, key2, {
4560
+ Object.defineProperty(object2, key3, {
4561
4561
  get() {
4562
4562
  if (value === EVALUATING) {
4563
4563
  return void 0;
@@ -4569,7 +4569,7 @@ function defineLazy(object2, key2, getter) {
4569
4569
  return value;
4570
4570
  },
4571
4571
  set(v) {
4572
- Object.defineProperty(object2, key2, {
4572
+ Object.defineProperty(object2, key3, {
4573
4573
  value: v
4574
4574
  // configurable: true,
4575
4575
  });
@@ -4595,47 +4595,47 @@ function rawShape(def) {
4595
4595
  function sourceShape(schema) {
4596
4596
  return rawShape(schema._zod.def) ?? schema._zod.def.shape;
4597
4597
  }
4598
- function deferProp(target, key2, getter) {
4599
- Object.defineProperty(target, key2, {
4598
+ function deferProp(target, key3, getter) {
4599
+ Object.defineProperty(target, key3, {
4600
4600
  get() {
4601
4601
  const value = getter();
4602
- assignProp(this, key2, value);
4602
+ assignProp(this, key3, value);
4603
4603
  return value;
4604
4604
  },
4605
4605
  enumerable: true,
4606
4606
  configurable: true
4607
4607
  });
4608
4608
  }
4609
- function putProp(target, key2, value) {
4610
- if (key2 in target)
4611
- assignProp(target, key2, value);
4609
+ function putProp(target, key3, value) {
4610
+ if (key3 in target)
4611
+ assignProp(target, key3, value);
4612
4612
  else
4613
- target[key2] = value;
4613
+ target[key3] = value;
4614
4614
  }
4615
4615
  function mirrorShape(target, source, keys, wrap) {
4616
4616
  const raw = sourceShape(source);
4617
- for (const key2 of keys) {
4618
- const desc = Object.getOwnPropertyDescriptor(raw, key2);
4617
+ for (const key3 of keys) {
4618
+ const desc = Object.getOwnPropertyDescriptor(raw, key3);
4619
4619
  if (!desc.enumerable)
4620
4620
  continue;
4621
4621
  if (desc.get) {
4622
- deferProp(target, key2, () => {
4623
- const value = source._zod.def.shape[key2];
4624
- return wrap ? wrap(value, key2) : value;
4622
+ deferProp(target, key3, () => {
4623
+ const value = source._zod.def.shape[key3];
4624
+ return wrap ? wrap(value, key3) : value;
4625
4625
  });
4626
4626
  } else
4627
- putProp(target, key2, wrap ? wrap(desc.value, key2) : desc.value);
4627
+ putProp(target, key3, wrap ? wrap(desc.value, key3) : desc.value);
4628
4628
  }
4629
4629
  }
4630
4630
  function mirrorProps(target, source) {
4631
- for (const key2 of Reflect.ownKeys(source)) {
4632
- const desc = Object.getOwnPropertyDescriptor(source, key2);
4631
+ for (const key3 of Reflect.ownKeys(source)) {
4632
+ const desc = Object.getOwnPropertyDescriptor(source, key3);
4633
4633
  if (!desc.enumerable)
4634
4634
  continue;
4635
4635
  if (desc.get)
4636
- deferProp(target, key2, () => source[key2]);
4636
+ deferProp(target, key3, () => source[key3]);
4637
4637
  else
4638
- putProp(target, key2, desc.value);
4638
+ putProp(target, key3, desc.value);
4639
4639
  }
4640
4640
  }
4641
4641
  function mergeDefs(...defs) {
@@ -4652,11 +4652,11 @@ function cloneDef(schema) {
4652
4652
  function getElementAtPath(obj, path) {
4653
4653
  if (!path)
4654
4654
  return obj;
4655
- return path.reduce((acc, key2) => acc?.[key2], obj);
4655
+ return path.reduce((acc, key3) => acc?.[key3], obj);
4656
4656
  }
4657
4657
  function promiseAllObject(promisesObj) {
4658
4658
  const keys = Object.keys(promisesObj);
4659
- const promises = keys.map((key2) => promisesObj[key2]);
4659
+ const promises = keys.map((key3) => promisesObj[key3]);
4660
4660
  return Promise.all(promises).then((results) => {
4661
4661
  const resolvedObj = {};
4662
4662
  for (let i = 0; i < keys.length; i++) {
@@ -4728,8 +4728,8 @@ function shallowClone(o) {
4728
4728
  }
4729
4729
  function numKeys(data) {
4730
4730
  let keyCount = 0;
4731
- for (const key2 in data) {
4732
- if (Object.prototype.hasOwnProperty.call(data, key2)) {
4731
+ for (const key3 in data) {
4732
+ if (Object.prototype.hasOwnProperty.call(data, key3)) {
4733
4733
  keyCount++;
4734
4734
  }
4735
4735
  }
@@ -4883,12 +4883,12 @@ function pick(schema, mask) {
4883
4883
  function maskedKeys(schema, mask) {
4884
4884
  const raw = sourceShape(schema);
4885
4885
  const keys = [];
4886
- for (const key2 of Reflect.ownKeys(mask)) {
4887
- if (!Object.getOwnPropertyDescriptor(raw, key2)?.enumerable) {
4888
- throw new Error(`Unrecognized key: "${String(key2)}"`);
4886
+ for (const key3 of Reflect.ownKeys(mask)) {
4887
+ if (!Object.getOwnPropertyDescriptor(raw, key3)?.enumerable) {
4888
+ throw new Error(`Unrecognized key: "${String(key3)}"`);
4889
4889
  }
4890
- if (mask[key2])
4891
- keys.push(key2);
4890
+ if (mask[key3])
4891
+ keys.push(key3);
4892
4892
  }
4893
4893
  return keys;
4894
4894
  }
@@ -4901,7 +4901,7 @@ function omit(schema, mask) {
4901
4901
  }
4902
4902
  const omitted = new Set(maskedKeys(schema, mask));
4903
4903
  const newShape = {};
4904
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key2) => !omitted.has(key2)));
4904
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key3) => !omitted.has(key3)));
4905
4905
  return clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
4906
4906
  }
4907
4907
  function extend(schema, shape) {
@@ -4912,8 +4912,8 @@ function extend(schema, shape) {
4912
4912
  const hasChecks = checks && checks.length > 0;
4913
4913
  if (hasChecks) {
4914
4914
  const existingShape = sourceShape(schema);
4915
- for (const key2 of Reflect.ownKeys(shape)) {
4916
- if (Object.getOwnPropertyDescriptor(existingShape, key2) !== void 0) {
4915
+ for (const key3 of Reflect.ownKeys(shape)) {
4916
+ if (Object.getOwnPropertyDescriptor(existingShape, key3) !== void 0) {
4917
4917
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
4918
4918
  }
4919
4919
  }
@@ -4960,15 +4960,15 @@ function partial(Class2, schema, mask, name = "partial") {
4960
4960
  }
4961
4961
  const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
4962
4962
  const newShape = {};
4963
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key2) => selected && !selected.has(key2) ? value : new Class2({ type: "optional", innerType: value })));
4963
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class2 && ((value, key3) => selected && !selected.has(key3) ? value : new Class2({ type: "optional", innerType: value })));
4964
4964
  return clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
4965
4965
  }
4966
4966
  function required(Class2, schema, mask) {
4967
4967
  const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
4968
4968
  const newShape = {};
4969
- mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key2) => (
4969
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key3) => (
4970
4970
  // overwrite with non-optional
4971
- selected && !selected.has(key2) ? value : new Class2({ type: "nonoptional", innerType: value })
4971
+ selected && !selected.has(key3) ? value : new Class2({ type: "nonoptional", innerType: value })
4972
4972
  ));
4973
4973
  return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
4974
4974
  }
@@ -5155,46 +5155,46 @@ var Class = class {
5155
5155
  }
5156
5156
  };
5157
5157
  function members(proto, table) {
5158
- for (const key2 in table) {
5159
- const desc = Object.getOwnPropertyDescriptor(table, key2);
5158
+ for (const key3 in table) {
5159
+ const desc = Object.getOwnPropertyDescriptor(table, key3);
5160
5160
  if (desc.get)
5161
- Object.defineProperty(proto, key2, { ...desc, enumerable: false });
5161
+ Object.defineProperty(proto, key3, { ...desc, enumerable: false });
5162
5162
  else
5163
- defineBound(proto, key2, desc.value);
5163
+ defineBound(proto, key3, desc.value);
5164
5164
  }
5165
5165
  }
5166
- function own(inst, key2, value, enumerable = true) {
5167
- Object.defineProperty(inst, key2, { configurable: true, writable: true, enumerable, value });
5166
+ function own(inst, key3, value, enumerable = true) {
5167
+ Object.defineProperty(inst, key3, { configurable: true, writable: true, enumerable, value });
5168
5168
  return value;
5169
5169
  }
5170
- function hide(inst, key2, value) {
5171
- return own(inst, key2, value, false);
5170
+ function hide(inst, key3, value) {
5171
+ return own(inst, key3, value, false);
5172
5172
  }
5173
5173
  // @__NO_SIDE_EFFECTS__
5174
5174
  function derived(computes, table) {
5175
- for (const key2 in computes) {
5176
- const compute = computes[key2];
5177
- Object.defineProperty(table, key2, {
5175
+ for (const key3 in computes) {
5176
+ const compute = computes[key3];
5177
+ Object.defineProperty(table, key3, {
5178
5178
  configurable: true,
5179
5179
  enumerable: true,
5180
5180
  get() {
5181
- return own(this, key2, compute(this));
5181
+ return own(this, key3, compute(this));
5182
5182
  },
5183
5183
  set(value) {
5184
- own(this, key2, value);
5184
+ own(this, key3, value);
5185
5185
  }
5186
5186
  });
5187
5187
  }
5188
5188
  return table;
5189
5189
  }
5190
- function defineBound(proto, key2, fn) {
5191
- Object.defineProperty(proto, key2, {
5190
+ function defineBound(proto, key3, fn) {
5191
+ Object.defineProperty(proto, key3, {
5192
5192
  configurable: true,
5193
5193
  get() {
5194
- return this == null ? fn : own(this, key2, fn.bind(this));
5194
+ return this == null ? fn : own(this, key3, fn.bind(this));
5195
5195
  },
5196
5196
  set(value) {
5197
- own(this, key2, value);
5197
+ own(this, key3, value);
5198
5198
  }
5199
5199
  });
5200
5200
  }
@@ -5211,53 +5211,53 @@ var breaker = {
5211
5211
  return void 0;
5212
5212
  }
5213
5213
  };
5214
- function defineLazyInternal(inst, key2, compute) {
5214
+ function defineLazyInternal(inst, key3, compute) {
5215
5215
  const proto = Object.getPrototypeOf(inst._zod);
5216
- if (key2 in proto && installing !== inst._zod) {
5216
+ if (key3 in proto && installing !== inst._zod) {
5217
5217
  installing = void 0;
5218
5218
  return;
5219
5219
  }
5220
5220
  installing = inst._zod;
5221
- Object.defineProperty(proto, key2, {
5221
+ Object.defineProperty(proto, key3, {
5222
5222
  configurable: true,
5223
5223
  get() {
5224
- Object.defineProperty(this, key2, breaker);
5224
+ Object.defineProperty(this, key3, breaker);
5225
5225
  const outer = broke;
5226
5226
  broke = false;
5227
5227
  try {
5228
5228
  const value = compute(this);
5229
5229
  if (broke)
5230
- delete this[key2];
5230
+ delete this[key3];
5231
5231
  else
5232
- Object.defineProperty(this, key2, { configurable: true, writable: true, value });
5232
+ Object.defineProperty(this, key3, { configurable: true, writable: true, value });
5233
5233
  broke = broke || outer;
5234
5234
  return value;
5235
5235
  } catch (err) {
5236
- delete this[key2];
5236
+ delete this[key3];
5237
5237
  broke = broke || outer;
5238
5238
  throw err;
5239
5239
  }
5240
5240
  },
5241
5241
  set(value) {
5242
- Object.defineProperty(this, key2, { configurable: true, writable: true, value });
5242
+ Object.defineProperty(this, key3, { configurable: true, writable: true, value });
5243
5243
  }
5244
5244
  });
5245
5245
  }
5246
- function installLazyProp(inst, key2, make, enumerable) {
5247
- const proto = claim(inst, key2);
5246
+ function installLazyProp(inst, key3, make, enumerable) {
5247
+ const proto = claim(inst, key3);
5248
5248
  if (!proto)
5249
5249
  return;
5250
- Object.defineProperty(proto, key2, {
5250
+ Object.defineProperty(proto, key3, {
5251
5251
  configurable: true,
5252
5252
  get() {
5253
5253
  const desc = { configurable: true, writable: true, enumerable, value: void 0 };
5254
- Object.defineProperty(this, key2, desc);
5254
+ Object.defineProperty(this, key3, desc);
5255
5255
  desc.value = make(this);
5256
- Object.defineProperty(this, key2, desc);
5256
+ Object.defineProperty(this, key3, desc);
5257
5257
  return desc.value;
5258
5258
  },
5259
5259
  set(value) {
5260
- Object.defineProperty(this, key2, { configurable: true, writable: true, enumerable, value });
5260
+ Object.defineProperty(this, key3, { configurable: true, writable: true, enumerable, value });
5261
5261
  }
5262
5262
  });
5263
5263
  }
@@ -5434,15 +5434,15 @@ var $ZodError = $constructor("$ZodError", initializer);
5434
5434
  var $ZodRealError = $constructor("$ZodError", initializer, void 0, {
5435
5435
  Parent: Error
5436
5436
  });
5437
- function node(obj, key2, make) {
5438
- if (!Object.prototype.hasOwnProperty.call(obj, key2)) {
5439
- if (key2 === "__proto__") {
5440
- Object.defineProperty(obj, key2, { value: make(), writable: true, enumerable: true, configurable: true });
5437
+ function node(obj, key3, make) {
5438
+ if (!Object.prototype.hasOwnProperty.call(obj, key3)) {
5439
+ if (key3 === "__proto__") {
5440
+ Object.defineProperty(obj, key3, { value: make(), writable: true, enumerable: true, configurable: true });
5441
5441
  } else {
5442
- obj[key2] = make();
5442
+ obj[key3] = make();
5443
5443
  }
5444
5444
  }
5445
- return obj[key2];
5445
+ return obj[key3];
5446
5446
  }
5447
5447
  function flattenError(error62, mapper = (issue2) => issue2.message) {
5448
5448
  const fieldErrors = {};
@@ -6351,16 +6351,16 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
6351
6351
  payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
6352
6352
  return void 0;
6353
6353
  }
6354
- entries ?? (entries = Reflect.ownKeys(def.shape).map((key2) => [key2, def.shape[key2]]));
6354
+ entries ?? (entries = Reflect.ownKeys(def.shape).map((key3) => [key3, def.shape[key3]]));
6355
6355
  const input2 = payload.value;
6356
6356
  let proms;
6357
- for (const [key2, schema] of entries) {
6358
- const result = schema._zod.run({ value: input2[key2], issues: [] }, {});
6357
+ for (const [key3, schema] of entries) {
6358
+ const result = schema._zod.run({ value: input2[key3], issues: [] }, {});
6359
6359
  if (result instanceof Promise) {
6360
6360
  proms ?? (proms = []);
6361
- proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key2)));
6361
+ proms.push(result.then((result2) => handleCheckPropertyResult(result2, payload, key3)));
6362
6362
  } else {
6363
- handleCheckPropertyResult(result, payload, key2);
6363
+ handleCheckPropertyResult(result, payload, key3);
6364
6364
  }
6365
6365
  }
6366
6366
  if (proms)
@@ -7261,8 +7261,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
7261
7261
  };
7262
7262
  capSize(inst, arraySize);
7263
7263
  });
7264
- function handlePropertyResult(result, final, key2, input2, optin, optout) {
7265
- const isPresent = key2 in input2;
7264
+ function handlePropertyResult(result, final, key3, input2, optin, optout) {
7265
+ const isPresent = key3 in input2;
7266
7266
  const isOptionalOut = optout === "optional";
7267
7267
  if (!isPresent && isOptionalOut && optin === "optional") {
7268
7268
  return;
@@ -7271,7 +7271,7 @@ function handlePropertyResult(result, final, key2, input2, optin, optout) {
7271
7271
  if (optin !== void 0 && isOptionalOut && !isPresent) {
7272
7272
  return;
7273
7273
  }
7274
- final.issues.push(...prefixIssues(key2, result.issues));
7274
+ final.issues.push(...prefixIssues(key3, result.issues));
7275
7275
  }
7276
7276
  if (!isPresent && optin === void 0) {
7277
7277
  if (!result.issues.length) {
@@ -7279,17 +7279,17 @@ function handlePropertyResult(result, final, key2, input2, optin, optout) {
7279
7279
  code: "invalid_type",
7280
7280
  expected: "nonoptional",
7281
7281
  input: void 0,
7282
- path: [key2]
7282
+ path: [key3]
7283
7283
  });
7284
7284
  }
7285
7285
  return;
7286
7286
  }
7287
7287
  if (result.value === void 0) {
7288
7288
  if (isPresent || optin === "defaulted" && !isOptionalOut) {
7289
- final.value[key2] = void 0;
7289
+ final.value[key3] = void 0;
7290
7290
  }
7291
7291
  } else {
7292
- final.value[key2] = result.value;
7292
+ final.value[key3] = result.value;
7293
7293
  }
7294
7294
  }
7295
7295
  var NO_SYMBOL_KEYS = [];
@@ -7322,28 +7322,28 @@ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
7322
7322
  const optin = _catchall.optin;
7323
7323
  const optout = _catchall.optout;
7324
7324
  let seen = 0;
7325
- for (const key2 in input2) {
7325
+ for (const key3 in input2) {
7326
7326
  if (abortEarly && payload.issues.length !== seen) {
7327
7327
  if (aborted(payload, seen))
7328
7328
  break;
7329
7329
  seen = payload.issues.length;
7330
7330
  }
7331
- if (keySet.has(key2))
7331
+ if (keySet.has(key3))
7332
7332
  continue;
7333
- if (key2 === "__proto__") {
7333
+ if (key3 === "__proto__") {
7334
7334
  if (t === "never")
7335
- unrecognized.push(key2);
7335
+ unrecognized.push(key3);
7336
7336
  continue;
7337
7337
  }
7338
7338
  if (t === "never") {
7339
- unrecognized.push(key2);
7339
+ unrecognized.push(key3);
7340
7340
  continue;
7341
7341
  }
7342
- const r = _catchall.run({ value: input2[key2], issues: [] }, ctx);
7342
+ const r = _catchall.run({ value: input2[key3], issues: [] }, ctx);
7343
7343
  if (r instanceof Promise) {
7344
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input2, optin, optout)));
7344
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key3, input2, optin, optout)));
7345
7345
  } else {
7346
- handlePropertyResult(r, payload, key2, input2, optin, optout);
7346
+ handlePropertyResult(r, payload, key3, input2, optin, optout);
7347
7347
  }
7348
7348
  }
7349
7349
  if (unrecognized.length) {
@@ -7380,16 +7380,16 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7380
7380
  defineLazyInternal(inst, "propValues", (zod) => {
7381
7381
  const shape = zod.def.shape;
7382
7382
  const propValues = {};
7383
- for (const key2 in shape) {
7384
- const field = shape[key2]._zod;
7383
+ for (const key3 in shape) {
7384
+ const field = shape[key3]._zod;
7385
7385
  if (field.values) {
7386
- if (!Object.prototype.hasOwnProperty.call(propValues, key2)) {
7387
- assignProp(propValues, key2, /* @__PURE__ */ new Set());
7386
+ if (!Object.prototype.hasOwnProperty.call(propValues, key3)) {
7387
+ assignProp(propValues, key3, /* @__PURE__ */ new Set());
7388
7388
  }
7389
7389
  for (const v of field.values)
7390
- propValues[key2].add(v);
7390
+ propValues[key3].add(v);
7391
7391
  if (field.optin !== void 0)
7392
- propValues[key2].add(void 0);
7392
+ propValues[key3].add(void 0);
7393
7393
  }
7394
7394
  }
7395
7395
  return propValues;
@@ -7416,22 +7416,22 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7416
7416
  const shape = value.shape;
7417
7417
  const abortEarly = ctx?.abortEarly;
7418
7418
  let seen = payload.issues.length;
7419
- for (const key2 of value.allKeys) {
7419
+ for (const key3 of value.allKeys) {
7420
7420
  if (abortEarly && payload.issues.length !== seen) {
7421
7421
  if (aborted(payload, seen))
7422
7422
  break;
7423
7423
  seen = payload.issues.length;
7424
7424
  }
7425
- if (key2 === "__proto__")
7425
+ if (key3 === "__proto__")
7426
7426
  continue;
7427
- const el = shape[key2];
7427
+ const el = shape[key3];
7428
7428
  const optin = el._zod.optin;
7429
7429
  const optout = el._zod.optout;
7430
- const r = el._zod.run({ value: input2[key2], issues: [] }, ctx);
7430
+ const r = el._zod.run({ value: input2[key3], issues: [] }, ctx);
7431
7431
  if (r instanceof Promise) {
7432
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key2, input2, optin, optout)));
7432
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key3, input2, optin, optout)));
7433
7433
  } else {
7434
- handlePropertyResult(r, payload, key2, input2, optin, optout);
7434
+ handlePropertyResult(r, payload, key3, input2, optin, optout);
7435
7435
  }
7436
7436
  }
7437
7437
  if (!catchall) {
@@ -7465,17 +7465,17 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7465
7465
  doc.write(`const input = payload.value;`);
7466
7466
  const ids = /* @__PURE__ */ Object.create(null);
7467
7467
  let counter = 0;
7468
- for (const key2 of normalized.allKeys) {
7469
- ids[key2] = `key_${counter++}`;
7468
+ for (const key3 of normalized.allKeys) {
7469
+ ids[key3] = `key_${counter++}`;
7470
7470
  }
7471
7471
  doc.write(memo3 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
7472
- for (const key2 of normalized.allKeys) {
7473
- if (key2 === "__proto__")
7472
+ for (const key3 of normalized.allKeys) {
7473
+ if (key3 === "__proto__")
7474
7474
  continue;
7475
- const id2 = ids[key2];
7476
- const k = typeof key2 === "symbol" ? `syms[${syms.indexOf(key2)}]` : esc(key2);
7475
+ const id2 = ids[key3];
7476
+ const k = typeof key3 === "symbol" ? `syms[${syms.indexOf(key3)}]` : esc(key3);
7477
7477
  const isPresent = `${k} in input`;
7478
- const schema = shape[key2];
7478
+ const schema = shape[key3];
7479
7479
  const optin = schema?._zod?.optin;
7480
7480
  const isOptionalIn = optin !== void 0;
7481
7481
  const isOptionalOut = schema?._zod?.optout === "optional";
@@ -7809,21 +7809,21 @@ function mergeValues(a, b) {
7809
7809
  }
7810
7810
  if (isPlainObject(a) && isPlainObject(b)) {
7811
7811
  const bKeys = Object.keys(b);
7812
- const sharedKeys = Object.keys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
7812
+ const sharedKeys = Object.keys(a).filter((key3) => bKeys.indexOf(key3) !== -1);
7813
7813
  const newObj = { ...a, ...b };
7814
7814
  if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
7815
7815
  delete newObj.__proto__;
7816
- for (const key2 of sharedKeys) {
7817
- if (key2 === "__proto__")
7816
+ for (const key3 of sharedKeys) {
7817
+ if (key3 === "__proto__")
7818
7818
  continue;
7819
- const sharedValue = mergeValues(a[key2], b[key2]);
7819
+ const sharedValue = mergeValues(a[key3], b[key3]);
7820
7820
  if (!sharedValue.valid) {
7821
7821
  return {
7822
7822
  valid: false,
7823
- mergeErrorPath: [key2, ...sharedValue.mergeErrorPath]
7823
+ mergeErrorPath: [key3, ...sharedValue.mergeErrorPath]
7824
7824
  };
7825
7825
  }
7826
- newObj[key2] = sharedValue.data;
7826
+ newObj[key3] = sharedValue.data;
7827
7827
  }
7828
7828
  return { valid: true, data: newObj };
7829
7829
  }
@@ -7982,9 +7982,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
7982
7982
  return handleTupleResults(itemResults, payload, items, input2, optoutStart);
7983
7983
  };
7984
7984
  });
7985
- function getTupleOptStart(items, key2) {
7985
+ function getTupleOptStart(items, key3) {
7986
7986
  for (let i = items.length - 1; i >= 0; i--) {
7987
- const omittable = key2 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
7987
+ const omittable = key3 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
7988
7988
  if (!omittable)
7989
7989
  return i + 1;
7990
7990
  }
@@ -8042,12 +8042,12 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8042
8042
  if (values && !def.partial) {
8043
8043
  payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
8044
8044
  const recordKeys = /* @__PURE__ */ new Set();
8045
- for (const key2 of values) {
8046
- if (typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol") {
8047
- recordKeys.add(typeof key2 === "number" ? key2.toString() : key2);
8048
- if (key2 === "__proto__")
8045
+ for (const key3 of values) {
8046
+ if (typeof key3 === "string" || typeof key3 === "number" || typeof key3 === "symbol") {
8047
+ recordKeys.add(typeof key3 === "number" ? key3.toString() : key3);
8048
+ if (key3 === "__proto__")
8049
8049
  continue;
8050
- const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
8050
+ const keyResult = def.keyType._zod.run({ value: key3, issues: [] }, ctx);
8051
8051
  if (keyResult instanceof Promise) {
8052
8052
  throw new Error("Async schemas not supported in object keys currently");
8053
8053
  }
@@ -8056,8 +8056,8 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8056
8056
  code: "invalid_key",
8057
8057
  origin: "record",
8058
8058
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
8059
- input: key2,
8060
- path: [key2],
8059
+ input: key3,
8060
+ path: [key3],
8061
8061
  inst
8062
8062
  });
8063
8063
  continue;
@@ -8065,32 +8065,32 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8065
8065
  const outKey = keyResult.value;
8066
8066
  if (outKey === "__proto__")
8067
8067
  continue;
8068
- const result = def.valueType._zod.run({ value: input2[key2], issues: [] }, ctx);
8068
+ const result = def.valueType._zod.run({ value: input2[key3], issues: [] }, ctx);
8069
8069
  if (result instanceof Promise) {
8070
8070
  proms.push(result.then((result2) => {
8071
8071
  if (result2.issues.length) {
8072
- payload.issues.push(...prefixIssues(key2, result2.issues));
8072
+ payload.issues.push(...prefixIssues(key3, result2.issues));
8073
8073
  }
8074
8074
  payload.value[outKey] = result2.value;
8075
8075
  }));
8076
8076
  } else {
8077
8077
  if (result.issues.length) {
8078
- payload.issues.push(...prefixIssues(key2, result.issues));
8078
+ payload.issues.push(...prefixIssues(key3, result.issues));
8079
8079
  }
8080
8080
  payload.value[outKey] = result.value;
8081
8081
  }
8082
8082
  }
8083
8083
  }
8084
8084
  let unrecognized;
8085
- for (const key2 in input2) {
8086
- if (!recordKeys.has(key2)) {
8085
+ for (const key3 in input2) {
8086
+ if (!recordKeys.has(key3)) {
8087
8087
  if (def.mode === "loose") {
8088
- if (key2 === "__proto__")
8088
+ if (key3 === "__proto__")
8089
8089
  continue;
8090
- payload.value[key2] = input2[key2];
8090
+ payload.value[key3] = input2[key3];
8091
8091
  } else {
8092
8092
  unrecognized = unrecognized ?? [];
8093
- unrecognized.push(key2);
8093
+ unrecognized.push(key3);
8094
8094
  }
8095
8095
  }
8096
8096
  }
@@ -8106,18 +8106,18 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8106
8106
  } else {
8107
8107
  payload.value = memo3 ? memo3.alloc(inst, payload, {}, ctx) : {};
8108
8108
  let unrecognized;
8109
- for (const key2 of Reflect.ownKeys(input2)) {
8110
- if (key2 === "__proto__")
8109
+ for (const key3 of Reflect.ownKeys(input2)) {
8110
+ if (key3 === "__proto__")
8111
8111
  continue;
8112
- if (!Object.prototype.propertyIsEnumerable.call(input2, key2))
8112
+ if (!Object.prototype.propertyIsEnumerable.call(input2, key3))
8113
8113
  continue;
8114
- let keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
8114
+ let keyResult = def.keyType._zod.run({ value: key3, issues: [] }, ctx);
8115
8115
  if (keyResult instanceof Promise) {
8116
8116
  throw new Error("Async schemas not supported in object keys currently");
8117
8117
  }
8118
- const checkNumericKey = typeof key2 === "string" && number.test(key2) && keyResult.issues.length;
8118
+ const checkNumericKey = typeof key3 === "string" && number.test(key3) && keyResult.issues.length;
8119
8119
  if (checkNumericKey) {
8120
- const retryResult = def.keyType._zod.run({ value: Number(key2), issues: [] }, ctx);
8120
+ const retryResult = def.keyType._zod.run({ value: Number(key3), issues: [] }, ctx);
8121
8121
  if (retryResult instanceof Promise) {
8122
8122
  throw new Error("Async schemas not supported in object keys currently");
8123
8123
  }
@@ -8127,17 +8127,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8127
8127
  }
8128
8128
  if (keyResult.issues.length) {
8129
8129
  if (def.mode === "loose") {
8130
- payload.value[key2] = input2[key2];
8130
+ payload.value[key3] = input2[key3];
8131
8131
  } else if (values) {
8132
8132
  unrecognized = unrecognized ?? [];
8133
- unrecognized.push(key2);
8133
+ unrecognized.push(key3);
8134
8134
  } else {
8135
8135
  payload.issues.push({
8136
8136
  code: "invalid_key",
8137
8137
  origin: "record",
8138
8138
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
8139
- input: key2,
8140
- path: [key2],
8139
+ input: key3,
8140
+ path: [key3],
8141
8141
  inst
8142
8142
  });
8143
8143
  }
@@ -8146,17 +8146,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
8146
8146
  const outKey = keyResult.value;
8147
8147
  if (outKey === "__proto__")
8148
8148
  continue;
8149
- const result = def.valueType._zod.run({ value: input2[key2], issues: [] }, ctx);
8149
+ const result = def.valueType._zod.run({ value: input2[key3], issues: [] }, ctx);
8150
8150
  if (result instanceof Promise) {
8151
8151
  proms.push(result.then((result2) => {
8152
8152
  if (result2.issues.length) {
8153
- payload.issues.push(...prefixIssues(key2, result2.issues));
8153
+ payload.issues.push(...prefixIssues(key3, result2.issues));
8154
8154
  }
8155
8155
  payload.value[outKey] = result2.value;
8156
8156
  }));
8157
8157
  } else {
8158
8158
  if (result.issues.length) {
8159
- payload.issues.push(...prefixIssues(key2, result.issues));
8159
+ payload.issues.push(...prefixIssues(key3, result.issues));
8160
8160
  }
8161
8161
  payload.value[outKey] = result.value;
8162
8162
  }
@@ -8196,20 +8196,20 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
8196
8196
  payload.value = memo3 ? memo3.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
8197
8197
  const abortEarly = ctx?.abortEarly;
8198
8198
  let seen = payload.issues.length;
8199
- for (const [key2, value] of input2) {
8199
+ for (const [key3, value] of input2) {
8200
8200
  if (abortEarly && payload.issues.length !== seen) {
8201
8201
  if (aborted(payload, seen))
8202
8202
  break;
8203
8203
  seen = payload.issues.length;
8204
8204
  }
8205
- const keyResult = def.keyType._zod.run({ value: key2, issues: [] }, ctx);
8205
+ const keyResult = def.keyType._zod.run({ value: key3, issues: [] }, ctx);
8206
8206
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
8207
8207
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
8208
8208
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
8209
- handleMapResult(keyResult2, valueResult2, payload, key2, input2, inst, ctx);
8209
+ handleMapResult(keyResult2, valueResult2, payload, key3, input2, inst, ctx);
8210
8210
  }));
8211
8211
  } else {
8212
- handleMapResult(keyResult, valueResult, payload, key2, input2, inst, ctx);
8212
+ handleMapResult(keyResult, valueResult, payload, key3, input2, inst, ctx);
8213
8213
  }
8214
8214
  }
8215
8215
  if (proms.length)
@@ -8218,10 +8218,10 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
8218
8218
  };
8219
8219
  capSize(inst, mapSize);
8220
8220
  });
8221
- function handleMapResult(keyResult, valueResult, final, key2, input2, inst, ctx) {
8221
+ function handleMapResult(keyResult, valueResult, final, key3, input2, inst, ctx) {
8222
8222
  if (keyResult.issues.length) {
8223
- if (propertyKeyTypes.has(typeof key2)) {
8224
- final.issues.push(...prefixIssues(key2, keyResult.issues));
8223
+ if (propertyKeyTypes.has(typeof key3)) {
8224
+ final.issues.push(...prefixIssues(key3, keyResult.issues));
8225
8225
  } else {
8226
8226
  final.issues.push({
8227
8227
  code: "invalid_key",
@@ -8233,15 +8233,15 @@ function handleMapResult(keyResult, valueResult, final, key2, input2, inst, ctx)
8233
8233
  }
8234
8234
  }
8235
8235
  if (valueResult.issues.length) {
8236
- if (propertyKeyTypes.has(typeof key2)) {
8237
- final.issues.push(...prefixIssues(key2, valueResult.issues));
8236
+ if (propertyKeyTypes.has(typeof key3)) {
8237
+ final.issues.push(...prefixIssues(key3, valueResult.issues));
8238
8238
  } else {
8239
8239
  final.issues.push({
8240
8240
  origin: "map",
8241
8241
  code: "invalid_element",
8242
8242
  input: input2,
8243
8243
  inst,
8244
- key: key2,
8244
+ key: key3,
8245
8245
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
8246
8246
  });
8247
8247
  }
@@ -8916,8 +8916,8 @@ function isRecursive(inst, stack, resolve8) {
8916
8916
  };
8917
8917
  const shape = (sh, spread) => {
8918
8918
  let answer = NONE;
8919
- for (const key2 of Reflect.ownKeys(sh)) {
8920
- const desc = Object.getOwnPropertyDescriptor(sh, key2);
8919
+ for (const key3 of Reflect.ownKeys(sh)) {
8920
+ const desc = Object.getOwnPropertyDescriptor(sh, key3);
8921
8921
  if (spread && !desc.enumerable)
8922
8922
  continue;
8923
8923
  const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve8) : NONE;
@@ -9013,8 +9013,8 @@ function isRecursive(inst, stack, resolve8) {
9013
9013
  break;
9014
9014
  default: {
9015
9015
  kind;
9016
- for (const key2 in def) {
9017
- const desc = Object.getOwnPropertyDescriptor(def, key2);
9016
+ for (const key3 in def) {
9017
+ const desc = Object.getOwnPropertyDescriptor(def, key3);
9018
9018
  if (!desc || desc.get)
9019
9019
  continue;
9020
9020
  const value = desc.value;
@@ -17147,11 +17147,11 @@ function generatePropertiesChecks(doc, ctx, def, accessor) {
17147
17147
  }
17148
17148
  doc.write(`if (${accessor} == null) return INVALID;`);
17149
17149
  const shape = def.shape;
17150
- for (const key2 of Reflect.ownKeys(shape)) {
17151
- const keyExpr = typeof key2 === "symbol" ? addConstant(ctx, key2) : esc(key2);
17150
+ for (const key3 of Reflect.ownKeys(shape)) {
17151
+ const keyExpr = typeof key3 === "symbol" ? addConstant(ctx, key3) : esc(key3);
17152
17152
  const inputVar = newVar(ctx);
17153
17153
  doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
17154
- compileChild(doc, ctx, shape[key2], inputVar, false);
17154
+ compileChild(doc, ctx, shape[key3], inputVar, false);
17155
17155
  }
17156
17156
  }
17157
17157
  function generatePropertyCheck(doc, ctx, def, accessor) {
@@ -17544,9 +17544,9 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
17544
17544
  throw new ZodCompileUnsupportedError('object shape key "__proto__"');
17545
17545
  }
17546
17546
  const propOutputs = /* @__PURE__ */ new Map();
17547
- for (const key2 of allKeys) {
17548
- const propSchema = propShape[key2];
17549
- const kx = keyExpr(key2);
17547
+ for (const key3 of allKeys) {
17548
+ const propSchema = propShape[key3];
17549
+ const kx = keyExpr(key3);
17550
17550
  const inputVar = newVar(ctx);
17551
17551
  doc.write(`const ${inputVar} = ${accessor}[${kx}];`);
17552
17552
  if (propSchema._zod.optin !== void 0) {
@@ -17567,14 +17567,14 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
17567
17567
  } else {
17568
17568
  doc.write(`if (${outputVar2} === INVALID) return INVALID;`);
17569
17569
  }
17570
- propOutputs.set(key2, outputVar2);
17570
+ propOutputs.set(key3, outputVar2);
17571
17571
  } else {
17572
17572
  if (requiresPresenceCheck(propSchema)) {
17573
17573
  doc.write(`if (!(${kx} in ${accessor})) return INVALID;`);
17574
17574
  }
17575
17575
  const outputAccessor = compileChild(doc, ctx, propSchema, inputVar, buildsValue);
17576
17576
  if (outputAccessor !== null)
17577
- propOutputs.set(key2, outputAccessor);
17577
+ propOutputs.set(key3, outputAccessor);
17578
17578
  }
17579
17579
  }
17580
17580
  const catchall = def.catchall;
@@ -17995,9 +17995,9 @@ function generateTupleCheck(doc, ctx, schema, accessor) {
17995
17995
  }
17996
17996
  return outputVar;
17997
17997
  }
17998
- function getTupleOptStart2(items, key2) {
17998
+ function getTupleOptStart2(items, key3) {
17999
17999
  for (let i = items.length - 1; i >= 0; i--) {
18000
- const omittable = key2 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
18000
+ const omittable = key3 === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional";
18001
18001
  if (!omittable)
18002
18002
  return i + 1;
18003
18003
  }
@@ -18127,16 +18127,16 @@ function generateRecordCheck(doc, ctx, schema, accessor) {
18127
18127
  const keyValues = recordDef.partial ? void 0 : def.keyType._zod.values;
18128
18128
  if (keyValues) {
18129
18129
  const inputKeys = [];
18130
- for (const key2 of keyValues) {
18131
- if (!(typeof key2 === "string" || typeof key2 === "number" || typeof key2 === "symbol")) {
18132
- throw new ZodCompileUnsupportedError(`record key value ${String(key2)}`);
18130
+ for (const key3 of keyValues) {
18131
+ if (!(typeof key3 === "string" || typeof key3 === "number" || typeof key3 === "symbol")) {
18132
+ throw new ZodCompileUnsupportedError(`record key value ${String(key3)}`);
18133
18133
  }
18134
- const inputKey = typeof key2 === "number" ? key2.toString() : key2;
18134
+ const inputKey = typeof key3 === "number" ? key3.toString() : key3;
18135
18135
  if (inputKey === "__proto__") {
18136
18136
  throw new ZodCompileUnsupportedError('record key "__proto__"');
18137
18137
  }
18138
18138
  inputKeys.push(inputKey);
18139
- const keyConst = addConstant(ctx, key2);
18139
+ const keyConst = addConstant(ctx, key3);
18140
18140
  const outKey = generateCheck(doc, ctx, def.keyType, keyConst);
18141
18141
  const valueVar = newVar(ctx);
18142
18142
  doc.write(`const ${valueVar} = ${accessor}[${literalPropertyKey(ctx, inputKey)}];`);
@@ -18214,10 +18214,10 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
18214
18214
  });
18215
18215
  doc.write(`}`);
18216
18216
  }
18217
- function literalPropertyKey(ctx, key2) {
18218
- if (typeof key2 === "string")
18219
- return esc(key2);
18220
- return addConstant(ctx, key2);
18217
+ function literalPropertyKey(ctx, key3) {
18218
+ if (typeof key3 === "string")
18219
+ return esc(key3);
18220
+ return addConstant(ctx, key3);
18221
18221
  }
18222
18222
  function generateMapCheck(doc, ctx, schema, accessor) {
18223
18223
  const def = schema._zod.def;
@@ -19446,9 +19446,9 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
19446
19446
  // node_modules/zod/v4/core/to-json-schema.js
19447
19447
  function assignProps(target, ...sources) {
19448
19448
  for (const source of sources) {
19449
- for (const key2 of Reflect.ownKeys(source)) {
19450
- if (Object.prototype.propertyIsEnumerable.call(source, key2)) {
19451
- assignProp(target, key2, source[key2]);
19449
+ for (const key3 of Reflect.ownKeys(source)) {
19450
+ if (Object.prototype.propertyIsEnumerable.call(source, key3)) {
19451
+ assignProp(target, key3, source[key3]);
19452
19452
  }
19453
19453
  }
19454
19454
  }
@@ -19594,8 +19594,8 @@ function extractDefs(ctx, schema) {
19594
19594
  if (defId)
19595
19595
  seen.defId = defId;
19596
19596
  const schema2 = seen.schema;
19597
- for (const key2 in schema2) {
19598
- delete schema2[key2];
19597
+ for (const key3 in schema2) {
19598
+ delete schema2[key3];
19599
19599
  }
19600
19600
  schema2.$ref = ref;
19601
19601
  };
@@ -19676,8 +19676,8 @@ function foldObjects(members2) {
19676
19676
  for (const member of members2) {
19677
19677
  if (typeof member !== "object" || member.type !== "object")
19678
19678
  return null;
19679
- for (const key2 in member) {
19680
- if (!FOLDABLE_KEYS.has(key2))
19679
+ for (const key3 in member) {
19680
+ if (!FOLDABLE_KEYS.has(key3))
19681
19681
  return null;
19682
19682
  }
19683
19683
  objects.push(member);
@@ -19685,22 +19685,22 @@ function foldObjects(members2) {
19685
19685
  const properties = {};
19686
19686
  const required2 = /* @__PURE__ */ new Set();
19687
19687
  for (const object2 of objects) {
19688
- for (const key2 in object2.properties) {
19689
- if (Object.prototype.hasOwnProperty.call(properties, key2))
19688
+ for (const key3 in object2.properties) {
19689
+ if (Object.prototype.hasOwnProperty.call(properties, key3))
19690
19690
  continue;
19691
19691
  const parts = [];
19692
19692
  for (const other of objects) {
19693
- const part = other.properties?.[key2] ?? undeclaredConstraint(other);
19693
+ const part = other.properties?.[key3] ?? undeclaredConstraint(other);
19694
19694
  if (part === null || part === void 0)
19695
19695
  continue;
19696
19696
  if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part)))
19697
19697
  parts.push(part);
19698
19698
  }
19699
19699
  const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
19700
- assignProp(properties, key2, merged);
19700
+ assignProp(properties, key3, merged);
19701
19701
  }
19702
- for (const key2 of object2.required ?? [])
19703
- required2.add(key2);
19702
+ for (const key3 of object2.required ?? [])
19703
+ required2.add(key3);
19704
19704
  }
19705
19705
  const folded = { type: "object", properties };
19706
19706
  if (required2.size)
@@ -19725,8 +19725,8 @@ function foldIntersection(json2) {
19725
19725
  const allOf = json2.allOf;
19726
19726
  if (!Array.isArray(allOf) || allOf.length < 2)
19727
19727
  return;
19728
- for (const key2 of FOLDABLE_KEYS)
19729
- if (key2 in json2)
19728
+ for (const key3 of FOLDABLE_KEYS)
19729
+ if (key3 in json2)
19730
19730
  return;
19731
19731
  const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
19732
19732
  let folded = null;
@@ -19773,20 +19773,20 @@ function finalize(ctx, schema) {
19773
19773
  assignProps(schema2, _cached);
19774
19774
  const isParentRef = zodSchema._zod.parent === ref;
19775
19775
  if (isParentRef) {
19776
- for (const key2 in schema2) {
19777
- if (key2 === "$ref" || key2 === "allOf")
19776
+ for (const key3 in schema2) {
19777
+ if (key3 === "$ref" || key3 === "allOf")
19778
19778
  continue;
19779
- if (!(key2 in _cached)) {
19780
- delete schema2[key2];
19779
+ if (!(key3 in _cached)) {
19780
+ delete schema2[key3];
19781
19781
  }
19782
19782
  }
19783
19783
  }
19784
19784
  if (refSchema.$ref && refSeen.def) {
19785
- for (const key2 in schema2) {
19786
- if (key2 === "$ref" || key2 === "allOf")
19785
+ for (const key3 in schema2) {
19786
+ if (key3 === "$ref" || key3 === "allOf")
19787
19787
  continue;
19788
- if (key2 in refSeen.def && JSON.stringify(schema2[key2]) === JSON.stringify(refSeen.def[key2])) {
19789
- delete schema2[key2];
19788
+ if (key3 in refSeen.def && JSON.stringify(schema2[key3]) === JSON.stringify(refSeen.def[key3])) {
19789
+ delete schema2[key3];
19790
19790
  }
19791
19791
  }
19792
19792
  }
@@ -19798,11 +19798,11 @@ function finalize(ctx, schema) {
19798
19798
  if (parentSeen?.schema.$ref) {
19799
19799
  schema2.$ref = parentSeen.schema.$ref;
19800
19800
  if (parentSeen.def) {
19801
- for (const key2 in schema2) {
19802
- if (key2 === "$ref" || key2 === "allOf")
19801
+ for (const key3 in schema2) {
19802
+ if (key3 === "$ref" || key3 === "allOf")
19803
19803
  continue;
19804
- if (key2 in parentSeen.def && JSON.stringify(schema2[key2]) === JSON.stringify(parentSeen.def[key2])) {
19805
- delete schema2[key2];
19804
+ if (key3 in parentSeen.def && JSON.stringify(schema2[key3]) === JSON.stringify(parentSeen.def[key3])) {
19805
+ delete schema2[key3];
19806
19806
  }
19807
19807
  }
19808
19808
  }
@@ -19935,8 +19935,8 @@ function isTransforming(_schema, _ctx) {
19935
19935
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
19936
19936
  }
19937
19937
  if (def.type === "object") {
19938
- for (const key2 in def.shape) {
19939
- if (isTransforming(def.shape[key2], ctx))
19938
+ for (const key3 in def.shape) {
19939
+ if (isTransforming(def.shape[key3], ctx))
19940
19940
  return true;
19941
19941
  }
19942
19942
  return false;
@@ -19974,13 +19974,13 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
19974
19974
  };
19975
19975
 
19976
19976
  // node_modules/zod/v4/core/json-schema-processors.js
19977
- var narrowMin = (agg, key2, value) => {
19978
- if (agg[key2] === void 0 || value > agg[key2])
19979
- agg[key2] = value;
19977
+ var narrowMin = (agg, key3, value) => {
19978
+ if (agg[key3] === void 0 || value > agg[key3])
19979
+ agg[key3] = value;
19980
19980
  };
19981
- var narrowMax = (agg, key2, value) => {
19982
- if (agg[key2] === void 0 || value < agg[key2])
19983
- agg[key2] = value;
19981
+ var narrowMax = (agg, key3, value) => {
19982
+ if (agg[key3] === void 0 || value < agg[key3])
19983
+ agg[key3] = value;
19984
19984
  };
19985
19985
  var narrowBoth = (agg, value) => {
19986
19986
  narrowMin(agg, "minimum", value);
@@ -20318,17 +20318,17 @@ var objectProcessor = (schema, ctx, _json, params) => {
20318
20318
  }
20319
20319
  json2.type = "object";
20320
20320
  json2.properties = {};
20321
- for (const key2 in shape) {
20322
- assignProp(json2.properties, key2, processSchema(shape[key2], ctx, {
20321
+ for (const key3 in shape) {
20322
+ assignProp(json2.properties, key3, processSchema(shape[key3], ctx, {
20323
20323
  ...params,
20324
- path: [...params.path, "properties", key2]
20324
+ path: [...params.path, "properties", key3]
20325
20325
  }));
20326
20326
  }
20327
20327
  const requiredKeys = [];
20328
- for (const key2 of Object.keys(shape)) {
20329
- const field = def.shape[key2];
20328
+ for (const key3 of Object.keys(shape)) {
20329
+ const field = def.shape[key3];
20330
20330
  if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) {
20331
- requiredKeys.push(key2);
20331
+ requiredKeys.push(key3);
20332
20332
  }
20333
20333
  }
20334
20334
  if (requiredKeys.length > 0) {
@@ -20703,9 +20703,9 @@ function toJSONSchema(input2, params) {
20703
20703
  };
20704
20704
  ctx2.external = external;
20705
20705
  for (const entry of registry2._idmap.entries()) {
20706
- const [key2, schema] = entry;
20706
+ const [key3, schema] = entry;
20707
20707
  extractDefs(ctx2, schema);
20708
- assignProp(schemas, key2, finalize(ctx2, schema));
20708
+ assignProp(schemas, key3, finalize(ctx2, schema));
20709
20709
  }
20710
20710
  if (Object.keys(defs).length > 0) {
20711
20711
  const defsSegment = ctx2.target === "draft-2020-12" ? "$defs" : "definitions";
@@ -21020,17 +21020,17 @@ __export(checks_exports2, {
21020
21020
 
21021
21021
  // node_modules/zod/v4/classic/errors.js
21022
21022
  var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
21023
- function _lazyMethod(proto, key2, make) {
21024
- Object.defineProperty(proto, key2, {
21023
+ function _lazyMethod(proto, key3, make) {
21024
+ Object.defineProperty(proto, key3, {
21025
21025
  configurable: true,
21026
21026
  enumerable: false,
21027
21027
  get() {
21028
21028
  const value = make(this);
21029
- Object.defineProperty(this, key2, { value, configurable: true, writable: true });
21029
+ Object.defineProperty(this, key3, { value, configurable: true, writable: true });
21030
21030
  return value;
21031
21031
  },
21032
21032
  set(value) {
21033
- Object.defineProperty(this, key2, { value, configurable: true, writable: true });
21033
+ Object.defineProperty(this, key3, { value, configurable: true, writable: true });
21034
21034
  }
21035
21035
  });
21036
21036
  }
@@ -22700,11 +22700,11 @@ function resolveRef(ref, ctx) {
22700
22700
  }
22701
22701
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
22702
22702
  if (path[0] === defsKey) {
22703
- const key2 = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
22704
- if (!key2 || !ctx.defs[key2]) {
22703
+ const key3 = path[1] === void 0 ? void 0 : decodeJSONPointerSegment(path[1]);
22704
+ if (!key3 || !ctx.defs[key3]) {
22705
22705
  throw new Error(`Reference not found: ${ref}`);
22706
22706
  }
22707
- return ctx.defs[key2];
22707
+ return ctx.defs[key3];
22708
22708
  }
22709
22709
  throw new Error(`Reference not found: ${ref}`);
22710
22710
  }
@@ -22739,16 +22739,16 @@ function checkObjectGuards(objectSchema, guards) {
22739
22739
  });
22740
22740
  }
22741
22741
  if (guards.keySchema) {
22742
- for (const key2 of keys) {
22743
- const result = guards.keySchema.safeParse(key2);
22742
+ for (const key3 of keys) {
22743
+ const result = guards.keySchema.safeParse(key3);
22744
22744
  if (result.success)
22745
22745
  continue;
22746
22746
  payload.issues.push({
22747
22747
  code: "invalid_key",
22748
22748
  origin: "record",
22749
22749
  issues: result.error.issues,
22750
- input: key2,
22751
- path: [key2],
22750
+ input: key3,
22751
+ path: [key3],
22752
22752
  continue: true
22753
22753
  });
22754
22754
  }
@@ -22773,20 +22773,20 @@ function canonicalKey(value, seen) {
22773
22773
  if (Array.isArray(value)) {
22774
22774
  const parts2 = [];
22775
22775
  for (const item of value) {
22776
- const key2 = canonicalKey(item, seen);
22777
- if (key2 === null)
22776
+ const key3 = canonicalKey(item, seen);
22777
+ if (key3 === null)
22778
22778
  return null;
22779
- parts2.push(key2);
22779
+ parts2.push(key3);
22780
22780
  }
22781
22781
  return `a${parts2.length}:[${parts2.join(",")}]`;
22782
22782
  }
22783
22783
  const keys = Object.keys(value).sort();
22784
22784
  const parts = [];
22785
22785
  for (const k of keys) {
22786
- const key2 = canonicalKey(value[k], seen);
22787
- if (key2 === null)
22786
+ const key3 = canonicalKey(value[k], seen);
22787
+ if (key3 === null)
22788
22788
  return null;
22789
- parts.push(`${k.length}:${k}=${key2}`);
22789
+ parts.push(`${k.length}:${k}=${key3}`);
22790
22790
  }
22791
22791
  return `o${parts.length}:{${parts.join(",")}}`;
22792
22792
  } finally {
@@ -22826,10 +22826,10 @@ function containsRef(value) {
22826
22826
  return value.some(containsRef);
22827
22827
  if (typeof value.$ref === "string")
22828
22828
  return true;
22829
- return Object.entries(value).some(([key2, sub]) => {
22830
- if (SCHEMA_KEYWORDS.has(key2))
22829
+ return Object.entries(value).some(([key3, sub]) => {
22830
+ if (SCHEMA_KEYWORDS.has(key3))
22831
22831
  return containsRef(sub);
22832
- if (!SCHEMA_MAP_KEYWORDS.has(key2) || typeof sub !== "object" || sub === null)
22832
+ if (!SCHEMA_MAP_KEYWORDS.has(key3) || typeof sub !== "object" || sub === null)
22833
22833
  return false;
22834
22834
  return Object.values(sub).some(containsRef);
22835
22835
  });
@@ -22845,12 +22845,12 @@ function checkArrayGuards(arraySchema, guards) {
22845
22845
  if (guards.uniqueItems === true) {
22846
22846
  const firstSeen = /* @__PURE__ */ new Map();
22847
22847
  for (let i = 0; i < items.length; i++) {
22848
- const key2 = canonicalKey(items[i], /* @__PURE__ */ new Set());
22849
- if (key2 === null)
22848
+ const key3 = canonicalKey(items[i], /* @__PURE__ */ new Set());
22849
+ if (key3 === null)
22850
22850
  continue;
22851
- const first = firstSeen.get(key2);
22851
+ const first = firstSeen.get(key3);
22852
22852
  if (first === void 0) {
22853
- firstSeen.set(key2, i);
22853
+ firstSeen.set(key3, i);
22854
22854
  continue;
22855
22855
  }
22856
22856
  payload.issues.push({
@@ -23089,9 +23089,9 @@ function convertBaseSchema(schema, ctx) {
23089
23089
  const properties = schema.properties || {};
23090
23090
  const requiredSet = new Set(schema.required || []);
23091
23091
  const additionalSchema = typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : void 0;
23092
- for (const [key2, propSchema] of Object.entries(properties)) {
23092
+ for (const [key3, propSchema] of Object.entries(properties)) {
23093
23093
  const propZodSchema = convertSchema(propSchema, ctx);
23094
- assignProp(shape, key2, requiredSet.has(key2) ? propZodSchema : propZodSchema.optional());
23094
+ assignProp(shape, key3, requiredSet.has(key3) ? propZodSchema : propZodSchema.optional());
23095
23095
  }
23096
23096
  if (schema.patternProperties) {
23097
23097
  const patternProps = schema.patternProperties;
@@ -23126,12 +23126,12 @@ function convertBaseSchema(schema, ctx) {
23126
23126
  if (!isPlainObject(payload.value))
23127
23127
  return;
23128
23128
  const unrecognized = [];
23129
- for (const key2 of Object.keys(payload.value)) {
23130
- if (propertyKeys.includes(key2))
23129
+ for (const key3 of Object.keys(payload.value)) {
23130
+ if (propertyKeys.includes(key3))
23131
23131
  continue;
23132
- if (patterns.some((regex) => regex.test(key2)))
23132
+ if (patterns.some((regex) => regex.test(key3)))
23133
23133
  continue;
23134
- unrecognized.push(key2);
23134
+ unrecognized.push(key3);
23135
23135
  }
23136
23136
  if (unrecognized.length) {
23137
23137
  payload.issues.push({
@@ -23262,38 +23262,38 @@ function convertSchema(schema, ctx) {
23262
23262
  }
23263
23263
  const extraMeta = {};
23264
23264
  const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
23265
- for (const key2 of coreMetadataKeys) {
23266
- if (key2 in schema) {
23267
- extraMeta[key2] = schema[key2];
23265
+ for (const key3 of coreMetadataKeys) {
23266
+ if (key3 in schema) {
23267
+ extraMeta[key3] = schema[key3];
23268
23268
  }
23269
23269
  }
23270
23270
  const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
23271
- for (const key2 of contentMetadataKeys) {
23272
- if (key2 in schema) {
23273
- extraMeta[key2] = schema[key2];
23271
+ for (const key3 of contentMetadataKeys) {
23272
+ if (key3 in schema) {
23273
+ extraMeta[key3] = schema[key3];
23274
23274
  }
23275
23275
  }
23276
23276
  if (schema.type === "object" && schema.$ref === void 0) {
23277
23277
  if (schema.propertyNames !== void 0 && !containsRef(schema.propertyNames)) {
23278
23278
  extraMeta.propertyNames = schema.propertyNames;
23279
23279
  }
23280
- for (const key2 of ["minProperties", "maxProperties"]) {
23281
- if (schema[key2] !== void 0)
23282
- extraMeta[key2] = schema[key2];
23280
+ for (const key3 of ["minProperties", "maxProperties"]) {
23281
+ if (schema[key3] !== void 0)
23282
+ extraMeta[key3] = schema[key3];
23283
23283
  }
23284
23284
  }
23285
23285
  if (schema.type === "array" && schema.$ref === void 0) {
23286
23286
  if (schema.contains !== void 0 && !containsRef(schema.contains)) {
23287
23287
  extraMeta.contains = schema.contains;
23288
23288
  }
23289
- for (const key2 of ["uniqueItems", "minContains", "maxContains"]) {
23290
- if (schema[key2] !== void 0)
23291
- extraMeta[key2] = schema[key2];
23289
+ for (const key3 of ["uniqueItems", "minContains", "maxContains"]) {
23290
+ if (schema[key3] !== void 0)
23291
+ extraMeta[key3] = schema[key3];
23292
23292
  }
23293
23293
  }
23294
- for (const key2 of Object.keys(schema)) {
23295
- if (!RECOGNIZED_KEYS.has(key2)) {
23296
- assignProp(extraMeta, key2, schema[key2]);
23294
+ for (const key3 of Object.keys(schema)) {
23295
+ if (!RECOGNIZED_KEYS.has(key3)) {
23296
+ assignProp(extraMeta, key3, schema[key3]);
23297
23297
  }
23298
23298
  }
23299
23299
  if (Object.keys(extraMeta).length > 0) {
@@ -24711,7 +24711,7 @@ var TOOL_RESULT_FOREIGN_FAMILY_KEYS = [
24711
24711
  "requestState"
24712
24712
  ];
24713
24713
  function normalizeContentlessToolResult(value) {
24714
- if (value === null || typeof value !== "object" || Array.isArray(value) || value.content !== void 0 || TOOL_RESULT_FOREIGN_FAMILY_KEYS.some((key2) => key2 in value)) return value;
24714
+ if (value === null || typeof value !== "object" || Array.isArray(value) || value.content !== void 0 || TOOL_RESULT_FOREIGN_FAMILY_KEYS.some((key3) => key3 in value)) return value;
24715
24715
  return {
24716
24716
  ...value,
24717
24717
  content: []
@@ -25581,10 +25581,10 @@ function build$1() {
25581
25581
  ]),
25582
25582
  CallToolResultWireSchema: unknown().superRefine((value, ctx) => {
25583
25583
  if (typeof value !== "object" || value === null || Array.isArray(value) || value.content !== void 0) return;
25584
- for (const key2 of TOOL_RESULT_FOREIGN_FAMILY_KEYS) if (key2 in value) {
25584
+ for (const key3 of TOOL_RESULT_FOREIGN_FAMILY_KEYS) if (key3 in value) {
25585
25585
  ctx.addIssue({
25586
25586
  code: "custom",
25587
- message: `content is required when the body carries '${key2}' \u2014 another result family cannot default into an empty tools/call success`
25587
+ message: `content is required when the body carries '${key3}' \u2014 another result family cannot default into an empty tools/call success`
25588
25588
  });
25589
25589
  return;
25590
25590
  }
@@ -27122,17 +27122,17 @@ var rev2026Codec = {
27122
27122
  },
27123
27123
  validateEnvelopeMeta(meta3) {
27124
27124
  const issues = [];
27125
- for (const key2 of REQUIRED_ENVELOPE_KEYS) if (!(key2 in meta3)) issues.push({
27126
- key: key2,
27125
+ for (const key3 of REQUIRED_ENVELOPE_KEYS) if (!(key3 in meta3)) issues.push({
27126
+ key: key3,
27127
27127
  problem: "missing"
27128
27128
  });
27129
27129
  const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
27130
27130
  if (!parsed.success) for (const issue2 of parsed.error.issues) {
27131
27131
  const path = issue2.path.map(String);
27132
- const key2 = path.length > 0 ? path.join(".") : "_meta";
27133
- if (path.length === 1 && issues.some((existing) => existing.key === key2 && existing.problem === "missing")) continue;
27132
+ const key3 = path.length > 0 ? path.join(".") : "_meta";
27133
+ if (path.length === 1 && issues.some((existing) => existing.key === key3 && existing.problem === "missing")) continue;
27134
27134
  issues.push({
27135
- key: key2,
27135
+ key: key3,
27136
27136
  problem: issue2.message
27137
27137
  });
27138
27138
  }
@@ -27482,8 +27482,8 @@ function scanXMcpHeaderDeclarations(inputSchema) {
27482
27482
  });
27483
27483
  }
27484
27484
  const properties = schema.properties;
27485
- if (properties !== null && typeof properties === "object") for (const [key2, child] of Object.entries(properties)) {
27486
- const fault$1 = visit2(child, [...path, key2], reachable);
27485
+ if (properties !== null && typeof properties === "object") for (const [key3, child] of Object.entries(properties)) {
27486
+ const fault$1 = visit2(child, [...path, key3], reachable);
27487
27487
  if (fault$1 !== void 0) return fault$1;
27488
27488
  }
27489
27489
  for (const k of NON_REACHABLE_SUBSCHEMA_KEYWORDS) {
@@ -27713,12 +27713,12 @@ function isProvablyObjectShapedRoot(schema, root = schema) {
27713
27713
  if ("properties" in schema || "patternProperties" in schema || "additionalProperties" in schema || "required" in schema) return true;
27714
27714
  const ref = typeof schema.$ref === "string" && LOCAL_DEFINITION_REF.exec(schema.$ref);
27715
27715
  if (ref && root[ref[1]]?.[ref[2]]?.type === "object") return true;
27716
- for (const key2 of [
27716
+ for (const key3 of [
27717
27717
  "oneOf",
27718
27718
  "anyOf",
27719
27719
  "allOf"
27720
27720
  ]) {
27721
- const members2 = schema[key2];
27721
+ const members2 = schema[key3];
27722
27722
  if (Array.isArray(members2) && members2.length > 0) return members2.every((m) => m !== null && typeof m === "object" && (m.type === "object" || isProvablyObjectShapedRoot(m, "$id" in m ? {} : root)));
27723
27723
  }
27724
27724
  return false;
@@ -27812,8 +27812,8 @@ var ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
27812
27812
  "title",
27813
27813
  "writeOnly"
27814
27814
  ]);
27815
- function isAnnotationOnlyJsonSchemaKeyword(key2) {
27816
- return ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS.has(key2) || key2.startsWith("x-");
27815
+ function isAnnotationOnlyJsonSchemaKeyword(key3) {
27816
+ return ANNOTATION_ONLY_JSON_SCHEMA_KEYWORDS.has(key3) || key3.startsWith("x-");
27817
27817
  }
27818
27818
  var ROOT_KEYS = /* @__PURE__ */ new Set(["$schema", ...Object.keys(ElicitRequestFormParamsSchema.shape.requestedSchema.shape)]);
27819
27819
  var PROPERTY_KEYS_BY_TYPE = {
@@ -27834,19 +27834,19 @@ function walkProperty(node2, path, vendor, unsupported) {
27834
27834
  const allowedKeys = typeof node2.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node2.type) ? PROPERTY_KEYS_BY_TYPE[node2.type] : void 0;
27835
27835
  if (allowedKeys === void 0) return node2;
27836
27836
  const pruned = {};
27837
- for (const [key2, value] of Object.entries(node2)) if (allowedKeys.has(key2) || isAnnotationOnlyJsonSchemaKeyword(key2)) pruned[key2] = value;
27838
- else if (key2 === "pattern" && node2.type === "string" && typeof node2.format === "string") {
27839
- if (!SUPPORTED_STRING_FORMATS.has(node2.format)) pruned[key2] = value;
27840
- else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path}.${key2}`);
27841
- } else unsupported.push(`${path}.${key2}`);
27837
+ for (const [key3, value] of Object.entries(node2)) if (allowedKeys.has(key3) || isAnnotationOnlyJsonSchemaKeyword(key3)) pruned[key3] = value;
27838
+ else if (key3 === "pattern" && node2.type === "string" && typeof node2.format === "string") {
27839
+ if (!SUPPORTED_STRING_FORMATS.has(node2.format)) pruned[key3] = value;
27840
+ else if (typeof value !== "string" || !isLibraryFormatPattern(node2.format, value, vendor)) unsupported.push(`${path}.${key3}`);
27841
+ } else unsupported.push(`${path}.${key3}`);
27842
27842
  return pruned;
27843
27843
  }
27844
27844
  function walkRequestedSchema(converted, vendor) {
27845
27845
  const pruned = {};
27846
27846
  const unsupported = [];
27847
- for (const [key2, value] of Object.entries(converted)) if (key2 === "properties" && isJsonObject(value)) pruned[key2] = Object.fromEntries(Object.entries(value).map(([name, node2]) => [name, walkProperty(node2, `properties.${name}`, vendor, unsupported)]));
27848
- else if (ROOT_KEYS.has(key2)) pruned[key2] = value;
27849
- else if (!isAnnotationOnlyJsonSchemaKeyword(key2)) unsupported.push(key2);
27847
+ for (const [key3, value] of Object.entries(converted)) if (key3 === "properties" && isJsonObject(value)) pruned[key3] = Object.fromEntries(Object.entries(value).map(([name, node2]) => [name, walkProperty(node2, `properties.${name}`, vendor, unsupported)]));
27848
+ else if (ROOT_KEYS.has(key3)) pruned[key3] = value;
27849
+ else if (!isAnnotationOnlyJsonSchemaKeyword(key3)) unsupported.push(key3);
27850
27850
  if (unsupported.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${unsupported.join(", ")}`);
27851
27851
  return pruned;
27852
27852
  }
@@ -27858,10 +27858,10 @@ function describeUnsupportedProperties(pruned, fallback) {
27858
27858
  function findDroppedConstraintPaths(original, parsed, path = "") {
27859
27859
  if (Array.isArray(original) && Array.isArray(parsed)) return original.flatMap((item, index) => findDroppedConstraintPaths(item, parsed[index], `${path}[${index}]`));
27860
27860
  if (!isJsonObject(original) || !isJsonObject(parsed)) return [];
27861
- return Object.entries(original).flatMap(([key2, value]) => {
27862
- const childPath = path ? `${path}.${key2}` : key2;
27863
- if (!Object.prototype.hasOwnProperty.call(parsed, key2)) return isAnnotationOnlyJsonSchemaKeyword(key2) ? [] : [childPath];
27864
- return findDroppedConstraintPaths(value, parsed[key2], childPath);
27861
+ return Object.entries(original).flatMap(([key3, value]) => {
27862
+ const childPath = path ? `${path}.${key3}` : key3;
27863
+ if (!Object.prototype.hasOwnProperty.call(parsed, key3)) return isAnnotationOnlyJsonSchemaKeyword(key3) ? [] : [childPath];
27864
+ return findDroppedConstraintPaths(value, parsed[key3], childPath);
27865
27865
  });
27866
27866
  }
27867
27867
  function normalizeElicitInputParams(input2) {
@@ -27876,7 +27876,7 @@ function normalizeElicitInputParams(input2) {
27876
27876
  if (!parsed.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${describeUnsupportedProperties(pruned, parsed.error.message)}`);
27877
27877
  const droppedConstraints = findDroppedConstraintPaths(pruned, parsed.data);
27878
27878
  if (droppedConstraints.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${droppedConstraints.join(", ")}`);
27879
- const danglingRequired = (parsed.data.required ?? []).filter((key2) => !Object.prototype.hasOwnProperty.call(parsed.data.properties, key2));
27879
+ const danglingRequired = (parsed.data.required ?? []).filter((key3) => !Object.prototype.hasOwnProperty.call(parsed.data.properties, key3));
27880
27880
  if (danglingRequired.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema lists required properties that are not defined in properties: ${danglingRequired.join(", ")}`);
27881
27881
  return {
27882
27882
  ...input2,
@@ -27924,17 +27924,17 @@ var inputRequired = Object.assign(buildInputRequired, {
27924
27924
  return { method: "roots/list" };
27925
27925
  }
27926
27926
  });
27927
- function acceptedContent(responses, key2, schema) {
27928
- const view = inputResponse(responses, key2);
27927
+ function acceptedContent(responses, key3, schema) {
27928
+ const view = inputResponse(responses, key3);
27929
27929
  if (view.kind !== "elicit" || view.action !== "accept" || view.content === void 0) return void 0;
27930
27930
  if (schema === void 0) return view.content;
27931
27931
  const outcome = schema["~standard"].validate(view.content);
27932
27932
  if (outcome instanceof Promise) throw new TypeError("acceptedContent(responses, key, schema) requires a synchronously-validating schema");
27933
27933
  return outcome.issues === void 0 ? outcome.value : void 0;
27934
27934
  }
27935
- function inputResponse(responses, key2) {
27935
+ function inputResponse(responses, key3) {
27936
27936
  if (responses === void 0 || typeof responses !== "object" || responses === null) return { kind: "missing" };
27937
- const entry = responses[key2];
27937
+ const entry = responses[key3];
27938
27938
  if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return { kind: "missing" };
27939
27939
  const candidate = entry;
27940
27940
  if (candidate["action"] === "accept" || candidate["action"] === "decline" || candidate["action"] === "cancel") {
@@ -28166,13 +28166,13 @@ var authSchemas = {
28166
28166
  };
28167
28167
  var _specTypeSchemas = {};
28168
28168
  var _isSpecType = {};
28169
- function register(key2, schema) {
28170
- const name = key2.slice(0, -6);
28169
+ function register(key3, schema) {
28170
+ const name = key3.slice(0, -6);
28171
28171
  _specTypeSchemas[name] = schema;
28172
28172
  _isSpecType[name] = (v) => schema.safeParse(v).success;
28173
28173
  }
28174
- for (const key2 of SPEC_SCHEMA_KEYS) register(key2, schemas_exports3[key2]);
28175
- for (const [key2, schema] of Object.entries(authSchemas)) register(key2, schema);
28174
+ for (const key3 of SPEC_SCHEMA_KEYS) register(key3, schemas_exports3[key3]);
28175
+ for (const [key3, schema] of Object.entries(authSchemas)) register(key3, schema);
28176
28176
  var specTypeSchemas = Object.freeze(_specTypeSchemas);
28177
28177
  var isSpecType = Object.freeze(_isSpecType);
28178
28178
  function bootstrapOutboundCodec(method) {
@@ -28201,8 +28201,8 @@ function liftWireOnlyMaterial(message, kind) {
28201
28201
  lifted: {}
28202
28202
  };
28203
28203
  const meta3 = params._meta;
28204
- const envelopeKeys = isPlainObject$1(meta3) ? RESERVED_ENVELOPE_META_KEYS.filter((key2) => key2 in meta3) : [];
28205
- const retryKeys = kind === "request" ? RETRY_PARAMS_KEYS.filter((key2) => key2 in params) : [];
28204
+ const envelopeKeys = isPlainObject$1(meta3) ? RESERVED_ENVELOPE_META_KEYS.filter((key3) => key3 in meta3) : [];
28205
+ const retryKeys = kind === "request" ? RETRY_PARAMS_KEYS.filter((key3) => key3 in params) : [];
28206
28206
  if (envelopeKeys.length === 0 && retryKeys.length === 0) return {
28207
28207
  message,
28208
28208
  lifted: {}
@@ -28212,18 +28212,18 @@ function liftWireOnlyMaterial(message, kind) {
28212
28212
  if (envelopeKeys.length > 0 && isPlainObject$1(meta3)) {
28213
28213
  const envelope = {};
28214
28214
  const nextMeta = { ...meta3 };
28215
- for (const key2 of envelopeKeys) {
28216
- envelope[key2] = meta3[key2];
28217
- delete nextMeta[key2];
28215
+ for (const key3 of envelopeKeys) {
28216
+ envelope[key3] = meta3[key3];
28217
+ delete nextMeta[key3];
28218
28218
  }
28219
28219
  lifted.envelope = envelope;
28220
28220
  if (Object.keys(nextMeta).length > 0) nextParams._meta = nextMeta;
28221
28221
  else delete nextParams._meta;
28222
28222
  }
28223
- for (const key2 of retryKeys) {
28224
- if (key2 === "inputResponses") lifted.inputResponses = nextParams[key2];
28225
- if (key2 === "requestState") lifted.requestState = nextParams[key2];
28226
- delete nextParams[key2];
28223
+ for (const key3 of retryKeys) {
28224
+ if (key3 === "inputResponses") lifted.inputResponses = nextParams[key3];
28225
+ if (key3 === "requestState") lifted.requestState = nextParams[key3];
28226
+ delete nextParams[key3];
28227
28227
  }
28228
28228
  return {
28229
28229
  message: {
@@ -29004,8 +29004,8 @@ function isPlainObject$1(value) {
29004
29004
  }
29005
29005
  function mergeCapabilities(base, additional) {
29006
29006
  const result = { ...base };
29007
- for (const key2 in additional) {
29008
- const k = key2;
29007
+ for (const key3 in additional) {
29008
+ const k = key3;
29009
29009
  const addValue = additional[k];
29010
29010
  if (addValue === void 0) continue;
29011
29011
  const baseValue = result[k];
@@ -29026,12 +29026,12 @@ function partitionInputResponses(inputResponses) {
29026
29026
  accepted,
29027
29027
  droppedKeys
29028
29028
  };
29029
- for (const [key2, entry] of Object.entries(inputResponses)) {
29029
+ for (const [key3, entry] of Object.entries(inputResponses)) {
29030
29030
  if (!isPlainObject2(entry) || "method" in entry || "result" in entry) {
29031
- droppedKeys.push(key2);
29031
+ droppedKeys.push(key3);
29032
29032
  continue;
29033
29033
  }
29034
- accepted[key2] = entry;
29034
+ accepted[key3] = entry;
29035
29035
  }
29036
29036
  return {
29037
29037
  accepted,
@@ -29060,20 +29060,20 @@ var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
29060
29060
  if (!TYPE_REGEXP.test(type)) throw new TypeError("invalid media type");
29061
29061
  var obj = new ContentType(type.toLowerCase());
29062
29062
  if (index !== -1) {
29063
- var key2;
29063
+ var key3;
29064
29064
  var match;
29065
29065
  var value;
29066
29066
  PARAM_REGEXP.lastIndex = index;
29067
29067
  while (match = PARAM_REGEXP.exec(header)) {
29068
29068
  if (match.index !== index) throw new TypeError("invalid parameter format");
29069
29069
  index += match[0].length;
29070
- key2 = match[1].toLowerCase();
29070
+ key3 = match[1].toLowerCase();
29071
29071
  value = match[2];
29072
29072
  if (value.charCodeAt(0) === 34) {
29073
29073
  value = value.slice(1, -1);
29074
29074
  if (value.indexOf("\\") !== -1) value = value.replace(QESC_REGEXP, "$1");
29075
29075
  }
29076
- obj.parameters[key2] = value;
29076
+ obj.parameters[key3] = value;
29077
29077
  }
29078
29078
  if (index !== header.length) throw new TypeError("invalid parameter format");
29079
29079
  }
@@ -29315,13 +29315,13 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
29315
29315
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
29316
29316
  }
29317
29317
  exports.safeStringify = safeStringify;
29318
- function getProperty(key2) {
29319
- return typeof key2 == "string" && exports.IDENTIFIER.test(key2) ? new _Code(`.${key2}`) : _`[${key2}]`;
29318
+ function getProperty(key3) {
29319
+ return typeof key3 == "string" && exports.IDENTIFIER.test(key3) ? new _Code(`.${key3}`) : _`[${key3}]`;
29320
29320
  }
29321
29321
  exports.getProperty = getProperty;
29322
- function getEsmExportName(key2) {
29323
- if (typeof key2 == "string" && exports.IDENTIFIER.test(key2)) return new _Code(`${key2}`);
29324
- throw new Error(`CodeGen: invalid export name: ${key2}, use explicit $id name mapping`);
29322
+ function getEsmExportName(key3) {
29323
+ if (typeof key3 == "string" && exports.IDENTIFIER.test(key3)) return new _Code(`${key3}`);
29324
+ throw new Error(`CodeGen: invalid export name: ${key3}, use explicit $id name mapping`);
29325
29325
  }
29326
29326
  exports.getEsmExportName = getEsmExportName;
29327
29327
  function regexpCode(rx) {
@@ -29932,10 +29932,10 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
29932
29932
  }
29933
29933
  object(...keyValues) {
29934
29934
  const code2 = ["{"];
29935
- for (const [key2, value] of keyValues) {
29935
+ for (const [key3, value] of keyValues) {
29936
29936
  if (code2.length > 1) code2.push(",");
29937
- code2.push(key2);
29938
- if (key2 !== value || this.opts.es5) {
29937
+ code2.push(key3);
29938
+ if (key3 !== value || this.opts.es5) {
29939
29939
  code2.push(":");
29940
29940
  (0, code_1.addCodeArg)(code2, value);
29941
29941
  }
@@ -30157,18 +30157,18 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
30157
30157
  if (!opts.strictSchema) return;
30158
30158
  if (typeof schema === "boolean") return;
30159
30159
  const rules = self.RULES.keywords;
30160
- for (const key2 in schema) if (!rules[key2]) checkStrictMode(it, `unknown keyword: "${key2}"`);
30160
+ for (const key3 in schema) if (!rules[key3]) checkStrictMode(it, `unknown keyword: "${key3}"`);
30161
30161
  }
30162
30162
  exports.checkUnknownRules = checkUnknownRules;
30163
30163
  function schemaHasRules(schema, rules) {
30164
30164
  if (typeof schema == "boolean") return !schema;
30165
- for (const key2 in schema) if (rules[key2]) return true;
30165
+ for (const key3 in schema) if (rules[key3]) return true;
30166
30166
  return false;
30167
30167
  }
30168
30168
  exports.schemaHasRules = schemaHasRules;
30169
30169
  function schemaHasRulesButRef(schema, RULES) {
30170
30170
  if (typeof schema == "boolean") return !schema;
30171
- for (const key2 in schema) if (key2 !== "$ref" && RULES.all[key2]) return true;
30171
+ for (const key3 in schema) if (key3 !== "$ref" && RULES.all[key3]) return true;
30172
30172
  return false;
30173
30173
  }
30174
30174
  exports.schemaHasRulesButRef = schemaHasRulesButRef;
@@ -30675,7 +30675,7 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
30675
30675
  const util_1 = require_util();
30676
30676
  function assignDefaults(it, ty) {
30677
30677
  const { properties, items } = it.schema;
30678
- if (ty === "object" && properties) for (const key2 in properties) assignDefault(it, key2, properties[key2].default);
30678
+ if (ty === "object" && properties) for (const key3 in properties) assignDefault(it, key3, properties[key3].default);
30679
30679
  else if (ty === "array" && Array.isArray(items)) items.forEach((sch, i) => assignDefault(it, i, sch.default));
30680
30680
  }
30681
30681
  exports.assignDefaults = assignDefaults;
@@ -31001,8 +31001,8 @@ var require_fast_deep_equal = /* @__PURE__ */ __commonJSMin(((exports, module) =
31001
31001
  if (length !== Object.keys(b).length) return false;
31002
31002
  for (i = length; i-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
31003
31003
  for (i = length; i-- !== 0; ) {
31004
- var key2 = keys[i];
31005
- if (!equal(a[key2], b[key2])) return false;
31004
+ var key3 = keys[i];
31005
+ if (!equal(a[key3], b[key3])) return false;
31006
31006
  }
31007
31007
  return true;
31008
31008
  }
@@ -31069,13 +31069,13 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
31069
31069
  function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
31070
31070
  if (schema && typeof schema == "object" && !Array.isArray(schema)) {
31071
31071
  pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
31072
- for (var key2 in schema) {
31073
- var sch = schema[key2];
31072
+ for (var key3 in schema) {
31073
+ var sch = schema[key3];
31074
31074
  if (Array.isArray(sch)) {
31075
- if (key2 in traverse.arrayKeywords) for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key2 + "/" + i, rootSchema, jsonPtr, key2, schema, i);
31076
- } else if (key2 in traverse.propsKeywords) {
31077
- if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key2 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key2, schema, prop);
31078
- } else if (key2 in traverse.keywords || opts.allKeys && !(key2 in traverse.skipKeywords)) _traverse(opts, pre, post, sch, jsonPtr + "/" + key2, rootSchema, jsonPtr, key2, schema);
31075
+ if (key3 in traverse.arrayKeywords) for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key3 + "/" + i, rootSchema, jsonPtr, key3, schema, i);
31076
+ } else if (key3 in traverse.propsKeywords) {
31077
+ if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key3 + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key3, schema, prop);
31078
+ } else if (key3 in traverse.keywords || opts.allKeys && !(key3 in traverse.skipKeywords)) _traverse(opts, pre, post, sch, jsonPtr + "/" + key3, rootSchema, jsonPtr, key3, schema);
31079
31079
  }
31080
31080
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
31081
31081
  }
@@ -31123,9 +31123,9 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
31123
31123
  "$dynamicAnchor"
31124
31124
  ]);
31125
31125
  function hasRef(schema) {
31126
- for (const key2 in schema) {
31127
- if (REF_KEYWORDS.has(key2)) return true;
31128
- const sch = schema[key2];
31126
+ for (const key3 in schema) {
31127
+ if (REF_KEYWORDS.has(key3)) return true;
31128
+ const sch = schema[key3];
31129
31129
  if (Array.isArray(sch) && sch.some(hasRef)) return true;
31130
31130
  if (typeof sch == "object" && hasRef(sch)) return true;
31131
31131
  }
@@ -31133,11 +31133,11 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
31133
31133
  }
31134
31134
  function countKeys(schema) {
31135
31135
  let count = 0;
31136
- for (const key2 in schema) {
31137
- if (key2 === "$ref") return Infinity;
31136
+ for (const key3 in schema) {
31137
+ if (key3 === "$ref") return Infinity;
31138
31138
  count++;
31139
- if (SIMPLE_INLINED.has(key2)) continue;
31140
- if (typeof schema[key2] == "object") (0, util_1.eachItem)(schema[key2], (sch) => count += countKeys(sch));
31139
+ if (SIMPLE_INLINED.has(key3)) continue;
31140
+ if (typeof schema[key3] == "object") (0, util_1.eachItem)(schema[key3], (sch) => count += countKeys(sch));
31141
31141
  if (count === Infinity) return Infinity;
31142
31142
  }
31143
31143
  return count;
@@ -31295,7 +31295,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
31295
31295
  }
31296
31296
  function schemaCxtHasRules({ schema, self }) {
31297
31297
  if (typeof schema == "boolean") return !schema;
31298
- for (const key2 in schema) if (self.RULES.all[key2]) return true;
31298
+ for (const key3 in schema) if (self.RULES.all[key3]) return true;
31299
31299
  return false;
31300
31300
  }
31301
31301
  function isSchemaObj(it) {
@@ -33028,7 +33028,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
33028
33028
  }
33029
33029
  }
33030
33030
  }
33031
- addSchema(schema, key2, _meta, _validateSchema = this.opts.validateSchema) {
33031
+ addSchema(schema, key3, _meta, _validateSchema = this.opts.validateSchema) {
33032
33032
  if (Array.isArray(schema)) {
33033
33033
  for (const sch of schema) this.addSchema(sch, void 0, _meta, _validateSchema);
33034
33034
  return this;
@@ -33039,13 +33039,13 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
33039
33039
  id2 = schema[schemaId];
33040
33040
  if (id2 !== void 0 && typeof id2 != "string") throw new Error(`schema ${schemaId} must be string`);
33041
33041
  }
33042
- key2 = (0, resolve_1.normalizeId)(key2 || id2);
33043
- this._checkUnique(key2);
33044
- this.schemas[key2] = this._addSchema(schema, _meta, key2, _validateSchema, true);
33042
+ key3 = (0, resolve_1.normalizeId)(key3 || id2);
33043
+ this._checkUnique(key3);
33044
+ this.schemas[key3] = this._addSchema(schema, _meta, key3, _validateSchema, true);
33045
33045
  return this;
33046
33046
  }
33047
- addMetaSchema(schema, key2, _validateSchema = this.opts.validateSchema) {
33048
- this.addSchema(schema, key2, true, _validateSchema);
33047
+ addMetaSchema(schema, key3, _validateSchema = this.opts.validateSchema) {
33048
+ this.addSchema(schema, key3, true, _validateSchema);
33049
33049
  return this;
33050
33050
  }
33051
33051
  validateSchema(schema, throwOrLogError) {
@@ -33177,12 +33177,12 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
33177
33177
  const segments = jsonPointer.split("/").slice(1);
33178
33178
  let keywords = metaSchema;
33179
33179
  for (const seg of segments) keywords = keywords[seg];
33180
- for (const key2 in rules) {
33181
- const rule = rules[key2];
33180
+ for (const key3 in rules) {
33181
+ const rule = rules[key3];
33182
33182
  if (typeof rule != "object") continue;
33183
33183
  const { $data } = rule.definition;
33184
- const schema = keywords[key2];
33185
- if ($data && schema) keywords[key2] = schemaOrData(schema);
33184
+ const schema = keywords[key3];
33185
+ if ($data && schema) keywords[key3] = schemaOrData(schema);
33186
33186
  }
33187
33187
  }
33188
33188
  return metaSchema;
@@ -33247,9 +33247,9 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
33247
33247
  Ajv2.MissingRefError = ref_error_1.default;
33248
33248
  exports.default = Ajv2;
33249
33249
  function checkOptions(checkOpts, options, msg, log = "error") {
33250
- for (const key2 in checkOpts) {
33251
- const opt = key2;
33252
- if (opt in options) this.logger[log](`${msg}: option ${key2}. ${checkOpts[opt]}`);
33250
+ for (const key3 in checkOpts) {
33251
+ const opt = key3;
33252
+ if (opt in options) this.logger[log](`${msg}: option ${key3}. ${checkOpts[opt]}`);
33253
33253
  }
33254
33254
  }
33255
33255
  function getSchEnv(keyRef) {
@@ -33260,7 +33260,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
33260
33260
  const optsSchemas = this.opts.schemas;
33261
33261
  if (!optsSchemas) return;
33262
33262
  if (Array.isArray(optsSchemas)) this.addSchema(optsSchemas);
33263
- else for (const key2 in optsSchemas) this.addSchema(optsSchemas[key2], key2);
33263
+ else for (const key3 in optsSchemas) this.addSchema(optsSchemas[key3], key3);
33264
33264
  }
33265
33265
  function addInitialFormats() {
33266
33266
  for (const name in this.opts.formats) {
@@ -34150,10 +34150,10 @@ var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
34150
34150
  function splitDependencies({ schema }) {
34151
34151
  const propertyDeps = {};
34152
34152
  const schemaDeps = {};
34153
- for (const key2 in schema) {
34154
- if (key2 === "__proto__") continue;
34155
- const deps = Array.isArray(schema[key2]) ? propertyDeps : schemaDeps;
34156
- deps[key2] = schema[key2];
34153
+ for (const key3 in schema) {
34154
+ if (key3 === "__proto__") continue;
34155
+ const deps = Array.isArray(schema[key3]) ? propertyDeps : schemaDeps;
34156
+ deps[key3] = schema[key3];
34157
34157
  }
34158
34158
  return [propertyDeps, schemaDeps];
34159
34159
  }
@@ -34215,13 +34215,13 @@ var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
34215
34215
  const { gen, schema, data, it } = cxt;
34216
34216
  if ((0, util_1.alwaysValidSchema)(it, schema)) return;
34217
34217
  const valid = gen.name("valid");
34218
- gen.forIn("key", data, (key2) => {
34219
- cxt.setParams({ propertyName: key2 });
34218
+ gen.forIn("key", data, (key3) => {
34219
+ cxt.setParams({ propertyName: key3 });
34220
34220
  cxt.subschema({
34221
34221
  keyword: "propertyNames",
34222
- data: key2,
34222
+ data: key3,
34223
34223
  dataTypes: ["string"],
34224
- propertyName: key2,
34224
+ propertyName: key3,
34225
34225
  compositeRule: true
34226
34226
  }, valid);
34227
34227
  gen.if((0, codegen_1.not)(valid), () => {
@@ -34261,31 +34261,31 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
34261
34261
  checkAdditionalProperties();
34262
34262
  cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
34263
34263
  function checkAdditionalProperties() {
34264
- gen.forIn("key", data, (key2) => {
34265
- if (!props.length && !patProps.length) additionalPropertyCode(key2);
34266
- else gen.if(isAdditional(key2), () => additionalPropertyCode(key2));
34264
+ gen.forIn("key", data, (key3) => {
34265
+ if (!props.length && !patProps.length) additionalPropertyCode(key3);
34266
+ else gen.if(isAdditional(key3), () => additionalPropertyCode(key3));
34267
34267
  });
34268
34268
  }
34269
- function isAdditional(key2) {
34269
+ function isAdditional(key3) {
34270
34270
  let definedProp;
34271
34271
  if (props.length > 8) {
34272
34272
  const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
34273
- definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key2);
34274
- } else if (props.length) definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key2} === ${p}`));
34273
+ definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key3);
34274
+ } else if (props.length) definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key3} === ${p}`));
34275
34275
  else definedProp = codegen_1.nil;
34276
- if (patProps.length) definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key2})`));
34276
+ if (patProps.length) definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key3})`));
34277
34277
  return (0, codegen_1.not)(definedProp);
34278
34278
  }
34279
- function deleteAdditional(key2) {
34280
- gen.code((0, codegen_1._)`delete ${data}[${key2}]`);
34279
+ function deleteAdditional(key3) {
34280
+ gen.code((0, codegen_1._)`delete ${data}[${key3}]`);
34281
34281
  }
34282
- function additionalPropertyCode(key2) {
34282
+ function additionalPropertyCode(key3) {
34283
34283
  if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
34284
- deleteAdditional(key2);
34284
+ deleteAdditional(key3);
34285
34285
  return;
34286
34286
  }
34287
34287
  if (schema === false) {
34288
- cxt.setParams({ additionalProperty: key2 });
34288
+ cxt.setParams({ additionalProperty: key3 });
34289
34289
  cxt.error();
34290
34290
  if (!allErrors) gen.break();
34291
34291
  return;
@@ -34293,21 +34293,21 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
34293
34293
  if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
34294
34294
  const valid = gen.name("valid");
34295
34295
  if (opts.removeAdditional === "failing") {
34296
- applyAdditionalSchema(key2, valid, false);
34296
+ applyAdditionalSchema(key3, valid, false);
34297
34297
  gen.if((0, codegen_1.not)(valid), () => {
34298
34298
  cxt.reset();
34299
- deleteAdditional(key2);
34299
+ deleteAdditional(key3);
34300
34300
  });
34301
34301
  } else {
34302
- applyAdditionalSchema(key2, valid);
34302
+ applyAdditionalSchema(key3, valid);
34303
34303
  if (!allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
34304
34304
  }
34305
34305
  }
34306
34306
  }
34307
- function applyAdditionalSchema(key2, valid, errors) {
34307
+ function applyAdditionalSchema(key3, valid, errors) {
34308
34308
  const subschema = {
34309
34309
  keyword: "additionalProperties",
34310
- dataProp: key2,
34310
+ dataProp: key3,
34311
34311
  dataPropType: util_1.Type.Str
34312
34312
  };
34313
34313
  if (errors === false) Object.assign(subschema, {
@@ -34401,16 +34401,16 @@ var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
34401
34401
  for (const prop in checkProperties) if (new RegExp(pat).test(prop)) (0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
34402
34402
  }
34403
34403
  function validateProperties(pat) {
34404
- gen.forIn("key", data, (key2) => {
34405
- gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key2})`, () => {
34404
+ gen.forIn("key", data, (key3) => {
34405
+ gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key3})`, () => {
34406
34406
  const alwaysValid = alwaysValidPatterns.includes(pat);
34407
34407
  if (!alwaysValid) cxt.subschema({
34408
34408
  keyword: "patternProperties",
34409
34409
  schemaProp: pat,
34410
- dataProp: key2,
34410
+ dataProp: key3,
34411
34411
  dataPropType: util_2.Type.Str
34412
34412
  }, valid);
34413
- if (it.opts.unevaluated && props !== true) gen.assign((0, codegen_1._)`${props}[${key2}]`, true);
34413
+ if (it.opts.unevaluated && props !== true) gen.assign((0, codegen_1._)`${props}[${key3}]`, true);
34414
34414
  else if (!alwaysValid && !it.allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
34415
34415
  });
34416
34416
  });
@@ -35261,13 +35261,13 @@ var require_unevaluatedProperties = /* @__PURE__ */ __commonJSMin(((exports) =>
35261
35261
  const { gen, schema, data, errsCount, it } = cxt;
35262
35262
  if (!errsCount) throw new Error("ajv implementation error");
35263
35263
  const { allErrors, props } = it;
35264
- if (props instanceof codegen_1.Name) gen.if((0, codegen_1._)`${props} !== true`, () => gen.forIn("key", data, (key2) => gen.if(unevaluatedDynamic(props, key2), () => unevaluatedPropCode(key2))));
35265
- else if (props !== true) gen.forIn("key", data, (key2) => props === void 0 ? unevaluatedPropCode(key2) : gen.if(unevaluatedStatic(props, key2), () => unevaluatedPropCode(key2)));
35264
+ if (props instanceof codegen_1.Name) gen.if((0, codegen_1._)`${props} !== true`, () => gen.forIn("key", data, (key3) => gen.if(unevaluatedDynamic(props, key3), () => unevaluatedPropCode(key3))));
35265
+ else if (props !== true) gen.forIn("key", data, (key3) => props === void 0 ? unevaluatedPropCode(key3) : gen.if(unevaluatedStatic(props, key3), () => unevaluatedPropCode(key3)));
35266
35266
  it.props = true;
35267
35267
  cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
35268
- function unevaluatedPropCode(key2) {
35268
+ function unevaluatedPropCode(key3) {
35269
35269
  if (schema === false) {
35270
- cxt.setParams({ unevaluatedProperty: key2 });
35270
+ cxt.setParams({ unevaluatedProperty: key3 });
35271
35271
  cxt.error();
35272
35272
  if (!allErrors) gen.break();
35273
35273
  return;
@@ -35276,18 +35276,18 @@ var require_unevaluatedProperties = /* @__PURE__ */ __commonJSMin(((exports) =>
35276
35276
  const valid = gen.name("valid");
35277
35277
  cxt.subschema({
35278
35278
  keyword: "unevaluatedProperties",
35279
- dataProp: key2,
35279
+ dataProp: key3,
35280
35280
  dataPropType: util_1.Type.Str
35281
35281
  }, valid);
35282
35282
  if (!allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
35283
35283
  }
35284
35284
  }
35285
- function unevaluatedDynamic(evaluatedProps, key2) {
35286
- return (0, codegen_1._)`!${evaluatedProps} || !${evaluatedProps}[${key2}]`;
35285
+ function unevaluatedDynamic(evaluatedProps, key3) {
35286
+ return (0, codegen_1._)`!${evaluatedProps} || !${evaluatedProps}[${key3}]`;
35287
35287
  }
35288
- function unevaluatedStatic(evaluatedProps, key2) {
35288
+ function unevaluatedStatic(evaluatedProps, key3) {
35289
35289
  const ps = [];
35290
- for (const p in evaluatedProps) if (evaluatedProps[p] === true) ps.push((0, codegen_1._)`${key2} !== ${p}`);
35290
+ for (const p in evaluatedProps) if (evaluatedProps[p] === true) ps.push((0, codegen_1._)`${key3} !== ${p}`);
35291
35291
  return (0, codegen_1.and)(...ps);
35292
35292
  }
35293
35293
  }
@@ -36812,11 +36812,11 @@ function resolveLegacyShimOptions(options) {
36812
36812
  legacyShim: options?.legacyShim ?? true
36813
36813
  };
36814
36814
  }
36815
- function coerceEmbeddedInputRequest(method, key2, entry) {
36816
- if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${key2}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);
36815
+ function coerceEmbeddedInputRequest(method, key3, entry) {
36816
+ if (entry === null || typeof entry !== "object" || typeof entry.method !== "string") throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an invalid input request '${key3}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);
36817
36817
  const embedded = entry;
36818
36818
  const required2 = requiredClientCapabilitiesForInputRequest(embedded);
36819
- if (required2 === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key2}' of kind '${embedded.method}', which is not an embedded request the 2026-07-28 revision defines`);
36819
+ if (required2 === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key3}' of kind '${embedded.method}', which is not an embedded request the 2026-07-28 revision defines`);
36820
36820
  return {
36821
36821
  embedded,
36822
36822
  required: required2
@@ -36862,11 +36862,11 @@ var LegacyInputRequiredShim = class {
36862
36862
  if (hasInputRequests) {
36863
36863
  const declared = this._host.resolvedClientCapabilities(ctx);
36864
36864
  const coerced = [];
36865
- for (const [key2, entry] of Object.entries(inputRequests)) {
36866
- const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key2, entry);
36867
- if (embedded.method !== "roots/list" && embedded.params === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key2}' of kind '${embedded.method}' without params`);
36868
- if (missingClientCapabilities(required2, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${key2}' (${embedded.method}): the client on this 2025-era connection did not declare the required capability${declared === void 0 ? " (no client capabilities are available on this connection \u2014 per-request legacy serving cannot receive server-to-client requests)" : ""}`);
36869
- coerced.push([key2, embedded]);
36865
+ for (const [key3, entry] of Object.entries(inputRequests)) {
36866
+ const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key3, entry);
36867
+ if (embedded.method !== "roots/list" && embedded.params === void 0) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input request '${key3}' of kind '${embedded.method}' without params`);
36868
+ if (missingClientCapabilities(required2, declared) !== void 0) return legacyShimFailure(method, `Cannot request input '${key3}' (${embedded.method}): the client on this 2025-era connection did not declare the required capability${declared === void 0 ? " (no client capabilities are available on this connection \u2014 per-request legacy serving cannot receive server-to-client requests)" : ""}`);
36869
+ coerced.push([key3, embedded]);
36870
36870
  }
36871
36871
  const roundAbort = linkedRoundAbort(outerSignal);
36872
36872
  try {
@@ -36878,9 +36878,9 @@ var LegacyInputRequiredShim = class {
36878
36878
  },
36879
36879
  signal: roundAbort.signal
36880
36880
  };
36881
- const fulfilled = await Promise.all(coerced.map(async ([key2, embedded]) => {
36881
+ const fulfilled = await Promise.all(coerced.map(async ([key3, embedded]) => {
36882
36882
  try {
36883
- return [key2, await this._dispatchLeg(embedded, legOptions)];
36883
+ return [key3, await this._dispatchLeg(embedded, legOptions)];
36884
36884
  } catch (error62) {
36885
36885
  roundAbort.abort(error62);
36886
36886
  throw error62;
@@ -37187,10 +37187,10 @@ var Server = class extends Protocol {
37187
37187
  if (!hasInputRequests && !hasRequestState) throw new ProtocolError(ProtocolErrorCode.InternalError, `Handler for ${method} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);
37188
37188
  if (hasInputRequests) {
37189
37189
  const declared = this._inputRequestCapabilityView(ctx);
37190
- for (const [key2, entry] of Object.entries(inputRequests)) {
37191
- const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key2, entry);
37190
+ for (const [key3, entry] of Object.entries(inputRequests)) {
37191
+ const { embedded, required: required2 } = coerceEmbeddedInputRequest(method, key3, entry);
37192
37192
  const missing = missingClientCapabilities(required2, declared);
37193
- if (missing !== void 0) throw new MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${key2}' (${embedded.method}): the request's client capabilities do not declare the required capability`);
37193
+ if (missing !== void 0) throw new MissingRequiredClientCapabilityError({ requiredCapabilities: missing }, `Cannot request input '${key3}' (${embedded.method}): the request's client capabilities do not declare the required capability`);
37194
37194
  }
37195
37195
  }
37196
37196
  return result;
@@ -37580,10 +37580,10 @@ function toolInputElementCount(value, max) {
37580
37580
  if (++count > max) return count;
37581
37581
  if (child !== null && typeof child === "object") stack.push(child);
37582
37582
  }
37583
- else for (const key2 in node2) {
37584
- if (!Object.prototype.hasOwnProperty.call(node2, key2)) continue;
37583
+ else for (const key3 in node2) {
37584
+ if (!Object.prototype.hasOwnProperty.call(node2, key3)) continue;
37585
37585
  if (++count > max) return count;
37586
- const child = node2[key2];
37586
+ const child = node2[key3];
37587
37587
  if (child !== null && typeof child === "object") stack.push(child);
37588
37588
  }
37589
37589
  }
@@ -39027,8 +39027,8 @@ var DQ_STRING_RE = /"((?:[^"\\]|\\.)*)"/g;
39027
39027
  var SQ_STRING_RE = /'((?:[^'\\]|\\.)*)'/g;
39028
39028
  function redactJsonCookie(quote) {
39029
39029
  const stringRe = quote === '"' ? DQ_STRING_RE : SQ_STRING_RE;
39030
- return (_m, prefix, key2, value) => {
39031
- const setCookie = key2.toLowerCase() === "set-cookie";
39030
+ return (_m, prefix, key3, value) => {
39031
+ const setCookie = key3.toLowerCase() === "set-cookie";
39032
39032
  const redacted = value.replace(stringRe, (_s, body) => {
39033
39033
  const out = setCookie ? body.replace(/^(\s*[^=;]+)=[^;]*/, "$1=[REDACTED]") : body.replace(/=[^;]*/g, "=[REDACTED]");
39034
39034
  return `${quote}${out}${quote}`;
@@ -39164,9 +39164,9 @@ function errorResult(message) {
39164
39164
  }
39165
39165
  function pruneUndefined(obj) {
39166
39166
  const out = {};
39167
- for (const key2 of Object.keys(obj)) {
39168
- if (obj[key2] !== void 0)
39169
- out[key2] = obj[key2];
39167
+ for (const key3 of Object.keys(obj)) {
39168
+ if (obj[key3] !== void 0)
39169
+ out[key3] = obj[key3];
39170
39170
  }
39171
39171
  return out;
39172
39172
  }
@@ -39212,8 +39212,8 @@ function canonicalJson(value) {
39212
39212
  const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
39213
39213
  return `{${entries.map(([k, v]) => `${JSON.stringify(escapeKey(k))}:${canonicalJson(v)}`).join(",")}}`;
39214
39214
  }
39215
- function escapeKey(key2) {
39216
- return key2.startsWith("$") ? `$${key2}` : key2;
39215
+ function escapeKey(key3) {
39216
+ return key3.startsWith("$") ? `$${key3}` : key3;
39217
39217
  }
39218
39218
 
39219
39219
  // node_modules/@chrischall/mcp-utils/dist/server/confirmation.js
@@ -39226,22 +39226,22 @@ function bindingKey(binding) {
39226
39226
  if (binding.ttlSeconds !== void 0 && !(Number.isFinite(binding.ttlSeconds) && binding.ttlSeconds > 0)) {
39227
39227
  throw new RangeError("requireConfirmation: binding.ttlSeconds must be a finite number greater than 0.");
39228
39228
  }
39229
- const key2 = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
39230
- if (key2.length < 32) {
39229
+ const key3 = typeof binding.key === "string" ? Buffer.from(binding.key, "utf8") : Buffer.from(binding.key);
39230
+ if (key3.length < 32) {
39231
39231
  throw new RangeError("requireConfirmation: binding.key must be at least 32 bytes.");
39232
39232
  }
39233
- return key2;
39233
+ return key3;
39234
39234
  }
39235
39235
  function commitment(action, args) {
39236
39236
  return createHash("sha256").update(`${action}\0${canonicalJson(args)}`).digest("base64url");
39237
39237
  }
39238
- function mintState(key2, action, binding) {
39238
+ function mintState(key3, action, binding) {
39239
39239
  const exp = Math.floor(Date.now() / 1e3) + (binding.ttlSeconds ?? 600);
39240
39240
  const body = Buffer.from(JSON.stringify({ c: commitment(action, binding.args), exp })).toString("base64url");
39241
- const mac3 = createHmac("sha256", key2).update(`${STATE_PREFIX}${body}`).digest("base64url");
39241
+ const mac3 = createHmac("sha256", key3).update(`${STATE_PREFIX}${body}`).digest("base64url");
39242
39242
  return `${STATE_PREFIX}${body}.${mac3}`;
39243
39243
  }
39244
- function verifyState(key2, action, binding, state) {
39244
+ function verifyState(key3, action, binding, state) {
39245
39245
  if (typeof state !== "string" || !state.startsWith(STATE_PREFIX))
39246
39246
  return false;
39247
39247
  const rest = state.slice(STATE_PREFIX.length);
@@ -39250,7 +39250,7 @@ function verifyState(key2, action, binding, state) {
39250
39250
  return false;
39251
39251
  const body = rest.slice(0, dot);
39252
39252
  const mac3 = Buffer.from(rest.slice(dot + 1), "base64url");
39253
- const expected = createHmac("sha256", key2).update(`${STATE_PREFIX}${body}`).digest();
39253
+ const expected = createHmac("sha256", key3).update(`${STATE_PREFIX}${body}`).digest();
39254
39254
  if (mac3.length !== expected.length || !timingSafeEqual(mac3, expected))
39255
39255
  return false;
39256
39256
  let payload;
@@ -39271,7 +39271,7 @@ function echoedState(ctx) {
39271
39271
  }
39272
39272
  function requireConfirmation(ctx, options) {
39273
39273
  const requestKey = options.requestKey ?? DEFAULT_REQUEST_KEY;
39274
- const key2 = options.binding ? bindingKey(options.binding) : void 0;
39274
+ const key3 = options.binding ? bindingKey(options.binding) : void 0;
39275
39275
  const confirmationSchema = external_exports.object({
39276
39276
  confirmed: external_exports.boolean().describe(options.confirmationLabel ?? DEFAULT_CONFIRMATION_LABEL)
39277
39277
  });
@@ -39288,7 +39288,7 @@ ${JSON.stringify(preview, null, 2)}`,
39288
39288
  requestedSchema: confirmationSchema
39289
39289
  })
39290
39290
  },
39291
- ...key2 && options.binding ? { requestState: mintState(key2, options.action, options.binding) } : {}
39291
+ ...key3 && options.binding ? { requestState: mintState(key3, options.action, options.binding) } : {}
39292
39292
  });
39293
39293
  };
39294
39294
  const response = inputResponse(ctx.mcpReq.inputResponses, requestKey);
@@ -39315,12 +39315,12 @@ ${JSON.stringify(preview, null, 2)}`,
39315
39315
  return ask();
39316
39316
  }
39317
39317
  if (response.kind === "elicit" && response.action === "accept" && accepted?.confirmed === true) {
39318
- if (key2 && options.binding) {
39318
+ if (key3 && options.binding) {
39319
39319
  const state = echoedState(ctx);
39320
39320
  if (state === void 0 || state === null) {
39321
39321
  return errorResult(`Confirmation for ${options.action} was accepted, but the retry carried no requestState, so it cannot be checked against the prompt that was shown. Nothing was done. The likely cause is that the MCP client or host does not round-trip requestState (it must echo the requestState from the input_required result back on the retry); asking again would loop.`);
39322
39322
  }
39323
- if (!verifyState(key2, options.action, options.binding, state))
39323
+ if (!verifyState(key3, options.action, options.binding, state))
39324
39324
  return ask();
39325
39325
  }
39326
39326
  return void 0;
@@ -39455,8 +39455,8 @@ function createSpentTokenStore() {
39455
39455
  var PROCESS_SPENT = createSpentTokenStore();
39456
39456
  var PREFIX = "mcpu.token.v1.";
39457
39457
  var DEFAULT_TTL_SECONDS = 600;
39458
- function tokenKey(key2) {
39459
- const bytes = typeof key2 === "string" ? Buffer.from(key2, "utf8") : Buffer.from(key2);
39458
+ function tokenKey(key3) {
39459
+ const bytes = typeof key3 === "string" ? Buffer.from(key3, "utf8") : Buffer.from(key3);
39460
39460
  if (bytes.length < 32)
39461
39461
  throw new RangeError("confirm token: key must be at least 32 bytes.");
39462
39462
  return bytes;
@@ -39469,14 +39469,14 @@ function ttlOf(ttlSeconds) {
39469
39469
  }
39470
39470
  return ttlSeconds;
39471
39471
  }
39472
- function sign(key2, body) {
39473
- return createHmac2("sha256", key2).update(`${PREFIX}${body}`).digest();
39472
+ function sign(key3, body) {
39473
+ return createHmac2("sha256", key3).update(`${PREFIX}${body}`).digest();
39474
39474
  }
39475
39475
  function hashConfirmPayload(payload) {
39476
39476
  return createHash2("sha256").update(canonicalJson(payload)).digest("base64url");
39477
39477
  }
39478
- function issueConfirmToken(key2, binding, options = {}) {
39479
- const k = tokenKey(key2);
39478
+ function issueConfirmToken(key3, binding, options = {}) {
39479
+ const k = tokenKey(key3);
39480
39480
  const now = options.now ?? Date.now();
39481
39481
  const exp = now + ttlOf(options.ttlSeconds) * 1e3;
39482
39482
  const claims = {
@@ -39499,8 +39499,8 @@ function parseClaims(body) {
39499
39499
  return void 0;
39500
39500
  }
39501
39501
  }
39502
- function verifyConfirmToken(key2, token, binding, options = {}) {
39503
- const k = tokenKey(key2);
39502
+ function verifyConfirmToken(key3, token, binding, options = {}) {
39503
+ const k = tokenKey(key3);
39504
39504
  const now = options.now ?? Date.now();
39505
39505
  const spent = options.spent ?? PROCESS_SPENT;
39506
39506
  spent.prune(now);
@@ -39614,9 +39614,9 @@ import { isAbsolute as isAbsolute2, join as join3 } from "node:path";
39614
39614
  import { homedir } from "node:os";
39615
39615
  import { isAbsolute, join, resolve } from "node:path";
39616
39616
  var PLACEHOLDER_RE = /^\$\{[^}]*\}$/;
39617
- function readEnvVar(key2, opts = {}) {
39617
+ function readEnvVar(key3, opts = {}) {
39618
39618
  const env = opts.env ?? process.env;
39619
- const raw = env[key2];
39619
+ const raw = env[key3];
39620
39620
  if (typeof raw === "string") {
39621
39621
  const trimmed = raw.trim();
39622
39622
  if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
@@ -39627,9 +39627,9 @@ function readEnvVar(key2, opts = {}) {
39627
39627
  }
39628
39628
  var TRUE_TOKENS = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
39629
39629
  var FALSE_TOKENS = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
39630
- function parseBoolEnv(key2, opts = {}) {
39630
+ function parseBoolEnv(key3, opts = {}) {
39631
39631
  const fallback = opts.default ?? false;
39632
- const raw = readEnvVar(key2, { env: opts.env });
39632
+ const raw = readEnvVar(key3, { env: opts.env });
39633
39633
  if (raw === void 0)
39634
39634
  return fallback;
39635
39635
  const token = raw.toLowerCase();
@@ -39768,9 +39768,9 @@ function readConfirmElicitation(env = process.env) {
39768
39768
  return "on";
39769
39769
  if (raw === "off")
39770
39770
  return "off";
39771
- const key2 = `elicitation:${raw}`;
39772
- if (!warned.has(key2)) {
39773
- warned.add(key2);
39771
+ const key3 = `elicitation:${raw}`;
39772
+ if (!warned.has(key3)) {
39773
+ warned.add(key3);
39774
39774
  process.stderr.write(`MCP_CONFIRM_ELICITATION="${raw}" is not one of on, off; treating it as on.
39775
39775
  `);
39776
39776
  }
@@ -39782,9 +39782,9 @@ function readConfirmTtl(env) {
39782
39782
  return DEFAULT_TTL_SECONDS2;
39783
39783
  if (/^[1-9]\d*$/.test(raw))
39784
39784
  return Number(raw);
39785
- const key2 = `ttl:${raw}`;
39786
- if (!warned.has(key2)) {
39787
- warned.add(key2);
39785
+ const key3 = `ttl:${raw}`;
39786
+ if (!warned.has(key3)) {
39787
+ warned.add(key3);
39788
39788
  process.stderr.write(`MCP_CONFIRM_TTL_SECONDS="${raw}" is not a positive whole number of seconds; gated writes will refuse on clients that cannot show a confirmation prompt until it is fixed.
39789
39789
  `);
39790
39790
  }
@@ -40654,8 +40654,8 @@ function headerOf(headers, name) {
40654
40654
  if (typeof headers.get === "function")
40655
40655
  return headers.get(name) ?? void 0;
40656
40656
  const wanted = name.toLowerCase();
40657
- for (const [key2, value] of Object.entries(headers)) {
40658
- if (key2.toLowerCase() === wanted)
40657
+ for (const [key3, value] of Object.entries(headers)) {
40658
+ if (key3.toLowerCase() === wanted)
40659
40659
  return value;
40660
40660
  }
40661
40661
  return void 0;
@@ -41371,8 +41371,8 @@ import { fileURLToPath } from "url";
41371
41371
 
41372
41372
  // node_modules/@fetchproxy/protocol/dist/crypto.js
41373
41373
  var subtle = globalThis.crypto.subtle;
41374
- async function exportRaw(key2, format) {
41375
- const buf = await subtle.exportKey(format, key2);
41374
+ async function exportRaw(key3, format) {
41375
+ const buf = await subtle.exportKey(format, key3);
41376
41376
  return new Uint8Array(buf);
41377
41377
  }
41378
41378
  async function generateX25519() {
@@ -41475,15 +41475,15 @@ async function hkdfSha256(ikm, salt, info, lenBytes) {
41475
41475
  }, baseKey, lenBytes * 8);
41476
41476
  return new Uint8Array(bits);
41477
41477
  }
41478
- async function aesGcmSeal(key2, iv, plaintext, aad) {
41479
- const k = await subtle.importKey("raw", key2, { name: "AES-GCM" }, false, [
41478
+ async function aesGcmSeal(key3, iv, plaintext, aad) {
41479
+ const k = await subtle.importKey("raw", key3, { name: "AES-GCM" }, false, [
41480
41480
  "encrypt"
41481
41481
  ]);
41482
41482
  const ct = await subtle.encrypt({ name: "AES-GCM", iv, additionalData: aad }, k, plaintext);
41483
41483
  return new Uint8Array(ct);
41484
41484
  }
41485
- async function aesGcmOpen(key2, iv, ciphertext, aad) {
41486
- const k = await subtle.importKey("raw", key2, { name: "AES-GCM" }, false, [
41485
+ async function aesGcmOpen(key3, iv, ciphertext, aad) {
41486
+ const k = await subtle.importKey("raw", key3, { name: "AES-GCM" }, false, [
41487
41487
  "decrypt"
41488
41488
  ]);
41489
41489
  const pt = await subtle.decrypt({ name: "AES-GCM", iv, additionalData: aad }, k, ciphertext);
@@ -41987,11 +41987,11 @@ function assertCaptureHeadersArray(value, label) {
41987
41987
  throw new ProtocolError3(`${label}[${i}].headerName: invalid name ${JSON.stringify(entry.headerName)}`);
41988
41988
  }
41989
41989
  const normalizedPath = entry.path ?? "/*";
41990
- const key2 = `${entry.host}\0${normalizedPath}\0${entry.headerName}`;
41991
- if (seen.has(key2)) {
41990
+ const key3 = `${entry.host}\0${normalizedPath}\0${entry.headerName}`;
41991
+ if (seen.has(key3)) {
41992
41992
  throw new ProtocolError3(`${label}: duplicate ${JSON.stringify({ host: entry.host, path: normalizedPath, headerName: entry.headerName })}`);
41993
41993
  }
41994
- seen.add(key2);
41994
+ seen.add(key3);
41995
41995
  for (const k of Object.keys(entry)) {
41996
41996
  if (k !== "host" && k !== "path" && k !== "headerName") {
41997
41997
  throw new ProtocolError3(`${label}[${i}]: unexpected field ${JSON.stringify(k)}`);
@@ -44410,10 +44410,10 @@ async function startHost(opts) {
44410
44410
  const extPub = fromB64(frame.extensionSessionPub);
44411
44411
  const shared = await ecdhX25519(held.priv, extPub);
44412
44412
  const salt = await transcriptHash(held.nonce, extNonce, held.pub, extPub);
44413
- const key2 = await hkdfSha256(shared, salt, enc5.encode(HKDF_SESSION_INFO), 32);
44413
+ const key3 = await hkdfSha256(shared, salt, enc5.encode(HKDF_SESSION_INFO), 32);
44414
44414
  if (extensionWs !== ws)
44415
44415
  return;
44416
- ownSession = new SessionState(key2);
44416
+ ownSession = new SessionState(key3);
44417
44417
  ownSessionInfo = sessionInfoFromHello(verifiedHello);
44418
44418
  ownDecryptFailures = 0;
44419
44419
  ownPendingPairCode = null;
@@ -46978,8 +46978,8 @@ var FetchproxyServer = class {
46978
46978
  return { ...opts, expectStatus: [...DEFAULT_JSON_OK_STATUSES] };
46979
46979
  }
46980
46980
  hasContentType(headers) {
46981
- for (const key2 of Object.keys(headers)) {
46982
- if (key2.toLowerCase() === "content-type")
46981
+ for (const key3 of Object.keys(headers)) {
46982
+ if (key3.toLowerCase() === "content-type")
46983
46983
  return true;
46984
46984
  }
46985
46985
  return false;
@@ -47852,7 +47852,7 @@ function describeTokenlessLogin(record2) {
47852
47852
 
47853
47853
  // src/version.ts
47854
47854
  var SERVER_NAME = "ofw-mcp";
47855
- var VERSION = "2.27.3";
47855
+ var VERSION = "2.27.5";
47856
47856
 
47857
47857
  // src/auth.ts
47858
47858
  function fetchproxyDisabled() {
@@ -48356,7 +48356,7 @@ function isRealCalendarDate(p) {
48356
48356
  const utc = new Date(Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second));
48357
48357
  return utc.getUTCFullYear() === p.year && utc.getUTCMonth() === p.month - 1 && utc.getUTCDate() === p.day && utc.getUTCHours() === p.hour && utc.getUTCMinutes() === p.minute && utc.getUTCSeconds() === p.second;
48358
48358
  }
48359
- function parseTimestampValue(key2, value, assumeNaiveIn) {
48359
+ function parseTimestampValue(key3, value, assumeNaiveIn) {
48360
48360
  if (typeof value !== "string") return null;
48361
48361
  const raw = value.trim();
48362
48362
  if (raw === "" || DATE_ONLY.test(raw)) return null;
@@ -48425,18 +48425,18 @@ function walk(node2, tz) {
48425
48425
  }
48426
48426
  if (node2 === null || typeof node2 !== "object") return node2;
48427
48427
  const obj = node2;
48428
- for (const key2 of Object.keys(obj)) {
48429
- const value = obj[key2];
48428
+ for (const key3 of Object.keys(obj)) {
48429
+ const value = obj[key3];
48430
48430
  if (value !== null && typeof value === "object") {
48431
48431
  walk(value, tz);
48432
48432
  continue;
48433
48433
  }
48434
- if (ZONE_NAME_KEYS.has(key2) || !TIMESTAMP_KEYS.has(key2)) continue;
48435
- const instant = parseTimestampValue(key2, value, tz);
48434
+ if (ZONE_NAME_KEYS.has(key3) || !TIMESTAMP_KEYS.has(key3)) continue;
48435
+ const instant = parseTimestampValue(key3, value, tz);
48436
48436
  if (!instant) continue;
48437
48437
  const { iso, display } = formatInstant(instant, tz);
48438
- obj[key2] = iso;
48439
- obj[`${key2}Display`] = display;
48438
+ obj[key3] = iso;
48439
+ obj[`${key3}Display`] = display;
48440
48440
  }
48441
48441
  return obj;
48442
48442
  }
@@ -48490,6 +48490,16 @@ function hasRealView(recipients) {
48490
48490
  function threadedReplyTo(detail) {
48491
48491
  return detail.replyToId ?? detail.inReplyTo ?? null;
48492
48492
  }
48493
+ function draftReplyTarget(echoes, fallback) {
48494
+ for (const echo of echoes) {
48495
+ const target = threadedReplyTo(echo);
48496
+ if (target !== null) return { replyToId: target, replyToSource: "server" };
48497
+ }
48498
+ if (fallback !== null && !echoes.some(reportsUnthreaded)) {
48499
+ return { replyToId: fallback, replyToSource: "cache" };
48500
+ }
48501
+ return { replyToId: null, replyToSource: null };
48502
+ }
48493
48503
  function reportsThreaded(detail) {
48494
48504
  return threadedReplyTo(detail) !== null || detail.showContext === true;
48495
48505
  }
@@ -48497,17 +48507,18 @@ function reportsUnthreaded(detail) {
48497
48507
  if (reportsThreaded(detail)) return false;
48498
48508
  return detail.inReplyTo !== void 0 || detail.showContext !== void 0;
48499
48509
  }
48500
- function scrapeSaysRead(listData) {
48510
+ function scrapeSaysRead(folder, listData) {
48501
48511
  if (typeof listData !== "object" || listData === null) return false;
48502
48512
  const ld = listData;
48513
+ if (folder === "inbox") return ld.read === true;
48503
48514
  return ld.read === true || ld.showNeverViewed === false;
48504
48515
  }
48505
48516
  function deriveRead(row) {
48506
48517
  const viewedByAnyone = row.recipients.some((r) => r.viewedAt !== null);
48507
48518
  if (row.folder === "inbox") {
48508
- return viewedByAnyone || row.fetchedBodyAt !== null || scrapeSaysRead(row.listData);
48519
+ return viewedByAnyone || row.fetchedBodyAt !== null || scrapeSaysRead("inbox", row.listData);
48509
48520
  }
48510
- return viewedByAnyone || scrapeSaysRead(row.listData);
48521
+ return viewedByAnyone || scrapeSaysRead(row.folder, row.listData);
48511
48522
  }
48512
48523
  function withReadState(row) {
48513
48524
  const read = deriveRead(row);
@@ -48713,6 +48724,142 @@ async function heldFilesFor(cache, draftIds) {
48713
48724
  }
48714
48725
  var HELD_NOTE = "OurFamilyWizard drafts do not store attachments, so these files are held with this draft by this server and attached when you send it with ofw_send_message (draftId). They are not visible on the draft in the OurFamilyWizard web app.";
48715
48726
 
48727
+ // src/tools/reply-source.ts
48728
+ var key2 = (draftId) => `draft_reply_source:${draftId}`;
48729
+ async function setReplyToSource(cache, draftId, source) {
48730
+ await cache.setMeta(key2(draftId), source ?? "");
48731
+ }
48732
+ async function getReplyToSource(cache, draftId, replyToId) {
48733
+ if (replyToId === null) return null;
48734
+ return await cache.getMeta(key2(draftId)) === "cache" ? "cache" : "server";
48735
+ }
48736
+ async function replyToSourceField(cache, draftId, replyToId) {
48737
+ const source = await getReplyToSource(cache, draftId, replyToId);
48738
+ return source === null ? {} : { replyToSource: source };
48739
+ }
48740
+
48741
+ // src/tools/project.ts
48742
+ import { createHash as createHash5 } from "node:crypto";
48743
+ var MESSAGE_VIEWS = ["compact", "full"];
48744
+ var LABEL = "ofw-mcp";
48745
+ function asRecord(value) {
48746
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
48747
+ }
48748
+ function senderOf(row) {
48749
+ if (typeof row.fromUser === "string" && row.fromUser !== "") return row.fromUser;
48750
+ const author = asRecord(asRecord(row.listData)?.author);
48751
+ const name = author?.name;
48752
+ return typeof name === "string" && name !== "" ? name : null;
48753
+ }
48754
+ function fileCountOf(row) {
48755
+ const files = asRecord(row.listData)?.files;
48756
+ if (typeof files === "number") return files;
48757
+ if (Array.isArray(files)) return files.length;
48758
+ return void 0;
48759
+ }
48760
+ function repliedOf(row) {
48761
+ const replied = asRecord(row.listData)?.replied;
48762
+ return typeof replied === "boolean" ? replied : void 0;
48763
+ }
48764
+ function compactMessage(row) {
48765
+ const { listData: _drop, fromUser: _dropFrom, ...rest } = row;
48766
+ return pruneUndefined({
48767
+ id: rest.id,
48768
+ folder: rest.folder,
48769
+ subject: rest.subject,
48770
+ from: senderOf(row),
48771
+ sentAt: rest.sentAt,
48772
+ recipients: rest.recipients,
48773
+ read: rest.read,
48774
+ replied: repliedOf(row),
48775
+ files: fileCountOf(row),
48776
+ replyToId: rest.replyToId,
48777
+ chainRootId: rest.chainRootId,
48778
+ body: rest.body,
48779
+ fetchedBodyAt: rest.fetchedBodyAt,
48780
+ // Anything a TOOL added on top of the cache row — `attachments`,
48781
+ // `revision`, `cacheStatus`, `serverConfirmed`, `freshness` — is kept
48782
+ // wholesale. Those are this server's own answers, never OFW's echo, and a
48783
+ // projection that dropped one would be removing the thing the caller
48784
+ // asked for rather than the thing they got twice.
48785
+ ...omitKnown(rest, MESSAGE_ROW_KEYS)
48786
+ });
48787
+ }
48788
+ var MESSAGE_ROW_KEYS = /* @__PURE__ */ new Set([
48789
+ "id",
48790
+ "folder",
48791
+ "subject",
48792
+ "sentAt",
48793
+ "recipients",
48794
+ "read",
48795
+ "replyToId",
48796
+ "chainRootId",
48797
+ "body",
48798
+ "fetchedBodyAt"
48799
+ ]);
48800
+ var DRAFT_ROW_KEYS = /* @__PURE__ */ new Set(["id", "subject", "recipients", "replyToId", "modifiedAt", "body"]);
48801
+ function omitKnown(rest, own2) {
48802
+ const out = {};
48803
+ for (const [key3, value] of Object.entries(rest)) if (!own2.has(key3)) out[key3] = value;
48804
+ return out;
48805
+ }
48806
+ function compactDraft(row) {
48807
+ const { listData: _drop, ...rest } = row;
48808
+ return pruneUndefined({
48809
+ id: rest.id,
48810
+ subject: rest.subject,
48811
+ recipients: rest.recipients,
48812
+ replyToId: rest.replyToId,
48813
+ modifiedAt: rest.modifiedAt,
48814
+ body: rest.body,
48815
+ ...omitKnown(rest, DRAFT_ROW_KEYS)
48816
+ });
48817
+ }
48818
+ function bodyDigest(body) {
48819
+ if (body === null) return { bodyLength: null, bodySha256: null };
48820
+ return { bodyLength: body.length, bodySha256: createHash5("sha256").update(body).digest("hex").slice(0, 16) };
48821
+ }
48822
+ function compactWrittenDraft(row) {
48823
+ return {
48824
+ id: row.id,
48825
+ subject: row.subject,
48826
+ ...bodyDigest(row.body),
48827
+ recipients: row.recipients,
48828
+ replyToId: row.replyToId,
48829
+ modifiedAt: row.modifiedAt
48830
+ };
48831
+ }
48832
+ function compactSentMessage(row) {
48833
+ return {
48834
+ id: row.id,
48835
+ folder: row.folder,
48836
+ subject: row.subject,
48837
+ ...bodyDigest(row.body),
48838
+ sentAt: row.sentAt,
48839
+ recipients: row.recipients,
48840
+ replyToId: row.replyToId,
48841
+ chainRootId: row.chainRootId
48842
+ };
48843
+ }
48844
+ function viewMessages(view, rows) {
48845
+ if (view !== "compact") return rows;
48846
+ return projectOrRaw(rows, (rs) => rs.map((r) => compactMessage(r)), {
48847
+ label: LABEL,
48848
+ context: "the cached message rows"
48849
+ });
48850
+ }
48851
+ function viewDrafts(view, rows) {
48852
+ if (view !== "compact") return rows;
48853
+ return projectOrRaw(rows, (rs) => rs.map((r) => compactDraft(r)), {
48854
+ label: LABEL,
48855
+ context: "the cached draft rows"
48856
+ });
48857
+ }
48858
+ function viewOne(view, row) {
48859
+ if (view !== "compact") return row;
48860
+ return projectOrRaw(row, (r) => compactMessage(r), { label: LABEL, context: "a cached message row" });
48861
+ }
48862
+
48716
48863
  // src/read-days.ts
48717
48864
  var WEEKDAYS = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"];
48718
48865
  var WEEKDAY_LABELS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
@@ -48877,6 +49024,7 @@ var ListItemSchema = external_exports.looseObject({
48877
49024
  date: external_exports.looseObject({ dateTime: external_exports.string() }),
48878
49025
  from: external_exports.looseObject({ name: external_exports.string().optional() }).optional(),
48879
49026
  showNeverViewed: external_exports.boolean(),
49027
+ read: external_exports.boolean().optional(),
48880
49028
  recipients: external_exports.array(ApiRecipientSchema).optional()
48881
49029
  });
48882
49030
  var ListResponseSchema = external_exports.looseObject({ data: external_exports.array(ListItemSchema).optional() });
@@ -48887,6 +49035,16 @@ var DetailResponseSchema = external_exports.looseObject({
48887
49035
  // endpoint only has an epoch placeholder) — used by the view-status refresh.
48888
49036
  recipients: external_exports.array(ApiRecipientSchema).optional()
48889
49037
  });
49038
+ var STAMP_TOLERANCE_MS = 2e3;
49039
+ function stampedByFetch(viewedAt, startedAtMs) {
49040
+ if (viewedAt === null) return false;
49041
+ const at = parseTimestampValue("viewedAt", viewedAt, displayTimeZone());
49042
+ return at !== null && at.getTime() >= startedAtMs - STAMP_TOLERANCE_MS;
49043
+ }
49044
+ function latestViewedAt(recipients) {
49045
+ const times = mapRecipients(recipients).map((r) => r.viewedAt).filter((t) => t !== null);
49046
+ return times.length === 0 ? null : times.sort().at(-1);
49047
+ }
48890
49048
  var maxId = (a, b) => a === null ? b : b === null ? a : Math.max(a, b);
48891
49049
  async function walkPages(client2, folder, folderId, opts, store) {
48892
49050
  const budget = opts.budget;
@@ -48895,9 +49053,34 @@ async function walkPages(client2, folder, folderId, opts, store) {
48895
49053
  let synced = 0;
48896
49054
  let pagesFetched = 0;
48897
49055
  const unread = [];
49056
+ const newMessages = [];
49057
+ const markedRead = [];
49058
+ const totals = () => ({ synced, unread, newMessages, markedRead, newestId, pagesFetched });
49059
+ const fetchDetail = async (item, row, context, deliberate) => {
49060
+ const startedAt = Date.now();
49061
+ const detail = parseLenient(
49062
+ DetailResponseSchema,
49063
+ await client2.request("GET", `/pub/v3/messages/${item.id}`),
49064
+ { label: "ofw-mcp", context }
49065
+ );
49066
+ if (folder === "inbox") {
49067
+ const viewedAt = latestViewedAt(detail.recipients);
49068
+ if (deliberate || stampedByFetch(viewedAt, startedAt)) {
49069
+ markedRead.push({
49070
+ id: item.id,
49071
+ subject: row.subject,
49072
+ from: row.from,
49073
+ sentAt: row.sentAt,
49074
+ viewedAt,
49075
+ reason: deliberate ? "fetchUnreadBodies" : "unexpected"
49076
+ });
49077
+ }
49078
+ }
49079
+ return detail;
49080
+ };
48898
49081
  while (true) {
48899
49082
  if (!budget.take()) {
48900
- return { synced, unread, newestId, pagesFetched, done: false, nextPage: page };
49083
+ return { ...totals(), done: false, nextPage: page };
48901
49084
  }
48902
49085
  const path = `/pub/v3/messages?folders=${encodeURIComponent(folderId)}&page=${page}&size=50&sort=date&sortDirection=desc`;
48903
49086
  const list = parseLenient(
@@ -48908,7 +49091,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
48908
49091
  pagesFetched++;
48909
49092
  const items = list.data ?? [];
48910
49093
  if (items.length === 0) {
48911
- return { synced, unread, newestId, pagesFetched, done: true, nextPage: null };
49094
+ return { ...totals(), done: true, nextPage: null };
48912
49095
  }
48913
49096
  const existingById = new Map(
48914
49097
  (await store.getMessages(items.map((it) => it.id))).map((row) => [row.id, row])
@@ -48919,17 +49102,19 @@ async function walkPages(client2, folder, folderId, opts, store) {
48919
49102
  for (const item of items) {
48920
49103
  if (newestId === null || item.id > newestId) newestId = item.id;
48921
49104
  const existing = existingById.get(item.id);
48922
- const isInboxUnread = folder === "inbox" && item.showNeverViewed === true;
49105
+ const listRead = scrapeSaysRead(folder, item);
49106
+ const isInboxUnread = folder === "inbox" && !listRead;
48923
49107
  if (existing) {
48924
49108
  if (opts.fetchBodies && existing.body === null && !isInboxUnread) {
48925
49109
  if (!budget.take()) {
48926
49110
  pageBudgetHit = true;
48927
49111
  break;
48928
49112
  }
48929
- const detail = parseLenient(
48930
- DetailResponseSchema,
48931
- await client2.request("GET", `/pub/v3/messages/${item.id}`),
48932
- { label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (body backfill)" }
49113
+ const detail = await fetchDetail(
49114
+ item,
49115
+ { subject: existing.subject, sentAt: existing.sentAt, from: senderOf(existing) },
49116
+ "GET /pub/v3/messages/{id} (body backfill)",
49117
+ false
48933
49118
  );
48934
49119
  toUpsert.push({
48935
49120
  ...existing,
@@ -48966,43 +49151,54 @@ async function walkPages(client2, folder, folderId, opts, store) {
48966
49151
  let fetchedBodyAt = null;
48967
49152
  let detailFileIds = [];
48968
49153
  let detailRecipients;
49154
+ const row = {
49155
+ id: item.id,
49156
+ folder,
49157
+ subject: item.subject ?? "(no subject)",
49158
+ fromUser: item.from?.name ?? "",
49159
+ sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
49160
+ recipients: mapRecipients(item.recipients),
49161
+ body: null,
49162
+ fetchedBodyAt: null,
49163
+ replyToId: null,
49164
+ chainRootId: null,
49165
+ listData: item
49166
+ };
49167
+ const from = senderOf(row);
48969
49168
  if (shouldFetchBody) {
48970
49169
  if (!budget.take()) {
48971
49170
  pageBudgetHit = true;
48972
49171
  break;
48973
49172
  }
48974
- const detail = parseLenient(
48975
- DetailResponseSchema,
48976
- await client2.request("GET", `/pub/v3/messages/${item.id}`),
48977
- { label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (sync)" }
48978
- );
49173
+ const detail = await fetchDetail(item, { subject: row.subject, sentAt: row.sentAt, from }, "GET /pub/v3/messages/{id} (sync)", isInboxUnread);
48979
49174
  body = detail.body ?? "";
48980
49175
  fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
48981
49176
  detailRecipients = detail.recipients;
48982
49177
  if (Array.isArray(detail.files) && detail.files.length > 0) {
48983
49178
  detailFileIds = detail.files;
48984
49179
  }
48985
- } else if (isInboxUnread) {
49180
+ }
49181
+ if (isInboxUnread) {
48986
49182
  unread.push({
48987
49183
  id: item.id,
48988
49184
  subject: item.subject,
48989
- from: item.from?.name ?? "",
48990
- sentAt: item.date.dateTime
49185
+ from: from ?? "",
49186
+ sentAt: item.date.dateTime,
49187
+ bodyFetched: shouldFetchBody
48991
49188
  });
48992
49189
  }
48993
- const row = {
49190
+ newMessages.push({
48994
49191
  id: item.id,
48995
49192
  folder,
48996
- subject: item.subject ?? "(no subject)",
48997
- fromUser: item.from?.name ?? "",
48998
- sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
48999
- recipients: mapRecipients(detailRecipients ?? item.recipients),
49000
- body,
49001
- fetchedBodyAt,
49002
- replyToId: null,
49003
- chainRootId: null,
49004
- listData: item
49005
- };
49193
+ from,
49194
+ subject: row.subject,
49195
+ sentAt: row.sentAt,
49196
+ read: listRead,
49197
+ bodyFetched: shouldFetchBody
49198
+ });
49199
+ row.body = body;
49200
+ row.fetchedBodyAt = fetchedBodyAt;
49201
+ if (detailRecipients) row.recipients = mapRecipients(detailRecipients);
49006
49202
  toUpsert.push(row);
49007
49203
  synced++;
49008
49204
  if (detailFileIds.length > 0) {
@@ -49011,10 +49207,10 @@ async function walkPages(client2, folder, folderId, opts, store) {
49011
49207
  }
49012
49208
  if (toUpsert.length > 0) await store.upsertMessages(toUpsert);
49013
49209
  if (pageBudgetHit) {
49014
- return { synced, unread, newestId, pagesFetched, done: false, nextPage: page };
49210
+ return { ...totals(), done: false, nextPage: page };
49015
49211
  }
49016
49212
  if (opts.stopAtCachedPage && !pageHadNewItem) {
49017
- return { synced, unread, newestId, pagesFetched, done: true, nextPage: page };
49213
+ return { ...totals(), done: true, nextPage: page };
49018
49214
  }
49019
49215
  page++;
49020
49216
  }
@@ -49033,6 +49229,8 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
49033
49229
  }, store);
49034
49230
  let synced = fwd.synced;
49035
49231
  const unread = [...fwd.unread];
49232
+ const newMessages = [...fwd.newMessages];
49233
+ const markedRead = [...fwd.markedRead];
49036
49234
  let newestId = maxId(saved?.newestId ?? null, fwd.newestId);
49037
49235
  let done;
49038
49236
  let resumePage;
@@ -49059,6 +49257,8 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
49059
49257
  }, store);
49060
49258
  synced += bf.synced;
49061
49259
  unread.push(...bf.unread);
49260
+ newMessages.push(...bf.newMessages);
49261
+ markedRead.push(...bf.markedRead);
49062
49262
  newestId = maxId(newestId, bf.newestId);
49063
49263
  done = bf.done;
49064
49264
  resumePage = bf.done ? null : bf.nextPage;
@@ -49066,7 +49266,7 @@ async function syncMessageFolder(client2, folder, folderId, opts, store) {
49066
49266
  const now = (/* @__PURE__ */ new Date()).toISOString();
49067
49267
  await store.setSyncState(folder, { lastSyncAt: now, newestId, resumePage });
49068
49268
  if (fwd.done) await markFolderVerified(store, folder, now);
49069
- return { synced, unread, done, verified: fwd.done };
49269
+ return { synced, unread, newMessages, markedRead, done, verified: fwd.done };
49070
49270
  }
49071
49271
  var DraftListItemSchema = external_exports.looseObject({
49072
49272
  id: external_exports.number(),
@@ -49083,7 +49283,15 @@ var DraftListItemSchema = external_exports.looseObject({
49083
49283
  var DraftListResponseSchema = external_exports.looseObject({ data: external_exports.array(DraftListItemSchema).optional() });
49084
49284
  var DraftDetailSchema = external_exports.looseObject({
49085
49285
  body: external_exports.string().optional(),
49086
- subject: external_exports.string().optional()
49286
+ subject: external_exports.string().optional(),
49287
+ // The reply linkage and recipients are read from the DETAIL, not the list
49288
+ // item: the drafts list carries no replyToId/inReplyTo/showContext key at all
49289
+ // (verified live 2026-11-08), so a row built from it hashed to a different
49290
+ // revision than the save echo and lost the reply target.
49291
+ replyToId: external_exports.number().nullable().optional(),
49292
+ inReplyTo: external_exports.number().nullable().optional(),
49293
+ showContext: external_exports.boolean().optional(),
49294
+ recipients: external_exports.array(ApiRecipientSchema).optional()
49087
49295
  });
49088
49296
  var DRAFTS_CACHE_STATUS_KEY = "drafts_cache_status";
49089
49297
  async function getDraftsCacheStatus(store) {
@@ -49105,15 +49313,15 @@ async function inferReplacedDraftLineage(store, vanishedIds, newRows) {
49105
49313
  if (vanishedIds.length === 0 || newRows.length === 0) return;
49106
49314
  for (const goneId of vanishedIds) {
49107
49315
  const gone = await store.getDraft(goneId);
49108
- const key2 = (await store.getDraftLineageById(goneId))?.draftKey;
49316
+ const key3 = (await store.getDraftLineageById(goneId))?.draftKey;
49109
49317
  const held = await getHeldFiles(store, goneId);
49110
- if (!key2 && held.length === 0) continue;
49318
+ if (!key3 && held.length === 0) continue;
49111
49319
  const matches = newRows.filter((r) => r.subject === gone.subject && r.body === gone.body && r.replyToId === gone.replyToId);
49112
49320
  if (matches.length !== 1) continue;
49113
49321
  const target = matches[0];
49114
49322
  if (await store.getDraftLineageById(target.id)) continue;
49115
- if (key2) {
49116
- await store.recordDraftLineage({ id: target.id, draftKey: key2, previousId: goneId, recordedAt: (/* @__PURE__ */ new Date()).toISOString() });
49323
+ if (key3) {
49324
+ await store.recordDraftLineage({ id: target.id, draftKey: key3, previousId: goneId, recordedAt: (/* @__PURE__ */ new Date()).toISOString() });
49117
49325
  await store.setMeta(`draft_key_inferred:${target.id}`, "1");
49118
49326
  }
49119
49327
  if (held.length > 0) {
@@ -49148,7 +49356,10 @@ async function syncDrafts(client2, draftsFolderId, store, budget) {
49148
49356
  if (pageItems.length < 50) break;
49149
49357
  page++;
49150
49358
  }
49359
+ const ids = items.map((it) => it.id);
49360
+ const existingById = new Map((await store.getDrafts(ids)).map((d) => [d.id, d]));
49151
49361
  const rows = [];
49362
+ const replySources = [];
49152
49363
  for (const item of items) {
49153
49364
  if (!b.take()) return defer();
49154
49365
  const detail = parseLenient(
@@ -49156,19 +49367,20 @@ async function syncDrafts(client2, draftsFolderId, store, budget) {
49156
49367
  await client2.request("GET", `/pub/v3/messages/${item.id}`),
49157
49368
  { label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (drafts sync)" }
49158
49369
  );
49370
+ const reply = draftReplyTarget([detail, item], existingById.get(item.id)?.replyToId ?? null);
49159
49371
  rows.push({
49160
49372
  id: item.id,
49161
49373
  subject: detail.subject ?? item.subject ?? "(no subject)",
49162
49374
  body: detail.body ?? "",
49163
- recipients: mapRecipients(item.recipients),
49164
- replyToId: threadedReplyTo(item),
49375
+ recipients: mapRecipients(detail.recipients ?? item.recipients),
49376
+ replyToId: reply.replyToId,
49165
49377
  modifiedAt: item.date?.dateTime ?? nowNaiveWallClock(),
49166
49378
  listData: item
49167
49379
  });
49380
+ replySources.push(reply.replyToSource);
49168
49381
  }
49169
- const ids = items.map((it) => it.id);
49170
- const existingById = new Map((await store.getDrafts(ids)).map((d) => [d.id, d]));
49171
49382
  await store.upsertDrafts(rows);
49383
+ for (const [i, row] of rows.entries()) await setReplyToSource(store, row.id, replySources[i]);
49172
49384
  for (const stale of await store.getMessages(ids)) {
49173
49385
  await store.deleteMessage(stale.id);
49174
49386
  }
@@ -49189,9 +49401,40 @@ async function syncDrafts(client2, draftsFolderId, store, budget) {
49189
49401
  await markFolderVerified(store, "drafts", now);
49190
49402
  return { synced, done: true };
49191
49403
  }
49404
+ var NEW_MESSAGES_CAP = 50;
49405
+ function newestFirst(a, b) {
49406
+ if (a.sentAt !== b.sentAt) return a.sentAt < b.sentAt ? 1 : -1;
49407
+ return b.id - a.id;
49408
+ }
49192
49409
  function unreadInboxNote(count) {
49193
49410
  return `${count} unread inbox messages cached without bodies. Call ofw_get_message(id) to read them \u2014 this will mark them as read on OFW.`;
49194
49411
  }
49412
+ var MARKED_READ_LEAD = "MARKED READ on OurFamilyWizard by this sync:";
49413
+ function markedReadNote(markedRead) {
49414
+ const unexpected = markedRead.filter((m) => m.reason === "unexpected").length;
49415
+ return `${MARKED_READ_LEAD} ${markedRead.length} inbox message${markedRead.length === 1 ? "" : "s"} (ids ${markedRead.map((m) => m.id).join(", ")}). Each now carries a "First Viewed" time your co-parent can see; it cannot be undone.${unexpected > 0 ? ` ${unexpected} of them ${unexpected === 1 ? "was" : "were"} NOT requested (reason "unexpected").` : ""}`;
49416
+ }
49417
+ function markedReadWarning(markedRead) {
49418
+ const unexpected = markedRead.filter((m) => m.reason === "unexpected").length;
49419
+ return `WARNING: this sync marked ${markedRead.length} inbox message${markedRead.length === 1 ? "" : "s"} READ on OurFamilyWizard (see markedRead). Your co-parent can see the "First Viewed" time, and it cannot be undone.${unexpected > 0 ? ` ${unexpected} of them ${unexpected === 1 ? "was" : "were"} NOT requested: the list reported ${unexpected === 1 ? "it" : "them"} as already read, but the fetch stamped ${unexpected === 1 ? "it" : "them"}. Tell the user, and report this as a bug.` : ""}`;
49420
+ }
49421
+ function refreshReadReporting(result) {
49422
+ const markedRead = result.markedRead ?? [];
49423
+ const notes = (result.note === void 0 ? [] : result.note.split("\n\n")).filter((n) => !n.startsWith(MARKED_READ_LEAD) && !/^\d+ unread inbox messages cached without bodies\./.test(n));
49424
+ const bodiless = result.unreadInbox.filter((h) => !h.bodyFetched).length;
49425
+ if (bodiless > 0) notes.push(unreadInboxNote(bodiless));
49426
+ if (markedRead.length > 0) notes.unshift(markedReadNote(markedRead));
49427
+ result.note = notes.length > 0 ? notes.join("\n\n") : void 0;
49428
+ if (result.note === void 0) delete result.note;
49429
+ result.markedReadCount = markedRead.length;
49430
+ if (markedRead.length > 0) {
49431
+ result.warning = markedReadWarning(markedRead);
49432
+ result.markedRead = markedRead;
49433
+ } else {
49434
+ delete result.warning;
49435
+ delete result.markedRead;
49436
+ }
49437
+ }
49195
49438
  async function syncAll(client2, opts, store) {
49196
49439
  const requested = opts.folders ?? ["inbox", "sent", "drafts"];
49197
49440
  const folders = [
@@ -49204,6 +49447,8 @@ async function syncAll(client2, opts, store) {
49204
49447
  const ids = await resolveFolderIds(client2, store);
49205
49448
  const synced = {};
49206
49449
  let unreadInbox = [];
49450
+ const newMessages = [];
49451
+ const markedRead = [];
49207
49452
  let done = true;
49208
49453
  let draftsUnverified = false;
49209
49454
  const refreshed = [];
@@ -49226,6 +49471,8 @@ async function syncAll(client2, opts, store) {
49226
49471
  }, store);
49227
49472
  record2("inbox", r.verified, r.synced);
49228
49473
  unreadInbox = r.unread;
49474
+ newMessages.push(...r.newMessages);
49475
+ markedRead.push(...r.markedRead);
49229
49476
  if (!r.done) done = false;
49230
49477
  } else if (folder === "sent") {
49231
49478
  const r = await syncMessageFolder(client2, "sent", ids.sent, {
@@ -49235,6 +49482,7 @@ async function syncAll(client2, opts, store) {
49235
49482
  budget
49236
49483
  }, store);
49237
49484
  record2("sent", r.verified, r.synced);
49485
+ newMessages.push(...r.newMessages);
49238
49486
  if (!r.done) done = false;
49239
49487
  } else if (folder === "drafts") {
49240
49488
  const r = await syncDrafts(client2, ids.drafts, store, budget);
@@ -49252,9 +49500,6 @@ async function syncAll(client2, opts, store) {
49252
49500
  if (draftsUnverified) {
49253
49501
  notes.push('The drafts folder was NOT checked against OurFamilyWizard on this call (the request budget ran out first), so no drafts count is reported and the cached drafts are marked "unverified". Cached draft bodies may be behind the server. Call ofw_sync_messages again \u2014 or ofw_sync_messages with folders:["drafts"] \u2014 before editing or deleting a draft.');
49254
49502
  }
49255
- if (unreadInbox.length > 0) {
49256
- notes.push(unreadInboxNote(unreadInbox.length));
49257
- }
49258
49503
  if (notRefreshed.length > 0) {
49259
49504
  notes.push(`NOT checked against OurFamilyWizard on this call: ${notRefreshed.join(", ")}. No count is reported for ${notRefreshed.length > 1 ? "those folders" : "that folder"} \u2014 absence of a count means "not looked at", not "no changes". Cached contents may be behind the server; call ofw_sync_messages again to finish, or ofw_check_freshness for a cheap live confirmation.`);
49260
49505
  }
@@ -49262,20 +49507,29 @@ async function syncAll(client2, opts, store) {
49262
49507
  notes.push("Paused after the request budget to stay within the hosting limit; more pages remain \u2014 call ofw_sync_messages again with the same arguments to resume where it left off and continue the backfill.");
49263
49508
  }
49264
49509
  const note = notes.length > 0 ? notes.join("\n\n") : void 0;
49265
- return {
49510
+ newMessages.sort(newestFirst);
49511
+ const result = {
49512
+ warning: void 0,
49266
49513
  synced,
49514
+ markedReadCount: 0,
49515
+ newMessagesTotal: newMessages.length,
49516
+ newMessagesTruncated: newMessages.length > NEW_MESSAGES_CAP,
49267
49517
  unreadInbox,
49268
49518
  done,
49269
49519
  syncComplete: done,
49270
49520
  refreshed,
49271
49521
  notRefreshed,
49272
49522
  ...readingBlocked ? { bodiesWithheld: true } : {},
49273
- ...note ? { note } : {}
49523
+ note,
49524
+ markedRead,
49525
+ newMessages: newMessages.slice(0, NEW_MESSAGES_CAP)
49274
49526
  };
49527
+ refreshReadReporting(result);
49528
+ return result;
49275
49529
  }
49276
49530
 
49277
49531
  // src/config.ts
49278
- import { createHash as createHash5 } from "node:crypto";
49532
+ import { createHash as createHash6 } from "node:crypto";
49279
49533
  import { homedir as homedir4 } from "node:os";
49280
49534
  import { join as join10 } from "node:path";
49281
49535
  function readCacheIdentity() {
@@ -49286,7 +49540,7 @@ function getCacheDir() {
49286
49540
  }
49287
49541
  function getCacheDbPath() {
49288
49542
  const identity = readCacheIdentity();
49289
- const hash2 = createHash5("sha256").update(identity).digest("hex").slice(0, 16);
49543
+ const hash2 = createHash6("sha256").update(identity).digest("hex").slice(0, 16);
49290
49544
  return join10(getCacheDir(), `${hash2}.db`);
49291
49545
  }
49292
49546
  function getAttachmentsDir() {
@@ -49522,6 +49776,7 @@ var ServerDraftSchema = external_exports.looseObject({
49522
49776
  // that disagreed about the same draft.
49523
49777
  replyToId: external_exports.number().nullable().optional(),
49524
49778
  inReplyTo: external_exports.number().nullable().optional(),
49779
+ showContext: external_exports.boolean().optional(),
49525
49780
  recipients: external_exports.array(ApiRecipientSchema).optional(),
49526
49781
  // Attachment fileIds — read so send-by-draft carries the draft's
49527
49782
  // attachments onto the sent message (see DraftContent.files).
@@ -49548,7 +49803,7 @@ var ServerDraftSchema = external_exports.looseObject({
49548
49803
  function isNotFound(e) {
49549
49804
  return e instanceof Error && /OFW API error: 404\b/.test(e.message);
49550
49805
  }
49551
- async function fetchMessageSnapshot(client2, id2) {
49806
+ async function fetchMessageSnapshot(client2, id2, fallbackReplyTo = null) {
49552
49807
  let raw;
49553
49808
  try {
49554
49809
  raw = await client2.request("GET", `/pub/v3/messages/${id2}`);
@@ -49564,21 +49819,23 @@ async function fetchMessageSnapshot(client2, id2) {
49564
49819
  context: "GET /pub/v3/messages/{id} (draft freshness check)",
49565
49820
  mode: "strict"
49566
49821
  });
49822
+ const reply = draftReplyTarget([detail], fallbackReplyTo);
49567
49823
  return {
49568
49824
  content: {
49569
49825
  subject: detail.subject ?? "",
49570
49826
  body: detail.body ?? "",
49571
- replyToId: threadedReplyTo(detail),
49827
+ replyToId: reply.replyToId,
49572
49828
  recipients: mapRecipients(detail.recipients),
49573
49829
  ...detail.files !== void 0 ? { files: detail.files } : {}
49574
49830
  },
49575
49831
  folderId: detail.folder?.id === void 0 ? null : String(detail.folder.id),
49576
49832
  folderName: detail.folder?.name ?? null,
49577
- dateTime: detail.date?.dateTime ?? null
49833
+ dateTime: detail.date?.dateTime ?? null,
49834
+ replyToSource: reply.replyToSource
49578
49835
  };
49579
49836
  }
49580
- async function fetchServerDraft(client2, id2) {
49581
- return (await fetchMessageSnapshot(client2, id2))?.content ?? null;
49837
+ async function fetchServerDraft(client2, id2, fallbackReplyTo = null) {
49838
+ return (await fetchMessageSnapshot(client2, id2, fallbackReplyTo))?.content ?? null;
49582
49839
  }
49583
49840
  var SUBSTANTIVE_FIELDS = ["subject", "body", "recipients"];
49584
49841
  function substantiveChanges(changed) {
@@ -49782,7 +50039,7 @@ async function probeOne(client2, prepared, map2, draftKey, heldFiles) {
49782
50039
  const { id: id2, cachedDraft } = prepared;
49783
50040
  let snapshot;
49784
50041
  try {
49785
- snapshot = await fetchMessageSnapshot(client2, id2);
50042
+ snapshot = await fetchMessageSnapshot(client2, id2, cachedDraft?.replyToId ?? null);
49786
50043
  } catch (e) {
49787
50044
  return {
49788
50045
  requests: 1,
@@ -50054,12 +50311,12 @@ function parseBase(baseUrl) {
50054
50311
  function badInput(message) {
50055
50312
  return new McpToolError(message, { kind: "unknown" });
50056
50313
  }
50057
- function encodeKey(key2) {
50058
- if (typeof key2 !== "string" || key2.length === 0)
50314
+ function encodeKey(key3) {
50315
+ if (typeof key3 !== "string" || key3.length === 0)
50059
50316
  throw badInput("Blob key must be a non-empty string.");
50060
- if (key2.length > MAX_KEY_LENGTH)
50317
+ if (key3.length > MAX_KEY_LENGTH)
50061
50318
  throw badInput(`Blob key is longer than ${MAX_KEY_LENGTH} characters.`);
50062
- const segments = key2.split("/");
50319
+ const segments = key3.split("/");
50063
50320
  for (const seg of segments) {
50064
50321
  if (seg === "" || seg === "." || seg === ".." || !SAFE_SEGMENT.test(seg)) {
50065
50322
  throw badInput('Blob key must be relative, slash-separated segments of [A-Za-z0-9._~-] with no empty, "." or ".." segment.');
@@ -50090,20 +50347,20 @@ function createBlobStore(opts) {
50090
50347
  const signingKey = opts.signingKey;
50091
50348
  const sign2 = (payload) => createHmac4("sha256", signingKey).update(payload).digest("base64url");
50092
50349
  const link2 = (encodedKey, exp, sig) => `${base}/${encodedKey}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
50093
- const signGetUrl = (key2, o) => {
50094
- const encoded = encodeKey(key2);
50350
+ const signGetUrl = (key3, o) => {
50351
+ const encoded = encodeKey(key3);
50095
50352
  const exp = expiry(o);
50096
- return { url: link2(encoded, exp, sign2(`${prefix}/${key2}
50353
+ return { url: link2(encoded, exp, sign2(`${prefix}/${key3}
50097
50354
  ${exp}`)), expiresAtMs: exp };
50098
50355
  };
50099
- const signPutUrl = (key2, contentType, o) => {
50100
- const encoded = encodeKey(key2);
50356
+ const signPutUrl = (key3, contentType, o) => {
50357
+ const encoded = encodeKey(key3);
50101
50358
  checkContentType(contentType);
50102
50359
  const exp = expiry(o);
50103
- return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key2}\0${contentType}\0${exp}`)), expiresAtMs: exp };
50360
+ return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key3}\0${contentType}\0${exp}`)), expiresAtMs: exp };
50104
50361
  };
50105
- const put = async (key2, body, contentType, o = {}) => {
50106
- const { url: url2 } = signPutUrl(key2, contentType, o);
50362
+ const put = async (key3, body, contentType, o = {}) => {
50363
+ const { url: url2 } = signPutUrl(key3, contentType, o);
50107
50364
  const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
50108
50365
  const doFetch = o.fetchImpl ?? fetch;
50109
50366
  let res;
@@ -50117,22 +50374,22 @@ ${exp}`)), expiresAtMs: exp };
50117
50374
  } catch (cause) {
50118
50375
  if (o.signal?.aborted)
50119
50376
  throw cause;
50120
- throw new McpToolError(`Blob store upload of ${key2} did not complete (network error).`, {
50377
+ throw new McpToolError(`Blob store upload of ${key3} did not complete (network error).`, {
50121
50378
  kind: "transport"
50122
50379
  });
50123
50380
  }
50124
50381
  if (!res.ok) {
50125
- throw new McpToolError(`Blob store upload of ${key2} failed (HTTP ${res.status}).`, {
50382
+ throw new McpToolError(`Blob store upload of ${key3} failed (HTTP ${res.status}).`, {
50126
50383
  kind: "http",
50127
50384
  status: res.status
50128
50385
  });
50129
50386
  }
50130
- return { key: key2, bytes: bytes.byteLength };
50387
+ return { key: key3, bytes: bytes.byteLength };
50131
50388
  };
50132
- const signDeleteUrl = (key2, o) => {
50133
- const encoded = encodeKey(key2);
50389
+ const signDeleteUrl = (key3, o) => {
50390
+ const encoded = encodeKey(key3);
50134
50391
  const exp = expiry(o);
50135
- return { url: link2(encoded, exp, sign2(`del\0${prefix}/${key2}\0${exp}`)), expiresAtMs: exp };
50392
+ return { url: link2(encoded, exp, sign2(`del\0${prefix}/${key3}\0${exp}`)), expiresAtMs: exp };
50136
50393
  };
50137
50394
  const exchange = async (what, url2, method, read, o) => {
50138
50395
  try {
@@ -50149,34 +50406,34 @@ ${exp}`)), expiresAtMs: exp };
50149
50406
  throw new McpToolError(`Blob store ${what} did not complete (network error).`, { kind: "transport" });
50150
50407
  }
50151
50408
  };
50152
- const get = async (key2, o = {}) => {
50153
- const { url: url2 } = signGetUrl(key2, o);
50154
- const res = await exchange(`read of ${key2}`, url2, "GET", "bytes", o);
50409
+ const get = async (key3, o = {}) => {
50410
+ const { url: url2 } = signGetUrl(key3, o);
50411
+ const res = await exchange(`read of ${key3}`, url2, "GET", "bytes", o);
50155
50412
  if (!res.ok) {
50156
50413
  const why = res.status === 404 ? " \u2014 not found (never uploaded, expired, or already consumed)" : "";
50157
- throw new McpToolError(`Blob store read of ${key2} failed (HTTP ${res.status})${why}.`, {
50414
+ throw new McpToolError(`Blob store read of ${key3} failed (HTTP ${res.status})${why}.`, {
50158
50415
  kind: "http",
50159
50416
  status: res.status
50160
50417
  });
50161
50418
  }
50162
50419
  const contentType = res.headers.get("content-type") ?? void 0;
50163
- return { key: key2, bytes: res.body, ...contentType !== void 0 ? { contentType } : {} };
50420
+ return { key: key3, bytes: res.body, ...contentType !== void 0 ? { contentType } : {} };
50164
50421
  };
50165
- const del = async (key2, o = {}) => {
50166
- const { url: url2 } = signDeleteUrl(key2, o);
50167
- const res = await exchange(`delete of ${key2}`, url2, "DELETE", "none", o);
50422
+ const del = async (key3, o = {}) => {
50423
+ const { url: url2 } = signDeleteUrl(key3, o);
50424
+ const res = await exchange(`delete of ${key3}`, url2, "DELETE", "none", o);
50168
50425
  if (!res.ok) {
50169
- throw new McpToolError(`Blob store delete of ${key2} failed (HTTP ${res.status}).`, {
50426
+ throw new McpToolError(`Blob store delete of ${key3} failed (HTTP ${res.status}).`, {
50170
50427
  kind: "http",
50171
50428
  status: res.status
50172
50429
  });
50173
50430
  }
50174
50431
  };
50175
- const consume = async (key2, use, o = {}) => {
50176
- const object2 = await get(key2, o);
50432
+ const consume = async (key3, use, o = {}) => {
50433
+ const object2 = await get(key3, o);
50177
50434
  const result = await use(object2);
50178
50435
  try {
50179
- await del(key2, o);
50436
+ await del(key3, o);
50180
50437
  return { result, deleted: true };
50181
50438
  } catch (e) {
50182
50439
  return { result, deleted: false, deleteError: e instanceof Error ? e.message : String(e) };
@@ -50344,13 +50601,13 @@ function mintUploadSlot(store, req, opts = {}) {
50344
50601
  };
50345
50602
  }
50346
50603
  var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
50347
- function uploadFileNameFromKey(key2, opts = {}) {
50604
+ function uploadFileNameFromKey(key3, opts = {}) {
50348
50605
  const prefix = opts.prefix ?? UPLOAD_KEY_PREFIX;
50349
50606
  checkPrefix(prefix);
50350
50607
  const escaped = prefix.replace(/[.~-]/g, "\\$&");
50351
- const match = new RegExp(`^${escaped}/${UUID}/([A-Za-z0-9_-]+)$`).exec(key2);
50608
+ const match = new RegExp(`^${escaped}/${UUID}/([A-Za-z0-9_-]+)$`).exec(key3);
50352
50609
  if (!match) {
50353
- throw new Error(`blobKey ${JSON.stringify(key2)} is not an upload key. Pass the blobKey exactly as the upload slot returned it.`);
50610
+ throw new Error(`blobKey ${JSON.stringify(key3)} is not an upload key. Pass the blobKey exactly as the upload slot returned it.`);
50354
50611
  }
50355
50612
  return sanitizeUploadFilename(Buffer.from(match[1], "base64url").toString("utf8"));
50356
50613
  }
@@ -50360,7 +50617,7 @@ var INLINE_DELIVERY_MAX_BYTES = 10 * 1024 * 1024;
50360
50617
  var DELIVERY_LINK_DEFAULT_TTL_MS = 60 * 60 * 1e3;
50361
50618
 
50362
50619
  // src/tools/uploads.ts
50363
- import { createHash as createHash6 } from "node:crypto";
50620
+ import { createHash as createHash7 } from "node:crypto";
50364
50621
  var MAX_FILES_PER_CALL = MAX_UPLOAD_FILES;
50365
50622
  var UPLOAD_SLOT_TTL_MS = UPLOAD_SLOT_DEFAULT_TTL_MS;
50366
50623
  var UPLOAD_BLOB_PREFIX = UPLOAD_KEY_PREFIX;
@@ -50377,21 +50634,21 @@ function resolveInlineUpload(file2) {
50377
50634
  const bytes = decodeBase64Content(file2.contentBase64, fileName);
50378
50635
  return { blob: new Blob([new Uint8Array(bytes)], { type: mimeType }), fileName, mimeType, sizeBytes: bytes.length };
50379
50636
  }
50380
- function fileNameFromBlobKey(key2) {
50637
+ function fileNameFromBlobKey(key3) {
50381
50638
  try {
50382
- return uploadFileNameFromKey(key2, { prefix: UPLOAD_BLOB_PREFIX });
50639
+ return uploadFileNameFromKey(key3, { prefix: UPLOAD_BLOB_PREFIX });
50383
50640
  } catch (e) {
50384
50641
  const message = e.message;
50385
50642
  if (!message.includes("is not an upload key")) throw e;
50386
- throw new Error(`blobKey ${JSON.stringify(key2)} is not an upload key. Pass the blobKey exactly as ofw_upload_attachment's uploadSlots returned it.`);
50643
+ throw new Error(`blobKey ${JSON.stringify(key3)} is not an upload key. Pass the blobKey exactly as ofw_upload_attachment's uploadSlots returned it.`);
50387
50644
  }
50388
50645
  }
50389
50646
  function mintUploadSlot2(store, req) {
50390
50647
  const { expiresAtMs, ...slot } = mintUploadSlot(store, req, { prefix: UPLOAD_BLOB_PREFIX, ttlMs: UPLOAD_SLOT_TTL_MS });
50391
50648
  return { ...slot, expiresAt: formatInstant(new Date(expiresAtMs)).iso };
50392
50649
  }
50393
- function blobObjectToUpload(key2, object2) {
50394
- const fileName = fileNameFromBlobKey(key2);
50650
+ function blobObjectToUpload(key3, object2) {
50651
+ const fileName = fileNameFromBlobKey(key3);
50395
50652
  checkUploadSize2(fileName, object2.bytes.length);
50396
50653
  const mimeType = normalizeMimeType(object2.contentType ?? mimeFromName(fileName));
50397
50654
  return {
@@ -50440,7 +50697,7 @@ async function uploadToMyFiles(client2, cache, upload, opts) {
50440
50697
  return { fileId: meta3.fileId, ...stored, bytes: sizeBytes, shareClass: meta3.shareClass ?? opts.shareClass };
50441
50698
  }
50442
50699
  async function sha256Hex(blob) {
50443
- return createHash6("sha256").update(new Uint8Array(await blob.arrayBuffer())).digest("hex");
50700
+ return createHash7("sha256").update(new Uint8Array(await blob.arrayBuffer())).digest("hex");
50444
50701
  }
50445
50702
  function checkFileCount(count, what) {
50446
50703
  if (count > MAX_FILES_PER_CALL) {
@@ -51500,7 +51757,7 @@ function pageState(input2) {
51500
51757
  const hasMore = input2.page * input2.size < input2.total;
51501
51758
  return { hasMore, nextPage: hasMore ? input2.page + 1 : null };
51502
51759
  }
51503
- function asRecord(value) {
51760
+ function asRecord2(value) {
51504
51761
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
51505
51762
  }
51506
51763
  function recordArray(root) {
@@ -51511,9 +51768,9 @@ function recordArray(root) {
51511
51768
  return null;
51512
51769
  }
51513
51770
  function readUpstreamPaging(payload) {
51514
- const root = asRecord(payload);
51771
+ const root = asRecord2(payload);
51515
51772
  const rows = root === null ? null : recordArray(root);
51516
- const meta3 = root === null ? null : asRecord(root.metadata);
51773
+ const meta3 = root === null ? null : asRecord2(root.metadata);
51517
51774
  const total = meta3 !== null && typeof meta3.totalElements === "number" && Number.isFinite(meta3.totalElements) ? meta3.totalElements : null;
51518
51775
  const last = meta3 !== null && typeof meta3.last === "boolean" ? meta3.last : null;
51519
51776
  return { returned: rows?.length ?? 0, total, last };
@@ -51525,7 +51782,7 @@ function offsetState(input2) {
51525
51782
  return { hasMore, nextStart: hasMore ? input2.start + input2.max : null };
51526
51783
  }
51527
51784
  function withPaginationFirst(input2) {
51528
- const body = asRecord(input2.payload);
51785
+ const body = asRecord2(input2.payload);
51529
51786
  if (body === null) return null;
51530
51787
  const scope = input2.total !== null ? ` of ${input2.total}` : "";
51531
51788
  const head = {
@@ -51540,102 +51797,8 @@ function withPaginationFirst(input2) {
51540
51797
  return { ...head, ...body, ...head };
51541
51798
  }
51542
51799
 
51543
- // src/tools/project.ts
51544
- var MESSAGE_VIEWS = ["compact", "full"];
51545
- var LABEL = "ofw-mcp";
51546
- function asRecord2(value) {
51547
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
51548
- }
51549
- function senderOf(row) {
51550
- if (typeof row.fromUser === "string" && row.fromUser !== "") return row.fromUser;
51551
- const author = asRecord2(asRecord2(row.listData)?.author);
51552
- const name = author?.name;
51553
- return typeof name === "string" && name !== "" ? name : null;
51554
- }
51555
- function fileCountOf(row) {
51556
- const files = asRecord2(row.listData)?.files;
51557
- if (typeof files === "number") return files;
51558
- if (Array.isArray(files)) return files.length;
51559
- return void 0;
51560
- }
51561
- function repliedOf(row) {
51562
- const replied = asRecord2(row.listData)?.replied;
51563
- return typeof replied === "boolean" ? replied : void 0;
51564
- }
51565
- function compactMessage(row) {
51566
- const { listData: _drop, fromUser: _dropFrom, ...rest } = row;
51567
- return pruneUndefined({
51568
- id: rest.id,
51569
- folder: rest.folder,
51570
- subject: rest.subject,
51571
- from: senderOf(row),
51572
- sentAt: rest.sentAt,
51573
- recipients: rest.recipients,
51574
- read: rest.read,
51575
- replied: repliedOf(row),
51576
- files: fileCountOf(row),
51577
- replyToId: rest.replyToId,
51578
- chainRootId: rest.chainRootId,
51579
- body: rest.body,
51580
- fetchedBodyAt: rest.fetchedBodyAt,
51581
- // Anything a TOOL added on top of the cache row — `attachments`,
51582
- // `revision`, `cacheStatus`, `serverConfirmed`, `freshness` — is kept
51583
- // wholesale. Those are this server's own answers, never OFW's echo, and a
51584
- // projection that dropped one would be removing the thing the caller
51585
- // asked for rather than the thing they got twice.
51586
- ...omitKnown(rest, MESSAGE_ROW_KEYS)
51587
- });
51588
- }
51589
- var MESSAGE_ROW_KEYS = /* @__PURE__ */ new Set([
51590
- "id",
51591
- "folder",
51592
- "subject",
51593
- "sentAt",
51594
- "recipients",
51595
- "read",
51596
- "replyToId",
51597
- "chainRootId",
51598
- "body",
51599
- "fetchedBodyAt"
51600
- ]);
51601
- var DRAFT_ROW_KEYS = /* @__PURE__ */ new Set(["id", "subject", "recipients", "replyToId", "modifiedAt", "body"]);
51602
- function omitKnown(rest, own2) {
51603
- const out = {};
51604
- for (const [key2, value] of Object.entries(rest)) if (!own2.has(key2)) out[key2] = value;
51605
- return out;
51606
- }
51607
- function compactDraft(row) {
51608
- const { listData: _drop, ...rest } = row;
51609
- return pruneUndefined({
51610
- id: rest.id,
51611
- subject: rest.subject,
51612
- recipients: rest.recipients,
51613
- replyToId: rest.replyToId,
51614
- modifiedAt: rest.modifiedAt,
51615
- body: rest.body,
51616
- ...omitKnown(rest, DRAFT_ROW_KEYS)
51617
- });
51618
- }
51619
- function viewMessages(view, rows) {
51620
- if (view !== "compact") return rows;
51621
- return projectOrRaw(rows, (rs) => rs.map((r) => compactMessage(r)), {
51622
- label: LABEL,
51623
- context: "the cached message rows"
51624
- });
51625
- }
51626
- function viewDrafts(view, rows) {
51627
- if (view !== "compact") return rows;
51628
- return projectOrRaw(rows, (rs) => rs.map((r) => compactDraft(r)), {
51629
- label: LABEL,
51630
- context: "the cached draft rows"
51631
- });
51632
- }
51633
- function viewOne(view, row) {
51634
- if (view !== "compact") return row;
51635
- return projectOrRaw(row, (r) => compactMessage(r), { label: LABEL, context: "a cached message row" });
51636
- }
51637
-
51638
51800
  // src/tools/messages.ts
51801
+ var WRITE_VIEW_NOTE = 'compact omits OurFamilyWizard\'s raw `listData` echo (which repeats the body, subject, recipients and a date block) and replaces the body you just wrote with `bodyLength` + `bodySha256` (the first 16 hex characters of its SHA-256) to confirm what landed. Pass "full" for both.';
51639
51802
  var DRAFT_KEY_NULL_REASON = "No draftKey: this draft was not saved through this server's cache \u2014 it may have been created in the OurFamilyWizard web app or replaced from another session \u2014 so its lineage is unknown. The next ofw_save_draft on it starts a new key.";
51640
51803
  async function describeDraftKey(cache, id2) {
51641
51804
  const row = await cache.getDraftLineageById(id2);
@@ -51802,6 +51965,14 @@ async function openUnreadBody(client2, cache, cached2) {
51802
51965
  if (Array.isArray(detail.files) && detail.files.length > 0) {
51803
51966
  await fetchAttachmentMetaForMessage(client2, cached2.id, detail.files, cache);
51804
51967
  }
51968
+ return {
51969
+ id: cached2.id,
51970
+ subject: cached2.subject,
51971
+ from: senderOf(cached2),
51972
+ sentAt: cached2.sentAt,
51973
+ viewedAt: latestViewedAt(detail.recipients),
51974
+ reason: "fetchUnreadBodies"
51975
+ };
51805
51976
  }
51806
51977
  async function confirmMarkRead(ctx, cached2, args) {
51807
51978
  if (!getConfirmMarkRead()) return void 0;
@@ -51933,20 +52104,20 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
51933
52104
  });
51934
52105
  }
51935
52106
  const bounds = {};
51936
- for (const key2 of ["since", "until"]) {
51937
- const value2 = args[key2];
52107
+ for (const key3 of ["since", "until"]) {
52108
+ const value2 = args[key3];
51938
52109
  if (value2 === void 0) continue;
51939
52110
  const converted = toNaiveWallClock(value2);
51940
52111
  if (converted === null) {
51941
52112
  return jsonErrorResponse({
51942
52113
  result: "INVALID_DATE",
51943
- reason: `${key2} must be an ISO date (YYYY-MM-DD) or datetime, optionally with an offset or Z (got ${JSON.stringify(value2)}).`,
51944
- remedy: `Re-call with ${key2} as e.g. "2026-07-27" or "2026-07-27T22:00:00-04:00".`,
52114
+ reason: `${key3} must be an ISO date (YYYY-MM-DD) or datetime, optionally with an offset or Z (got ${JSON.stringify(value2)}).`,
52115
+ remedy: `Re-call with ${key3} as e.g. "2026-07-27" or "2026-07-27T22:00:00-04:00".`,
51945
52116
  complete: false,
51946
52117
  note: 'No lookup was performed. This says NOTHING about what is in the cache \u2014 do not read it as "no messages".'
51947
52118
  });
51948
52119
  }
51949
- bounds[key2] = converted;
52120
+ bounds[key3] = converted;
51950
52121
  }
51951
52122
  const cache = cacheProvider();
51952
52123
  const folders = folder === void 0 ? ["inbox", "sent"] : [folder];
@@ -52075,6 +52246,9 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
52075
52246
  // ofw_delete_draft / ofw_send_message to assert you are acting on
52076
52247
  // THIS version.
52077
52248
  revision: draftRevision(draftRow, held),
52249
+ // Whether the reply target is OFW's own echo or this server's record of
52250
+ // it (OFW's payload omitted the linkage) — see reply-source.ts.
52251
+ ...await replyToSourceField(cache, draftRow.id, draftRow.replyToId),
52078
52252
  cacheStatus,
52079
52253
  // False = this draft's existence and unsent status are remembered from
52080
52254
  // a cache, not confirmed on OFW. Call ofw_check_freshness before
@@ -52193,7 +52367,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
52193
52367
  myFileIDs: external_exports.array(external_exports.number()).describe("Attachment file ids (from ofw_upload_attachment) to attach to the message. When sending by draftId, omit it to carry the server draft's own attachments over; passing it overrides them.").optional(),
52194
52368
  inlineAttachments: inlineAttachmentsParam,
52195
52369
  blobKeys: blobKeysParam,
52196
- confirmToken: confirmTokenParam
52370
+ confirmToken: confirmTokenParam,
52371
+ view: viewParam(MESSAGE_VIEWS, { note: WRITE_VIEW_NOTE })
52197
52372
  })
52198
52373
  }, async (args, ctx) => {
52199
52374
  if (args.messageId !== void 0 && args.draftId !== void 0 && args.messageId !== args.draftId) {
@@ -52413,12 +52588,12 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
52413
52588
  if (draftRef !== void 0) {
52414
52589
  const prior = await cache.getDraftLineageById(draftRef);
52415
52590
  const now = (/* @__PURE__ */ new Date()).toISOString();
52416
- const key2 = prior?.draftKey ?? newDraftKey();
52591
+ const key3 = prior?.draftKey ?? newDraftKey();
52417
52592
  if (prior === null) {
52418
- await cache.recordDraftLineage({ id: draftRef, draftKey: key2, previousId: null, recordedAt: now });
52593
+ await cache.recordDraftLineage({ id: draftRef, draftKey: key3, previousId: null, recordedAt: now });
52419
52594
  }
52420
- await cache.recordDraftLineage({ id: newId, draftKey: key2, previousId: draftRef, recordedAt: now });
52421
- sentDraftKey = key2;
52595
+ await cache.recordDraftLineage({ id: newId, draftKey: key3, previousId: draftRef, recordedAt: now });
52596
+ sentDraftKey = key3;
52422
52597
  }
52423
52598
  for (const fileId of myFileIDs) {
52424
52599
  const existing = await cache.getAttachment(fileId);
@@ -52467,7 +52642,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
52467
52642
  ...draftDeleted ? {} : { draftRetained: true, draftRetainedReason },
52468
52643
  previousId: draftRef
52469
52644
  } : {},
52470
- ...persisted,
52645
+ ...resolveView(args.view, MESSAGE_VIEWS) === "full" ? persisted : compactSentMessage(persisted),
52471
52646
  ...attachmentCheck !== null ? { attachments: attachmentCheck } : {},
52472
52647
  ...newFiles.length > 0 ? { attachmentsUploaded: newFiles } : {},
52473
52648
  ...uploadWarnings.length > 0 ? { warnings: uploadWarnings } : {}
@@ -52490,7 +52665,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
52490
52665
  };
52491
52666
  let server2;
52492
52667
  try {
52493
- server2 = await fetchServerDraft(client2, draftId);
52668
+ server2 = await fetchServerDraft(client2, draftId, cachedRow?.replyToId ?? null);
52494
52669
  } catch (e) {
52495
52670
  const reason = e.message;
52496
52671
  if (force) {
@@ -52583,8 +52758,9 @@ ${jsonText(
52583
52758
  );
52584
52759
  const held = await heldFilesFor(cache, rows.map((d) => d.id));
52585
52760
  const inferred = await inferredDraftKeys(cache, rows.map((d) => d.id));
52586
- const drafts2 = rows.map((d) => ({
52761
+ const drafts2 = await Promise.all(rows.map(async (d) => ({
52587
52762
  ...d,
52763
+ ...await replyToSourceField(cache, d.id, d.replyToId),
52588
52764
  revision: draftRevision(d, held.get(d.id)),
52589
52765
  ...held.get(d.id).length > 0 ? { heldFiles: held.get(d.id) } : {},
52590
52766
  draftKey: keyById.get(d.id) ?? null,
@@ -52592,7 +52768,7 @@ ${jsonText(
52592
52768
  cacheStatus,
52593
52769
  serverConfirmed: serverConfirmed2,
52594
52770
  asOf: freshness2.asOf
52595
- }));
52771
+ })));
52596
52772
  return { drafts: drafts2, total: total2, freshness: freshness2, serverConfirmed: serverConfirmed2 };
52597
52773
  }
52598
52774
  });
@@ -52642,7 +52818,7 @@ ${jsonText(
52642
52818
  });
52643
52819
  if (allowDrafts) server.registerTool("ofw_save_draft", {
52644
52820
  _meta: familyMeta("change"),
52645
- description: "Save a message as a draft in OurFamilyWizard. RECIPIENTS: OurFamilyWizard has not reliably kept recipients on drafts (when the saved draft comes back with none it is noted once, not warned about) \u2014 supply recipientIds at send time as well. ATTACHMENTS: OurFamilyWizard does not store files on drafts, so myFileIDs / inlineAttachments / blobKeys are HELD with the draft by this server (carried across edits, de-duplicated; removeFileIDs drops one), shown under attachments.held, folded into `revision`, and attached when the draft is sent with ofw_send_message(draftId). They are not visible on the draft in the OurFamilyWizard web app. IDENTITY: the response leads with `draftKey`, the stable identity that survives editing \u2014 key off it, because the `id` changes on EVERY edit (replacing a draft creates a NEW draft and deletes the old one; OFW's update-in-place endpoint silently no-ops, so we never use it). Pass messageId to replace an existing draft; the response.id will be the NEW id, and a transparency NOTE documents the swap and which fields were carried over. THREADING: if replyToId is provided, the cache may rewrite it to the latest reply in the thread (note included). The threading verdict is read from OFW's full echo (replyToId/inReplyTo/showContext) \u2014 a warning appears ONLY when the reply linkage was genuinely dropped or re-targeted, and the response's top-level replyToId/inReplyTo always agree with its listData. After saving, the tool re-fetches the draft from OFW, and the returned `revision` reflects that authoritative state (so it will match on your next edit). SAFETY: because replacing DESTROYS the old draft rather than merging, passing messageId first re-reads that draft from OFW and REFUSES the write if its subject/body/recipients changed since you read it (drafts edited in the OFW web app do not bump any timestamp, so the local cache can be silently behind). A pure replyToId normalization by OFW is NOT treated as a conflict. The refusal returns the current server body under serverBody \u2014 merge your edit into it and retry with expectedRevision.",
52821
+ description: "Save a message as a draft in OurFamilyWizard. RECIPIENTS: OurFamilyWizard has not reliably kept recipients on drafts (when the saved draft comes back with none it is noted once, not warned about) \u2014 supply recipientIds at send time as well. ATTACHMENTS: OurFamilyWizard does not store files on drafts, so myFileIDs / inlineAttachments / blobKeys are HELD with the draft by this server (carried across edits, de-duplicated; removeFileIDs drops one), shown under attachments.held, folded into `revision`, and attached when the draft is sent with ofw_send_message(draftId). They are not visible on the draft in the OurFamilyWizard web app. IDENTITY: the response leads with `draftKey`, the stable identity that survives editing \u2014 key off it, because the `id` changes on EVERY edit (replacing a draft creates a NEW draft and deletes the old one; OFW's update-in-place endpoint silently no-ops, so we never use it). Pass messageId to replace an existing draft; the response.id will be the NEW id, and a transparency NOTE documents the swap and which fields were carried over. THREADING: if replyToId is provided, the cache may rewrite it to the latest reply in the thread (note included). The threading verdict is read from OFW's full echo (replyToId/inReplyTo/showContext) \u2014 a warning appears ONLY when the reply linkage was genuinely dropped or re-targeted. When OFW's echo omits the linkage entirely, the posted target is kept and marked replyToSource:\"cache\". Replacing a draft (messageId) without replyToId keeps the draft's own reply target. RESPONSE: compact by default \u2014 no listData echo, and the body you wrote is returned as bodyLength + bodySha256; view:\"full\" returns both. After saving, the tool re-fetches the draft from OFW, and the returned `revision` reflects that authoritative state (so it will match on your next edit). SAFETY: because replacing DESTROYS the old draft rather than merging, passing messageId first re-reads that draft from OFW and REFUSES the write if its subject/body/recipients changed since you read it (drafts edited in the OFW web app do not bump any timestamp, so the local cache can be silently behind). A pure replyToId normalization by OFW is NOT treated as a conflict. The refusal returns the current server body under serverBody \u2014 merge your edit into it and retry with expectedRevision.",
52646
52822
  // Destructive: with messageId, saving REPLACES the draft by creating a new
52647
52823
  // one and deleting the old (OFW has no draft update), so the old draft's
52648
52824
  // server content is gone. Not idempotent: every call mints a new draft id.
@@ -52658,10 +52834,12 @@ ${jsonText(
52658
52834
  inlineAttachments: inlineAttachmentsParam,
52659
52835
  blobKeys: blobKeysParam,
52660
52836
  expectedRevision: external_exports.string().describe('With messageId: the `revision` you got from ofw_list_drafts/ofw_get_message for that draft. Asserts you are replacing THAT version. If the draft changed on OFW since, the write is refused and the current server body is returned. Omit and the tool compares the server against the local cache instead \u2014 omitting never means "overwrite anyway".').optional(),
52661
- force: external_exports.boolean().describe("Default false. Overwrite even when the draft changed on OurFamilyWizard since you read it. The discarded server version is echoed back in the response. Only use after showing the user the conflict.").optional()
52837
+ force: external_exports.boolean().describe("Default false. Overwrite even when the draft changed on OurFamilyWizard since you read it. The discarded server version is echoed back in the response. Only use after showing the user the conflict.").optional(),
52838
+ view: viewParam(MESSAGE_VIEWS, { note: WRITE_VIEW_NOTE })
52662
52839
  })
52663
52840
  }, async (args) => {
52664
52841
  const cache = cacheProvider();
52842
+ const view = resolveView(args.view, MESSAGE_VIEWS);
52665
52843
  const blobStore = args.blobKeys?.length ? blobStoreFromEnv() : void 0;
52666
52844
  const pending = await planAttachments(
52667
52845
  { inline: args.inlineAttachments, blobKeys: args.blobKeys },
@@ -52671,6 +52849,7 @@ ${jsonText(
52671
52849
  let serverFiles;
52672
52850
  let priorHeld = [];
52673
52851
  let serverRecipientIds;
52852
+ let serverReplyTo = null;
52674
52853
  if (args.messageId !== void 0) {
52675
52854
  const guard = await guardDestructiveDraftOp({
52676
52855
  cache,
@@ -52685,8 +52864,9 @@ ${jsonText(
52685
52864
  priorHeld = guard.heldFiles;
52686
52865
  const kept = (guard.server?.recipients ?? []).map((r) => r.userId).filter((id2) => id2 !== 0);
52687
52866
  if (kept.length > 0) serverRecipientIds = [...new Set(kept)];
52867
+ serverReplyTo = guard.server?.replyToId ?? null;
52688
52868
  }
52689
- const requestedReplyTo = args.replyToId ?? null;
52869
+ const requestedReplyTo = args.replyToId ?? serverReplyTo;
52690
52870
  let resolvedReplyTo = requestedReplyTo;
52691
52871
  let rewriteNote = null;
52692
52872
  if (requestedReplyTo !== null) {
@@ -52729,13 +52909,16 @@ ${jsonText(
52729
52909
  let verifyNote = null;
52730
52910
  let recipientsNote = null;
52731
52911
  let newRevision = null;
52912
+ let replyToSource = null;
52732
52913
  let onDraft = [];
52733
52914
  let held = [];
52734
52915
  let draftKey = null;
52735
52916
  const warnings = [...uploadWarnings];
52736
52917
  if (newId !== null) {
52737
52918
  verifyNote = verifyWriteLanded("draft", { subject: args.subject, body: args.body }, detail);
52738
- const effectiveReplyTo = threadedReplyTo(detail);
52919
+ const reply = draftReplyTarget([detail], resolvedReplyTo);
52920
+ const effectiveReplyTo = reply.replyToId;
52921
+ replyToSource = reply.replyToSource;
52739
52922
  const storedRecipients = mapRecipients(detail.recipients);
52740
52923
  persisted = {
52741
52924
  id: newId,
@@ -52747,6 +52930,7 @@ ${jsonText(
52747
52930
  listData: detail
52748
52931
  };
52749
52932
  await cache.upsertDraft(persisted);
52933
+ await setReplyToSource(cache, newId, replyToSource);
52750
52934
  onDraft = Array.isArray(detail.files) ? detail.files : [];
52751
52935
  held = myFileIDs.filter((id2) => !onDraft.includes(id2));
52752
52936
  await setHeldFiles(cache, newId, held);
@@ -52810,8 +52994,9 @@ ${jsonText(
52810
52994
  const responseObj = persisted !== null ? {
52811
52995
  draftKey,
52812
52996
  revision: newRevision,
52813
- ...persisted,
52997
+ ...view === "full" ? persisted : compactWrittenDraft(persisted),
52814
52998
  inReplyTo: persisted.replyToId,
52999
+ ...replyToSource !== null ? { replyToSource } : {},
52815
53000
  previousId: args.messageId ?? null,
52816
53001
  cacheStatus: "fresh",
52817
53002
  serverConfirmed: true,
@@ -53033,10 +53218,10 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53033
53218
  results.push({ index, ok: true, ...await uploadToMyFiles(client2, cache, upload, opts) });
53034
53219
  continue;
53035
53220
  }
53036
- const key2 = args.blobKeys[index];
53037
- fileNameFromBlobKey(key2);
53038
- const out = await store.consume(key2, async (object2) => {
53039
- const upload = blobObjectToUpload(key2, object2);
53221
+ const key3 = args.blobKeys[index];
53222
+ fileNameFromBlobKey(key3);
53223
+ const out = await store.consume(key3, async (object2) => {
53224
+ const upload = blobObjectToUpload(key3, object2);
53040
53225
  const gate = await shareGate(ctx, args, upload, opts, confirmToken);
53041
53226
  if (gate) throw new GateHalt(gate);
53042
53227
  return uploadToMyFiles(client2, cache, upload, opts);
@@ -53117,9 +53302,9 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53117
53302
  }
53118
53303
  const linkDelivery = async (bytes, fileName2, mimeType2, note) => {
53119
53304
  const keyName = `${fileId}-${basename3(fileName2)}`.replace(/[^A-Za-z0-9._~-]/g, "_").replace(/^\.+/, "_");
53120
- const key2 = `attachments/${randomUUID3()}/${keyName}`;
53121
- await store.put(key2, new Uint8Array(bytes), mimeType2);
53122
- const signed = store.signGetUrl(key2, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
53305
+ const key3 = `attachments/${randomUUID3()}/${keyName}`;
53306
+ await store.put(key3, new Uint8Array(bytes), mimeType2);
53307
+ const signed = store.signGetUrl(key3, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
53123
53308
  return jsonResponse({
53124
53309
  fileId,
53125
53310
  deliveredVia: "link",
@@ -53204,7 +53389,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53204
53389
  _meta: familyMeta("other"),
53205
53390
  // Destructive: fetchUnreadBodies:true stamps a co-parent-visible "First
53206
53391
  // Viewed" time on every unread inbox message it touches — irreversible.
53207
- description: "Sync messages from OurFamilyWizard into the local cache. Returns counts per folder and a list of unread inbox messages whose bodies were NOT fetched (to avoid mark-as-read on OFW). Call ofw_get_message(id) on those to read them. EVERY call re-checks the newest page first, so new messages are picked up promptly even while an old-history backfill is still running; only then does it spend what is left of its budget advancing that backfill. Pass deep:true to walk all OFW pages instead of stopping at the first all-cached page (use to backfill suspected gaps). Sync is BOUNDED and RESUMABLE: on hosted deployments a per-call OFW-request budget (env OFW_SYNC_MAX_REQUESTS, or the maxRequests argument) caps how far one call walks; when the budget is hit the response reports done:false with a note \u2014 call again with the SAME arguments to resume. done:false means older history is still being backfilled; it does NOT mean recent messages are missing. Local installs are unbounded by default (done is always true). On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) no inbox or sent message body is downloaded at all \u2014 new messages are cached from the list (sender, date, subject) and the response carries bodiesWithheld:true; the first sync on a reading day fills in those bodies, except unread inbox ones.",
53392
+ description: 'Sync messages from OurFamilyWizard into the local cache. A sync NEVER marks a message read unless fetchUnreadBodies is set: a new inbox message that OFW does not list as read is cached from the list (sender, date, subject) WITHOUT its body, because fetching the body is what stamps a co-parent-visible "First Viewed" time. Every response says what arrived: newMessages lists each message first cached by THIS call \u2014 inbox and sent, newest first, with read (its state before the sync) and bodyFetched; newMessagesTotal and newMessagesTruncated give the full count when more than ' + NEW_MESSAGES_CAP + ' arrived (ofw_list_messages pages through the rest). unreadInbox lists the new inbox messages that were unread when the sync began; bodyFetched:false means still unread on OFW \u2014 call ofw_get_message(id) to read one, which marks it read. If this call DID mark anything read (fetchUnreadBodies, or a stamp it detected but did not intend), the response LEADS with a warning and lists each in markedRead with reason "fetchUnreadBodies" or "unexpected"; markedRead is omitted when nothing was marked, and markedReadCount is always present. Returns counts per folder too. EVERY call re-checks the newest page first, so new messages are picked up promptly even while an old-history backfill is still running; only then does it spend what is left of its budget advancing that backfill. Pass deep:true to walk all OFW pages instead of stopping at the first all-cached page (use to backfill suspected gaps). Sync is BOUNDED and RESUMABLE: on hosted deployments a per-call OFW-request budget (env OFW_SYNC_MAX_REQUESTS, or the maxRequests argument) caps how far one call walks; when the budget is hit the response reports done:false with a note \u2014 call again with the SAME arguments to resume. done:false means older history is still being backfilled; it does NOT mean recent messages are missing. Local installs are unbounded by default (done is always true). On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) no inbox or sent message body is downloaded at all \u2014 new messages are cached from the list (sender, date, subject) and the response carries bodiesWithheld:true; the first sync on a reading day fills in those bodies, except unread inbox ones.',
53208
53393
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
53209
53394
  inputSchema: external_exports.object({
53210
53395
  folders: external_exports.array(external_exports.enum(["inbox", "sent", "drafts"])).min(1).describe("Folders to sync (default: all three). Must be non-empty if given \u2014 an empty list would sync nothing while reporting success.").optional(),
@@ -53261,23 +53446,28 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53261
53446
  confirmToken: args.confirmToken
53262
53447
  });
53263
53448
  if (gate) return gate;
53264
- for (const row of rows) await openUnreadBody(client2, cache, row);
53449
+ const markedRead = result.markedRead ?? [];
53450
+ for (const row of rows) markedRead.push(await openUnreadBody(client2, cache, row));
53451
+ result.markedRead = markedRead;
53265
53452
  }
53266
53453
  const opened = new Set(rows.map((row) => row.id));
53267
- const before = result.unreadInbox.length;
53268
- result.unreadInbox = result.unreadInbox.filter((hint) => !opened.has(hint.id));
53269
- if (result.unreadInbox.length !== before) {
53270
- const notes = result.note.split("\n\n").filter((n) => n !== unreadInboxNote(before));
53271
- if (result.unreadInbox.length > 0) notes.push(unreadInboxNote(result.unreadInbox.length));
53272
- result.note = notes.length > 0 ? notes.join("\n\n") : void 0;
53273
- }
53454
+ result.unreadInbox = result.unreadInbox.map((hint) => opened.has(hint.id) ? { ...hint, bodyFetched: true } : hint);
53455
+ result.newMessages = result.newMessages.map((m) => opened.has(m.id) ? { ...m, bodyFetched: true } : m);
53456
+ refreshReadReporting(result);
53274
53457
  unreadBodies = { requested: true, fetched: true, opened: [...opened], ...remaining > 0 ? { remaining } : {} };
53275
53458
  }
53276
53459
  const freshness = await buildFreshness(cache, {
53277
53460
  source: "cache",
53278
53461
  folders: args.folders ?? ["inbox", "sent", "drafts"]
53279
53462
  });
53280
- return jsonResponse({ ...result, ...unreadBodies ? { unreadBodies } : {}, freshness });
53463
+ const { warning, newMessages, ...rest } = result;
53464
+ return jsonResponse({
53465
+ ...warning ? { warning } : {},
53466
+ ...rest,
53467
+ ...unreadBodies ? { unreadBodies } : {},
53468
+ freshness,
53469
+ newMessages
53470
+ });
53281
53471
  });
53282
53472
  server.registerTool("ofw_check_freshness", {
53283
53473
  _meta: familyMeta("other"),
@@ -53394,7 +53584,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53394
53584
  );
53395
53585
  const held = await heldFilesFor(cache, rows.map((d) => d.id));
53396
53586
  const inferred = await inferredDraftKeys(cache, rows.map((d) => d.id));
53397
- drafts = rows.map((d) => ({
53587
+ drafts = await Promise.all(rows.map(async (d) => ({
53398
53588
  id: d.id,
53399
53589
  draftKey: keyById.get(d.id) ?? null,
53400
53590
  ...inferred.has(d.id) ? { draftKeyInferred: true } : {},
@@ -53404,8 +53594,9 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
53404
53594
  modifiedAt: d.modifiedAt,
53405
53595
  recipients: d.recipients,
53406
53596
  replyToId: d.replyToId,
53597
+ ...await replyToSourceField(cache, d.id, d.replyToId),
53407
53598
  cacheStatus
53408
- }));
53599
+ })));
53409
53600
  if (!inventoryComplete) {
53410
53601
  incomplete.push("the drafts folder was not fully verified against OurFamilyWizard on this call (the request budget paused the walk), so this inventory may be missing or misreporting drafts");
53411
53602
  }
@@ -53889,9 +54080,9 @@ function registerCalendarTools(server, client2, attachmentIO = new NodeAttachmen
53889
54080
  const fileName = `ofw-calendar-${args.startDate}_${args.endDate}-${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z.ics`;
53890
54081
  const blob = blobStoreFromEnv();
53891
54082
  if (blob) {
53892
- const key2 = `calendar/${randomUUID4()}/${fileName}`;
53893
- await blob.put(key2, built.ics, "text/calendar");
53894
- const link2 = blob.signGetUrl(key2, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
54083
+ const key3 = `calendar/${randomUUID4()}/${fileName}`;
54084
+ await blob.put(key3, built.ics, "text/calendar");
54085
+ const link2 = blob.signGetUrl(key3, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
53895
54086
  return jsonResponse({
53896
54087
  delivered: "link",
53897
54088
  url: link2.url,
@@ -54371,10 +54562,10 @@ var ARG_FOR = {
54371
54562
  };
54372
54563
  var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
54373
54564
  var positiveInt = (v) => typeof v === "number" && Number.isInteger(v) && v > 0 ? v : void 0;
54374
- var refId = (v, key2) => positiveInt(v) ?? (isRecord3(v) ? positiveInt(v[key2]) ?? positiveInt(v.id) : void 0);
54375
- var idList = (v, key2) => {
54565
+ var refId = (v, key3) => positiveInt(v) ?? (isRecord3(v) ? positiveInt(v[key3]) ?? positiveInt(v.id) : void 0);
54566
+ var idList = (v, key3) => {
54376
54567
  if (!Array.isArray(v)) return void 0;
54377
- const ids = v.map((x) => refId(x, key2));
54568
+ const ids = v.map((x) => refId(x, key3));
54378
54569
  return ids.every((id2) => id2 !== void 0) ? ids : void 0;
54379
54570
  };
54380
54571
  function readExpenseState(raw) {
@@ -54398,9 +54589,9 @@ function readExpenseState(raw) {
54398
54589
  if (d.description === null || d.description === "") out.description = null;
54399
54590
  else if (typeof d.description === "string") out.description = d.description;
54400
54591
  }
54401
- for (const key2 of ["fileIds", "files"]) {
54402
- if (!(key2 in d)) continue;
54403
- const ids = d[key2] === null ? [] : idList(d[key2], "fileId");
54592
+ for (const key3 of ["fileIds", "files"]) {
54593
+ if (!(key3 in d)) continue;
54594
+ const ids = d[key3] === null ? [] : idList(d[key3], "fileId");
54404
54595
  if (ids !== void 0) out.fileIds = ids;
54405
54596
  break;
54406
54597
  }
@@ -55189,14 +55380,14 @@ var OFWCacheCore = class {
55189
55380
  [folder, state.lastSyncAt, nullish3(state.newestId), nullish3(state.resumePage)]
55190
55381
  );
55191
55382
  }
55192
- getMeta(key2) {
55193
- const r = this.db.get("SELECT value FROM meta WHERE key = ?", [key2]);
55383
+ getMeta(key3) {
55384
+ const r = this.db.get("SELECT value FROM meta WHERE key = ?", [key3]);
55194
55385
  return r ? r.value : null;
55195
55386
  }
55196
- setMeta(key2, value) {
55387
+ setMeta(key3, value) {
55197
55388
  this.db.run(
55198
55389
  "INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",
55199
- [key2, value]
55390
+ [key3, value]
55200
55391
  );
55201
55392
  }
55202
55393
  findLatestReplyTip(replyToId) {
@@ -55336,11 +55527,11 @@ var LocalCacheStore = class {
55336
55527
  async setSyncState(folder, state) {
55337
55528
  this.core.setSyncState(folder, state);
55338
55529
  }
55339
- async getMeta(key2) {
55340
- return this.core.getMeta(key2);
55530
+ async getMeta(key3) {
55531
+ return this.core.getMeta(key3);
55341
55532
  }
55342
- async setMeta(key2, value) {
55343
- this.core.setMeta(key2, value);
55533
+ async setMeta(key3, value) {
55534
+ this.core.setMeta(key3, value);
55344
55535
  }
55345
55536
  async findLatestReplyTip(replyToId) {
55346
55537
  return this.core.findLatestReplyTip(replyToId);