omni-notify-mcp 1.3.488 → 1.3.489
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/agentGateway.js +43 -11
- package/dist/notify.js +76 -23
- package/dist/shared/webhost/workspaceList.js +56 -8
- package/package.json +1 -1
package/dist/agentGateway.js
CHANGED
|
@@ -12,6 +12,7 @@ import { randomUUID } from "crypto";
|
|
|
12
12
|
import { closeSync, existsSync, openSync, readdirSync, readSync, statSync } from "fs";
|
|
13
13
|
import { homedir } from "os";
|
|
14
14
|
import { join } from "path";
|
|
15
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
15
16
|
import { choicesOf, StreamedReply } from "./messaging/messenger.js";
|
|
16
17
|
import { GatewayError, readGatewaySettings } from "./notify.js";
|
|
17
18
|
import { toolLine } from "./shared/toolLine.js";
|
|
@@ -45,11 +46,11 @@ export function clusterUnreachable(err) {
|
|
|
45
46
|
return new GatewayError(503, `AgenticBullseye at ${clusterBase()} could not be reached (${cause}); the agent conversations run there`);
|
|
46
47
|
}
|
|
47
48
|
/** One call to AB under the gateway bearer: AB's JSON answer, or AB's own refusal as a GatewayError carrying its status and words. */
|
|
48
|
-
export async function clusterCall(method, path, body) {
|
|
49
|
+
export async function clusterCall(method, path, body, signal) {
|
|
49
50
|
let answer;
|
|
50
51
|
for (let attempt = 1;; attempt++) {
|
|
51
52
|
try {
|
|
52
|
-
answer = await fetch(`${clusterBase()}${path}`, { method, headers: { authorization: `Bearer ${clusterToken()}`, ...(body === undefined ? {} : { "content-type": "application/json" }) }, body: body === undefined ? undefined : JSON.stringify(body) });
|
|
53
|
+
answer = await fetch(`${clusterBase()}${path}`, { method, headers: { authorization: `Bearer ${clusterToken()}`, ...(body === undefined ? {} : { "content-type": "application/json" }) }, body: body === undefined ? undefined : JSON.stringify(body), signal });
|
|
53
54
|
break;
|
|
54
55
|
}
|
|
55
56
|
catch (err) {
|
|
@@ -60,10 +61,18 @@ export async function clusterCall(method, path, body) {
|
|
|
60
61
|
// OWNER: ITER/LOOP — a refused connection never reached AB (it is restarting), so it is tried again after a pause; any other failure, or the last try, is AB unreachable, thrown as the 503 naming it.
|
|
61
62
|
if (!refused || attempt === CLUSTER_CALL_TRIES)
|
|
62
63
|
throw clusterUnreachable(err);
|
|
63
|
-
await
|
|
64
|
+
await delay(CLUSTER_FIRST_WAIT_MS << (attempt - 1), undefined, { signal });
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
let text;
|
|
68
|
+
try {
|
|
69
|
+
text = await answer.text();
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
if (!(err instanceof TypeError))
|
|
73
|
+
throw err;
|
|
74
|
+
throw clusterUnreachable(err);
|
|
75
|
+
}
|
|
67
76
|
let parsed;
|
|
68
77
|
try {
|
|
69
78
|
parsed = JSON.parse(text);
|
|
@@ -84,6 +93,17 @@ export async function clusterCall(method, path, body) {
|
|
|
84
93
|
function carriage(op, body) {
|
|
85
94
|
return clusterCall("POST", `/v1/chat/${op}`, body);
|
|
86
95
|
}
|
|
96
|
+
async function chatCallWithDeadline(op, body) {
|
|
97
|
+
const signal = AbortSignal.timeout(2000);
|
|
98
|
+
try {
|
|
99
|
+
return await clusterCall("POST", `/v1/chat/${op}`, body, signal);
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (!signal.aborted)
|
|
103
|
+
throw err;
|
|
104
|
+
throw new GatewayError(504, "AgenticBullseye did not answer in time.");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
87
107
|
export class AgentGateway {
|
|
88
108
|
static self;
|
|
89
109
|
static instance() {
|
|
@@ -123,19 +143,31 @@ export class AgentGateway {
|
|
|
123
143
|
if (!text.startsWith(AGENT_PREFIX) && !COMMAND_RE.test(text))
|
|
124
144
|
return undefined;
|
|
125
145
|
// NULL-OK: field act is OPTIONAL and therefore it is ok to check for NULL
|
|
126
|
-
return (await
|
|
146
|
+
return (await chatCallWithDeadline("classify", { key, raw })).act ?? undefined;
|
|
127
147
|
}
|
|
128
148
|
/** A message inside a thread the agent holds is all for the agent: `/new` and `/stop` act, anything else is said, with or without `!`. */
|
|
129
149
|
async classifyInThread(key, raw) {
|
|
130
|
-
return (await
|
|
150
|
+
return (await chatCallWithDeadline("classifyInThread", { key, raw })).act;
|
|
131
151
|
}
|
|
132
152
|
/** A message of Meni's one chat is all for its one conversation (#4453); `bare` says the chat cannot type a slash, so a bare "new" or "stop" is a command there. */
|
|
133
153
|
async classifyChat(raw, bare) {
|
|
134
|
-
return (await
|
|
154
|
+
return (await chatCallWithDeadline("classifyChat", { raw, bare })).act;
|
|
135
155
|
}
|
|
136
156
|
/** The text one message of Meni's one chat is sent as: the bound conversation's brief on its first turn, then what the chat knows around it, then his own words. */
|
|
137
157
|
async turnText(key, text, context) {
|
|
138
|
-
return (await
|
|
158
|
+
return (await chatCallWithDeadline("turnText", { key, text, context })).text;
|
|
159
|
+
}
|
|
160
|
+
async workingStatus(key, platform) {
|
|
161
|
+
try {
|
|
162
|
+
const { text } = await chatCallWithDeadline("workingStatus", { key, platform });
|
|
163
|
+
return text;
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
// OWNER: the status read answers its originating chat even when the cluster cannot report the turn.
|
|
167
|
+
if (!(err instanceof GatewayError))
|
|
168
|
+
throw err;
|
|
169
|
+
return err.status === 504 ? "BN received your message. The agent did not report its status in time." : "BN received your message. The agent's status is unavailable.";
|
|
170
|
+
}
|
|
139
171
|
}
|
|
140
172
|
/**
|
|
141
173
|
* A message's act as AB classifies it; one AB could not classify (unreachable, or refused with its reason) has that
|
|
@@ -158,15 +190,15 @@ export class AgentGateway {
|
|
|
158
190
|
return (await carriage("emailTaken", { messageId })).taken;
|
|
159
191
|
}
|
|
160
192
|
async openSlackThreads() {
|
|
161
|
-
return (await
|
|
193
|
+
return (await chatCallWithDeadline("openSlackThreads", {})).conversations;
|
|
162
194
|
}
|
|
163
195
|
/** Every conversation AB holds, each marked `working` while a turn of it is under way: the Slack Home tab and the Slack thread reader list them. */
|
|
164
196
|
async conversations() {
|
|
165
|
-
return (await
|
|
197
|
+
return (await chatCallWithDeadline("conversations", {})).conversations;
|
|
166
198
|
}
|
|
167
199
|
/** Records how far a Slack thread has been read. */
|
|
168
200
|
async markSlackRead(key, readTs) {
|
|
169
|
-
await
|
|
201
|
+
await chatCallWithDeadline("markSlackRead", { key, readTs });
|
|
170
202
|
}
|
|
171
203
|
/**
|
|
172
204
|
* Hands one addressed message to AB with its own way back held under a fresh reply id. A plain reply resolves once the
|
package/dist/notify.js
CHANGED
|
@@ -1325,6 +1325,19 @@ function toOneChat(key, platform, act, messenger) {
|
|
|
1325
1325
|
log("→", trail, `NOT DELIVERED to ${key}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1326
1326
|
});
|
|
1327
1327
|
}
|
|
1328
|
+
function isWorkingProbe(text) {
|
|
1329
|
+
return /^(?:!\s*)?working\?$/i.test(text.trim());
|
|
1330
|
+
}
|
|
1331
|
+
async function answerWorkingProbe(key, platform, reply) {
|
|
1332
|
+
const status = await AgentGateway.instance().workingStatus(key, platform);
|
|
1333
|
+
await reply(status);
|
|
1334
|
+
}
|
|
1335
|
+
async function answerSlackThreadProbe(token, channel, threadTs, ts) {
|
|
1336
|
+
if (!firstRouting(channel, ts))
|
|
1337
|
+
return;
|
|
1338
|
+
const view = slackChannelChat(token, channel).inThread(threadTs);
|
|
1339
|
+
await answerWorkingProbe(`slack:${channel}:${threadTs}`, "slack", (part) => view.send(part));
|
|
1340
|
+
}
|
|
1328
1341
|
/** One update of the bot: a message of the bound chat, or a tap on one of its buttons. */
|
|
1329
1342
|
async function takeTelegramUpdate(token, update) {
|
|
1330
1343
|
const chatIds = loadConfig().telegram?.chatIds ?? [];
|
|
@@ -1375,6 +1388,11 @@ async function takeTelegramUpdate(token, update) {
|
|
|
1375
1388
|
log("←", "telegram", saved === undefined ? text : `${text} [file ${saved}]`);
|
|
1376
1389
|
// A message written inside a topic is never the plain chat's last inbound, so a later plain notification never replies into that topic.
|
|
1377
1390
|
noteTelegramInbound(msg.message_id, chat, Date.now(), thread !== undefined);
|
|
1391
|
+
if (typeof msg.text === "string" && isWorkingProbe(text)) {
|
|
1392
|
+
const key = thread === undefined ? `telegram:${chat}` : `telegram:${chat}:${thread}`;
|
|
1393
|
+
await answerWorkingProbe(key, "telegram", (part) => telegramMessenger(token, chat, thread, msg.message_id).alongside().send(part));
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1378
1396
|
if (/^\/start(@\w+)?$/i.test(text.trim())) {
|
|
1379
1397
|
await messenger.send(TELEGRAM_WELCOME);
|
|
1380
1398
|
return;
|
|
@@ -2198,6 +2216,11 @@ async function answerSlackAgentMessage(token, channel, m, owner) {
|
|
|
2198
2216
|
}
|
|
2199
2217
|
const stripped = text.replace(/<@[A-Za-z0-9]+>/g, "");
|
|
2200
2218
|
const key = `slack:${channel}:${m.ts}`;
|
|
2219
|
+
if (isWorkingProbe(stripped)) {
|
|
2220
|
+
log("←", "agent:slack", text);
|
|
2221
|
+
await answerWorkingProbe(slackDmKey(channel, undefined), "slack", (part) => slackPostInThread(token, channel, String(m.ts), part));
|
|
2222
|
+
return;
|
|
2223
|
+
}
|
|
2201
2224
|
const gateway = AgentGateway.instance();
|
|
2202
2225
|
const act = await gateway.classified(() => gateway.classify(key, stripped), (part) => slackPostInThread(token, channel, String(m.ts), part));
|
|
2203
2226
|
if (act === "answered")
|
|
@@ -2220,6 +2243,11 @@ async function pollAgentThreads(token, owner, threads) {
|
|
|
2220
2243
|
throw new Error(`conversations.replies: ${json.error ?? "unknown"}`);
|
|
2221
2244
|
const fresh = (json.messages ?? []).filter((m) => Number(m.ts) > Number(readTs)).sort((a, b) => Number(a.ts) - Number(b.ts));
|
|
2222
2245
|
for (const m of fresh) {
|
|
2246
|
+
if (isHumanSlackMessage(m) && m.user === owner && isWorkingProbe(slackPlain(String(m.text))) && String(m.ts) !== threadTs) {
|
|
2247
|
+
await answerSlackThreadProbe(token, channel, threadTs, String(m.ts));
|
|
2248
|
+
await gateway.markSlackRead(c.chat, String(m.ts));
|
|
2249
|
+
continue;
|
|
2250
|
+
}
|
|
2223
2251
|
await gateway.markSlackRead(c.chat, String(m.ts));
|
|
2224
2252
|
if (!isHumanSlackMessage(m))
|
|
2225
2253
|
continue;
|
|
@@ -2285,10 +2313,10 @@ async function routeSlackInbox(m, reply) {
|
|
|
2285
2313
|
async function pollSlackOnce(token, channel) {
|
|
2286
2314
|
const cursor = slackBusCursor(channel);
|
|
2287
2315
|
const reply = (text) => slackBusReply(token, channel, text);
|
|
2288
|
-
const json = await slackCall(SLACK_API_BASE, token, `conversations.history?channel=${encodeURIComponent(channel)}&
|
|
2316
|
+
const json = await slackCall(SLACK_API_BASE, token, `conversations.history?channel=${encodeURIComponent(channel)}&limit=50`, {});
|
|
2289
2317
|
const all = json.messages ?? [];
|
|
2290
2318
|
const human = all
|
|
2291
|
-
.filter(m =>
|
|
2319
|
+
.filter(m => Number(m.ts) > Number(cursor.value) && isHumanSlackMessage(m))
|
|
2292
2320
|
.sort((a, b) => Number(a.ts) - Number(b.ts));
|
|
2293
2321
|
const isAsk = (m) => String(m.text ?? "").replace(/<@[A-Za-z0-9]+>/g, "").toLowerCase().trim().startsWith(AGENT_PREFIX);
|
|
2294
2322
|
// Every message meant for the agent — his own words and a '!'-prefixed ask — not bus commands or a message addressed to a connected client.
|
|
@@ -2340,6 +2368,19 @@ async function pollSlackOnce(token, channel) {
|
|
|
2340
2368
|
}
|
|
2341
2369
|
}
|
|
2342
2370
|
cursor.moveTo(all.reduce((acc, m) => (Number(m.ts) > Number(acc) ? String(m.ts) : acc), cursor.value));
|
|
2371
|
+
const threadReplies = slackThreadsWithReplies(channel, all, slackChannelProbesFrom);
|
|
2372
|
+
if (threadReplies.length > 0 && human.length === 0)
|
|
2373
|
+
await findOwner();
|
|
2374
|
+
// NULL-OK: field owner is OPTIONAL and therefore it is ok to check for NULL
|
|
2375
|
+
if (owner !== undefined) {
|
|
2376
|
+
const authorized = owner;
|
|
2377
|
+
for (const threadTs of threadReplies) {
|
|
2378
|
+
await readSlackThread(token, channel, threadTs, async (m) => {
|
|
2379
|
+
if (m.user === authorized && isWorkingProbe(slackPlain(String(m.text))))
|
|
2380
|
+
await answerSlackThreadProbe(token, channel, threadTs, String(m.ts));
|
|
2381
|
+
});
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2343
2384
|
try {
|
|
2344
2385
|
const threads = await AgentGateway.instance().openSlackThreads();
|
|
2345
2386
|
if (threads.length > 0 && human.length === 0)
|
|
@@ -2400,7 +2441,8 @@ function cursorPast(cursor, ts) {
|
|
|
2400
2441
|
}
|
|
2401
2442
|
/** The place the poll has read to in one thread of the direct message (#4585), kept across restarts. */
|
|
2402
2443
|
const SLACK_THREAD_CURSOR = "slack-dm-thread:";
|
|
2403
|
-
const
|
|
2444
|
+
const slackChannelProbesFrom = Date.now() / 1000;
|
|
2445
|
+
const slackThreadCursor = (channel, threadTs, after = Number(threadTs)) => POLL_CURSORS.cursor(`${SLACK_THREAD_CURSOR}${channel}:${threadTs}`, () => String(Math.max(Number(threadTs), after)));
|
|
2404
2446
|
/** The direct-message chat of each bot token, opened once per process. */
|
|
2405
2447
|
const slackDms = new Map();
|
|
2406
2448
|
/** Why the direct message cannot be read with this bot token; it is not tried again until the token changes or BN restarts. */
|
|
@@ -2476,6 +2518,11 @@ async function takeSlackDmMessage(dm, owner, m, threadTs) {
|
|
|
2476
2518
|
const view = threadTs === undefined ? dm : slackDmThread(dm, threadTs);
|
|
2477
2519
|
const text = slackPlain(String(m.text));
|
|
2478
2520
|
log("←", "agent:slack", text);
|
|
2521
|
+
if (isWorkingProbe(text)) {
|
|
2522
|
+
const target = threadTs === String(m.ts) ? slackDmKey(dm.channel, undefined) : key;
|
|
2523
|
+
await answerWorkingProbe(target, "slack", (part) => view.send(part));
|
|
2524
|
+
return;
|
|
2525
|
+
}
|
|
2479
2526
|
const picked = view.choiceFor(text);
|
|
2480
2527
|
// NULL-OK: field picked is OPTIONAL and therefore it is ok to check for NULL
|
|
2481
2528
|
const providerCmd = picked === undefined ? text.trim().match(PROVIDER_COMMAND) : null;
|
|
@@ -2514,7 +2561,8 @@ async function pollSlackDm(token) {
|
|
|
2514
2561
|
await takeSlackDmMessage(dm, owner, m, threaded ? String(m.ts) : undefined);
|
|
2515
2562
|
}
|
|
2516
2563
|
SLACK_DM_CURSOR.moveTo(newTop.reduce((acc, m) => (Number(m.ts) > Number(acc) ? String(m.ts) : acc), SLACK_DM_CURSOR.value));
|
|
2517
|
-
|
|
2564
|
+
for (const threadTs of slackThreadsWithReplies(dm.channel, all))
|
|
2565
|
+
await readSlackDmThread(token, dm, owner, threadTs);
|
|
2518
2566
|
if (threaded && Date.now() - slackThreadsReadAt >= SLACK_LIVE_POLL_MS) {
|
|
2519
2567
|
slackThreadsReadAt = Date.now();
|
|
2520
2568
|
await pollSlackDmThreads(token, dm, owner);
|
|
@@ -2537,44 +2585,49 @@ const SLACK_THREAD_KEPT_MS = 7 * 24 * 3_600_000;
|
|
|
2537
2585
|
* Reads one thread of the direct message from its cursor: each new reply of his goes on in that thread's conversation. A thread Slack
|
|
2538
2586
|
* will not read is named once per reason; one whose parent message is gone is let go.
|
|
2539
2587
|
*/
|
|
2540
|
-
async function readSlackThread(token,
|
|
2541
|
-
const
|
|
2588
|
+
async function readSlackThread(token, channel, threadTs, take) {
|
|
2589
|
+
const key = `${channel}:${threadTs}`;
|
|
2590
|
+
const cursor = slackThreadCursor(channel, threadTs);
|
|
2542
2591
|
let read;
|
|
2543
2592
|
try {
|
|
2544
|
-
read = await slackCall(SLACK_API_BASE, token, "conversations.replies", { channel
|
|
2545
|
-
slackThreadUnread.delete(
|
|
2593
|
+
read = await slackCall(SLACK_API_BASE, token, "conversations.replies", { channel, ts: threadTs, oldest: cursor.value, limit: 100 });
|
|
2594
|
+
slackThreadUnread.delete(key);
|
|
2546
2595
|
}
|
|
2547
2596
|
catch (err) {
|
|
2548
2597
|
if (!(err instanceof SlackRefused) && !(err instanceof SlackUnknown) && !(err instanceof SlackUnreachable))
|
|
2549
2598
|
throw err;
|
|
2550
2599
|
// OWNER: ITER/LOOP — one thread Slack will not read now is named once per reason and the next thread is still read; a thread whose parent is gone has its cursor let go.
|
|
2551
|
-
if (slackThreadUnread.get(
|
|
2552
|
-
log("·", "slack:error", `thread ${
|
|
2553
|
-
slackThreadUnread.set(
|
|
2600
|
+
if (slackThreadUnread.get(key) !== err.message)
|
|
2601
|
+
log("·", "slack:error", `Slack thread ${key} was not read: ${err.message}`);
|
|
2602
|
+
slackThreadUnread.set(key, err.message);
|
|
2554
2603
|
if (err instanceof SlackRefused && err.error === "thread_not_found") {
|
|
2555
|
-
slackThreadsGone.add(
|
|
2556
|
-
POLL_CURSORS.delete(`${SLACK_THREAD_CURSOR}${
|
|
2604
|
+
slackThreadsGone.add(key);
|
|
2605
|
+
POLL_CURSORS.delete(`${SLACK_THREAD_CURSOR}${key}`);
|
|
2557
2606
|
}
|
|
2558
2607
|
return;
|
|
2559
2608
|
}
|
|
2560
2609
|
const replies = (read.messages ?? []).filter((m) => String(m.ts) !== threadTs && Number(m.ts) > Number(cursor.value));
|
|
2561
2610
|
for (const m of replies.filter(isHumanSlackMessage).sort((a, b) => Number(a.ts) - Number(b.ts))) {
|
|
2562
2611
|
cursorPast(cursor, String(m.ts));
|
|
2563
|
-
|
|
2564
|
-
await takeSlackDmMessage(dm, owner, m, threadTs);
|
|
2612
|
+
await take(m);
|
|
2565
2613
|
}
|
|
2566
2614
|
for (const m of replies)
|
|
2567
2615
|
cursorPast(cursor, String(m.ts));
|
|
2568
2616
|
}
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2617
|
+
async function readSlackDmThread(token, dm, owner, threadTs) {
|
|
2618
|
+
await readSlackThread(token, dm.channel, threadTs, async (m) => {
|
|
2619
|
+
if (firstRouting(dm.channel, String(m.ts)))
|
|
2620
|
+
await takeSlackDmMessage(dm, owner, m, threadTs);
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
/** The history marks a thread's parent with `latest_reply`, so a thread with nothing new costs no call. */
|
|
2624
|
+
function slackThreadsWithReplies(channel, recent, after) {
|
|
2625
|
+
return recent
|
|
2572
2626
|
.filter((m) => m.thread_ts !== undefined && String(m.thread_ts) === String(m.ts) && m.latest_reply !== undefined)
|
|
2573
2627
|
.filter((m) => Date.now() - Number(m.latest_reply) * 1000 < SLACK_THREAD_READ_MS)
|
|
2574
|
-
.filter((m) => !slackThreadsGone.has(`${
|
|
2575
|
-
.filter((m) => Number(m.latest_reply) > Number(slackThreadCursor(
|
|
2576
|
-
|
|
2577
|
-
await readSlackThread(token, dm, owner, String(m.ts));
|
|
2628
|
+
.filter((m) => !slackThreadsGone.has(`${channel}:${m.ts}`))
|
|
2629
|
+
.filter((m) => Number(m.latest_reply) > Number(slackThreadCursor(channel, String(m.ts), after).value))
|
|
2630
|
+
.map((m) => String(m.ts));
|
|
2578
2631
|
}
|
|
2579
2632
|
/**
|
|
2580
2633
|
* Reads the threads of the direct message whose conversation spoke in the last day, newest first: each new reply of his goes on in
|
|
@@ -2591,7 +2644,7 @@ async function pollSlackDmThreads(token, dm, owner) {
|
|
|
2591
2644
|
const threads = [...day.slice(start), ...day.slice(0, start)].slice(0, SLACK_THREADS_A_PASS);
|
|
2592
2645
|
slackThreadTurn = start + threads.length;
|
|
2593
2646
|
for (const threadTs of threads)
|
|
2594
|
-
await
|
|
2647
|
+
await readSlackDmThread(token, dm, owner, threadTs);
|
|
2595
2648
|
const tooOld = Date.now() / 1000 - SLACK_THREAD_KEPT_MS / 1000;
|
|
2596
2649
|
for (const key of POLL_CURSORS.keys())
|
|
2597
2650
|
if (key.startsWith(`${SLACK_THREAD_CURSOR}${dm.channel}:`) && Number(key.split(":").pop()) < tooOld)
|
|
@@ -13,7 +13,7 @@ const CHECKOUT = {
|
|
|
13
13
|
listFile: () => path.join(vscRoot(), "workspaces.json"),
|
|
14
14
|
noList: (file) => `the BullseyeVSC checkout holds no workspace list (${file}) — pull BullseyeVSC, or add the folders on Bullseye Control`,
|
|
15
15
|
settingsFileOf: (listed, tool) => path.join(listed.root, ".bullseye", "settings", `${tool}.json`),
|
|
16
|
-
publish:
|
|
16
|
+
publish: publishFile,
|
|
17
17
|
toolHome: () => vscRoot(),
|
|
18
18
|
homeFileOf: () => undefined,
|
|
19
19
|
holdsToolHome: () => workspacesHere().some((w) => sameRoot(w.root, vscRoot())),
|
|
@@ -28,8 +28,17 @@ const LOCAL = {
|
|
|
28
28
|
homeFileOf: (root, tool) => (sameRoot(root, LOCAL.toolHome()) ? path.join(LOCAL.toolHome(), "settings", `${tool}.json`) : undefined),
|
|
29
29
|
holdsToolHome: () => true,
|
|
30
30
|
};
|
|
31
|
+
/** #4827 — what one event-loop turn has already read: the server asks for the list on every settings call, and each ask cost an existsSync and a statSync per listed root. Dropped at the next turn, and by a save. */
|
|
32
|
+
let turn;
|
|
33
|
+
function workspaceTurn() {
|
|
34
|
+
if (turn === undefined) {
|
|
35
|
+
turn = { store: fs.existsSync(vscRoot()) ? CHECKOUT : LOCAL, list: undefined };
|
|
36
|
+
setImmediate(() => { turn = undefined; }).unref();
|
|
37
|
+
}
|
|
38
|
+
return turn;
|
|
39
|
+
}
|
|
31
40
|
function store() {
|
|
32
|
-
return
|
|
41
|
+
return workspaceTurn().store;
|
|
33
42
|
}
|
|
34
43
|
/** #3849 — the root a machine-wide tool (BS, BU) keeps its own settings under: the BullseyeVSC checkout, or ~/.bullseye on a box without one. Its readSettings, writeSettings and publishSettings take this root like a workspace's. */
|
|
35
44
|
function toolHome() {
|
|
@@ -71,7 +80,22 @@ function nameKey(entry) {
|
|
|
71
80
|
return path.basename(homeRelative(entry) ? entry : path.resolve(entry)).toLowerCase();
|
|
72
81
|
}
|
|
73
82
|
function listedWorkspaces() {
|
|
74
|
-
const
|
|
83
|
+
const current = workspaceTurn();
|
|
84
|
+
if (current.list === undefined) {
|
|
85
|
+
try {
|
|
86
|
+
current.list = { entries: readListed(current.store.listFile()) };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (!(error instanceof SyntaxError))
|
|
90
|
+
throw error;
|
|
91
|
+
current.list = { error };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if ("error" in current.list)
|
|
95
|
+
throw current.list.error;
|
|
96
|
+
return current.list.entries.map((entry) => ({ ...entry }));
|
|
97
|
+
}
|
|
98
|
+
function readListed(file) {
|
|
75
99
|
let text;
|
|
76
100
|
try {
|
|
77
101
|
text = fs.readFileSync(file, "utf8");
|
|
@@ -110,6 +134,7 @@ function listedWorkspaces() {
|
|
|
110
134
|
return { label: present ? labelOf(root) : path.basename(root), root, path: entry.path, present };
|
|
111
135
|
});
|
|
112
136
|
}
|
|
137
|
+
/** @returns {{ label: string, root: string }[]} The named workspaces available on this machine. */
|
|
113
138
|
function workspacesHere() {
|
|
114
139
|
return listedWorkspaces().filter((w) => w.present).map(({ label, root }) => ({ label, root }));
|
|
115
140
|
}
|
|
@@ -139,7 +164,12 @@ function saveWorkspaces(folders) {
|
|
|
139
164
|
entries.push({ path: entry });
|
|
140
165
|
}
|
|
141
166
|
const file = workspacesFile();
|
|
142
|
-
underLock(file, () =>
|
|
167
|
+
underLock(file, () => writeWorkspaceList(file, listText(entries)));
|
|
168
|
+
}
|
|
169
|
+
function writeWorkspaceList(file, text) {
|
|
170
|
+
writeAtomically(file, text);
|
|
171
|
+
if (turn !== undefined)
|
|
172
|
+
turn.list = undefined;
|
|
143
173
|
}
|
|
144
174
|
function listText(entries) {
|
|
145
175
|
return `${JSON.stringify({ workspaces: entries }, null, 2)}\n`;
|
|
@@ -168,8 +198,24 @@ function settingsFile(root, tool) {
|
|
|
168
198
|
const listed = workspacesHere().find((w) => sameRoot(w.root, root));
|
|
169
199
|
if (listed === undefined)
|
|
170
200
|
throw new WorkspaceNotListed(`${root} is not a workspace on this machine's list (${workspacesFile()}) — settings are kept only for a listed workspace`);
|
|
201
|
+
if (tool === "da" && sameRoot(root, vscRoot()))
|
|
202
|
+
return localDeepAgentFile(CHECKOUT.settingsFileOf(listed, tool));
|
|
171
203
|
return store().settingsFileOf(listed, tool);
|
|
172
204
|
}
|
|
205
|
+
/** Keep the existing settings and sign-ins through the checkout's removal of its legacy da.json. */
|
|
206
|
+
function localDeepAgentFile(legacy) {
|
|
207
|
+
const local = path.join(LOCAL.toolHome(), "settings", "da.json");
|
|
208
|
+
if (fs.existsSync(local) || !fs.existsSync(legacy))
|
|
209
|
+
return local;
|
|
210
|
+
underLock(local, () => {
|
|
211
|
+
if (bytesOf(local) !== undefined)
|
|
212
|
+
return;
|
|
213
|
+
const old = bytesOf(legacy);
|
|
214
|
+
if (old !== undefined)
|
|
215
|
+
writeAtomically(local, serialized(parsedSettings(legacy, old.toString("utf8"))));
|
|
216
|
+
});
|
|
217
|
+
return local;
|
|
218
|
+
}
|
|
173
219
|
const digest = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex");
|
|
174
220
|
/** #3849 — the part of `tool`'s settings that belongs to this box alone (a login it signed in with itself): kept in its own ~/.bullseye/settings, never published and never merged, so no other box's copy can replace it. */
|
|
175
221
|
function boxFile(root, tool) {
|
|
@@ -331,7 +377,7 @@ function writeAtomically(file, text) {
|
|
|
331
377
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
332
378
|
const staged = `${file}.${process.pid}.tmp`;
|
|
333
379
|
try {
|
|
334
|
-
fs.writeFileSync(staged, text);
|
|
380
|
+
fs.writeFileSync(staged, text, { mode: 0o600 });
|
|
335
381
|
}
|
|
336
382
|
catch (failed) {
|
|
337
383
|
fs.rmSync(staged, { force: true });
|
|
@@ -638,7 +684,7 @@ async function settleHere(root, rel, text, commit) {
|
|
|
638
684
|
* refused because origin moved is fetched and cut again after a backoff, up to PUBLISH_ATTEMPTS; any other git failure THROWS. Resolves with the pushed
|
|
639
685
|
* commit, or null when origin already holds the file.
|
|
640
686
|
*/
|
|
641
|
-
async function publishFile(root, file, merge, subject) {
|
|
687
|
+
async function publishFile(root, file, merge, subject, write = writeAtomically) {
|
|
642
688
|
const rel = `${(await git(path.dirname(file), ["rev-parse", "--show-prefix"])).trim()}${path.basename(file)}`;
|
|
643
689
|
const published = path.join((await git(root, ["rev-parse", "--absolute-git-dir"])).trim(), "bullseye", "published", rel.split("/").join("__"));
|
|
644
690
|
for (let attempt = 1;; attempt++) {
|
|
@@ -650,7 +696,7 @@ async function publishFile(root, file, merge, subject) {
|
|
|
650
696
|
const oursText = fs.readFileSync(file, "utf8");
|
|
651
697
|
const joined = merge(baseText, oursText, theirsText);
|
|
652
698
|
if (joined.text !== oursText)
|
|
653
|
-
|
|
699
|
+
write(file, joined.text);
|
|
654
700
|
return joined;
|
|
655
701
|
});
|
|
656
702
|
if (contested.length > 0)
|
|
@@ -690,6 +736,8 @@ async function publishFile(root, file, merge, subject) {
|
|
|
690
736
|
}
|
|
691
737
|
/** Carries `tool`'s settings of workspace `root` to every box through its repo, merged key by key with another box's change; a box with no BullseyeVSC checkout carries nothing and resolves null. */
|
|
692
738
|
function publishSettings(root, tool) {
|
|
739
|
+
if (tool === "da" && sameRoot(root, toolHome()))
|
|
740
|
+
return Promise.resolve(null);
|
|
693
741
|
const file = settingsFile(root, tool);
|
|
694
742
|
const parse = (text) => (text === null ? EMPTY : parsedSettings(file, text));
|
|
695
743
|
return store().publish(root, file, (base, ours, theirs) => {
|
|
@@ -701,7 +749,7 @@ function publishSettings(root, tool) {
|
|
|
701
749
|
/** Carries the workspace list to every box through the BullseyeVSC repo, merged folder by folder with another box's change; a box with no BullseyeVSC checkout carries nothing and resolves null. */
|
|
702
750
|
function publishWorkspaces() {
|
|
703
751
|
const parse = (text) => (text === null ? [] : JSON.parse(text).workspaces);
|
|
704
|
-
return store().publish(vscRoot(), workspacesFile(), (base, ours, theirs) => ({ text: listText(mergeList(parse(base), parse(ours), parse(theirs))), contested: [] }), "workspace list");
|
|
752
|
+
return store().publish(vscRoot(), workspacesFile(), (base, ours, theirs) => ({ text: listText(mergeList(parse(base), parse(ours), parse(theirs))), contested: [] }), "workspace list", writeWorkspaceList);
|
|
705
753
|
}
|
|
706
754
|
/** #3849 — a machine-wide tool's (BS, BU) saved settings under toolHome(): undefined while no list is defined, the BullseyeVSC checkout is off it or the tool has saved none yet; any other failure THROWS. */
|
|
707
755
|
function savedSettings(tool) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.489",
|
|
4
4
|
"homepage": "https://www.npmjs.com/package/omni-notify-mcp",
|
|
5
5
|
"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.",
|
|
6
6
|
"main": "dist/daemon.js",
|