omni-notify-mcp 1.3.494 → 1.3.496
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 +6 -1
- package/dist/daemon.js +22 -8
- package/dist/gateway/agentRuntime.js +171 -0
- package/dist/gateway/notifyDoor.js +22 -1
- package/dist/gateway/package.json +23 -0
- package/dist/gateway/panelPage.js +2 -2
- package/dist/gateway/restDoor.js +4 -4
- package/dist/gateway/{chatPage.js → signInDoor/chatPage.js} +3 -3
- package/dist/gateway/signInDoor/doorSettings.js +36 -0
- package/dist/gateway/{oauthDoor.js → signInDoor/oauthDoor.js} +1 -1
- package/dist/gateway/{passkeyDoor.js → signInDoor/passkeyDoor.js} +2 -1
- package/dist/gateway/signInDoor/shared/package.json +1 -0
- package/dist/gateway/signInDoor/shared/webviewShim.js +996 -0
- package/dist/gatewaySettings.js +7 -33
- package/dist/notify.js +7 -0
- package/dist/shared/webhost/originHandover.js +32 -14
- package/package.json +3 -3
- /package/dist/gateway/{iconData.js → signInDoor/iconData.js} +0 -0
- /package/dist/gateway/{iconDoor.js → signInDoor/iconDoor.js} +0 -0
- /package/dist/gateway/{passkeyClient.js → signInDoor/passkeyClient.js} +0 -0
package/dist/agentGateway.js
CHANGED
|
@@ -24,12 +24,17 @@ const COMMAND_RE = /^\/?(new|stop)(@\w+)?$/i;
|
|
|
24
24
|
const FINAL_KINDS = new Set(["answer", "failed", "stopped", "archived", "deleted"]);
|
|
25
25
|
// GATE: the port AgenticBullseye serves on (#4196 Section 9); NOTIFY_AGENT_CLUSTER_URL names another ONLY under the test gate, so a suite drives the real carriage on a cluster it owns, and without the gate no environment can redirect it.
|
|
26
26
|
const CLUSTER_URL = "http://127.0.0.1:7481";
|
|
27
|
+
let residentCluster;
|
|
28
|
+
/** The daemon publishes its own door only while it owns the runtime listener. */
|
|
29
|
+
export function setResidentCluster(resolve) {
|
|
30
|
+
residentCluster = resolve;
|
|
31
|
+
}
|
|
27
32
|
// GATE: a refused connection to AB is tried five times, waiting 0.5, 1, 2 and 4 s — the bound AB's own call into BN takes (AgenticBullseye wire.ts BN_CALL_TRIES) — then AB is unreachable.
|
|
28
33
|
const CLUSTER_CALL_TRIES = 5;
|
|
29
34
|
const CLUSTER_FIRST_WAIT_MS = 500;
|
|
30
35
|
/** AgenticBullseye's base URL: the one this machine runs, or the stand-in a suite names under the test gate. */
|
|
31
36
|
export function clusterBase() {
|
|
32
|
-
return process.env.NOTIFY_MCP_TEST_ENDPOINTS === "1" && process.env.NOTIFY_AGENT_CLUSTER_URL ? process.env.NOTIFY_AGENT_CLUSTER_URL.replace(/\/+$/, "") : CLUSTER_URL;
|
|
37
|
+
return process.env.NOTIFY_MCP_TEST_ENDPOINTS === "1" && process.env.NOTIFY_AGENT_CLUSTER_URL ? process.env.NOTIFY_AGENT_CLUSTER_URL.replace(/\/+$/, "") : residentCluster?.() ?? CLUSTER_URL;
|
|
33
38
|
}
|
|
34
39
|
/** The gateway bearer every call to AB carries; with no `agentGateway.token` in config.json BN has no way into AB and says so. */
|
|
35
40
|
export function clusterToken() {
|
package/dist/daemon.js
CHANGED
|
@@ -13,7 +13,9 @@ import { createWriteStream, existsSync, readFileSync, mkdirSync, renameSync } fr
|
|
|
13
13
|
import { join } from "path";
|
|
14
14
|
import { fileURLToPath } from "url";
|
|
15
15
|
import { DAEMON_BEAT_PATH, CONFIG_DIR, DAEMON_TAG, PACKAGE_VERSION, smsReachesOwner, startNotifyServer, takePendingInbox, textOwner, writeRecordFile, yieldGateway } from "./notify.js";
|
|
16
|
-
import {
|
|
16
|
+
import { AgentRuntime } from "./gateway/agentRuntime.js";
|
|
17
|
+
import { NOTIFY_DOOR_PORT, startNotifyDoor } from "./gateway/notifyDoor.js";
|
|
18
|
+
import { setResidentCluster } from "./agentGateway.js";
|
|
17
19
|
import { announceTakeover, inThisBoot } from "./shared/webhost/originHandover.js";
|
|
18
20
|
import { TunnelRunner } from "./gateway/tunnel.js";
|
|
19
21
|
const HEARTBEAT_MS = 10_000;
|
|
@@ -123,14 +125,21 @@ function keepConsole() {
|
|
|
123
125
|
const takeover = process.argv.includes("--takeover");
|
|
124
126
|
/** Whether this process writes the heartbeat: the next release only from the moment it holds the chat door, so a takeover that never lands leaves the serving build's beat alone; and a build that let the door go no longer, so the release that took it is the one beat. */
|
|
125
127
|
let beating = !takeover;
|
|
128
|
+
let ownsNotifyDoor = false;
|
|
129
|
+
const agentRuntime = new AgentRuntime();
|
|
130
|
+
setResidentCluster(() => ownsNotifyDoor && agentRuntime.serving ? "http://127.0.0.1:" + NOTIFY_DOOR_PORT : undefined);
|
|
126
131
|
keepConsole();
|
|
127
132
|
// The server's own timers are unref'd, so this beat and the door hold the process until it is stopped.
|
|
128
133
|
if (beating)
|
|
129
134
|
beat();
|
|
130
135
|
/** Each tick reads the Stop first, beating or not: a press in a window that may not end this process — the boot task's, in session 0, or one still draining its gateway after a hand-over — stops it all the same, within one tick. */
|
|
131
136
|
const beatTimer = setInterval(() => {
|
|
132
|
-
if (stoppedByHand())
|
|
133
|
-
process.exit(0);
|
|
137
|
+
if (stoppedByHand()) {
|
|
138
|
+
void agentRuntime.close().then(() => process.exit(0));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (ownsNotifyDoor)
|
|
142
|
+
agentRuntime.acquire();
|
|
134
143
|
if (beating)
|
|
135
144
|
beat();
|
|
136
145
|
}, HEARTBEAT_MS);
|
|
@@ -142,24 +151,29 @@ const daemonHost = {
|
|
|
142
151
|
clientId: DAEMON_TAG, tag: DAEMON_TAG,
|
|
143
152
|
bindDoor: async (settings) => {
|
|
144
153
|
// #4247 — the sign-in doors text Meni's code through notify, handed in here so passkeyDoor imports no notification code.
|
|
145
|
-
(await import("./gateway/passkeyDoor.js")).setOwnerTexter({ reaches: smsReachesOwner, text: textOwner });
|
|
154
|
+
(await import("./gateway/signInDoor/passkeyDoor.js")).setOwnerTexter({ reaches: smsReachesOwner, text: textOwner });
|
|
146
155
|
return (await import("./gateway/restDoor.js")).startRestDoor(settings);
|
|
147
156
|
},
|
|
148
157
|
findOtherOwner: async (port) => (await import("./gateway/lanProbe.js")).findOtherBn(port),
|
|
149
158
|
onDoorOwned: (port) => {
|
|
150
|
-
// #4231 — BN holds no agent CLI: the cluster keeps every chat CLI and its background subagents (#4814), so a BN release never waits on one.
|
|
151
159
|
tunnel.beat(port, undefined);
|
|
152
160
|
setInterval(() => tunnel.beat(port, undefined), HEARTBEAT_MS);
|
|
153
161
|
},
|
|
154
|
-
|
|
162
|
+
prepareHandover: () => agentRuntime.prepareHandover(),
|
|
163
|
+
onSuperseded: () => {
|
|
164
|
+
void agentRuntime.close().then(() => handedOver === undefined ? replaceWithInstalledBuild() : handedOver.then(() => process.exit(0)));
|
|
165
|
+
},
|
|
155
166
|
};
|
|
156
167
|
startNotifyServer(daemonHost);
|
|
157
168
|
takePendingInbox();
|
|
158
|
-
startNotifyDoor(() => { beating = true; beat(); }, undefined, {
|
|
169
|
+
startNotifyDoor(() => { ownsNotifyDoor = true; beating = true; beat(); agentRuntime.acquire(); }, undefined, {
|
|
170
|
+
agentRuntime,
|
|
159
171
|
version: PACKAGE_VERSION,
|
|
160
172
|
takeover,
|
|
173
|
+
onUnbound: () => { ownsNotifyDoor = false; beating = false; },
|
|
161
174
|
onShutdown: (closed) => {
|
|
162
175
|
beating = false;
|
|
176
|
+
ownsNotifyDoor = false;
|
|
163
177
|
handedOver = closed;
|
|
164
178
|
yieldGateway();
|
|
165
179
|
},
|
|
@@ -168,6 +182,6 @@ startNotifyDoor(() => { beating = true; beat(); }, undefined, {
|
|
|
168
182
|
if (takeover)
|
|
169
183
|
announceTakeover();
|
|
170
184
|
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
171
|
-
process.
|
|
185
|
+
process.once(signal, () => { void agentRuntime.close().then(() => process.exit(0)); });
|
|
172
186
|
}
|
|
173
187
|
process.on("exit", () => tunnel.stop());
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { holdOf } from "../shared/webhost/originHandover.js";
|
|
7
|
+
/** Existing remote links and older clients address this port. Binding it excludes every preceding owner. */
|
|
8
|
+
const COMPATIBILITY_PORT = 7481;
|
|
9
|
+
const runtimeRoot = () => join(process.env.NOTIFY_MCP_CONFIG_DIR || join(homedir(), ".notify-mcp"), "agent-runtime");
|
|
10
|
+
async function closeListener(server) {
|
|
11
|
+
if (!server.listening)
|
|
12
|
+
return;
|
|
13
|
+
const closed = new Promise(resolve => server.close(() => resolve()));
|
|
14
|
+
server.closeAllConnections();
|
|
15
|
+
await closed;
|
|
16
|
+
}
|
|
17
|
+
export class AgentRuntime {
|
|
18
|
+
listener;
|
|
19
|
+
lease;
|
|
20
|
+
opening;
|
|
21
|
+
closing;
|
|
22
|
+
leaving = false;
|
|
23
|
+
lastError = "";
|
|
24
|
+
loadedEntry;
|
|
25
|
+
failed = new Map();
|
|
26
|
+
/** Called by the owner of the notification door on bind and on its recovery heartbeat. */
|
|
27
|
+
acquire() {
|
|
28
|
+
if (this.leaving || this.closing)
|
|
29
|
+
return;
|
|
30
|
+
try {
|
|
31
|
+
if (holdOf("agentic-bullseye").desired !== "running") {
|
|
32
|
+
if (this.listener || this.opening)
|
|
33
|
+
void this.close(false);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (this.opening)
|
|
37
|
+
return;
|
|
38
|
+
const releases = join(runtimeRoot(), "releases");
|
|
39
|
+
if (!existsSync(releases))
|
|
40
|
+
return;
|
|
41
|
+
const versions = readdirSync(releases, { withFileTypes: true }).filter(item => item.isDirectory() && /^\d+\.\d+\.\d+$/.test(item.name));
|
|
42
|
+
const newest = versions.sort((a, b) => b.name.localeCompare(a.name, "en", { numeric: true }))[0];
|
|
43
|
+
if (!newest)
|
|
44
|
+
return;
|
|
45
|
+
const marker = join(runtimeRoot(), "managed-by-notify");
|
|
46
|
+
const good = existsSync(marker) ? readFileSync(marker, "utf8").trim() : undefined;
|
|
47
|
+
const available = (version) => (this.failed.get(version)?.retryAt ?? 0) <= Date.now();
|
|
48
|
+
const chosen = available(newest.name) ? newest.name : versions.find(item => item.name === good && available(item.name))?.name;
|
|
49
|
+
if (!chosen)
|
|
50
|
+
return;
|
|
51
|
+
const entry = join(releases, chosen, "dist", "residentRuntime.js");
|
|
52
|
+
if (this.listener) {
|
|
53
|
+
if (this.loadedEntry !== entry && this.canHandOver())
|
|
54
|
+
void this.close(false);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.opening = this.open(entry, chosen, marker).catch((error) => {
|
|
58
|
+
const attempts = (this.failed.get(chosen)?.attempts ?? 0) + 1;
|
|
59
|
+
const waitMs = Math.min(600_000, 30_000 * 2 ** Math.min(attempts - 1, 5));
|
|
60
|
+
this.failed.set(chosen, { attempts, retryAt: Date.now() + waitMs });
|
|
61
|
+
this.report(error);
|
|
62
|
+
}).finally(() => { this.opening = undefined; });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
this.report(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async open(entry, version, marker) {
|
|
69
|
+
const server = createServer();
|
|
70
|
+
const acquired = await new Promise((resolve, reject) => {
|
|
71
|
+
const failed = (error) => error.code === "EADDRINUSE" ? resolve(false) : reject(error);
|
|
72
|
+
server.once("error", failed);
|
|
73
|
+
server.listen(COMPATIBILITY_PORT, "127.0.0.1", () => {
|
|
74
|
+
server.off("error", failed);
|
|
75
|
+
resolve(true);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
if (!acquired)
|
|
79
|
+
return;
|
|
80
|
+
this.listener = server;
|
|
81
|
+
try {
|
|
82
|
+
if (this.leaving || this.closing)
|
|
83
|
+
return;
|
|
84
|
+
const runtime = createRequire(import.meta.url)(entry);
|
|
85
|
+
this.lease = await runtime.mountCluster(server, "BullseyeNotif");
|
|
86
|
+
this.loadedEntry = entry;
|
|
87
|
+
// The marker survives a resident restart. Consumers and startup registrations then stay on this owner.
|
|
88
|
+
if (!existsSync(marker) || readFileSync(marker, "utf8").trim() !== version) {
|
|
89
|
+
const temporary = marker + "." + process.pid;
|
|
90
|
+
writeFileSync(temporary, version + "\n", { mode: 0o600 });
|
|
91
|
+
renameSync(temporary, marker);
|
|
92
|
+
}
|
|
93
|
+
this.failed.delete(version);
|
|
94
|
+
this.lastError = "";
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
try {
|
|
98
|
+
await this.lease?.close();
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
this.lease = undefined;
|
|
102
|
+
this.loadedEntry = undefined;
|
|
103
|
+
await closeListener(server);
|
|
104
|
+
this.listener = undefined;
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
report(error) {
|
|
110
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
111
|
+
if (message !== this.lastError)
|
|
112
|
+
console.error("[notify] agent runtime unavailable: " + message);
|
|
113
|
+
this.lastError = message;
|
|
114
|
+
}
|
|
115
|
+
get serving() {
|
|
116
|
+
return !!this.lease && this.listener?.listening === true && !this.closing;
|
|
117
|
+
}
|
|
118
|
+
/** Called before a routine replacement releases either public door. An active owner keeps serving. */
|
|
119
|
+
canHandOver() {
|
|
120
|
+
return !this.opening && !this.lease?.handoverHolders().length;
|
|
121
|
+
}
|
|
122
|
+
prepareHandover() {
|
|
123
|
+
if (!this.canHandOver())
|
|
124
|
+
return false;
|
|
125
|
+
void this.close();
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
request(req, res) {
|
|
129
|
+
if (!this.serving || !this.listener) {
|
|
130
|
+
res.writeHead(503, { "content-type": "application/json" });
|
|
131
|
+
res.end(JSON.stringify({ error: this.lastError || "The resident has not acquired the agent runtime" }));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (req.url === "/v1/agent-mcp")
|
|
135
|
+
req.url = "/mcp";
|
|
136
|
+
this.listener.emit("request", req, res);
|
|
137
|
+
}
|
|
138
|
+
upgrade(req, socket, head) {
|
|
139
|
+
if (this.serving && this.listener)
|
|
140
|
+
this.listener.emit("upgrade", req, socket, head);
|
|
141
|
+
else
|
|
142
|
+
socket.end("HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n");
|
|
143
|
+
}
|
|
144
|
+
close(leaving = true) {
|
|
145
|
+
if (leaving)
|
|
146
|
+
this.leaving = true;
|
|
147
|
+
if (!this.closing)
|
|
148
|
+
this.closing = this.drain().finally(() => { this.closing = undefined; });
|
|
149
|
+
return this.closing;
|
|
150
|
+
}
|
|
151
|
+
async drain() {
|
|
152
|
+
if (this.opening)
|
|
153
|
+
await this.opening;
|
|
154
|
+
const server = this.listener;
|
|
155
|
+
const lease = this.lease;
|
|
156
|
+
this.lease = undefined;
|
|
157
|
+
try {
|
|
158
|
+
if (server) {
|
|
159
|
+
server.removeAllListeners("upgrade");
|
|
160
|
+
server.on("upgrade", (_req, socket) => socket.end("HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n"));
|
|
161
|
+
}
|
|
162
|
+
if (lease)
|
|
163
|
+
await lease.close();
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
if (server)
|
|
167
|
+
await closeListener(server);
|
|
168
|
+
this.listener = undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -95,16 +95,27 @@ export function startNotifyDoor(onBound, port = NOTIFY_DOOR_PORT, resident) {
|
|
|
95
95
|
const path = new URL(req.url ?? "/", "http://door").pathname;
|
|
96
96
|
if (resident !== undefined && path === "/health") {
|
|
97
97
|
res.writeHead(200, { "content-type": "application/json" });
|
|
98
|
-
|
|
98
|
+
const health = healthBody(NOTIFY_SERVER, port, resident.version);
|
|
99
|
+
res.end(resident.agentRuntime ? JSON.stringify({ ...JSON.parse(health), agentRuntime: resident.agentRuntime.serving }) : health);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (path === "/shutdown" && req.method === "POST" && req.headers.origin === undefined &&
|
|
103
|
+
resident?.agentRuntime && !resident.agentRuntime.canHandOver()) {
|
|
104
|
+
refuse(res, 409, "Active agent work still holds this resident");
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
107
|
if (resident !== undefined && answerShutdown(req, res, server, NOTIFY_SERVER, port, resident.version, (closed) => {
|
|
102
108
|
stopping = true;
|
|
103
109
|
bound = false;
|
|
110
|
+
resident.onUnbound?.();
|
|
104
111
|
say(`the next release asked for the chat door on ${port}; build ${resident.version} lets it go`);
|
|
105
112
|
resident.onShutdown(closed);
|
|
106
113
|
}))
|
|
107
114
|
return;
|
|
115
|
+
if (resident?.agentRuntime && (path === "/agents/" || path === "/terminal" || path.startsWith("/v1/"))) {
|
|
116
|
+
resident.agentRuntime.request(req, res);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
108
119
|
if (path !== NOTIFY_DOOR_PATH) {
|
|
109
120
|
refuse(res, 404, `the notify MCP door answers on ${NOTIFY_DOOR_PATH}`);
|
|
110
121
|
return;
|
|
@@ -118,6 +129,15 @@ export function startNotifyDoor(onBound, port = NOTIFY_DOOR_PORT, resident) {
|
|
|
118
129
|
res.end();
|
|
119
130
|
});
|
|
120
131
|
});
|
|
132
|
+
if (resident?.agentRuntime) {
|
|
133
|
+
const runtime = resident.agentRuntime;
|
|
134
|
+
server.on("upgrade", (request, socket, head) => {
|
|
135
|
+
if (/^\/v1\/terminals\/[^/?]+\/ws$/.test(request.url ?? ""))
|
|
136
|
+
runtime.upgrade(request, socket, head);
|
|
137
|
+
else
|
|
138
|
+
socket.end("HTTP/1.1 404 Not Found\r\nConnection: close\r\n\r\n");
|
|
139
|
+
});
|
|
140
|
+
}
|
|
121
141
|
server.on("error", (err) => {
|
|
122
142
|
attempting = false;
|
|
123
143
|
const cause = err.code ?? err.message;
|
|
@@ -125,6 +145,7 @@ export function startNotifyDoor(onBound, port = NOTIFY_DOOR_PORT, resident) {
|
|
|
125
145
|
// The listener failed after it was serving: close it before clearing the flag, or the retry timer
|
|
126
146
|
// asks for a port this very process still holds and answers EADDRINUSE to itself for ever.
|
|
127
147
|
bound = false;
|
|
148
|
+
resident?.onUnbound?.();
|
|
128
149
|
lastCause = "";
|
|
129
150
|
server.close();
|
|
130
151
|
say(`the chat door on ${port} stopped serving (${cause}); rebinding`);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bullseye-sign-in-door",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The public sign-in door every Bullseye host's grants come from: passkey, authenticator and texted-code sign-in, OAuth for the MCP connectors and the sign-in pages. Built from signInDoor/ into dist/ by build-sign-in-door.cjs, which the gateway deploy and refresh run.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=20.0.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node build-sign-in-door.cjs"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@simplewebauthn/server": "^14.0.3",
|
|
16
|
+
"qrcode": "^1.5.4"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.0.0",
|
|
20
|
+
"@types/qrcode": "^1.5.6",
|
|
21
|
+
"typescript": "^5.4.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* these very pages, so the panel and a browser with every editor closed show the same thing from the same service.
|
|
6
6
|
*/
|
|
7
7
|
import { PACKAGE_HOMEPAGE } from "../gatewaySettings.js";
|
|
8
|
-
import { NOTICE_SCRIPT, PAGE_STYLE } from "./chatPage.js";
|
|
9
|
-
import { ICON_HEAD } from "./iconDoor.js";
|
|
8
|
+
import { NOTICE_SCRIPT, PAGE_STYLE } from "./signInDoor/chatPage.js";
|
|
9
|
+
import { ICON_HEAD } from "./signInDoor/iconDoor.js";
|
|
10
10
|
import { CONNECTION_SOURCE, PICKER_PAGE_SOURCE } from "../shared/webhost/webviewShim.js";
|
|
11
11
|
export const PANEL_PAGES = ["settings", "public-access"];
|
|
12
12
|
const LINKS = {
|
package/dist/gateway/restDoor.js
CHANGED
|
@@ -19,10 +19,10 @@ import { isAbsolute, join, relative } from "path";
|
|
|
19
19
|
import { createServer, request as httpRequest } from "http";
|
|
20
20
|
import { WebSocket, WebSocketServer } from "ws";
|
|
21
21
|
import { CONFIG_DIR, GatewayError } from "../gatewaySettings.js";
|
|
22
|
-
import { CHAT_HEADERS } from "./chatPage.js";
|
|
23
|
-
import { isIconPath, serveIcon } from "./iconDoor.js";
|
|
24
|
-
import { MCP_PATH, accessGranted, challenge, grantClient, handleOAuth, isOAuthPath, publicBase } from "./oauthDoor.js";
|
|
25
|
-
import { bearer, bearerAdmitted, fromThisMachine, handlePasskey, isPasskeyPath, localOnly, refusalOfRequest, sessionExpiresAt, sessionSignIn, tokenProves } from "./passkeyDoor.js";
|
|
22
|
+
import { CHAT_HEADERS } from "./signInDoor/chatPage.js";
|
|
23
|
+
import { isIconPath, serveIcon } from "./signInDoor/iconDoor.js";
|
|
24
|
+
import { MCP_PATH, accessGranted, challenge, grantClient, handleOAuth, isOAuthPath, publicBase } from "./signInDoor/oauthDoor.js";
|
|
25
|
+
import { bearer, bearerAdmitted, fromThisMachine, handlePasskey, isPasskeyPath, localOnly, refusalOfRequest, sessionExpiresAt, sessionSignIn, tokenProves } from "./signInDoor/passkeyDoor.js";
|
|
26
26
|
import { configFile, panelState, reinstallMessenger, saveConfigFile, saveSetting } from "./panel.js";
|
|
27
27
|
import { PANEL_PAGES, panelHtml } from "./panelPage.js";
|
|
28
28
|
import { configureMcpHosts } from "./mcpHosts.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PACKAGE_VERSION } from "
|
|
1
|
+
import { PACKAGE_VERSION } from "./doorSettings.js";
|
|
2
2
|
import { ICON_HEAD } from "./iconDoor.js";
|
|
3
3
|
import { PASSKEY_SCRIPT } from "./passkeyDoor.js";
|
|
4
4
|
import { PROOF_WAYS } from "./passkeyClient.js";
|
|
5
|
-
import { CONNECTION_SOURCE } from "
|
|
5
|
+
import { CONNECTION_SOURCE } from "./shared/webviewShim.js";
|
|
6
6
|
/** The ancestors allowed to frame this page, and nothing else. VS Code's own webview shell shows the one shared
|
|
7
7
|
* interface inside the extension panel (#2726); a scheme source admits any documentation of that scheme and no site.
|
|
8
8
|
* The same page is also framed in a browser (#3081): the Bullseye dashboard's web shell writes the panel's own HTML
|
|
@@ -400,7 +400,7 @@ export function serviceHtml({ name, host }) {
|
|
|
400
400
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
|
401
401
|
<title>${safe(name)}</title>${ICON_HEAD}<style>${PAGE_STYLE}</style></head><body class="titled">
|
|
402
402
|
<header><h1 id="title">${safe(name)}</h1><span class="grow"></span><button id="refresh" class="keep" hidden>🔄<span class="lbl"> Refresh</span></button><button id="logout" class="keep" hidden>🚪<span class="lbl"> Logout</span></button></header>
|
|
403
|
-
<div id="status" role="status"></div><div id="serving" class="idbar" hidden data-be-tip="The process that answered this page — its process id, when it started and the sign-in build its code was loaded from — and when this page's sign-in expires"><span class="srv">${safe(host)} · pid ${me.pid} · started ${storedStamp(me.startedAt)} · sign-in
|
|
403
|
+
<div id="status" role="status"></div><div id="serving" class="idbar" hidden data-be-tip="The process that answered this page — its process id, when it started and the sign-in build its code was loaded from — and when this page's sign-in expires"><span class="srv">${safe(host)} · pid ${me.pid} · started ${storedStamp(me.startedAt)} · sign-in ${safe(me.build)}</span><small id="expires" hidden></small></div>
|
|
404
404
|
<main id="main"></main>
|
|
405
405
|
<script>${CONNECTION_SOURCE}</script><script>var FACTS = ${facts}, TITLE = FACTS.name;
|
|
406
406
|
${PASSKEY_SCRIPT}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4247 — what every sign-in door shares: where the notify config lives, the gateway's token settings, the refusal
|
|
3
|
+
* type every door answers with and the build the door was loaded from. The gateway and BullseyeNotif both import it,
|
|
4
|
+
* so a refusal thrown by any door is the one GatewayError class each catcher tests against.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync } from "fs";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
/** The build the door's code was loaded from: the package.json one folder above the built module. */
|
|
11
|
+
export const PACKAGE_VERSION = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
|
|
12
|
+
export const CONFIG_DIR = process.env.NOTIFY_MCP_CONFIG_DIR || join(homedir(), ".notify-mcp");
|
|
13
|
+
export const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
14
|
+
export const DEFAULT_GATEWAY_PORT = 7470;
|
|
15
|
+
/** A refused request, answered to its caller with this status and these words by whichever door it reached. */
|
|
16
|
+
export class GatewayError extends Error {
|
|
17
|
+
status;
|
|
18
|
+
facts;
|
|
19
|
+
/** `facts` ride beside the words in the refusal's body, so a caller acts on what was refused without parsing the message. */
|
|
20
|
+
constructor(status, message, facts = {}) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.status = status;
|
|
23
|
+
this.facts = facts;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The token is mandatory: a door that is open to the home network never starts without one. */
|
|
27
|
+
export function readGatewaySettings() {
|
|
28
|
+
if (!existsSync(CONFIG_PATH))
|
|
29
|
+
return undefined;
|
|
30
|
+
const section = JSON.parse(readFileSync(CONFIG_PATH, "utf8")).agentGateway;
|
|
31
|
+
if (!section || typeof section.token !== "string" || section.token.length === 0)
|
|
32
|
+
return undefined;
|
|
33
|
+
const host = typeof section.host === "string" && section.host.length > 0 ? section.host : undefined;
|
|
34
|
+
const hosts = Array.isArray(section.hosts) && section.hosts.length > 0 ? section.hosts.map(String) : undefined;
|
|
35
|
+
return { token: section.token, port: typeof section.port === "number" ? section.port : DEFAULT_GATEWAY_PORT, ...(host === undefined ? {} : { host }), ...(hosts === undefined ? {} : { hosts }) };
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, createHmac, timingSafeEqual } from "crypto";
|
|
2
2
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
|
-
import { CONFIG_DIR, GatewayError } from "
|
|
4
|
+
import { CONFIG_DIR, GatewayError } from "./doorSettings.js";
|
|
5
5
|
import { ICON_HEAD, logoUri } from "./iconDoor.js";
|
|
6
6
|
import { HOST_RE, LOOPBACK_HOSTS, PASSKEY_SCRIPT, approvalStands, digest, doorState, escapeHtml, mint, fromThisMachine, sessionApproval, tokenProves, tokenStands } from "./passkeyDoor.js";
|
|
7
7
|
export const MCP_PATH = "/mcp";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { PASSKEY_SCRIPT, PROOF_WAYS } from "./passkeyClient.js";
|
|
2
2
|
export { PASSKEY_SCRIPT } from "./passkeyClient.js";
|
|
3
|
+
export { GatewayError, readGatewaySettings } from "./doorSettings.js";
|
|
3
4
|
import { createHash, createHmac, randomBytes, randomInt, timingSafeEqual } from "crypto";
|
|
4
5
|
import { existsSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "fs";
|
|
5
6
|
import { hostname, uptime } from "os";
|
|
6
7
|
import { join } from "path";
|
|
7
8
|
import { generateAuthenticationOptions, generateRegistrationOptions, verifyAuthenticationResponse, verifyRegistrationResponse } from "@simplewebauthn/server";
|
|
8
9
|
import QRCode from "qrcode";
|
|
9
|
-
import { CONFIG_DIR, GatewayError, readGatewaySettings } from "
|
|
10
|
+
import { CONFIG_DIR, GatewayError, readGatewaySettings } from "./doorSettings.js";
|
|
10
11
|
import { ICON_HEAD } from "./iconDoor.js";
|
|
11
12
|
const PASSKEY_PREFIX = "/passkey/";
|
|
12
13
|
const ENROL_PATH = "/passkey/enrol";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|