ofw-mcp 2.29.0 → 2.30.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 -2
- package/dist/bundle.js +700 -98
- package/dist/sync.js +23 -10
- package/dist/timestamps.js +4 -0
- package/dist/tools/_shared.js +71 -15
- package/dist/tools/folder-messages.js +198 -0
- package/dist/tools/messages.js +213 -39
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/ofw/SKILL.md +4 -4
package/dist/bundle.js
CHANGED
|
@@ -67,6 +67,7 @@ var require_constants = __commonJS({
|
|
|
67
67
|
var require_buffer_util = __commonJS({
|
|
68
68
|
"node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
69
69
|
"use strict";
|
|
70
|
+
var { websocketMask, websocketUnmask } = __require("http");
|
|
70
71
|
var { EMPTY_BUFFER } = require_constants();
|
|
71
72
|
var FastBuffer = Buffer[Symbol.species];
|
|
72
73
|
function concat(list, totalLength) {
|
|
@@ -121,7 +122,16 @@ var require_buffer_util = __commonJS({
|
|
|
121
122
|
toBuffer,
|
|
122
123
|
unmask: _unmask
|
|
123
124
|
};
|
|
124
|
-
if (
|
|
125
|
+
if (websocketMask) {
|
|
126
|
+
module.exports.mask = function(source, mask, output2, offset, length) {
|
|
127
|
+
if (length < 24) _mask(source, mask, output2, offset, length);
|
|
128
|
+
else websocketMask(source, mask, output2, offset, length);
|
|
129
|
+
};
|
|
130
|
+
module.exports.unmask = function(buffer, mask) {
|
|
131
|
+
if (buffer.length < 24) _unmask(buffer, mask);
|
|
132
|
+
else websocketUnmask(buffer, mask);
|
|
133
|
+
};
|
|
134
|
+
} else if (false) {
|
|
125
135
|
try {
|
|
126
136
|
const bufferUtil = null;
|
|
127
137
|
module.exports.mask = function(source, mask, output2, offset, length) {
|
|
@@ -1184,6 +1194,7 @@ var require_receiver = __commonJS({
|
|
|
1184
1194
|
unmask(data, this._mask);
|
|
1185
1195
|
}
|
|
1186
1196
|
}
|
|
1197
|
+
this._mask = void 0;
|
|
1187
1198
|
if (this._opcode > 7) {
|
|
1188
1199
|
this.controlMessage(data, cb);
|
|
1189
1200
|
return;
|
|
@@ -1516,12 +1527,15 @@ var require_sender = __commonJS({
|
|
|
1516
1527
|
target[2] = target[3] = 0;
|
|
1517
1528
|
target.writeUIntBE(dataLength, 4, 6);
|
|
1518
1529
|
}
|
|
1519
|
-
if (!options.mask)
|
|
1530
|
+
if (!options.mask) {
|
|
1531
|
+
return dataLength ? [target, data] : [target];
|
|
1532
|
+
}
|
|
1520
1533
|
target[1] |= 128;
|
|
1521
1534
|
target[offset - 4] = mask[0];
|
|
1522
1535
|
target[offset - 3] = mask[1];
|
|
1523
1536
|
target[offset - 2] = mask[2];
|
|
1524
1537
|
target[offset - 1] = mask[3];
|
|
1538
|
+
if (!dataLength) return [target];
|
|
1525
1539
|
if (skipMasking) return [target, data];
|
|
1526
1540
|
if (merge2) {
|
|
1527
1541
|
applyMask(data, mask, target, offset, dataLength);
|
|
@@ -2278,6 +2292,7 @@ var require_websocket = __commonJS({
|
|
|
2278
2292
|
var https = __require("https");
|
|
2279
2293
|
var http = __require("http");
|
|
2280
2294
|
var net = __require("net");
|
|
2295
|
+
var querystring = __require("querystring");
|
|
2281
2296
|
var tls = __require("tls");
|
|
2282
2297
|
var { randomBytes: randomBytes7, createHash: createHash8 } = __require("crypto");
|
|
2283
2298
|
var { Duplex, Readable } = __require("stream");
|
|
@@ -2356,12 +2371,17 @@ var require_websocket = __commonJS({
|
|
|
2356
2371
|
protocols = [protocols];
|
|
2357
2372
|
}
|
|
2358
2373
|
}
|
|
2359
|
-
initAsClient(this, address, protocols, options);
|
|
2374
|
+
options = initAsClient(this, address, protocols, options);
|
|
2360
2375
|
} else {
|
|
2361
|
-
this._autoPong = options.autoPong;
|
|
2362
|
-
this._closeTimeout = options.closeTimeout;
|
|
2363
2376
|
this._isServer = true;
|
|
2364
2377
|
}
|
|
2378
|
+
if (options.autoPong) {
|
|
2379
|
+
this._autoPong = true;
|
|
2380
|
+
this._autoPongComplete = () => autoPongComplete(this);
|
|
2381
|
+
this._pendingAutoPongs = 0;
|
|
2382
|
+
this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
|
|
2383
|
+
}
|
|
2384
|
+
this._closeTimeout = options.closeTimeout;
|
|
2365
2385
|
}
|
|
2366
2386
|
/**
|
|
2367
2387
|
* For historical reasons, the custom "nodebuffer" type is used by the default
|
|
@@ -2772,6 +2792,7 @@ var require_websocket = __commonJS({
|
|
|
2772
2792
|
maxBufferedChunks: 256 * 1024,
|
|
2773
2793
|
maxFragments: 16 * 1024,
|
|
2774
2794
|
maxPayload: 100 * 1024 * 1024,
|
|
2795
|
+
maxPendingAutoPongs: 60,
|
|
2775
2796
|
skipUTF8Validation: false,
|
|
2776
2797
|
perMessageDeflate: true,
|
|
2777
2798
|
followRedirects: false,
|
|
@@ -2787,8 +2808,6 @@ var require_websocket = __commonJS({
|
|
|
2787
2808
|
path: void 0,
|
|
2788
2809
|
port: void 0
|
|
2789
2810
|
};
|
|
2790
|
-
websocket._autoPong = opts.autoPong;
|
|
2791
|
-
websocket._closeTimeout = opts.closeTimeout;
|
|
2792
2811
|
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
2793
2812
|
throw new RangeError(
|
|
2794
2813
|
`Unsupported protocol version: ${opts.protocolVersion} (supported versions: ${protocolVersions.join(", ")})`
|
|
@@ -2804,10 +2823,9 @@ var require_websocket = __commonJS({
|
|
|
2804
2823
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2805
2824
|
}
|
|
2806
2825
|
}
|
|
2807
|
-
if (parsedUrl.protocol === "http:") {
|
|
2808
|
-
parsedUrl
|
|
2809
|
-
|
|
2810
|
-
parsedUrl.protocol = "wss:";
|
|
2826
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
2827
|
+
parsedUrl = new URL2(parsedUrl);
|
|
2828
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
2811
2829
|
}
|
|
2812
2830
|
websocket._url = parsedUrl.href;
|
|
2813
2831
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
@@ -2876,12 +2894,19 @@ var require_websocket = __commonJS({
|
|
|
2876
2894
|
}
|
|
2877
2895
|
}
|
|
2878
2896
|
if (parsedUrl.username || parsedUrl.password) {
|
|
2879
|
-
|
|
2897
|
+
const username = querystring.unescape(parsedUrl.username);
|
|
2898
|
+
const password = querystring.unescape(parsedUrl.password);
|
|
2899
|
+
opts.auth = `${username}:${password}`;
|
|
2880
2900
|
}
|
|
2881
2901
|
if (isIpcUrl) {
|
|
2882
|
-
const
|
|
2883
|
-
|
|
2884
|
-
|
|
2902
|
+
const i = opts.path.indexOf(":");
|
|
2903
|
+
if (i === -1) {
|
|
2904
|
+
opts.socketPath = opts.path;
|
|
2905
|
+
opts.path = "";
|
|
2906
|
+
} else {
|
|
2907
|
+
opts.socketPath = opts.path.slice(0, i);
|
|
2908
|
+
opts.path = opts.path.slice(i + 1);
|
|
2909
|
+
}
|
|
2885
2910
|
}
|
|
2886
2911
|
let req;
|
|
2887
2912
|
if (opts.followRedirects) {
|
|
@@ -3025,6 +3050,7 @@ var require_websocket = __commonJS({
|
|
|
3025
3050
|
} else {
|
|
3026
3051
|
req.end();
|
|
3027
3052
|
}
|
|
3053
|
+
return opts;
|
|
3028
3054
|
}
|
|
3029
3055
|
function emitErrorAndClose(websocket, err) {
|
|
3030
3056
|
websocket._readyState = WebSocket2.CLOSING;
|
|
@@ -3076,8 +3102,13 @@ var require_websocket = __commonJS({
|
|
|
3076
3102
|
function receiverOnConclude(code2, reason) {
|
|
3077
3103
|
const websocket = this[kWebSocket];
|
|
3078
3104
|
websocket._closeFrameReceived = true;
|
|
3079
|
-
websocket._closeMessage = reason;
|
|
3080
3105
|
websocket._closeCode = code2;
|
|
3106
|
+
if (reason.length === 0) {
|
|
3107
|
+
websocket._closeMessage = EMPTY_BUFFER;
|
|
3108
|
+
} else {
|
|
3109
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
3110
|
+
websocket._closeMessage.set(reason);
|
|
3111
|
+
}
|
|
3081
3112
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
3082
3113
|
websocket._socket.removeListener("data", socketOnData);
|
|
3083
3114
|
process.nextTick(resume, websocket._socket);
|
|
@@ -3108,9 +3139,19 @@ var require_websocket = __commonJS({
|
|
|
3108
3139
|
}
|
|
3109
3140
|
function receiverOnPing(data) {
|
|
3110
3141
|
const websocket = this[kWebSocket];
|
|
3111
|
-
if (websocket._autoPong
|
|
3142
|
+
if (websocket._autoPong && websocket.readyState === WebSocket2.OPEN) {
|
|
3143
|
+
if (websocket._maxPendingAutoPongs > 0 && websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs) {
|
|
3144
|
+
websocket.terminate();
|
|
3145
|
+
} else {
|
|
3146
|
+
websocket._pendingAutoPongs++;
|
|
3147
|
+
websocket.pong(data, !this._isServer, websocket._autoPongComplete);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3112
3150
|
websocket.emit("ping", data);
|
|
3113
3151
|
}
|
|
3152
|
+
function autoPongComplete(websocket) {
|
|
3153
|
+
websocket._pendingAutoPongs--;
|
|
3154
|
+
}
|
|
3114
3155
|
function receiverOnPong(data) {
|
|
3115
3156
|
this[kWebSocket].emit("pong", data);
|
|
3116
3157
|
}
|
|
@@ -3364,6 +3405,8 @@ var require_websocket_server = __commonJS({
|
|
|
3364
3405
|
* fragments
|
|
3365
3406
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3366
3407
|
* size
|
|
3408
|
+
* @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
|
|
3409
|
+
* pending automatic pongs
|
|
3367
3410
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
3368
3411
|
* @param {String} [options.path] Accept only connections matching this path
|
|
3369
3412
|
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
|
@@ -3386,6 +3429,7 @@ var require_websocket_server = __commonJS({
|
|
|
3386
3429
|
maxBufferedChunks: 256 * 1024,
|
|
3387
3430
|
maxFragments: 16 * 1024,
|
|
3388
3431
|
maxPayload: 100 * 1024 * 1024,
|
|
3432
|
+
maxPendingAutoPongs: 60,
|
|
3389
3433
|
skipUTF8Validation: false,
|
|
3390
3434
|
perMessageDeflate: false,
|
|
3391
3435
|
handleProtocols: null,
|
|
@@ -41650,6 +41694,33 @@ function parseUnsupportedCapabilityReason(reason) {
|
|
|
41650
41694
|
return rest.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
41651
41695
|
}
|
|
41652
41696
|
|
|
41697
|
+
// node_modules/@fetchproxy/protocol/dist/binary-fetch.js
|
|
41698
|
+
var FETCH_RESPONSE_TYPE_BASE64 = "base64";
|
|
41699
|
+
var EXTENSION_FEATURE_FETCH_BASE64 = "fetch_base64";
|
|
41700
|
+
var KNOWN_EXTENSION_FEATURES = /* @__PURE__ */ new Set([
|
|
41701
|
+
EXTENSION_FEATURE_FETCH_BASE64
|
|
41702
|
+
]);
|
|
41703
|
+
var MAX_EXTENSION_FEATURES = 32;
|
|
41704
|
+
var MAX_EXTENSION_FEATURE_LENGTH = 64;
|
|
41705
|
+
var HOSTED_RELAY_MESSAGE_BYTES = 32 * 1024 * 1024;
|
|
41706
|
+
var MAX_BINARY_RESPONSE_BYTES = 16 * 1024 * 1024;
|
|
41707
|
+
var RESPONSE_TOO_LARGE_CODE = "response_too_large";
|
|
41708
|
+
var TOO_LARGE_DECLARED_RE = /^response body too large: content-length (\d{1,16}) exceeds the (\d{1,16})-byte binary cap/;
|
|
41709
|
+
var TOO_LARGE_STREAMED_RE = /^response body too large: more than the (\d{1,16})-byte binary cap was received/;
|
|
41710
|
+
function parseResponseTooLarge(error62) {
|
|
41711
|
+
const declared = TOO_LARGE_DECLARED_RE.exec(error62);
|
|
41712
|
+
if (declared)
|
|
41713
|
+
return { limitBytes: Number(declared[2]), declaredBytes: Number(declared[1]) };
|
|
41714
|
+
const streamed = TOO_LARGE_STREAMED_RE.exec(error62);
|
|
41715
|
+
if (streamed)
|
|
41716
|
+
return { limitBytes: Number(streamed[1]), declaredBytes: null };
|
|
41717
|
+
return null;
|
|
41718
|
+
}
|
|
41719
|
+
var BASE64_RE = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
41720
|
+
function isBase64Body(s) {
|
|
41721
|
+
return s.length % 4 === 0 && BASE64_RE.test(s);
|
|
41722
|
+
}
|
|
41723
|
+
|
|
41653
41724
|
// node_modules/@fetchproxy/protocol/dist/json-pointer.js
|
|
41654
41725
|
function matchesDeclaredKey(requested, declared) {
|
|
41655
41726
|
for (const decl of declared) {
|
|
@@ -41835,7 +41906,7 @@ var ProtocolError3 = class extends Error {
|
|
|
41835
41906
|
}
|
|
41836
41907
|
};
|
|
41837
41908
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
41838
|
-
var
|
|
41909
|
+
var BASE64_RE2 = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
41839
41910
|
var SCOPE_KEY_RE = /^[A-Za-z0-9_.\-]{1,256}$/;
|
|
41840
41911
|
var SCOPE_KEY_GLOB_RE = /^[A-Za-z0-9_.\-]{1,256}\*?$/;
|
|
41841
41912
|
var HEADER_NAME_RE = /^[A-Za-z0-9_\-]{1,128}$/;
|
|
@@ -41860,7 +41931,7 @@ function assertString(x, label) {
|
|
|
41860
41931
|
}
|
|
41861
41932
|
function assertBase64(x, label) {
|
|
41862
41933
|
assertString(x, label);
|
|
41863
|
-
if (!
|
|
41934
|
+
if (!BASE64_RE2.test(x))
|
|
41864
41935
|
throw new ProtocolError3(`${label}: invalid base64`);
|
|
41865
41936
|
}
|
|
41866
41937
|
function base64ByteLength(s) {
|
|
@@ -42268,6 +42339,17 @@ function validateFrame(raw) {
|
|
|
42268
42339
|
}
|
|
42269
42340
|
throw new ProtocolError3(`unknown frame type: ${String(t)}`);
|
|
42270
42341
|
}
|
|
42342
|
+
function assertTabDomains(value, domains, label) {
|
|
42343
|
+
if (!Array.isArray(value))
|
|
42344
|
+
throw new ProtocolError3(`${label}: expected array`);
|
|
42345
|
+
if (value.length === 0)
|
|
42346
|
+
throw new ProtocolError3(`${label}: must be non-empty`);
|
|
42347
|
+
for (const d of value) {
|
|
42348
|
+
if (typeof d !== "string" || !domains.includes(d)) {
|
|
42349
|
+
throw new ProtocolError3(`${label}: ${JSON.stringify(d)} is not one of the declared domains [${domains.join(", ")}]`);
|
|
42350
|
+
}
|
|
42351
|
+
}
|
|
42352
|
+
}
|
|
42271
42353
|
function validateHello(raw) {
|
|
42272
42354
|
if (raw.protocolVersion !== PROTOCOL_VERSION) {
|
|
42273
42355
|
throw new ProtocolError3(`hello.protocolVersion: must be ${PROTOCOL_VERSION}`);
|
|
@@ -42344,6 +42426,9 @@ function validateHello(raw) {
|
|
|
42344
42426
|
}
|
|
42345
42427
|
if (raw.accepts !== void 0)
|
|
42346
42428
|
assertAcceptsList(raw.accepts);
|
|
42429
|
+
if (raw.tabDomains !== void 0) {
|
|
42430
|
+
assertTabDomains(raw.tabDomains, raw.domains, "hello.tabDomains");
|
|
42431
|
+
}
|
|
42347
42432
|
if (raw.graphqlOps !== void 0) {
|
|
42348
42433
|
assertGraphqlOpsArray(raw.graphqlOps, "hello.graphqlOps");
|
|
42349
42434
|
}
|
|
@@ -42370,6 +42455,8 @@ function validateHello(raw) {
|
|
|
42370
42455
|
if (raw.unavailableCapabilities !== void 0) {
|
|
42371
42456
|
assertUnavailableCapabilities(raw.unavailableCapabilities);
|
|
42372
42457
|
}
|
|
42458
|
+
if (raw.features !== void 0)
|
|
42459
|
+
assertExtensionFeatures(raw.features);
|
|
42373
42460
|
return raw;
|
|
42374
42461
|
}
|
|
42375
42462
|
throw new ProtocolError3(`hello.role: must be 'server' or 'extension', got ${String(role)}`);
|
|
@@ -42435,6 +42522,22 @@ function assertAcceptsList(accepts) {
|
|
|
42435
42522
|
}
|
|
42436
42523
|
}
|
|
42437
42524
|
}
|
|
42525
|
+
function assertExtensionFeatures(list) {
|
|
42526
|
+
const label = "hello.features";
|
|
42527
|
+
if (!Array.isArray(list))
|
|
42528
|
+
throw new ProtocolError3(`${label}: expected array`);
|
|
42529
|
+
if (list.length > MAX_EXTENSION_FEATURES) {
|
|
42530
|
+
throw new ProtocolError3(`${label}: at most ${MAX_EXTENSION_FEATURES} entries, got ${list.length}`);
|
|
42531
|
+
}
|
|
42532
|
+
for (const f of list) {
|
|
42533
|
+
if (typeof f !== "string") {
|
|
42534
|
+
throw new ProtocolError3(`${label}: entry must be string, got ${typeof f}`);
|
|
42535
|
+
}
|
|
42536
|
+
if (f.length < 1 || f.length > MAX_EXTENSION_FEATURE_LENGTH) {
|
|
42537
|
+
throw new ProtocolError3(`${label}: entry must be 1-${MAX_EXTENSION_FEATURE_LENGTH} characters, got ${f.length}`);
|
|
42538
|
+
}
|
|
42539
|
+
}
|
|
42540
|
+
}
|
|
42438
42541
|
function assertUnavailableCapabilities(list) {
|
|
42439
42542
|
const label = "hello.unavailableCapabilities";
|
|
42440
42543
|
if (!Array.isArray(list))
|
|
@@ -42670,6 +42773,11 @@ function validateInnerRequest(raw) {
|
|
|
42670
42773
|
throw new ProtocolError3("inner.init.credentials: must be 'include' or 'omit'");
|
|
42671
42774
|
}
|
|
42672
42775
|
}
|
|
42776
|
+
if (raw.init.responseType !== void 0) {
|
|
42777
|
+
if (raw.init.responseType !== FETCH_RESPONSE_TYPE_BASE64) {
|
|
42778
|
+
throw new ProtocolError3("inner.init.responseType: must be 'base64' when present");
|
|
42779
|
+
}
|
|
42780
|
+
}
|
|
42673
42781
|
return raw;
|
|
42674
42782
|
}
|
|
42675
42783
|
if (raw.op === "read_cookies") {
|
|
@@ -42978,6 +43086,16 @@ function validateInnerResponse(raw) {
|
|
|
42978
43086
|
assertPositiveInt(raw.status, "inner.status");
|
|
42979
43087
|
assertString(raw.url, "inner.url");
|
|
42980
43088
|
assertString(raw.body, "inner.body");
|
|
43089
|
+
if (raw.bodyEncoding !== void 0) {
|
|
43090
|
+
if (raw.bodyEncoding !== "base64") {
|
|
43091
|
+
throw new ProtocolError3("inner.bodyEncoding: must be 'base64' when present");
|
|
43092
|
+
}
|
|
43093
|
+
if (!isBase64Body(raw.body)) {
|
|
43094
|
+
throw new ProtocolError3("inner.body: not standard padded base64 under bodyEncoding base64");
|
|
43095
|
+
}
|
|
43096
|
+
}
|
|
43097
|
+
if (raw.headers !== void 0)
|
|
43098
|
+
assertStringMap(raw.headers, "inner.headers");
|
|
42981
43099
|
return raw;
|
|
42982
43100
|
}
|
|
42983
43101
|
if (op === "read_cookies") {
|
|
@@ -43192,7 +43310,30 @@ function sessionInfoFromHello(hello) {
|
|
|
43192
43310
|
known.add(c);
|
|
43193
43311
|
}
|
|
43194
43312
|
}
|
|
43195
|
-
|
|
43313
|
+
const features = /* @__PURE__ */ new Set();
|
|
43314
|
+
const rawFeatures = hello.features;
|
|
43315
|
+
if (Array.isArray(rawFeatures)) {
|
|
43316
|
+
for (const f of rawFeatures) {
|
|
43317
|
+
if (typeof f === "string" && KNOWN_EXTENSION_FEATURES.has(f))
|
|
43318
|
+
features.add(f);
|
|
43319
|
+
}
|
|
43320
|
+
}
|
|
43321
|
+
return {
|
|
43322
|
+
platform: hello.platform,
|
|
43323
|
+
unavailableCapabilities: [...known].sort(),
|
|
43324
|
+
features: [...features].sort()
|
|
43325
|
+
};
|
|
43326
|
+
}
|
|
43327
|
+
function featureForRequest(inner) {
|
|
43328
|
+
if (inner.type !== "request" || inner.op !== "fetch")
|
|
43329
|
+
return null;
|
|
43330
|
+
return inner.init.responseType === "base64" ? EXTENSION_FEATURE_FETCH_BASE64 : null;
|
|
43331
|
+
}
|
|
43332
|
+
function missingFeatureFor(inner, info) {
|
|
43333
|
+
const feature = featureForRequest(inner);
|
|
43334
|
+
if (feature === null || info === null)
|
|
43335
|
+
return null;
|
|
43336
|
+
return info.features.includes(feature) ? null : feature;
|
|
43196
43337
|
}
|
|
43197
43338
|
function capabilitiesForRequest(inner) {
|
|
43198
43339
|
if (inner.type !== "request")
|
|
@@ -43298,6 +43439,8 @@ async function buildServerHello(opts) {
|
|
|
43298
43439
|
};
|
|
43299
43440
|
if (opts.accepts && opts.accepts.length > 0)
|
|
43300
43441
|
hello.accepts = [...opts.accepts];
|
|
43442
|
+
if (opts.tabDomains && opts.tabDomains.length > 0)
|
|
43443
|
+
hello.tabDomains = [...opts.tabDomains];
|
|
43301
43444
|
if (opts.cookieKeys && opts.cookieKeys.length > 0) {
|
|
43302
43445
|
hello.cookieKeys = [...opts.cookieKeys];
|
|
43303
43446
|
}
|
|
@@ -44105,7 +44248,8 @@ async function startHost(opts) {
|
|
|
44105
44248
|
sessionStoragePointers: opts.ownSessionStoragePointers,
|
|
44106
44249
|
domSelectors: opts.ownDomSelectors,
|
|
44107
44250
|
domListSelectors: opts.ownDomListSelectors,
|
|
44108
|
-
graphqlOps: opts.ownGraphqlOps
|
|
44251
|
+
graphqlOps: opts.ownGraphqlOps,
|
|
44252
|
+
tabDomains: opts.ownTabDomains
|
|
44109
44253
|
};
|
|
44110
44254
|
const generateSessionKeypair = opts.generateSessionKeypair ?? generateX25519;
|
|
44111
44255
|
let extensionWs = null;
|
|
@@ -44670,6 +44814,7 @@ async function startPeer(opts) {
|
|
|
44670
44814
|
localStoragePointers: opts.localStoragePointers,
|
|
44671
44815
|
sessionStoragePointers: opts.sessionStoragePointers,
|
|
44672
44816
|
graphqlOps: opts.graphqlOps,
|
|
44817
|
+
tabDomains: opts.tabDomains,
|
|
44673
44818
|
// 2.5.0: let a host ≥2.5.0 tell us when the extension leaves, so
|
|
44674
44819
|
// `extensionConnected()` / `sessionLinked()` can go back to false.
|
|
44675
44820
|
// 2.6.0: `hello-rejected` for the same reason, from the extension.
|
|
@@ -45031,6 +45176,8 @@ async function startPeer(opts) {
|
|
|
45031
45176
|
function classifyFetchError(error62, code2) {
|
|
45032
45177
|
if (code2 === CAPABILITY_UNAVAILABLE_CODE)
|
|
45033
45178
|
return "capability_unavailable";
|
|
45179
|
+
if (code2 === RESPONSE_TOO_LARGE_CODE)
|
|
45180
|
+
return "body_too_large";
|
|
45034
45181
|
if (/^(in-page )?fetch threw:/.test(error62)) {
|
|
45035
45182
|
return "tab_fetch_failed";
|
|
45036
45183
|
}
|
|
@@ -45190,6 +45337,28 @@ var FetchproxyCapabilityUnavailableError = class extends FetchproxyHintedError {
|
|
|
45190
45337
|
this.platform = info.platform;
|
|
45191
45338
|
}
|
|
45192
45339
|
};
|
|
45340
|
+
var FetchproxyExtensionUpdateRequiredError = class extends FetchproxyHintedError {
|
|
45341
|
+
/** The feature the extension lacks (`'fetch_base64'`). */
|
|
45342
|
+
feature;
|
|
45343
|
+
constructor(originalError, info) {
|
|
45344
|
+
super(originalError, `this MCP needs the browser extension to support "${info.feature}" (binary downloads through the bridge), and the ContextMint Bridge build it is paired with does not. Update ContextMint Bridge (Chrome Web Store / App Store, or rebuild a sideloaded copy and reload it), then retry. Nothing is wrong with the MCP or your pairing, and re-pairing will not change it.`);
|
|
45345
|
+
this.name = "FetchproxyExtensionUpdateRequiredError";
|
|
45346
|
+
this.feature = info.feature;
|
|
45347
|
+
}
|
|
45348
|
+
};
|
|
45349
|
+
var FetchproxyResponseTooLargeError = class extends FetchproxyHintedError {
|
|
45350
|
+
/** The cap the extension enforced, in bytes, when it said; else `null`. */
|
|
45351
|
+
limitBytes;
|
|
45352
|
+
/** The response's `content-length`, when the refusal came from it; else `null`. */
|
|
45353
|
+
declaredBytes;
|
|
45354
|
+
constructor(originalError, info) {
|
|
45355
|
+
const cap = info.limitBytes ?? MAX_BINARY_RESPONSE_BYTES;
|
|
45356
|
+
super(originalError, `the file is larger than the ${cap}-byte cap one bridge response can carry, so the extension refused it rather than send a frame the bridge cannot deliver. This is not a version or pairing problem: fetch a smaller rendition if the site offers one, or download it directly in the browser.`);
|
|
45357
|
+
this.name = "FetchproxyResponseTooLargeError";
|
|
45358
|
+
this.limitBytes = info.limitBytes;
|
|
45359
|
+
this.declaredBytes = info.declaredBytes;
|
|
45360
|
+
}
|
|
45361
|
+
};
|
|
45193
45362
|
function waitedHint(op) {
|
|
45194
45363
|
const tail = " This is not a version problem and does not need an update.";
|
|
45195
45364
|
if (op === "capture" || op === "capture_redirect") {
|
|
@@ -45212,6 +45381,13 @@ function protocolErrorFrom(error62, op, response) {
|
|
|
45212
45381
|
platform: unavailable?.platform ?? null
|
|
45213
45382
|
});
|
|
45214
45383
|
}
|
|
45384
|
+
const tooLarge = parseResponseTooLarge(error62);
|
|
45385
|
+
if (tooLarge !== null || response?.code === RESPONSE_TOO_LARGE_CODE) {
|
|
45386
|
+
return new FetchproxyResponseTooLargeError(error62, {
|
|
45387
|
+
limitBytes: tooLarge?.limitBytes ?? null,
|
|
45388
|
+
declaredBytes: tooLarge?.declaredBytes ?? null
|
|
45389
|
+
});
|
|
45390
|
+
}
|
|
45215
45391
|
if (error62 === "timeout")
|
|
45216
45392
|
return new FetchproxyWaitedError(error62, op);
|
|
45217
45393
|
if (SCOPE_REJECTION.test(error62))
|
|
@@ -45304,6 +45480,13 @@ function assertSubdomainLabel(label) {
|
|
|
45304
45480
|
throw new Error(`FetchproxyServer: subdomain must be a DNS label like "www" or "api" (or dot-separated like "auth.api"), got ${JSON.stringify(label)}`);
|
|
45305
45481
|
}
|
|
45306
45482
|
}
|
|
45483
|
+
function assertExpectedStatus(response, expected, asHttp = () => response) {
|
|
45484
|
+
if (expected === void 0)
|
|
45485
|
+
return;
|
|
45486
|
+
const matched = Array.isArray(expected) ? expected.includes(response.status) : response.status === expected;
|
|
45487
|
+
if (!matched)
|
|
45488
|
+
throw new FetchproxyHttpError(asHttp());
|
|
45489
|
+
}
|
|
45307
45490
|
function assertUrlInDomains(field, url2, domains) {
|
|
45308
45491
|
let parsed;
|
|
45309
45492
|
try {
|
|
@@ -45453,6 +45636,9 @@ var FetchproxyServer = class {
|
|
|
45453
45636
|
throw new Error(`FetchproxyServer: opts.domains entry ${JSON.stringify(d)} is a public suffix \u2014 declare a registrable domain (e.g. "example.${d}"), not the suffix every site under it shares`);
|
|
45454
45637
|
}
|
|
45455
45638
|
}
|
|
45639
|
+
if (opts.tabDomains !== void 0) {
|
|
45640
|
+
assertTabDomains(opts.tabDomains, opts.domains, "FetchproxyServer: opts.tabDomains");
|
|
45641
|
+
}
|
|
45456
45642
|
let capabilities;
|
|
45457
45643
|
if (opts.capabilities === void 0) {
|
|
45458
45644
|
capabilities = ["fetch"];
|
|
@@ -45523,6 +45709,7 @@ var FetchproxyServer = class {
|
|
|
45523
45709
|
name: d.name,
|
|
45524
45710
|
operationName: d.operationName
|
|
45525
45711
|
})),
|
|
45712
|
+
...opts.tabDomains !== void 0 ? { tabDomains: [...opts.tabDomains] } : {},
|
|
45526
45713
|
// 0.8.0+: timer + lazy-revive default to ON. Every realty MCP
|
|
45527
45714
|
// adapter was about to set these to the same numbers anyway; the
|
|
45528
45715
|
// back-door is `0` (explicit opt-out) if a caller genuinely wants
|
|
@@ -45652,6 +45839,7 @@ var FetchproxyServer = class {
|
|
|
45652
45839
|
ownDomSelectors: this.opts.domSelectors,
|
|
45653
45840
|
ownDomListSelectors: this.opts.domListSelectors,
|
|
45654
45841
|
ownGraphqlOps: this.opts.graphqlOps,
|
|
45842
|
+
ownTabDomains: this.opts.tabDomains,
|
|
45655
45843
|
onPairCode: this.opts.onPairCode,
|
|
45656
45844
|
extensionTrust: this.extensionTrust()
|
|
45657
45845
|
});
|
|
@@ -45685,6 +45873,7 @@ var FetchproxyServer = class {
|
|
|
45685
45873
|
domSelectors: this.opts.domSelectors,
|
|
45686
45874
|
domListSelectors: this.opts.domListSelectors,
|
|
45687
45875
|
graphqlOps: this.opts.graphqlOps,
|
|
45876
|
+
tabDomains: this.opts.tabDomains,
|
|
45688
45877
|
extensionTrust: this.extensionTrust(),
|
|
45689
45878
|
requireExtensionIdentity: this.opts.requireExtensionIdentity
|
|
45690
45879
|
});
|
|
@@ -45969,6 +46158,15 @@ var FetchproxyServer = class {
|
|
|
45969
46158
|
cause: err
|
|
45970
46159
|
};
|
|
45971
46160
|
}
|
|
46161
|
+
if (err instanceof FetchproxyExtensionUpdateRequiredError) {
|
|
46162
|
+
return {
|
|
46163
|
+
ok: false,
|
|
46164
|
+
error: err.originalError,
|
|
46165
|
+
kind: "extension_update_required",
|
|
46166
|
+
retryAttempted: false,
|
|
46167
|
+
cause: err
|
|
46168
|
+
};
|
|
46169
|
+
}
|
|
45972
46170
|
return {
|
|
45973
46171
|
ok: false,
|
|
45974
46172
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -46115,7 +46313,10 @@ var FetchproxyServer = class {
|
|
|
46115
46313
|
if (result.kind === "capability_unavailable") {
|
|
46116
46314
|
return protocolErrorFrom(result.error, void 0, { code: CAPABILITY_UNAVAILABLE_CODE, op });
|
|
46117
46315
|
}
|
|
46118
|
-
|
|
46316
|
+
if (result.kind === "extension_update_required" && result.cause instanceof FetchproxyExtensionUpdateRequiredError) {
|
|
46317
|
+
return result.cause;
|
|
46318
|
+
}
|
|
46319
|
+
return protocolErrorFrom(result.error, void 0, result.code !== void 0 ? { code: result.code, op } : void 0);
|
|
46119
46320
|
}
|
|
46120
46321
|
/**
|
|
46121
46322
|
* Convenience wrapper around `fetch()`. Builds the URL from a path
|
|
@@ -46135,6 +46336,88 @@ var FetchproxyServer = class {
|
|
|
46135
46336
|
* the declared domains exactly.
|
|
46136
46337
|
*/
|
|
46137
46338
|
async request(method, path, opts = {}) {
|
|
46339
|
+
const init = this.resolveRequestInit("request", method, path, opts);
|
|
46340
|
+
const result = await this.fetch(init, opts.retryOnTimeout !== void 0 ? { retryOnTimeout: opts.retryOnTimeout } : {});
|
|
46341
|
+
if (!result.ok)
|
|
46342
|
+
this.throwFetchFailure(result, init.url, method, opts.retryOnTimeout);
|
|
46343
|
+
const response = {
|
|
46344
|
+
status: result.status,
|
|
46345
|
+
body: result.body,
|
|
46346
|
+
url: result.url
|
|
46347
|
+
};
|
|
46348
|
+
assertExpectedStatus(response, opts.expectStatus);
|
|
46349
|
+
return response;
|
|
46350
|
+
}
|
|
46351
|
+
/**
|
|
46352
|
+
* #460: like `request()`, but the response body comes back as BYTES,
|
|
46353
|
+
* intact — a PDF, an office file, an image — together with the relayed
|
|
46354
|
+
* `content-type` / `content-length` / `content-disposition` headers and the
|
|
46355
|
+
* final URL after redirects.
|
|
46356
|
+
*
|
|
46357
|
+
* The extension runs it from its background worker rather than a tab, so a
|
|
46358
|
+
* file host that sends no CORS headers is still readable, and it follows
|
|
46359
|
+
* redirects. Both the request URL and the FINAL URL must be inside the
|
|
46360
|
+
* declared `domains` — the extension enforces that, and so does this method
|
|
46361
|
+
* on the answer. To read a signed file host, declare it.
|
|
46362
|
+
*
|
|
46363
|
+
* Bodies are capped at `MAX_BINARY_RESPONSE_BYTES` (16 MiB): over it the
|
|
46364
|
+
* extension refuses with `FetchproxyResponseTooLargeError`. An extension
|
|
46365
|
+
* that predates binary fetch is refused with
|
|
46366
|
+
* `FetchproxyExtensionUpdateRequiredError` — locally when its hello says so,
|
|
46367
|
+
* and on the answer when it replied in text anyway.
|
|
46368
|
+
*/
|
|
46369
|
+
async requestBytes(method, path, opts = {}) {
|
|
46370
|
+
const init = {
|
|
46371
|
+
...this.resolveRequestInit("requestBytes", method, path, opts),
|
|
46372
|
+
responseType: "base64"
|
|
46373
|
+
};
|
|
46374
|
+
const result = await this.fetch(init, opts.retryOnTimeout !== void 0 ? { retryOnTimeout: opts.retryOnTimeout } : {});
|
|
46375
|
+
if (!result.ok)
|
|
46376
|
+
this.throwFetchFailure(result, init.url, method, opts.retryOnTimeout);
|
|
46377
|
+
if (result.bodyEncoding !== "base64") {
|
|
46378
|
+
throw new FetchproxyExtensionUpdateRequiredError("the paired ContextMint Bridge extension answered a binary request as text", { feature: EXTENSION_FEATURE_FETCH_BASE64 });
|
|
46379
|
+
}
|
|
46380
|
+
try {
|
|
46381
|
+
assertUrlInDomains("requestBytes final url", result.url, this.opts.domains);
|
|
46382
|
+
} catch (err) {
|
|
46383
|
+
throw new FetchproxyProtocolError(err.message);
|
|
46384
|
+
}
|
|
46385
|
+
if (!isBase64Body(result.body)) {
|
|
46386
|
+
throw new FetchproxyProtocolError("requestBytes: the extension sent a body that is not base64");
|
|
46387
|
+
}
|
|
46388
|
+
const decoded = Buffer.from(result.body, "base64");
|
|
46389
|
+
const response = {
|
|
46390
|
+
status: result.status,
|
|
46391
|
+
url: result.url,
|
|
46392
|
+
headers: { ...result.headers ?? {} },
|
|
46393
|
+
bytes: new Uint8Array(decoded.buffer, decoded.byteOffset, decoded.byteLength)
|
|
46394
|
+
};
|
|
46395
|
+
assertExpectedStatus(response, opts.expectStatus, () => ({
|
|
46396
|
+
status: response.status,
|
|
46397
|
+
url: response.url,
|
|
46398
|
+
// FetchproxyHttpError carries an HttpResponse; a binary body has no
|
|
46399
|
+
// honest text form, so the bytes stay on the BinaryResponse.
|
|
46400
|
+
body: ""
|
|
46401
|
+
}));
|
|
46402
|
+
return response;
|
|
46403
|
+
}
|
|
46404
|
+
/** #460: `requestBytes('GET', path, opts)`. */
|
|
46405
|
+
getBytes(path, opts = {}) {
|
|
46406
|
+
return this.requestBytes("GET", path, opts);
|
|
46407
|
+
}
|
|
46408
|
+
/**
|
|
46409
|
+
* Resolve `path` + options into the wire `FetchInit` — URL building, the
|
|
46410
|
+
* declared-domain guard, the relay tab. Shared by `request()` and
|
|
46411
|
+
* `requestBytes()` so the two can never disagree about which URLs are
|
|
46412
|
+
* reachable.
|
|
46413
|
+
*
|
|
46414
|
+
* Path resolution:
|
|
46415
|
+
* - Absolute URL (`https://...`) → used as-is (still guarded against
|
|
46416
|
+
* leaving the declared domain set).
|
|
46417
|
+
* - Relative path → joined with `https://${subdomain}.${baseDomain}`
|
|
46418
|
+
* (or `https://${baseDomain}` if no subdomain is given).
|
|
46419
|
+
*/
|
|
46420
|
+
resolveRequestInit(caller, method, path, opts) {
|
|
46138
46421
|
if (opts.subdomain !== void 0)
|
|
46139
46422
|
assertSubdomainLabel(opts.subdomain);
|
|
46140
46423
|
const baseDomain = this.resolveBaseDomain(opts.domain);
|
|
@@ -46144,24 +46427,24 @@ var FetchproxyServer = class {
|
|
|
46144
46427
|
try {
|
|
46145
46428
|
host = new URL(path).host;
|
|
46146
46429
|
} catch {
|
|
46147
|
-
throw new Error(`FetchproxyServer
|
|
46430
|
+
throw new Error(`FetchproxyServer.${caller}: absolute path is not a valid URL: ${JSON.stringify(path)}`);
|
|
46148
46431
|
}
|
|
46149
46432
|
} else {
|
|
46150
46433
|
host = opts.subdomain ? `${opts.subdomain}.${baseDomain}` : baseDomain;
|
|
46151
46434
|
}
|
|
46152
46435
|
const url2 = isAbsolute7 ? path : `https://${host}${path}`;
|
|
46153
|
-
assertUrlInDomains(
|
|
46436
|
+
assertUrlInDomains(`${caller} url`, url2, this.opts.domains);
|
|
46154
46437
|
let tabUrl = `https://${host}/`;
|
|
46155
46438
|
if (opts.viaTab !== void 0) {
|
|
46156
46439
|
try {
|
|
46157
46440
|
new URL(opts.viaTab);
|
|
46158
46441
|
} catch {
|
|
46159
|
-
throw new Error(`FetchproxyServer
|
|
46442
|
+
throw new Error(`FetchproxyServer.${caller}: viaTab is not a valid URL: ${JSON.stringify(opts.viaTab)}`);
|
|
46160
46443
|
}
|
|
46161
46444
|
assertUrlInDomains("viaTab", opts.viaTab, this.opts.domains);
|
|
46162
46445
|
tabUrl = opts.viaTab;
|
|
46163
46446
|
}
|
|
46164
|
-
|
|
46447
|
+
return {
|
|
46165
46448
|
url: url2,
|
|
46166
46449
|
method,
|
|
46167
46450
|
tabUrl,
|
|
@@ -46176,29 +46459,16 @@ var FetchproxyServer = class {
|
|
|
46176
46459
|
// every version before this option existed.
|
|
46177
46460
|
...opts.credentials === "omit" ? { credentials: "omit" } : {}
|
|
46178
46461
|
};
|
|
46179
|
-
|
|
46180
|
-
|
|
46181
|
-
|
|
46182
|
-
|
|
46183
|
-
|
|
46184
|
-
if (result.kind === "capability_unavailable" && result.cause instanceof FetchproxyCapabilityUnavailableError) {
|
|
46185
|
-
throw result.cause;
|
|
46186
|
-
}
|
|
46187
|
-
throw this._typedErrorFor(result, init.url, "fetch", result.retryAttempted ?? false, isRetrySafeOnTimeout(method, opts.retryOnTimeout));
|
|
46462
|
+
}
|
|
46463
|
+
/** Turn a failed `fetch()` envelope into the throw `request()` has always made. */
|
|
46464
|
+
throwFetchFailure(result, url2, method, retryOnTimeout) {
|
|
46465
|
+
if (result.kind === "session_not_ready" && result.cause instanceof Error) {
|
|
46466
|
+
throw result.cause;
|
|
46188
46467
|
}
|
|
46189
|
-
|
|
46190
|
-
|
|
46191
|
-
body: result.body,
|
|
46192
|
-
url: result.url
|
|
46193
|
-
};
|
|
46194
|
-
if (opts.expectStatus !== void 0) {
|
|
46195
|
-
const expected = opts.expectStatus;
|
|
46196
|
-
const matched = Array.isArray(expected) ? expected.includes(response.status) : response.status === expected;
|
|
46197
|
-
if (!matched) {
|
|
46198
|
-
throw new FetchproxyHttpError(response);
|
|
46199
|
-
}
|
|
46468
|
+
if (result.kind === "capability_unavailable" && result.cause instanceof FetchproxyCapabilityUnavailableError) {
|
|
46469
|
+
throw result.cause;
|
|
46200
46470
|
}
|
|
46201
|
-
|
|
46471
|
+
throw this._typedErrorFor(result, url2, "fetch", result.retryAttempted ?? false, isRetrySafeOnTimeout(method, retryOnTimeout));
|
|
46202
46472
|
}
|
|
46203
46473
|
/** Issue a GET against `path` (resolved via `request()` rules). */
|
|
46204
46474
|
get(path, opts = {}) {
|
|
@@ -46999,6 +47269,10 @@ var FetchproxyServer = class {
|
|
|
46999
47269
|
status: inner.status,
|
|
47000
47270
|
url: inner.url,
|
|
47001
47271
|
body: inner.body,
|
|
47272
|
+
// #460: carried only when present, so a text answer's envelope
|
|
47273
|
+
// has exactly the keys it always had.
|
|
47274
|
+
...inner.bodyEncoding !== void 0 ? { bodyEncoding: inner.bodyEncoding } : {},
|
|
47275
|
+
...inner.headers !== void 0 ? { headers: { ...inner.headers } } : {},
|
|
47002
47276
|
retryAttempted: false
|
|
47003
47277
|
});
|
|
47004
47278
|
} else {
|
|
@@ -47015,7 +47289,8 @@ var FetchproxyServer = class {
|
|
|
47015
47289
|
ok: false,
|
|
47016
47290
|
error: inner.error,
|
|
47017
47291
|
kind: classifyFetchError(inner.error, inner.code),
|
|
47018
|
-
retryAttempted: false
|
|
47292
|
+
retryAttempted: false,
|
|
47293
|
+
...inner.code !== void 0 ? { code: inner.code } : {}
|
|
47019
47294
|
});
|
|
47020
47295
|
}
|
|
47021
47296
|
return;
|
|
@@ -47319,6 +47594,7 @@ var FetchproxyServer = class {
|
|
|
47319
47594
|
pairCode,
|
|
47320
47595
|
extensionConnected: false,
|
|
47321
47596
|
unavailableCapabilities: [],
|
|
47597
|
+
features: [],
|
|
47322
47598
|
platform: null
|
|
47323
47599
|
};
|
|
47324
47600
|
}
|
|
@@ -47330,6 +47606,7 @@ var FetchproxyServer = class {
|
|
|
47330
47606
|
pairCode,
|
|
47331
47607
|
extensionConnected,
|
|
47332
47608
|
unavailableCapabilities: info ? [...info.unavailableCapabilities] : [],
|
|
47609
|
+
features: info ? [...info.features] : [],
|
|
47333
47610
|
platform: info?.platform ?? null
|
|
47334
47611
|
};
|
|
47335
47612
|
}
|
|
@@ -47343,9 +47620,13 @@ var FetchproxyServer = class {
|
|
|
47343
47620
|
*/
|
|
47344
47621
|
refuseIfUnavailable(inner, info) {
|
|
47345
47622
|
const cap = unavailableCapabilityFor(inner, info);
|
|
47346
|
-
if (cap
|
|
47347
|
-
|
|
47348
|
-
|
|
47623
|
+
if (cap !== null && info !== null) {
|
|
47624
|
+
throw new FetchproxyCapabilityUnavailableError(capabilityUnavailableMessage(cap, info.platform), { capability: cap, platform: info.platform });
|
|
47625
|
+
}
|
|
47626
|
+
const feature = missingFeatureFor(inner, info);
|
|
47627
|
+
if (feature !== null) {
|
|
47628
|
+
throw new FetchproxyExtensionUpdateRequiredError(`the paired ContextMint Bridge extension does not support "${feature}"`, { feature });
|
|
47629
|
+
}
|
|
47349
47630
|
}
|
|
47350
47631
|
/**
|
|
47351
47632
|
* 0.5.2+: throw `FetchproxyProtocolError` with the actionable pair-code
|
|
@@ -47852,7 +48133,7 @@ function describeTokenlessLogin(record2) {
|
|
|
47852
48133
|
|
|
47853
48134
|
// src/version.ts
|
|
47854
48135
|
var SERVER_NAME = "ofw-mcp";
|
|
47855
|
-
var VERSION = "2.
|
|
48136
|
+
var VERSION = "2.30.0";
|
|
47856
48137
|
|
|
47857
48138
|
// src/auth.ts
|
|
47858
48139
|
function fetchproxyDisabled() {
|
|
@@ -48325,6 +48606,10 @@ var TIMESTAMP_KEYS = /* @__PURE__ */ new Set([
|
|
|
48325
48606
|
// OFW: UTC instants we stamp ourselves.
|
|
48326
48607
|
"fetchedBodyAt",
|
|
48327
48608
|
"fetchedAt",
|
|
48609
|
+
// When the detail behind a recipient's `viewedAt` was read (issue #448).
|
|
48610
|
+
// NOT `viewedPlaceholder`: that is OFW's raw epoch-zero placeholder, kept
|
|
48611
|
+
// verbatim precisely so it can never be rendered as a real time.
|
|
48612
|
+
"viewedAtCheckedAt",
|
|
48328
48613
|
"syncedAt",
|
|
48329
48614
|
"downloadedAt",
|
|
48330
48615
|
"recordedAt",
|
|
@@ -48477,12 +48762,52 @@ var ApiRecipientSchema = external_exports.looseObject({
|
|
|
48477
48762
|
}).optional(),
|
|
48478
48763
|
viewed: external_exports.looseObject({ dateTime: external_exports.string() }).nullable().optional()
|
|
48479
48764
|
});
|
|
48480
|
-
function mapRecipients(items) {
|
|
48765
|
+
function mapRecipients(items, origin) {
|
|
48481
48766
|
return (items ?? []).map((r) => {
|
|
48482
48767
|
const dt = r.viewed?.dateTime;
|
|
48483
|
-
const
|
|
48484
|
-
|
|
48768
|
+
const placeholder = typeof dt === "string" && dt.startsWith("1970-01-01");
|
|
48769
|
+
const viewedAt = typeof dt === "string" && !placeholder ? dt : null;
|
|
48770
|
+
const out = { userId: r.user?.userId ?? r.user?.id ?? 0, name: r.user?.name ?? "", viewedAt };
|
|
48771
|
+
if (origin) {
|
|
48772
|
+
out.viewedAtSource = origin.source;
|
|
48773
|
+
if (origin.source === "detail" && origin.checkedAt !== void 0) out.viewedAtCheckedAt = origin.checkedAt;
|
|
48774
|
+
if (placeholder) out.viewedPlaceholder = dt;
|
|
48775
|
+
}
|
|
48776
|
+
return out;
|
|
48777
|
+
});
|
|
48778
|
+
}
|
|
48779
|
+
function detailRecipients(items, checkedAt) {
|
|
48780
|
+
return items && items.length > 0 ? mapRecipients(items, { source: "detail", checkedAt }) : null;
|
|
48781
|
+
}
|
|
48782
|
+
function sameRecipient(a, b) {
|
|
48783
|
+
if (a.userId !== 0 && b.userId !== 0) return a.userId === b.userId;
|
|
48784
|
+
return a.name !== "" && a.name === b.name;
|
|
48785
|
+
}
|
|
48786
|
+
function mergeRecipients(prior, fresh) {
|
|
48787
|
+
if (fresh === null || fresh.length === 0) return prior ?? [];
|
|
48788
|
+
const priorList = prior ?? [];
|
|
48789
|
+
return fresh.map((r) => {
|
|
48790
|
+
if (hasRealView([r])) return r;
|
|
48791
|
+
const match = priorList.find((p) => sameRecipient(p, r) && hasRealView([p]));
|
|
48792
|
+
if (!match) return r;
|
|
48793
|
+
const carried = { userId: r.userId, name: r.name, viewedAt: match.viewedAt };
|
|
48794
|
+
if (match.viewedAtSource !== void 0) carried.viewedAtSource = match.viewedAtSource;
|
|
48795
|
+
if (match.viewedAtCheckedAt !== void 0) carried.viewedAtCheckedAt = match.viewedAtCheckedAt;
|
|
48796
|
+
return carried;
|
|
48797
|
+
});
|
|
48798
|
+
}
|
|
48799
|
+
function withViewOrigin(row, callStartedAtMs) {
|
|
48800
|
+
const recipients = row.recipients.map((r) => {
|
|
48801
|
+
let viewedAtOrigin;
|
|
48802
|
+
if (r.viewedAtSource === "detail") {
|
|
48803
|
+
const at = r.viewedAtCheckedAt === void 0 ? NaN : Date.parse(r.viewedAtCheckedAt);
|
|
48804
|
+
viewedAtOrigin = at >= callStartedAtMs ? "detail-this-call" : "detail-cached";
|
|
48805
|
+
} else {
|
|
48806
|
+
viewedAtOrigin = r.viewedAtSource ?? "unrecorded";
|
|
48807
|
+
}
|
|
48808
|
+
return { ...r, viewedAtOrigin };
|
|
48485
48809
|
});
|
|
48810
|
+
return { ...row, recipients };
|
|
48486
48811
|
}
|
|
48487
48812
|
function hasRealView(recipients) {
|
|
48488
48813
|
return recipients.some((r) => r.viewedAt !== null && !r.viewedAt.startsWith("1970-01-01"));
|
|
@@ -49006,8 +49331,9 @@ async function fetchAttachmentMetaBudgeted(client2, messageId, fileIds, store, b
|
|
|
49006
49331
|
await fetchAttachmentMetaForMessage(client2, messageId, affordable, store);
|
|
49007
49332
|
}
|
|
49008
49333
|
}
|
|
49334
|
+
var FolderIdSchema = external_exports.union([external_exports.string(), external_exports.number()]).transform(String);
|
|
49009
49335
|
var FoldersSchema = external_exports.looseObject({
|
|
49010
|
-
systemFolders: external_exports.array(external_exports.looseObject({ id:
|
|
49336
|
+
systemFolders: external_exports.array(external_exports.looseObject({ id: FolderIdSchema, folderType: external_exports.string() })).optional()
|
|
49011
49337
|
});
|
|
49012
49338
|
async function resolveFolderIds(client2, store) {
|
|
49013
49339
|
const data = parseLenient(
|
|
@@ -49129,11 +49455,15 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49129
49455
|
"GET /pub/v3/messages/{id} (body backfill)",
|
|
49130
49456
|
false
|
|
49131
49457
|
);
|
|
49458
|
+
const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49132
49459
|
toUpsert.push({
|
|
49133
49460
|
...existing,
|
|
49134
49461
|
body: detail.body ?? "",
|
|
49135
|
-
fetchedBodyAt:
|
|
49136
|
-
|
|
49462
|
+
fetchedBodyAt: checkedAt,
|
|
49463
|
+
// A detail that omits recipients (or a view time) must not erase
|
|
49464
|
+
// what the cache already recorded — and the LIST's recipients
|
|
49465
|
+
// carry only a placeholder, so they are never a substitute.
|
|
49466
|
+
recipients: mergeRecipients(existing.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
49137
49467
|
listData: item
|
|
49138
49468
|
});
|
|
49139
49469
|
synced++;
|
|
@@ -49153,7 +49483,8 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49153
49483
|
await client2.request("GET", `/pub/v3/messages/${item.id}`),
|
|
49154
49484
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (view-status refresh)" }
|
|
49155
49485
|
);
|
|
49156
|
-
|
|
49486
|
+
const recipients = mergeRecipients(existing.recipients, detailRecipients(detail.recipients, (/* @__PURE__ */ new Date()).toISOString()));
|
|
49487
|
+
toUpsert.push({ ...existing, recipients, listData: item });
|
|
49157
49488
|
synced++;
|
|
49158
49489
|
}
|
|
49159
49490
|
continue;
|
|
@@ -49163,14 +49494,14 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49163
49494
|
let body = null;
|
|
49164
49495
|
let fetchedBodyAt = null;
|
|
49165
49496
|
let detailFileIds = [];
|
|
49166
|
-
let
|
|
49497
|
+
let detailRecipientsRaw;
|
|
49167
49498
|
const row = {
|
|
49168
49499
|
id: item.id,
|
|
49169
49500
|
folder,
|
|
49170
49501
|
subject: item.subject ?? "(no subject)",
|
|
49171
49502
|
fromUser: item.from?.name ?? "",
|
|
49172
49503
|
sentAt: item.date?.dateTime ?? nowNaiveWallClock(),
|
|
49173
|
-
recipients: mapRecipients(item.recipients),
|
|
49504
|
+
recipients: mapRecipients(item.recipients, { source: "list" }),
|
|
49174
49505
|
body: null,
|
|
49175
49506
|
fetchedBodyAt: null,
|
|
49176
49507
|
replyToId: null,
|
|
@@ -49187,7 +49518,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49187
49518
|
if (isInboxUnread) opts.onUnreadBodyFetched?.(item.id);
|
|
49188
49519
|
body = detail.body ?? "";
|
|
49189
49520
|
fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49190
|
-
|
|
49521
|
+
detailRecipientsRaw = detail.recipients;
|
|
49191
49522
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
49192
49523
|
detailFileIds = detail.files;
|
|
49193
49524
|
}
|
|
@@ -49212,7 +49543,7 @@ async function walkPages(client2, folder, folderId, opts, store) {
|
|
|
49212
49543
|
});
|
|
49213
49544
|
row.body = body;
|
|
49214
49545
|
row.fetchedBodyAt = fetchedBodyAt;
|
|
49215
|
-
if (
|
|
49546
|
+
if (detailRecipientsRaw) row.recipients = mergeRecipients(row.recipients, detailRecipients(detailRecipientsRaw, fetchedBodyAt));
|
|
49216
49547
|
toUpsert.push(row);
|
|
49217
49548
|
synced++;
|
|
49218
49549
|
if (detailFileIds.length > 0) {
|
|
@@ -51821,6 +52152,168 @@ function withPaginationFirst(input2) {
|
|
|
51821
52152
|
return { ...head, ...body, ...head };
|
|
51822
52153
|
}
|
|
51823
52154
|
|
|
52155
|
+
// src/tools/folder-messages.ts
|
|
52156
|
+
var FolderEntrySchema = external_exports.looseObject({
|
|
52157
|
+
// Numeric on the live payload (verified 2026-11-19), strings in older fixtures.
|
|
52158
|
+
id: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
|
|
52159
|
+
name: external_exports.string().optional(),
|
|
52160
|
+
folderType: external_exports.string().optional()
|
|
52161
|
+
});
|
|
52162
|
+
var FoldersSchema2 = external_exports.looseObject({
|
|
52163
|
+
systemFolders: external_exports.array(FolderEntrySchema).optional(),
|
|
52164
|
+
userFolders: external_exports.array(FolderEntrySchema).optional()
|
|
52165
|
+
});
|
|
52166
|
+
async function resolveMessageFolder(client2, arg) {
|
|
52167
|
+
const data = parseLenient(
|
|
52168
|
+
FoldersSchema2,
|
|
52169
|
+
await client2.request("GET", "/pub/v1/messageFolders?includeFolderCounts=true"),
|
|
52170
|
+
{ label: "ofw-mcp", context: "GET /pub/v1/messageFolders (ofw_list_messages folder)" }
|
|
52171
|
+
);
|
|
52172
|
+
const toFolder = (user) => (f) => f.id === void 0 ? null : { id: String(f.id), name: f.name ?? null, folderType: f.folderType ?? null, user };
|
|
52173
|
+
const all = [
|
|
52174
|
+
...(data?.systemFolders ?? []).map(toFolder(false)),
|
|
52175
|
+
...(data?.userFolders ?? []).map(toFolder(true))
|
|
52176
|
+
].filter((f) => f !== null);
|
|
52177
|
+
const wanted = arg.trim();
|
|
52178
|
+
let matches = all.filter((f) => f.id === wanted);
|
|
52179
|
+
if (matches.length === 0) {
|
|
52180
|
+
const lower = wanted.toLowerCase();
|
|
52181
|
+
matches = all.filter((f) => f.name !== null && f.name.trim().toLowerCase() === lower);
|
|
52182
|
+
}
|
|
52183
|
+
if (matches.length !== 1) {
|
|
52184
|
+
return { kind: "unknown", available: matches.length > 1 ? matches : all, ambiguous: matches.length > 1 };
|
|
52185
|
+
}
|
|
52186
|
+
const [folder] = matches;
|
|
52187
|
+
if (folder.folderType === "INBOX") return { kind: "cached", folder: "inbox" };
|
|
52188
|
+
if (folder.folderType === "SENT_MESSAGES") return { kind: "cached", folder: "sent" };
|
|
52189
|
+
if (folder.folderType === "DRAFTS") return { kind: "drafts" };
|
|
52190
|
+
return { kind: "live", folder };
|
|
52191
|
+
}
|
|
52192
|
+
var ListItemSchema2 = external_exports.looseObject({
|
|
52193
|
+
id: external_exports.number(),
|
|
52194
|
+
subject: external_exports.string(),
|
|
52195
|
+
date: external_exports.looseObject({ dateTime: external_exports.string() }).optional(),
|
|
52196
|
+
recipients: external_exports.array(ApiRecipientSchema).optional()
|
|
52197
|
+
});
|
|
52198
|
+
var ListResponseSchema2 = external_exports.looseObject({ data: external_exports.array(ListItemSchema2).optional() });
|
|
52199
|
+
function asRecord3(value) {
|
|
52200
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
52201
|
+
}
|
|
52202
|
+
function nameOf(value) {
|
|
52203
|
+
const name = asRecord3(value)?.name;
|
|
52204
|
+
return typeof name === "string" && name !== "" ? name : null;
|
|
52205
|
+
}
|
|
52206
|
+
async function fetchFolderPage(client2, folder, opts) {
|
|
52207
|
+
const direction = opts.sort === "oldest" ? "asc" : "desc";
|
|
52208
|
+
const raw = await client2.request(
|
|
52209
|
+
"GET",
|
|
52210
|
+
`/pub/v3/messages?folders=${encodeURIComponent(folder.id)}&page=${opts.page}&size=${opts.size}&sort=date&sortDirection=${direction}`
|
|
52211
|
+
);
|
|
52212
|
+
parseLenient(ListResponseSchema2, raw, { label: "ofw-mcp", context: "GET /pub/v3/messages?folders={folder}" });
|
|
52213
|
+
const items = asRecord3(raw)?.data ?? [];
|
|
52214
|
+
const upstream = readUpstreamPaging(raw);
|
|
52215
|
+
const messages = [];
|
|
52216
|
+
for (const entry of items) {
|
|
52217
|
+
const it = asRecord3(entry);
|
|
52218
|
+
if (it === null || typeof it.id !== "number") continue;
|
|
52219
|
+
const files = it.files;
|
|
52220
|
+
const dateTime = asRecord3(it.date)?.dateTime;
|
|
52221
|
+
const message = pruneUndefined({
|
|
52222
|
+
id: it.id,
|
|
52223
|
+
folderId: folder.id,
|
|
52224
|
+
folderName: folder.name,
|
|
52225
|
+
subject: typeof it.subject === "string" ? it.subject : "",
|
|
52226
|
+
from: nameOf(it.author) ?? nameOf(it.from),
|
|
52227
|
+
sentAt: typeof dateTime === "string" ? dateTime : null,
|
|
52228
|
+
recipients: mapRecipients(
|
|
52229
|
+
Array.isArray(it.recipients) ? it.recipients : [],
|
|
52230
|
+
{ source: "list", checkedAt: opts.checkedAt }
|
|
52231
|
+
),
|
|
52232
|
+
read: typeof it.read === "boolean" ? it.read : null,
|
|
52233
|
+
replied: typeof it.replied === "boolean" ? it.replied : void 0,
|
|
52234
|
+
files: typeof files === "number" ? files : Array.isArray(files) ? files.length : void 0
|
|
52235
|
+
});
|
|
52236
|
+
if (opts.full) {
|
|
52237
|
+
const { preview: _preview, body: _body, ...listData } = it;
|
|
52238
|
+
message.listData = listData;
|
|
52239
|
+
}
|
|
52240
|
+
messages.push(message);
|
|
52241
|
+
}
|
|
52242
|
+
const { hasMore } = offsetState({
|
|
52243
|
+
start: (opts.page - 1) * opts.size,
|
|
52244
|
+
max: opts.size,
|
|
52245
|
+
returned: items.length,
|
|
52246
|
+
total: upstream.total,
|
|
52247
|
+
last: upstream.last,
|
|
52248
|
+
base: 0
|
|
52249
|
+
});
|
|
52250
|
+
return {
|
|
52251
|
+
messages,
|
|
52252
|
+
returned: messages.length,
|
|
52253
|
+
skipped: items.length - messages.length,
|
|
52254
|
+
total: upstream.total,
|
|
52255
|
+
hasMore,
|
|
52256
|
+
nextPage: hasMore ? opts.page + 1 : null
|
|
52257
|
+
};
|
|
52258
|
+
}
|
|
52259
|
+
function folderMessageBrief(m, tz) {
|
|
52260
|
+
const status = m.read === null ? "read state unknown" : m.read ? "read" : "unread";
|
|
52261
|
+
return briefLine(m.from ? `${m.from}: ${m.subject}` : m.subject, briefDate(m.sentAt, tz), status);
|
|
52262
|
+
}
|
|
52263
|
+
var LIVE_FOLDER_MAX_PAGE = 50;
|
|
52264
|
+
var sightingKey = (id2) => `folder_sighting:${id2}`;
|
|
52265
|
+
async function recordFolderSightings(store, messages, seenAt) {
|
|
52266
|
+
for (const m of messages) {
|
|
52267
|
+
const sighting = {
|
|
52268
|
+
folderId: m.folderId,
|
|
52269
|
+
folderName: m.folderName,
|
|
52270
|
+
subject: m.subject,
|
|
52271
|
+
from: m.from,
|
|
52272
|
+
sentAt: m.sentAt,
|
|
52273
|
+
read: m.read,
|
|
52274
|
+
seenAt
|
|
52275
|
+
};
|
|
52276
|
+
await store.setMeta(sightingKey(m.id), JSON.stringify(sighting));
|
|
52277
|
+
}
|
|
52278
|
+
}
|
|
52279
|
+
async function getFolderSighting(store, id2) {
|
|
52280
|
+
const raw = await store.getMeta(sightingKey(id2));
|
|
52281
|
+
if (raw === null) return null;
|
|
52282
|
+
let value;
|
|
52283
|
+
try {
|
|
52284
|
+
value = JSON.parse(raw);
|
|
52285
|
+
} catch {
|
|
52286
|
+
return null;
|
|
52287
|
+
}
|
|
52288
|
+
const r = asRecord3(value);
|
|
52289
|
+
if (r === null || typeof r.folderId !== "string" || typeof r.subject !== "string") return null;
|
|
52290
|
+
const str = (v) => typeof v === "string" ? v : null;
|
|
52291
|
+
return {
|
|
52292
|
+
folderId: r.folderId,
|
|
52293
|
+
folderName: str(r.folderName),
|
|
52294
|
+
subject: r.subject,
|
|
52295
|
+
from: str(r.from),
|
|
52296
|
+
sentAt: str(r.sentAt),
|
|
52297
|
+
read: typeof r.read === "boolean" ? r.read : null,
|
|
52298
|
+
seenAt: str(r.seenAt)
|
|
52299
|
+
};
|
|
52300
|
+
}
|
|
52301
|
+
function sightingGateRow(id2, s) {
|
|
52302
|
+
return {
|
|
52303
|
+
id: id2,
|
|
52304
|
+
folder: "inbox",
|
|
52305
|
+
subject: s.subject,
|
|
52306
|
+
fromUser: s.from ?? "",
|
|
52307
|
+
sentAt: s.sentAt ?? "(time unknown)",
|
|
52308
|
+
recipients: [],
|
|
52309
|
+
body: null,
|
|
52310
|
+
fetchedBodyAt: null,
|
|
52311
|
+
replyToId: null,
|
|
52312
|
+
chainRootId: null,
|
|
52313
|
+
listData: { read: s.read === true, sightedInFolder: s.folderName ?? s.folderId }
|
|
52314
|
+
};
|
|
52315
|
+
}
|
|
52316
|
+
|
|
51824
52317
|
// src/tools/plain-text.ts
|
|
51825
52318
|
var CHANGE_ORDER = [
|
|
51826
52319
|
"headings",
|
|
@@ -52062,7 +52555,7 @@ var MessageDetailSchema = external_exports.looseObject({
|
|
|
52062
52555
|
var DetailFilesSchema = external_exports.looseObject({ files: external_exports.array(external_exports.number()).optional() });
|
|
52063
52556
|
var FolderCountsSchema = external_exports.looseObject({
|
|
52064
52557
|
systemFolders: external_exports.array(external_exports.looseObject({
|
|
52065
|
-
id:
|
|
52558
|
+
id: FolderIdSchema,
|
|
52066
52559
|
folderType: external_exports.string(),
|
|
52067
52560
|
totalCount: external_exports.number().optional(),
|
|
52068
52561
|
messageCount: external_exports.number().optional(),
|
|
@@ -52154,11 +52647,12 @@ async function openUnreadBody(client2, cache, cached2) {
|
|
|
52154
52647
|
await client2.request("GET", `/pub/v3/messages/${cached2.id}`),
|
|
52155
52648
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (sync, confirmed mark-read)" }
|
|
52156
52649
|
);
|
|
52650
|
+
const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52157
52651
|
await cache.upsertMessage({
|
|
52158
52652
|
...cached2,
|
|
52159
|
-
recipients:
|
|
52653
|
+
recipients: mergeRecipients(cached2.recipients, detailRecipients(detail.recipients, checkedAt)),
|
|
52160
52654
|
body: detail.body ?? "",
|
|
52161
|
-
fetchedBodyAt:
|
|
52655
|
+
fetchedBodyAt: checkedAt
|
|
52162
52656
|
});
|
|
52163
52657
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
52164
52658
|
await fetchAttachmentMetaForMessage(client2, cached2.id, detail.files, cache);
|
|
@@ -52172,6 +52666,7 @@ async function openUnreadBody(client2, cache, cached2) {
|
|
|
52172
52666
|
reason: "fetchUnreadBodies"
|
|
52173
52667
|
};
|
|
52174
52668
|
}
|
|
52669
|
+
var UNSEEN_ID_HINT = "Run ofw_sync_messages first: it walks list pages, not bodies, so it learns an inbox or sent message's subject, sender and read state without marking anything read. If the message is in another folder (Archived, Action Items, a folder you created), list that folder instead with ofw_list_messages(folderId: <its id or name>) \u2014 that reads its list page without opening anything. Then call ofw_get_message again.";
|
|
52175
52670
|
async function confirmMarkRead(ctx, cached2, args, overriding) {
|
|
52176
52671
|
if (!getConfirmMarkRead()) return void 0;
|
|
52177
52672
|
if (cached2 !== null && !(cached2.folder === "inbox" && !deriveRead(cached2))) return void 0;
|
|
@@ -52180,7 +52675,7 @@ async function confirmMarkRead(ctx, cached2, args, overriding) {
|
|
|
52180
52675
|
error: "MARK_READ_CONFIRMATION_UNAVAILABLE",
|
|
52181
52676
|
messageId: Number(args.messageId),
|
|
52182
52677
|
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.",
|
|
52183
|
-
hint:
|
|
52678
|
+
hint: UNSEEN_ID_HINT
|
|
52184
52679
|
});
|
|
52185
52680
|
}
|
|
52186
52681
|
const when = normalizeTimestampsInValue({ sentAt: cached2.sentAt });
|
|
@@ -52216,6 +52711,10 @@ function withholdBody(row) {
|
|
|
52216
52711
|
}
|
|
52217
52712
|
return { ...row, body: null, listData, bodyWithheld: true, withheldReason: UNREAD_ON_NO_READ_DAY };
|
|
52218
52713
|
}
|
|
52714
|
+
function sightedIn(row) {
|
|
52715
|
+
const where = row.listData?.sightedInFolder;
|
|
52716
|
+
return typeof where === "string" ? where : null;
|
|
52717
|
+
}
|
|
52219
52718
|
function markReadVerdict(cached2, requested) {
|
|
52220
52719
|
const ceiling = getAllowMarkRead();
|
|
52221
52720
|
if (ceiling && (requested ?? true)) return null;
|
|
@@ -52225,9 +52724,9 @@ function markReadVerdict(cached2, requested) {
|
|
|
52225
52724
|
return jsonErrorResponse({
|
|
52226
52725
|
error: "MARK_READ_BLOCKED",
|
|
52227
52726
|
messageId: cached2?.id ?? null,
|
|
52228
|
-
reason: cached2 === null ? "This id is not in the cache, so whether reading it would mark it read is unknowable without making the request that would." : "This is an unread inbox message; fetching its body would mark it read on OurFamilyWizard.",
|
|
52727
|
+
reason: cached2 === null ? "This id is not in the cache, so whether reading it would mark it read is unknowable without making the request that would." : sightedIn(cached2) !== null ? `This is an unread message in the "${sightedIn(cached2)}" folder (per OurFamilyWizard's folder listing); fetching its body would mark it read on OurFamilyWizard.` : "This is an unread inbox message; fetching its body would mark it read on OurFamilyWizard.",
|
|
52229
52728
|
note: `Refused because ${because}. Reading a message for the first time stamps a "First Viewed" timestamp that your co-parent can see and that forms part of the record \u2014 it cannot be undone. To read it anyway, call again with allowMarkRead:true${ceiling ? "" : " (which this deployment does not permit \u2014 clear OFW_ALLOW_MARK_READ to re-enable)"}.`,
|
|
52230
|
-
...cached2 === null ? { hint:
|
|
52729
|
+
...cached2 === null ? { hint: UNSEEN_ID_HINT } : { subject: cached2.subject, fromUser: cached2.fromUser, sentAt: cached2.sentAt }
|
|
52231
52730
|
});
|
|
52232
52731
|
}
|
|
52233
52732
|
async function describeRecipients(cache, recipientIds, known) {
|
|
@@ -52259,7 +52758,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52259
52758
|
const allowDrafts = writeMode !== "none";
|
|
52260
52759
|
server.registerTool("ofw_list_message_folders", {
|
|
52261
52760
|
_meta: familyMeta("lookup"),
|
|
52262
|
-
description: "List OurFamilyWizard message folders (
|
|
52761
|
+
description: "List OurFamilyWizard message folders \u2014 system folders (Inbox, Sent, Archived, Action Items, \u2026) and folders the user created \u2014 with their unread counts. Fetched LIVE from OFW, so the counts are current. Pass a folder's id or name to ofw_list_messages(folderId) to list the messages in it. Does NOT return message content.",
|
|
52263
52762
|
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
52264
52763
|
}, async () => {
|
|
52265
52764
|
const data = await client2.request("GET", "/pub/v1/messageFolders?includeFolderCounts=true");
|
|
@@ -52272,12 +52771,12 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52272
52771
|
when: { start: "since", end: "until" },
|
|
52273
52772
|
aliases: ["messages", "inbox", "co-parent", "ofw", "ourfamilywizard", "new messages"]
|
|
52274
52773
|
}),
|
|
52275
|
-
description: 'List messages from the local OurFamilyWizard cache. Supports filtering by folder, date range, and a substring query on subject+body. Pagination is offset-based (1-based `page`) but if you know what you want (a date range, a topic), prefer the filters over walking pages \u2014 the cache may have 1000+ messages. Results are newest-first by default; `sort:"oldest"` starts at the old end of a range instead of paging to it. Returns an explicit `complete` boolean describing the RESULT SET: true means "this is every message on OurFamilyWizard matching these filters as of freshness.asOf" \u2014 check it before asserting a count. An empty result from a cache that is not verified-fresh is REFUSED (result:"UNVERIFIED_EMPTY") rather than reported as an absence; pass autoRefresh:true to sync and answer instead. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only unread inbox messages are protected: each keeps its sender, subject and time but carries body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", and q matches it by subject only (bodySearchSkipped counts those); readingBlocked, ahead of the messages, appears only when something was withheld and says when reading resumes. Sent messages and inbox messages already read are returned and searched in full, exactly as on a reading day.' + OVERRIDE_DESCRIPTION,
|
|
52774
|
+
description: 'List messages from the local OurFamilyWizard cache. Supports filtering by folder, date range, and a substring query on subject+body. Pagination is offset-based (1-based `page`) but if you know what you want (a date range, a topic), prefer the filters over walking pages \u2014 the cache may have 1000+ messages. Results are newest-first by default; `sort:"oldest"` starts at the old end of a range instead of paging to it. Returns an explicit `complete` boolean describing the RESULT SET: true means "this is every message on OurFamilyWizard matching these filters as of freshness.asOf" \u2014 check it before asserting a count. An empty result from a cache that is not verified-fresh is REFUSED (result:"UNVERIFIED_EMPTY") rather than reported as an absence; pass autoRefresh:true to sync and answer instead. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only unread inbox messages are protected: each keeps its sender, subject and time but carries body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", and q matches it by subject only (bodySearchSkipped counts those); readingBlocked, ahead of the messages, appears only when something was withheld and says when reading resumes. Sent messages and inbox messages already read are returned and searched in full, exactly as on a reading day. folderId may also name any other OurFamilyWizard folder (a user-created folder, Archived, Action Items, \u2026) by id or name: that folder is not cached, so it is read live, one list page per call (at most 50), returning `folder` and each message\'s subject, sender, sentAt, recipients and OurFamilyWizard\'s own `read` flag \u2014 never a body, so it marks nothing read. since/until/q are refused there (UNSUPPORTED_FILTER); a folder id or name OurFamilyWizard does not have is refused as INVALID_FOLDER with `availableFolders`. Read a body with ofw_get_message(messageId).' + OVERRIDE_DESCRIPTION,
|
|
52276
52775
|
// Read-only even with autoRefresh: guardedCacheRead's sync never fetches
|
|
52277
52776
|
// unread inbox bodies, so a list call cannot stamp "First Viewed".
|
|
52278
52777
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
52279
52778
|
inputSchema: external_exports.object({
|
|
52280
|
-
folderId: external_exports.string().describe('
|
|
52779
|
+
folderId: external_exports.string().describe('"inbox", "sent", or "both" (default "both") read the local cache. Any other OurFamilyWizard folder \u2014 one the user created, or Archived, Action Items, etc. \u2014 by its id or name from ofw_list_message_folders: read LIVE, one page at a time, with subjects/senders/dates but no bodies, and without since/until/q.').optional(),
|
|
52281
52780
|
page: external_exports.number().int().min(1).describe("Page number (default 1)").optional(),
|
|
52282
52781
|
size: external_exports.number().int().min(1).describe("Messages per page (default 50)").optional(),
|
|
52283
52782
|
since: external_exports.string().describe("ISO date or datetime \u2014 only messages with sent_at >= since (inclusive). A value with an offset or Z is compared as that instant; a naive value is read as the account's local time (DISPLAY_TZ)").optional(),
|
|
@@ -52289,24 +52788,94 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52289
52788
|
view: LIST_MESSAGES_VIEW
|
|
52290
52789
|
})
|
|
52291
52790
|
}, async (args) => {
|
|
52791
|
+
const callStartedAt = Date.now();
|
|
52292
52792
|
const page = args.page ?? 1;
|
|
52293
52793
|
const size = args.size ?? 50;
|
|
52294
52794
|
const sort = args.sort ?? "newest";
|
|
52295
52795
|
const brief = args.view === "brief";
|
|
52296
52796
|
const view = resolveView(brief ? void 0 : args.view, MESSAGE_VIEWS);
|
|
52297
52797
|
const folderArg = args.folderId ?? "both";
|
|
52798
|
+
const listLiveFolder = async (liveFolder) => {
|
|
52799
|
+
const unsupported = ["since", "until", "q"].filter((k) => args[k] !== void 0);
|
|
52800
|
+
if (unsupported.length > 0) {
|
|
52801
|
+
return jsonErrorResponse({
|
|
52802
|
+
result: "UNSUPPORTED_FILTER",
|
|
52803
|
+
reason: `${unsupported.join(", ")} ${unsupported.length === 1 ? "is" : "are"} not supported for the "${liveFolder.name ?? liveFolder.id}" folder: it is read live from OurFamilyWizard, not from the cache, and OurFamilyWizard's folder listing cannot filter.`,
|
|
52804
|
+
remedy: 'Re-call without since/until/q and page through the folder (newest first, or sort:"oldest").',
|
|
52805
|
+
complete: false,
|
|
52806
|
+
note: "No messages were looked up."
|
|
52807
|
+
});
|
|
52808
|
+
}
|
|
52809
|
+
const liveSize = Math.min(size, LIVE_FOLDER_MAX_PAGE);
|
|
52810
|
+
const result = await fetchFolderPage(client2, liveFolder, {
|
|
52811
|
+
page,
|
|
52812
|
+
size: liveSize,
|
|
52813
|
+
sort,
|
|
52814
|
+
checkedAt: new Date(callStartedAt).toISOString(),
|
|
52815
|
+
full: args.view === "full"
|
|
52816
|
+
});
|
|
52817
|
+
await recordFolderSightings(cacheProvider(), result.messages, new Date(callStartedAt).toISOString());
|
|
52818
|
+
const freshness2 = await buildFreshness(cacheProvider(), { source: "live", folders: [] });
|
|
52819
|
+
if (brief) {
|
|
52820
|
+
const lines = result.messages.map((m) => folderMessageBrief(m, displayTimeZone()));
|
|
52821
|
+
return briefResult(
|
|
52822
|
+
result.hasMore && result.total === null ? [...lines, `-- ${result.returned} shown, more on page ${result.nextPage}`] : briefPage(lines, result.hasMore ? { shown: result.returned, total: result.total } : void 0),
|
|
52823
|
+
"Message subjects and sender names are written by your co-parent and other OurFamilyWizard users."
|
|
52824
|
+
);
|
|
52825
|
+
}
|
|
52826
|
+
const complete2 = page === 1 && !result.hasMore && result.skipped === 0;
|
|
52827
|
+
const label = liveFolder.name ?? liveFolder.id;
|
|
52828
|
+
const payload2 = {
|
|
52829
|
+
complete: complete2,
|
|
52830
|
+
hasMore: result.hasMore,
|
|
52831
|
+
nextPage: result.nextPage,
|
|
52832
|
+
returned: result.returned,
|
|
52833
|
+
...result.total !== null ? { total: result.total } : {},
|
|
52834
|
+
page,
|
|
52835
|
+
size: liveSize,
|
|
52836
|
+
sort,
|
|
52837
|
+
folder: liveFolder
|
|
52838
|
+
};
|
|
52839
|
+
if (result.skipped > 0) payload2.skipped = result.skipped;
|
|
52840
|
+
if (!complete2) {
|
|
52841
|
+
payload2.completeNote = [
|
|
52842
|
+
page !== 1 ? `this is page ${page}; earlier pages are not in this response` : null,
|
|
52843
|
+
result.hasMore ? `more messages remain in "${label}" \u2014 call again with page:${result.nextPage}` : null,
|
|
52844
|
+
result.skipped > 0 ? `${result.skipped} list item${result.skipped === 1 ? "" : "s"} carried no message id and ${result.skipped === 1 ? "was" : "were"} left out` : null
|
|
52845
|
+
].filter((r) => r !== null).join("; ").concat(". Do not state a total or an absence from this result without resolving that first.");
|
|
52846
|
+
}
|
|
52847
|
+
payload2.note = result.returned === 0 && complete2 ? `The "${label}" folder holds no messages on OurFamilyWizard (read live just now).` : `Read live from the "${label}" folder on OurFamilyWizard: subjects, senders and dates only \u2014 this folder is not cached, so no body is included and since/until/q do not apply. Fetch one with ofw_get_message(messageId); like any first read, that marks an unread message read on OurFamilyWizard. \`read\` is OurFamilyWizard's own list flag (null when it sent none).`;
|
|
52848
|
+
payload2.freshness = freshness2;
|
|
52849
|
+
payload2.messages = result.messages;
|
|
52850
|
+
return jsonResponse(payload2);
|
|
52851
|
+
};
|
|
52298
52852
|
let folder;
|
|
52299
52853
|
if (folderArg === "inbox") folder = "inbox";
|
|
52300
52854
|
else if (folderArg === "sent") folder = "sent";
|
|
52301
52855
|
else if (folderArg === "both") folder = void 0;
|
|
52302
52856
|
else {
|
|
52303
|
-
|
|
52304
|
-
|
|
52305
|
-
|
|
52306
|
-
|
|
52307
|
-
|
|
52308
|
-
|
|
52309
|
-
|
|
52857
|
+
const resolved = await resolveMessageFolder(client2, folderArg);
|
|
52858
|
+
if (resolved.kind === "cached") folder = resolved.folder;
|
|
52859
|
+
else if (resolved.kind === "drafts") {
|
|
52860
|
+
return jsonErrorResponse({
|
|
52861
|
+
result: "INVALID_FOLDER",
|
|
52862
|
+
reason: `${JSON.stringify(folderArg)} is the Drafts folder, which ofw_list_messages does not list.`,
|
|
52863
|
+
remedy: "Call ofw_list_drafts instead: it verifies drafts against OurFamilyWizard and carries each draft's revision and draftKey.",
|
|
52864
|
+
complete: false,
|
|
52865
|
+
note: "No messages were looked up. This says NOTHING about what is in the folder."
|
|
52866
|
+
});
|
|
52867
|
+
} else if (resolved.kind === "unknown") {
|
|
52868
|
+
return jsonErrorResponse({
|
|
52869
|
+
result: "INVALID_FOLDER",
|
|
52870
|
+
reason: resolved.ambiguous ? `${resolved.available.length} folders are named ${JSON.stringify(folderArg.trim())}; pass one of their ids instead.` : `There is no OurFamilyWizard folder with the id or name ${JSON.stringify(folderArg)}.`,
|
|
52871
|
+
remedy: 'Re-call with folderId "inbox", "sent", "both", or the id or name of one of availableFolders (ofw_list_message_folders lists them with counts).',
|
|
52872
|
+
availableFolders: resolved.available,
|
|
52873
|
+
complete: false,
|
|
52874
|
+
note: 'No messages were looked up. This says NOTHING about what is in any folder \u2014 do not read it as "no messages".'
|
|
52875
|
+
});
|
|
52876
|
+
} else {
|
|
52877
|
+
return listLiveFolder(resolved.folder);
|
|
52878
|
+
}
|
|
52310
52879
|
}
|
|
52311
52880
|
const bounds = {};
|
|
52312
52881
|
for (const key3 of ["since", "until"]) {
|
|
@@ -52338,7 +52907,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52338
52907
|
isEmpty: (v) => v.total === 0,
|
|
52339
52908
|
read: async () => {
|
|
52340
52909
|
const total2 = await cache.countMessages(filter);
|
|
52341
|
-
const messages2 = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withReadState(m));
|
|
52910
|
+
const messages2 = (await cache.listMessages({ ...filter, page, size, sort })).map((m) => withViewOrigin(withReadState(m), callStartedAt));
|
|
52342
52911
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders });
|
|
52343
52912
|
return { messages: messages2, total: total2, freshness: freshness2 };
|
|
52344
52913
|
}
|
|
@@ -52419,7 +52988,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52419
52988
|
});
|
|
52420
52989
|
server.registerTool("ofw_get_message", {
|
|
52421
52990
|
_meta: familyMeta("lookup"),
|
|
52422
|
-
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) only an UNREAD inbox message is protected: its body is withheld (body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", readingBlocked says when reading resumes) and OFW is never contacted for it; an id not in the cache is refused, since fetching it could mark it read. Sent messages and inbox messages already read are returned exactly as on a reading day. 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.' + OVERRIDE_DESCRIPTION,
|
|
52991
|
+
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. A message in any other folder (Archived, Action Items, a folder the user created) comes back with folder:"other", folderId and folderName, no `read` verdict (received vs sent cannot be told from the folder; see recipients[].viewedAt), and is not cached (each read is live); after ofw_list_messages(folderId) has listed that folder, the mark-read safeguards below judge such a message by that listing\'s read flag, so it can be opened, confirmed or withheld like an inbox message instead of being refused as unknown. On a server-configured no-read day (OFW_READ_DAYS / OFW_NO_READ_DAYS) only an UNREAD inbox message is protected: its body is withheld (body:null, bodyWithheld:true, withheldReason:"UNREAD_ON_NO_READ_DAY", readingBlocked says when reading resumes) and OFW is never contacted for it; an id not in the cache is refused, since fetching it could mark it read. Sent messages and inbox messages already read are returned exactly as on a reading day. 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. Each recipient\'s `viewedAt` carries its provenance: `viewedAtOrigin` is "detail-this-call" (read from OurFamilyWizard during this call), "detail-cached" (from an earlier read \u2014 see `viewedAtCheckedAt`), "list" (only the list was seen, so a null `viewedAt` means UNKNOWN, not unviewed) or "unrecorded". `viewedPlaceholder` is OurFamilyWizard\'s raw 1970 placeholder, kept as source data \u2014 it is never a view time.' + OVERRIDE_DESCRIPTION,
|
|
52423
52992
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
|
|
52424
52993
|
inputSchema: external_exports.object({
|
|
52425
52994
|
messageId: external_exports.string().describe("Message ID (also accepts draft IDs \u2014 drafts are routed via the drafts cache)"),
|
|
@@ -52431,6 +53000,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52431
53000
|
confirmToken: confirmTokenParam
|
|
52432
53001
|
})
|
|
52433
53002
|
}, async (args, ctx) => {
|
|
53003
|
+
const callStartedAt = Date.now();
|
|
52434
53004
|
const id2 = Number(args.messageId);
|
|
52435
53005
|
const view = resolveView(args.view, MESSAGE_VIEWS);
|
|
52436
53006
|
const cache = cacheProvider();
|
|
@@ -52487,23 +53057,36 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52487
53057
|
});
|
|
52488
53058
|
}
|
|
52489
53059
|
const cached2 = await cache.getMessage(id2);
|
|
53060
|
+
const sighting = cached2 === null ? await getFolderSighting(cache, id2) : null;
|
|
53061
|
+
const gateRow = cached2 ?? (sighting === null ? null : sightingGateRow(id2, sighting));
|
|
52490
53062
|
const noReadDay = readingBlockedToday();
|
|
52491
|
-
const protectedToday = noReadDay !== null && (
|
|
53063
|
+
const protectedToday = noReadDay !== null && (gateRow === null || isUnreadInbox(gateRow));
|
|
52492
53064
|
const overriding = protectedToday && args.overrideNoReadDay === true;
|
|
52493
53065
|
const blocked = protectedToday && !overriding ? noReadDay : null;
|
|
52494
53066
|
if (blocked !== null) {
|
|
52495
53067
|
if (cached2 === null) {
|
|
53068
|
+
if (sighting !== null) {
|
|
53069
|
+
return jsonErrorResponse({
|
|
53070
|
+
...blocked,
|
|
53071
|
+
messageId: id2,
|
|
53072
|
+
subject: sighting.subject,
|
|
53073
|
+
from: sighting.from,
|
|
53074
|
+
sentAt: sighting.sentAt,
|
|
53075
|
+
folderName: sighting.folderName,
|
|
53076
|
+
hint: `OurFamilyWizard's listing of the "${sighting.folderName ?? sighting.folderId}" folder shows this message unread, and opening it would mark it read. Its body is withheld until reading resumes (or overrideNoReadDay:true, if the user explicitly asks).`
|
|
53077
|
+
});
|
|
53078
|
+
}
|
|
52496
53079
|
return jsonErrorResponse({
|
|
52497
53080
|
...blocked,
|
|
52498
53081
|
messageId: id2,
|
|
52499
|
-
hint: "This id is not in the cache, so whether it is an unread inbox message cannot be told without the request that would mark it read. Run ofw_sync_messages (it never opens an unread inbox message) to see its subject, sender and date \u2014 and, if it is sent or already read, its body."
|
|
53082
|
+
hint: "This id is not in the cache, so whether it is an unread inbox message cannot be told without the request that would mark it read. Run ofw_sync_messages (it never opens an unread inbox message) to see its subject, sender and date \u2014 and, if it is sent or already read, its body. If it is in another folder (Archived, Action Items, a folder you created), list that folder with ofw_list_messages(folderId: <its id or name>) instead."
|
|
52500
53083
|
});
|
|
52501
53084
|
}
|
|
52502
53085
|
const attachments2 = await cache.listAttachmentsForMessage(id2);
|
|
52503
53086
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders: [cached2.folder] });
|
|
52504
53087
|
return jsonResponse({
|
|
52505
53088
|
readingBlocked: blocked,
|
|
52506
|
-
...viewOne(view, withholdBody(withReadState(cached2))),
|
|
53089
|
+
...viewOne(view, withholdBody(withViewOrigin(withReadState(cached2), callStartedAt))),
|
|
52507
53090
|
attachments: attachments2,
|
|
52508
53091
|
freshness: freshness2
|
|
52509
53092
|
});
|
|
@@ -52517,7 +53100,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52517
53100
|
await client2.request("GET", `/pub/v3/messages/${id2}`),
|
|
52518
53101
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (view-status refresh)" }
|
|
52519
53102
|
);
|
|
52520
|
-
const recipients =
|
|
53103
|
+
const recipients = mergeRecipients(cached2.recipients, detailRecipients(detail2.recipients, (/* @__PURE__ */ new Date()).toISOString()));
|
|
52521
53104
|
row2 = {
|
|
52522
53105
|
...cached2,
|
|
52523
53106
|
recipients,
|
|
@@ -52545,14 +53128,14 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52545
53128
|
const freshness2 = await buildFreshness(cache, { source: "cache", folders: [row2.folder] });
|
|
52546
53129
|
return jsonResponse({
|
|
52547
53130
|
...overriding ? readOverrideFields("ofw_get_message", [row2.id]) : {},
|
|
52548
|
-
...viewOne(view, withReadState(row2)),
|
|
53131
|
+
...viewOne(view, withViewOrigin(withReadState(row2), callStartedAt)),
|
|
52549
53132
|
attachments: attachments2,
|
|
52550
53133
|
freshness: freshness2
|
|
52551
53134
|
});
|
|
52552
53135
|
}
|
|
52553
|
-
const markReadCheck = markReadVerdict(
|
|
53136
|
+
const markReadCheck = markReadVerdict(gateRow, args.allowMarkRead);
|
|
52554
53137
|
if (markReadCheck !== null) return markReadCheck;
|
|
52555
|
-
const confirmGate = await confirmMarkRead(ctx,
|
|
53138
|
+
const confirmGate = await confirmMarkRead(ctx, gateRow, args, overriding);
|
|
52556
53139
|
if (confirmGate) return confirmGate;
|
|
52557
53140
|
const detail = parseLenient(
|
|
52558
53141
|
MessageDetailSchema,
|
|
@@ -52560,34 +53143,53 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52560
53143
|
{ label: "ofw-mcp", context: "GET /pub/v3/messages/{id} (ofw_get_message)" }
|
|
52561
53144
|
);
|
|
52562
53145
|
let folder = cached2?.folder ?? "inbox";
|
|
53146
|
+
let otherFolder = null;
|
|
52563
53147
|
if (!cached2) {
|
|
52564
|
-
const
|
|
52565
|
-
|
|
53148
|
+
const map2 = await readFolderIdMap(cache);
|
|
53149
|
+
const detailFolderId = detail.folder?.id == null ? null : String(detail.folder.id);
|
|
53150
|
+
if (map2.sent !== null && detailFolderId === map2.sent) {
|
|
52566
53151
|
folder = "sent";
|
|
53152
|
+
} else if (detailFolderId !== null && map2.inbox !== null && map2.sent !== null && detailFolderId !== map2.inbox) {
|
|
53153
|
+
const detailName = detail.folder.name;
|
|
53154
|
+
otherFolder = {
|
|
53155
|
+
id: detailFolderId,
|
|
53156
|
+
name: typeof detailName === "string" && detailName !== "" ? detailName : sighting !== null && sighting.folderId === detailFolderId ? sighting.folderName : null
|
|
53157
|
+
};
|
|
52567
53158
|
}
|
|
52568
53159
|
}
|
|
53160
|
+
const fetchedBodyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
52569
53161
|
const row = {
|
|
52570
53162
|
id: detail.id,
|
|
52571
53163
|
folder,
|
|
52572
53164
|
subject: detail.subject,
|
|
52573
53165
|
fromUser: detail.from?.name ?? "",
|
|
52574
53166
|
sentAt: detail.date?.dateTime ?? nowNaiveWallClock(),
|
|
52575
|
-
recipients:
|
|
53167
|
+
recipients: mergeRecipients(cached2?.recipients, detailRecipients(detail.recipients, fetchedBodyAt)),
|
|
52576
53168
|
body: detail.body ?? "",
|
|
52577
|
-
fetchedBodyAt
|
|
53169
|
+
fetchedBodyAt,
|
|
52578
53170
|
replyToId: cached2?.replyToId ?? null,
|
|
52579
53171
|
chainRootId: cached2?.chainRootId ?? null,
|
|
52580
53172
|
listData: cached2?.listData ?? detail
|
|
52581
53173
|
};
|
|
52582
|
-
await cache.upsertMessage(row);
|
|
53174
|
+
if (otherFolder === null) await cache.upsertMessage(row);
|
|
52583
53175
|
if (Array.isArray(detail.files) && detail.files.length > 0) {
|
|
52584
53176
|
await fetchAttachmentMetaForMessage(client2, detail.id, detail.files, cache);
|
|
52585
53177
|
}
|
|
52586
53178
|
const attachments = await cache.listAttachmentsForMessage(detail.id);
|
|
52587
|
-
const freshness = await buildFreshness(cache, { source: "live", folders: [folder] });
|
|
53179
|
+
const freshness = await buildFreshness(cache, { source: "live", folders: otherFolder === null ? [folder] : [] });
|
|
53180
|
+
const shown = { ...viewOne(view, withViewOrigin(withReadState(row), callStartedAt)) };
|
|
53181
|
+
if (otherFolder !== null) {
|
|
53182
|
+
delete shown.read;
|
|
53183
|
+
}
|
|
52588
53184
|
return jsonResponse({
|
|
52589
53185
|
...overriding ? readOverrideFields("ofw_get_message", [row.id]) : {},
|
|
52590
|
-
...
|
|
53186
|
+
...shown,
|
|
53187
|
+
...otherFolder === null ? {} : {
|
|
53188
|
+
folder: "other",
|
|
53189
|
+
folderId: otherFolder.id,
|
|
53190
|
+
folderName: otherFolder.name,
|
|
53191
|
+
otherFolderNote: `This message is in the "${otherFolder.name ?? otherFolder.id}" folder, which this server does not sync, so it is not cached: every read of it is a live fetch. There is no \`read\` verdict, because whether it was received or sent cannot be told from the folder; recipients[].viewedAt is OurFamilyWizard's own record.`
|
|
53192
|
+
},
|
|
52591
53193
|
attachments,
|
|
52592
53194
|
freshness
|
|
52593
53195
|
});
|
|
@@ -52803,7 +53405,7 @@ function registerMessageTools(server, client2, cacheProvider, attachmentIO) {
|
|
|
52803
53405
|
} else {
|
|
52804
53406
|
threaded = true;
|
|
52805
53407
|
}
|
|
52806
|
-
const storedRecipients = mapRecipients(detail.recipients);
|
|
53408
|
+
const storedRecipients = mapRecipients(detail.recipients, { source: "detail", checkedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
52807
53409
|
if (Array.isArray(detail.recipients) && detail.recipients.length > 0) {
|
|
52808
53410
|
const landed = new Set(storedRecipients.map((r) => r.userId));
|
|
52809
53411
|
const missingRecipients = recipientIds.filter((rid) => !landed.has(rid));
|
|
@@ -53456,7 +54058,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53456
54058
|
const store = inline ? void 0 : requireBlobStore(blobStoreFromEnv(), "blobKeys");
|
|
53457
54059
|
const results = [];
|
|
53458
54060
|
for (let index = 0; index < count; index++) {
|
|
53459
|
-
const
|
|
54061
|
+
const nameOf2 = () => {
|
|
53460
54062
|
if (inline) return inline[index].filename;
|
|
53461
54063
|
try {
|
|
53462
54064
|
return fileNameFromBlobKey(args.blobKeys[index]);
|
|
@@ -53489,7 +54091,7 @@ Up to ${MAX_FILES_PER_CALL} files per call; each must be non-empty and at most 2
|
|
|
53489
54091
|
});
|
|
53490
54092
|
} catch (e) {
|
|
53491
54093
|
if (e instanceof GateHalt) return e.response;
|
|
53492
|
-
results.push({ index, ok: false, filename:
|
|
54094
|
+
results.push({ index, ok: false, filename: nameOf2(), error: e.message });
|
|
53493
54095
|
}
|
|
53494
54096
|
}
|
|
53495
54097
|
const succeeded = results.filter((r) => r.ok);
|