omni-notify-mcp 1.3.314 → 1.3.316

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.
@@ -388,12 +388,13 @@ class ServedWebview {
388
388
  forget() { }
389
389
  release() { }
390
390
  /**
391
- * One browser of this page: the address it opened (its `search`), a post that reaches that browser alone, and
391
+ * One browser of this page: the address it opened (its `search`), the public address base it came through the gateway
392
+ * on (`base`, undefined on this machine), a post that reaches that browser alone, and
392
393
  * `guard(work, { saidOnce })` for the work a service starts on its own clock (a change watch) — the same owner a browser's
393
394
  * message runs under. `saidOnce` says a failure that persists across the watch's ticks is told to this browser once.
394
395
  */
395
396
  viewerOf(socket) {
396
- const viewer = { search: socket.at, post: (message) => writeFrame(socket, postFrame(message, this.served)) };
397
+ const viewer = { search: socket.at, base: socket.base, post: (message) => writeFrame(socket, postFrame(message, this.served)) };
397
398
  viewer.guard = (work, options = {}) => this.guarded(socket, viewer, work, options.saidOnce === true);
398
399
  return viewer;
399
400
  }
@@ -442,7 +443,7 @@ class ServedWebview {
442
443
  return;
443
444
  }
444
445
  socket.failure = err.message;
445
- const defect = err instanceof TypeError || err instanceof ReferenceError || err instanceof RangeError;
446
+ const defect = codeDefect(err);
446
447
  const where = [...viewer.search].map(([key, value]) => `${key}=${value}`).join("&");
447
448
  console.error(`[${this.page.host.extension}] ${defect ? "a defect in the service's own code" : "a read failed"} on page "${this.page.name}" (${where}) — that browser is told and serving goes on: ${defect ? err.stack : err.message}`);
448
449
  // NULL-OK: field failed is OPTIONAL and therefore it is ok to check for NULL
@@ -708,15 +709,24 @@ class WebHost {
708
709
  return value === undefined || value === `http://127.0.0.1:${this.port}` || value === `http://localhost:${this.port}`;
709
710
  }
710
711
  answer(request, response) {
712
+ this.answered(request, response, () => this.handle(request, response));
713
+ }
714
+ answered(request, response, work) {
711
715
  try {
712
- this.handle(request, response);
716
+ work();
713
717
  }
714
718
  catch (err) {
715
- if (!(err instanceof URIError) && err.code !== "ERR_INVALID_URL") {
719
+ if (!(err instanceof Error)) {
716
720
  throw err;
717
721
  }
718
- // OWNER: a browser's malformed %-escape or address must not reach the process that serves this page — that one request is answered 400 with the reason.
719
- send(response, 400, MIME[".txt"], `the address is not a valid URL: ${err.message}`);
722
+ // OWNER: a browser request is its own trigger root inside the process every hosted extension shares — that one request is answered with its failure, and the process goes on serving.
723
+ if (err instanceof URIError || err.code === "ERR_INVALID_URL") {
724
+ send(response, 400, MIME[".txt"], `the address is not a valid URL: ${err.message}`);
725
+ return;
726
+ }
727
+ const at = (request.url ?? "").split("?")[0];
728
+ console.error(`[${this.extension}] ${request.method} ${at} ${codeDefect(err) ? "hit a defect in the host's own code" : "failed"} — answered 500: ${codeDefect(err) ? err.stack : err.message}`);
729
+ send(response, 500, MIME[".txt"], `${request.method} ${at} failed: ${err.message}`);
720
730
  }
721
731
  }
722
732
  handle(request, response) {
@@ -938,7 +948,10 @@ class WebHost {
938
948
  if (input === null || typeof input !== "object" || Array.isArray(input)) {
939
949
  return json(400, { error: "bad_request", text: "the body must be a JSON object" });
940
950
  }
941
- Promise.resolve(handler(input)).then((answer) => json(answer.status, answer.body), (cause) => json(500, { error: "failed", text: cause instanceof Error ? cause.message : String(cause) }));
951
+ Promise.resolve()
952
+ .then(() => handler(input))
953
+ .then((answer) => json(answer.status, answer.body))
954
+ .catch((cause) => json(500, { error: "failed", text: cause instanceof Error ? cause.message : String(cause) }));
942
955
  });
943
956
  return undefined;
944
957
  }
@@ -956,7 +969,7 @@ class WebHost {
956
969
  if (!over)
957
970
  chunks.push(chunk);
958
971
  });
959
- request.on("end", () => {
972
+ request.on("end", () => this.answered(request, response, () => {
960
973
  if (over)
961
974
  return;
962
975
  let label;
@@ -995,7 +1008,7 @@ class WebHost {
995
1008
  return send(response, 500, MIME[".txt"], `the workspace pick could not be saved: ${err.message}`);
996
1009
  }
997
1010
  return send(response, 204, MIME[".txt"], "");
998
- });
1011
+ }));
999
1012
  return undefined;
1000
1013
  }
1001
1014
  serveFile(encoded, response) {
@@ -1045,6 +1058,16 @@ class WebHost {
1045
1058
  socket.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n");
1046
1059
  return;
1047
1060
  }
1061
+ try {
1062
+ socket.base = publicBase(request);
1063
+ }
1064
+ catch (err) {
1065
+ if (!(err instanceof TypeError))
1066
+ throw err;
1067
+ // OWNER: this socket request's trigger root — a gateway name that is not a host name is answered 400, and no address is built on it.
1068
+ socket.end("HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n");
1069
+ return;
1070
+ }
1048
1071
  const accept = crypto.createHash("sha1").update(key + WS_GUID).digest("base64");
1049
1072
  socket.write(`HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: ${accept}\r\n\r\n`);
1050
1073
  socket.setNoDelay(true);
@@ -1137,7 +1160,24 @@ function peekedRosterPage(label, home, back) {
1137
1160
  }
1138
1161
  function closedPage(extension, page) {
1139
1162
  return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
1140
- <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc">⚪ ${escapeAttribute(page.title)} is not open in VS Code right now, so there is nothing to show here — this page loads it the moment it opens.<script>setTimeout(function () { location.reload(); }, 5000);</script></body></html>`;
1163
+ <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc">⚪ ${escapeAttribute(page.title)} is not open in VS Code right now, so there is nothing to show here — this page loads it the moment it opens.<div id="said" style="margin-top:8px"></div>
1164
+ <script>(function () {
1165
+ var opened = false;
1166
+ var socket = new WebSocket((location.protocol === "https:" ? "wss:" : "ws:") + "//" + location.host + "/__bullseye/ws?page=${encodeURIComponent(page.name)}&peek=1");
1167
+ function awaitHost() {
1168
+ document.getElementById("said").textContent = "⏳ This page's host is not answering — this page reloads the moment it does";
1169
+ fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { if (r.ok) location.reload(); else if (r.status === 401) location.assign("/"); else setTimeout(awaitHost, 1000); }, function () { setTimeout(awaitHost, 1000); });
1170
+ }
1171
+ socket.addEventListener("open", function () {
1172
+ opened = true;
1173
+ fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { return r.json(); }).then(function (health) { if (health.pages[${JSON.stringify(page.name)}].live) location.reload(); });
1174
+ });
1175
+ socket.addEventListener("message", function (event) { if (JSON.parse(String(event.data)).type === "reload") location.reload(); });
1176
+ socket.addEventListener("close", function () { if (opened) awaitHost(); else document.getElementById("said").textContent = "⚠️ This page could not reach its host, so it cannot load the page when it opens — reload it to try again"; });
1177
+ })();</script></body></html>`;
1178
+ }
1179
+ function codeDefect(err) {
1180
+ return err instanceof TypeError || err instanceof ReferenceError || err instanceof RangeError;
1141
1181
  }
1142
1182
  function send(response, status, type, body, headers = {}) {
1143
1183
  const payload = Buffer.isBuffer(body) ? body : Buffer.from(String(body), "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.314",
3
+ "version": "1.3.316",
4
4
  "description": "Reach your AI agents from anywhere — and let them reach you. One stdio process serves the whole tool surface to Claude Code, GitHub Copilot Chat and Codex: desktop, Telegram, Slack, ntfy, Discord, Teams and SMS are configured in one file, and agents notify you when long work finishes or a decision is needed, ask you a question and wait for your answer, and receive and reply to the messages you send them — with Do Not Disturb and idle detection deciding what actually gets through.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",