omni-notify-mcp 1.3.469 โ 1.3.471
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 +13 -6
- package/dist/gatewayInstall.cjs +59 -59
- package/dist/notify.js +13 -1
- package/dist/shared/agentSession.js +439 -327
- package/dist/shared/webhost/originHandover.js +18 -7
- package/dist/shared/webhost/workspaceList.js +51 -14
- package/package.json +1 -1
- package/scripts/shared/ownerGuard.cs +665 -0
- package/scripts/shared/ownerGuard.ps1 +31 -0
package/dist/agentGateway.js
CHANGED
|
@@ -90,12 +90,12 @@ const ONE = {
|
|
|
90
90
|
// NULL-OK: field main is OPTIONAL and therefore it is ok to check for NULL
|
|
91
91
|
return main !== undefined && busy(main) ? main.sessionId : undefined;
|
|
92
92
|
},
|
|
93
|
-
async renew(key, platform, end) {
|
|
93
|
+
async renew(key, platform, end, provider) {
|
|
94
94
|
for (const c of ONE.allOf(key)) {
|
|
95
95
|
end(c.id);
|
|
96
96
|
archiveConversation(c.id);
|
|
97
97
|
}
|
|
98
|
-
const { notice } = await createdIn(rootFolder(),
|
|
98
|
+
const { notice } = await createdIn(rootFolder(), provider, () => key, (on) => openConversation({ platform, chat: key, ...on }));
|
|
99
99
|
// NULL-OK: field notice is OPTIONAL and therefore it is ok to check for NULL
|
|
100
100
|
return `๐ Fresh conversation โ your next message starts it.${notice === undefined ? "" : `\n${notice.text}`}`;
|
|
101
101
|
},
|
|
@@ -259,11 +259,18 @@ export class AgentGateway {
|
|
|
259
259
|
return reply(carriage.stopped(stopped, carriage.allOf(key).filter((c) => !stopped.includes(c)).length));
|
|
260
260
|
}
|
|
261
261
|
if (act.kind === "new")
|
|
262
|
-
return reply(await carriage.renew(key, platform, (id) => this.end(id)));
|
|
262
|
+
return reply(await carriage.renew(key, platform, (id) => this.end(id), act.provider));
|
|
263
263
|
if (act.text === "")
|
|
264
264
|
return reply("Send `! <your message>` to talk to the agent.");
|
|
265
|
-
const
|
|
266
|
-
|
|
265
|
+
const replaced = open !== undefined && act.provider !== undefined && open.provider !== act.provider;
|
|
266
|
+
if (replaced) {
|
|
267
|
+
for (const c of carriage.allOf(key)) {
|
|
268
|
+
this.end(c.id);
|
|
269
|
+
archiveConversation(c.id);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const target = replaced ? undefined : carriage.routeOf(key, act.text);
|
|
273
|
+
const forkOf = replaced ? undefined : carriage.forkOf(key);
|
|
267
274
|
// NULL-OK: field target is OPTIONAL and therefore it is ok to check for NULL
|
|
268
275
|
if (target === undefined) {
|
|
269
276
|
let project;
|
|
@@ -280,7 +287,7 @@ export class AgentGateway {
|
|
|
280
287
|
// NULL-OK: field open is OPTIONAL and therefore it is ok to check for NULL
|
|
281
288
|
const slack = origin.slack !== undefined && open?.slack !== undefined ? { ...origin.slack, readTs: open.slack.readTs } : origin.slack;
|
|
282
289
|
const turn = {};
|
|
283
|
-
const [creation] = await Promise.allSettled([createdIn(project, undefined, () => key, (on) => {
|
|
290
|
+
const [creation] = await Promise.allSettled([createdIn(project, act.kind === "say" ? act.provider : undefined, () => key, (on) => {
|
|
284
291
|
const created = startConversation({ platform, chat: key, slack, email: origin.email, ...on, forkOf, text: act.text, receivedMs: monotonicMs() - arrived });
|
|
285
292
|
turn.answered = this.awaitTurn(created.id, 1, relayOf(created.id, 1, false));
|
|
286
293
|
turn.id = created.id;
|
package/dist/gatewayInstall.cjs
CHANGED
|
@@ -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
|
-
|
|
1239
|
+
const routed = act.kind === "stop" ? act : { ...act, provider: TELEGRAM_PROVIDER };
|
|
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
|