mcp-newoutlook 0.23.0 → 0.23.2
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/README.md +4 -3
- package/dist/body.js +9 -2
- package/dist/body.js.map +1 -1
- package/dist/bridge.js +170 -25
- package/dist/bridge.js.map +1 -1
- package/dist/recipients.js +26 -11
- package/dist/recipients.js.map +1 -1
- package/dist/tools.js +37 -20
- package/dist/tools.js.map +1 -1
- package/extension/background.js +688 -251
- package/extension/manifest.json +1 -1
- package/extension/owa.js +122 -24
- package/package.json +1 -1
- package/extension/requestlog.js +0 -45
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ AI app ────stdio(MCP)──► mcp-newoutlook server ──ws://127.0.0.
|
|
|
14
14
|
|
|
15
15
|
| Tool | What it does |
|
|
16
16
|
|---|---|
|
|
17
|
-
| `get_version` | Server and extension versions, and the connection/session status.
|
|
17
|
+
| `get_version` | Server and extension versions, and the connection/session status. Per Outlook site, `fullTextSearch` and `teamsMeetings` show whether its search and Teams sessions are there yet |
|
|
18
18
|
| `reload_extension` | Reloads the browser extension from disk after an update and waits until it is back, reporting the version before and after |
|
|
19
19
|
| `list_folders` | Every mail folder, including subfolders, with its path (`Inbox/Projects/Northwind`) and counts (`include_ids: true` adds folder ids) |
|
|
20
20
|
| `search_emails` | Lists emails, or searches them with Outlook-style syntax (`from:alice`, `subject:report`, `cc:bob`, `hasattachment:yes`, `after:2026-09-01`, `received:today`; see below) in Outlook's full-text index, newest first or by relevance (`order`). By default it covers Inbox, Sent Items and all their subfolders. `folder` takes a standard name (`inbox`, `sentitems`…), a path or id from `list_folders`, a list of these, or `all` for every folder; each folder is searched with its subfolders (`subfolders: false` leaves them out). Results carry their folder path. `preview: true` adds each email's To line and the start of its body. Each result carries its `conversationId` |
|
|
@@ -23,9 +23,9 @@ AI app ────stdio(MCP)──► mcp-newoutlook server ──ws://127.0.0.
|
|
|
23
23
|
| `list_events` | Calendar appointments and meetings in a date range (default: the next 7 days), optionally only those whose subject, location, organizer or attendees match `query` (`searchNote` says when attendees couldn't be read), recurring meetings expanded, with location, organizer, your response and free/busy. Times in UTC and local time. |
|
|
24
24
|
| `find_meeting_times` | Suggests times when you and the attendees (addresses or names) are all free, from their free/busy and your calendar, inside working hours (default 09:00–17:00 local, weekdays). Tentative meetings count as busy unless `allow_tentative` |
|
|
25
25
|
| `read_event` | One event with its attendees and their responses, and the description |
|
|
26
|
-
| `find_contacts` | Looks people up by name, email or domain in your personal contacts, the organization directory and the people you exchange email with (external partners). Contacts and directory give job title, department, company, office and phone numbers where stored; people from mail come with how many emails were found, the latest one, the folders they're filed in and the signature of their latest email (usually title, company, phone and address). `source` picks `contacts`, `directory`, `mail` or `all` (mail only when contacts and the directory find nobody, since it scans every folder). |
|
|
26
|
+
| `find_contacts` | Looks people up by name, email or domain in your personal contacts, the organization directory and the people you exchange email with (external partners). Contacts and directory give job title, department, company, office and phone numbers where stored; people from mail come with how many emails were found, the latest one, the folders they're filed in and the signature of their latest email (usually title, company, phone and address). `source` picks `contacts`, `directory`, `mail` or `all` (mail only when contacts and the directory find nobody, since it scans every folder). If Outlook is throttling, the mail part can be incomplete; the answer then says `partial: true`. |
|
|
27
27
|
| `respond_to_event` | Accept, tentatively accept or decline a meeting, optionally with a note to the organizer. **You must confirm.** |
|
|
28
|
-
| `create_event` | Your own appointment (created at once, nothing is sent), or a meeting with attendees by address or name, whose invitation **you must confirm**. Meetings get a Microsoft Teams link by default (`teams_meeting`), made the way Outlook makes it
|
|
28
|
+
| `create_event` | Your own appointment (created at once, nothing is sent), or a meeting with attendees by address or name, whose invitation **you must confirm**. Meetings get a Microsoft Teams link by default (`teams_meeting`), made the way Outlook makes it. Outlook sets up its Teams session when its tab loads; if there is none, reload the Outlook tab (or give `teams_meeting: false`) |
|
|
29
29
|
| `create_draft` | Writes an email into Drafts. Never sends. |
|
|
30
30
|
| `create_reply_draft` | Reply or reply all to an email, as a draft with the original quoted. Never sends. |
|
|
31
31
|
| `create_forward_draft` | Forward an email with its attachments, as a draft. Never sends. |
|
|
@@ -123,6 +123,7 @@ Connections from web pages are always refused, and peers need the pairing token.
|
|
|
123
123
|
- Without full-text search (see Search syntax), search matches substrings in fields (subject, body, sender, `To`/`Cc` display names).
|
|
124
124
|
- Emails can't be permanently deleted, only moved to Deleted Items.
|
|
125
125
|
- Outlook doesn't hand out an attached email's original MIME, so its `.eml` is rebuilt from the original headers, body and attachments. It opens normally in mail clients, but isn't byte-identical to the original (e.g. signatures can't be verified).
|
|
126
|
+
- `download_email` and attached emails in `download_attachments` are limited to 30 MB per email (Outlook's size of the item). A larger one is refused before it is fetched; the error gives its size and a link to open it in Outlook.
|
|
126
127
|
|
|
127
128
|
## Development
|
|
128
129
|
|
package/dist/body.js
CHANGED
|
@@ -36,6 +36,12 @@ export function collapseRepeats(lines, minLength = 120) {
|
|
|
36
36
|
return true;
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* preCut: the extension cut the body well above maxLength (#73); fullLength is its length
|
|
41
|
+
* before that cut. When the quoted history starts before the cut, the part cut off was quoted
|
|
42
|
+
* history and the result is the same as for the whole body. Otherwise the result is reported
|
|
43
|
+
* as truncated, with that fullLength.
|
|
44
|
+
*/
|
|
39
45
|
export function shortenBody(body, { includeQuoted = false, maxLength = 20_000 } = {}) {
|
|
40
46
|
const out = { format: body.format, value: body.value };
|
|
41
47
|
if (body.format === "text") {
|
|
@@ -50,8 +56,9 @@ export function shortenBody(body, { includeQuoted = false, maxLength = 20_000 }
|
|
|
50
56
|
}
|
|
51
57
|
out.value = collapseRepeats(lines).join("\n").trimEnd();
|
|
52
58
|
}
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
const cutOwnText = body.preCut === true && !out.quotedRemoved;
|
|
60
|
+
if (out.value.length > maxLength || cutOwnText) {
|
|
61
|
+
out.fullLength = cutOwnText ? Math.max(body.fullLength ?? 0, out.value.length) : out.value.length;
|
|
55
62
|
out.value = out.value.slice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S,CAAC,CAAC"}
|
package/dist/bridge.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1
2
|
import { randomUUID } from "node:crypto";
|
|
2
3
|
import { WebSocketServer, WebSocket } from "ws";
|
|
3
4
|
import { EXTENSION_ORIGIN as TRUSTED_EXTENSION_ORIGIN } from "./extension.js";
|
|
4
5
|
/** Protocol features this server supports (sent in welcome and peer messages). */
|
|
5
|
-
export const SERVER_FEATURES = [];
|
|
6
|
+
export const SERVER_FEATURES = ["heartbeat", "cancel"];
|
|
6
7
|
/** The string features of a hello's capabilities; none for a side too old to send them. */
|
|
7
8
|
const featuresOf = (msg) => Array.isArray(msg?.capabilities?.features) ? msg.capabilities.features.filter((f) => typeof f === "string") : [];
|
|
9
|
+
/**
|
|
10
|
+
* The abort signal of the MCP request a tool is running for (see tools.ts), so a call the
|
|
11
|
+
* AI client cancels is cancelled at the extension too, without passing it through every tool.
|
|
12
|
+
*/
|
|
13
|
+
export const callScope = new AsyncLocalStorage();
|
|
14
|
+
const cancelledError = () => new Error("Cancelled: the AI client withdrew the request.");
|
|
8
15
|
/** How long the hub trusts what it learned about which browser has Outlook signed in. */
|
|
9
16
|
const PICK_STATUS_TIMEOUT_MS = 3_000;
|
|
10
17
|
const EXTENSION_ORIGIN = /^(chrome-extension|extension):\/\/[a-z0-9]+$/i;
|
|
@@ -62,6 +69,16 @@ function describeSocketError(err, limit) {
|
|
|
62
69
|
}
|
|
63
70
|
/** How often the hub pings each extension; one that missed the previous ping is dropped. */
|
|
64
71
|
const KEEP_ALIVE_MS = 20_000;
|
|
72
|
+
/** A peer drops a hub (one that declares "heartbeat") that sent no ping for this many keep-alive periods. */
|
|
73
|
+
const HUB_SILENCE_PERIODS = 2.5;
|
|
74
|
+
/**
|
|
75
|
+
* Hub: a peer with more than this waiting in its send buffer at two keep-alive ticks in a
|
|
76
|
+
* row isn't reading its answers. It is closed (its calls fail and it connects again)
|
|
77
|
+
* instead of the hub buffering more. A burst that drains in between is fine.
|
|
78
|
+
*/
|
|
79
|
+
export const MAX_PEER_BUFFERED_BYTES = 64 * 1024 * 1024;
|
|
80
|
+
/** Hub: a peer with more than this many times MAX_PEER_BUFFERED_BYTES waiting is closed at once. */
|
|
81
|
+
const PEER_BUFFER_HARD_CAP = 4;
|
|
65
82
|
/**
|
|
66
83
|
* After the hub changed or an extension dropped, a call waits this long for the bridge to
|
|
67
84
|
* be back (the extension reconnects within about a second) instead of failing at once.
|
|
@@ -87,8 +104,11 @@ export class ExtensionBridge {
|
|
|
87
104
|
hub; // peer: the hub
|
|
88
105
|
peers = new Set();
|
|
89
106
|
peerLimits = new WeakMap(); // hub: the largest message each peer accepts
|
|
107
|
+
peerCalls = new WeakMap(); // hub: calls run for each peer, by its id
|
|
90
108
|
pending = new Map();
|
|
91
109
|
keepAlive;
|
|
110
|
+
peerBeat; // hub: pings the peers
|
|
111
|
+
backlogged = new WeakSet(); // hub: peers over maxPeerBufferedBytes at the last tick
|
|
92
112
|
retry;
|
|
93
113
|
closed = false;
|
|
94
114
|
steppingDown = false;
|
|
@@ -114,6 +134,7 @@ export class ExtensionBridge {
|
|
|
114
134
|
keepAliveMs: o.keepAliveMs ?? KEEP_ALIVE_MS,
|
|
115
135
|
pickStatusTimeoutMs: o.pickStatusTimeoutMs ?? PICK_STATUS_TIMEOUT_MS,
|
|
116
136
|
reconnectGraceMs: o.reconnectGraceMs ?? RECONNECT_GRACE_MS,
|
|
137
|
+
maxPeerBufferedBytes: o.maxPeerBufferedBytes ?? MAX_PEER_BUFFERED_BYTES,
|
|
117
138
|
};
|
|
118
139
|
}
|
|
119
140
|
/** Becomes the hub, or a peer of the existing hub. Keeps retrying in the background if neither works. */
|
|
@@ -211,6 +232,9 @@ export class ExtensionBridge {
|
|
|
211
232
|
ws.on("close", () => {
|
|
212
233
|
clearTimeout(authTimer);
|
|
213
234
|
this.peers.delete(ws);
|
|
235
|
+
// A peer session that went away waits for nothing: stop what the hub runs for it.
|
|
236
|
+
for (const abort of this.peerCalls.get(ws)?.values() ?? [])
|
|
237
|
+
abort.abort();
|
|
214
238
|
if (this.sockets.delete(ws)) {
|
|
215
239
|
if (this.preferred === ws)
|
|
216
240
|
this.preferred = undefined;
|
|
@@ -287,6 +311,7 @@ export class ExtensionBridge {
|
|
|
287
311
|
acceptPeer(ws, peerVersion, maxMessageBytes) {
|
|
288
312
|
this.peers.add(ws);
|
|
289
313
|
this.peerLimits.set(ws, maxMessageBytes);
|
|
314
|
+
this.startPeerHeartbeat(ws);
|
|
290
315
|
ws.send(JSON.stringify({
|
|
291
316
|
type: "peer-welcome",
|
|
292
317
|
serverVersion: this.serverVersion,
|
|
@@ -323,8 +348,7 @@ export class ExtensionBridge {
|
|
|
323
348
|
// The newer server takes the port first, so an older peer doesn't win it and need a second handover.
|
|
324
349
|
const note = JSON.stringify({ type: "handover", version: newer });
|
|
325
350
|
for (const peer of this.peers)
|
|
326
|
-
|
|
327
|
-
peer.send(note);
|
|
351
|
+
this.sendToPeer(peer, note);
|
|
328
352
|
this.restartHub("mcp-newoutlook was updated; try again in a few seconds.", this.timing.retryMs);
|
|
329
353
|
this.steppingDown = false;
|
|
330
354
|
}
|
|
@@ -335,6 +359,8 @@ export class ExtensionBridge {
|
|
|
335
359
|
this.wss = undefined;
|
|
336
360
|
this.role = "none";
|
|
337
361
|
clearInterval(this.keepAlive);
|
|
362
|
+
clearInterval(this.peerBeat);
|
|
363
|
+
this.peerBeat = undefined;
|
|
338
364
|
this.rejectAll(reason);
|
|
339
365
|
for (const s of this.sockets.keys())
|
|
340
366
|
s.close(1012, "restarting");
|
|
@@ -358,18 +384,20 @@ export class ExtensionBridge {
|
|
|
358
384
|
}
|
|
359
385
|
/** Runs a peer's call against the extension and sends back the outcome. */
|
|
360
386
|
onPeerMessage(ws, msg) {
|
|
387
|
+
// The peer gave up on a call (its AI client cancelled it, or it timed out there).
|
|
388
|
+
if (msg.type === "cancel" && typeof msg.id === "string")
|
|
389
|
+
return void this.peerCalls.get(ws)?.get(msg.id)?.abort();
|
|
361
390
|
if (msg.type !== "request" || typeof msg.id !== "string")
|
|
362
391
|
return;
|
|
363
392
|
if (this.steppingDown && msg.method !== "status") {
|
|
364
393
|
// The peer sends it again through the new hub (peers before 0.23 show the message).
|
|
365
394
|
const err = handoverError();
|
|
366
|
-
|
|
367
|
-
ws.send(JSON.stringify({ type: "response", id: msg.id, ok: false, error: err.message, retry: "handover" }));
|
|
395
|
+
this.sendToPeer(ws, JSON.stringify({ type: "response", id: msg.id, ok: false, error: err.message, retry: "handover" }));
|
|
368
396
|
return;
|
|
369
397
|
}
|
|
370
398
|
const reply = (body) => {
|
|
371
399
|
try {
|
|
372
|
-
if (ws.readyState !== WebSocket.OPEN)
|
|
400
|
+
if (ws.readyState !== WebSocket.OPEN || !this.peerKeepsUp(ws))
|
|
373
401
|
return;
|
|
374
402
|
// A message over the peer's limit would drop its connection and every call on it.
|
|
375
403
|
let text = JSON.stringify({ type: "response", id: msg.id, ...body });
|
|
@@ -383,13 +411,81 @@ export class ExtensionBridge {
|
|
|
383
411
|
console.error(`[mcp-newoutlook] could not answer a peer: ${err.message}`);
|
|
384
412
|
}
|
|
385
413
|
};
|
|
386
|
-
|
|
414
|
+
// Aborted when the peer cancels it or goes away, so the extension stops working on it.
|
|
415
|
+
const abort = new AbortController();
|
|
416
|
+
let calls = this.peerCalls.get(ws);
|
|
417
|
+
if (!calls)
|
|
418
|
+
this.peerCalls.set(ws, (calls = new Map()));
|
|
419
|
+
calls.set(msg.id, abort);
|
|
420
|
+
this.call(String(msg.method), msg.params ?? {}, Number(msg.timeoutMs) || undefined, abort.signal)
|
|
421
|
+
.then((result) => reply({ ok: true, result }), (err) => reply({ ok: false, error: err.message }))
|
|
422
|
+
.finally(() => calls.delete(msg.id));
|
|
387
423
|
}
|
|
388
424
|
broadcastState() {
|
|
389
425
|
const state = JSON.stringify({ type: "ext-state", extension: this.extension ?? null, extensions: this.extensions });
|
|
390
426
|
for (const peer of this.peers)
|
|
391
|
-
|
|
392
|
-
|
|
427
|
+
this.sendToPeer(peer, state);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Hub, before sending to a peer: false, and the peer is closed, when its send buffer is
|
|
431
|
+
* over the hard cap (4x maxPeerBufferedBytes). A smaller backlog is only closed when it
|
|
432
|
+
* lasts (see startPeerHeartbeat), so a burst of large answers doesn't drop a healthy peer.
|
|
433
|
+
*/
|
|
434
|
+
peerKeepsUp(ws) {
|
|
435
|
+
if (ws.bufferedAmount <= this.timing.maxPeerBufferedBytes * PEER_BUFFER_HARD_CAP)
|
|
436
|
+
return true;
|
|
437
|
+
this.closeSlowPeer(ws);
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
/** Hub: closes a peer that isn't reading its answers (1013); its calls fail and it connects again. */
|
|
441
|
+
closeSlowPeer(ws) {
|
|
442
|
+
console.error(`[mcp-newoutlook] closing a peer that doesn't read its answers (${formatSize(ws.bufferedAmount)} waiting)`);
|
|
443
|
+
this.peers.delete(ws);
|
|
444
|
+
ws.close(1013, "too slow");
|
|
445
|
+
}
|
|
446
|
+
/** Hub: sends to a peer that is open and keeping up. */
|
|
447
|
+
sendToPeer(ws, text) {
|
|
448
|
+
if (ws.readyState === WebSocket.OPEN && this.peerKeepsUp(ws))
|
|
449
|
+
ws.send(text);
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Hub: pings each peer every keepAliveMs; one that didn't answer the previous ping (a
|
|
453
|
+
* suspended or hung session) is dropped. The peers in turn drop a hub that stops pinging.
|
|
454
|
+
* A peer whose send buffer is over maxPeerBufferedBytes at this tick and the previous one
|
|
455
|
+
* isn't draining it and is closed (1013).
|
|
456
|
+
*/
|
|
457
|
+
startPeerHeartbeat(ws) {
|
|
458
|
+
this.alive.add(ws);
|
|
459
|
+
ws.on("pong", () => this.alive.add(ws));
|
|
460
|
+
if (this.peerBeat)
|
|
461
|
+
return;
|
|
462
|
+
this.peerBeat = setInterval(() => {
|
|
463
|
+
if (!this.peers.size) {
|
|
464
|
+
clearInterval(this.peerBeat);
|
|
465
|
+
this.peerBeat = undefined;
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
for (const p of this.peers) {
|
|
469
|
+
if (p.readyState !== WebSocket.OPEN)
|
|
470
|
+
continue;
|
|
471
|
+
if (p.bufferedAmount > this.timing.maxPeerBufferedBytes) {
|
|
472
|
+
if (this.backlogged.has(p)) {
|
|
473
|
+
this.closeSlowPeer(p);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
this.backlogged.add(p);
|
|
477
|
+
}
|
|
478
|
+
else
|
|
479
|
+
this.backlogged.delete(p);
|
|
480
|
+
if (!this.alive.has(p)) {
|
|
481
|
+
p.terminate();
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
this.alive.delete(p);
|
|
485
|
+
p.ping();
|
|
486
|
+
}
|
|
487
|
+
}, this.timing.keepAliveMs);
|
|
488
|
+
this.peerBeat.unref();
|
|
393
489
|
}
|
|
394
490
|
/**
|
|
395
491
|
* Pings keep the MV3 service worker alive while connected. A connection that didn't
|
|
@@ -422,6 +518,15 @@ export class ExtensionBridge {
|
|
|
422
518
|
const ws = new WebSocket(`ws://127.0.0.1:${this.port}`, { maxPayload: this.maxMessageBytes });
|
|
423
519
|
let joined = false;
|
|
424
520
|
const timer = setTimeout(() => ws.terminate(), this.timing.joinTimeoutMs);
|
|
521
|
+
// A hub that declares "heartbeat" pings every keepAliveMs. When the pings stop (a hub
|
|
522
|
+
// suspended or hung), drop it so the reconnect/takeover path runs. Older hubs never ping peers.
|
|
523
|
+
let watchdog;
|
|
524
|
+
const watch = () => {
|
|
525
|
+
clearTimeout(watchdog);
|
|
526
|
+
watchdog = setTimeout(() => ws.terminate(), this.timing.keepAliveMs * HUB_SILENCE_PERIODS);
|
|
527
|
+
watchdog.unref();
|
|
528
|
+
};
|
|
529
|
+
ws.on("ping", () => watchdog && watch());
|
|
425
530
|
ws.on("open", () => ws.send(JSON.stringify({ type: "peer-hello", token: this.token, version: this.serverVersion, capabilities: this.capabilities })));
|
|
426
531
|
ws.on("message", (raw) => {
|
|
427
532
|
let msg;
|
|
@@ -443,6 +548,8 @@ export class ExtensionBridge {
|
|
|
443
548
|
: null;
|
|
444
549
|
this.extension = msg.extension ?? undefined;
|
|
445
550
|
this.extensions = msg.extensions ?? (msg.extension ? [msg.extension] : []);
|
|
551
|
+
if (this.hubCapabilities?.features.includes("heartbeat"))
|
|
552
|
+
watch();
|
|
446
553
|
resolve(true);
|
|
447
554
|
}
|
|
448
555
|
else if (msg.type === "handover") {
|
|
@@ -462,6 +569,7 @@ export class ExtensionBridge {
|
|
|
462
569
|
});
|
|
463
570
|
ws.on("close", (code) => {
|
|
464
571
|
clearTimeout(timer);
|
|
572
|
+
clearTimeout(watchdog);
|
|
465
573
|
if (!joined) {
|
|
466
574
|
this.listenError =
|
|
467
575
|
code === 4401
|
|
@@ -495,11 +603,12 @@ export class ExtensionBridge {
|
|
|
495
603
|
});
|
|
496
604
|
}
|
|
497
605
|
// ------------------------------------------------------------------ calls
|
|
498
|
-
|
|
606
|
+
/** signal: aborts the call (default: the MCP request's, from callScope); the extension is told to stop. */
|
|
607
|
+
async call(method, params = {}, timeoutMs = 60_000, signal = callScope.getStore()?.signal) {
|
|
499
608
|
const started = Date.now();
|
|
500
609
|
const via = this.hub;
|
|
501
610
|
try {
|
|
502
|
-
return await this.callOnce(method, params, timeoutMs);
|
|
611
|
+
return await this.callOnce(method, params, timeoutMs, signal);
|
|
503
612
|
}
|
|
504
613
|
catch (err) {
|
|
505
614
|
if (!isHandover(err))
|
|
@@ -507,7 +616,7 @@ export class ExtensionBridge {
|
|
|
507
616
|
// The hub (this one, or the one a peer forwards through) is handing over to a newer
|
|
508
617
|
// server: send the call again once the new hub is there.
|
|
509
618
|
await this.waitForHandover(via, started + timeoutMs);
|
|
510
|
-
return this.callOnce(method, params, Math.max(1_000, timeoutMs - (Date.now() - started)));
|
|
619
|
+
return this.callOnce(method, params, Math.max(1_000, timeoutMs - (Date.now() - started)), signal);
|
|
511
620
|
}
|
|
512
621
|
}
|
|
513
622
|
/** Waits until a hub other than `via` serves the bridge (or this server serves it again), until deadline. */
|
|
@@ -516,7 +625,7 @@ export class ExtensionBridge {
|
|
|
516
625
|
while (!done() && !this.closed && Date.now() < deadline)
|
|
517
626
|
await new Promise((r) => setTimeout(r, 20));
|
|
518
627
|
}
|
|
519
|
-
async callOnce(method, params, timeoutMs) {
|
|
628
|
+
async callOnce(method, params, timeoutMs, signal) {
|
|
520
629
|
// A hub that is stepping down starts no new calls (status still answers).
|
|
521
630
|
if (this.role === "hub" && this.steppingDown && method !== "status")
|
|
522
631
|
throw handoverError();
|
|
@@ -524,18 +633,20 @@ export class ExtensionBridge {
|
|
|
524
633
|
if (counted)
|
|
525
634
|
this.active++;
|
|
526
635
|
try {
|
|
527
|
-
return await this.runCall(method, params, timeoutMs);
|
|
636
|
+
return await this.runCall(method, params, timeoutMs, signal);
|
|
528
637
|
}
|
|
529
638
|
finally {
|
|
530
639
|
if (counted)
|
|
531
640
|
this.active--;
|
|
532
641
|
}
|
|
533
642
|
}
|
|
534
|
-
async runCall(method, params, timeoutMs) {
|
|
643
|
+
async runCall(method, params, timeoutMs, signal) {
|
|
644
|
+
if (signal?.aborted)
|
|
645
|
+
throw cancelledError();
|
|
535
646
|
if (method === "reloadAll" && this.role === "hub")
|
|
536
647
|
return this.reloadAll(timeoutMs);
|
|
537
648
|
if (this.role !== "hub" || UNQUEUED.has(method)) {
|
|
538
|
-
const result = await this.callNow(method, params, timeoutMs);
|
|
649
|
+
const result = await this.callNow(method, params, timeoutMs, signal);
|
|
539
650
|
// Every session reads the hub's load through the status call.
|
|
540
651
|
if (method === "status" && this.role === "hub" && result && typeof result === "object") {
|
|
541
652
|
return { ...result, calls: this.load };
|
|
@@ -543,9 +654,9 @@ export class ExtensionBridge {
|
|
|
543
654
|
return result;
|
|
544
655
|
}
|
|
545
656
|
const started = Date.now();
|
|
546
|
-
await this.takeTurn(timeoutMs);
|
|
657
|
+
await this.takeTurn(timeoutMs, signal);
|
|
547
658
|
try {
|
|
548
|
-
return await this.callNow(method, params, Math.max(1_000, timeoutMs - (Date.now() - started)));
|
|
659
|
+
return await this.callNow(method, params, Math.max(1_000, timeoutMs - (Date.now() - started)), signal);
|
|
549
660
|
}
|
|
550
661
|
catch (err) {
|
|
551
662
|
const others = this.running - 1 + this.waiting.length;
|
|
@@ -567,7 +678,7 @@ export class ExtensionBridge {
|
|
|
567
678
|
return { running: this.running, waiting: this.waiting.length, max: MAX_CONCURRENT_CALLS };
|
|
568
679
|
}
|
|
569
680
|
/** Hub: waits until fewer than MAX_CONCURRENT_CALLS calls run; a Busy error after timeoutMs. */
|
|
570
|
-
takeTurn(timeoutMs) {
|
|
681
|
+
takeTurn(timeoutMs, signal) {
|
|
571
682
|
if (this.running < MAX_CONCURRENT_CALLS) {
|
|
572
683
|
this.running++;
|
|
573
684
|
return Promise.resolve();
|
|
@@ -576,16 +687,22 @@ export class ExtensionBridge {
|
|
|
576
687
|
return new Promise((resolve, reject) => {
|
|
577
688
|
const go = () => {
|
|
578
689
|
clearTimeout(timer);
|
|
690
|
+
signal?.removeEventListener("abort", onAbort);
|
|
579
691
|
resolve();
|
|
580
692
|
};
|
|
581
|
-
const
|
|
693
|
+
const leave = (err) => {
|
|
694
|
+
clearTimeout(timer);
|
|
695
|
+
signal?.removeEventListener("abort", onAbort);
|
|
582
696
|
this.waiting = this.waiting.filter((w) => w !== go);
|
|
583
|
-
reject(
|
|
584
|
-
}
|
|
697
|
+
reject(err);
|
|
698
|
+
};
|
|
699
|
+
const onAbort = () => leave(cancelledError());
|
|
700
|
+
const timer = setTimeout(() => leave(busyError(`${MAX_CONCURRENT_CALLS} calls were running and ${ahead} waiting ahead of this one for ${Math.round(timeoutMs / 1000)} s.`)), timeoutMs);
|
|
701
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
585
702
|
this.waiting.push(go);
|
|
586
703
|
});
|
|
587
704
|
}
|
|
588
|
-
async callNow(method, params, timeoutMs) {
|
|
705
|
+
async callNow(method, params, timeoutMs, signal) {
|
|
589
706
|
// Right after the hub changed or an extension dropped, wait for it to be back.
|
|
590
707
|
const graceEnd = Math.min(this.disruptedAt + this.timing.reconnectGraceMs, Date.now() + timeoutMs);
|
|
591
708
|
while (!this.connected && !this.closed && Date.now() < graceEnd)
|
|
@@ -597,7 +714,7 @@ export class ExtensionBridge {
|
|
|
597
714
|
: "Browser extension is not connected. Open Chrome or Edge with the mcp-newoutlook extension installed (run `mcp-newoutlook setup`).";
|
|
598
715
|
throw new Error(reason);
|
|
599
716
|
}
|
|
600
|
-
const result = await this.send(target, method, params, timeoutMs);
|
|
717
|
+
const result = await this.send(target, method, params, timeoutMs, signal);
|
|
601
718
|
if (this.role === "hub" && this.preferred !== target && this.sockets.has(target)) {
|
|
602
719
|
this.preferred = target;
|
|
603
720
|
this.updateExtensions();
|
|
@@ -616,13 +733,36 @@ export class ExtensionBridge {
|
|
|
616
733
|
return { reloading: results.length - failed.length };
|
|
617
734
|
}
|
|
618
735
|
/** Sends one request on a connection (an extension for the hub, the hub for a peer). */
|
|
619
|
-
send(target, method, params, timeoutMs) {
|
|
736
|
+
send(target, method, params, timeoutMs, signal) {
|
|
737
|
+
if (signal?.aborted)
|
|
738
|
+
return Promise.reject(cancelledError());
|
|
620
739
|
const id = randomUUID();
|
|
621
740
|
// A peer waits a little longer than the hub, so the hub's own timeout message wins.
|
|
622
741
|
const wait = this.role === "peer" ? timeoutMs + 5_000 : timeoutMs;
|
|
742
|
+
// A call given up here (timed out or aborted) is cancelled where it runs, if that side can.
|
|
743
|
+
const canCancel = this.role === "hub" ? !!this.sockets.get(target)?.features?.includes("cancel") : !!this.hubCapabilities?.features.includes("cancel");
|
|
744
|
+
const cancelThere = () => {
|
|
745
|
+
if (canCancel && target.readyState === WebSocket.OPEN)
|
|
746
|
+
target.send(JSON.stringify({ type: "cancel", id }));
|
|
747
|
+
};
|
|
623
748
|
return new Promise((resolve, reject) => {
|
|
749
|
+
const onAbort = () => {
|
|
750
|
+
if (!this.pending.delete(id))
|
|
751
|
+
return;
|
|
752
|
+
clearTimeout(timer);
|
|
753
|
+
cancelThere();
|
|
754
|
+
reject(cancelledError());
|
|
755
|
+
};
|
|
624
756
|
const timer = setTimeout(() => {
|
|
625
757
|
this.pending.delete(id);
|
|
758
|
+
signal?.removeEventListener("abort", onAbort);
|
|
759
|
+
cancelThere();
|
|
760
|
+
// A browser that let a call time out isn't preferred until it answers again (it may be
|
|
761
|
+
// frozen or asleep); the next call picks a browser afresh.
|
|
762
|
+
if (this.role === "hub" && this.preferred === target) {
|
|
763
|
+
this.preferred = undefined;
|
|
764
|
+
this.updateExtensions();
|
|
765
|
+
}
|
|
626
766
|
reject(new Error(`Extension call '${method}' timed out`));
|
|
627
767
|
}, wait);
|
|
628
768
|
this.pending.set(id, {
|
|
@@ -632,7 +772,9 @@ export class ExtensionBridge {
|
|
|
632
772
|
socket: this.role === "hub" ? target : undefined,
|
|
633
773
|
deadline: Date.now() + wait,
|
|
634
774
|
confirm: CONFIRM_CALLS.has(method),
|
|
775
|
+
dispose: () => signal?.removeEventListener("abort", onAbort),
|
|
635
776
|
});
|
|
777
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
636
778
|
target.send(JSON.stringify({ type: "request", id, method, params, timeoutMs }));
|
|
637
779
|
});
|
|
638
780
|
}
|
|
@@ -685,6 +827,7 @@ export class ExtensionBridge {
|
|
|
685
827
|
return;
|
|
686
828
|
this.pending.delete(msg.id);
|
|
687
829
|
clearTimeout(p.timer);
|
|
830
|
+
p.dispose?.();
|
|
688
831
|
if (msg.ok)
|
|
689
832
|
p.resolve(msg.result);
|
|
690
833
|
else
|
|
@@ -696,6 +839,7 @@ export class ExtensionBridge {
|
|
|
696
839
|
if (socket && p.socket !== socket)
|
|
697
840
|
continue;
|
|
698
841
|
clearTimeout(p.timer);
|
|
842
|
+
p.dispose?.();
|
|
699
843
|
p.reject(typeof reason === "string" ? new Error(reason) : reason());
|
|
700
844
|
this.pending.delete(id);
|
|
701
845
|
}
|
|
@@ -704,6 +848,7 @@ export class ExtensionBridge {
|
|
|
704
848
|
this.closed = true;
|
|
705
849
|
clearTimeout(this.retry);
|
|
706
850
|
clearInterval(this.keepAlive);
|
|
851
|
+
clearInterval(this.peerBeat);
|
|
707
852
|
this.rejectAll("mcp-newoutlook is shutting down");
|
|
708
853
|
this.hub?.close();
|
|
709
854
|
for (const s of this.sockets.keys())
|