omni-notify-mcp 1.3.325 → 1.3.326
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/daemon.js
CHANGED
|
@@ -13,33 +13,48 @@ import { spawn } from "child_process";
|
|
|
13
13
|
import { existsSync, readFileSync, renameSync, writeFileSync, mkdirSync } from "fs";
|
|
14
14
|
import { join } from "path";
|
|
15
15
|
import { fileURLToPath } from "url";
|
|
16
|
-
import {
|
|
16
|
+
import { DAEMON_BEAT_PATH, CONFIG_DIR, PACKAGE_VERSION, startNotifyServer, yieldGateway } from "./notify.js";
|
|
17
17
|
import { startNotifyDoor } from "./gateway/notifyDoor.js";
|
|
18
18
|
import { announceTakeover, inThisBoot } from "./shared/webhost/originHandover.js";
|
|
19
19
|
import { TunnelRunner } from "./gateway/tunnel.js";
|
|
20
20
|
const HEARTBEAT_MS = 10_000;
|
|
21
|
+
/** the beat's name in the release before: a box that has not run this release's activation still has that release's lifecycle staged, which reads only this name, so for one release the beat is written under both. */
|
|
22
|
+
const OLD_BEAT_PATH = join(CONFIG_DIR, "always-on.json");
|
|
21
23
|
function beat(pid = process.pid) {
|
|
22
24
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const text = JSON.stringify({ pid, at: Date.now(), version: PACKAGE_VERSION });
|
|
26
|
+
for (const file of [DAEMON_BEAT_PATH, OLD_BEAT_PATH]) {
|
|
27
|
+
const staged = `${file}.${process.pid}.tmp`;
|
|
28
|
+
writeFileSync(staged, text);
|
|
29
|
+
renameSync(staged, file);
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
|
-
/**
|
|
32
|
+
/** The boot supervisor's login entry: launchd's label and systemd's unit. the release before registered it under the old names, which a daemon it started is told by for one release. */
|
|
33
|
+
const ENTRY_LABELS = ["com.bullseye.BullseyeMcpOrigins", "com.bullseye.BullseyeNotifyAlwaysOn"];
|
|
34
|
+
const ENTRY_UNITS = ["bullseye-mcp-origins.service", "bullseye-notify-always-on.service"];
|
|
35
|
+
/** BN's lifecycle in the config dir, then its name in the release before, which that release's activation staged, read for one release. */
|
|
36
|
+
const SUPERVISE_LOOPS = [join(CONFIG_DIR, "bnDaemon.js"), join(CONFIG_DIR, "alwaysOn.js")];
|
|
37
|
+
/** The Stop the panel writes, then its name in the release before, read for one release. */
|
|
38
|
+
const STOP_FILES = [join(CONFIG_DIR, "daemon-stop.json"), join(CONFIG_DIR, "always-on-desired.json")];
|
|
39
|
+
/** Run by the boot supervisor (BullseyeShared workspace-mcp/originSupervisor.js, under the login starter every Bullseye extension installs), or on Windows by the login session's supervise loop in bnDaemon.js, each of which starts it again when it exits. On Windows that supervisor is this process's IPC parent: the channel is open only while it lives, so a dead supervisor, or a reused pid, never reads as supervised. */
|
|
28
40
|
function supervised() {
|
|
29
41
|
if (process.platform === "win32")
|
|
30
42
|
return process.connected === true;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
if (process.platform === "darwin")
|
|
44
|
+
return ENTRY_LABELS.includes(process.env.XPC_SERVICE_NAME ?? "");
|
|
45
|
+
if (process.platform !== "linux")
|
|
46
|
+
return false;
|
|
47
|
+
const cgroup = readFileSync("/proc/self/cgroup", "utf8");
|
|
48
|
+
return ENTRY_UNITS.some((unit) => cgroup.includes(unit));
|
|
34
49
|
}
|
|
35
50
|
/** Who starts the installed build after this unsupervised process exits: on Windows the supervise loop the login entry and the boot task keep in the config dir, which owns every run after this one; elsewhere the same entry, started again. */
|
|
36
51
|
function successor() {
|
|
37
52
|
const self = fileURLToPath(import.meta.url);
|
|
38
53
|
if (process.platform !== "win32")
|
|
39
54
|
return spawn(process.execPath, [...process.execArgv, self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
40
|
-
const loop =
|
|
41
|
-
if (
|
|
42
|
-
throw new Error(`the supervise loop is not in the config dir at ${
|
|
55
|
+
const loop = SUPERVISE_LOOPS.find((file) => existsSync(file));
|
|
56
|
+
if (loop === undefined)
|
|
57
|
+
throw new Error(`the supervise loop is not in the config dir at ${SUPERVISE_LOOPS[0]} — the login entry and the boot task copy it there, so nothing can own the next run`);
|
|
43
58
|
return spawn(process.execPath, [loop, "supervise", self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
44
59
|
}
|
|
45
60
|
/** The installed build has replaced this one on disk: a supervised process only exits and its owner starts that build; an unsupervised one starts its successor and names it in the heartbeat before it exits, so no other owner starts a second build meanwhile, and on Windows the supervise loop reads that beat as the claim on its first run. */
|
|
@@ -53,22 +68,26 @@ function replaceWithInstalledBuild() {
|
|
|
53
68
|
}
|
|
54
69
|
process.exit(0);
|
|
55
70
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!existsSync(desired))
|
|
60
|
-
return false;
|
|
61
|
-
let pressed;
|
|
71
|
+
function pressedIn(file) {
|
|
72
|
+
if (!existsSync(file))
|
|
73
|
+
return undefined;
|
|
62
74
|
try {
|
|
63
|
-
|
|
75
|
+
return { ...JSON.parse(readFileSync(file, "utf8")), file };
|
|
64
76
|
}
|
|
65
77
|
catch (err) {
|
|
66
|
-
throw new Error(`${
|
|
78
|
+
throw new Error(`${file} is not readable JSON, so whether a Stop was pressed on this machine cannot be known — ${err.message}`);
|
|
67
79
|
}
|
|
80
|
+
}
|
|
81
|
+
/** The Stop the panel pressed is this machine's own setting until a Start or the next boot (#3849 Q782), so a process a login entry started after it in this boot reads the same file and starts nothing. Absent, the machine has never been stopped and starts as it always has. */
|
|
82
|
+
function stoppedByHand() {
|
|
83
|
+
const [now, old] = STOP_FILES.map(pressedIn);
|
|
84
|
+
const pressed = old !== undefined && (now === undefined || (old.at ?? -Infinity) > (now.at ?? -Infinity)) ? old : now;
|
|
85
|
+
if (pressed === undefined)
|
|
86
|
+
return false;
|
|
68
87
|
if (pressed.desired !== "stopped")
|
|
69
88
|
return false;
|
|
70
89
|
if (typeof pressed.at !== "number")
|
|
71
|
-
throw new Error(`${
|
|
90
|
+
throw new Error(`${pressed.file} names a Stop with no time it was pressed, so whether it was pressed in this boot cannot be known`);
|
|
72
91
|
return inThisBoot(pressed.at);
|
|
73
92
|
}
|
|
74
93
|
if (stoppedByHand()) {
|
|
@@ -25,7 +25,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
25
25
|
import { createMcpServer, sessionIdentity } from "../notify.js";
|
|
26
26
|
import { answerShutdown, healthBody, TAKEOVER_BIND } from "../shared/webhost/originHandover.js";
|
|
27
27
|
/** BN's own port block: 7470 is the gateway, so the chat tools take the next free one. */
|
|
28
|
-
// GATE: the door's port may be moved ONLY under the test gate, so a suite drives a real daemon on a port it owns; without the gate it is 7475 and no environment can redirect it. vscode-extension/
|
|
28
|
+
// GATE: the door's port may be moved ONLY under the test gate, so a suite drives a real daemon on a port it owns; without the gate it is 7475 and no environment can redirect it. vscode-extension/bnDaemon.js probes the same rule.
|
|
29
29
|
export const NOTIFY_DOOR_PORT = process.env.NOTIFY_MCP_TEST_ENDPOINTS === "1" && Number(process.env.NOTIFY_DOOR_PORT) > 0 ? Number(process.env.NOTIFY_DOOR_PORT) : 7475;
|
|
30
30
|
export const NOTIFY_DOOR_PATH = "/mcp";
|
|
31
31
|
const RETRY_MS = 5_000;
|
|
@@ -23,7 +23,7 @@ const ATTEMPTS = 3;
|
|
|
23
23
|
// GATE: a request that has sent nothing for this long is abandoned as a network failure.
|
|
24
24
|
const IDLE_MS = 30_000;
|
|
25
25
|
const REDIRECTS = 5;
|
|
26
|
-
// GATE: a gateway-state beat older than this is presumed dead; it is vscode-extension/
|
|
26
|
+
// GATE: a gateway-state beat older than this is presumed dead; it is vscode-extension/bnDaemon.js's own STALE_MS.
|
|
27
27
|
const STALE_MS = 30_000;
|
|
28
28
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
29
29
|
const HOSTNAME = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
package/dist/notify.js
CHANGED
|
@@ -2508,15 +2508,22 @@ function startOwnedWork() {
|
|
|
2508
2508
|
AgentGateway.instance().boot();
|
|
2509
2509
|
log("·", "listener", `this process (pid ${process.pid}, build ${PACKAGE_VERSION}) owns the Telegram, Slack, Discord and Teams pollers, the ntfy and SMS pollers, the agent's email door, and the agent conversations`);
|
|
2510
2510
|
}
|
|
2511
|
-
// GATE: a daemon's beat older than this is presumed dead; it is vscode-extension/
|
|
2511
|
+
// GATE: a daemon's beat older than this is presumed dead; it is vscode-extension/bnDaemon.js's own STALE_MS.
|
|
2512
2512
|
const DAEMON_BEAT_STALE_MS = 30_000;
|
|
2513
|
-
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/
|
|
2514
|
-
export const
|
|
2513
|
+
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/bnDaemon.js. */
|
|
2514
|
+
export const DAEMON_BEAT_PATH = join(CONFIG_DIR, "daemon.json");
|
|
2515
|
+
/** the beat's name in the release before, read for one release so a daemon of that build is never read as gone. */
|
|
2516
|
+
const OLD_DAEMON_BEAT_PATH = join(CONFIG_DIR, "always-on.json");
|
|
2517
|
+
/** The later of the beat and the one under its old name, or undefined when neither was written. */
|
|
2518
|
+
function latestBeat() {
|
|
2519
|
+
const [beat, old] = [DAEMON_BEAT_PATH, OLD_DAEMON_BEAT_PATH].map((file) => (existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : undefined));
|
|
2520
|
+
return old !== undefined && (beat === undefined || old.at > beat.at) ? old : beat;
|
|
2521
|
+
}
|
|
2515
2522
|
/** An always-on process is alive and beating — of the given build, when one is named. */
|
|
2516
2523
|
function daemonBeats(version) {
|
|
2517
|
-
|
|
2524
|
+
const beat = latestBeat();
|
|
2525
|
+
if (beat === undefined)
|
|
2518
2526
|
return false;
|
|
2519
|
-
const beat = JSON.parse(readFileSync(ALWAYS_ON_PATH, "utf8"));
|
|
2520
2527
|
if (Date.now() - beat.at >= DAEMON_BEAT_STALE_MS || (version !== undefined && beat.version !== version))
|
|
2521
2528
|
return false;
|
|
2522
2529
|
try {
|
|
@@ -214,7 +214,7 @@ function webDocument(source, { page, roots, theme }) {
|
|
|
214
214
|
"font-src 'self' data:",
|
|
215
215
|
`script-src 'self'${nonces.length === 0 ? " 'unsafe-inline'" : ` ${[...new Set(nonces)].join(" ")}`}`,
|
|
216
216
|
"connect-src 'self' ws://127.0.0.1:* ws://localhost:*",
|
|
217
|
-
"frame-src 'self'",
|
|
217
|
+
"frame-src 'self' http://127.0.0.1:* http://localhost:*",
|
|
218
218
|
"media-src 'self'",
|
|
219
219
|
].join("; ");
|
|
220
220
|
// NULL-OK: field theme is OPTIONAL and therefore it is ok to check for NULL
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.326",
|
|
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",
|