omni-notify-mcp 1.3.341 → 1.3.343
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
|
@@ -104,7 +104,7 @@ let handedOver;
|
|
|
104
104
|
// Only the daemon that owns the gateway port runs the connector and publishes its state: a dormant one has nothing for it to reach.
|
|
105
105
|
const tunnel = new TunnelRunner();
|
|
106
106
|
const daemonHost = {
|
|
107
|
-
clientId: DAEMON_TAG, tag: DAEMON_TAG,
|
|
107
|
+
clientId: DAEMON_TAG, tag: DAEMON_TAG,
|
|
108
108
|
onDoorOwned: (port) => {
|
|
109
109
|
tunnel.beat(port);
|
|
110
110
|
setInterval(() => tunnel.beat(port), HEARTBEAT_MS);
|
|
@@ -112,8 +112,7 @@ const daemonHost = {
|
|
|
112
112
|
onSuperseded: () => (handedOver === undefined ? replaceWithInstalledBuild() : void handedOver.then(() => process.exit(0))),
|
|
113
113
|
};
|
|
114
114
|
startNotifyServer(daemonHost);
|
|
115
|
-
|
|
116
|
-
takePendingInbox(daemonHost);
|
|
115
|
+
takePendingInbox();
|
|
117
116
|
startNotifyDoor(() => { beating = true; beat(); }, undefined, {
|
|
118
117
|
version: PACKAGE_VERSION,
|
|
119
118
|
takeover,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
|
-
import autoSwitch from "../shared/autoSwitch.cjs";
|
|
2
|
+
import autoSwitch from "../shared/webhost/autoSwitch.cjs";
|
|
3
3
|
import { OpenCodeTurn } from "../shared/agentSession.js";
|
|
4
4
|
import { agentEnv } from "./provider.js";
|
|
5
5
|
const ROUTE_REFUSALS = new Set(["OPENCODE_NO_KEY", "KEYPLAN_UNREADABLE", "REFUSAL_UNREADABLE"]);
|
package/dist/notify.js
CHANGED
|
@@ -37,9 +37,8 @@ function installedVersion() {
|
|
|
37
37
|
export const PACKAGE_VERSION = installedVersion();
|
|
38
38
|
/**
|
|
39
39
|
* The identity one chat reports and the tag its messages are routed by: `<machine>-<workspace>[-<session>]`.
|
|
40
|
-
* The HTTP door derives it from the headers its client sends
|
|
41
|
-
*
|
|
42
|
-
* system directory names, and a session id (when the host has one) tells two windows on one workspace apart.
|
|
40
|
+
* The HTTP door derives it from the headers its client sends: the workspace is walked up from the project folder,
|
|
41
|
+
* skipping launcher and system directory names, and a session id (when the host has one) tells two windows on one workspace apart.
|
|
43
42
|
* The session part is only ever what a host ACTUALLY sends: a Claude Code MCP header does not expand
|
|
44
43
|
* `${CLAUDE_CODE_SESSION_ID}` — measured, the literal string arrives — so an HTTP chat there is named by its
|
|
45
44
|
* workspace alone and two windows on one workspace share that name.
|
|
@@ -51,9 +50,6 @@ const GENERIC_DIRS = new Set([
|
|
|
51
50
|
]);
|
|
52
51
|
export function sessionIdentity(from) {
|
|
53
52
|
const cleanId = (s) => s.toLowerCase().replace(/[^a-z0-9_-]/g, "");
|
|
54
|
-
const explicit = cleanId(from.explicitTag ?? "");
|
|
55
|
-
if (explicit !== "")
|
|
56
|
-
return explicit;
|
|
57
53
|
// A request that names no workspace never inherits the serving process's own folder: the name it falls back to
|
|
58
54
|
// is the caller's, so a chat is never told it is some other workspace's session.
|
|
59
55
|
const root = from.projectDir ?? "";
|
|
@@ -742,11 +738,17 @@ function persistInboxQueue(arrivals = []) {
|
|
|
742
738
|
absorbQueued(merged, entry, [...(inboxDeliveredTo.get(entryKey(entry)) ?? [])]);
|
|
743
739
|
for (const entry of arrivals)
|
|
744
740
|
absorbQueued(merged, entry, []);
|
|
741
|
+
for (const [key, entry] of merged)
|
|
742
|
+
absorbQueued(merged, entry, [...(inboxDeliveredTo.get(key) ?? [])]);
|
|
745
743
|
const name = `${OWN_QUEUE_PREFIX}${Date.now()}${String(queueWrites++).padStart(4, "0")}.json`;
|
|
746
744
|
writeFileSync(join(CONFIG_DIR, `${name}.tmp`), JSON.stringify([...merged.values()]));
|
|
747
745
|
renameSync(join(CONFIG_DIR, `${name}.tmp`), join(CONFIG_DIR, name));
|
|
748
746
|
for (const old of earlier)
|
|
749
747
|
rmSync(join(CONFIG_DIR, old), { force: true });
|
|
748
|
+
const queued = new Set(inboxQueue.map(entryKey));
|
|
749
|
+
for (const key of [...inboxDeliveredTo.keys()])
|
|
750
|
+
if (!queued.has(key))
|
|
751
|
+
inboxDeliveredTo.delete(key);
|
|
750
752
|
// a file nobody wrote for the entry lifetime holds only entries already past it (an entry is never newer than its file's last write); a staging file a dead process left is the same
|
|
751
753
|
const staged = existsSync(CONFIG_DIR) ? readdirSync(CONFIG_DIR).filter((f) => STAGED_QUEUE_FILE.test(f)) : [];
|
|
752
754
|
for (const other of [...queueFileNames().filter((f) => !f.startsWith(OWN_QUEUE_PREFIX)), ...staged]) {
|
|
@@ -755,34 +757,37 @@ function persistInboxQueue(arrivals = []) {
|
|
|
755
757
|
rmSync(join(CONFIG_DIR, other), { force: true });
|
|
756
758
|
}
|
|
757
759
|
}
|
|
758
|
-
// Entries in the shared queue
|
|
759
|
-
|
|
760
|
-
function takeSharedEntriesForSelf(saved) {
|
|
760
|
+
// Entries in the shared queue this process does not hold yet, restored with the marks the file carries.
|
|
761
|
+
function takeSharedEntries(saved) {
|
|
761
762
|
const mine = [];
|
|
762
763
|
for (const { deliveredTo, ...entry } of saved) {
|
|
763
|
-
|
|
764
|
+
const key = entryKey(entry);
|
|
765
|
+
if (inboxQueue.some((queued) => entryKey(queued) === key))
|
|
764
766
|
continue;
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
mine.push(entry);
|
|
767
|
+
if (entry.tag && (deliveredTo.includes(deliveredKey(entry.tag)) || alreadyDelivered(entry, entry.tag)))
|
|
768
|
+
continue;
|
|
769
|
+
for (const mark of deliveredTo)
|
|
770
|
+
markDelivered(entry, mark === "*" ? undefined : mark);
|
|
771
|
+
mine.push(entry);
|
|
771
772
|
}
|
|
772
773
|
if (mine.length === 0)
|
|
773
|
-
return
|
|
774
|
+
return;
|
|
774
775
|
for (const entry of mine) {
|
|
775
776
|
// Only the entry addressed to this host is recorded as taken by it; a tagged entry another chat owns stays
|
|
776
777
|
// unmarked here and is marked when that chat drains it.
|
|
778
|
+
const takenBefore = alreadyDelivered(entry, SELF_TAG);
|
|
777
779
|
if (matchesSession(entry, SELF_TAG))
|
|
778
780
|
markDelivered(entry, SELF_TAG);
|
|
781
|
+
if (takenBefore) {
|
|
782
|
+
inboxQueue.push(entry);
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
779
785
|
if (entry.origin === "telegram")
|
|
780
786
|
noteTelegramInbound(entry.messageId, entry.chatId, Date.parse(entry.ts));
|
|
781
787
|
handOver(entry);
|
|
782
788
|
log("·", "inbox", "taken from the shared queue", entry.tag ?? SELF_TAG);
|
|
783
789
|
}
|
|
784
790
|
persistInboxQueue();
|
|
785
|
-
return mine;
|
|
786
791
|
}
|
|
787
792
|
// A message this process took meets its live consumers here: the open question a reply on an
|
|
788
793
|
// answering channel answers, else every parked wait_for_inbox, else the queue the session's next tool result drains.
|
|
@@ -800,7 +805,8 @@ function handOver(entry) {
|
|
|
800
805
|
markDelivered(entry, w.tag);
|
|
801
806
|
w.resolve([entry]);
|
|
802
807
|
}
|
|
803
|
-
|
|
808
|
+
// an untagged entry is every chat's: the ones parked took it, the ones not parked drain it from the queue
|
|
809
|
+
if (waiters.length === 0 || !entry.tag)
|
|
804
810
|
inboxQueue.push(entry);
|
|
805
811
|
}
|
|
806
812
|
// The open question a reply answers: one asked by the session the reply is tagged for, or any
|
|
@@ -849,15 +855,10 @@ function matchesSession(entry, sessionTag) {
|
|
|
849
855
|
return true; // untagged → everyone
|
|
850
856
|
return entry.tag === sessionTag; // tagged → only matching session
|
|
851
857
|
}
|
|
852
|
-
// Set once by startNotifyServer() from the
|
|
853
|
-
//
|
|
854
|
-
// host: there is no other session in here to route to.
|
|
858
|
+
// Set once by startNotifyServer() from the tag its host gave it: the daemon's own tag, the one the shared queue keeps its
|
|
859
|
+
// own reads under.
|
|
855
860
|
let SELF_TAG;
|
|
856
|
-
|
|
857
|
-
function matchesSelfTag(tag) {
|
|
858
|
-
return tag === undefined || tag === SELF_TAG;
|
|
859
|
-
}
|
|
860
|
-
// ── /btw file-drop bridge ─────────────────────────────────────────────────────
|
|
861
|
+
// ── /btw file-drop ─────────────────────────────────────────────────────
|
|
861
862
|
// Claude Code has no API for injecting a prompt into a running session while a
|
|
862
863
|
// tool call is executing (anthropics/claude-code#27441, still open). The only
|
|
863
864
|
// in-band channel is the `FileChanged` hook: when a watched file changes on
|
|
@@ -869,7 +870,7 @@ function matchesSelfTag(tag) {
|
|
|
869
870
|
// closest thing to a "/btw" we can get until the client exposes a real inject
|
|
870
871
|
// endpoint.
|
|
871
872
|
// Test mode drops to an isolated dir so a smoke run never pollutes the live
|
|
872
|
-
// inbox the hook
|
|
873
|
+
// inbox the hook reads (sim/live separation).
|
|
873
874
|
const INBOX_DROP_DIR = join(CONFIG_DIR, process.env.NOTIFY_MCP_TEST_ENDPOINTS === "1" ? "inbox-test" : "inbox");
|
|
874
875
|
const INBOX_DROP_TTL_MS = 24 * 60 * 60 * 1000; // 24h — hook should have consumed within seconds
|
|
875
876
|
function writeInboxDrop(entry) {
|
|
@@ -930,7 +931,7 @@ function rejectDrop(path, name, reason) {
|
|
|
930
931
|
renameSync(path, `${path}.rejected`);
|
|
931
932
|
log("·", "inbox-drop", `${name} is not a well-formed drop and was kept as .rejected: ${reason}`);
|
|
932
933
|
}
|
|
933
|
-
function retryUnreadDrops(unread
|
|
934
|
+
function retryUnreadDrops(unread) {
|
|
934
935
|
if (unread.length === 0) {
|
|
935
936
|
dropFailedPasses = 0;
|
|
936
937
|
return;
|
|
@@ -949,7 +950,7 @@ function retryUnreadDrops(unread, host) {
|
|
|
949
950
|
log("·", "inbox-drop", `could not read ${which}; they stay in inbox-drop, read again in ${waitMs} ms (retry ${dropFailedPasses} of ${DROP_READ_RETRIES})`);
|
|
950
951
|
setTimeout(() => {
|
|
951
952
|
dropRetryPending = false;
|
|
952
|
-
ingestDropFolder(
|
|
953
|
+
ingestDropFolder();
|
|
953
954
|
}, waitMs).unref();
|
|
954
955
|
}
|
|
955
956
|
function processIsAlive(pid) {
|
|
@@ -1019,7 +1020,7 @@ function claimDrop(marker) {
|
|
|
1019
1020
|
rmSync(takeover, { force: true });
|
|
1020
1021
|
}
|
|
1021
1022
|
}
|
|
1022
|
-
function ingestDropFolder(
|
|
1023
|
+
function ingestDropFolder() {
|
|
1023
1024
|
if (!existsSync(INBOX_DROP_IN_DIR))
|
|
1024
1025
|
return;
|
|
1025
1026
|
mkdirSync(INBOX_DROP_CLAIM_DIR, { recursive: true });
|
|
@@ -1072,12 +1073,12 @@ function ingestDropFolder(host) {
|
|
|
1072
1073
|
log("·", "inbox-drop", `${name} could not be claimed or settled and stays in the folder: ${err instanceof Error ? err.message : String(err)}`);
|
|
1073
1074
|
}
|
|
1074
1075
|
}
|
|
1075
|
-
retryUnreadDrops(unread
|
|
1076
|
+
retryUnreadDrops(unread);
|
|
1076
1077
|
if (arrivals.length === 0)
|
|
1077
1078
|
return;
|
|
1078
1079
|
persistInboxQueue(arrivals);
|
|
1079
1080
|
log("·", "inbox-drop", `queued ${arrivals.length} message${arrivals.length === 1 ? "" : "s"} from ${INBOX_DROP_IN_DIR}`);
|
|
1080
|
-
syncInboxFromDisk(
|
|
1081
|
+
syncInboxFromDisk();
|
|
1081
1082
|
}
|
|
1082
1083
|
function ingestInboxEntry(entry, source) {
|
|
1083
1084
|
const waiters = takeWaitersFor(entry.tag);
|
|
@@ -1088,7 +1089,8 @@ function ingestInboxEntry(entry, source) {
|
|
|
1088
1089
|
w.resolve([entry]);
|
|
1089
1090
|
}
|
|
1090
1091
|
}
|
|
1091
|
-
|
|
1092
|
+
// an untagged entry is every chat's: the ones parked took it, the ones not parked drain it from the queue
|
|
1093
|
+
if (waiters.length === 0 || !entry.tag) {
|
|
1092
1094
|
inboxQueue.push(entry);
|
|
1093
1095
|
writeInboxDrop(entry);
|
|
1094
1096
|
}
|
|
@@ -1096,7 +1098,6 @@ function ingestInboxEntry(entry, source) {
|
|
|
1096
1098
|
markDelivered(entry, SELF_TAG);
|
|
1097
1099
|
persistInboxQueue();
|
|
1098
1100
|
log("·", "inbox", `${source}: ${entry.text} (waiters=${waiters.length})`, entry.tag);
|
|
1099
|
-
return { waiters: waiters.length };
|
|
1100
1101
|
}
|
|
1101
1102
|
// #770's late answer: the reply to a question the caller ASKED, so it is queued
|
|
1102
1103
|
// for that caller's own inbox rather than pushed at every subscriber — the
|
|
@@ -1109,22 +1110,11 @@ function queueInboxEntry(entry) {
|
|
|
1109
1110
|
persistInboxQueue();
|
|
1110
1111
|
}
|
|
1111
1112
|
function ingestChatEntry(entry) {
|
|
1112
|
-
|
|
1113
|
+
ingestInboxEntry(entry, entry.origin ?? "telegram");
|
|
1113
1114
|
// The daemon serves no session of its own, so it cannot say who is connected — only that the shared inbox holds the message.
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
: "📬 Queued. Delivered to every agent session that connects.";
|
|
1118
|
-
const listening = waiters > 0 || matchesSelfTag(entry.tag);
|
|
1119
|
-
// NULL-OK: field tag is OPTIONAL and therefore it is ok to check for NULL
|
|
1120
|
-
if (entry.tag) {
|
|
1121
|
-
return listening
|
|
1122
|
-
? `📬 Routed to @${entry.tag}. Waiting for reply.`
|
|
1123
|
-
: `📭 No session @${entry.tag} connected. Message queued — next @${entry.tag} to connect will pick it up.`;
|
|
1124
|
-
}
|
|
1125
|
-
return listening
|
|
1126
|
-
? "📬 Queued for every connected agent. Waiting for reply."
|
|
1127
|
-
: "📭 No agents connected. Message queued — next agent to connect will pick it up.";
|
|
1115
|
+
return entry.tag
|
|
1116
|
+
? `📬 Queued for @${entry.tag}. Delivered when that session is connected.`
|
|
1117
|
+
: "📬 Queued. Delivered to every agent session that connects.";
|
|
1128
1118
|
}
|
|
1129
1119
|
async function initTgOffset(token) {
|
|
1130
1120
|
const r = await fetch(tgApi(token, "getUpdates?offset=-1&timeout=0"));
|
|
@@ -1680,20 +1670,25 @@ async function slackSend(text) {
|
|
|
1680
1670
|
if (!json.ok)
|
|
1681
1671
|
throw new Error(`chat.postMessage: ${json.error ?? "unknown"}`);
|
|
1682
1672
|
}
|
|
1683
|
-
// The tags a user can @-address from Slack
|
|
1684
|
-
//
|
|
1673
|
+
// The tags a user can @-address from Slack: the tags of the chats connected
|
|
1674
|
+
// right now, i.e. the ones holding a live inbox waiter.
|
|
1685
1675
|
function slackClientTags() {
|
|
1686
|
-
|
|
1676
|
+
const tags = new Set();
|
|
1677
|
+
for (const [, w] of inboxWaiters)
|
|
1678
|
+
if (w.tag !== undefined)
|
|
1679
|
+
tags.add(w.tag);
|
|
1680
|
+
return [...tags];
|
|
1687
1681
|
}
|
|
1688
1682
|
// How many live agents would actually receive a message with this tag (undefined
|
|
1689
1683
|
// = broadcast). Used to gate the Slack ack: an "ack" posted when nobody is
|
|
1690
1684
|
// connected is a lie — the message only sits queued for the next connector.
|
|
1685
|
+
// The daemon serves no session of its own, so it is never counted.
|
|
1691
1686
|
function liveListenerCount(tag) {
|
|
1692
1687
|
let waiters = 0;
|
|
1693
1688
|
for (const [, w] of inboxWaiters)
|
|
1694
1689
|
if (!tag || w.tag === tag)
|
|
1695
1690
|
waiters++;
|
|
1696
|
-
return waiters
|
|
1691
|
+
return waiters;
|
|
1697
1692
|
}
|
|
1698
1693
|
function slackClientsNumbered() {
|
|
1699
1694
|
const tags = slackClientTags();
|
|
@@ -1890,14 +1885,14 @@ async function routeSlackInbox(m) {
|
|
|
1890
1885
|
log("←", "slack", `unknown client: ${handle}`);
|
|
1891
1886
|
return;
|
|
1892
1887
|
}
|
|
1888
|
+
const listening = liveListenerCount(tag) > 0; // counted BEFORE ingest, which hands the message to and removes its waiters
|
|
1893
1889
|
ingestInboxEntry({ text: msg, ts: new Date().toISOString(), tag, origin: "slack" }, "slack");
|
|
1894
|
-
|
|
1895
|
-
await slackPost("ack");
|
|
1890
|
+
await slackPost(listening ? "ack" : `📭 No session @${displayTag(tag)} connected. Message queued — next @${displayTag(tag)} to connect will pick it up.`);
|
|
1896
1891
|
}
|
|
1897
1892
|
else {
|
|
1893
|
+
const listening = liveListenerCount(undefined) > 0; // counted BEFORE ingest, which hands the message to and removes its waiters
|
|
1898
1894
|
ingestInboxEntry({ text, ts: new Date().toISOString(), origin: "slack" }, "slack");
|
|
1899
|
-
|
|
1900
|
-
await slackPost("ack");
|
|
1895
|
+
await slackPost(listening ? "ack" : "📭 No agents connected. Message queued — next agent to connect will pick it up.");
|
|
1901
1896
|
}
|
|
1902
1897
|
}
|
|
1903
1898
|
async function pollSlackOnce(token, channel) {
|
|
@@ -2023,13 +2018,20 @@ function drainInboxFor(tag) {
|
|
|
2023
2018
|
const taken = [];
|
|
2024
2019
|
const queuedBefore = inboxQueue.length;
|
|
2025
2020
|
for (let i = inboxQueue.length - 1; i >= 0; i--) {
|
|
2026
|
-
|
|
2021
|
+
const entry = inboxQueue[i];
|
|
2022
|
+
if (!entry.tag && Date.now() - Date.parse(entry.ts) >= INBOX_ENTRY_TTL_MS) {
|
|
2023
|
+
inboxQueue.splice(i, 1);
|
|
2027
2024
|
continue;
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2025
|
+
}
|
|
2026
|
+
if (!matchesSession(entry, tag) || alreadyDelivered(entry, tag))
|
|
2027
|
+
continue;
|
|
2028
|
+
markDelivered(entry, tag);
|
|
2029
|
+
taken.unshift(entry);
|
|
2030
|
+
// a tagged entry has one reader, so it leaves the queue with it; an untagged one stays for every other chat until its lifetime ends
|
|
2031
|
+
if (entry.tag)
|
|
2032
|
+
inboxQueue.splice(i, 1);
|
|
2031
2033
|
}
|
|
2032
|
-
if (inboxQueue.length !== queuedBefore)
|
|
2034
|
+
if (taken.length > 0 || inboxQueue.length !== queuedBefore)
|
|
2033
2035
|
persistInboxQueue();
|
|
2034
2036
|
return taken;
|
|
2035
2037
|
}
|
|
@@ -2380,8 +2382,7 @@ export function createMcpServer(clientId, sessionTag) {
|
|
|
2380
2382
|
? "WAS delivered over telegram"
|
|
2381
2383
|
: "was NOT delivered over anything";
|
|
2382
2384
|
// A blocking MCP tool call does not survive longer than the caller's own
|
|
2383
|
-
// request timeout — MEASURED 2026-09-20 against a real MCP client
|
|
2384
|
-
// stdio bridge: `ask` with timeout_seconds=300 threw `MCP error -32001:
|
|
2385
|
+
// request timeout — MEASURED 2026-09-20 against a real MCP client: `ask` with timeout_seconds=300 threw `MCP error -32001:
|
|
2385
2386
|
// Request timed out` at exactly 60.0s, while the server kept the question
|
|
2386
2387
|
// parked and any answer went into a promise whose caller was gone. So the
|
|
2387
2388
|
// WAIT is clamped and the caller is TOLD; the question itself stays open
|
|
@@ -2509,9 +2510,6 @@ export function createMcpServer(clientId, sessionTag) {
|
|
|
2509
2510
|
"carry, and a channel nothing has measured, each hold it false and are named in " +
|
|
2510
2511
|
"`reason`. Read `channels` for the ones that can carry and `carriage` for the " +
|
|
2511
2512
|
"per-channel state. Do NOT report the user as reachable off `process`.", {}, async () => {
|
|
2512
|
-
// Deliberately NOT logged: this server's `log()` writes to stdout, which on
|
|
2513
|
-
// a stdio server is the JSON-RPC channel, so a line here would interleave
|
|
2514
|
-
// with the tool result. See the finding filed against the stdout trail.
|
|
2515
2513
|
const verdict = deliveryReport();
|
|
2516
2514
|
return { content: [{ type: "text", text: appendInbox(JSON.stringify(verdict), sessionTag, clientId) }] };
|
|
2517
2515
|
});
|
|
@@ -2671,33 +2669,8 @@ function startOwnedWork() {
|
|
|
2671
2669
|
AgentGateway.instance().boot();
|
|
2672
2670
|
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`);
|
|
2673
2671
|
}
|
|
2674
|
-
// GATE: a daemon's beat older than this is presumed dead; it is vscode-extension/bnDaemon.js's own STALE_MS.
|
|
2675
|
-
const DAEMON_BEAT_STALE_MS = 30_000;
|
|
2676
2672
|
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/bnDaemon.js. */
|
|
2677
2673
|
export const DAEMON_BEAT_PATH = join(CONFIG_DIR, "daemon.json");
|
|
2678
|
-
/** The daemon's last beat, or undefined when it never wrote one. */
|
|
2679
|
-
function latestBeat() {
|
|
2680
|
-
return existsSync(DAEMON_BEAT_PATH) ? JSON.parse(readFileSync(DAEMON_BEAT_PATH, "utf8")) : undefined;
|
|
2681
|
-
}
|
|
2682
|
-
/** A daemon is alive and beating — of the given build, when one is named. */
|
|
2683
|
-
function daemonBeats(version) {
|
|
2684
|
-
const beat = latestBeat();
|
|
2685
|
-
if (beat === undefined)
|
|
2686
|
-
return false;
|
|
2687
|
-
if (Date.now() - beat.at >= DAEMON_BEAT_STALE_MS || (version !== undefined && beat.version !== version))
|
|
2688
|
-
return false;
|
|
2689
|
-
try {
|
|
2690
|
-
process.kill(beat.pid, 0);
|
|
2691
|
-
return true;
|
|
2692
|
-
}
|
|
2693
|
-
catch (err) {
|
|
2694
|
-
if (err.code === "ESRCH")
|
|
2695
|
-
return false;
|
|
2696
|
-
if (err.code === "EPERM")
|
|
2697
|
-
return true;
|
|
2698
|
-
throw err;
|
|
2699
|
-
}
|
|
2700
|
-
}
|
|
2701
2674
|
let lastBindRefusal = "";
|
|
2702
2675
|
let lastOtherBn = "";
|
|
2703
2676
|
let lastProbeFailure = "";
|
|
@@ -2715,9 +2688,7 @@ export function yieldGateway() {
|
|
|
2715
2688
|
}
|
|
2716
2689
|
/**
|
|
2717
2690
|
* Once the extension installs a newer build, this process is superseded and the gateway passes to the installed build:
|
|
2718
|
-
*
|
|
2719
|
-
* answer is in flight — the daemon at once, since it starts the installed build in its place, and a
|
|
2720
|
-
* bridge once the installed build's daemon beats to take it over.
|
|
2691
|
+
* one that holds it steps aside once no answer is in flight, and then starts the installed build in its place.
|
|
2721
2692
|
*/
|
|
2722
2693
|
function tryOwnGateway(polling, host) {
|
|
2723
2694
|
if (ownershipAttempting)
|
|
@@ -2728,16 +2699,11 @@ function tryOwnGateway(polling, host) {
|
|
|
2728
2699
|
log("·", "listener", `build ${PACKAGE_VERSION} is superseded by ${yielding ? "the release that asked for the chat door" : `the installed ${installed}`}; this process hands the gateway to it`);
|
|
2729
2700
|
supersededSaid = true;
|
|
2730
2701
|
if (door !== undefined) {
|
|
2731
|
-
|
|
2732
|
-
void stepAside(polling, host);
|
|
2733
|
-
return;
|
|
2734
|
-
}
|
|
2735
|
-
if (host.onSuperseded !== undefined) {
|
|
2736
|
-
host.onSuperseded();
|
|
2702
|
+
void stepAside(polling, host);
|
|
2737
2703
|
return;
|
|
2738
2704
|
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2705
|
+
host.onSuperseded();
|
|
2706
|
+
return;
|
|
2741
2707
|
}
|
|
2742
2708
|
if (door !== undefined)
|
|
2743
2709
|
return;
|
|
@@ -2809,21 +2775,15 @@ async function stepAside(polling, host) {
|
|
|
2809
2775
|
finally {
|
|
2810
2776
|
ownershipAttempting = false;
|
|
2811
2777
|
}
|
|
2812
|
-
host.onSuperseded
|
|
2778
|
+
host.onSuperseded();
|
|
2813
2779
|
}
|
|
2814
|
-
// Messages another
|
|
2815
|
-
//
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
for (const entry of takeSharedEntriesForSelf(readSharedQueue())) {
|
|
2819
|
-
host.emit(entry).catch((err) =>
|
|
2820
|
-
// OWNER: the message is already in this host's inbox and in the shared queue, so a refused push costs the push alone — it is reported once here and the caller's next poll or wait_for_inbox still hands the message over.
|
|
2821
|
-
log("·", "inbox", `channel push failed: ${err instanceof Error ? err.message : String(err)}`, host.clientId));
|
|
2822
|
-
}
|
|
2780
|
+
// Messages another process's poller recorded: hand them to the tool layer, and
|
|
2781
|
+
// record it in the shared file so no process delivers the same message twice.
|
|
2782
|
+
function syncInboxFromDisk() {
|
|
2783
|
+
takeSharedEntries(readSharedQueue());
|
|
2823
2784
|
}
|
|
2824
2785
|
export function startNotifyServer(host) {
|
|
2825
2786
|
SELF_TAG = host.tag;
|
|
2826
|
-
QUEUE_ONLY = host.queueOnly === true;
|
|
2827
2787
|
importCredsOnStart();
|
|
2828
2788
|
warnIfNoChannelConfigured(loadConfig());
|
|
2829
2789
|
refreshReach();
|
|
@@ -2854,7 +2814,7 @@ export function startNotifyServer(host) {
|
|
|
2854
2814
|
if (dropWatched || !existsSync(INBOX_DROP_IN_DIR))
|
|
2855
2815
|
return;
|
|
2856
2816
|
dropWatched = true;
|
|
2857
|
-
const drops = watch(INBOX_DROP_IN_DIR, { persistent: false }, () => ingestDropFolder(
|
|
2817
|
+
const drops = watch(INBOX_DROP_IN_DIR, { persistent: false }, () => ingestDropFolder());
|
|
2858
2818
|
// The drop folder was taken away: its watch is gone, and the folder's return is seen on the config folder's own watch.
|
|
2859
2819
|
drops.on("error", () => { dropWatched = false; });
|
|
2860
2820
|
};
|
|
@@ -2862,10 +2822,10 @@ export function startNotifyServer(host) {
|
|
|
2862
2822
|
watchNames(CONFIG_DIR, (name) => INBOX_QUEUE_FILE.test(name) || name === basename(INBOX_DROP_IN_DIR), (name) => {
|
|
2863
2823
|
if (name === undefined || name === basename(INBOX_DROP_IN_DIR)) {
|
|
2864
2824
|
watchDrops();
|
|
2865
|
-
ingestDropFolder(
|
|
2825
|
+
ingestDropFolder();
|
|
2866
2826
|
}
|
|
2867
2827
|
if (name !== basename(INBOX_DROP_IN_DIR) && !name?.startsWith(OWN_QUEUE_PREFIX))
|
|
2868
|
-
syncInboxFromDisk(
|
|
2828
|
+
syncInboxFromDisk();
|
|
2869
2829
|
});
|
|
2870
2830
|
watchDrops();
|
|
2871
2831
|
const reapTimer = setInterval(reapInboxDrops, 60 * 60 * 1000);
|
|
@@ -2873,8 +2833,8 @@ export function startNotifyServer(host) {
|
|
|
2873
2833
|
reapTimer.unref();
|
|
2874
2834
|
return createMcpServer(host.clientId, host.tag);
|
|
2875
2835
|
}
|
|
2876
|
-
/** Takes in what was queued or dropped before this process started.
|
|
2877
|
-
export function takePendingInbox(
|
|
2878
|
-
ingestDropFolder(
|
|
2879
|
-
syncInboxFromDisk(
|
|
2836
|
+
/** Takes in what was queued or dropped before this process started. */
|
|
2837
|
+
export function takePendingInbox() {
|
|
2838
|
+
ingestDropFolder();
|
|
2839
|
+
syncInboxFromDisk();
|
|
2880
2840
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.343",
|
|
4
4
|
"description": "Reach your AI agents from anywhere — and let them reach you. One resident process on 127.0.0.1:7475 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/daemon.js",
|
|
6
6
|
"type": "module",
|
|
File without changes
|