omni-notify-mcp 1.3.334 → 1.3.335
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 +21 -28
- package/dist/notify.js +100 -22
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -18,44 +18,38 @@ 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");
|
|
23
21
|
function beat(pid = process.pid) {
|
|
24
22
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
writeFileSync(staged, text);
|
|
29
|
-
renameSync(staged, file);
|
|
30
|
-
}
|
|
23
|
+
const staged = `${DAEMON_BEAT_PATH}.${process.pid}.tmp`;
|
|
24
|
+
writeFileSync(staged, JSON.stringify({ pid, at: Date.now(), version: PACKAGE_VERSION }));
|
|
25
|
+
renameSync(staged, DAEMON_BEAT_PATH);
|
|
31
26
|
}
|
|
32
|
-
/** The boot supervisor's login entry: launchd's label and systemd's unit.
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
/** BN's lifecycle in the config dir,
|
|
36
|
-
const
|
|
37
|
-
/** The Stop the panel writes
|
|
38
|
-
const
|
|
27
|
+
/** The boot supervisor's login entry: launchd's label and systemd's unit. */
|
|
28
|
+
const ENTRY_LABEL = "com.bullseye.BullseyeMcpOrigins";
|
|
29
|
+
const ENTRY_UNIT = "bullseye-mcp-origins.service";
|
|
30
|
+
/** BN's lifecycle in the config dir, which the login entry and the boot task keep. */
|
|
31
|
+
const SUPERVISE_LOOP = join(CONFIG_DIR, "bnDaemon.js");
|
|
32
|
+
/** The Stop the panel writes. */
|
|
33
|
+
const STOP_FILE = join(CONFIG_DIR, "daemon-stop.json");
|
|
39
34
|
/** 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. */
|
|
40
35
|
function supervised() {
|
|
41
36
|
if (process.platform === "win32")
|
|
42
37
|
return process.connected === true;
|
|
43
38
|
if (process.platform === "darwin")
|
|
44
|
-
return
|
|
39
|
+
return process.env.XPC_SERVICE_NAME === ENTRY_LABEL;
|
|
45
40
|
if (process.platform !== "linux")
|
|
46
41
|
return false;
|
|
47
42
|
const cgroup = readFileSync("/proc/self/cgroup", "utf8");
|
|
48
|
-
return
|
|
43
|
+
return cgroup.includes(ENTRY_UNIT);
|
|
49
44
|
}
|
|
50
45
|
/** 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. */
|
|
51
46
|
function successor() {
|
|
52
47
|
const self = fileURLToPath(import.meta.url);
|
|
53
48
|
if (process.platform !== "win32")
|
|
54
49
|
return spawn(process.execPath, [...process.execArgv, self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return spawn(process.execPath, [loop, "supervise", self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
50
|
+
if (!existsSync(SUPERVISE_LOOP))
|
|
51
|
+
throw new Error(`the supervise loop is not in the config dir at ${SUPERVISE_LOOP} — the login entry and the boot task copy it there, so nothing can own the next run`);
|
|
52
|
+
return spawn(process.execPath, [SUPERVISE_LOOP, "supervise", self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
59
53
|
}
|
|
60
54
|
/** 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. */
|
|
61
55
|
function replaceWithInstalledBuild() {
|
|
@@ -72,7 +66,7 @@ function pressedIn(file) {
|
|
|
72
66
|
if (!existsSync(file))
|
|
73
67
|
return undefined;
|
|
74
68
|
try {
|
|
75
|
-
return
|
|
69
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
76
70
|
}
|
|
77
71
|
catch (err) {
|
|
78
72
|
throw new Error(`${file} is not readable JSON, so whether a Stop was pressed on this machine cannot be known — ${err.message}`);
|
|
@@ -80,14 +74,13 @@ function pressedIn(file) {
|
|
|
80
74
|
}
|
|
81
75
|
/** 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
76
|
function stoppedByHand() {
|
|
83
|
-
const
|
|
84
|
-
const pressed = old !== undefined && (now === undefined || (old.at ?? -Infinity) > (now.at ?? -Infinity)) ? old : now;
|
|
77
|
+
const pressed = pressedIn(STOP_FILE);
|
|
85
78
|
if (pressed === undefined)
|
|
86
79
|
return false;
|
|
87
80
|
if (pressed.desired !== "stopped")
|
|
88
81
|
return false;
|
|
89
82
|
if (typeof pressed.at !== "number")
|
|
90
|
-
throw new Error(`${
|
|
83
|
+
throw new Error(`${STOP_FILE} names a Stop with no time it was pressed, so whether it was pressed in this boot cannot be known`);
|
|
91
84
|
return inThisBoot(pressed.at);
|
|
92
85
|
}
|
|
93
86
|
if (stoppedByHand()) {
|
|
@@ -112,7 +105,7 @@ const beatTimer = setInterval(() => {
|
|
|
112
105
|
let handedOver;
|
|
113
106
|
// Only the daemon that owns the gateway port runs the connector and publishes its state: a dormant one has nothing for it to reach.
|
|
114
107
|
const tunnel = new TunnelRunner();
|
|
115
|
-
const
|
|
108
|
+
const daemonHost = {
|
|
116
109
|
clientId: DAEMON_TAG, tag: DAEMON_TAG, queueOnly: true, emit: async () => { },
|
|
117
110
|
onDoorOwned: (port) => {
|
|
118
111
|
tunnel.beat(port);
|
|
@@ -120,9 +113,9 @@ const alwaysOn = {
|
|
|
120
113
|
},
|
|
121
114
|
onSuperseded: () => (handedOver === undefined ? replaceWithInstalledBuild() : void handedOver.then(() => process.exit(0))),
|
|
122
115
|
};
|
|
123
|
-
startNotifyServer(
|
|
116
|
+
startNotifyServer(daemonHost);
|
|
124
117
|
// No MCP client connects here, so nothing can be pushed: the boot take only hands entries to the queue.
|
|
125
|
-
takePendingInbox(
|
|
118
|
+
takePendingInbox(daemonHost);
|
|
126
119
|
startNotifyDoor(() => { beating = true; beat(); }, undefined, {
|
|
127
120
|
version: PACKAGE_VERSION,
|
|
128
121
|
takeover,
|
package/dist/notify.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { randomUUID, createHash } from "crypto";
|
|
14
14
|
import { createServer as createNetServer } from "net";
|
|
15
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, renameSync, rmSync, watch } from "fs";
|
|
15
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync, linkSync, renameSync, rmSync, watch } from "fs";
|
|
16
16
|
import { homedir, networkInterfaces, hostname, tmpdir } from "os";
|
|
17
17
|
import { join, basename, dirname } from "path";
|
|
18
18
|
import { fileURLToPath } from "url";
|
|
@@ -919,32 +919,113 @@ function reapInboxDrops() {
|
|
|
919
919
|
}
|
|
920
920
|
// The drop folder is how a process that is not this one (the trading app's alerts) hands the notify app a
|
|
921
921
|
// message, because only the notify app writes its queue. One .json file per message, staged as .tmp and
|
|
922
|
-
// renamed by the writer; each is claimed
|
|
923
|
-
// so every window sees it, and deleted. An unreadable file is kept as .rejected, never silently dropped.
|
|
922
|
+
// renamed by the writer; each is claimed through an exclusive hard link in the claims folder, so exactly one host process takes it,
|
|
923
|
+
// queued UNTAGGED so every window sees it, and deleted. An unreadable file is kept as .rejected, never silently dropped.
|
|
924
924
|
const INBOX_DROP_IN_DIR = join(CONFIG_DIR, "inbox-drop");
|
|
925
|
+
const INBOX_DROP_CLAIM_DIR = join(CONFIG_DIR, "inbox-drop-claims");
|
|
926
|
+
function processIsAlive(pid) {
|
|
927
|
+
try {
|
|
928
|
+
process.kill(pid, 0);
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
catch (err) {
|
|
932
|
+
const code = err.code;
|
|
933
|
+
if (code === "ESRCH")
|
|
934
|
+
return false;
|
|
935
|
+
if (code === "EPERM")
|
|
936
|
+
return true;
|
|
937
|
+
throw err;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
function lockedByAnother(code) {
|
|
941
|
+
return code === "EEXIST" || (process.platform === "win32" && (code === "EPERM" || code === "EACCES" || code === "EBUSY"));
|
|
942
|
+
}
|
|
943
|
+
function createExclusive(target) {
|
|
944
|
+
const staging = `${target}.${process.pid}.tmp`;
|
|
945
|
+
writeFileSync(staging, String(process.pid));
|
|
946
|
+
try {
|
|
947
|
+
linkSync(staging, target);
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
catch (err) {
|
|
951
|
+
if (lockedByAnother(err.code))
|
|
952
|
+
return false;
|
|
953
|
+
throw err;
|
|
954
|
+
}
|
|
955
|
+
finally {
|
|
956
|
+
rmSync(staging, { force: true });
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
function ownerOf(marker) {
|
|
960
|
+
try {
|
|
961
|
+
return Number.parseInt(readFileSync(marker, "utf8"), 10);
|
|
962
|
+
}
|
|
963
|
+
catch (err) {
|
|
964
|
+
const code = err.code;
|
|
965
|
+
if (code === "ENOENT")
|
|
966
|
+
return undefined;
|
|
967
|
+
if (lockedByAnother(code))
|
|
968
|
+
return Number.POSITIVE_INFINITY;
|
|
969
|
+
throw err;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
function claimDrop(marker) {
|
|
973
|
+
if (createExclusive(marker))
|
|
974
|
+
return true;
|
|
975
|
+
const owner = ownerOf(marker);
|
|
976
|
+
if (owner === undefined)
|
|
977
|
+
return createExclusive(marker);
|
|
978
|
+
if (owner === Number.POSITIVE_INFINITY || (owner !== process.pid && processIsAlive(owner)))
|
|
979
|
+
return false;
|
|
980
|
+
const takeover = `${marker}.takeover.${owner}`;
|
|
981
|
+
if (!claimDrop(takeover))
|
|
982
|
+
return false;
|
|
983
|
+
try {
|
|
984
|
+
if (ownerOf(marker) !== owner)
|
|
985
|
+
return false;
|
|
986
|
+
rmSync(marker, { force: true });
|
|
987
|
+
return createExclusive(marker);
|
|
988
|
+
}
|
|
989
|
+
finally {
|
|
990
|
+
rmSync(takeover, { force: true });
|
|
991
|
+
}
|
|
992
|
+
}
|
|
925
993
|
function ingestDropFolder(host) {
|
|
926
994
|
if (!existsSync(INBOX_DROP_IN_DIR))
|
|
927
995
|
return;
|
|
996
|
+
mkdirSync(INBOX_DROP_CLAIM_DIR, { recursive: true });
|
|
928
997
|
const arrivals = [];
|
|
929
998
|
for (const name of readdirSync(INBOX_DROP_IN_DIR).filter((f) => f.endsWith(".json"))) {
|
|
930
999
|
const path = join(INBOX_DROP_IN_DIR, name);
|
|
931
|
-
const
|
|
932
|
-
try {
|
|
933
|
-
renameSync(path, claimed);
|
|
934
|
-
}
|
|
935
|
-
catch {
|
|
936
|
-
continue; // another host process claimed it first
|
|
937
|
-
}
|
|
1000
|
+
const marker = join(INBOX_DROP_CLAIM_DIR, `${name}.claim`);
|
|
938
1001
|
try {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1002
|
+
if (!claimDrop(marker))
|
|
1003
|
+
continue;
|
|
1004
|
+
try {
|
|
1005
|
+
if (!existsSync(path))
|
|
1006
|
+
continue;
|
|
1007
|
+
let entry;
|
|
1008
|
+
try {
|
|
1009
|
+
const { text, ts } = JSON.parse(readFileSync(path, "utf8"));
|
|
1010
|
+
if (typeof text !== "string" || text === "")
|
|
1011
|
+
throw new Error("no text");
|
|
1012
|
+
entry = { text, ts: typeof ts === "string" ? ts : new Date().toISOString(), origin: "drop" };
|
|
1013
|
+
}
|
|
1014
|
+
catch (err) {
|
|
1015
|
+
renameSync(path, `${path}.rejected`);
|
|
1016
|
+
log("·", "inbox-drop", `${name} is not a well-formed drop and was kept as .rejected: ${err instanceof Error ? err.message : String(err)}`);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
unlinkSync(path);
|
|
1020
|
+
arrivals.push(entry);
|
|
1021
|
+
}
|
|
1022
|
+
finally {
|
|
1023
|
+
rmSync(marker, { force: true });
|
|
1024
|
+
}
|
|
944
1025
|
}
|
|
945
1026
|
catch (err) {
|
|
946
|
-
|
|
947
|
-
log("·", "inbox-drop", `${name}
|
|
1027
|
+
// OWNER: ITER/LOOP — one drop's failed claim or settle must not lose the arrivals already collected — it is logged and the drop stays in the folder for the next pass
|
|
1028
|
+
log("·", "inbox-drop", `${name} could not be claimed or settled and stays in the folder: ${err instanceof Error ? err.message : String(err)}`);
|
|
948
1029
|
}
|
|
949
1030
|
}
|
|
950
1031
|
if (arrivals.length === 0)
|
|
@@ -2537,12 +2618,9 @@ function startOwnedWork() {
|
|
|
2537
2618
|
const DAEMON_BEAT_STALE_MS = 30_000;
|
|
2538
2619
|
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/bnDaemon.js. */
|
|
2539
2620
|
export const DAEMON_BEAT_PATH = join(CONFIG_DIR, "daemon.json");
|
|
2540
|
-
/**
|
|
2541
|
-
const OLD_DAEMON_BEAT_PATH = join(CONFIG_DIR, "always-on.json");
|
|
2542
|
-
/** The later of the beat and the one under its old name, or undefined when neither was written. */
|
|
2621
|
+
/** The daemon's last beat, or undefined when it never wrote one. */
|
|
2543
2622
|
function latestBeat() {
|
|
2544
|
-
|
|
2545
|
-
return old !== undefined && (beat === undefined || old.at > beat.at) ? old : beat;
|
|
2623
|
+
return existsSync(DAEMON_BEAT_PATH) ? JSON.parse(readFileSync(DAEMON_BEAT_PATH, "utf8")) : undefined;
|
|
2546
2624
|
}
|
|
2547
2625
|
/** A daemon is alive and beating — of the given build, when one is named. */
|
|
2548
2626
|
function daemonBeats(version) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.335",
|
|
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",
|