omni-notify-mcp 1.3.504 → 1.3.506

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/chunk.js CHANGED
@@ -22,6 +22,11 @@ const BLOCK_START = /^\s*(#{1,6}\s|>|[-*+]\s|\||```|\*\*\S)/;
22
22
  export function withLead(lead, text) {
23
23
  return `${lead}${BLOCK_START.test(text) ? "\n" : " "}${text}`;
24
24
  }
25
+ /** #5085 — the text one channel reads: `message` whole, or with `lead.from` swapped for that channel's own wording when the caller named one. */
26
+ export function forChannel(message, channel, lead) {
27
+ const said = lead?.per[channel];
28
+ return lead === undefined || said === undefined ? message : message.split(lead.from).join(said);
29
+ }
25
30
  export function splitForNotify(message, limit = NOTIFY_CHUNK_LIMIT) {
26
31
  if (message.length <= limit)
27
32
  return [message];
@@ -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
@@ -21,14 +21,14 @@ import { sendWithRouting, formatIdleReading, describePriorityRouting } from "./m
21
21
  import { deliveryVerdict } from "./messaging/deliveryVerdict.js";
22
22
  import { telegramSendErrorHint } from "./messaging/telegramError.js";
23
23
  import { postTelegramMessage, telegramParseMode } from "./messaging/telegramFormat.js";
24
- import { splitForNotify, withLead } from "./chunk.js";
24
+ import { forChannel, splitForNotify, withLead } from "./chunk.js";
25
25
  import { idleNow, playVoice, showBanner } from "./desk.js";
26
26
  import { AgentGateway, AGENT_PREFIX, SLACK_DM, streamedChat } from "./agentGateway.js";
27
27
  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";
@@ -389,7 +389,7 @@ export const textOwner = (message) => smsEveryNumber(loadConfig(), message);
389
389
  export function masterMuted() {
390
390
  return loadConfig().muteAll === true;
391
391
  }
392
- async function sendNotification(message, priority, client, buttons, topic) {
392
+ async function sendNotification(message, priority, client, buttons, topic, lead) {
393
393
  const cfg = loadConfig();
394
394
  if (cfg.muteAll === true) {
395
395
  log("·", "notify", `BLOCKED — all notifications disabled (master mute), priority=${priority}`, client);
@@ -437,11 +437,12 @@ async function sendNotification(message, priority, client, buttons, topic) {
437
437
  enableTeams: able.teams,
438
438
  senders: measuredSends({
439
439
  desktop: async () => {
440
+ const text = forChannel(message, "desktop", lead);
440
441
  if (cfg.desktop?.tts) {
441
442
  const voice = cfg.desktop?.ttsVoice ?? "en-US-AndrewMultilingualNeural";
442
- speakText(message, voice).catch((err) => log("→", "tts", `ERROR: ${err instanceof Error ? err.message : String(err)}`, client));
443
+ speakText(text, voice).catch((err) => log("→", "tts", `ERROR: ${err instanceof Error ? err.message : String(err)}`, client));
443
444
  }
444
- await showBanner(CONFIG_DIR, "Claude Notify", message);
445
+ await showBanner(CONFIG_DIR, "Claude Notify", text);
445
446
  },
446
447
  telegram: async () => {
447
448
  const errors = [];
@@ -449,7 +450,7 @@ async function sendNotification(message, priority, client, buttons, topic) {
449
450
  let unformatted = 0;
450
451
  const mode = telegramParseMode(cfg);
451
452
  for (const chatId of cfg.telegram.chatIds) {
452
- const body = { chat_id: chatId, text: message };
453
+ const body = { chat_id: chatId, text: forChannel(message, "telegram", lead) };
453
454
  // NULL-OK: field buttons is OPTIONAL and therefore it is ok to check for NULL
454
455
  if (buttons !== undefined)
455
456
  body.reply_markup = buttons;
@@ -489,8 +490,8 @@ async function sendNotification(message, priority, client, buttons, topic) {
489
490
  throw new Error(errors.join("; "));
490
491
  return unformatted ? `went out UNFORMATTED to ${unformatted} chat(s): Telegram refused the formatting (can't parse entities), so the message was re-sent once as plain text` : undefined;
491
492
  },
492
- sms: () => smsEveryNumber(cfg, message),
493
- ntfy: async (_text, prio) => { await ntfyPublish(cfg, message, prio); },
493
+ sms: () => smsEveryNumber(cfg, forChannel(message, "sms", lead)),
494
+ ntfy: async (_text, prio) => { await ntfyPublish(cfg, forChannel(message, "ntfy", lead), prio); },
494
495
  discord: async (_text, prio) => {
495
496
  const colorMap = { low: 0x6b7280, normal: 0x7c6dfa, high: 0xef4444 };
496
497
  const r = await fetch(cfg.discord.webhookUrl, {
@@ -500,7 +501,7 @@ async function sendNotification(message, priority, client, buttons, topic) {
500
501
  username: cfg.discord.username ?? "Claude Notify",
501
502
  embeds: [{
502
503
  title: "Claude Notify",
503
- description: message,
504
+ description: forChannel(message, "discord", lead),
504
505
  color: colorMap[prio] ?? colorMap.normal,
505
506
  timestamp: new Date().toISOString(),
506
507
  }],
@@ -513,7 +514,7 @@ async function sendNotification(message, priority, client, buttons, topic) {
513
514
  const emojiMap = { low: "ℹ️", normal: "🔔", high: "🚨" };
514
515
  const emoji = emojiMap[prio] ?? emojiMap.normal;
515
516
  const blocks = [
516
- { type: "section", text: { type: "mrkdwn", text: `${emoji} *Claude Notify*\n${message}` } },
517
+ { type: "section", text: { type: "mrkdwn", text: `${emoji} *Claude Notify*\n${forChannel(message, "slack", lead)}` } },
517
518
  { type: "context", elements: [{ type: "mrkdwn", text: `Priority: ${prio}` }] },
518
519
  ];
519
520
  // Bot token + selected channels → one chat.postMessage per channel
@@ -560,7 +561,7 @@ async function sendNotification(message, priority, client, buttons, topic) {
560
561
  version: "1.2",
561
562
  body: [
562
563
  { type: "TextBlock", size: "Medium", weight: "Bolder", text: "Claude Notify", color: colorMap[prio] ?? "Default" },
563
- { type: "TextBlock", text: message, wrap: true },
564
+ { type: "TextBlock", text: forChannel(message, "teams", lead), wrap: true },
564
565
  { type: "TextBlock", text: `Priority: ${prio}`, isSubtle: true, size: "Small" },
565
566
  ],
566
567
  },
@@ -583,7 +584,7 @@ async function sendNotification(message, priority, client, buttons, topic) {
583
584
  };
584
585
  }
585
586
  for (const delivered of result.delivered) {
586
- log("→", delivered, message, client);
587
+ log("→", delivered, forChannel(message, delivered, lead), client);
587
588
  }
588
589
  for (const err of result.errors) {
589
590
  log("→", "notify", `ERROR: ${err}`, client);
@@ -1170,11 +1171,26 @@ function logTelegramError(msg) {
1170
1171
  async function telegramSendTo(token, chatId, text, replyTo, thread) {
1171
1172
  if (loadConfig().telegram?.enabled !== true)
1172
1173
  throw new Error("Telegram is switched off in BN settings, so nothing is sent to it");
1173
- const { response: r, unformatted } = 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));
1174
+ let posted;
1175
+ try {
1176
+ 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));
1177
+ }
1178
+ catch (err) {
1179
+ if (!(err instanceof TypeError) && !(err instanceof DOMException))
1180
+ throw err;
1181
+ // 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.
1182
+ if (err.name === "TimeoutError")
1183
+ throw new TelegramSendUnconfirmed("sendMessage", 15_000);
1184
+ throw new TelegramUnreachable(`Telegram could not be reached for sendMessage: ${err.message}`);
1185
+ }
1186
+ const { response: r, unformatted } = posted;
1174
1187
  if (!r.ok) {
1175
1188
  const refused = await telegramSendErrorHint(r);
1176
1189
  recordReach("telegram", false, "a reply in his chat", refused);
1177
- throw new Error(refused);
1190
+ // 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.
1191
+ if (DOCUMENTED_REFUSALS.has(r.status))
1192
+ throw new TelegramRefused("sendMessage", r.status, refused);
1193
+ throw new TelegramUnreachable(`Telegram could not deliver the reply (HTTP ${r.status}): ${refused}`);
1178
1194
  }
1179
1195
  recordReach("telegram", true, "a reply in his chat", "Telegram took the message");
1180
1196
  if (unformatted)
@@ -1394,7 +1410,7 @@ async function takeTelegramUpdate(token, update) {
1394
1410
  if (said.ruled)
1395
1411
  await dropDecisionButtons(token, chat, msg.reply_to_message.message_id);
1396
1412
  if (!masterMuted())
1397
- await telegramSendTo(token, chat, `${said.ruled ? "✅ RULED" : "❌ NOT RULED"}\n${said.report}`, msg.message_id, thread);
1413
+ await sendRuling(token, chat, said, msg.message_id, thread);
1398
1414
  // 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
1415
  if (said.ruled || !("words" in pick))
1400
1416
  return;
@@ -1505,6 +1521,21 @@ async function tgCall(token, method, body) {
1505
1521
  log("→", `telegram:${method}`, `NOT DONE: ${err.message}`);
1506
1522
  }
1507
1523
  }
1524
+ /**
1525
+ * 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
1526
+ * 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.
1527
+ */
1528
+ async function sendRuling(token, chatId, said, replyTo, thread) {
1529
+ try {
1530
+ await telegramSendTo(token, chatId, `${said.ruled ? "✅ RULED" : "❌ NOT RULED"}\n${said.report}`, replyTo, thread);
1531
+ }
1532
+ catch (err) {
1533
+ if (!(err instanceof TelegramRefused || err instanceof TelegramUnreachable || err instanceof TelegramUnknown || err instanceof TelegramSendUnconfirmed))
1534
+ throw err;
1535
+ // 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.
1536
+ log("→", "telegram:sendMessage", `NOT DONE: the ${said.ruled ? "ruling" : "refusal"} of his pick reached the board but not him: ${err.message}`);
1537
+ }
1538
+ }
1508
1539
  /** Takes the option buttons off a decision message once it is ruled, so a second tap cannot land on an answered decision. */
1509
1540
  async function dropDecisionButtons(token, chatId, messageId) {
1510
1541
  await tgCall(token, "editMessageReplyMarkup", { chat_id: chatId, message_id: messageId, reply_markup: { inline_keyboard: [] } });
@@ -1541,7 +1572,7 @@ async function takeDecisionTap(token, chatIds, tap) {
1541
1572
  await dropDecisionButtons(token, chatId, tap.message.message_id);
1542
1573
  if (masterMuted())
1543
1574
  return;
1544
- await telegramSendTo(token, chatId, `${said.ruled ? "✅ RULED" : "❌ NOT RULED"}\n${said.report}`, tap.message.message_id, tap.message.is_topic_message === true ? tap.message.message_thread_id : undefined);
1575
+ await sendRuling(token, chatId, said, tap.message.message_id, tap.message.is_topic_message === true ? tap.message.message_thread_id : undefined);
1545
1576
  }
1546
1577
  /**
1547
1578
  * The bot's long poll, in the daemon only. A network failure, a 5xx and a 429 back off and poll again; a documented
@@ -3174,7 +3205,7 @@ function drainInboxFor(tag) {
3174
3205
  // One message, delivered as however many parts the 500-character limit needs.
3175
3206
  // Every part is sent and every part's outcome is returned — a part that reached
3176
3207
  // nobody must not be swallowed by the part before it.
3177
- async function sendChunked(message, priority, clientId) {
3208
+ async function sendChunked(message, priority, clientId, lead) {
3178
3209
  const outcomes = [];
3179
3210
  const parts = splitForNotify(message);
3180
3211
  const buttons = decisionButtons(message);
@@ -3183,7 +3214,7 @@ async function sendChunked(message, priority, clientId) {
3183
3214
  // #5063 — the buttons ride on EVERY part, not only the last: splitForNotify puts the decision link on every part too, so a
3184
3215
  // tap on any part's buttons resolves the decision (buttonPick reads the link off the message the button sits on). Attaching
3185
3216
  // them to the last part alone left every earlier part a dead end for both a tap and a reply.
3186
- outcomes.push(await sendNotification(withLead(`[${clientId}]`, chunk), priority, clientId, buttons, topic === undefined ? undefined : { ...topic, ships: topic.ships && i === parts.length - 1 }));
3217
+ outcomes.push(await sendNotification(withLead(`[${clientId}]`, chunk), priority, clientId, buttons, topic === undefined ? undefined : { ...topic, ships: topic.ships && i === parts.length - 1 }, lead));
3187
3218
  }
3188
3219
  return outcomes;
3189
3220
  }
@@ -3395,11 +3426,16 @@ export function createMcpServer(clientId, sessionTag) {
3395
3426
  .describe(`Channels per priority, each only when enabled: ${describePriorityRouting()} — high also bypasses activity gating (it never overrides DND)`),
3396
3427
  answers: z.string().max(2000).optional()
3397
3428
  .describe("The user's own words, verbatim, of the request this notification answers. Required unless the message is a board decision carrying its decision link."),
3398
- }, async ({ message, priority, answers }) => {
3429
+ per_channel_line: z.object({
3430
+ from: z.string().min(1),
3431
+ per: z.record(z.string(), z.string()),
3432
+ }).optional()
3433
+ .describe("One line of `message` that must read differently on a channel where it is not true, with the wording that channel reads instead: `from` is the line as sent on the channels not named; `per` maps a channel (telegram, slack, desktop, …) to the line it reads. Every channel the caller does not name, and every message that sends none, is delivered whole. A board decision uses it so the tap-or-reply invitation reaches only the channel whose reply rules it."),
3434
+ }, async ({ message, priority, answers, per_channel_line }) => {
3399
3435
  const unasked = refusedUnasked(message, answers, sessionTag, clientId);
3400
3436
  if (unasked !== undefined)
3401
3437
  return unasked;
3402
- const outcomes = await sendChunked(message, priority, clientId);
3438
+ const outcomes = await sendChunked(message, priority, clientId, per_channel_line);
3403
3439
  const notDelivered = outcomes.some((o) => o.outcome !== "delivered");
3404
3440
  const held = notDelivered && outcomes.every((o) => o.outcome === "blocked");
3405
3441
  const delivered = [...new Set(outcomes.filter((o) => o.outcome === "delivered").flatMap((o) => o.delivered))];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.504",
3
+ "version": "1.3.506",
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",