omni-notify-mcp 1.3.469 → 1.3.470

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.
@@ -280,7 +280,7 @@ export class AgentGateway {
280
280
  // NULL-OK: field open is OPTIONAL and therefore it is ok to check for NULL
281
281
  const slack = origin.slack !== undefined && open?.slack !== undefined ? { ...origin.slack, readTs: open.slack.readTs } : origin.slack;
282
282
  const turn = {};
283
- const [creation] = await Promise.allSettled([createdIn(project, undefined, () => key, (on) => {
283
+ const [creation] = await Promise.allSettled([createdIn(project, act.kind === "say" ? act.provider : undefined, () => key, (on) => {
284
284
  const created = startConversation({ platform, chat: key, slack, email: origin.email, ...on, forkOf, text: act.text, receivedMs: monotonicMs() - arrived });
285
285
  turn.answered = this.awaitTurn(created.id, 1, relayOf(created.id, 1, false));
286
286
  turn.id = created.id;
@@ -1,59 +1,59 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { spawn } = require("child_process");
6
-
7
- const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
8
-
9
- function deployArgs({ deploy, domain, preview, projectRoot, home, doorsDir }) {
10
- return [
11
- deploy,
12
- "--domain", domain,
13
- ...(preview ? ["--new-install", "--dry-run"] : ["--new-install"]),
14
- // NULL-OK: field projectRoot is OPTIONAL and therefore it is ok to check for NULL
15
- "--project-root", projectRoot ?? home,
16
- "--security-dir", path.join(home, ".notify-mcp", "gateway", "security"),
17
- "--notify-dir", doorsDir,
18
- ];
19
- }
20
-
21
- function runDeploy({ node, args, cwd, env, onOutput }) {
22
- return new Promise((resolve, reject) => {
23
- const child = spawn(node, args, { windowsHide: true, cwd, env });
24
- child.stdout.on("data", (chunk) => onOutput(String(chunk)));
25
- child.stderr.on("data", (chunk) => onOutput(String(chunk)));
26
- child.on("error", reject);
27
- child.on("exit", (exitCode, signal) => resolve({ exitCode, signal }));
28
- });
29
- }
30
-
31
- const PROMPT_ON_THE_PC = "The elevated helper is not running as this build's copy, so installing would raise one Windows administrator prompt on the PC itself, which only a person at the PC can accept. Run Set up public access from VS Code on the PC (or accept the prompt there); with the helper running, this button installs without a prompt. Preview needs no administrator.";
32
-
33
- function writeRecord(file, record) {
34
- const staged = `${file}.${process.pid}.tmp`;
35
- fs.writeFileSync(staged, JSON.stringify(record, null, 2));
36
- try {
37
- fs.renameSync(staged, file);
38
- } catch (err) {
39
- fs.rmSync(staged, { force: true });
40
- throw err;
41
- }
42
- }
43
-
44
- async function runRecorded(recordFile, recordText) {
45
- const record = { ...JSON.parse(recordText), pid: process.pid };
46
- const log = recordFile.replace(/\.json$/, ".log");
47
- const write = (fields) => writeRecord(recordFile, { ...record, ...fields });
48
- try {
49
- const ended = await runDeploy({ node: process.execPath, args: record.args, cwd: record.cwd, onOutput: (text) => fs.appendFileSync(log, text) });
50
- write({ endedAt: new Date().toISOString(), ...ended });
51
- } catch (err) {
52
- // OWNER: the detached run's trigger root — a deploy that could not be launched is written into the run's record, which the page and the MCP tool read back.
53
- write({ endedAt: new Date().toISOString(), exitCode: null, failure: `the deploy could not be launched: ${err.message}` });
54
- }
55
- }
56
-
57
- if (require.main === module) void runRecorded(process.argv[2], process.argv[3]);
58
-
59
- module.exports = { DOMAIN, deployArgs, runDeploy, runRecorded, writeRecord, PROMPT_ON_THE_PC };
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawn } = require("child_process");
6
+
7
+ const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
8
+
9
+ function deployArgs({ deploy, domain, preview, projectRoot, home, doorsDir }) {
10
+ return [
11
+ deploy,
12
+ "--domain", domain,
13
+ ...(preview ? ["--new-install", "--dry-run"] : ["--new-install"]),
14
+ // NULL-OK: field projectRoot is OPTIONAL and therefore it is ok to check for NULL
15
+ "--project-root", projectRoot ?? home,
16
+ "--security-dir", path.join(home, ".notify-mcp", "gateway", "security"),
17
+ "--notify-dir", doorsDir,
18
+ ];
19
+ }
20
+
21
+ function runDeploy({ node, args, cwd, env, onOutput }) {
22
+ return new Promise((resolve, reject) => {
23
+ const child = spawn(node, args, { windowsHide: true, cwd, env });
24
+ child.stdout.on("data", (chunk) => onOutput(String(chunk)));
25
+ child.stderr.on("data", (chunk) => onOutput(String(chunk)));
26
+ child.on("error", reject);
27
+ child.on("exit", (exitCode, signal) => resolve({ exitCode, signal }));
28
+ });
29
+ }
30
+
31
+ const PROMPT_ON_THE_PC = "The elevated helper is not running as this build's copy, so installing would raise one Windows administrator prompt on the PC itself, which only a person at the PC can accept. Run Set up public access from VS Code on the PC (or accept the prompt there); with the helper running, this button installs without a prompt. Preview needs no administrator.";
32
+
33
+ function writeRecord(file, record) {
34
+ const staged = `${file}.${process.pid}.tmp`;
35
+ fs.writeFileSync(staged, JSON.stringify(record, null, 2));
36
+ try {
37
+ fs.renameSync(staged, file);
38
+ } catch (err) {
39
+ fs.rmSync(staged, { force: true });
40
+ throw err;
41
+ }
42
+ }
43
+
44
+ async function runRecorded(recordFile, recordText) {
45
+ const record = { ...JSON.parse(recordText), pid: process.pid };
46
+ const log = recordFile.replace(/\.json$/, ".log");
47
+ const write = (fields) => writeRecord(recordFile, { ...record, ...fields });
48
+ try {
49
+ const ended = await runDeploy({ node: process.execPath, args: record.args, cwd: record.cwd, onOutput: (text) => fs.appendFileSync(log, text) });
50
+ write({ endedAt: new Date().toISOString(), ...ended });
51
+ } catch (err) {
52
+ // OWNER: the detached run's trigger root — a deploy that could not be launched is written into the run's record, which the page and the MCP tool read back.
53
+ write({ endedAt: new Date().toISOString(), exitCode: null, failure: `the deploy could not be launched: ${err.message}` });
54
+ }
55
+ }
56
+
57
+ if (require.main === module) void runRecorded(process.argv[2], process.argv[3]);
58
+
59
+ module.exports = { DOMAIN, deployArgs, runDeploy, runRecorded, writeRecord, PROMPT_ON_THE_PC };
package/dist/notify.js CHANGED
@@ -1196,6 +1196,12 @@ function bindTelegramChat(chat) {
1196
1196
  throw new Error(`the binding to chat ${chat} did not hold in ${CONFIG_PATH}`);
1197
1197
  log("·", "telegram", `this bot is bound to chat ${chat}: every message from it reaches the BN conversation, every other sender is refused`);
1198
1198
  }
1199
+ const TELEGRAM_PROVIDER = "opencode";
1200
+ function setTelegramProvider(name) {
1201
+ if (name === undefined)
1202
+ return `🤖 Provider for new conversations: ${TELEGRAM_PROVIDER} (fixed)`;
1203
+ return `❌ Telegram always runs on ${TELEGRAM_PROVIDER}; /provider cannot change it.`;
1204
+ }
1199
1205
  const storyTopics = new StoryTopics(join(CONFIG_DIR, "story-topics.json"));
1200
1206
  const topicCalls = (token) => ({ call: (method, body) => telegramCall(tgApi(token, method), method, body) });
1201
1207
  function topicOfMessage(text) {
@@ -1230,7 +1236,8 @@ function openAsksContext() {
1230
1236
  /** One said thing of the bound chat goes to its one conversation, its turn streamed back into the chat. */
1231
1237
  function toTelegramConversation(token, chat, act, thread) {
1232
1238
  // #4586 — a topic is its own conversation (the story's); the plain chat keeps its one.
1233
- toOneChat(thread === undefined ? `telegram:${chat}` : `telegram:${chat}:${thread}`, "telegram", act, telegramMessenger(token, chat, thread));
1239
+ const routed = act.kind === "say" ? { ...act, provider: TELEGRAM_PROVIDER } : act;
1240
+ toOneChat(thread === undefined ? `telegram:${chat}` : `telegram:${chat}:${thread}`, "telegram", routed, telegramMessenger(token, chat, thread));
1234
1241
  }
1235
1242
  /** One said thing of one of Meni's one chats — Telegram, or his Slack direct message — goes to its one conversation, its turn streamed back into that chat. */
1236
1243
  function toOneChat(key, platform, act, messenger) {
@@ -1295,6 +1302,11 @@ async function takeTelegramUpdate(token, update) {
1295
1302
  await messenger.send(TELEGRAM_WELCOME);
1296
1303
  return;
1297
1304
  }
1305
+ const providerCmd = text.trim().match(/^\/provider(?:@\w+)?(?:\s+(\S+))?$/i);
1306
+ if (providerCmd !== null) {
1307
+ await messenger.send(setTelegramProvider(providerCmd[1]));
1308
+ return;
1309
+ }
1298
1310
  // #4494 — a digit he replied to a board decision message with is that decision's pick, and #4123 other words its answer, whatever else waits on him.
1299
1311
  const pick = saved === undefined ? decisionReply(text, msg.reply_to_message?.text) : undefined;
1300
1312
  // NULL-OK: field pick is OPTIONAL and therefore it is ok to check for NULL