ofw-mcp 2.22.0 → 2.23.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -1
- package/dist/bundle.js +523 -96
- package/dist/index.js +2 -1
- package/dist/timestamps.js +19 -0
- package/dist/tools/_shared.js +6 -4
- package/dist/tools/attachments.js +21 -1
- package/dist/tools/calendar-ics.js +250 -0
- package/dist/tools/calendar.js +122 -10
- package/dist/tools/messages.js +4 -18
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +2 -1
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
|
|
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 =
|
|
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
|
|
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 (!
|
|
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
|
|
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 (!
|
|
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,
|
|
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,
|
|
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,
|
|
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 ?? (
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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
|
|
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
|
|
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)
|
|
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 =
|
|
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
|
|
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
|
|
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:
|
|
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((
|
|
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
|
-
|
|
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
|
-
|
|
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((
|
|
37944
|
+
return await new Promise((resolve8) => {
|
|
37945
37945
|
const waiter = () => {
|
|
37946
37946
|
clearTimeout(timer);
|
|
37947
|
-
|
|
37947
|
+
resolve8(true);
|
|
37948
37948
|
};
|
|
37949
37949
|
const timer = setTimeout(() => {
|
|
37950
37950
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
37951
|
-
|
|
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((
|
|
40121
|
+
await new Promise((resolve8) => {
|
|
40122
40122
|
const done = () => {
|
|
40123
40123
|
clearTimeout(timer);
|
|
40124
40124
|
signal?.removeEventListener("abort", done);
|
|
40125
|
-
|
|
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((
|
|
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
|
-
|
|
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
|
-
|
|
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((
|
|
43349
|
+
ownSessionReady = new Promise((resolve8, reject) => {
|
|
43350
43350
|
resolveOwnSession = (st) => {
|
|
43351
43351
|
ownSessionSettled = true;
|
|
43352
|
-
|
|
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((
|
|
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(() =>
|
|
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((
|
|
43836
|
+
await new Promise((resolve8, reject) => {
|
|
43837
43837
|
let timer;
|
|
43838
43838
|
const onOpen = () => {
|
|
43839
43839
|
cleanup();
|
|
43840
|
-
|
|
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((
|
|
43931
|
+
sessionPromise = new Promise((resolve8, reject) => {
|
|
43932
43932
|
resolveFirstReady = (st) => {
|
|
43933
43933
|
sessionPromiseSettled = true;
|
|
43934
|
-
|
|
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((
|
|
45167
|
-
this.pending.set(id2,
|
|
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((
|
|
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
|
-
|
|
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((
|
|
45634
|
-
this.pendingReadCookies.set(id2,
|
|
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((
|
|
45693
|
-
this.pendingWriteCookies.set(id2, { resolve:
|
|
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((
|
|
45764
|
-
this.pendingStorage.set(id2, { resolve:
|
|
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((
|
|
45823
|
-
this.pendingCapture.set(id2, { resolve:
|
|
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((
|
|
45871
|
-
this.pendingRedirect.set(id2, { resolve:
|
|
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((
|
|
45967
|
-
this.pendingDownload.set(id2, { resolve:
|
|
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((
|
|
46028
|
-
this.pendingIdb.set(id2, { resolve:
|
|
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((
|
|
46068
|
-
this.pendingStorage.set(id2, { resolve:
|
|
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((
|
|
46114
|
-
this.pendingDomList.set(id2, { resolve:
|
|
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((
|
|
46160
|
-
this.pendingGraphql.set(id2, { resolve:
|
|
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.
|
|
47066
|
+
var VERSION = "2.23.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)) {
|
|
@@ -49878,11 +49888,21 @@ async function extractAttachment(bytes, mimeType, fileName, opts = {}) {
|
|
|
49878
49888
|
|
|
49879
49889
|
// src/tools/attachments.ts
|
|
49880
49890
|
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";
|
|
49891
|
+
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
49892
|
function isWithin(root, candidate) {
|
|
49883
49893
|
const rel = relative2(root, candidate);
|
|
49884
49894
|
return rel !== "" && !rel.startsWith("..") && !isAbsolute6(rel);
|
|
49885
49895
|
}
|
|
49896
|
+
function resolveSaveDest(root, saveTo, defaultName) {
|
|
49897
|
+
if (!saveTo) return join11(root, defaultName);
|
|
49898
|
+
const isDirArg = saveTo.endsWith("/") || saveTo.endsWith("\\");
|
|
49899
|
+
const abs = resolve5(root, saveTo.startsWith("~") ? expandPath(saveTo) : saveTo);
|
|
49900
|
+
const dest = isDirArg ? join11(abs, defaultName) : abs;
|
|
49901
|
+
if (!isWithin(root, dest)) {
|
|
49902
|
+
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.`);
|
|
49903
|
+
}
|
|
49904
|
+
return dest;
|
|
49905
|
+
}
|
|
49886
49906
|
var MIME_BY_EXT = {
|
|
49887
49907
|
".pdf": "application/pdf",
|
|
49888
49908
|
".png": "image/png",
|
|
@@ -50075,7 +50095,7 @@ async function buildInlineDelivery(input2) {
|
|
|
50075
50095
|
}
|
|
50076
50096
|
|
|
50077
50097
|
// src/tools/messages.ts
|
|
50078
|
-
import { basename as basename3,
|
|
50098
|
+
import { basename as basename3, resolve as resolve6 } from "node:path";
|
|
50079
50099
|
|
|
50080
50100
|
// src/tools/pagination.ts
|
|
50081
50101
|
function pageState(input2) {
|
|
@@ -51453,19 +51473,9 @@ ${jsonText(
|
|
|
51453
51473
|
diskAvailable: attachmentIO.supportsDisk
|
|
51454
51474
|
});
|
|
51455
51475
|
}
|
|
51456
|
-
let dest;
|
|
51457
51476
|
const safeName = basename3(cached2.fileName);
|
|
51458
51477
|
const root = resolve6(getAttachmentsDir());
|
|
51459
|
-
|
|
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
|
-
}
|
|
51478
|
+
const dest = resolveSaveDest(root, args.saveTo, `${fileId}-${safeName}`);
|
|
51469
51479
|
const extractOnDisk = args.extract === true;
|
|
51470
51480
|
if (!args.force && cached2.downloadedPath === dest) {
|
|
51471
51481
|
const onDisk = extractOnDisk ? attachmentIO.readDownloaded(dest) : null;
|
|
@@ -51720,6 +51730,337 @@ async function deleteOFWMessages(client2, ids) {
|
|
|
51720
51730
|
return client2.request("DELETE", "/pub/v1/messages", form);
|
|
51721
51731
|
}
|
|
51722
51732
|
|
|
51733
|
+
// node_modules/@chrischall/mcp-utils/dist/export/blob.js
|
|
51734
|
+
import { createHmac as createHmac4 } from "node:crypto";
|
|
51735
|
+
var BLOB_DEFAULT_TTL_MS = 60 * 60 * 1e3;
|
|
51736
|
+
var BLOB_MAX_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
51737
|
+
var MAX_KEY_LENGTH = 1024;
|
|
51738
|
+
var SAFE_SEGMENT = /^[A-Za-z0-9._~-]+$/;
|
|
51739
|
+
function configError(reason) {
|
|
51740
|
+
return new McpToolError(`MCP_BLOB_BASE_URL is not usable: ${reason}.`, {
|
|
51741
|
+
hint: "It should look like https://<host>/b/<registrationId> \u2014 check the deployment's environment.",
|
|
51742
|
+
kind: "unknown"
|
|
51743
|
+
});
|
|
51744
|
+
}
|
|
51745
|
+
function parseBase(baseUrl) {
|
|
51746
|
+
let parsed;
|
|
51747
|
+
try {
|
|
51748
|
+
parsed = new URL(baseUrl);
|
|
51749
|
+
} catch {
|
|
51750
|
+
throw configError("not a valid URL");
|
|
51751
|
+
}
|
|
51752
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
51753
|
+
throw configError("scheme must be http(s)");
|
|
51754
|
+
if (parsed.username || parsed.password)
|
|
51755
|
+
throw configError("must not contain credentials");
|
|
51756
|
+
if (parsed.search || parsed.hash)
|
|
51757
|
+
throw configError("must not contain a query or fragment");
|
|
51758
|
+
const path = parsed.pathname.replace(/^\/+|\/+$/g, "");
|
|
51759
|
+
const prefix = path.startsWith("b/") ? path.slice(2) : path;
|
|
51760
|
+
if (!prefix || prefix === "b")
|
|
51761
|
+
throw configError("has no registration path");
|
|
51762
|
+
return { base: `${parsed.origin}/${path}`, prefix };
|
|
51763
|
+
}
|
|
51764
|
+
function badInput(message) {
|
|
51765
|
+
return new McpToolError(message, { kind: "unknown" });
|
|
51766
|
+
}
|
|
51767
|
+
function encodeKey(key) {
|
|
51768
|
+
if (typeof key !== "string" || key.length === 0)
|
|
51769
|
+
throw badInput("Blob key must be a non-empty string.");
|
|
51770
|
+
if (key.length > MAX_KEY_LENGTH)
|
|
51771
|
+
throw badInput(`Blob key is longer than ${MAX_KEY_LENGTH} characters.`);
|
|
51772
|
+
const segments = key.split("/");
|
|
51773
|
+
for (const seg of segments) {
|
|
51774
|
+
if (seg === "" || seg === "." || seg === ".." || !SAFE_SEGMENT.test(seg)) {
|
|
51775
|
+
throw badInput('Blob key must be relative, slash-separated segments of [A-Za-z0-9._~-] with no empty, "." or ".." segment.');
|
|
51776
|
+
}
|
|
51777
|
+
}
|
|
51778
|
+
return segments.map(encodeURIComponent).join("/");
|
|
51779
|
+
}
|
|
51780
|
+
function checkContentType(contentType) {
|
|
51781
|
+
if (typeof contentType !== "string" || contentType.length === 0 || /[\x00-\x1f\x7f]/.test(contentType)) {
|
|
51782
|
+
throw badInput("Blob content type must be a non-empty string without control characters.");
|
|
51783
|
+
}
|
|
51784
|
+
}
|
|
51785
|
+
function expiry(opts) {
|
|
51786
|
+
const ttl = opts?.ttlMs ?? BLOB_DEFAULT_TTL_MS;
|
|
51787
|
+
if (!Number.isFinite(ttl) || ttl <= 0 || ttl > BLOB_MAX_TTL_MS) {
|
|
51788
|
+
throw badInput(`Blob link TTL must be between 1 ms and ${BLOB_MAX_TTL_MS} ms (24h); the gateway refuses longer.`);
|
|
51789
|
+
}
|
|
51790
|
+
return Math.floor((opts?.now ?? Date.now()) + ttl);
|
|
51791
|
+
}
|
|
51792
|
+
function toArrayBuffer(view) {
|
|
51793
|
+
const buf = view.buffer;
|
|
51794
|
+
if (buf instanceof ArrayBuffer && view.byteOffset === 0 && view.byteLength === buf.byteLength)
|
|
51795
|
+
return buf;
|
|
51796
|
+
return view.slice().buffer;
|
|
51797
|
+
}
|
|
51798
|
+
function createBlobStore(opts) {
|
|
51799
|
+
const { base, prefix } = parseBase(opts.baseUrl);
|
|
51800
|
+
const signingKey = opts.signingKey;
|
|
51801
|
+
const sign2 = (payload) => createHmac4("sha256", signingKey).update(payload).digest("base64url");
|
|
51802
|
+
const link2 = (encodedKey, exp, sig) => `${base}/${encodedKey}?exp=${exp}&sig=${encodeURIComponent(sig)}`;
|
|
51803
|
+
const signGetUrl = (key, o) => {
|
|
51804
|
+
const encoded = encodeKey(key);
|
|
51805
|
+
const exp = expiry(o);
|
|
51806
|
+
return { url: link2(encoded, exp, sign2(`${prefix}/${key}
|
|
51807
|
+
${exp}`)), expiresAtMs: exp };
|
|
51808
|
+
};
|
|
51809
|
+
const signPutUrl = (key, contentType, o) => {
|
|
51810
|
+
const encoded = encodeKey(key);
|
|
51811
|
+
checkContentType(contentType);
|
|
51812
|
+
const exp = expiry(o);
|
|
51813
|
+
return { url: link2(encoded, exp, sign2(`put\0${prefix}/${key}\0${contentType}\0${exp}`)), expiresAtMs: exp };
|
|
51814
|
+
};
|
|
51815
|
+
const put = async (key, body, contentType, o = {}) => {
|
|
51816
|
+
const { url: url2 } = signPutUrl(key, contentType, o);
|
|
51817
|
+
const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
|
|
51818
|
+
const doFetch = o.fetchImpl ?? fetch;
|
|
51819
|
+
let res;
|
|
51820
|
+
try {
|
|
51821
|
+
res = await doFetch(url2, {
|
|
51822
|
+
method: "PUT",
|
|
51823
|
+
headers: { "content-type": contentType },
|
|
51824
|
+
body: toArrayBuffer(bytes),
|
|
51825
|
+
...o.signal ? { signal: o.signal } : {}
|
|
51826
|
+
});
|
|
51827
|
+
} catch (cause) {
|
|
51828
|
+
if (o.signal?.aborted)
|
|
51829
|
+
throw cause;
|
|
51830
|
+
throw new McpToolError(`Blob store upload of ${key} did not complete (network error).`, {
|
|
51831
|
+
kind: "transport"
|
|
51832
|
+
});
|
|
51833
|
+
}
|
|
51834
|
+
if (!res.ok) {
|
|
51835
|
+
throw new McpToolError(`Blob store upload of ${key} failed (HTTP ${res.status}).`, {
|
|
51836
|
+
kind: "http",
|
|
51837
|
+
status: res.status
|
|
51838
|
+
});
|
|
51839
|
+
}
|
|
51840
|
+
return { key, bytes: bytes.byteLength };
|
|
51841
|
+
};
|
|
51842
|
+
return { baseUrl: base, prefix, signGetUrl, signPutUrl, put };
|
|
51843
|
+
}
|
|
51844
|
+
function blobStoreFromEnv(env = process.env) {
|
|
51845
|
+
const baseUrl = readEnvVar("MCP_BLOB_BASE_URL", { env });
|
|
51846
|
+
const signingKey = readEnvVar("MCP_BLOB_SIGNING_KEY", { env });
|
|
51847
|
+
if (!baseUrl || !signingKey)
|
|
51848
|
+
return void 0;
|
|
51849
|
+
return createBlobStore({ baseUrl, signingKey });
|
|
51850
|
+
}
|
|
51851
|
+
|
|
51852
|
+
// node_modules/@chrischall/mcp-utils/dist/export/zip.js
|
|
51853
|
+
var CRC_TABLE = (() => {
|
|
51854
|
+
const table = new Uint32Array(256);
|
|
51855
|
+
for (let n = 0; n < 256; n++) {
|
|
51856
|
+
let c = n;
|
|
51857
|
+
for (let k = 0; k < 8; k++)
|
|
51858
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
51859
|
+
table[n] = c >>> 0;
|
|
51860
|
+
}
|
|
51861
|
+
return table;
|
|
51862
|
+
})();
|
|
51863
|
+
|
|
51864
|
+
// node_modules/@chrischall/mcp-utils/dist/export/sink.js
|
|
51865
|
+
var EXPORT_BLOB_MAX_BYTES = 256 * 1024 * 1024;
|
|
51866
|
+
|
|
51867
|
+
// src/tools/calendar.ts
|
|
51868
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
51869
|
+
import { resolve as resolve7 } from "node:path";
|
|
51870
|
+
|
|
51871
|
+
// src/tools/calendar-ics.ts
|
|
51872
|
+
var CALENDAR_ITEM_TYPES = ["EVENT", "CONNECTED_EVENT", "TRANSITION", "SCHEDULE"];
|
|
51873
|
+
var isObject2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
51874
|
+
function itemsOf(data) {
|
|
51875
|
+
const items = isObject2(data) ? data.calendarItems : void 0;
|
|
51876
|
+
return Array.isArray(items) ? items.filter(isObject2) : [];
|
|
51877
|
+
}
|
|
51878
|
+
function filterCalendarTypes(data, types) {
|
|
51879
|
+
if (!types?.length || !isObject2(data)) return data;
|
|
51880
|
+
const wanted = new Set(types);
|
|
51881
|
+
const { calendarItems: _items, guardianData, ...rest } = data;
|
|
51882
|
+
const out = { ...rest };
|
|
51883
|
+
if (Array.isArray(data.calendarItems)) {
|
|
51884
|
+
out.calendarItems = data.calendarItems.filter((i) => isObject2(i) && wanted.has(String(i.type)));
|
|
51885
|
+
}
|
|
51886
|
+
if (wanted.has("SCHEDULE") && guardianData !== void 0) out.guardianData = guardianData;
|
|
51887
|
+
return out;
|
|
51888
|
+
}
|
|
51889
|
+
function escapeText(value) {
|
|
51890
|
+
return value.replace(/\\/g, "\\\\").replace(/\r\n|\r|\n/g, "\\n").replace(/;/g, "\\;").replace(/,/g, "\\,");
|
|
51891
|
+
}
|
|
51892
|
+
function fold(line) {
|
|
51893
|
+
const out = [];
|
|
51894
|
+
let current = "";
|
|
51895
|
+
let size = 0;
|
|
51896
|
+
for (const char of line) {
|
|
51897
|
+
const bytes = Buffer.byteLength(char, "utf8");
|
|
51898
|
+
if (size + bytes > 75) {
|
|
51899
|
+
out.push(current);
|
|
51900
|
+
current = " ";
|
|
51901
|
+
size = 1;
|
|
51902
|
+
}
|
|
51903
|
+
current += char;
|
|
51904
|
+
size += bytes;
|
|
51905
|
+
}
|
|
51906
|
+
out.push(current);
|
|
51907
|
+
return out.join("\r\n");
|
|
51908
|
+
}
|
|
51909
|
+
var utcStamp = (d) => d.toISOString().replace(/[-:]/g, "").replace(/\.\d{3}/, "");
|
|
51910
|
+
function dateTimeOf(item, field) {
|
|
51911
|
+
const value = item[field];
|
|
51912
|
+
return isObject2(value) && typeof value.dateTime === "string" ? value.dateTime : void 0;
|
|
51913
|
+
}
|
|
51914
|
+
function instantOf(item, field, tz) {
|
|
51915
|
+
const raw = dateTimeOf(item, field);
|
|
51916
|
+
return raw === void 0 ? null : parseTimestampValue(field, raw, tz);
|
|
51917
|
+
}
|
|
51918
|
+
function wallDateOf(item, field) {
|
|
51919
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(dateTimeOf(item, field) ?? "");
|
|
51920
|
+
return m && parseTimestampValue(field, `${m[0]}T00:00:00`, "UTC") ? `${m[1]}${m[2]}${m[3]}` : null;
|
|
51921
|
+
}
|
|
51922
|
+
function nextDay(yyyymmdd) {
|
|
51923
|
+
const d = new Date(Date.UTC(Number(yyyymmdd.slice(0, 4)), Number(yyyymmdd.slice(4, 6)) - 1, Number(yyyymmdd.slice(6)) + 1));
|
|
51924
|
+
return d.toISOString().slice(0, 10).replace(/-/g, "");
|
|
51925
|
+
}
|
|
51926
|
+
var idOf = (item) => Number.isSafeInteger(item.id) && item.id > 0 ? item.id : null;
|
|
51927
|
+
function parentOf(value) {
|
|
51928
|
+
if (!isObject2(value) || typeof value.userId !== "number") return null;
|
|
51929
|
+
const name = typeof value.name === "string" && value.name.trim() ? value.name.trim() : `parent ${value.userId}`;
|
|
51930
|
+
return { userId: value.userId, name };
|
|
51931
|
+
}
|
|
51932
|
+
function buildCalendarIcs(data, opts) {
|
|
51933
|
+
const tz = opts.timeZone;
|
|
51934
|
+
const stamp = utcStamp(opts.now ?? /* @__PURE__ */ new Date());
|
|
51935
|
+
const omitted = [];
|
|
51936
|
+
const vevents = [];
|
|
51937
|
+
const issued = /* @__PURE__ */ new Map();
|
|
51938
|
+
let events = 0;
|
|
51939
|
+
let custodyPeriods = 0;
|
|
51940
|
+
const vevent = (uid, props) => ["BEGIN:VEVENT", `UID:${uid}@ofw-mcp`, `DTSTAMP:${stamp}`, ...props, "END:VEVENT"];
|
|
51941
|
+
const transitions = [];
|
|
51942
|
+
for (const item of itemsOf(data)) {
|
|
51943
|
+
const type = typeof item.type === "string" ? item.type : null;
|
|
51944
|
+
const id2 = type === "TRANSITION" ? null : idOf(item);
|
|
51945
|
+
const omit2 = (reason) => omitted.push({ type, id: id2, reason });
|
|
51946
|
+
if (type === "TRANSITION") {
|
|
51947
|
+
const at = instantOf(item, "startDate", tz);
|
|
51948
|
+
if (!at) {
|
|
51949
|
+
omit2("unreadable_time");
|
|
51950
|
+
continue;
|
|
51951
|
+
}
|
|
51952
|
+
transitions.push({ at, from: parentOf(item.transitionStartParent), to: parentOf(item.transitionEndParent) });
|
|
51953
|
+
continue;
|
|
51954
|
+
}
|
|
51955
|
+
if (type !== "EVENT" && type !== "CONNECTED_EVENT") {
|
|
51956
|
+
omit2("unsupported_type");
|
|
51957
|
+
continue;
|
|
51958
|
+
}
|
|
51959
|
+
if (id2 === null) {
|
|
51960
|
+
omit2("no_id");
|
|
51961
|
+
continue;
|
|
51962
|
+
}
|
|
51963
|
+
let when;
|
|
51964
|
+
let startKey;
|
|
51965
|
+
let signature;
|
|
51966
|
+
if (item.allDay === true) {
|
|
51967
|
+
const start = wallDateOf(item, "startDate");
|
|
51968
|
+
const end = wallDateOf(item, "endDate");
|
|
51969
|
+
if (!start || !end) {
|
|
51970
|
+
omit2("unreadable_time");
|
|
51971
|
+
continue;
|
|
51972
|
+
}
|
|
51973
|
+
if (end < start) {
|
|
51974
|
+
omit2("ends_before_start");
|
|
51975
|
+
continue;
|
|
51976
|
+
}
|
|
51977
|
+
when = [`DTSTART;VALUE=DATE:${start}`, `DTEND;VALUE=DATE:${nextDay(end)}`];
|
|
51978
|
+
startKey = start;
|
|
51979
|
+
signature = `${start}/${end}`;
|
|
51980
|
+
} else {
|
|
51981
|
+
const start = instantOf(item, "startDate", tz);
|
|
51982
|
+
const end = instantOf(item, "endDate", tz);
|
|
51983
|
+
if (!start || !end) {
|
|
51984
|
+
omit2("unreadable_time");
|
|
51985
|
+
continue;
|
|
51986
|
+
}
|
|
51987
|
+
if (end < start) {
|
|
51988
|
+
omit2("ends_before_start");
|
|
51989
|
+
continue;
|
|
51990
|
+
}
|
|
51991
|
+
when = [`DTSTART:${utcStamp(start)}`, `DTEND:${utcStamp(end)}`];
|
|
51992
|
+
startKey = utcStamp(start);
|
|
51993
|
+
signature = `${startKey}/${utcStamp(end)}`;
|
|
51994
|
+
}
|
|
51995
|
+
const title = typeof item.title === "string" && item.title.trim() ? item.title : "(untitled)";
|
|
51996
|
+
signature += `/${title}`;
|
|
51997
|
+
const base = type === "EVENT" ? `ofw-event-${id2}` : `ofw-connected-${String(item.connectedCalendarSubscriptionId ?? "unknown")}-${id2}`;
|
|
51998
|
+
let uid = item.repeating === true ? `${base}-${startKey}` : base;
|
|
51999
|
+
if (issued.has(uid)) {
|
|
52000
|
+
if (issued.get(uid) === signature) {
|
|
52001
|
+
omit2("duplicate");
|
|
52002
|
+
continue;
|
|
52003
|
+
}
|
|
52004
|
+
uid = `${base}-${startKey}`;
|
|
52005
|
+
if (issued.has(uid)) {
|
|
52006
|
+
omit2("duplicate");
|
|
52007
|
+
continue;
|
|
52008
|
+
}
|
|
52009
|
+
}
|
|
52010
|
+
issued.set(uid, signature);
|
|
52011
|
+
const props = [...when, `SUMMARY:${escapeText(title)}`];
|
|
52012
|
+
if (typeof item.location === "string" && item.location.trim()) props.push(`LOCATION:${escapeText(item.location)}`);
|
|
52013
|
+
if (typeof item.notes === "string" && item.notes.trim()) props.push(`DESCRIPTION:${escapeText(item.notes)}`);
|
|
52014
|
+
vevents.push(vevent(uid, props));
|
|
52015
|
+
events += 1;
|
|
52016
|
+
}
|
|
52017
|
+
transitions.sort((a, b) => a.at.getTime() - b.at.getTime());
|
|
52018
|
+
transitions.forEach((t, i) => {
|
|
52019
|
+
const owner = t.to;
|
|
52020
|
+
if (!owner) return;
|
|
52021
|
+
const next = transitions[i + 1];
|
|
52022
|
+
if (!next) {
|
|
52023
|
+
omitted.push({ type: "TRANSITION", id: null, reason: "no_end" });
|
|
52024
|
+
return;
|
|
52025
|
+
}
|
|
52026
|
+
if (next.from && next.from.userId !== owner.userId) {
|
|
52027
|
+
omitted.push({ type: "TRANSITION", id: null, reason: "handoff_mismatch" });
|
|
52028
|
+
return;
|
|
52029
|
+
}
|
|
52030
|
+
const clippedHead = t.from === null;
|
|
52031
|
+
const clippedTail = next.to === null;
|
|
52032
|
+
const uid = clippedHead ? `ofw-custody-${owner.userId}-until-${utcStamp(next.at)}` : `ofw-custody-${owner.userId}-${utcStamp(t.at)}`;
|
|
52033
|
+
const notes = [
|
|
52034
|
+
clippedHead ? "Starts before the exported range." : `Handoff from ${t.from.name}.`,
|
|
52035
|
+
...clippedTail ? ["Continues past the exported range."] : []
|
|
52036
|
+
];
|
|
52037
|
+
vevents.push(vevent(uid, [
|
|
52038
|
+
`DTSTART:${utcStamp(t.at)}`,
|
|
52039
|
+
`DTEND:${utcStamp(next.at)}`,
|
|
52040
|
+
`SUMMARY:${escapeText(`Parenting time: ${owner.name}`)}`,
|
|
52041
|
+
`DESCRIPTION:${escapeText(notes.join(" "))}`,
|
|
52042
|
+
"TRANSP:TRANSPARENT"
|
|
52043
|
+
]));
|
|
52044
|
+
custodyPeriods += 1;
|
|
52045
|
+
});
|
|
52046
|
+
const lines = [
|
|
52047
|
+
"BEGIN:VCALENDAR",
|
|
52048
|
+
"VERSION:2.0",
|
|
52049
|
+
"PRODID:-//ofw-mcp//Calendar//EN",
|
|
52050
|
+
"CALSCALE:GREGORIAN",
|
|
52051
|
+
"METHOD:PUBLISH",
|
|
52052
|
+
"X-WR-CALNAME:OurFamilyWizard",
|
|
52053
|
+
`X-WR-TIMEZONE:${tz}`,
|
|
52054
|
+
...vevents.flat(),
|
|
52055
|
+
"END:VCALENDAR"
|
|
52056
|
+
];
|
|
52057
|
+
return {
|
|
52058
|
+
ics: lines.map(fold).join("\r\n") + "\r\n",
|
|
52059
|
+
counts: { events, custodyPeriods, omitted: omitted.length },
|
|
52060
|
+
omitted
|
|
52061
|
+
};
|
|
52062
|
+
}
|
|
52063
|
+
|
|
51723
52064
|
// src/tools/calendar.ts
|
|
51724
52065
|
var ofwDate = external_exports.looseObject({ dateTime: external_exports.string() });
|
|
51725
52066
|
var userRef = external_exports.looseObject({ userId: external_exports.number() });
|
|
@@ -51827,23 +52168,108 @@ function namesIn(d) {
|
|
|
51827
52168
|
}
|
|
51828
52169
|
return names;
|
|
51829
52170
|
}
|
|
51830
|
-
|
|
52171
|
+
var calendarRangeFields = {
|
|
52172
|
+
startDate: external_exports.string().describe("Start date YYYY-MM-DD"),
|
|
52173
|
+
endDate: external_exports.string().describe("End date YYYY-MM-DD"),
|
|
52174
|
+
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(),
|
|
52175
|
+
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()
|
|
52176
|
+
};
|
|
52177
|
+
var detailedCalendarSchema = external_exports.looseObject({
|
|
52178
|
+
calendarItems: external_exports.array(external_exports.looseObject({ type: external_exports.string(), startDate: external_exports.looseObject({ dateTime: external_exports.string() }) }))
|
|
52179
|
+
});
|
|
52180
|
+
async function readDetailedCalendar(client2, startDate, endDate) {
|
|
52181
|
+
const path = `/pub/v1/calendar/detailed?startDate=${encodeURIComponent(startDate)}&endDate=${encodeURIComponent(endDate)}`;
|
|
52182
|
+
return parseLenient(detailedCalendarSchema, await client2.request("GET", path), { label: "ofw-mcp", context: "GET /pub/v1/calendar/detailed" });
|
|
52183
|
+
}
|
|
52184
|
+
function icsSummary(built, args, timeZone) {
|
|
52185
|
+
return {
|
|
52186
|
+
format: "ics",
|
|
52187
|
+
events: built.counts.events,
|
|
52188
|
+
custodyPeriods: built.counts.custodyPeriods,
|
|
52189
|
+
omittedCount: built.counts.omitted,
|
|
52190
|
+
startDate: args.startDate,
|
|
52191
|
+
endDate: args.endDate,
|
|
52192
|
+
timeZone,
|
|
52193
|
+
...args.types?.length ? { types: args.types } : {},
|
|
52194
|
+
...built.omitted.length ? { omitted: built.omitted } : {},
|
|
52195
|
+
snapshot: "Static: it does not update when OurFamilyWizard changes. Re-importing a later export updates events in place."
|
|
52196
|
+
};
|
|
52197
|
+
}
|
|
52198
|
+
function registerCalendarTools(server, client2, attachmentIO = new NodeAttachmentIO()) {
|
|
51831
52199
|
const allowWrites = getCalendarWritesAllowed();
|
|
51832
52200
|
server.registerTool("ofw_list_events", {
|
|
51833
|
-
description:
|
|
52201
|
+
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
52202
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
51835
52203
|
inputSchema: external_exports.object({
|
|
51836
|
-
|
|
51837
|
-
|
|
51838
|
-
|
|
52204
|
+
...calendarRangeFields,
|
|
52205
|
+
detailed: external_exports.boolean().describe('Return full event details (default false). Ignored for format:"ics", which always reads the detailed calendar').optional(),
|
|
52206
|
+
format: external_exports.enum(["json", "ics"]).describe("json (default): the OFW payload. ics: a summary block, then the iCalendar text").optional()
|
|
51839
52207
|
})
|
|
51840
52208
|
}, async (args) => {
|
|
51841
|
-
const
|
|
51842
|
-
const
|
|
51843
|
-
|
|
51844
|
-
|
|
51845
|
-
)
|
|
51846
|
-
|
|
52209
|
+
const timeZone = resolveTimeZoneArg(args.timeZone);
|
|
52210
|
+
const ics = args.format === "ics";
|
|
52211
|
+
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)}`));
|
|
52212
|
+
const data = filterCalendarTypes(raw, args.types);
|
|
52213
|
+
if (ics) {
|
|
52214
|
+
const built = buildCalendarIcs(data, { timeZone });
|
|
52215
|
+
return {
|
|
52216
|
+
content: [
|
|
52217
|
+
{ type: "text", text: jsonText(icsSummary(built, args, timeZone), timeZone) },
|
|
52218
|
+
{ type: "text", text: built.ics }
|
|
52219
|
+
]
|
|
52220
|
+
};
|
|
52221
|
+
}
|
|
52222
|
+
return jsonResponse(data, timeZone);
|
|
52223
|
+
});
|
|
52224
|
+
server.registerTool("ofw_save_calendar_ics", {
|
|
52225
|
+
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).`,
|
|
52226
|
+
// Additive: it adds a new local file (or a new uploaded object) and never
|
|
52227
|
+
// replaces one. Nothing reaches OFW.
|
|
52228
|
+
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
52229
|
+
inputSchema: external_exports.object({
|
|
52230
|
+
...calendarRangeFields,
|
|
52231
|
+
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(),
|
|
52232
|
+
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()
|
|
52233
|
+
})
|
|
52234
|
+
}, async (args) => {
|
|
52235
|
+
const timeZone = resolveTimeZoneArg(args.timeZone);
|
|
52236
|
+
const data = filterCalendarTypes(await readDetailedCalendar(client2, args.startDate, args.endDate), args.types);
|
|
52237
|
+
const now = /* @__PURE__ */ new Date();
|
|
52238
|
+
const built = buildCalendarIcs(data, { timeZone, now });
|
|
52239
|
+
const summary = icsSummary(built, args, timeZone);
|
|
52240
|
+
const fileName = `ofw-calendar-${args.startDate}_${args.endDate}-${now.toISOString().replace(/[-:]/g, "").slice(0, 15)}Z.ics`;
|
|
52241
|
+
const blob = blobStoreFromEnv();
|
|
52242
|
+
if (blob) {
|
|
52243
|
+
const key = `calendar/${randomUUID2()}/${fileName}`;
|
|
52244
|
+
await blob.put(key, built.ics, "text/calendar");
|
|
52245
|
+
const link2 = blob.signGetUrl(key, { ttlMs: (args.linkMinutes ?? 60) * 6e4 });
|
|
52246
|
+
return jsonResponse({
|
|
52247
|
+
delivered: "link",
|
|
52248
|
+
url: link2.url,
|
|
52249
|
+
expiresAt: formatInstant(new Date(link2.expiresAtMs), timeZone).iso,
|
|
52250
|
+
...summary,
|
|
52251
|
+
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." : ""}`
|
|
52252
|
+
}, timeZone);
|
|
52253
|
+
}
|
|
52254
|
+
if (!attachmentIO.supportsDisk) {
|
|
52255
|
+
return {
|
|
52256
|
+
content: [
|
|
52257
|
+
{ 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) },
|
|
52258
|
+
{ type: "text", text: built.ics }
|
|
52259
|
+
]
|
|
52260
|
+
};
|
|
52261
|
+
}
|
|
52262
|
+
const root = resolve7(getAttachmentsDir());
|
|
52263
|
+
const path = resolveSaveDest(root, args.saveTo, fileName);
|
|
52264
|
+
try {
|
|
52265
|
+
await attachmentIO.writeDownload(path, Buffer.from(built.ics, "utf8"), { root, overwrite: false });
|
|
52266
|
+
} catch (e) {
|
|
52267
|
+
if (e instanceof Error && /already exists/.test(e.message)) {
|
|
52268
|
+
throw new Error(`Refusing to overwrite ${path}: a file already exists there. Choose another saveTo, or omit it for a fresh timestamped name.`);
|
|
52269
|
+
}
|
|
52270
|
+
throw e;
|
|
52271
|
+
}
|
|
52272
|
+
return jsonResponse({ delivered: "disk", path, ...summary }, timeZone);
|
|
51847
52273
|
});
|
|
51848
52274
|
if (allowWrites) server.registerTool("ofw_create_event", {
|
|
51849
52275
|
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 +53778,12 @@ var nodeCacheProvider = () => nodeCache ??= OFWCache.open(getCacheDbPath());
|
|
|
53352
53778
|
var nodeAttachmentIO = new NodeAttachmentIO();
|
|
53353
53779
|
var expenseRegistrar = (server, deps) => registerExpenseTools(server, deps, nodeAttachmentIO);
|
|
53354
53780
|
var messageRegistrar = (server, deps) => registerMessageTools(server, deps, nodeCacheProvider, nodeAttachmentIO);
|
|
53781
|
+
var calendarRegistrar = (server, deps) => registerCalendarTools(server, deps, nodeAttachmentIO);
|
|
53355
53782
|
var tools = selectToolRegistrars({
|
|
53356
53783
|
healthcheck: registerHealthcheckTools,
|
|
53357
53784
|
user: registerUserTools,
|
|
53358
53785
|
messages: messageRegistrar,
|
|
53359
|
-
calendar:
|
|
53786
|
+
calendar: calendarRegistrar,
|
|
53360
53787
|
expenses: expenseRegistrar,
|
|
53361
53788
|
journal: registerJournalTools
|
|
53362
53789
|
});
|