omni-notify-mcp 1.3.504 → 1.3.505
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/messaging/messenger.js +1 -1
- package/dist/notify.js +35 -5
- package/package.json +1 -1
|
@@ -230,7 +230,7 @@ export class TelegramUnknown extends Error {
|
|
|
230
230
|
super(`Telegram answered ${method} with an undocumented ${status}: ${body.slice(0, 500)} (headers ${headersOf(headers)})`);
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
const DOCUMENTED_REFUSALS = new Set([400, 401, 403, 404, 409]);
|
|
233
|
+
export const DOCUMENTED_REFUSALS = new Set([400, 401, 403, 404, 409]);
|
|
234
234
|
// GATE: tries of one Bot API call before a network failure, a 5xx or a 429 is given up as unreachable — each wait doubles from 1 s, a 429 waits the retry_after Telegram names.
|
|
235
235
|
const TELEGRAM_TRIES = 4;
|
|
236
236
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
package/dist/notify.js
CHANGED
|
@@ -28,7 +28,7 @@ import { slackVerifyAndRepair } from "./messaging/slackSetup.js";
|
|
|
28
28
|
import { SlackSocket } from "./messaging/slackSocket.js";
|
|
29
29
|
import { homeView, pickedBlocks, tappedChoice } from "./messaging/slackBlocks.js";
|
|
30
30
|
import { MESSENGER_SETUPS } from "./messaging/setup.js";
|
|
31
|
-
import { SlackMessenger, SlackRefused, SlackUnknown, SlackUnreachable, slackCall, slackWebhookPost, TelegramMessenger, TelegramRefused, TelegramUnknown, TelegramUnreachable, telegramCall } from "./messaging/messenger.js";
|
|
31
|
+
import { DOCUMENTED_REFUSALS, SlackMessenger, SlackRefused, SlackUnknown, SlackUnreachable, slackCall, slackWebhookPost, TelegramMessenger, TelegramRefused, TelegramSendUnconfirmed, TelegramUnknown, TelegramUnreachable, telegramCall } from "./messaging/messenger.js";
|
|
32
32
|
import { PollCursors, DiscordPlatform, TeamsPlatform, NtfyPlatform, SmsPlatform, listenForever, pollForever } from "./messaging/chatInbound.js";
|
|
33
33
|
import { EmailAgentInbox } from "./messaging/emailInbound.js";
|
|
34
34
|
import { StoryTopics, shippedStory, storyOfMessage } from "./messaging/storyTopics.js";
|
|
@@ -1170,11 +1170,26 @@ function logTelegramError(msg) {
|
|
|
1170
1170
|
async function telegramSendTo(token, chatId, text, replyTo, thread) {
|
|
1171
1171
|
if (loadConfig().telegram?.enabled !== true)
|
|
1172
1172
|
throw new Error("Telegram is switched off in BN settings, so nothing is sent to it");
|
|
1173
|
-
|
|
1173
|
+
let posted;
|
|
1174
|
+
try {
|
|
1175
|
+
posted = await postTelegramMessage(tgApi(token, "sendMessage"), { chat_id: chatId, text, reply_to_message_id: replyTo, ...(thread === undefined ? {} : { message_thread_id: thread }) }, telegramParseMode(loadConfig()), AbortSignal.timeout(15_000));
|
|
1176
|
+
}
|
|
1177
|
+
catch (err) {
|
|
1178
|
+
if (!(err instanceof TypeError) && !(err instanceof DOMException))
|
|
1179
|
+
throw err;
|
|
1180
|
+
// Telegram could not be reached to send it, or did not answer in time: a send that timed out may already have been shown (#4927), so it is thrown as unconfirmed and never sent a second time; anything else carries no answer, thrown as unreachable.
|
|
1181
|
+
if (err.name === "TimeoutError")
|
|
1182
|
+
throw new TelegramSendUnconfirmed("sendMessage", 15_000);
|
|
1183
|
+
throw new TelegramUnreachable(`Telegram could not be reached for sendMessage: ${err.message}`);
|
|
1184
|
+
}
|
|
1185
|
+
const { response: r, unformatted } = posted;
|
|
1174
1186
|
if (!r.ok) {
|
|
1175
1187
|
const refused = await telegramSendErrorHint(r);
|
|
1176
1188
|
recordReach("telegram", false, "a reply in his chat", refused);
|
|
1177
|
-
|
|
1189
|
+
// A documented refusal (a revoked token, the bot blocked) is terminal; anything else (busy, a 5xx, rate limited) could not deliver and is not terminal.
|
|
1190
|
+
if (DOCUMENTED_REFUSALS.has(r.status))
|
|
1191
|
+
throw new TelegramRefused("sendMessage", r.status, refused);
|
|
1192
|
+
throw new TelegramUnreachable(`Telegram could not deliver the reply (HTTP ${r.status}): ${refused}`);
|
|
1178
1193
|
}
|
|
1179
1194
|
recordReach("telegram", true, "a reply in his chat", "Telegram took the message");
|
|
1180
1195
|
if (unformatted)
|
|
@@ -1394,7 +1409,7 @@ async function takeTelegramUpdate(token, update) {
|
|
|
1394
1409
|
if (said.ruled)
|
|
1395
1410
|
await dropDecisionButtons(token, chat, msg.reply_to_message.message_id);
|
|
1396
1411
|
if (!masterMuted())
|
|
1397
|
-
await
|
|
1412
|
+
await sendRuling(token, chat, said, msg.message_id, thread);
|
|
1398
1413
|
// Words the board did not rule go on to the BN conversation, so they are never lost; a ruling or a digit is the whole message.
|
|
1399
1414
|
if (said.ruled || !("words" in pick))
|
|
1400
1415
|
return;
|
|
@@ -1505,6 +1520,21 @@ async function tgCall(token, method, body) {
|
|
|
1505
1520
|
log("→", `telegram:${method}`, `NOT DONE: ${err.message}`);
|
|
1506
1521
|
}
|
|
1507
1522
|
}
|
|
1523
|
+
/**
|
|
1524
|
+
* What the board said about a pick he made, sent to him. It is a step AFTER the ruling, so a send that fails is logged NOT DONE and never thrown: the board already took his pick, and letting the
|
|
1525
|
+
* failure out would leave the update unacted, have the poller read it again, and send the same pick a second time — which the board answers an already answered decision as a false NOT RULED.
|
|
1526
|
+
*/
|
|
1527
|
+
async function sendRuling(token, chatId, said, replyTo, thread) {
|
|
1528
|
+
try {
|
|
1529
|
+
await telegramSendTo(token, chatId, `${said.ruled ? "✅ RULED" : "❌ NOT RULED"}\n${said.report}`, replyTo, thread);
|
|
1530
|
+
}
|
|
1531
|
+
catch (err) {
|
|
1532
|
+
if (!(err instanceof TelegramRefused || err instanceof TelegramUnreachable || err instanceof TelegramUnknown || err instanceof TelegramSendUnconfirmed))
|
|
1533
|
+
throw err;
|
|
1534
|
+
// OWNER: the ruling the board already took must never be lost to a failed confirmation, so this send is named NOT DONE here and the update is acted on — the same pick is never read again and re-picked.
|
|
1535
|
+
log("→", "telegram:sendMessage", `NOT DONE: the ${said.ruled ? "ruling" : "refusal"} of his pick reached the board but not him: ${err.message}`);
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1508
1538
|
/** Takes the option buttons off a decision message once it is ruled, so a second tap cannot land on an answered decision. */
|
|
1509
1539
|
async function dropDecisionButtons(token, chatId, messageId) {
|
|
1510
1540
|
await tgCall(token, "editMessageReplyMarkup", { chat_id: chatId, message_id: messageId, reply_markup: { inline_keyboard: [] } });
|
|
@@ -1541,7 +1571,7 @@ async function takeDecisionTap(token, chatIds, tap) {
|
|
|
1541
1571
|
await dropDecisionButtons(token, chatId, tap.message.message_id);
|
|
1542
1572
|
if (masterMuted())
|
|
1543
1573
|
return;
|
|
1544
|
-
await
|
|
1574
|
+
await sendRuling(token, chatId, said, tap.message.message_id, tap.message.is_topic_message === true ? tap.message.message_thread_id : undefined);
|
|
1545
1575
|
}
|
|
1546
1576
|
/**
|
|
1547
1577
|
* The bot's long poll, in the daemon only. A network failure, a 5xx and a 429 back off and poll again; a documented
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.505",
|
|
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",
|