omni-notify-mcp 1.3.325 → 1.3.327
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/daemon.js +39 -20
- package/dist/gateway/mcpDoor.js +62 -4
- package/dist/gateway/notifyDoor.js +1 -1
- package/dist/gateway/publicAccess.js +1 -1
- package/dist/gateway/terminalDoor.js +25 -14
- package/dist/notify.js +12 -5
- package/dist/shared/webhost/bullseyeWebHost.js +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -13,33 +13,48 @@ import { spawn } from "child_process";
|
|
|
13
13
|
import { existsSync, readFileSync, renameSync, writeFileSync, mkdirSync } from "fs";
|
|
14
14
|
import { join } from "path";
|
|
15
15
|
import { fileURLToPath } from "url";
|
|
16
|
-
import {
|
|
16
|
+
import { DAEMON_BEAT_PATH, CONFIG_DIR, PACKAGE_VERSION, startNotifyServer, yieldGateway } from "./notify.js";
|
|
17
17
|
import { startNotifyDoor } from "./gateway/notifyDoor.js";
|
|
18
18
|
import { announceTakeover, inThisBoot } from "./shared/webhost/originHandover.js";
|
|
19
19
|
import { TunnelRunner } from "./gateway/tunnel.js";
|
|
20
20
|
const HEARTBEAT_MS = 10_000;
|
|
21
|
+
/** the beat's name in the release before: a box that has not run this release's activation still has that release's lifecycle staged, which reads only this name, so for one release the beat is written under both. */
|
|
22
|
+
const OLD_BEAT_PATH = join(CONFIG_DIR, "always-on.json");
|
|
21
23
|
function beat(pid = process.pid) {
|
|
22
24
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const text = JSON.stringify({ pid, at: Date.now(), version: PACKAGE_VERSION });
|
|
26
|
+
for (const file of [DAEMON_BEAT_PATH, OLD_BEAT_PATH]) {
|
|
27
|
+
const staged = `${file}.${process.pid}.tmp`;
|
|
28
|
+
writeFileSync(staged, text);
|
|
29
|
+
renameSync(staged, file);
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
|
-
/**
|
|
32
|
+
/** The boot supervisor's login entry: launchd's label and systemd's unit. the release before registered it under the old names, which a daemon it started is told by for one release. */
|
|
33
|
+
const ENTRY_LABELS = ["com.bullseye.BullseyeMcpOrigins", "com.bullseye.BullseyeNotifyAlwaysOn"];
|
|
34
|
+
const ENTRY_UNITS = ["bullseye-mcp-origins.service", "bullseye-notify-always-on.service"];
|
|
35
|
+
/** BN's lifecycle in the config dir, then its name in the release before, which that release's activation staged, read for one release. */
|
|
36
|
+
const SUPERVISE_LOOPS = [join(CONFIG_DIR, "bnDaemon.js"), join(CONFIG_DIR, "alwaysOn.js")];
|
|
37
|
+
/** The Stop the panel writes, then its name in the release before, read for one release. */
|
|
38
|
+
const STOP_FILES = [join(CONFIG_DIR, "daemon-stop.json"), join(CONFIG_DIR, "always-on-desired.json")];
|
|
39
|
+
/** Run by the boot supervisor (BullseyeShared workspace-mcp/originSupervisor.js, under the login starter every Bullseye extension installs), or on Windows by the login session's supervise loop in bnDaemon.js, each of which starts it again when it exits. On Windows that supervisor is this process's IPC parent: the channel is open only while it lives, so a dead supervisor, or a reused pid, never reads as supervised. */
|
|
28
40
|
function supervised() {
|
|
29
41
|
if (process.platform === "win32")
|
|
30
42
|
return process.connected === true;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
if (process.platform === "darwin")
|
|
44
|
+
return ENTRY_LABELS.includes(process.env.XPC_SERVICE_NAME ?? "");
|
|
45
|
+
if (process.platform !== "linux")
|
|
46
|
+
return false;
|
|
47
|
+
const cgroup = readFileSync("/proc/self/cgroup", "utf8");
|
|
48
|
+
return ENTRY_UNITS.some((unit) => cgroup.includes(unit));
|
|
34
49
|
}
|
|
35
50
|
/** Who starts the installed build after this unsupervised process exits: on Windows the supervise loop the login entry and the boot task keep in the config dir, which owns every run after this one; elsewhere the same entry, started again. */
|
|
36
51
|
function successor() {
|
|
37
52
|
const self = fileURLToPath(import.meta.url);
|
|
38
53
|
if (process.platform !== "win32")
|
|
39
54
|
return spawn(process.execPath, [...process.execArgv, self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
40
|
-
const loop =
|
|
41
|
-
if (
|
|
42
|
-
throw new Error(`the supervise loop is not in the config dir at ${
|
|
55
|
+
const loop = SUPERVISE_LOOPS.find((file) => existsSync(file));
|
|
56
|
+
if (loop === undefined)
|
|
57
|
+
throw new Error(`the supervise loop is not in the config dir at ${SUPERVISE_LOOPS[0]} — the login entry and the boot task copy it there, so nothing can own the next run`);
|
|
43
58
|
return spawn(process.execPath, [loop, "supervise", self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
44
59
|
}
|
|
45
60
|
/** The installed build has replaced this one on disk: a supervised process only exits and its owner starts that build; an unsupervised one starts its successor and names it in the heartbeat before it exits, so no other owner starts a second build meanwhile, and on Windows the supervise loop reads that beat as the claim on its first run. */
|
|
@@ -53,22 +68,26 @@ function replaceWithInstalledBuild() {
|
|
|
53
68
|
}
|
|
54
69
|
process.exit(0);
|
|
55
70
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (!existsSync(desired))
|
|
60
|
-
return false;
|
|
61
|
-
let pressed;
|
|
71
|
+
function pressedIn(file) {
|
|
72
|
+
if (!existsSync(file))
|
|
73
|
+
return undefined;
|
|
62
74
|
try {
|
|
63
|
-
|
|
75
|
+
return { ...JSON.parse(readFileSync(file, "utf8")), file };
|
|
64
76
|
}
|
|
65
77
|
catch (err) {
|
|
66
|
-
throw new Error(`${
|
|
78
|
+
throw new Error(`${file} is not readable JSON, so whether a Stop was pressed on this machine cannot be known — ${err.message}`);
|
|
67
79
|
}
|
|
80
|
+
}
|
|
81
|
+
/** The Stop the panel pressed is this machine's own setting until a Start or the next boot (#3849 Q782), so a process a login entry started after it in this boot reads the same file and starts nothing. Absent, the machine has never been stopped and starts as it always has. */
|
|
82
|
+
function stoppedByHand() {
|
|
83
|
+
const [now, old] = STOP_FILES.map(pressedIn);
|
|
84
|
+
const pressed = old !== undefined && (now === undefined || (old.at ?? -Infinity) > (now.at ?? -Infinity)) ? old : now;
|
|
85
|
+
if (pressed === undefined)
|
|
86
|
+
return false;
|
|
68
87
|
if (pressed.desired !== "stopped")
|
|
69
88
|
return false;
|
|
70
89
|
if (typeof pressed.at !== "number")
|
|
71
|
-
throw new Error(`${
|
|
90
|
+
throw new Error(`${pressed.file} names a Stop with no time it was pressed, so whether it was pressed in this boot cannot be known`);
|
|
72
91
|
return inThisBoot(pressed.at);
|
|
73
92
|
}
|
|
74
93
|
if (stoppedByHand()) {
|
package/dist/gateway/mcpDoor.js
CHANGED
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
* whether or not the client passes the id back; `new: true` starts a fresh one.
|
|
13
13
|
*/
|
|
14
14
|
import { AsyncLocalStorage } from "async_hooks";
|
|
15
|
+
import { spawn } from "child_process";
|
|
15
16
|
import { createHash, randomUUID } from "crypto";
|
|
17
|
+
import { existsSync } from "fs";
|
|
18
|
+
import { createRequire } from "module";
|
|
19
|
+
import { join } from "path";
|
|
16
20
|
import { performance } from "perf_hooks";
|
|
17
21
|
import { z } from "zod";
|
|
18
22
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -23,14 +27,18 @@ import { PROVIDER_NAMES } from "./providers.js";
|
|
|
23
27
|
import { iconsFor } from "./iconDoor.js";
|
|
24
28
|
import { grantClient, publicBase } from "./oauthDoor.js";
|
|
25
29
|
import { bearer, personId, sessionSignIn, tokenProves } from "./passkeyDoor.js";
|
|
26
|
-
import { consoleSession, terminalArriving } from "./nativeTerminal.js";
|
|
30
|
+
import { closeNativeTerminal, consoleSession, nativeTerminal, terminalArriving } from "./nativeTerminal.js";
|
|
31
|
+
import { dimensions, openTerminal, terminalListing, validFiles } from "./terminalDoor.js";
|
|
32
|
+
import { conversationSwitchRead, panelState, saveConversationSwitch, saveSetting } from "./panel.js";
|
|
33
|
+
import { wizard } from "./publicAccess.js";
|
|
27
34
|
import { EVENTS_CAPABILITY, serveEvents } from "./mcpEvents.js";
|
|
28
|
-
import { PACKAGE_VERSION, readGatewaySettings } from "../notify.js";
|
|
35
|
+
import { CONFIG_DIR, PACKAGE_VERSION, readGatewaySettings } from "../notify.js";
|
|
29
36
|
const answer = (value) => ({ content: [{ type: "text", text: JSON.stringify(value) }] });
|
|
30
37
|
/** A refused act is the tool's own error result, never a protocol failure, so the calling agent can read why. */
|
|
31
|
-
async function act(run) {
|
|
38
|
+
async function act(run, switchGated = true) {
|
|
32
39
|
try {
|
|
33
|
-
|
|
40
|
+
if (switchGated)
|
|
41
|
+
requireConversationEnabled();
|
|
34
42
|
return answer(await run());
|
|
35
43
|
}
|
|
36
44
|
catch (err) {
|
|
@@ -40,6 +48,27 @@ async function act(run) {
|
|
|
40
48
|
throw err;
|
|
41
49
|
}
|
|
42
50
|
}
|
|
51
|
+
/** A panel route that works with the agent-conversation switch Off — the Settings and Public access pages are what turn it On — so it is answered without the switch check `act` makes. */
|
|
52
|
+
const panelAct = (run) => act(run, false);
|
|
53
|
+
/** BN's lifecycle as the extension stages it beside the boot supervisor (bnDaemon.js LIFECYCLE_FILES): the one code the Uber dashboard row and the panel run. */
|
|
54
|
+
function stagedLifecycle() {
|
|
55
|
+
const file = join(CONFIG_DIR, "bnLifecycle.js");
|
|
56
|
+
if (!existsSync(file))
|
|
57
|
+
throw new GatewayError(503, `BN's lifecycle is not staged at ${file} — the extension stages it at activation, so a build that never activated has none`);
|
|
58
|
+
return file;
|
|
59
|
+
}
|
|
60
|
+
/** The press itself, run in a process of its own: the row's own act, whose outcome is read afterwards with act=state. */
|
|
61
|
+
const LIFECYCLE_ACTOR = "require(process.argv[1]).row(process.argv[2]).act(process.argv[3]).then(() => process.exit(0), () => process.exit(1))";
|
|
62
|
+
/** A launcher that starts the actor detached and exits at once, so no live parent links the actor to this daemon: the Stop inside a Restart ends this daemon's whole process tree, and an actor still in it would die before it started BN again. */
|
|
63
|
+
const LIFECYCLE_LAUNCHER = `require("child_process").spawn(process.execPath, ["-e", ${JSON.stringify(LIFECYCLE_ACTOR)}, ...process.argv.slice(1)], { detached: true, stdio: "ignore", windowsHide: true }).unref()`;
|
|
64
|
+
/** Start, Stop and Restart end or replace the process answering this very call, so they run in a process that outlives it; the outcome is read afterwards with act=state. */
|
|
65
|
+
function pressLifecycle(file, press) {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
const launcher = spawn(process.execPath, ["-e", LIFECYCLE_LAUNCHER, file, process.argv[1], press], { stdio: "ignore", windowsHide: true });
|
|
68
|
+
launcher.once("error", (err) => reject(new GatewayError(500, `the ${press} could not be launched — ${err.message}`)));
|
|
69
|
+
launcher.once("exit", (code) => (code === 0 ? resolve({ pressed: press, running: true, next: "read the outcome with bn_lifecycle act=state" }) : reject(new GatewayError(500, `the ${press} could not be launched — its launcher exited ${code}`))));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
43
72
|
/** #3849 — the project names a connection's tools offer, read from the workspace list when the connection is built; a list that cannot be read is offered as its reason, and every call naming a project is then refused with it. */
|
|
44
73
|
function projectOffer() {
|
|
45
74
|
try {
|
|
@@ -272,6 +301,35 @@ function buildServer(caller, base, offer) {
|
|
|
272
301
|
server.tool("agent_stop", "Stop a conversation and free its agent; a later message resumes it.", { id: z.string().min(1) }, ({ id }) => act(() => stopConversation(id)));
|
|
273
302
|
server.tool("agent_archive", "Archive a conversation: it is stopped and moved off the default list to the Archived list with its transcript kept. agent_list archived=true shows it; a message to it (agent_send or agent_prompt) brings it back and resumes it.", { id: z.string().min(1), restore: z.boolean().default(false).describe("true moves an archived conversation back to the default list instead") }, ({ id, restore }) => act(() => (restore ? unarchiveConversation(id) : archiveConversation(id))));
|
|
274
303
|
server.tool("agent_delete", "Delete a conversation for good: a running agent is stopped first, then the conversation and its transcript are removed from BN. It cannot be undone — agent_archive keeps the transcript instead.", { id: z.string().min(1) }, ({ id }) => act(() => deleteConversation(id)));
|
|
304
|
+
server.tool("agent_terminals", "The agent CLIs this person has open on this machine (what the CLI page lists) with the CLIs New Agent can open and whether each takes a model; id names one terminal and answers only its facts. A read — it starts nothing.", { id: z.string().min(1).optional().describe("One terminal's conversation id; without it every open terminal is listed beside the CLIs New Agent offers") }, ({ id }) => act(async () => (id === undefined ? terminalListing(personId()) : nativeTerminal(personId(), id).info())));
|
|
305
|
+
server.tool("agent_terminal_open", `New Agent, as the CLI page's button runs it: opens a conversation's own agent CLI and sizes its screen. Name conversation to open the CLI of one that exists (agent_open or agent_start made it); otherwise name BOTH project (exactly one of ${offer.either}) and provider (one of ${PROVIDER_NAMES.join(", ")}) and a new empty conversation is made on them, with no turn and nothing spent.`, {
|
|
306
|
+
conversation: z.string().min(1).optional().describe("An existing conversation id whose own CLI to open"),
|
|
307
|
+
project: projectField(offer).optional(),
|
|
308
|
+
provider: z.string().min(1).optional(),
|
|
309
|
+
model: z.string().min(1).optional(),
|
|
310
|
+
cols: z.number().int().min(1).max(1000).default(100),
|
|
311
|
+
rows: z.number().int().min(1).max(500).default(30),
|
|
312
|
+
}, (body) => act(() => openTerminal(body)));
|
|
313
|
+
server.tool("agent_terminal_close", "Ends a terminal's CLI process, as the CLI page's Close does; the conversation and its transcript stay and a later message resumes it.", { id: z.string().min(1).describe("The terminal's conversation id") }, ({ id }) => act(() => closeNativeTerminal(personId(), id)));
|
|
314
|
+
server.tool("agent_terminal_input", "Types raw keystrokes into a terminal's live CLI — what the CLI page sends for every key, answering a question the CLI waits on included. data is text; binary=true means data is base64 bytes. agent_send is the message door; this one is the keyboard.", { id: z.string().min(1), data: z.string().min(1), binary: z.boolean().default(false) }, ({ id, data, binary }) => act(async () => { await nativeTerminal(personId(), id).input(data, binary); return { id, sent: true }; }));
|
|
315
|
+
server.tool("agent_terminal_resize", "Resizes a terminal's screen to whole columns 1-1000 and rows 1-500, as the CLI page does when its window changes.", { id: z.string().min(1), cols: z.number().int(), rows: z.number().int() }, ({ id, cols, rows }) => act(async () => { const size = dimensions({ cols, rows }); await nativeTerminal(personId(), id).resize(size.cols, size.rows); return { id, ...size }; }));
|
|
316
|
+
server.tool("agent_terminal_files", "Hands files to a terminal's CLI as the CLI page's drop does: each file is written where the CLI can read it and its path is returned, to be named in a message. Each file is a name and its base64 contents.", { id: z.string().min(1), files: z.array(z.object({ name: z.string().min(1), data: z.string() })).min(1) }, ({ id, files }) => act(async () => {
|
|
317
|
+
if (!validFiles(files))
|
|
318
|
+
throw new GatewayError(400, "File transfer failed: expected file names and base64 contents.");
|
|
319
|
+
return { id, paths: await nativeTerminal(personId(), id).inputFiles(files) };
|
|
320
|
+
}));
|
|
321
|
+
server.tool("settings_get", "Everything the Settings page draws, in one reading: the channel state, every group with its rows' current values and next-step line, and the agent-conversation switch. Secrets are returned as stored, as the page shows them to the person who owns this machine.", {}, () => panelAct(() => panelState()));
|
|
322
|
+
server.tool("settings_save", "Saves one Settings row, as the page does: path is the row's key list from settings_get (for example [\"dnd\",\"enabled\"] or [\"telegram\",\"chatIds\"]) and value is checked against that row's kind (on/off, text, list, whole number, HH:MM, days 0-6) before config.json is written and read back. A path that is not a listed row is refused.", { path: z.array(z.string()).min(1), value: z.unknown() }, ({ path, value }) => panelAct(() => saveSetting(path, value)));
|
|
323
|
+
server.tool("conversation_switch", "The agent-conversation On/Off switch the Settings page holds. With no enabled it reads it; enabled=true or false flips it and reads it back. While Off every agent_* act is refused.", { enabled: z.boolean().optional() }, ({ enabled }) => panelAct(() => (enabled === undefined ? conversationSwitchRead() : saveConversationSwitch(enabled))));
|
|
324
|
+
server.tool("public_access", "The Public access wizard's model and its steps. With no step it reads the model. A step is one click: ready (re-look at the machine), createGatewayToken, saveToken (paste = the tunnel token or the command that carries it), install (cloudflared), restartConnector, turnOff, saveHostname (hostname) or check. It answers the model after the step, whose notes say what the step did.", { step: z.enum(["ready", "createGatewayToken", "saveToken", "install", "restartConnector", "turnOff", "saveHostname", "check"]).optional(), paste: z.string().optional(), hostname: z.string().optional() }, ({ step, paste, hostname }) => panelAct(async () => {
|
|
325
|
+
if (step !== undefined)
|
|
326
|
+
await wizard.handle(step, { paste, hostname });
|
|
327
|
+
return wizard.model();
|
|
328
|
+
}));
|
|
329
|
+
server.tool("bn_lifecycle", "BN's own Start, Stop and Restart as the dashboard row and the panel run them. act=state reads the measured state (running, stopped, unreachable ...) with its words and what a Stop would cut. start, stop and restart are pressed in a process that outlives this call — a Stop or Restart ends the process answering you — and the outcome is read afterwards with act=state; a Stop stays until Start. Restart takes and builds the newest main first, exactly as the row does.", { act: z.enum(["state", "start", "stop", "restart"]) }, ({ act: press }) => panelAct(async () => {
|
|
330
|
+
const file = stagedLifecycle();
|
|
331
|
+
return press === "state" ? createRequire(file)(file).row(process.argv[1]).state() : pressLifecycle(file, press);
|
|
332
|
+
}));
|
|
275
333
|
return server;
|
|
276
334
|
}
|
|
277
335
|
const ready = new Map();
|
|
@@ -25,7 +25,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
25
25
|
import { createMcpServer, sessionIdentity } from "../notify.js";
|
|
26
26
|
import { answerShutdown, healthBody, TAKEOVER_BIND } from "../shared/webhost/originHandover.js";
|
|
27
27
|
/** BN's own port block: 7470 is the gateway, so the chat tools take the next free one. */
|
|
28
|
-
// GATE: the door's port may be moved ONLY under the test gate, so a suite drives a real daemon on a port it owns; without the gate it is 7475 and no environment can redirect it. vscode-extension/
|
|
28
|
+
// GATE: the door's port may be moved ONLY under the test gate, so a suite drives a real daemon on a port it owns; without the gate it is 7475 and no environment can redirect it. vscode-extension/bnDaemon.js probes the same rule.
|
|
29
29
|
export const NOTIFY_DOOR_PORT = process.env.NOTIFY_MCP_TEST_ENDPOINTS === "1" && Number(process.env.NOTIFY_DOOR_PORT) > 0 ? Number(process.env.NOTIFY_DOOR_PORT) : 7475;
|
|
30
30
|
export const NOTIFY_DOOR_PATH = "/mcp";
|
|
31
31
|
const RETRY_MS = 5_000;
|
|
@@ -23,7 +23,7 @@ const ATTEMPTS = 3;
|
|
|
23
23
|
// GATE: a request that has sent nothing for this long is abandoned as a network failure.
|
|
24
24
|
const IDLE_MS = 30_000;
|
|
25
25
|
const REDIRECTS = 5;
|
|
26
|
-
// GATE: a gateway-state beat older than this is presumed dead; it is vscode-extension/
|
|
26
|
+
// GATE: a gateway-state beat older than this is presumed dead; it is vscode-extension/bnDaemon.js's own STALE_MS.
|
|
27
27
|
const STALE_MS = 30_000;
|
|
28
28
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
29
29
|
const HOSTNAME = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
@@ -4,12 +4,16 @@ import { closeNativeTerminal, consoleSession, nativeTerminal, nativeTerminals, t
|
|
|
4
4
|
import { AgentGateway } from "../agentGateway.js";
|
|
5
5
|
import { bearer, bearerAdmitted, personId, sessionExpiresAt } from "./passkeyDoor.js";
|
|
6
6
|
import { PROVIDER_NAMES, providerFor } from "./providers.js";
|
|
7
|
-
function dimensions(body) {
|
|
7
|
+
export function dimensions(body) {
|
|
8
8
|
const cols = Number(body.cols), rows = Number(body.rows);
|
|
9
9
|
if (!Number.isInteger(cols) || cols <= 0 || cols > 1000 || !Number.isInteger(rows) || rows <= 0 || rows > 500)
|
|
10
10
|
throw new GatewayError(400, "Terminal size must be whole columns 1-1000 and rows 1-500.");
|
|
11
11
|
return { cols, rows };
|
|
12
12
|
}
|
|
13
|
+
/** Whether a transfer names files by name and base64 contents, the one check the socket and the agent_terminal_files tool share. */
|
|
14
|
+
export function validFiles(files) {
|
|
15
|
+
return Array.isArray(files) && files.length > 0 && !files.some((file) => !file || typeof file.name !== "string" || typeof file.data !== "string" || (file.data.length % 4 !== 0 || !/^[A-Za-z0-9+/]*={0,2}$/.test(file.data)));
|
|
16
|
+
}
|
|
13
17
|
export function terminalSockets(server, token) {
|
|
14
18
|
const sockets = new WebSocketServer({ noServer: true, handleProtocols: () => "bn-terminal" });
|
|
15
19
|
server.on("upgrade", (req, socket, head) => {
|
|
@@ -70,7 +74,7 @@ export function terminalSockets(server, token) {
|
|
|
70
74
|
else if (body.kind === "input" && typeof body.data === "string")
|
|
71
75
|
await terminal.input(body.data, body.binary === true);
|
|
72
76
|
else if (body.kind === "files") {
|
|
73
|
-
if (!
|
|
77
|
+
if (!validFiles(body.files)) {
|
|
74
78
|
ws.send(JSON.stringify({ files: true, error: "File transfer failed: expected file names and base64 contents." }));
|
|
75
79
|
return;
|
|
76
80
|
}
|
|
@@ -127,6 +131,7 @@ export function terminalSockets(server, token) {
|
|
|
127
131
|
* (#3370): another person's id is refused 404 before any byte is streamed.
|
|
128
132
|
*/
|
|
129
133
|
export async function terminalConsole(req, res, url) {
|
|
134
|
+
requireConversationEnabled();
|
|
130
135
|
const id = url.pathname.split("/").filter((part) => part.length > 0)[2];
|
|
131
136
|
const afterRaw = url.searchParams.get("after");
|
|
132
137
|
const after = afterRaw === null ? undefined : Number(afterRaw);
|
|
@@ -198,24 +203,30 @@ function openedNew(id) {
|
|
|
198
203
|
throw err;
|
|
199
204
|
});
|
|
200
205
|
}
|
|
206
|
+
/** The terminals this person has open with the CLIs New Agent offers: what the page lists and what agent_terminals answers. */
|
|
207
|
+
export async function terminalListing(owner) {
|
|
208
|
+
return { terminals: await nativeTerminals(owner), providers: nativeCatalog() };
|
|
209
|
+
}
|
|
210
|
+
/** New Agent, whole: a conversation made on the CLI and folder the body names (or the one it names), its own CLI opened and sized — what the page's New Agent and agent_terminal_open both run. */
|
|
211
|
+
export async function openTerminal(body) {
|
|
212
|
+
// New Agent makes a conversation exactly as agent_open does — it names BOTH the CLI that runs and the folder it runs
|
|
213
|
+
// in (#3640), neither defaulted — and opens that conversation's own CLI, so a session the browser started and one MCP
|
|
214
|
+
// started are one kind: the same driven CLI, typed into by agent_send and shown here (#3916).
|
|
215
|
+
const terminal = typeof body.conversation === "string" && body.conversation.trim().length > 0 ? await opened(body.conversation.trim()) : await openedNew(newAgent(body));
|
|
216
|
+
const size = dimensions(body);
|
|
217
|
+
await terminal.resize(size.cols, size.rows);
|
|
218
|
+
return terminal.info();
|
|
219
|
+
}
|
|
201
220
|
export async function terminalRoute(req, url, readJson) {
|
|
221
|
+
requireConversationEnabled();
|
|
202
222
|
const owner = personId();
|
|
203
223
|
const parts = url.pathname.split("/").filter(Boolean);
|
|
204
224
|
const method = req.method;
|
|
205
225
|
if (parts.length === 2) {
|
|
206
226
|
if (method === "GET")
|
|
207
|
-
return { status: 200, body:
|
|
208
|
-
if (method === "POST")
|
|
209
|
-
|
|
210
|
-
const body = await readJson();
|
|
211
|
-
// New Agent makes a conversation exactly as agent_open does — it names BOTH the CLI that runs and the folder it runs
|
|
212
|
-
// in (#3640), neither defaulted — and opens that conversation's own CLI, so a session the browser started and one MCP
|
|
213
|
-
// started are one kind: the same driven CLI, typed into by agent_send and shown here (#3916).
|
|
214
|
-
const terminal = typeof body.conversation === "string" && body.conversation.trim().length > 0 ? await opened(body.conversation.trim()) : await openedNew(newAgent(body));
|
|
215
|
-
const size = dimensions(body);
|
|
216
|
-
await terminal.resize(size.cols, size.rows);
|
|
217
|
-
return { status: 201, body: terminal.info() };
|
|
218
|
-
}
|
|
227
|
+
return { status: 200, body: await terminalListing(owner) };
|
|
228
|
+
if (method === "POST")
|
|
229
|
+
return { status: 201, body: await openTerminal(await readJson()) };
|
|
219
230
|
}
|
|
220
231
|
const terminal = nativeTerminal(owner, parts[2]);
|
|
221
232
|
if (parts.length === 3 && method === "DELETE")
|
package/dist/notify.js
CHANGED
|
@@ -2508,15 +2508,22 @@ function startOwnedWork() {
|
|
|
2508
2508
|
AgentGateway.instance().boot();
|
|
2509
2509
|
log("·", "listener", `this process (pid ${process.pid}, build ${PACKAGE_VERSION}) owns the Telegram, Slack, Discord and Teams pollers, the ntfy and SMS pollers, the agent's email door, and the agent conversations`);
|
|
2510
2510
|
}
|
|
2511
|
-
// GATE: a daemon's beat older than this is presumed dead; it is vscode-extension/
|
|
2511
|
+
// GATE: a daemon's beat older than this is presumed dead; it is vscode-extension/bnDaemon.js's own STALE_MS.
|
|
2512
2512
|
const DAEMON_BEAT_STALE_MS = 30_000;
|
|
2513
|
-
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/
|
|
2514
|
-
export const
|
|
2513
|
+
/** Written by the daemon (daemon.ts) on its beat, read by vscode-extension/bnDaemon.js. */
|
|
2514
|
+
export const DAEMON_BEAT_PATH = join(CONFIG_DIR, "daemon.json");
|
|
2515
|
+
/** the beat's name in the release before, read for one release so a daemon of that build is never read as gone. */
|
|
2516
|
+
const OLD_DAEMON_BEAT_PATH = join(CONFIG_DIR, "always-on.json");
|
|
2517
|
+
/** The later of the beat and the one under its old name, or undefined when neither was written. */
|
|
2518
|
+
function latestBeat() {
|
|
2519
|
+
const [beat, old] = [DAEMON_BEAT_PATH, OLD_DAEMON_BEAT_PATH].map((file) => (existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : undefined));
|
|
2520
|
+
return old !== undefined && (beat === undefined || old.at > beat.at) ? old : beat;
|
|
2521
|
+
}
|
|
2515
2522
|
/** An always-on process is alive and beating — of the given build, when one is named. */
|
|
2516
2523
|
function daemonBeats(version) {
|
|
2517
|
-
|
|
2524
|
+
const beat = latestBeat();
|
|
2525
|
+
if (beat === undefined)
|
|
2518
2526
|
return false;
|
|
2519
|
-
const beat = JSON.parse(readFileSync(ALWAYS_ON_PATH, "utf8"));
|
|
2520
2527
|
if (Date.now() - beat.at >= DAEMON_BEAT_STALE_MS || (version !== undefined && beat.version !== version))
|
|
2521
2528
|
return false;
|
|
2522
2529
|
try {
|
|
@@ -214,7 +214,7 @@ function webDocument(source, { page, roots, theme }) {
|
|
|
214
214
|
"font-src 'self' data:",
|
|
215
215
|
`script-src 'self'${nonces.length === 0 ? " 'unsafe-inline'" : ` ${[...new Set(nonces)].join(" ")}`}`,
|
|
216
216
|
"connect-src 'self' ws://127.0.0.1:* ws://localhost:*",
|
|
217
|
-
"frame-src 'self'",
|
|
217
|
+
"frame-src 'self' http://127.0.0.1:* http://localhost:*",
|
|
218
218
|
"media-src 'self'",
|
|
219
219
|
].join("; ");
|
|
220
220
|
// NULL-OK: field theme is OPTIONAL and therefore it is ok to check for NULL
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.327",
|
|
4
4
|
"description": "Reach your AI agents from anywhere — and let them reach you. One stdio process 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.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|