ofw-mcp 2.22.0 → 2.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -94,7 +94,7 @@ var require_buffer_util = __commonJS({
94
94
  buffer[i] ^= mask[i & 3];
95
95
  }
96
96
  }
97
- function toArrayBuffer(buf) {
97
+ function toArrayBuffer2(buf) {
98
98
  if (buf.length === buf.buffer.byteLength) {
99
99
  return buf.buffer;
100
100
  }
@@ -117,7 +117,7 @@ var require_buffer_util = __commonJS({
117
117
  module.exports = {
118
118
  concat,
119
119
  mask: _mask,
120
- toArrayBuffer,
120
+ toArrayBuffer: toArrayBuffer2,
121
121
  toBuffer,
122
122
  unmask: _unmask
123
123
  };
@@ -784,7 +784,7 @@ var require_receiver = __commonJS({
784
784
  kStatusCode,
785
785
  kWebSocket
786
786
  } = require_constants();
787
- var { concat, toArrayBuffer, unmask } = require_buffer_util();
787
+ var { concat, toArrayBuffer: toArrayBuffer2, unmask } = require_buffer_util();
788
788
  var { isValidStatusCode, isValidUTF8 } = require_validation2();
789
789
  var FastBuffer = Buffer[Symbol.species];
790
790
  var GET_INFO = 0;
@@ -1263,7 +1263,7 @@ var require_receiver = __commonJS({
1263
1263
  if (this._binaryType === "nodebuffer") {
1264
1264
  data = concat(fragments, messageLength);
1265
1265
  } else if (this._binaryType === "arraybuffer") {
1266
- data = toArrayBuffer(concat(fragments, messageLength));
1266
+ data = toArrayBuffer2(concat(fragments, messageLength));
1267
1267
  } else if (this._binaryType === "blob") {
1268
1268
  data = new Blob(fragments);
1269
1269
  } else {
@@ -7394,7 +7394,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7394
7394
  }
7395
7395
  return propValues;
7396
7396
  });
7397
- const isObject2 = isObject;
7397
+ const isObject3 = isObject;
7398
7398
  const catchall = def.catchall;
7399
7399
  let value;
7400
7400
  const memo3 = globalConfig.memoizer;
@@ -7402,7 +7402,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
7402
7402
  inst._zod.parse = (payload, ctx) => {
7403
7403
  value ?? (value = _normalized.value);
7404
7404
  const input2 = payload.value;
7405
- if (!isObject2(input2)) {
7405
+ if (!isObject3(input2)) {
7406
7406
  payload.issues.push({
7407
7407
  expected: "object",
7408
7408
  code: "invalid_type",
@@ -7538,7 +7538,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7538
7538
  return doc.compile();
7539
7539
  };
7540
7540
  let fastpass;
7541
- const isObject2 = isObject;
7541
+ const isObject3 = isObject;
7542
7542
  const jit = !globalConfig.jitless;
7543
7543
  const allowsEval2 = allowsEval;
7544
7544
  const fastEnabled = jit && allowsEval2.value;
@@ -7547,7 +7547,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7547
7547
  inst._zod.parse = (payload, ctx) => {
7548
7548
  value ?? (value = _normalized.value);
7549
7549
  const input2 = payload.value;
7550
- if (!isObject2(input2)) {
7550
+ if (!isObject3(input2)) {
7551
7551
  payload.issues.push({
7552
7552
  expected: "object",
7553
7553
  code: "invalid_type",
@@ -8899,7 +8899,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
8899
8899
  var NONE = 0;
8900
8900
  var ASSUMED = 1;
8901
8901
  var PROVEN = 2;
8902
- function isRecursive(inst, stack, resolve7) {
8902
+ function isRecursive(inst, stack, resolve8) {
8903
8903
  const cached2 = recursive.get(inst);
8904
8904
  if (cached2 !== void 0)
8905
8905
  return cached2 ? PROVEN : NONE;
@@ -8909,7 +8909,7 @@ function isRecursive(inst, stack, resolve7) {
8909
8909
  let result = NONE;
8910
8910
  const check2 = (child) => {
8911
8911
  if (result !== PROVEN && child?._zod) {
8912
- const answer = isRecursive(child, stack, resolve7);
8912
+ const answer = isRecursive(child, stack, resolve8);
8913
8913
  if (answer > result)
8914
8914
  result = answer;
8915
8915
  }
@@ -8920,7 +8920,7 @@ function isRecursive(inst, stack, resolve7) {
8920
8920
  const desc = Object.getOwnPropertyDescriptor(sh, key);
8921
8921
  if (spread && !desc.enumerable)
8922
8922
  continue;
8923
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve7) : NONE;
8923
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve8) : NONE;
8924
8924
  if (child > answer)
8925
8925
  answer = child;
8926
8926
  }
@@ -8984,7 +8984,7 @@ function isRecursive(inst, stack, resolve7) {
8984
8984
  break;
8985
8985
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
8986
8986
  case "lazy": {
8987
- const inner = def._cachedInner ?? (resolve7 ? inst._zod.innerType : void 0);
8987
+ const inner = def._cachedInner ?? (resolve8 ? inst._zod.innerType : void 0);
8988
8988
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
8989
8989
  break;
8990
8990
  }
@@ -27946,14 +27946,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
27946
27946
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
27947
27947
  }
27948
27948
  function sleep(ms, signal) {
27949
- return new Promise((resolve7, reject) => {
27949
+ return new Promise((resolve8, reject) => {
27950
27950
  if (signal?.aborted) {
27951
27951
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
27952
27952
  return;
27953
27953
  }
27954
27954
  const timer = setTimeout(() => {
27955
27955
  signal?.removeEventListener("abort", onAbort);
27956
- resolve7();
27956
+ resolve8();
27957
27957
  }, ms);
27958
27958
  const onAbort = () => {
27959
27959
  clearTimeout(timer);
@@ -28752,7 +28752,7 @@ var Protocol = class {
28752
28752
  const flowStartedAt = Date.now();
28753
28753
  let onAbort;
28754
28754
  let cleanupMessageId;
28755
- return new Promise((resolve7, reject) => {
28755
+ return new Promise((resolve8, reject) => {
28756
28756
  const earlyReject = (error62) => {
28757
28757
  reject(error62);
28758
28758
  };
@@ -28821,7 +28821,7 @@ var Protocol = class {
28821
28821
  }
28822
28822
  if (decoded.kind === "invalid") return reject(decoded.error);
28823
28823
  if (decoded.kind === "input_required") {
28824
- if (options?.allowInputRequired === true) return resolve7(manualInputRequiredValue(decoded));
28824
+ if (options?.allowInputRequired === true) return resolve8(manualInputRequiredValue(decoded));
28825
28825
  const flow = {
28826
28826
  codec: codec2,
28827
28827
  request,
@@ -28833,11 +28833,11 @@ var Protocol = class {
28833
28833
  params
28834
28834
  }, resultSchema, legOptions)
28835
28835
  };
28836
- return resolve7(this._resolveNonCompleteResult(decoded, flow));
28836
+ return resolve8(this._resolveNonCompleteResult(decoded, flow));
28837
28837
  }
28838
28838
  const result = decoded.result;
28839
28839
  validateStandardSchema(resultSchema, result).then((parseResult) => {
28840
- if (parseResult.success) resolve7(parseResult.data);
28840
+ if (parseResult.success) resolve8(parseResult.data);
28841
28841
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request.method}: ${parseResult.error}`));
28842
28842
  }, reject);
28843
28843
  });
@@ -31753,7 +31753,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
31753
31753
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
31754
31754
  const schOrFunc = root.refs[ref];
31755
31755
  if (schOrFunc) return schOrFunc;
31756
- let _sch = resolve7.call(this, root, ref);
31756
+ let _sch = resolve8.call(this, root, ref);
31757
31757
  if (_sch === void 0) {
31758
31758
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
31759
31759
  const { schemaId } = this.opts;
@@ -31779,7 +31779,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
31779
31779
  function sameSchemaEnv(s1, s2) {
31780
31780
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
31781
31781
  }
31782
- function resolve7(root, ref) {
31782
+ function resolve8(root, ref) {
31783
31783
  let sch;
31784
31784
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
31785
31785
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -32229,7 +32229,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32229
32229
  else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
32230
32230
  return uri;
32231
32231
  }
32232
- function resolve7(baseURI, relativeURI, options) {
32232
+ function resolve8(baseURI, relativeURI, options) {
32233
32233
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
32234
32234
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
32235
32235
  schemelessOptions.skipEscape = true;
@@ -32403,7 +32403,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
32403
32403
  const fastUri = {
32404
32404
  SCHEMES,
32405
32405
  normalize,
32406
- resolve: resolve7,
32406
+ resolve: resolve8,
32407
32407
  resolveComponent,
32408
32408
  equal,
32409
32409
  serialize,
@@ -37865,7 +37865,7 @@ var StdioServerTransport = class {
37865
37865
  }
37866
37866
  send(message) {
37867
37867
  if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
37868
- return new Promise((resolve7, reject) => {
37868
+ return new Promise((resolve8, reject) => {
37869
37869
  const json2 = serializeMessage(message);
37870
37870
  let settled = false;
37871
37871
  const onError = (error62) => {
@@ -37880,14 +37880,14 @@ var StdioServerTransport = class {
37880
37880
  settled = true;
37881
37881
  this._stdout.off("error", onError);
37882
37882
  this._stdout.off("drain", onDrain);
37883
- resolve7();
37883
+ resolve8();
37884
37884
  };
37885
37885
  this._stdout.once("error", onError);
37886
37886
  if (this._stdout.write(json2)) {
37887
37887
  if (settled) return;
37888
37888
  settled = true;
37889
37889
  this._stdout.off("error", onError);
37890
- resolve7();
37890
+ resolve8();
37891
37891
  } else if (!settled) this._stdout.once("drain", onDrain);
37892
37892
  });
37893
37893
  }
@@ -37941,14 +37941,14 @@ var StdioConnectionChannel = class {
37941
37941
  */
37942
37942
  async whenRequestsAnswered(timeoutMs) {
37943
37943
  if (this._closed || this._pendingRequests.size === 0) return true;
37944
- return await new Promise((resolve7) => {
37944
+ return await new Promise((resolve8) => {
37945
37945
  const waiter = () => {
37946
37946
  clearTimeout(timer);
37947
- resolve7(true);
37947
+ resolve8(true);
37948
37948
  };
37949
37949
  const timer = setTimeout(() => {
37950
37950
  this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
37951
- resolve7(false);
37951
+ resolve8(false);
37952
37952
  }, timeoutMs);
37953
37953
  this._drainWaiters.push(waiter);
37954
37954
  });
@@ -40118,11 +40118,11 @@ async function withFileLock(lockPath, fn, opts = {}) {
40118
40118
  }
40119
40119
  if (r === "unlockable")
40120
40120
  break;
40121
- await new Promise((resolve7) => {
40121
+ await new Promise((resolve8) => {
40122
40122
  const done = () => {
40123
40123
  clearTimeout(timer);
40124
40124
  signal?.removeEventListener("abort", done);
40125
- resolve7();
40125
+ resolve8();
40126
40126
  };
40127
40127
  const timer = setTimeout(done, pollMs);
40128
40128
  signal?.addEventListener("abort", done, { once: true });
@@ -42431,7 +42431,7 @@ var DEFAULT_BIND_TIMEOUT_MS = 5e3;
42431
42431
  async function electRole(opts) {
42432
42432
  const server = createServer();
42433
42433
  const bindTimeoutMs = opts.bindTimeoutMs ?? DEFAULT_BIND_TIMEOUT_MS;
42434
- return new Promise((resolve7, reject) => {
42434
+ return new Promise((resolve8, reject) => {
42435
42435
  let timer;
42436
42436
  const clearBindTimer = () => {
42437
42437
  if (timer) {
@@ -42447,7 +42447,7 @@ async function electRole(opts) {
42447
42447
  server.close();
42448
42448
  } catch {
42449
42449
  }
42450
- resolve7({ role: "peer" });
42450
+ resolve8({ role: "peer" });
42451
42451
  } else {
42452
42452
  reject(e);
42453
42453
  }
@@ -42455,7 +42455,7 @@ async function electRole(opts) {
42455
42455
  const onListening = () => {
42456
42456
  clearBindTimer();
42457
42457
  server.removeListener("error", onError);
42458
- resolve7({ role: "host", server });
42458
+ resolve8({ role: "host", server });
42459
42459
  };
42460
42460
  server.once("error", onError);
42461
42461
  server.once("listening", onListening);
@@ -43346,10 +43346,10 @@ async function startHost(opts) {
43346
43346
  function resetSessionPromise() {
43347
43347
  ownRetryableRefusal = false;
43348
43348
  ownSessionSettled = false;
43349
- ownSessionReady = new Promise((resolve7, reject) => {
43349
+ ownSessionReady = new Promise((resolve8, reject) => {
43350
43350
  resolveOwnSession = (st) => {
43351
43351
  ownSessionSettled = true;
43352
- resolve7(st);
43352
+ resolve8(st);
43353
43353
  };
43354
43354
  rejectOwnSession = (e) => {
43355
43355
  ownSessionSettled = true;
@@ -43783,7 +43783,7 @@ async function startHost(opts) {
43783
43783
  });
43784
43784
  });
43785
43785
  return {
43786
- close: () => new Promise((resolve7) => {
43786
+ close: () => new Promise((resolve8) => {
43787
43787
  for (const client2 of wss.clients) {
43788
43788
  try {
43789
43789
  client2.terminate();
@@ -43791,7 +43791,7 @@ async function startHost(opts) {
43791
43791
  }
43792
43792
  }
43793
43793
  wss.close(() => {
43794
- opts.httpServer.close(() => resolve7());
43794
+ opts.httpServer.close(() => resolve8());
43795
43795
  });
43796
43796
  }),
43797
43797
  sendOwnInner: async (inner) => {
@@ -43833,11 +43833,11 @@ async function startPeer(opts) {
43833
43833
  maxPayload: opts.maxPayloadBytes ?? MAX_PAYLOAD_BYTES
43834
43834
  });
43835
43835
  const dialTimeoutMs = opts.dialTimeoutMs ?? PEER_DIAL_TIMEOUT_MS;
43836
- await new Promise((resolve7, reject) => {
43836
+ await new Promise((resolve8, reject) => {
43837
43837
  let timer;
43838
43838
  const onOpen = () => {
43839
43839
  cleanup();
43840
- resolve7();
43840
+ resolve8();
43841
43841
  };
43842
43842
  const onError = (e) => {
43843
43843
  cleanup();
@@ -43928,10 +43928,10 @@ async function startPeer(opts) {
43928
43928
  function resetSessionPromise() {
43929
43929
  retryableRefusal = false;
43930
43930
  sessionPromiseSettled = false;
43931
- sessionPromise = new Promise((resolve7, reject) => {
43931
+ sessionPromise = new Promise((resolve8, reject) => {
43932
43932
  resolveFirstReady = (st) => {
43933
43933
  sessionPromiseSettled = true;
43934
- resolve7(st);
43934
+ resolve8(st);
43935
43935
  };
43936
43936
  rejectFirstReady = (e) => {
43937
43937
  sessionPromiseSettled = true;
@@ -45163,8 +45163,8 @@ var FetchproxyServer = class {
45163
45163
  async _fetchOnceWithTimeout(init, fetchOpts = {}) {
45164
45164
  const id2 = this.nextRequestId++;
45165
45165
  const inner = { type: "request", id: id2, op: "fetch", init };
45166
- const pending = this.guardPending(new Promise((resolve7) => {
45167
- this.pending.set(id2, resolve7);
45166
+ const pending = this.guardPending(new Promise((resolve8) => {
45167
+ this.pending.set(id2, resolve8);
45168
45168
  }));
45169
45169
  try {
45170
45170
  await this.sendInnerFrame(inner, {
@@ -45196,13 +45196,13 @@ var FetchproxyServer = class {
45196
45196
  try {
45197
45197
  return await Promise.race([
45198
45198
  pending,
45199
- new Promise((resolve7) => {
45199
+ new Promise((resolve8) => {
45200
45200
  timer = setTimeout(() => {
45201
45201
  this.pending.delete(id2);
45202
45202
  const elapsedMs = Date.now() - start;
45203
45203
  const base = `fetchproxy: ${init.url} did not respond within ${timeoutMs}ms`;
45204
45204
  const error62 = isRetrySafeOnTimeout(init.method, fetchOpts.retryOnTimeout) ? base : withNotResentNote(base);
45205
- resolve7({
45205
+ resolve8({
45206
45206
  ok: false,
45207
45207
  error: error62,
45208
45208
  kind: "timeout",
@@ -45630,8 +45630,8 @@ var FetchproxyServer = class {
45630
45630
  const tabUrl = `https://${host}/`;
45631
45631
  inner = { type: "request", id: id2, op: "read_cookies", init: { tabUrl } };
45632
45632
  }
45633
- const pending = this.guardPending(new Promise((resolve7) => {
45634
- this.pendingReadCookies.set(id2, resolve7);
45633
+ const pending = this.guardPending(new Promise((resolve8) => {
45634
+ this.pendingReadCookies.set(id2, resolve8);
45635
45635
  }));
45636
45636
  await this.sendInnerFrame(inner);
45637
45637
  const result = await this._withVerbTimeout(pending, this.pendingReadCookies, id2, `https://${host}`);
@@ -45689,8 +45689,8 @@ var FetchproxyServer = class {
45689
45689
  ...cookiePath !== void 0 ? { path: cookiePath } : {}
45690
45690
  }
45691
45691
  };
45692
- const pending = this.guardPending(new Promise((resolve7, reject) => {
45693
- this.pendingWriteCookies.set(id2, { resolve: resolve7, reject });
45692
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
45693
+ this.pendingWriteCookies.set(id2, { resolve: resolve8, reject });
45694
45694
  }));
45695
45695
  await this.sendInnerFrame(inner);
45696
45696
  return this._withVerbTimeout(
@@ -45760,8 +45760,8 @@ var FetchproxyServer = class {
45760
45760
  ...opts.pointers ? { pointers: { ...opts.pointers } } : {}
45761
45761
  }
45762
45762
  };
45763
- const pending = this.guardPending(new Promise((resolve7, reject) => {
45764
- this.pendingStorage.set(id2, { resolve: resolve7, reject });
45763
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
45764
+ this.pendingStorage.set(id2, { resolve: resolve8, reject });
45765
45765
  }));
45766
45766
  await this.sendInnerFrame(inner);
45767
45767
  return this._withVerbTimeout(pending, this.pendingStorage, id2, `https://${host}`);
@@ -45819,8 +45819,8 @@ var FetchproxyServer = class {
45819
45819
  ...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {}
45820
45820
  }
45821
45821
  };
45822
- const pending = this.guardPending(new Promise((resolve7, reject) => {
45823
- this.pendingCapture.set(id2, { resolve: resolve7, reject });
45822
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
45823
+ this.pendingCapture.set(id2, { resolve: resolve8, reject });
45824
45824
  }));
45825
45825
  await this.sendInnerFrame(inner);
45826
45826
  return this._withVerbTimeout(
@@ -45867,8 +45867,8 @@ var FetchproxyServer = class {
45867
45867
  ...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {}
45868
45868
  }
45869
45869
  };
45870
- const pending = this.guardPending(new Promise((resolve7, reject) => {
45871
- this.pendingRedirect.set(id2, { resolve: resolve7, reject });
45870
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
45871
+ this.pendingRedirect.set(id2, { resolve: resolve8, reject });
45872
45872
  }));
45873
45873
  await this.sendInnerFrame(inner);
45874
45874
  return this._withVerbTimeout(
@@ -45963,8 +45963,8 @@ var FetchproxyServer = class {
45963
45963
  ...opts.timeoutMs !== void 0 ? { timeoutMs: opts.timeoutMs } : {}
45964
45964
  }
45965
45965
  };
45966
- const pending = this.guardPending(new Promise((resolve7, reject) => {
45967
- this.pendingDownload.set(id2, { resolve: resolve7, reject });
45966
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
45967
+ this.pendingDownload.set(id2, { resolve: resolve8, reject });
45968
45968
  }));
45969
45969
  await this.sendInnerFrame(inner);
45970
45970
  return this._withVerbTimeout(
@@ -46024,8 +46024,8 @@ var FetchproxyServer = class {
46024
46024
  keys: [...opts.keys]
46025
46025
  }
46026
46026
  };
46027
- const pending = this.guardPending(new Promise((resolve7, reject) => {
46028
- this.pendingIdb.set(id2, { resolve: resolve7, reject });
46027
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
46028
+ this.pendingIdb.set(id2, { resolve: resolve8, reject });
46029
46029
  }));
46030
46030
  await this.sendInnerFrame(inner);
46031
46031
  return this._withVerbTimeout(pending, this.pendingIdb, id2, origin);
@@ -46064,8 +46064,8 @@ var FetchproxyServer = class {
46064
46064
  op: "read_dom",
46065
46065
  init: { origin, names: [...opts.names] }
46066
46066
  };
46067
- const pending = this.guardPending(new Promise((resolve7, reject) => {
46068
- this.pendingStorage.set(id2, { resolve: resolve7, reject });
46067
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
46068
+ this.pendingStorage.set(id2, { resolve: resolve8, reject });
46069
46069
  }));
46070
46070
  await this.sendInnerFrame(inner);
46071
46071
  return this._withVerbTimeout(pending, this.pendingStorage, id2, origin);
@@ -46110,8 +46110,8 @@ var FetchproxyServer = class {
46110
46110
  op: "read_dom_list",
46111
46111
  init: { origin, name: opts.name }
46112
46112
  };
46113
- const pending = this.guardPending(new Promise((resolve7, reject) => {
46114
- this.pendingDomList.set(id2, { resolve: resolve7, reject });
46113
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
46114
+ this.pendingDomList.set(id2, { resolve: resolve8, reject });
46115
46115
  }));
46116
46116
  await this.sendInnerFrame(inner);
46117
46117
  return this._withVerbTimeout(pending, this.pendingDomList, id2, origin);
@@ -46156,8 +46156,8 @@ var FetchproxyServer = class {
46156
46156
  ...opts.tabUrl !== void 0 ? { tabUrl: opts.tabUrl } : {}
46157
46157
  }
46158
46158
  };
46159
- const pending = this.guardPending(new Promise((resolve7, reject) => {
46160
- this.pendingGraphql.set(id2, { resolve: resolve7, reject });
46159
+ const pending = this.guardPending(new Promise((resolve8, reject) => {
46160
+ this.pendingGraphql.set(id2, { resolve: resolve8, reject });
46161
46161
  }));
46162
46162
  const retrySafe = opts.retryOnTimeout === true;
46163
46163
  await this.sendInnerFrame(inner, { resendable: retrySafe });
@@ -47063,7 +47063,7 @@ function describeTokenlessLogin(record2) {
47063
47063
 
47064
47064
  // src/version.ts
47065
47065
  var SERVER_NAME = "ofw-mcp";
47066
- var VERSION = "2.22.0";
47066
+ var VERSION = "2.24.0";
47067
47067
 
47068
47068
  // src/auth.ts
47069
47069
  function fetchproxyDisabled() {
@@ -47437,6 +47437,17 @@ function displayTimeZone() {
47437
47437
  if (configured && isValidTimeZone(configured)) return configured;
47438
47438
  return DEFAULT_DISPLAY_TZ;
47439
47439
  }
47440
+ function resolveTimeZoneArg(tz) {
47441
+ const requested = tz?.trim();
47442
+ if (!requested) return displayTimeZone();
47443
+ if (/^(?:UTC|GMT)?[+-]\d/i.test(requested)) {
47444
+ throw new Error(`timeZone "${requested}" is a fixed offset, which is an hour wrong for half the year once DST changes. Pass an IANA zone such as America/Chicago.`);
47445
+ }
47446
+ if (!isValidTimeZone(requested)) {
47447
+ throw new Error(`timeZone "${requested}" is not a recognised IANA zone. Pass one such as America/Chicago or Europe/London.`);
47448
+ }
47449
+ return requested;
47450
+ }
47440
47451
  function offsetAt(instant, tz) {
47441
47452
  const w = wallPartsIn(instant, tz);
47442
47453
  const asUTC = Date.UTC(w.year, w.month - 1, w.day, w.hour, w.minute, w.second, instant.getUTCMilliseconds());
@@ -47646,12 +47657,12 @@ function normalizeTimestampsInValue(value, tz = displayTimeZone()) {
47646
47657
  }
47647
47658
 
47648
47659
  // src/tools/_shared.ts
47649
- function jsonResponse(data) {
47650
- return minifiedResult(normalizeTimestampsInValue(data));
47660
+ function jsonResponse(data, tz) {
47661
+ return minifiedResult(normalizeTimestampsInValue(data, tz));
47651
47662
  }
47652
47663
  var textResponse = rawTextResult;
47653
- function jsonText(data) {
47654
- return JSON.stringify(normalizeTimestampsInValue(data));
47664
+ function jsonText(data, tz) {
47665
+ return JSON.stringify(normalizeTimestampsInValue(data, tz));
47655
47666
  }
47656
47667
  function notedJsonResponse(notes, data, fallback) {
47657
47668
  const text = data ? jsonText(data) : fallback;
@@ -47714,7 +47725,6 @@ function withReadState(row) {
47714
47725
  const listData = typeof row.listData === "object" && row.listData !== null ? { ...row.listData, read, showNeverViewed: !read } : row.listData;
47715
47726
  return { ...row, read, listData };
47716
47727
  }
47717
- var expandPath2 = expandPath;
47718
47728
  function verifyWriteLanded(kind, sent, persisted) {
47719
47729
  const mismatches = [];
47720
47730
  if (typeof persisted.subject !== "string" || !persisted.subject.includes(sent.subject)) {
@@ -48465,6 +48475,17 @@ function getAllowMarkRead() {
48465
48475
  );
48466
48476
  return false;
48467
48477
  }
48478
+ function getConfirmMarkRead() {
48479
+ const raw = process.env.OFW_CONFIRM_MARK_READ;
48480
+ if (typeof raw !== "string" || raw.trim().length === 0) return false;
48481
+ const value = raw.trim().toLowerCase();
48482
+ if (["1", "true", "yes", "on"].includes(value)) return true;
48483
+ if (["0", "false", "no", "off"].includes(value)) return false;
48484
+ console.error(
48485
+ `[ofw-mcp] Unrecognized OFW_CONFIRM_MARK_READ "${raw.trim()}" \u2014 failing closed to "true" (opening an unread message asks for confirmation first). Valid values: true, false.`
48486
+ );
48487
+ return true;
48488
+ }
48468
48489
  function getFetchUnreadBodies() {
48469
48490
  return parseBoolEnv("OFW_FETCH_UNREAD_BODIES");
48470
48491
  }
@@ -49878,11 +49899,21 @@ async function extractAttachment(bytes, mimeType, fileName, opts = {}) {
49878
49899
 
49879
49900
  // src/tools/attachments.ts
49880
49901
  import { chmodSync as chmodSync3, readFileSync as readFileSync4, realpathSync as realpathSync3, statSync as statSync3, mkdirSync as mkdirSync5, unlinkSync as unlinkSync5 } from "node:fs";
49881
- import { basename as basename2, dirname as dirname6, extname, isAbsolute as isAbsolute6, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
49902
+ import { basename as basename2, dirname as dirname6, extname, isAbsolute as isAbsolute6, join as join11, relative as relative2, resolve as resolve5, sep as sep2 } from "node:path";
49882
49903
  function isWithin(root, candidate) {
49883
49904
  const rel = relative2(root, candidate);
49884
49905
  return rel !== "" && !rel.startsWith("..") && !isAbsolute6(rel);
49885
49906
  }
49907
+ function resolveSaveDest(root, saveTo, defaultName) {
49908
+ if (!saveTo) return join11(root, defaultName);
49909
+ const isDirArg = saveTo.endsWith("/") || saveTo.endsWith("\\");
49910
+ const abs = resolve5(root, saveTo.startsWith("~") ? expandPath(saveTo) : saveTo);
49911
+ const dest = isDirArg ? join11(abs, defaultName) : abs;
49912
+ if (!isWithin(root, dest)) {
49913
+ throw new Error(`Refusing to save to ${dest}: it is outside the attachments directory (${root}). Files can only be written inside it \u2014 pass a path or subdirectory under it, or set OFW_ATTACHMENTS_DIR to move it.`);
49914
+ }
49915
+ return dest;
49916
+ }
49886
49917
  var MIME_BY_EXT = {
49887
49918
  ".pdf": "application/pdf",
49888
49919
  ".png": "image/png",
@@ -50075,7 +50106,7 @@ async function buildInlineDelivery(input2) {
50075
50106
  }
50076
50107
 
50077
50108
  // src/tools/messages.ts
50078
- import { basename as basename3, join as join11, resolve as resolve6 } from "node:path";
50109
+ import { basename as basename3, resolve as resolve6 } from "node:path";
50079
50110
 
50080
50111
  // src/tools/pagination.ts
50081
50112
  function pageState(input2) {
@@ -50330,7 +50361,37 @@ function unverifiedEmptyResponse(input2) {
50330
50361
  });
50331
50362
  }
50332
50363
  function markReadPermitted() {
50333
- return getAllowMarkRead() && readingBlockedToday() === null;
50364
+ return getAllowMarkRead() && readingBlockedToday() === null && !getConfirmMarkRead();
50365
+ }
50366
+ async function confirmMarkRead(ctx, cached2, args) {
50367
+ if (!getConfirmMarkRead()) return void 0;
50368
+ if (cached2 !== null && !(cached2.folder === "inbox" && !deriveRead(cached2))) return void 0;
50369
+ if (cached2 === null) {
50370
+ return jsonErrorResponse({
50371
+ error: "MARK_READ_CONFIRMATION_UNAVAILABLE",
50372
+ messageId: Number(args.messageId),
50373
+ reason: "This server asks before opening an unread message (OFW_CONFIRM_MARK_READ), but this id is not in the cache, so there is no subject or time to show \u2014 and fetching them is the request that would mark it read.",
50374
+ hint: "Run ofw_sync_messages first: it walks list pages, not bodies, so it learns the subject and sent time without marking anything read. Then call ofw_get_message again."
50375
+ });
50376
+ }
50377
+ const when = normalizeTimestampsInValue({ sentAt: cached2.sentAt });
50378
+ return confirmWrite2(ctx, {
50379
+ args,
50380
+ tool: "ofw_get_message",
50381
+ action: "ofw.message.mark_read",
50382
+ message: `Open this unread OurFamilyWizard message and mark it read? "${cached2.subject}" \u2014 ${when.sentAtDisplay ?? cached2.sentAt}. Opening it stamps a "First Viewed" time your co-parent can see; that cannot be undone.`,
50383
+ target: `message:${cached2.id}`,
50384
+ payload: { messageId: cached2.id, markRead: true },
50385
+ preview: {
50386
+ action: "Open unread OurFamilyWizard message (marks it READ)",
50387
+ warning: 'Opening this message marks it read on OurFamilyWizard and stamps a "First Viewed" time your co-parent can see. It is part of the record and cannot be undone.',
50388
+ messageId: cached2.id,
50389
+ subject: cached2.subject,
50390
+ from: senderOf(cached2),
50391
+ ...when
50392
+ },
50393
+ confirmToken: args.confirmToken
50394
+ });
50334
50395
  }
50335
50396
  function withholdBody(row) {
50336
50397
  let listData = row.listData;
@@ -50497,16 +50558,17 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
50497
50558
  return jsonResponse(payload);
50498
50559
  });
50499
50560
  server.registerTool("ofw_get_message", {
50500
- description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW \u2014 and for an UNREAD INBOX message that fetch marks it read and stamps a "First Viewed" time the co-parent can see, which is part of the record and cannot be undone. Pass allowMarkRead:false to refuse such a fetch instead (cached bodies, sent messages and already-read messages are unaffected, because none of them stamp anything). For ids that match a draft (in the drafts cache), the response carries folder="drafts" and the body/subject/recipients reflect the drafts cache (which ofw_sync_messages keeps fresh) \u2014 drafts have no `fromUser`, and `sentAt`/`fetchedBodyAt` mirror the draft\'s `modifiedAt`. For inbox/sent messages, folder is "inbox" or "sent" as before. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) inbox/sent bodies are withheld (body:null, bodyWithheld:true, readingBlocked says when reading resumes) and OFW is never contacted.',
50561
+ description: 'Get a single OurFamilyWizard message OR draft by ID. Reads from local cache when available; otherwise fetches from OFW \u2014 and for an UNREAD INBOX message that fetch marks it read and stamps a "First Viewed" time the co-parent can see, which is part of the record and cannot be undone. Pass allowMarkRead:false to refuse such a fetch instead (cached bodies, sent messages and already-read messages are unaffected, because none of them stamp anything). For ids that match a draft (in the drafts cache), the response carries folder="drafts" and the body/subject/recipients reflect the drafts cache (which ofw_sync_messages keeps fresh) \u2014 drafts have no `fromUser`, and `sentAt`/`fetchedBodyAt` mirror the draft\'s `modifiedAt`. For inbox/sent messages, folder is "inbox" or "sent" as before. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) inbox/sent bodies are withheld (body:null, bodyWithheld:true, readingBlocked says when reading resumes) and OFW is never contacted. When the server runs with OFW_CONFIRM_MARK_READ=true, opening an unread inbox message first shows its subject, sender and sent time and asks the user to confirm marking it read: a confirmation prompt where the client supports one; otherwise the first call fetches NOTHING and returns that preview plus a confirmToken, and only a repeat call with that token opens the message (see MCP_CONFIRM_MODE). Show the user the preview and wait for their yes before repeating the call.',
50501
50562
  annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
50502
50563
  inputSchema: external_exports.object({
50503
50564
  messageId: external_exports.string().describe("Message ID (also accepts draft IDs \u2014 drafts are routed via the drafts cache)"),
50504
50565
  allowMarkRead: external_exports.boolean().describe("Default true (the long-standing behaviour). Set false to refuse a fetch that would mark an unread INBOX message as READ on OurFamilyWizard \u2014 an irreversible, co-parent-visible change to the record. Reads that cannot stamp anything (a cached body, a sent message, an already-read message) still succeed. The server-wide OFW_ALLOW_MARK_READ=false is a ceiling this argument cannot raise.").optional(),
50505
50566
  view: viewParam(MESSAGE_VIEWS, {
50506
50567
  note: "compact omits OurFamilyWizard's raw `listData` echo, which duplicates this record's own id, subject, sentAt, recipients and read flag; the sender is promoted to `from`, and `files`/`replied` are kept. Pass \"full\" for the echo."
50507
- })
50568
+ }),
50569
+ confirmToken: confirmTokenParam
50508
50570
  })
50509
- }, async (args) => {
50571
+ }, async (args, ctx) => {
50510
50572
  const id2 = Number(args.messageId);
50511
50573
  const view = resolveView(args.view, MESSAGE_VIEWS);
50512
50574
  const cache = cacheProvider();
@@ -50613,6 +50675,8 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
50613
50675
  }
50614
50676
  const markReadCheck = markReadVerdict(cached2, args.allowMarkRead);
50615
50677
  if (markReadCheck !== null) return markReadCheck;
50678
+ const confirmGate = await confirmMarkRead(ctx, cached2, args);
50679
+ if (confirmGate) return confirmGate;
50616
50680
  const detail = parseLenient(
50617
50681
  MessageDetailSchema,
50618
50682
  await client2.request("GET", `/pub/v3/messages/${encodeURIComponent(args.messageId)}`),
@@ -51453,19 +51517,9 @@ ${jsonText(
51453
51517
  diskAvailable: attachmentIO.supportsDisk
51454
51518
  });
51455
51519
  }
51456
- let dest;
51457
51520
  const safeName = basename3(cached2.fileName);
51458
51521
  const root = resolve6(getAttachmentsDir());
51459
- if (args.saveTo) {
51460
- const isDirArg = args.saveTo.endsWith("/") || args.saveTo.endsWith("\\");
51461
- const abs = resolve6(root, args.saveTo.startsWith("~") ? expandPath2(args.saveTo) : args.saveTo);
51462
- dest = isDirArg ? join11(abs, `${fileId}-${safeName}`) : abs;
51463
- if (!isWithin(root, dest)) {
51464
- throw new Error(`Refusing to save to ${dest}: it is outside the attachments directory (${root}). Downloads can only be written inside it \u2014 pass a path or subdirectory under it, or set OFW_ATTACHMENTS_DIR to move it.`);
51465
- }
51466
- } else {
51467
- dest = join11(root, `${fileId}-${safeName}`);
51468
- }
51522
+ const dest = resolveSaveDest(root, args.saveTo, `${fileId}-${safeName}`);
51469
51523
  const extractOnDisk = args.extract === true;
51470
51524
  if (!args.force && cached2.downloadedPath === dest) {
51471
51525
  const onDisk = extractOnDisk ? attachmentIO.readDownloaded(dest) : null;
@@ -51720,6 +51774,337 @@ async function deleteOFWMessages(client2, ids) {
51720
51774
  return client2.request("DELETE", "/pub/v1/messages", form);
51721
51775
  }
51722
51776
 
51777
+ // node_modules/@chrischall/mcp-utils/dist/export/blob.js
51778
+ import { createHmac as createHmac4 } from "node:crypto";
51779
+ var BLOB_DEFAULT_TTL_MS = 60 * 60 * 1e3;
51780
+ var BLOB_MAX_TTL_MS = 24 * 60 * 60 * 1e3;
51781
+ var MAX_KEY_LENGTH = 1024;
51782
+ var SAFE_SEGMENT = /^[A-Za-z0-9._~-]+$/;
51783
+ function configError(reason) {
51784
+ return new McpToolError(`MCP_BLOB_BASE_URL is not usable: ${reason}.`, {
51785
+ hint: "It should look like https://<host>/b/<registrationId> \u2014 check the deployment's environment.",
51786
+ kind: "unknown"
51787
+ });
51788
+ }
51789
+ function parseBase(baseUrl) {
51790
+ let parsed;
51791
+ try {
51792
+ parsed = new URL(baseUrl);
51793
+ } catch {
51794
+ throw configError("not a valid URL");
51795
+ }
51796
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
51797
+ throw configError("scheme must be http(s)");
51798
+ if (parsed.username || parsed.password)
51799
+ throw configError("must not contain credentials");
51800
+ if (parsed.search || parsed.hash)
51801
+ throw configError("must not contain a query or fragment");
51802
+ const path = parsed.pathname.replace(/^\/+|\/+$/g, "");
51803
+ const prefix = path.startsWith("b/") ? path.slice(2) : path;
51804
+ if (!prefix || prefix === "b")
51805
+ throw configError("has no registration path");
51806
+ return { base: `${parsed.origin}/${path}`, prefix };
51807
+ }
51808
+ function badInput(message) {
51809
+ return new McpToolError(message, { kind: "unknown" });
51810
+ }
51811
+ function encodeKey(key) {
51812
+ if (typeof key !== "string" || key.length === 0)
51813
+ throw badInput("Blob key must be a non-empty string.");
51814
+ if (key.length > MAX_KEY_LENGTH)
51815
+ throw badInput(`Blob key is longer than ${MAX_KEY_LENGTH} characters.`);
51816
+ const segments = key.split("/");
51817
+ for (const seg of segments) {
51818
+ if (seg === "" || seg === "." || seg === ".." || !SAFE_SEGMENT.test(seg)) {
51819
+ throw badInput('Blob key must be relative, slash-separated segments of [A-Za-z0-9._~-] with no empty, "." or ".." segment.');
51820
+ }
51821
+ }
51822
+ return segments.map(encodeURIComponent).join("/");
51823
+ }
51824
+ function checkContentType(contentType) {
51825
+ if (typeof contentType !== "string" || contentType.length === 0 || /[\x00-\x1f\x7f]/.test(contentType)) {
51826
+ throw badInput("Blob content type must be a non-empty string without control characters.");
51827
+ }
51828
+ }
51829
+ function expiry(opts) {
51830
+ const ttl = opts?.ttlMs ?? BLOB_DEFAULT_TTL_MS;
51831
+ if (!Number.isFinite(ttl) || ttl <= 0 || ttl > BLOB_MAX_TTL_MS) {
51832
+ throw badInput(`Blob link TTL must be between 1 ms and ${BLOB_MAX_TTL_MS} ms (24h); the gateway refuses longer.`);
51833
+ }
51834
+ return Math.floor((opts?.now ?? Date.now()) + ttl);
51835
+ }
51836
+ function toArrayBuffer(view) {
51837
+ const buf = view.buffer;
51838
+ if (buf instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === buf.byteLength)
51839
+ return buf;
51840
+ return view.slice().buffer;
51841
+ }
51842
+ function createBlobStore(opts) {
51843
+ const { base, prefix } = parseBase(opts.baseUrl);
51844
+ const signingKey = opts.signingKey;
51845
+ const sign2 = (payload) => createHmac4("sha256", signingKey).update(payload).digest("base64url");
51846
+ const link2 = (encodedKey, exp, sig) => `${base}/${encodedKey}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
51847
+ const signGetUrl = (key, o) => {
51848
+ const encoded = encodeKey(key);
51849
+ const exp = expiry(o);
51850
+ return { url: link2(encoded, exp, sign2(`${prefix}/${key}
51851
+ ${exp}`)), expiresAtMs: exp };
51852
+ };
51853
+ const signPutUrl = (key, contentType, o) => {
51854
+ const encoded = encodeKey(key);
51855
+ checkContentType(contentType);
51856
+ const exp = expiry(o);
51857
+ return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key}\0${contentType}\0${exp}`)), expiresAtMs: exp };
51858
+ };
51859
+ const put = async (key, body, contentType, o = {}) => {
51860
+ const { url: url2 } = signPutUrl(key, contentType, o);
51861
+ const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
51862
+ const doFetch = o.fetchImpl ?? fetch;
51863
+ let res;
51864
+ try {
51865
+ res = await doFetch(url2, {
51866
+ method: "PUT",
51867
+ headers: { "content-type": contentType },
51868
+ body: toArrayBuffer(bytes),
51869
+ ...o.signal ? { signal: o.signal } : {}
51870
+ });
51871
+ } catch (cause) {
51872
+ if (o.signal?.aborted)
51873
+ throw cause;
51874
+ throw new McpToolError(`Blob store upload of ${key} did not complete (network error).`, {
51875
+ kind: "transport"
51876
+ });
51877
+ }
51878
+ if (!res.ok) {
51879
+ throw new McpToolError(`Blob store upload of ${key} failed (HTTP ${res.status}).`, {
51880
+ kind: "http",
51881
+ status: res.status
51882
+ });
51883
+ }
51884
+ return { key, bytes: bytes.byteLength };
51885
+ };
51886
+ return { baseUrl: base, prefix, signGetUrl, signPutUrl, put };
51887
+ }
51888
+ function blobStoreFromEnv(env = process.env) {
51889
+ const baseUrl = readEnvVar("MCP_BLOB_BASE_URL", { env });
51890
+ const signingKey = readEnvVar("MCP_BLOB_SIGNING_KEY", { env });
51891
+ if (!baseUrl || !signingKey)
51892
+ return void 0;
51893
+ return createBlobStore({ baseUrl, signingKey });
51894
+ }
51895
+
51896
+ // node_modules/@chrischall/mcp-utils/dist/export/zip.js
51897
+ var CRC_TABLE = (() => {
51898
+ const table = new Uint32Array(256);
51899
+ for (let n = 0; n < 256; n++) {
51900
+ let c = n;
51901
+ for (let k = 0; k < 8; k++)
51902
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
51903
+ table[n] = c >>> 0;
51904
+ }
51905
+ return table;
51906
+ })();
51907
+
51908
+ // node_modules/@chrischall/mcp-utils/dist/export/sink.js
51909
+ var EXPORT_BLOB_MAX_BYTES = 256 * 1024 * 1024;
51910
+
51911
+ // src/tools/calendar.ts
51912
+ import { randomUUID as randomUUID2 } from "node:crypto";
51913
+ import { resolve as resolve7 } from "node:path";
51914
+
51915
+ // src/tools/calendar-ics.ts
51916
+ var CALENDAR_ITEM_TYPES = ["EVENT", "CONNECTED_EVENT", "TRANSITION", "SCHEDULE"];
51917
+ var isObject2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
51918
+ function itemsOf(data) {
51919
+ const items = isObject2(data) ? data.calendarItems : void 0;
51920
+ return Array.isArray(items) ? items.filter(isObject2) : [];
51921
+ }
51922
+ function filterCalendarTypes(data, types) {
51923
+ if (!types?.length || !isObject2(data)) return data;
51924
+ const wanted = new Set(types);
51925
+ const { calendarItems: _items, guardianData, ...rest } = data;
51926
+ const out = { ...rest };
51927
+ if (Array.isArray(data.calendarItems)) {
51928
+ out.calendarItems = data.calendarItems.filter((i) => isObject2(i) && wanted.has(String(i.type)));
51929
+ }
51930
+ if (wanted.has("SCHEDULE") && guardianData !== void 0) out.guardianData = guardianData;
51931
+ return out;
51932
+ }
51933
+ function escapeText(value) {
51934
+ return value.replace(/\\/g, "\\\\").replace(/\r\n|\r|\n/g, "\\n").replace(/;/g, "\\;").replace(/,/g, "\\,");
51935
+ }
51936
+ function fold(line) {
51937
+ const out = [];
51938
+ let current = "";
51939
+ let size = 0;
51940
+ for (const char of line) {
51941
+ const bytes = Buffer.byteLength(char, "utf8");
51942
+ if (size + bytes > 75) {
51943
+ out.push(current);
51944
+ current = " ";
51945
+ size = 1;
51946
+ }
51947
+ current += char;
51948
+ size += bytes;
51949
+ }
51950
+ out.push(current);
51951
+ return out.join("\r\n");
51952
+ }
51953
+ var utcStamp = (d) => d.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
51954
+ function dateTimeOf(item, field) {
51955
+ const value = item[field];
51956
+ return isObject2(value) && typeof value.dateTime === "string" ? value.dateTime : void 0;
51957
+ }
51958
+ function instantOf(item, field, tz) {
51959
+ const raw = dateTimeOf(item, field);
51960
+ return raw === void 0 ? null : parseTimestampValue(field, raw, tz);
51961
+ }
51962
+ function wallDateOf(item, field) {
51963
+ const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(dateTimeOf(item, field) ?? "");
51964
+ return m && parseTimestampValue(field, `${m[0]}T00:00:00`, "UTC") ? `${m[1]}${m[2]}${m[3]}` : null;
51965
+ }
51966
+ function nextDay(yyyymmdd) {
51967
+ const d = new Date(Date.UTC(Number(yyyymmdd.slice(0, 4)), Number(yyyymmdd.slice(4, 6)) - 1, Number(yyyymmdd.slice(6)) + 1));
51968
+ return d.toISOString().slice(0, 10).replace(/-/g, "");
51969
+ }
51970
+ var idOf = (item) => Number.isSafeInteger(item.id) && item.id > 0 ? item.id : null;
51971
+ function parentOf(value) {
51972
+ if (!isObject2(value) || typeof value.userId !== "number") return null;
51973
+ const name = typeof value.name === "string" && value.name.trim() ? value.name.trim() : `parent ${value.userId}`;
51974
+ return { userId: value.userId, name };
51975
+ }
51976
+ function buildCalendarIcs(data, opts) {
51977
+ const tz = opts.timeZone;
51978
+ const stamp = utcStamp(opts.now ?? /* @__PURE__ */ new Date());
51979
+ const omitted = [];
51980
+ const vevents = [];
51981
+ const issued = /* @__PURE__ */ new Map();
51982
+ let events = 0;
51983
+ let custodyPeriods = 0;
51984
+ const vevent = (uid, props) => ["BEGIN:VEVENT", `UID:${uid}@ofw-mcp`, `DTSTAMP:${stamp}`, ...props, "END:VEVENT"];
51985
+ const transitions = [];
51986
+ for (const item of itemsOf(data)) {
51987
+ const type = typeof item.type === "string" ? item.type : null;
51988
+ const id2 = type === "TRANSITION" ? null : idOf(item);
51989
+ const omit2 = (reason) => omitted.push({ type, id: id2, reason });
51990
+ if (type === "TRANSITION") {
51991
+ const at = instantOf(item, "startDate", tz);
51992
+ if (!at) {
51993
+ omit2("unreadable_time");
51994
+ continue;
51995
+ }
51996
+ transitions.push({ at, from: parentOf(item.transitionStartParent), to: parentOf(item.transitionEndParent) });
51997
+ continue;
51998
+ }
51999
+ if (type !== "EVENT" && type !== "CONNECTED_EVENT") {
52000
+ omit2("unsupported_type");
52001
+ continue;
52002
+ }
52003
+ if (id2 === null) {
52004
+ omit2("no_id");
52005
+ continue;
52006
+ }
52007
+ let when;
52008
+ let startKey;
52009
+ let signature;
52010
+ if (item.allDay === true) {
52011
+ const start = wallDateOf(item, "startDate");
52012
+ const end = wallDateOf(item, "endDate");
52013
+ if (!start || !end) {
52014
+ omit2("unreadable_time");
52015
+ continue;
52016
+ }
52017
+ if (end < start) {
52018
+ omit2("ends_before_start");
52019
+ continue;
52020
+ }
52021
+ when = [`DTSTART;VALUE=DATE:${start}`, `DTEND;VALUE=DATE:${nextDay(end)}`];
52022
+ startKey = start;
52023
+ signature = `${start}/${end}`;
52024
+ } else {
52025
+ const start = instantOf(item, "startDate", tz);
52026
+ const end = instantOf(item, "endDate", tz);
52027
+ if (!start || !end) {
52028
+ omit2("unreadable_time");
52029
+ continue;
52030
+ }
52031
+ if (end < start) {
52032
+ omit2("ends_before_start");
52033
+ continue;
52034
+ }
52035
+ when = [`DTSTART:${utcStamp(start)}`, `DTEND:${utcStamp(end)}`];
52036
+ startKey = utcStamp(start);
52037
+ signature = `${startKey}/${utcStamp(end)}`;
52038
+ }
52039
+ const title = typeof item.title === "string" && item.title.trim() ? item.title : "(untitled)";
52040
+ signature += `/${title}`;
52041
+ const base = type === "EVENT" ? `ofw-event-${id2}` : `ofw-connected-${String(item.connectedCalendarSubscriptionId ?? "unknown")}-${id2}`;
52042
+ let uid = item.repeating === true ? `${base}-${startKey}` : base;
52043
+ if (issued.has(uid)) {
52044
+ if (issued.get(uid) === signature) {
52045
+ omit2("duplicate");
52046
+ continue;
52047
+ }
52048
+ uid = `${base}-${startKey}`;
52049
+ if (issued.has(uid)) {
52050
+ omit2("duplicate");
52051
+ continue;
52052
+ }
52053
+ }
52054
+ issued.set(uid, signature);
52055
+ const props = [...when, `SUMMARY:${escapeText(title)}`];
52056
+ if (typeof item.location === "string" && item.location.trim()) props.push(`LOCATION:${escapeText(item.location)}`);
52057
+ if (typeof item.notes === "string" && item.notes.trim()) props.push(`DESCRIPTION:${escapeText(item.notes)}`);
52058
+ vevents.push(vevent(uid, props));
52059
+ events += 1;
52060
+ }
52061
+ transitions.sort((a, b) => a.at.getTime() - b.at.getTime());
52062
+ transitions.forEach((t, i) => {
52063
+ const owner = t.to;
52064
+ if (!owner) return;
52065
+ const next = transitions[i + 1];
52066
+ if (!next) {
52067
+ omitted.push({ type: "TRANSITION", id: null, reason: "no_end" });
52068
+ return;
52069
+ }
52070
+ if (next.from && next.from.userId !== owner.userId) {
52071
+ omitted.push({ type: "TRANSITION", id: null, reason: "handoff_mismatch" });
52072
+ return;
52073
+ }
52074
+ const clippedHead = t.from === null;
52075
+ const clippedTail = next.to === null;
52076
+ const uid = clippedHead ? `ofw-custody-${owner.userId}-until-${utcStamp(next.at)}` : `ofw-custody-${owner.userId}-${utcStamp(t.at)}`;
52077
+ const notes = [
52078
+ clippedHead ? "Starts before the exported range." : `Handoff from ${t.from.name}.`,
52079
+ ...clippedTail ? ["Continues past the exported range."] : []
52080
+ ];
52081
+ vevents.push(vevent(uid, [
52082
+ `DTSTART:${utcStamp(t.at)}`,
52083
+ `DTEND:${utcStamp(next.at)}`,
52084
+ `SUMMARY:${escapeText(`Parenting time: ${owner.name}`)}`,
52085
+ `DESCRIPTION:${escapeText(notes.join(" "))}`,
52086
+ "TRANSP:TRANSPARENT"
52087
+ ]));
52088
+ custodyPeriods += 1;
52089
+ });
52090
+ const lines = [
52091
+ "BEGIN:VCALENDAR",
52092
+ "VERSION:2.0",
52093
+ "PRODID:-//ofw-mcp//Calendar//EN",
52094
+ "CALSCALE:GREGORIAN",
52095
+ "METHOD:PUBLISH",
52096
+ "X-WR-CALNAME:OurFamilyWizard",
52097
+ `X-WR-TIMEZONE:${tz}`,
52098
+ ...vevents.flat(),
52099
+ "END:VCALENDAR"
52100
+ ];
52101
+ return {
52102
+ ics: lines.map(fold).join("\r\n") + "\r\n",
52103
+ counts: { events, custodyPeriods, omitted: omitted.length },
52104
+ omitted
52105
+ };
52106
+ }
52107
+
51723
52108
  // src/tools/calendar.ts
51724
52109
  var ofwDate = external_exports.looseObject({ dateTime: external_exports.string() });
51725
52110
  var userRef = external_exports.looseObject({ userId: external_exports.number() });
@@ -51827,23 +52212,108 @@ function namesIn(d) {
51827
52212
  }
51828
52213
  return names;
51829
52214
  }
51830
- function registerCalendarTools(server, client2) {
52215
+ var calendarRangeFields = {
52216
+ startDate: external_exports.string().describe("Start date YYYY-MM-DD"),
52217
+ endDate: external_exports.string().describe("End date YYYY-MM-DD"),
52218
+ types: external_exports.array(external_exports.enum(CALENDAR_ITEM_TYPES)).describe('Keep only these: EVENT, CONNECTED_EVENT (from a subscribed outside calendar), TRANSITION (custody handoffs; in .ics they become "Parenting time" periods), SCHEDULE (the per-day custody grid, JSON only). Default: everything').optional(),
52219
+ timeZone: external_exports.string().describe("IANA zone of the user's OFW account, e.g. America/Chicago. OFW reports wall-clock times with no zone; this is the zone they are read and shown in. Default: the server's DISPLAY_TZ").optional()
52220
+ };
52221
+ var detailedCalendarSchema = external_exports.looseObject({
52222
+ calendarItems: external_exports.array(external_exports.looseObject({ type: external_exports.string(), startDate: external_exports.looseObject({ dateTime: external_exports.string() }) }))
52223
+ });
52224
+ async function readDetailedCalendar(client2, startDate, endDate) {
52225
+ const path = `/pub/v1/calendar/detailed?startDate=${encodeURIComponent(startDate)}&endDate=${encodeURIComponent(endDate)}`;
52226
+ return parseLenient(detailedCalendarSchema, await client2.request("GET", path), { label: "ofw-mcp", context: "GET /pub/v1/calendar/detailed" });
52227
+ }
52228
+ function icsSummary(built, args, timeZone) {
52229
+ return {
52230
+ format: "ics",
52231
+ events: built.counts.events,
52232
+ custodyPeriods: built.counts.custodyPeriods,
52233
+ omittedCount: built.counts.omitted,
52234
+ startDate: args.startDate,
52235
+ endDate: args.endDate,
52236
+ timeZone,
52237
+ ...args.types?.length ? { types: args.types } : {},
52238
+ ...built.omitted.length ? { omitted: built.omitted } : {},
52239
+ snapshot: "Static: it does not update when OurFamilyWizard changes. Re-importing a later export updates events in place."
52240
+ };
52241
+ }
52242
+ function registerCalendarTools(server, client2, attachmentIO = new NodeAttachmentIO()) {
51831
52243
  const allowWrites = getCalendarWritesAllowed();
51832
52244
  server.registerTool("ofw_list_events", {
51833
- description: "List OurFamilyWizard calendar events in a date range",
52245
+ description: 'List OurFamilyWizard calendar items in a date range: events, connected (subscribed outside-calendar) events, custody handoffs (TRANSITION) and the per-day custody grid (guardianData, type SCHEDULE). Pass `types` to keep only some of them \u2014 the custody grid is most of a response\'s weight, so leave SCHEDULE out unless you need who-has-the-children per day. Times are OFW wall clock in the account\'s zone, rendered with an offset in `timeZone` (default: the server\'s DISPLAY_TZ). format:"ics" returns an iCalendar (.ics) text you can show or save \u2014 events, all-day events, and each custody period as a "Parenting time" event \u2014 after a short JSON summary of what was included and what was left out. To get a file or download link instead, use ofw_save_calendar_ics.',
51834
52246
  annotations: { readOnlyHint: true, openWorldHint: true },
51835
52247
  inputSchema: external_exports.object({
51836
- startDate: external_exports.string().describe("Start date YYYY-MM-DD"),
51837
- endDate: external_exports.string().describe("End date YYYY-MM-DD"),
51838
- detailed: external_exports.boolean().describe("Return full event details (default false)").optional()
52248
+ ...calendarRangeFields,
52249
+ detailed: external_exports.boolean().describe('Return full event details (default false). Ignored for format:"ics", which always reads the detailed calendar').optional(),
52250
+ format: external_exports.enum(["json", "ics"]).describe("json (default): the OFW payload. ics: a summary block, then the iCalendar text").optional()
51839
52251
  })
51840
52252
  }, async (args) => {
51841
- const variant = args.detailed ? "detailed" : "basic";
51842
- const data = await client2.request(
51843
- "GET",
51844
- `/pub/v1/calendar/${variant}?startDate=${encodeURIComponent(args.startDate)}&endDate=${encodeURIComponent(args.endDate)}`
51845
- );
51846
- return jsonResponse(data);
52253
+ const timeZone = resolveTimeZoneArg(args.timeZone);
52254
+ const ics = args.format === "ics";
52255
+ const raw = await (ics || args.detailed ? readDetailedCalendar(client2, args.startDate, args.endDate) : client2.request("GET", `/pub/v1/calendar/basic?startDate=${encodeURIComponent(args.startDate)}&endDate=${encodeURIComponent(args.endDate)}`));
52256
+ const data = filterCalendarTypes(raw, args.types);
52257
+ if (ics) {
52258
+ const built = buildCalendarIcs(data, { timeZone });
52259
+ return {
52260
+ content: [
52261
+ { type: "text", text: jsonText(icsSummary(built, args, timeZone), timeZone) },
52262
+ { type: "text", text: built.ics }
52263
+ ]
52264
+ };
52265
+ }
52266
+ return jsonResponse(data, timeZone);
52267
+ });
52268
+ server.registerTool("ofw_save_calendar_ics", {
52269
+ description: `Save an OurFamilyWizard date range as an iCalendar (.ics) file the user can import into Google, Apple or Outlook calendar \u2014 events, all-day events, and each custody period as a "Parenting time" event (OFW's own export leaves the parenting schedule out). Same filters as ofw_list_events. On a hosted connector the file is uploaded and you get a private download link that expires (default 1 hour); locally it is written inside the attachments directory (OFW_ATTACHMENTS_DIR, default ~/Downloads/ofw-mcp) and you get its path. Never overwrites an existing file. The file is a snapshot: it does not update when OFW changes, and re-importing a later export updates events in place (stable UIDs).`,
52270
+ // Additive: it adds a new local file (or a new uploaded object) and never
52271
+ // replaces one. Nothing reaches OFW.
52272
+ annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
52273
+ inputSchema: external_exports.object({
52274
+ ...calendarRangeFields,
52275
+ saveTo: external_exports.string().describe("Local installs only: path or directory (trailing /) INSIDE the attachments directory; relative paths resolve against it. Default: <attachments dir>/ofw-calendar-<start>_<end>-<time>.ics. Ignored on a hosted connector").optional(),
52276
+ linkMinutes: external_exports.number().int().min(1).max(1440).describe("Hosted connector only: how long the download link works, in minutes (default 60, max 1440)").optional()
52277
+ })
52278
+ }, async (args) => {
52279
+ const timeZone = resolveTimeZoneArg(args.timeZone);
52280
+ const data = filterCalendarTypes(await readDetailedCalendar(client2, args.startDate, args.endDate), args.types);
52281
+ const now = /* @__PURE__ */ new Date();
52282
+ const built = buildCalendarIcs(data, { timeZone, now });
52283
+ const summary = icsSummary(built, args, timeZone);
52284
+ const fileName = `ofw-calendar-${args.startDate}_${args.endDate}-${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z.ics`;
52285
+ const blob = blobStoreFromEnv();
52286
+ if (blob) {
52287
+ const key = `calendar/${randomUUID2()}/${fileName}`;
52288
+ await blob.put(key, built.ics, "text/calendar");
52289
+ const link2 = blob.signGetUrl(key, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
52290
+ return jsonResponse({
52291
+ delivered: "link",
52292
+ url: link2.url,
52293
+ expiresAt: formatInstant(new Date(link2.expiresAtMs), timeZone).iso,
52294
+ ...summary,
52295
+ note: `Private link to the .ics \u2014 anyone holding it can download the file until it expires, so give it only to the user.${args.saveTo ? " saveTo is ignored on a hosted connector." : ""}`
52296
+ }, timeZone);
52297
+ }
52298
+ if (!attachmentIO.supportsDisk) {
52299
+ return {
52300
+ content: [
52301
+ { type: "text", text: jsonText({ delivered: "inline", forcedInline: true, ...summary, note: "No disk or download store on this deployment, so the calendar is returned inline instead." }, timeZone) },
52302
+ { type: "text", text: built.ics }
52303
+ ]
52304
+ };
52305
+ }
52306
+ const root = resolve7(getAttachmentsDir());
52307
+ const path = resolveSaveDest(root, args.saveTo, fileName);
52308
+ try {
52309
+ await attachmentIO.writeDownload(path, Buffer.from(built.ics, "utf8"), { root, overwrite: false });
52310
+ } catch (e) {
52311
+ if (e instanceof Error && /already exists/.test(e.message)) {
52312
+ throw new Error(`Refusing to overwrite ${path}: a file already exists there. Choose another saveTo, or omit it for a fresh timestamped name.`);
52313
+ }
52314
+ throw e;
52315
+ }
52316
+ return jsonResponse({ delivered: "disk", path, ...summary }, timeZone);
51847
52317
  });
51848
52318
  if (allowWrites) server.registerTool("ofw_create_event", {
51849
52319
  description: "Create a calendar event in OurFamilyWizard. Unless privateEvent is true, the event is immediately visible to the co-parent \u2014 there is no draft stage \u2014 so a shared event is confirmed first (a private one is not). If the request fails without a definitive answer the result is EVENT_UNCONFIRMED: the event may already exist, so do NOT retry until ofw_list_events shows it did not land. " + CONFIRM_NOTE,
@@ -53352,11 +53822,12 @@ var nodeCacheProvider = () => nodeCache ??= OFWCache.open(getCacheDbPath());
53352
53822
  var nodeAttachmentIO = new NodeAttachmentIO();
53353
53823
  var expenseRegistrar = (server, deps) => registerExpenseTools(server, deps, nodeAttachmentIO);
53354
53824
  var messageRegistrar = (server, deps) => registerMessageTools(server, deps, nodeCacheProvider, nodeAttachmentIO);
53825
+ var calendarRegistrar = (server, deps) => registerCalendarTools(server, deps, nodeAttachmentIO);
53355
53826
  var tools = selectToolRegistrars({
53356
53827
  healthcheck: registerHealthcheckTools,
53357
53828
  user: registerUserTools,
53358
53829
  messages: messageRegistrar,
53359
- calendar: registerCalendarTools,
53830
+ calendar: calendarRegistrar,
53360
53831
  expenses: expenseRegistrar,
53361
53832
  journal: registerJournalTools
53362
53833
  });