omni-notify-mcp 1.3.310 → 1.3.311

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.
@@ -22,7 +22,7 @@ import { PANEL_PAGES, panelHtml } from "./panelPage.js";
22
22
  import { wizard } from "./publicAccess.js";
23
23
  import { terminalHtml } from "./terminalPage.js";
24
24
  import { ServiceHost } from "../shared/webhost/bullseyeWebHost.js";
25
- import { openedWorkspaces, sameRoot } from "../shared/webhost/openedWorkspaces.js";
25
+ import { sameRoot, workspacesHere } from "../shared/webhost/workspaceList.js";
26
26
  export const BAD_TOKEN_ERROR = "missing or wrong token";
27
27
  // GATE: a request body past this is refused with 413 before it is parsed.
28
28
  const MAX_BODY_BYTES = 256 * 1024;
@@ -203,13 +203,13 @@ async function conversationStream(req, res, url) {
203
203
  function workspaceHost(port) {
204
204
  const host = new ServiceHost({
205
205
  extension: "bullseye-notify",
206
- workspaces: () => new Map(openedWorkspaces().map((w) => [w.label, Object.fromEntries(PANEL_PAGES.map((page) => [page, `/${page}?project=${encodeURIComponent(w.root)}`]))])),
206
+ workspaces: () => new Map(workspacesHere().map((w) => [w.label, Object.fromEntries(PANEL_PAGES.map((page) => [page, `/${page}?project=${encodeURIComponent(w.root)}`]))])),
207
207
  currentOf: (at) => {
208
208
  const project = at.get("project");
209
209
  // NULL-OK: field project is OPTIONAL and therefore it is ok to check for NULL
210
210
  if (project === null)
211
211
  return "";
212
- const workspace = openedWorkspaces().find((w) => sameRoot(w.root, project));
212
+ const workspace = workspacesHere().find((w) => sameRoot(w.root, project));
213
213
  // NULL-OK: field workspace is OPTIONAL and therefore it is ok to check for NULL
214
214
  return workspace?.label ?? "";
215
215
  },
@@ -101,13 +101,9 @@ function sameBoard(a, b) {
101
101
  function heldByWords(claim) {
102
102
  return `#${claim.storyId} is held by ${claim.name} (${String(claim.sessionId).replace(/^hold:/, "")}) — heartbeat ${claim.at}${claim.why === undefined ? "" : ` — why: ${claim.why}`}`;
103
103
  }
104
- /** The address every hold of this daemon is written under and released by (#2838). */
105
- function holdAddress() {
106
- return `hold:${hostname()}:${process.pid}`;
107
- }
108
- /** The hold a conversation writes for a story: a `hold` in the conversation's own name, addressed by this machine and this process exactly as the board's engine writes one (#2838). `drives` names the agent session this conversation runs, so a door can tell this hold from the work of the very session it holds for (#3850). */
109
- function holdOf(name, storyId, board, now, drives) {
110
- return { storyId, name, sessionId: holdAddress(), at: boardStamp(now), kind: "hold", board, drives };
104
+ /** The hold a conversation writes for a story: a `hold` in the conversation's own name, addressed by this machine and this process exactly as the board's engine writes one (#2838). */
105
+ function holdOf(name, storyId, board, now) {
106
+ return { storyId, name, sessionId: `hold:${hostname()}:${process.pid}`, at: boardStamp(now), kind: "hold", board };
111
107
  }
112
108
  /** The claims the file still holds at `now`, lapsed ones dropped exactly as every reader of the file drops them; a file that is not there is a machine that has claimed nothing. */
113
109
  function readClaims(file, now) {
@@ -211,16 +207,14 @@ function writeClaims(file, claims) {
211
207
  }
212
208
  }
213
209
  /** BN's conversation takes the story's hold: the holder's name IS the conversation's id, so every refusal and every door name this conversation. Another session's standing hold, or its fresh `taken` claim, refuses in the file's own words (#2838/#2040). */
214
- function holdStory(file, name, storyId, board, now, drives) {
215
- const claim = holdOf(name, storyId, board, now, drives);
210
+ function holdStory(file, name, storyId, board, now) {
211
+ const claim = holdOf(name, storyId, board, now);
216
212
  underClaimsLock(file, () => {
217
213
  const before = readClaims(file, now);
218
214
  const on = (c) => c.storyId === claim.storyId && sameBoard(c.board, board);
219
215
  const prior = before.find(on);
220
- if (prior !== undefined && prior.sessionId === drives)
221
- return;
222
- // The name IS the conversation's id, so a hold in it is this conversation's own even under the address of a BN process that died; a DIFFERENT conversation's hold has another name and neither may overwrite the other.
223
- const mine = prior !== undefined && prior.kind === "hold" && prior.name === claim.name;
216
+ // The derived sessionId is the same for every conversation of one daemon, so a DIFFERENT conversation in this process is another holder too — its own name is what tells two of them apart, and neither may overwrite the other.
217
+ const mine = prior !== undefined && prior.sessionId === claim.sessionId && prior.name === claim.name;
224
218
  if (prior !== undefined && !mine && (prior.kind === "hold" || claim.kind === "hold"))
225
219
  throw new GatewayError(409, heldByWords(prior));
226
220
  writeClaims(file, [...before.filter((c) => !on(c)), claim]);
@@ -228,7 +222,7 @@ function holdStory(file, name, storyId, board, now, drives) {
228
222
  }
229
223
  /** BN drops the hold it wrote when the work on the story ends: only the claim under its own address AND its own name goes — a different conversation of this daemon shares the address and must keep its own claim (#2838). */
230
224
  function releaseStory(file, name, storyId, board, now) {
231
- const mine = holdAddress();
225
+ const mine = holdOf(name, storyId, board, now).sessionId;
232
226
  underClaimsLock(file, () => {
233
227
  const before = readClaims(file, now);
234
228
  const isMine = (c) => c.storyId === storyId && sameBoard(c.board, board) && c.sessionId === mine && c.name === name;
@@ -685,7 +679,6 @@ export class SessionDriver {
685
679
  let beat;
686
680
  if (hold !== undefined) {
687
681
  const held = hold;
688
- this.refreshHold(c.id, held);
689
682
  beat = setInterval(() => this.refreshHold(c.id, held), HOLD_BEAT_MS);
690
683
  beat.unref();
691
684
  }
@@ -712,13 +705,13 @@ export class SessionDriver {
712
705
  // NULL-OK: field storyId is OPTIONAL and therefore it is ok to check for NULL
713
706
  if (storyId === undefined)
714
707
  return undefined;
715
- holdStory(claimsFile(), conversationId, storyId, project, Date.now(), readConversation(conversationId).sessionId);
708
+ holdStory(claimsFile(), conversationId, storyId, project, Date.now());
716
709
  return { storyId, board: project };
717
710
  }
718
711
  /** The hold is refreshed so it never lapses while the turn it belongs to runs. */
719
712
  refreshHold(conversationId, hold) {
720
713
  try {
721
- holdStory(claimsFile(), conversationId, hold.storyId, hold.board, Date.now(), readConversation(conversationId).sessionId);
714
+ holdStory(claimsFile(), conversationId, hold.storyId, hold.board, Date.now());
722
715
  }
723
716
  catch (err) {
724
717
  if (!(err instanceof Error))
@@ -255,6 +255,9 @@ export class WarmSession {
255
255
  return !this.ended && this.child.exitCode === null && this.child.signalCode === null && this.startError === undefined && this.writeError === undefined;
256
256
  }
257
257
  read(chunk) {
258
+ // A session that was ended reads nothing more: its state is gone, so no line of its output is handed on.
259
+ if (this.ended)
260
+ return;
258
261
  this.lineBuffer += chunk;
259
262
  for (let i = this.lineBuffer.indexOf("\n"); i >= 0; i = this.lineBuffer.indexOf("\n")) {
260
263
  const line = this.lineBuffer.slice(0, i).trim();
@@ -5,8 +5,10 @@ const http = require("http");
5
5
  const os = require("os");
6
6
  const path = require("path");
7
7
  const { SHIM_SOURCE } = require("./webviewShim");
8
+ const { workspacesHere } = require("./workspaceList");
8
9
  const WS_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
9
10
  const TOKEN_PARAMETER = "bullseye-token";
11
+ const PHONE_VIEWPORT = `<meta name="viewport" content="width=device-width, initial-scale=1">`;
10
12
  const VSCODE_CSP_SOURCE = "https://*.vscode-cdn.net";
11
13
  const RESOURCE_URL = /https:\/\/file(?:\+|%2B)\.vscode-resource\.vscode-cdn\.net(\/[^"'\s<>()\\?#]*)/gi;
12
14
  const MIME = {
@@ -218,7 +220,7 @@ function webDocument(source, { page, roots, theme }) {
218
220
  // NULL-OK: field theme is OPTIONAL and therefore it is ok to check for NULL
219
221
  const known = theme !== undefined;
220
222
  const vars = known ? Object.entries(theme.vars).map(([name, value]) => `${name}: ${value}`).join("; ") : "";
221
- const viewport = /<meta\b[^>]*\bname\s*=\s*["']viewport["']/i.test(source) ? "" : `<meta name="viewport" content="width=device-width, initial-scale=1">`;
223
+ const viewport = /<meta\b[^>]*\bname\s*=\s*["']viewport["']/i.test(source) ? "" : PHONE_VIEWPORT;
222
224
  const head = viewport +
223
225
  `<meta http-equiv="Content-Security-Policy" content="${policy}">` +
224
226
  `<style id="_defaultStyles">${known ? theme.defaultCss.replace(/<\/style/gi, "<\\/style") : ""}</style>` +
@@ -464,7 +466,6 @@ class Page {
464
466
  constructor(host, name, options) {
465
467
  this.host = host;
466
468
  this.name = name;
467
- this.open = options.open;
468
469
  // NULL-OK: field search is OPTIONAL and therefore it is ok to check for NULL
469
470
  this.search = options.search ?? "";
470
471
  // NULL-OK: field title is OPTIONAL and therefore it is ok to check for NULL
@@ -767,8 +768,8 @@ class WebHost {
767
768
  catch (err) {
768
769
  if (!(err instanceof SyntaxError))
769
770
  throw err;
770
- // OWNER: the page's workspace read is this read's trigger root — a record of opened workspaces that cannot be read is answered 500 with its reason and the process serving it goes on.
771
- return send(response, 500, MIME[".txt"], `the workspaces this host serves could not be read: ${err.message}`);
771
+ // OWNER: the page's workspace read is this read's trigger root — a workspace list that is not defined or cannot be read is answered with its reason beside this host's own workspace, so the page says why its picker is short, and the process serving it goes on.
772
+ return send(response, 200, MIME[".json"], JSON.stringify({ extension: this.extension, current: this.ownLabel(), chosen: "", workspaces: this.ownWorkspaces(base), listUnreadable: err.message }), { "Cache-Control": "no-store" });
772
773
  }
773
774
  let chosen = "";
774
775
  let chosenUnreadable;
@@ -783,9 +784,6 @@ class WebHost {
783
784
  }
784
785
  return send(response, 200, MIME[".json"], JSON.stringify({ extension: this.extension, current, chosen, chosenUnreadable, workspaces }), { "Cache-Control": "no-store" });
785
786
  }
786
- if (request.method === "POST" && url.pathname === "/__bullseye/open") {
787
- return this.openInVSCode(request, response, url.searchParams.get("page"));
788
- }
789
787
  if (request.method !== "GET" && request.method !== "HEAD") {
790
788
  return send(response, 405, MIME[".txt"], "method not allowed");
791
789
  }
@@ -815,9 +813,22 @@ class WebHost {
815
813
  }
816
814
  return this.serveDocument(page, response);
817
815
  }
818
- /** The workspaces a page of this host can switch to: label -> { page -> address }, built on `base` when the request came through the gateway. A window's host lists every live window serving the same extension. */
816
+ /** The workspaces a page of this host can switch to: label -> { page -> address }, built on `base` when the request came through the gateway. The workspaces are this window's own and the ones on the workspace list; a live window's record is only the address of that window's pages, never a source of the list. */
819
817
  workspaces(base) {
820
- return workspacesServed(this.extension, base);
818
+ const windows = workspacesServed(this.extension, base);
819
+ const listed = new Map(workspacesHere().filter((w) => windows.has(w.label)).map((w) => [w.label, windows.get(w.label)]));
820
+ if (windows.has(this.label))
821
+ listed.set(this.label, windows.get(this.label));
822
+ return listed;
823
+ }
824
+ /** The workspace a page of this host is on with no workspace list to read: this window's own. */
825
+ ownLabel() {
826
+ return this.label;
827
+ }
828
+ /** The workspaces a page of this host can switch to with no workspace list to read: this window's own, when its record is live. */
829
+ ownWorkspaces(base) {
830
+ const windows = workspacesServed(this.extension, base);
831
+ return windows.has(this.label) ? { [this.label]: windows.get(this.label) } : {};
821
832
  }
822
833
  /** The workspace the page asking is on, from the address it opened (`at`). A window's host is on its own window's workspace whatever the page asked. */
823
834
  currentOf() {
@@ -961,14 +972,6 @@ class WebHost {
961
972
  });
962
973
  return undefined;
963
974
  }
964
- openInVSCode(request, response, name) {
965
- const page = this.pages.get(name);
966
- if (!this.ownOrigin(request.headers.origin) || page === undefined || page.open === undefined) {
967
- return send(response, 403, MIME[".txt"], "refused");
968
- }
969
- Promise.resolve(page.open()).then(() => send(response, 204, MIME[".txt"], ""), (cause) => send(response, 500, MIME[".txt"], `could not open it in VS Code: ${cause instanceof Error ? cause.message : String(cause)}`));
970
- return undefined;
971
- }
972
975
  serveFile(encoded, response) {
973
976
  const file = fileOfResourcePath(encoded);
974
977
  const roots = [...this.pages.values()].filter((page) => page.live).flatMap((page) => page.mirror.roots());
@@ -1069,6 +1072,14 @@ class ServiceHost extends WebHost {
1069
1072
  workspaces() {
1070
1073
  return this.listed();
1071
1074
  }
1075
+ /** The always-on service is on no workspace of its own: with no workspace list to read it is on none. */
1076
+ ownLabel() {
1077
+ return "";
1078
+ }
1079
+ /** The always-on service has no workspace of its own to offer with no workspace list to read. */
1080
+ ownWorkspaces() {
1081
+ return {};
1082
+ }
1072
1083
  currentOf(at) {
1073
1084
  return this.current(at);
1074
1085
  }
@@ -1087,31 +1098,20 @@ function indexPage(host, base) {
1087
1098
  const rows = [...host.pages.values()]
1088
1099
  .map((page) => `<li><a href="${escapeAttribute(base === undefined ? page.url : `${base}/${encodeURIComponent(page.name)}/${page.search}`)}">${page.live ? "🟢" : "⚪"} ${escapeAttribute(page.title)}</a></li>`)
1089
1100
  .join("");
1090
- return `<!DOCTYPE html><html><head><meta charset="utf-8"><title>${escapeAttribute(host.extension)}</title></head>
1101
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(host.extension)}</title></head>
1091
1102
  <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div>${escapeAttribute(host.extension)} · ${escapeAttribute(host.label)}</div><ul>${rows}</ul></body></html>`;
1092
1103
  }
1093
1104
  /** The extensions whose page is a roster of work this window owns: another workspace's roster is not shown from here, so a peek at one answers in words instead of a page that could start work. */
1094
1105
  const ROSTER_EXTENSIONS = new Set(["fleetview"]);
1095
1106
  function peekedRosterPage(label, home, back) {
1096
1107
  const link = back === undefined ? "" : `<p><a href="${escapeAttribute(back)}" style="color:#9cdcfe">⬅ Back to ${escapeAttribute(home)}</a></p>`;
1097
- return `<!DOCTYPE html><html><head><meta charset="utf-8"><title>Fleet · peeking</title></head>
1108
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>Fleet · peeking</title></head>
1098
1109
  <body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc"><div style="background:#5a3d00;color:#fff;padding:6px 10px;border-radius:4px">👁 Peeking at ${escapeAttribute(label)} — look only</div>
1099
1110
  <p>This workspace's Fleet roster and queue belong to its own VS Code window, and they are not shown from another workspace yet — so there is nothing here to read, and nothing here can start work or reach that window's main.</p>${link}</body></html>`;
1100
1111
  }
1101
1112
  function closedPage(extension, page) {
1102
- const button = page.open === undefined
1103
- ? ""
1104
- : `<button id="open" style="font:inherit;padding:6px 14px;margin-top:12px;cursor:pointer">↗️ Open it in VS Code</button><div id="said" style="margin-top:8px"></div>
1105
- <script>document.getElementById("open").addEventListener("click", function () {
1106
- var b = this, said = document.getElementById("said"); b.disabled = true; b.style.cursor = "progress"; said.textContent = "⏳ Opening it in VS Code…";
1107
- fetch("/__bullseye/open?page=${encodeURIComponent(page.name)}", { method: "POST" }).then(function (r) {
1108
- b.disabled = false; b.style.cursor = "pointer";
1109
- if (r.ok) { said.textContent = "✅ Opened — loading it here"; setTimeout(function () { location.reload(); }, 800); } else { r.text().then(function (t) { said.textContent = "⛔ " + t; }); }
1110
- }, function (e) { b.disabled = false; b.style.cursor = "pointer"; said.textContent = "⛔ " + e.message; });
1111
- });
1112
- setTimeout(function () { location.reload(); }, 5000);</script>`;
1113
- return `<!DOCTYPE html><html><head><meta charset="utf-8"><title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
1114
- <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.${button}</body></html>`;
1113
+ return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
1114
+ <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>`;
1115
1115
  }
1116
1116
  function send(response, status, type, body, headers = {}) {
1117
1117
  const payload = Buffer.isBuffer(body) ? body : Buffer.from(String(body), "utf8");
@@ -123,11 +123,17 @@ const PICKER_SOURCE = String.raw `
123
123
  return;
124
124
  }
125
125
  window.fetch(workspacesUrl(), { cache: "no-store" }).then(function (response) {
126
- return response.ok ? response.json() : null;
126
+ return response.ok ? response.json() : response.text().then(function (text) {
127
+ notice("__bullseye-workspace-unread", "⛔ The workspace picker could not be drawn (" + response.status + ") — " + text);
128
+ return null;
129
+ });
127
130
  }).then(function (served) {
128
131
  if (served === null) {
129
132
  return;
130
133
  }
134
+ if (served.listUnreadable !== undefined) {
135
+ notice("__bullseye-workspace-unread", "⛔ Workspace list: " + served.listUnreadable + " — this page offers only its own workspace until the list is fixed on Bullseye Control");
136
+ }
131
137
  var labels = Object.keys(served.workspaces).filter(function (label) {
132
138
  return served.workspaces[label][page] !== undefined;
133
139
  });
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ const crypto = require("crypto");
3
+ const fs = require("fs");
4
+ const os = require("os");
5
+ const path = require("path");
6
+ function workspacesFile() {
7
+ return path.join(os.homedir(), ".bullseye", "workspaces", "settings.json");
8
+ }
9
+ class WorkspacesUndefined extends SyntaxError {
10
+ }
11
+ function stored(root) {
12
+ if (!path.isAbsolute(root))
13
+ return root;
14
+ const home = os.homedir();
15
+ const relative = path.relative(home, root);
16
+ return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative) ? `~/${relative.split(path.sep).join("/")}` : root;
17
+ }
18
+ function resolved(entry) {
19
+ return entry === "~" || entry.startsWith("~/") ? path.join(os.homedir(), ...entry.slice(2).split("/").filter((part) => part !== "")) : path.resolve(entry);
20
+ }
21
+ function homeRelative(entry) {
22
+ return entry === "~" || entry.startsWith("~/");
23
+ }
24
+ function labelOf(root) {
25
+ const name = path.basename(root);
26
+ return fs.existsSync(path.join(root, `${name}.code-workspace`)) ? `${name} (Workspace)` : name;
27
+ }
28
+ function rootKey(root) {
29
+ if (process.platform !== "win32")
30
+ return root.replace(/\/+$/, "");
31
+ return path.win32.normalize(root).replace(/[\\/]+$/, "").toLowerCase();
32
+ }
33
+ /** #3588 — whether two paths name one workspace root; the ONE comparison every service uses to match a page's `?project=` against a listed workspace. */
34
+ function sameRoot(a, b) {
35
+ return rootKey(a) === rootKey(b);
36
+ }
37
+ function nameKey(entry) {
38
+ return path.basename(homeRelative(entry) ? entry : path.resolve(entry)).toLowerCase();
39
+ }
40
+ function listedWorkspaces() {
41
+ const file = workspacesFile();
42
+ let text;
43
+ try {
44
+ text = fs.readFileSync(file, "utf8");
45
+ }
46
+ catch (err) {
47
+ if (err.code === "ENOENT")
48
+ throw new WorkspacesUndefined(`no workspace list is defined on this machine yet — add the folders on Bullseye Control (${file})`);
49
+ throw new SyntaxError(`${file} could not be read as the workspace list: ${err.message}`);
50
+ }
51
+ let entries;
52
+ try {
53
+ entries = JSON.parse(text).workspaces;
54
+ }
55
+ catch (err) {
56
+ throw new SyntaxError(`${file} is not the workspace list: ${err.message}`);
57
+ }
58
+ if (!Array.isArray(entries) || entries.some((entry) => entry === null || typeof entry !== "object" || typeof entry.path !== "string" || entry.path.trim() === "")) {
59
+ throw new SyntaxError(`${file} is not the workspace list: "workspaces" must be a list of { "path": "<folder>" }`);
60
+ }
61
+ const named = new Map();
62
+ for (const entry of entries) {
63
+ const twin = named.get(nameKey(entry.path));
64
+ if (twin !== undefined)
65
+ throw new SyntaxError(`${file} names two folders called ${path.basename(resolved(entry.path))} (${twin} and ${entry.path}) — a workspace is named by its folder, so take one off the list on Bullseye Control`);
66
+ named.set(nameKey(entry.path), entry.path);
67
+ }
68
+ return entries.map((entry) => {
69
+ const root = resolved(entry.path);
70
+ let present = false;
71
+ try {
72
+ present = fs.existsSync(root) && fs.statSync(root).isDirectory();
73
+ }
74
+ catch (err) {
75
+ throw new SyntaxError(`${root}, on the workspace list in ${file}, could not be read: ${err.message}`);
76
+ }
77
+ return { label: present ? labelOf(root) : path.basename(root), root, path: entry.path, present };
78
+ });
79
+ }
80
+ function workspacesHere() {
81
+ return listedWorkspaces().filter((w) => w.present).map(({ label, root }) => ({ label, root }));
82
+ }
83
+ /** The list a Save is made from, as its bytes on disk: their sha256, or "undefined" when no list is defined. A file that is there but cannot be read THROWS, so no Save can be made from it unseen. */
84
+ function listBase() {
85
+ const file = workspacesFile();
86
+ if (!fs.existsSync(file))
87
+ return "undefined";
88
+ return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
89
+ }
90
+ function saveWorkspaces(folders) {
91
+ const seen = new Set();
92
+ const named = new Map();
93
+ const entries = [];
94
+ for (const folder of folders) {
95
+ if (typeof folder !== "string" || !(homeRelative(folder) || path.win32.isAbsolute(folder) || path.posix.isAbsolute(folder)))
96
+ throw new TypeError(`a workspace is an absolute folder path or a ~/ path, not ${JSON.stringify(folder)}`);
97
+ const entry = homeRelative(folder) ? folder : stored(folder);
98
+ const key = rootKey(resolved(entry));
99
+ if (seen.has(key))
100
+ continue;
101
+ seen.add(key);
102
+ const twin = named.get(nameKey(entry));
103
+ if (twin !== undefined)
104
+ throw new TypeError(`two folders called ${path.basename(resolved(entry))} cannot both be on the list (${twin} and ${entry}) — a workspace is named by its folder`);
105
+ named.set(nameKey(entry), entry);
106
+ entries.push({ path: entry });
107
+ }
108
+ const file = workspacesFile();
109
+ fs.mkdirSync(path.dirname(file), { recursive: true });
110
+ const staged = `${file}.${process.pid}.tmp`;
111
+ fs.writeFileSync(staged, `${JSON.stringify({ workspaces: entries }, null, 2)}\n`);
112
+ fs.renameSync(staged, file);
113
+ }
114
+ module.exports = { workspacesFile, WorkspacesUndefined, listedWorkspaces, workspacesHere, listBase, saveWorkspaces, sameRoot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.310",
3
+ "version": "1.3.311",
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",
@@ -1,62 +0,0 @@
1
- "use strict";
2
- const fs = require("fs");
3
- const os = require("os");
4
- const path = require("path");
5
- const { fileURLToPath } = require("url");
6
- /** The User folder of every VS Code flavour that exists on this machine, per OS. */
7
- function userFolders() {
8
- const home = os.homedir();
9
- const root = process.platform === "win32"
10
- ? (process.env.APPDATA ?? path.join(home, "AppData", "Roaming"))
11
- : process.platform === "darwin"
12
- ? path.join(home, "Library", "Application Support")
13
- : (process.env.XDG_CONFIG_HOME ?? path.join(home, ".config"));
14
- return ["Code", "Code - Insiders", "VSCodium"].map((flavour) => path.join(root, flavour, "User")).filter((folder) => fs.existsSync(folder));
15
- }
16
- /** The workspace paths one VS Code record holds; a record that cannot be read as that is a SyntaxError naming the file and why, the one kind the service host answers instead of dying on. */
17
- function recordedTargets(file) {
18
- try {
19
- const associations = JSON.parse(fs.readFileSync(file, "utf8")).profileAssociations;
20
- // NULL-OK: field profileAssociations is OPTIONAL and therefore it is ok to check for NULL
21
- return Object.keys(associations?.workspaces ?? {}).filter((uri) => uri.startsWith("file://")).map((uri) => fileURLToPath(uri));
22
- }
23
- catch (err) {
24
- throw new SyntaxError(`${file} could not be read as VS Code's workspace record: ${err instanceof Error ? err.message : String(err)}`);
25
- }
26
- }
27
- /** The identity of a workspace root: on Windows the path is case-insensitive and either separator, so C:\a\b and c:/a/b/ are one key. */
28
- function rootKey(root) {
29
- if (process.platform !== "win32")
30
- return root;
31
- return path.win32.normalize(root).replace(/[\\/]+$/, "").toLowerCase();
32
- }
33
- /** #3588 — whether two paths name one workspace root; the ONE comparison every service uses to match a page's `?project=` against an opened workspace. */
34
- function sameRoot(a, b) {
35
- return rootKey(a) === rootKey(b);
36
- }
37
- /**
38
- * #3566 — the ONE list of every workspace VS Code has opened on this machine, as VS Code itself records them (the
39
- * `profileAssociations` of its global storage), so a page an always-on service draws can list them with no window open.
40
- * Each is its root folder and the name VS Code gives it: a `.code-workspace` file is `<name> (Workspace)`, a folder its
41
- * own name. A record that cannot be read throws a SyntaxError — a page that lists no workspace because the record was
42
- * unreadable would say nothing opened.
43
- */
44
- function openedWorkspaces() {
45
- const seen = new Map();
46
- for (const folder of userFolders()) {
47
- const file = path.join(folder, "globalStorage", "storage.json");
48
- if (!fs.existsSync(file))
49
- continue;
50
- for (const target of recordedTargets(file)) {
51
- const workspaceFile = target.endsWith(".code-workspace");
52
- const root = workspaceFile ? path.dirname(target) : target;
53
- const label = workspaceFile ? `${path.basename(target, ".code-workspace")} (Workspace)` : path.basename(target);
54
- const key = rootKey(root);
55
- // A folder opened both bare and through its .code-workspace is one workspace: the workspace file's name is the one its windows carry.
56
- if (workspaceFile || !seen.has(key))
57
- seen.set(key, { label, root });
58
- }
59
- }
60
- return [...seen.values()];
61
- }
62
- module.exports = { openedWorkspaces, sameRoot };