omni-notify-mcp 1.3.310 → 1.3.312
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/dist/gateway/claudeProvider.js +25 -4
- package/dist/gateway/conversations.js +28 -0
- package/dist/gateway/restDoor.js +3 -3
- package/dist/gateway/sessionDriver.js +36 -5
- package/dist/shared/agentSession.js +3 -0
- package/dist/shared/webhost/bullseyeWebHost.js +32 -32
- package/dist/shared/webhost/webviewShim.js +7 -1
- package/dist/shared/webhost/workspaceList.js +114 -0
- package/package.json +1 -1
- package/dist/shared/webhost/openedWorkspaces.js +0 -62
|
@@ -34,13 +34,16 @@ function activity(tool) {
|
|
|
34
34
|
const mcp = /^mcp__([^_]+(?:_[^_]+)*)__/.exec(tool);
|
|
35
35
|
return mcp ? `using ${mcp[1]}` : `using ${tool}`;
|
|
36
36
|
}
|
|
37
|
+
function projectsDir() {
|
|
38
|
+
return join(process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "projects");
|
|
39
|
+
}
|
|
37
40
|
/**
|
|
38
41
|
* Whether the CLI has written this session's transcript. A first turn cut off before its result line (BN restarted
|
|
39
42
|
* under it) leaves one behind with the record still unstarted, and the CLI then refuses `--session-id` for that id as
|
|
40
43
|
* already in use: such a session is resumed, never created again.
|
|
41
44
|
*/
|
|
42
45
|
function transcriptWritten(sessionId) {
|
|
43
|
-
const projects =
|
|
46
|
+
const projects = projectsDir();
|
|
44
47
|
if (!existsSync(projects))
|
|
45
48
|
return false;
|
|
46
49
|
return readdirSync(projects).some((dir) => existsSync(join(projects, dir, `${sessionId}.jsonl`)));
|
|
@@ -315,15 +318,21 @@ class ClaudeSession {
|
|
|
315
318
|
sink.layers(clock.finish(monotonicMs(), this.debugFile));
|
|
316
319
|
this.sink = undefined;
|
|
317
320
|
}
|
|
321
|
+
// A session that was ended reads no record: its answer is refused here, before any record is read for it.
|
|
322
|
+
if (this.warm.stopped)
|
|
323
|
+
throw this.spec.failures.fail("the agent's session was ended");
|
|
318
324
|
// NULL-OK: field unsupported is OPTIONAL and therefore it is ok to check for NULL
|
|
319
325
|
if (this.unsupported !== undefined)
|
|
320
326
|
throw this.spec.failures.fail(`the agent asked BN for "${this.unsupported}", which BN does not answer — the session was ended.`);
|
|
321
327
|
if (result.stdout === "") {
|
|
328
|
+
const exited = `the agent exited (code ${result.code ?? "none"}) without an answer while ${this.resumes ? "resuming" : "creating"} session ${this.spec.sessionId}${result.stderr.trim() ? `: ${result.stderr.trim().slice(-300)}` : ""}`;
|
|
329
|
+
if (this.resumes && !transcriptWritten(this.spec.sessionId))
|
|
330
|
+
throw this.lost(exited, sink);
|
|
322
331
|
// A first turn that died before the CLI wrote its session leaves a half-made id: the retry starts a new one, and
|
|
323
332
|
// a session the record already holds is never overwritten by it.
|
|
324
333
|
if (!this.spec.isStarted() && !this.resumes)
|
|
325
334
|
sink.sessionId(randomUUID(), false);
|
|
326
|
-
throw this.spec.failures.fail(
|
|
335
|
+
throw this.spec.failures.fail(exited);
|
|
327
336
|
}
|
|
328
337
|
let parsed;
|
|
329
338
|
try {
|
|
@@ -336,8 +345,14 @@ class ClaudeSession {
|
|
|
336
345
|
throw new AgentTurnFailed(text, `❌ The agent's answer was unreadable: ${result.stdout.slice(0, 200)}`);
|
|
337
346
|
}
|
|
338
347
|
if (parsed.is_error === true) {
|
|
339
|
-
const
|
|
340
|
-
|
|
348
|
+
const subtype = parsed.subtype ?? "error";
|
|
349
|
+
const parts = [...new Set([String(parsed.result ?? ""), ...(Array.isArray(parsed.errors) ? parsed.errors.map(String) : []), result.stderr].map((part) => part.trim()).filter((part) => part !== ""))];
|
|
350
|
+
const said = parts.length === 0 ? "the CLI gave no reason on its result line or its stderr" : parts.join(" — ");
|
|
351
|
+
const how = this.resumes ? `resuming session ${this.spec.sessionId}` : `creating session ${this.spec.sessionId}`;
|
|
352
|
+
const detail = `the Claude CLI ended the turn with ${subtype} while ${how} in ${this.spec.project}: ${said.slice(0, 300)}`;
|
|
353
|
+
if (this.resumes && !transcriptWritten(this.spec.sessionId))
|
|
354
|
+
throw this.lost(detail, sink);
|
|
355
|
+
throw new AgentTurnFailed(detail, `❌ The agent reported an error (${subtype}) while ${how}: ${said.slice(0, 300)}`);
|
|
341
356
|
}
|
|
342
357
|
const answer = parsed.result;
|
|
343
358
|
if (typeof answer !== "string") {
|
|
@@ -354,6 +369,12 @@ class ClaudeSession {
|
|
|
354
369
|
}
|
|
355
370
|
return answer;
|
|
356
371
|
}
|
|
372
|
+
/** A resume the CLI could not make because the session's transcript is gone: the record moves to a new session id, so the next message creates one under this same conversation, and the turn fails saying so. */
|
|
373
|
+
lost(detail, sink) {
|
|
374
|
+
sink.sessionId(randomUUID(), false);
|
|
375
|
+
const lost = `this conversation's agent session ${this.spec.sessionId} cannot be resumed — its saved history is no longer on disk under ${projectsDir()} (${detail})`;
|
|
376
|
+
return new AgentTurnFailed(lost, `❌ ${lost[0].toUpperCase()}${lost.slice(1)}. Nothing was run. A message already waiting runs in a new agent session of this same conversation, and a message sent now does the same; that session starts without the earlier turns, so include what it needs to know.`);
|
|
377
|
+
}
|
|
357
378
|
answerPermission(requestId, allow, refusal) {
|
|
358
379
|
const response = allow ? { behavior: "allow", updatedInput: this.inputs.get(requestId) } : { behavior: "deny", message: `Refused over chat: ${refusal}` };
|
|
359
380
|
this.inputs.delete(requestId);
|
|
@@ -161,10 +161,38 @@ function textAt(file) {
|
|
|
161
161
|
throw err;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
/** Whether a process id still names a live process: EPERM means it exists and this account may not signal it. */
|
|
165
|
+
export function pidAlive(pid) {
|
|
166
|
+
try {
|
|
167
|
+
process.kill(pid, 0);
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const code = error.code;
|
|
172
|
+
if (code === "EPERM")
|
|
173
|
+
return true;
|
|
174
|
+
if (code === "ESRCH")
|
|
175
|
+
return false;
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
let sweptStaged = false;
|
|
180
|
+
/** Removes every <name>.json.<pid>.tmp of the agent store whose writer is no longer a live process: a BN killed between a staged write and its rename leaves one nothing else ever removes. Runs once per BN process, on the store's first listing at boot. */
|
|
181
|
+
function sweepDeadStaged() {
|
|
182
|
+
sweptStaged = true;
|
|
183
|
+
for (const name of readdirSync(agentDir())) {
|
|
184
|
+
const writer = /\.json\.(\d+)\.tmp$/.exec(name)?.[1];
|
|
185
|
+
// NULL-OK: field writer is OPTIONAL and therefore it is ok to check for NULL
|
|
186
|
+
if (writer !== undefined && !pidAlive(Number(writer)))
|
|
187
|
+
dropStaged(join(agentDir(), name));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
164
190
|
/** Every conversation, newest first. */
|
|
165
191
|
export function listConversations(includeInteractive = false) {
|
|
166
192
|
if (!existsSync(agentDir()))
|
|
167
193
|
return [];
|
|
194
|
+
if (!sweptStaged)
|
|
195
|
+
sweepDeadStaged();
|
|
168
196
|
return readdirSync(agentDir())
|
|
169
197
|
.filter((name) => name.endsWith(".json") && UUID.test(name.slice(0, -5)))
|
|
170
198
|
.flatMap((name) => recordAt(join(agentDir(), name)) ?? [])
|
package/dist/gateway/restDoor.js
CHANGED
|
@@ -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 {
|
|
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(
|
|
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 =
|
|
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
|
},
|
|
@@ -260,6 +260,10 @@ export class SessionDriver {
|
|
|
260
260
|
archiveIdleMs;
|
|
261
261
|
lives = new Map();
|
|
262
262
|
driving = new Set();
|
|
263
|
+
/** Every conversation's queue loop still running: shutdown stops them and waits for each to finish. */
|
|
264
|
+
loops = new Set();
|
|
265
|
+
/** Set by shutdown: no queue loop begins another iteration, so none reads a record after the store was handed back. */
|
|
266
|
+
stopping = false;
|
|
263
267
|
archiving = new Set();
|
|
264
268
|
/** Conversations waiting for a slot, first come first served. */
|
|
265
269
|
waiting = [];
|
|
@@ -297,6 +301,7 @@ export class SessionDriver {
|
|
|
297
301
|
* cut off in the middle of is taken up again on the same session; then the store is read on a beat.
|
|
298
302
|
*/
|
|
299
303
|
boot() {
|
|
304
|
+
this.stopping = false;
|
|
300
305
|
if (this.watcher !== undefined)
|
|
301
306
|
return;
|
|
302
307
|
this.bootedAt = Date.now();
|
|
@@ -418,7 +423,8 @@ export class SessionDriver {
|
|
|
418
423
|
return this.driving.size === 0 && this.waiting.length === 0;
|
|
419
424
|
}
|
|
420
425
|
/** Hands the store back: the beat stops and every held session's process is ended, its conversation left idle for the next owner to resume. */
|
|
421
|
-
shutdown() {
|
|
426
|
+
async shutdown() {
|
|
427
|
+
this.stopping = true;
|
|
422
428
|
this.watcher?.close();
|
|
423
429
|
this.watcher = undefined;
|
|
424
430
|
clearTimeout(this.dueTimer);
|
|
@@ -428,7 +434,8 @@ export class SessionDriver {
|
|
|
428
434
|
this.spare = undefined;
|
|
429
435
|
this.resuming.clear();
|
|
430
436
|
for (const id of [...this.lives.keys()])
|
|
431
|
-
this.
|
|
437
|
+
this.endLive(id);
|
|
438
|
+
await Promise.all([...this.loops]);
|
|
432
439
|
}
|
|
433
440
|
/** Closes the conversation and reaps its process tree at once. */
|
|
434
441
|
stop(id) {
|
|
@@ -616,7 +623,9 @@ export class SessionDriver {
|
|
|
616
623
|
}
|
|
617
624
|
/** Runs a conversation's queue; a failure is written into its own log rather than left as an unhandled rejection. */
|
|
618
625
|
driveNow(id) {
|
|
619
|
-
|
|
626
|
+
if (this.stopping)
|
|
627
|
+
return;
|
|
628
|
+
const loop = this.drive(id).catch((err) => {
|
|
620
629
|
process.stderr.write(`[agent-gateway] the driver of ${id} failed: ${err instanceof Error ? err.message : String(err)}
|
|
621
630
|
`);
|
|
622
631
|
const live = this.lives.get(id);
|
|
@@ -624,12 +633,16 @@ export class SessionDriver {
|
|
|
624
633
|
this.emit(id, "system", "failed", `❌ The conversation could not carry on: ${err instanceof Error ? err.message : String(err)}`, turn, this.failureTiming(id, turn, Date.now()));
|
|
625
634
|
this.release(id);
|
|
626
635
|
});
|
|
636
|
+
this.loops.add(loop);
|
|
637
|
+
void loop.then(() => this.loops.delete(loop));
|
|
627
638
|
}
|
|
628
639
|
// OWNER: ITER/LOOP — one conversation's turns run one after another; a turn that fails is written into its own log as a failed event and the loop takes the next message.
|
|
629
640
|
async drive(id) {
|
|
630
641
|
this.driving.add(id);
|
|
631
642
|
try {
|
|
632
643
|
for (;;) {
|
|
644
|
+
if (this.stopping)
|
|
645
|
+
return;
|
|
633
646
|
const c = readConversation(id);
|
|
634
647
|
if (c.state === "closed" || conversationRefusal() !== undefined)
|
|
635
648
|
return;
|
|
@@ -782,6 +795,8 @@ export class SessionDriver {
|
|
|
782
795
|
}
|
|
783
796
|
/** A slot came free: the first conversation in line takes it. */
|
|
784
797
|
drain() {
|
|
798
|
+
if (this.stopping)
|
|
799
|
+
return;
|
|
785
800
|
const first = this.waiting[0];
|
|
786
801
|
// NULL-OK: field first is OPTIONAL and therefore it is ok to check for NULL
|
|
787
802
|
if (first === undefined || this.driving.has(first))
|
|
@@ -859,6 +874,8 @@ export class SessionDriver {
|
|
|
859
874
|
catch (err) {
|
|
860
875
|
if (!(err instanceof AgentTurnFailed))
|
|
861
876
|
throw err;
|
|
877
|
+
process.stderr.write(`[agent-gateway] ${c.id} turn ${message.n} failed: ${err.message}
|
|
878
|
+
`);
|
|
862
879
|
failure = err.shown ?? `❌ The agent could not answer: ${err.message}`;
|
|
863
880
|
}
|
|
864
881
|
const answeredAt = monotonicMs();
|
|
@@ -870,6 +887,10 @@ export class SessionDriver {
|
|
|
870
887
|
return;
|
|
871
888
|
const mark = { message, startEvent, startedAt, startedWall, askAt, answeredAt };
|
|
872
889
|
this.answer(c.id, message.n, result, failure, (storeAt) => this.timing(c, live, opened, mark, storeAt));
|
|
890
|
+
if (live.rotated) {
|
|
891
|
+
this.free(c.id, "idle");
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
873
894
|
if (live.stalled) {
|
|
874
895
|
// The CLI was killed at the silence bound: its slot goes to the message in line in the same step as that failure.
|
|
875
896
|
this.free(c.id, "idle");
|
|
@@ -894,7 +915,9 @@ export class SessionDriver {
|
|
|
894
915
|
updateConversation(id, { pid });
|
|
895
916
|
},
|
|
896
917
|
sessionId: (sessionId, written) => {
|
|
897
|
-
updateConversation(id,
|
|
918
|
+
updateConversation(id, { sessionId, started: written });
|
|
919
|
+
if (!written)
|
|
920
|
+
live.rotated = true;
|
|
898
921
|
},
|
|
899
922
|
started: () => {
|
|
900
923
|
updateConversation(id, { started: true });
|
|
@@ -1142,7 +1165,8 @@ export class SessionDriver {
|
|
|
1142
1165
|
return event;
|
|
1143
1166
|
}
|
|
1144
1167
|
/** Ends a session's process and gives its slot back; `keep` leaves the record's own state to the caller that is handing the session over. */
|
|
1145
|
-
|
|
1168
|
+
/** Ends the process of a live session and forgets the session; the record is left as its caller sets it. */
|
|
1169
|
+
endLive(id) {
|
|
1146
1170
|
const live = this.lives.get(id);
|
|
1147
1171
|
// NULL-OK: field live is OPTIONAL and therefore it is ok to check for NULL
|
|
1148
1172
|
if (live === undefined)
|
|
@@ -1155,6 +1179,13 @@ export class SessionDriver {
|
|
|
1155
1179
|
if (unstopped)
|
|
1156
1180
|
process.stderr.write(`[agent-gateway] the agent of ${id} was ended${unstopped}\n`);
|
|
1157
1181
|
live.ended();
|
|
1182
|
+
}
|
|
1183
|
+
/** Ends a session's process and gives its slot back; `keep` leaves the record's own state to the caller that is handing the session over. */
|
|
1184
|
+
free(id, state) {
|
|
1185
|
+
// NULL-OK: field live is OPTIONAL and therefore it is ok to check for NULL
|
|
1186
|
+
if (this.stopping || this.lives.get(id) === undefined)
|
|
1187
|
+
return;
|
|
1188
|
+
this.endLive(id);
|
|
1158
1189
|
if (state !== "keep")
|
|
1159
1190
|
updateConversation(id, { state, pid: undefined });
|
|
1160
1191
|
this.drain();
|
|
@@ -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) ? "" :
|
|
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
|
|
771
|
-
return send(response,
|
|
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.
|
|
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
|
-
|
|
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"
|
|
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"
|
|
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
|
-
|
|
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() :
|
|
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.
|
|
3
|
+
"version": "1.3.312",
|
|
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 };
|