omni-notify-mcp 1.3.373 → 1.3.374
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 +1 -1
- package/dist/desk.js +268 -0
- package/dist/gateway/chatPage.js +10 -2
- package/dist/gateway/claudeProvider.js +5 -1
- package/dist/gateway/conversations.js +35 -8
- package/dist/gateway/mcpDoor.js +12 -12
- package/dist/gateway/notifyDoor.js +2 -1
- package/dist/gateway/passkeyDoor.js +146 -108
- package/dist/gateway/restDoor.js +11 -5
- package/dist/gateway/terminalDoor.js +5 -5
- package/dist/gateway/terminalPage.js +7 -14
- package/dist/messaging/notificationEngine.js +10 -7
- package/dist/notify.js +8 -62
- package/dist/shared/agentSession.js +557 -103
- package/dist/shared/webhost/autoSwitch.cjs +12 -5
- package/dist/shared/webhost/originHandover.js +58 -3
- package/dist/shared/webhost/userSession.js +178 -0
- package/package.json +1 -1
- package/dist/gateway/agentStream.js +0 -88
- package/dist/googlehome/foyer-client.js +0 -210
- package/dist/googlehome/foyer-codec.js +0 -318
- package/dist/googlehome/gpsoauth.js +0 -119
- package/dist/googlehome/index.js +0 -267
- package/dist/index.js +0 -41
- package/dist/shared/webhost/openedWorkspaces.js +0 -62
- package/scripts/shared/ownerGuard.cs +0 -665
- package/scripts/shared/ownerGuard.ps1 +0 -31
package/dist/daemon.js
CHANGED
|
@@ -47,7 +47,7 @@ function successor() {
|
|
|
47
47
|
return spawn(process.execPath, [...process.execArgv, self], { detached: true, stdio: "ignore", windowsHide: true });
|
|
48
48
|
if (!existsSync(SUPERVISE_LOOP))
|
|
49
49
|
throw new Error(`the supervise loop is not in the config dir at ${SUPERVISE_LOOP} — the login entry and the boot task copy it there, so nothing can own the next run`);
|
|
50
|
-
return spawn(process.execPath, [SUPERVISE_LOOP, "supervise"
|
|
50
|
+
return spawn(process.execPath, [SUPERVISE_LOOP, "supervise"], { detached: true, stdio: "ignore", windowsHide: true });
|
|
51
51
|
}
|
|
52
52
|
/** 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
53
|
function replaceWithInstalledBuild() {
|
package/dist/desk.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4142 — BN's desk: the one BN process that runs in the logged-on user's own Windows session. The boot task runs the daemon in
|
|
3
|
+
* session 0, which has none of his keyboard, mouse, screen or speakers — GetLastInputInfo there reads the services session's own
|
|
4
|
+
* last input, so the "idle" it gives is the time since the machine booted, a banner draws on no desktop and a voice plays to no
|
|
5
|
+
* one. The daemon asks the desk over a named pipe instead; a desk that does not answer is started in his session through the
|
|
6
|
+
* shared user-session launcher, and a machine with no logon session of his has no desk and says so. On macOS and Linux the
|
|
7
|
+
* daemon runs in his own login, so each act is taken in-process.
|
|
8
|
+
*
|
|
9
|
+
* Started as `node desk.(m)js --serve-desk <config dir>`, this module serves the desk; imported, it is the daemon's client.
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from "crypto";
|
|
12
|
+
import { connect, createServer } from "net";
|
|
13
|
+
import { existsSync, readFileSync } from "fs";
|
|
14
|
+
import { tmpdir } from "os";
|
|
15
|
+
import { dirname, extname, join } from "path";
|
|
16
|
+
import { fileURLToPath } from "url";
|
|
17
|
+
import { execFile, spawn } from "child_process";
|
|
18
|
+
import notifier from "node-notifier";
|
|
19
|
+
import { idleReading, idleUnmeasured } from "./messaging/notificationEngine.js";
|
|
20
|
+
import { NoUserSession, OsCallTimedOut, startInUserSession } from "./shared/webhost/userSession.js";
|
|
21
|
+
const SELF = fileURLToPath(import.meta.url);
|
|
22
|
+
/** The desk's own entry beside this module, in whichever build this is: `dist/desk.js` of the npm package, `dist/desk.mjs` beside the extension's bundled daemon, `doors/dist/desk.js` beside the gateway's doors. */
|
|
23
|
+
const DESK_ENTRY = join(dirname(SELF), `desk${extname(SELF)}`);
|
|
24
|
+
const VERSION = JSON.parse(readFileSync(join(dirname(SELF), "..", "package.json"), "utf8")).version;
|
|
25
|
+
/** The Windows idle probe the build ships at `../scripts/` beside it. */
|
|
26
|
+
const IDLE_PROBE = join(dirname(SELF), "..", "scripts", "idle-check.ps1");
|
|
27
|
+
const SERVE_FLAG = "--serve-desk";
|
|
28
|
+
const CHECK_FLAG = "--check-desk";
|
|
29
|
+
// GATE: how long a desk just started in the user's session has to answer on its pipe before the ask says it could not be reached.
|
|
30
|
+
const DESK_START_MS = 20_000;
|
|
31
|
+
// GATE: how long one ask waits for the desk's answer before the ask says the desk did not answer.
|
|
32
|
+
const DESK_ANSWER_MS = 10_000;
|
|
33
|
+
// GATE: how often the desk looks whether its config dir still exists; a desk whose config dir is gone (a suite's, removed) leaves.
|
|
34
|
+
const DESK_OWNER_LOOK_MS = 60_000;
|
|
35
|
+
/** The desk could not be asked: no logon session is open, it did not start, or it did not answer. */
|
|
36
|
+
export class DeskUnreachable extends Error {
|
|
37
|
+
}
|
|
38
|
+
const deskKey = (configDir) => createHash("sha256").update(configDir).digest("hex").slice(0, 12);
|
|
39
|
+
const deskPipe = (configDir) => `\\\\.\\pipe\\bullseye-notify-desk-${deskKey(configDir)}`;
|
|
40
|
+
/** The name every one-shot task that starts this config dir's desk in the user's session begins with; a suite's own config dir names its own. */
|
|
41
|
+
export const deskTask = (configDir) => `BullseyeNotifyDesk-${deskKey(configDir)}`;
|
|
42
|
+
/** One ask over the pipe: the desk's answer, or "absent" when nothing listens on it. */
|
|
43
|
+
function askOnce(configDir, request) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const socket = connect(deskPipe(configDir));
|
|
46
|
+
let reply = "";
|
|
47
|
+
let settled = false;
|
|
48
|
+
const settle = (outcome) => {
|
|
49
|
+
if (settled)
|
|
50
|
+
return;
|
|
51
|
+
settled = true;
|
|
52
|
+
socket.destroy();
|
|
53
|
+
outcome();
|
|
54
|
+
};
|
|
55
|
+
socket.setEncoding("utf8");
|
|
56
|
+
socket.setTimeout(DESK_ANSWER_MS, () => settle(() => reject(new DeskUnreachable(`the desk on ${deskPipe(configDir)} did not answer within ${DESK_ANSWER_MS / 1000} s`))));
|
|
57
|
+
socket.once("connect", () => socket.write(`${JSON.stringify({ ...request, version: VERSION })}\n`));
|
|
58
|
+
socket.on("data", (chunk) => {
|
|
59
|
+
reply += chunk;
|
|
60
|
+
if (reply.includes("\n"))
|
|
61
|
+
settle(() => resolve(JSON.parse(reply.slice(0, reply.indexOf("\n")))));
|
|
62
|
+
});
|
|
63
|
+
socket.once("close", () => settle(() => reject(new DeskUnreachable(`the desk on ${deskPipe(configDir)} closed the ask before it answered`))));
|
|
64
|
+
socket.once("error", (err) => settle(() => (err.code === "ENOENT" ? resolve("absent") : reject(new DeskUnreachable(`the desk on ${deskPipe(configDir)} could not be asked — ${err.message}`)))));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** The one start under way per config dir, so two asks that both find no desk start one between them. */
|
|
68
|
+
const starting = new Map();
|
|
69
|
+
/** Why a desk this process started did not come up, per config dir: a desk that cannot come up is started once, never again on every ask; a desk that comes up after all clears it. */
|
|
70
|
+
const parked = new Map();
|
|
71
|
+
async function startDesk(configDir) {
|
|
72
|
+
try {
|
|
73
|
+
await startInUserSession(deskTask(configDir), process.execPath, [DESK_ENTRY, SERVE_FLAG, configDir]);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (err instanceof NoUserSession)
|
|
77
|
+
throw new DeskUnreachable(err.message);
|
|
78
|
+
if (err instanceof OsCallTimedOut)
|
|
79
|
+
throw new DeskUnreachable(`the desk could not be started in the user's session yet — ${err.message} — the next ask starts it again`);
|
|
80
|
+
if (!(err instanceof Error))
|
|
81
|
+
throw err;
|
|
82
|
+
throw parkedBecause(configDir, `the desk could not be started in the user's session — ${err.message}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function parkedBecause(configDir, why) {
|
|
86
|
+
const said = `${why} — this BN process does not start it again until it restarts`;
|
|
87
|
+
parked.set(configDir, said);
|
|
88
|
+
return new DeskUnreachable(said);
|
|
89
|
+
}
|
|
90
|
+
/** What a load of the desk's own entry says in this session: a desk that dies before it listens leaves no trace in the user's session, and the same build loaded here prints why. */
|
|
91
|
+
function loadCheck() {
|
|
92
|
+
return new Promise((resolve) => {
|
|
93
|
+
execFile(process.execPath, [DESK_ENTRY, CHECK_FLAG], { encoding: "utf-8", windowsHide: true, timeout: DESK_ANSWER_MS }, (failed, _out, err) => {
|
|
94
|
+
resolve(failed === null ? "its entry loads cleanly here, so it stopped in the user's session itself" : `its entry ${DESK_ENTRY} does not load — ${(err || failed.message).trim().split(/\r?\n/).slice(0, 3).join(" ")}`);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** The desk's answer to `request`, starting the desk first when none listens; throws DeskUnreachable with why it could not be asked. */
|
|
99
|
+
async function ask(configDir, request) {
|
|
100
|
+
const first = await askOnce(configDir, request);
|
|
101
|
+
if (first !== "absent") {
|
|
102
|
+
parked.delete(configDir);
|
|
103
|
+
return answered(first);
|
|
104
|
+
}
|
|
105
|
+
const held = parked.get(configDir);
|
|
106
|
+
// NULL-OK: field held is OPTIONAL and therefore it is ok to check for NULL
|
|
107
|
+
if (held !== undefined)
|
|
108
|
+
throw new DeskUnreachable(held);
|
|
109
|
+
if (!starting.has(configDir))
|
|
110
|
+
starting.set(configDir, startAndListen(configDir).finally(() => starting.delete(configDir)));
|
|
111
|
+
await starting.get(configDir);
|
|
112
|
+
const again = await askOnce(configDir, request);
|
|
113
|
+
if (again === "absent")
|
|
114
|
+
throw new DeskUnreachable(`the desk listened on ${deskPipe(configDir)} and left before it answered`);
|
|
115
|
+
return answered(again);
|
|
116
|
+
}
|
|
117
|
+
/** Whether anything listens on the config dir's desk pipe now. */
|
|
118
|
+
function listening(configDir) {
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
const socket = connect(deskPipe(configDir));
|
|
121
|
+
socket.once("connect", () => { socket.destroy(); resolve(true); });
|
|
122
|
+
socket.once("error", () => resolve(false));
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/** Starts the desk and resolves once it listens, so every ask that found no desk waits on this one start; a desk that does not listen in time is parked with why. */
|
|
126
|
+
async function startAndListen(configDir) {
|
|
127
|
+
await startDesk(configDir);
|
|
128
|
+
const until = Date.now() + DESK_START_MS;
|
|
129
|
+
while (!(await listening(configDir))) {
|
|
130
|
+
if (Date.now() >= until)
|
|
131
|
+
throw parkedBecause(configDir, `the desk was started in the user's session but did not listen on ${deskPipe(configDir)} within ${DESK_START_MS / 1000} s — ${await loadCheck()}`);
|
|
132
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function answered(answer) {
|
|
136
|
+
// NULL-OK: field failed is OPTIONAL and therefore it is ok to check for NULL
|
|
137
|
+
if (answer.failed !== undefined)
|
|
138
|
+
throw new DeskUnreachable(answer.failed);
|
|
139
|
+
return answer;
|
|
140
|
+
}
|
|
141
|
+
/** The user's idle time where he is: the desk's reading on Windows, the session's own elsewhere; a reading that cannot be taken is "could not measure" with why, never a number. */
|
|
142
|
+
export async function idleNow(configDir) {
|
|
143
|
+
try {
|
|
144
|
+
if (process.platform === "win32")
|
|
145
|
+
return idleReading(secondsOf(await ask(configDir, { ask: "idle" })));
|
|
146
|
+
return idleReading(await sessionIdleSeconds());
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
// OWNER: the reading's producer — IdleReading's two outcomes are a number and "could not measure", which both callers (the routing and get_idle_seconds) render as given; a desk or probe that could not read is the second, with its reason
|
|
150
|
+
if (!(err instanceof Error))
|
|
151
|
+
throw err;
|
|
152
|
+
return idleUnmeasured(err.message);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function secondsOf(answer) {
|
|
156
|
+
// NULL-OK: field seconds is OPTIONAL and therefore it is ok to check for NULL
|
|
157
|
+
if (answer.seconds === undefined)
|
|
158
|
+
throw new DeskUnreachable("the desk answered the idle ask with no count of seconds");
|
|
159
|
+
return answer.seconds;
|
|
160
|
+
}
|
|
161
|
+
/** The desktop banner, drawn where the user is; throws why it could not be. */
|
|
162
|
+
export async function showBanner(configDir, title, message) {
|
|
163
|
+
if (process.platform === "win32")
|
|
164
|
+
await ask(configDir, { ask: "banner", title, message });
|
|
165
|
+
else
|
|
166
|
+
await bannerHere(title, message);
|
|
167
|
+
}
|
|
168
|
+
/** Windows: a voice file played through the desk, where the user's speakers are. */
|
|
169
|
+
export async function playVoice(configDir, file) {
|
|
170
|
+
await ask(configDir, { ask: "play", file });
|
|
171
|
+
}
|
|
172
|
+
/** macOS: ioreg's HIDIdleTime (nanoseconds); Linux: xprintidle (milliseconds). */
|
|
173
|
+
function sessionIdleSeconds() {
|
|
174
|
+
const [file, args] = process.platform === "darwin" ? ["/bin/sh", ["-c", "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'"]] : ["xprintidle", []];
|
|
175
|
+
return new Promise((resolve, reject) => {
|
|
176
|
+
execFile(file, args, { encoding: "utf-8", windowsHide: true, timeout: DESK_ANSWER_MS }, (failed, out, err) => {
|
|
177
|
+
if (failed !== null)
|
|
178
|
+
return reject(new Error(`${file} could not read the last input — ${(err || failed.message).trim()}`));
|
|
179
|
+
const value = Number(out.trim());
|
|
180
|
+
if (!Number.isInteger(value) || value < 0)
|
|
181
|
+
return reject(new Error(`${file} printed "${out.trim()}", not a count`));
|
|
182
|
+
resolve(process.platform === "darwin" ? value : Math.floor(value / 1000));
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// ── The desk itself, in the user's session ─────────────────────────────────────
|
|
187
|
+
/** GetLastInputInfo of this session, through the bundled probe. */
|
|
188
|
+
function idleSecondsHere() {
|
|
189
|
+
return new Promise((resolve, reject) => {
|
|
190
|
+
execFile("powershell", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", IDLE_PROBE], { encoding: "utf-8", windowsHide: true, cwd: tmpdir(), timeout: DESK_ANSWER_MS }, (failed, out, err) => {
|
|
191
|
+
if (failed !== null)
|
|
192
|
+
return reject(new Error(`${IDLE_PROBE} could not read the last input — ${(err || failed.message).trim()}`));
|
|
193
|
+
const seconds = Number(out.trim());
|
|
194
|
+
if (!Number.isInteger(seconds) || seconds < 0)
|
|
195
|
+
return reject(new Error(`${IDLE_PROBE} printed "${out.trim()}", not a count of seconds`));
|
|
196
|
+
resolve(seconds);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function bannerHere(title, message) {
|
|
201
|
+
return new Promise((resolve, reject) => {
|
|
202
|
+
notifier.notify({ title, message, sound: false }, (err) => (err ? reject(err) : resolve()));
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** Plays a voice file through Windows' media player and resolves once it has started. */
|
|
206
|
+
function playHere(file) {
|
|
207
|
+
const script = `Add-Type -AssemblyName presentationCore; $p = New-Object System.Windows.Media.MediaPlayer; $done = $false; Register-ObjectEvent $p MediaEnded -Action { $script:done = $true } | Out-Null; $p.Open([uri]'${file.replace(/'/g, "''")}'); $p.Play(); while (-not $done) { Start-Sleep -Milliseconds 200 }`;
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
spawn("powershell", ["-NoProfile", "-Command", script], { windowsHide: true, stdio: "ignore", cwd: tmpdir() }).once("spawn", () => resolve()).once("error", reject);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function act(request) {
|
|
213
|
+
if (request.ask === "idle")
|
|
214
|
+
return idleSecondsHere().then((seconds) => ({ seconds }));
|
|
215
|
+
if (request.ask === "banner")
|
|
216
|
+
return bannerHere(request.title, request.message).then(() => ({}));
|
|
217
|
+
return playHere(request.file).then(() => ({}));
|
|
218
|
+
}
|
|
219
|
+
/** One ask on the pipe: answered with the act's outcome; an ask from another build is answered and then this desk leaves, so the next ask starts that build's desk. */
|
|
220
|
+
function answer(socket) {
|
|
221
|
+
let line = "";
|
|
222
|
+
socket.setEncoding("utf8");
|
|
223
|
+
// OWNER: an asker that left before its answer cannot be told — the desk goes on serving the next ask
|
|
224
|
+
socket.on("error", () => socket.destroy());
|
|
225
|
+
socket.on("data", (chunk) => {
|
|
226
|
+
line += chunk;
|
|
227
|
+
if (!line.includes("\n"))
|
|
228
|
+
return;
|
|
229
|
+
let request;
|
|
230
|
+
try {
|
|
231
|
+
request = JSON.parse(line.slice(0, line.indexOf("\n")));
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
if (!(err instanceof SyntaxError))
|
|
235
|
+
throw err;
|
|
236
|
+
// OWNER: the pipe is the desk's own boundary — a line that is not an ask is answered with why, and the desk goes on serving the next ask
|
|
237
|
+
socket.end(`${JSON.stringify({ failed: `the desk was sent a line that is not an ask — ${err.message}` })}\n`);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
void act(request).then((outcome) => outcome, (failed) => {
|
|
241
|
+
// OWNER: the ask is this act's trigger root — a probe, banner or player that failed is answered to the daemon with why, and the desk goes on serving
|
|
242
|
+
if (!(failed instanceof Error))
|
|
243
|
+
throw failed;
|
|
244
|
+
return { failed: failed.message };
|
|
245
|
+
}).then((outcome) => socket.end(`${JSON.stringify(outcome)}\n`, () => {
|
|
246
|
+
if (request.version !== VERSION)
|
|
247
|
+
process.exit(0);
|
|
248
|
+
}));
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/** The desk: holds this config dir's pipe for as long as the user's session lasts and its config dir exists; a desk that finds the pipe held by another leaves, because that one serves. */
|
|
252
|
+
function serveDesk(configDir) {
|
|
253
|
+
const server = createServer(answer);
|
|
254
|
+
setInterval(() => {
|
|
255
|
+
if (!existsSync(configDir))
|
|
256
|
+
process.exit(0);
|
|
257
|
+
}, DESK_OWNER_LOOK_MS).unref();
|
|
258
|
+
server.once("error", (err) => {
|
|
259
|
+
if (err.code !== "EADDRINUSE")
|
|
260
|
+
throw err;
|
|
261
|
+
process.exit(0);
|
|
262
|
+
});
|
|
263
|
+
server.listen(deskPipe(configDir));
|
|
264
|
+
}
|
|
265
|
+
if (process.argv[2] === SERVE_FLAG)
|
|
266
|
+
serveDesk(process.argv[3]);
|
|
267
|
+
if (process.argv[2] === CHECK_FLAG)
|
|
268
|
+
process.exit(0);
|
package/dist/gateway/chatPage.js
CHANGED
|
@@ -180,14 +180,22 @@ async function signIn(notice) {
|
|
|
180
180
|
main.append(message);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
+
// GATE: how long the page waits before asking the gateway again about its sign-in after a failed check.
|
|
184
|
+
var RECHECK_MS = 3000;
|
|
183
185
|
async function resumeSignIn() {
|
|
184
186
|
var response = await fetch("/passkey/session", {headers:{authorization:"Bearer " + token}});
|
|
185
|
-
if (
|
|
187
|
+
if (response.status === 401) { signIn("Your sign-in expired or was revoked. Sign in again."); return; }
|
|
188
|
+
if (!response.ok) throw new Error("the gateway answered " + response.status);
|
|
186
189
|
var session = await response.json();
|
|
187
190
|
keep(token, session.expiresIn === null ? 0 : Date.now() + session.expiresIn * 1000);
|
|
188
191
|
home();
|
|
189
192
|
}
|
|
190
|
-
function
|
|
193
|
+
function recheckSignIn(err) {
|
|
194
|
+
show("signin", "Sign in");
|
|
195
|
+
main.append(el("div", "system", "Could not reach the gateway (" + err.message + ") — your sign-in is kept; checking again…"));
|
|
196
|
+
setTimeout(startSignIn, RECHECK_MS);
|
|
197
|
+
}
|
|
198
|
+
function startSignIn() { if (token) resumeSignIn().catch(recheckSignIn); else signIn(""); }`;
|
|
191
199
|
/**
|
|
192
200
|
* The conversations half of BN's one page: the list he manages — the table, its per-row actions and the project picker.
|
|
193
201
|
* It is carried from the deleted Conversations page (#3401) into the native CLI page because that capability lives
|
|
@@ -17,6 +17,7 @@ import { homedir } from "os";
|
|
|
17
17
|
import { dirname, join, resolve } from "path";
|
|
18
18
|
import { CliSession, endsWithTyped, folderKey, plain, sameText } from "./cliSession.js";
|
|
19
19
|
import { AgentTurnFailed } from "./provider.js";
|
|
20
|
+
import { isRootFolder, listedFolders } from "./conversations.js";
|
|
20
21
|
/** The CLI's own config folder, where its sessions and its config file live. */
|
|
21
22
|
function configDir() {
|
|
22
23
|
return process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude");
|
|
@@ -145,12 +146,15 @@ class ClaudeCliSession extends CliSession {
|
|
|
145
146
|
const hook = [{ hooks: [{ type: "http", url: `http://127.0.0.1:${hookPort()}${CLAUDE_HOOK_PATH}${this.key}` }] }];
|
|
146
147
|
const settings = JSON.stringify({ hooks: Object.fromEntries(HOOKED.map((name) => [name, hook])) });
|
|
147
148
|
sessions.set(this.key, (event) => this.hook(event));
|
|
149
|
+
// #4157 — at the workspace root no project's CLAUDE.md sits in the CLI's own folder chain, so every listed project is added and its rules loaded: the root session then routes each prompt as the project's own rules say.
|
|
150
|
+
const atRoot = isRootFolder(spec.project);
|
|
148
151
|
this.launch([
|
|
152
|
+
...(atRoot ? listedFolders().flatMap((folder) => ["--add-dir", folder]) : []),
|
|
149
153
|
...(spec.model === undefined ? [] : ["--model", spec.model]),
|
|
150
154
|
...(spec.title === undefined ? [] : ["--name", spec.title]),
|
|
151
155
|
...(this.resumes ? ["--resume", spec.sessionId] : ["--session-id", spec.sessionId]),
|
|
152
156
|
"--permission-mode", "bypassPermissions", "--disallowedTools", BN_REACHES_HIM_ON_THE_PAGE, "--settings", settings,
|
|
153
|
-
]);
|
|
157
|
+
], atRoot ? { CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: "1" } : undefined);
|
|
154
158
|
let draw;
|
|
155
159
|
this.drawn = new Promise((resolve) => { draw = resolve; });
|
|
156
160
|
this.terminal.onOutput(() => draw());
|
|
@@ -15,6 +15,7 @@ import { EventEmitter } from "events";
|
|
|
15
15
|
import { basename, dirname, join, resolve } from "path";
|
|
16
16
|
import { CONFIG_DIR, masterMuted } from "../notify.js";
|
|
17
17
|
import { PROVIDER_NAMES, providerFor } from "./providers.js";
|
|
18
|
+
import { DEFAULT_PROVIDER } from "./provider.js";
|
|
18
19
|
import { workspacesFile, workspacesHere } from "../shared/webhost/workspaceList.js";
|
|
19
20
|
/** The title the agent's session carries in Claude's session list: the project and the first request, so one session is told from another at a glance. A conversation opened with no message yet is named by its project alone. */
|
|
20
21
|
export function titleOf(meta, events) {
|
|
@@ -443,7 +444,29 @@ export function allowedProjects() {
|
|
|
443
444
|
}
|
|
444
445
|
/** The folder(s) the listed projects sit in, as a reader is told where a name resolves. */
|
|
445
446
|
export function workspaceRoot() {
|
|
446
|
-
return
|
|
447
|
+
return rootsHere().join(", ");
|
|
448
|
+
}
|
|
449
|
+
/** The folders the listed projects sit in, each once. */
|
|
450
|
+
function rootsHere() {
|
|
451
|
+
return [...new Set(projectsHere().map((p) => dirname(p.folder)))];
|
|
452
|
+
}
|
|
453
|
+
/** #4157 — the workspace root: the one folder holding every listed project, where a conversation that names no project runs, as a VS Code window with no workspace would. Listed projects spread over several folders have no one root, so a call naming no project is refused saying so. */
|
|
454
|
+
export function rootFolder() {
|
|
455
|
+
const roots = rootsHere();
|
|
456
|
+
if (roots.length !== 1)
|
|
457
|
+
throw new GatewayError(400, `no project was named and ${roots.length === 0 ? "no folder is listed" : `the listed workspaces sit in ${roots.length} folders (${roots.join(", ")})`}, so there is no one workspace root to run in — send project as exactly one of ${allowedProjects().join(", ")}`);
|
|
458
|
+
if (!existsSync(roots[0]) || !statSync(roots[0]).isDirectory())
|
|
459
|
+
throw new GatewayError(400, `the workspace root is not a folder on this machine — it is expected at ${roots[0]}`);
|
|
460
|
+
return roots[0];
|
|
461
|
+
}
|
|
462
|
+
/** Whether a folder is the workspace root. */
|
|
463
|
+
export function isRootFolder(folder) {
|
|
464
|
+
const roots = rootsHere();
|
|
465
|
+
return roots.length === 1 && sameFolder(roots[0], folder);
|
|
466
|
+
}
|
|
467
|
+
/** The listed projects' folders: what a session at the workspace root is given access to, so each project's own rules load. */
|
|
468
|
+
export function listedFolders() {
|
|
469
|
+
return projectsHere().map((p) => p.folder);
|
|
447
470
|
}
|
|
448
471
|
/** The refusal every door gives for a project outside the allowed ones. */
|
|
449
472
|
function notAllowedProject() {
|
|
@@ -461,7 +484,7 @@ function projectFolder(project) {
|
|
|
461
484
|
}
|
|
462
485
|
/** Whether a folder is one of the listed projects' folders. */
|
|
463
486
|
export function isAllowedFolder(folder) {
|
|
464
|
-
return projectsHere().some((p) => sameFolder(p.folder, folder));
|
|
487
|
+
return projectsHere().some((p) => sameFolder(p.folder, folder)) || isRootFolder(folder);
|
|
465
488
|
}
|
|
466
489
|
/** The folder an agent is about to run in, proven to be one of the allowed projects' folders: a stored or resolved path outside them is refused. */
|
|
467
490
|
export function allowedFolder(folder) {
|
|
@@ -566,12 +589,14 @@ export function resolveProject(project, text = "") {
|
|
|
566
589
|
}
|
|
567
590
|
/**
|
|
568
591
|
* The workspace a session is CREATED in, from the name its creation supplied (#3640): exactly one of the allowed project
|
|
569
|
-
* names, resolved to its folder. A creation that names none
|
|
570
|
-
*
|
|
592
|
+
* names, resolved to its folder. A creation that names none runs at the workspace root (#4157), where the root's rules
|
|
593
|
+
* route each prompt to its project — no request's own text picks a folder.
|
|
571
594
|
*/
|
|
572
595
|
export function namedProject(project) {
|
|
573
|
-
if (typeof project
|
|
574
|
-
|
|
596
|
+
if (project === undefined || (typeof project === "string" && project.trim() === ""))
|
|
597
|
+
return rootFolder();
|
|
598
|
+
if (typeof project !== "string")
|
|
599
|
+
throw new GatewayError(400, `project must be exactly one of: ${allowedProjects().join(", ")}, or left out for the workspace root`);
|
|
575
600
|
return projectFolder(project);
|
|
576
601
|
}
|
|
577
602
|
/**
|
|
@@ -584,10 +609,12 @@ export function createdFolder(project) {
|
|
|
584
609
|
throw new GatewayError(400, `a new session needs the workspace it runs in: send project as exactly one of ${allowedProjects().join(", ")}`);
|
|
585
610
|
return allowedFolder(project);
|
|
586
611
|
}
|
|
587
|
-
/** The agent CLI a session is CREATED on, from the name its creation supplied (#3640)
|
|
612
|
+
/** The agent CLI a session is CREATED on, from the name its creation supplied (#3640); a creation that names none runs on the default provider (#4157). */
|
|
588
613
|
export function namedProvider(provider) {
|
|
614
|
+
if (provider === undefined || (typeof provider === "string" && provider.trim() === ""))
|
|
615
|
+
return DEFAULT_PROVIDER;
|
|
589
616
|
if (typeof provider !== "string" || providerFor(provider) === undefined)
|
|
590
|
-
throw new GatewayError(400, `
|
|
617
|
+
throw new GatewayError(400, `provider must be exactly one of ${PROVIDER_NAMES.join(", ")}, or left out for ${DEFAULT_PROVIDER}`);
|
|
591
618
|
return provider;
|
|
592
619
|
}
|
|
593
620
|
/**
|
package/dist/gateway/mcpDoor.js
CHANGED
|
@@ -58,13 +58,13 @@ function stagedLifecycle() {
|
|
|
58
58
|
return file;
|
|
59
59
|
}
|
|
60
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(
|
|
61
|
+
const LIFECYCLE_ACTOR = "require(process.argv[1]).row().act(process.argv[2]).then(() => process.exit(0), () => process.exit(1))";
|
|
62
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
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
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
65
|
function pressLifecycle(file, press) {
|
|
66
66
|
return new Promise((resolve, reject) => {
|
|
67
|
-
const launcher = spawn(process.execPath, ["-e", LIFECYCLE_LAUNCHER, file,
|
|
67
|
+
const launcher = spawn(process.execPath, ["-e", LIFECYCLE_LAUNCHER, file, press], { stdio: "ignore", windowsHide: true });
|
|
68
68
|
launcher.once("error", (err) => reject(new GatewayError(500, `the ${press} could not be launched — ${err.message}`)));
|
|
69
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
70
|
});
|
|
@@ -90,9 +90,9 @@ function projectField(offer) {
|
|
|
90
90
|
}
|
|
91
91
|
const instructions = (offer) => `BullseyeNotify (BN) runs a Claude Code agent on this machine, with access to the user's files, git repositories, shell, MCP servers, skills and rules.
|
|
92
92
|
agent_prompt sends the user's request to that agent and returns its answer. It covers questions about the user's projects, files, code, builds and servers.
|
|
93
|
-
A NEW conversation
|
|
94
|
-
agent_open opens a conversation with no message and starts nothing: it
|
|
95
|
-
An agent
|
|
93
|
+
A NEW conversation needs no project: leave project out whatever the request is about, and the agent runs at the workspace root (${offer.under}), the folder holding every project, exactly as a VS Code window with no workspace would, loading each project's rules so it routes the request to the right project by itself — never choose a project for the user. Name a project only when the user names one: project is exactly one of ${offer.list}, never a path, and agent_projects lists them with their paths. provider is exactly one of ${PROVIDER_NAMES.join(", ")} and defaults when left out. A call that goes on with a conversation that already exists needs neither, because both were bound when it was created.
|
|
94
|
+
agent_open opens a conversation with no message and starts nothing: it takes project and provider as above, both optional, spends nothing and returns the id of a session to ask with agent_send and read with agent_wait. The folder of an existing conversation is switched with agent_project, which never starts a new agent and never makes a new conversation.
|
|
95
|
+
An agent that runs in a project works on that project: its own folder is the board it writes to, so work belonging to another project is never done from it — tell the user in one line which project the work belongs to, then start that project's own agent: agent_start with project naming the project and text carrying the request (agent_prompt with project for a quick answer), read its answer with agent_wait and relay it.
|
|
96
96
|
A request that changes a project is a Story, and the Story belongs on that project's own board: the agent of that project — this conversation's own agent when the work is this project's, the agent this conversation starts with agent_start as above when it belongs to another project — files it or joins it with the bullseye-backlog MCP server that project's folder declares, before any work is done on it. Once a Story is on the board the normal BB → FleetView workflow owns its execution and dispatches the subagents that run it, so BN stays free for the user's questions and follows the Story's progress on the board. A short read-only question or a status check is answered directly. Every agent respects the shared claim store, the one claims file this machine's doors write, so no Story is executed twice: the lane that works a Story claims it when that lane is dispatched, and a message that only names a Story — a question about it, a status check — claims nothing, so it never stands in the way of the lane that works it. The long task in the example below goes the same way: agent_start and agent_wait are how such a request is sent and read, and the Story it becomes is filed and run as above.
|
|
97
97
|
Each agent_prompt goes on with the same agent as the previous one from this connection, also when a different project is named; new=true starts a fresh agent. With no conversation named, BN also starts a fresh agent by itself when the newest agent is busy and the ask does not point at the work already under way — so the ask never waits behind that turn. An ask that does point at the work under way (a follow-up, "are you done?", "stop") goes to the agent that is doing that work, even when a later independent ask opened another agent. A stopped conversation resumes on its next message.
|
|
98
98
|
A call that finishes inside the wait returns the end of the turn itself — an answer, a failure, or stopped when the conversation was stopped — and that is shown to the user as it is. When it returns working=true the turn is still running: call agent_wait at once with the id and the after it gave, and call it again the moment each read returns, until an answer or failed event arrives, or the conversation is stopped. The events that end the turn carry kind answer, failed or stopped, so read them by kind. A question the agent asks does not end its turn: it waits on the agent's own CLI screen, a status event says so, and the user answers it there by opening the conversation in BN — a message sent meanwhile is queued behind that turn and is not the answer. The working state is not an answer and neither is a read that brought only progress events — never pass either of them to the user as one.
|
|
@@ -213,8 +213,8 @@ function buildServer(caller, base, offer) {
|
|
|
213
213
|
text: z.string().min(1).describe("The user's request, as the user wrote it"),
|
|
214
214
|
conversation: z.string().min(1).optional().describe("A 'conversation' id an earlier agent_prompt returned, to address that agent; without it the call goes on with this connection's current agent"),
|
|
215
215
|
new: z.boolean().optional().describe("true starts a fresh agent instead of going on with the current one; with a conversation named it is ignored, because that conversation is addressed as usual"),
|
|
216
|
-
project: projectField(offer).optional().describe(`The workspace of a NEW conversation: exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted.
|
|
217
|
-
provider: z.string().min(1).optional().describe(`The agent CLI a NEW conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}.
|
|
216
|
+
project: projectField(offer).optional().describe(`The workspace of a NEW conversation: exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted. Leave it out and the conversation runs at the workspace root (${offer.under}) with every project's rules, which route the request to its project; it is never taken from the request text`),
|
|
217
|
+
provider: z.string().min(1).optional().describe(`The agent CLI a NEW conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}. Leave it out for the default`),
|
|
218
218
|
model: z.string().min(1).optional(),
|
|
219
219
|
}, ({ text, conversation, new: fresh, project, provider, model }) => act(async () => {
|
|
220
220
|
const call = randomUUID().slice(0, 8);
|
|
@@ -253,13 +253,13 @@ function buildServer(caller, base, offer) {
|
|
|
253
253
|
return { ...head, working: true, waitedMs, events: others, after, next: `call agent_wait with id="${sent.id}", after=${after}, wait=${MAX_WAIT_SECONDS} until an event of kind answer, failed or stopped arrives` };
|
|
254
254
|
}));
|
|
255
255
|
server.tool("agent_projects", `The project folders on this machine (the folders under ${offer.under}), each with its absolute path and whether it is a git repository.`, {}, () => act(() => listProjects(viewerNow())));
|
|
256
|
-
server.tool("agent_start", `Creates a new conversation AND submits text as its first task (turn 1) in one call, and returns {id, state} at once without waiting for the agent. The way to run a long or autonomous task: read its progress and answer with agent_wait {id, after:1, wait:${MAX_WAIT_SECONDS}}, again with the after each reply returned, until an event of kind answer or failed with turn 1, or of kind stopped, arrives. The task is already submitted, so do not also agent_send the same text, and do not call agent_start again for it — each call starts another agent on the task. agent_prompt sends and waits in one blocking call instead.`, { project: projectField(offer).optional().describe(`The workspace this conversation runs in: exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted.
|
|
256
|
+
server.tool("agent_start", `Creates a new conversation AND submits text as its first task (turn 1) in one call, and returns {id, state} at once without waiting for the agent. The way to run a long or autonomous task: read its progress and answer with agent_wait {id, after:1, wait:${MAX_WAIT_SECONDS}}, again with the after each reply returned, until an event of kind answer or failed with turn 1, or of kind stopped, arrives. The task is already submitted, so do not also agent_send the same text, and do not call agent_start again for it — each call starts another agent on the task. agent_prompt sends and waits in one blocking call instead.`, { project: projectField(offer).optional().describe(`The workspace this conversation runs in: exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted. Leave it out and the conversation runs at the workspace root (${offer.under}) with every project's rules, which route the request to its project; it is never resolved from the text`), text: z.string().min(1).describe("The first task, submitted by this call itself"), provider: z.string().min(1).optional().describe(`The agent CLI this conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}. Leave it out for the default`), model: z.string().min(1).optional() }, ({ project, text, provider, model }) => act(() => {
|
|
257
257
|
const arrived = performance.now();
|
|
258
258
|
const arrival = arrivalOf(requestIdOf(), randomUUID().slice(0, 8));
|
|
259
259
|
const meta = startConversation({ platform: "mcp", technical: true, chat: caller, project: namedProject(project), provider: namedProvider(provider), model, text, receivedMs: Math.round(performance.now() - arrived), arrival });
|
|
260
260
|
return { id: meta.id, state: meta.state };
|
|
261
261
|
}));
|
|
262
|
-
server.tool("agent_open", `Opens a new conversation with no message and starts no agent: no text, no process started and nothing spent. It returns {id, state} at once. It names the workspace and the agent CLI the conversation opens on — project and provider are
|
|
262
|
+
server.tool("agent_open", `Opens a new conversation with no message and starts no agent: no text, no process started and nothing spent. It returns {id, state} at once. It names the workspace and the agent CLI the conversation opens on — project and provider are both optional: a conversation with no project runs at the workspace root, whose rules route each request to its project, and one with no provider runs on the default CLI. Ask it with agent_send and read it with agent_wait; the folder can be switched afterwards with agent_project, and the conversation keeps its id and its whole transcript.`, { project: projectField(offer).optional().describe(`Exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted. Leave it out for the workspace root (${offer.under}), where the rules of every project route the request; it is never resolved from anything else`), provider: z.string().min(1).optional().describe(`The agent CLI the conversation runs: exactly one of ${PROVIDER_NAMES.join(", ")}. Leave it out for the default`), model: z.string().min(1).optional() }, ({ project, provider, model }) => act(() => {
|
|
263
263
|
const meta = openConversation({ platform: "mcp", technical: true, chat: caller, project: namedProject(project), provider: namedProvider(provider), model });
|
|
264
264
|
return { id: meta.id, state: meta.state };
|
|
265
265
|
}));
|
|
@@ -324,7 +324,7 @@ function buildServer(caller, base, offer) {
|
|
|
324
324
|
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(() => (seen(id), restore ? unarchiveConversation(id) : archiveConversation(id))));
|
|
325
325
|
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(seen(id))));
|
|
326
326
|
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 ? scopedListing(await terminalListing(personId())) : (seen(id), nativeTerminal(personId(), id).info()))));
|
|
327
|
-
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
|
|
327
|
+
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 a new empty conversation is made on project (exactly one of ${offer.either}, or none for the workspace root) and provider (one of ${PROVIDER_NAMES.join(", ")}, or none for the default), with no turn and nothing spent.`, {
|
|
328
328
|
conversation: z.string().min(1).optional().describe("An existing conversation id whose own CLI to open"),
|
|
329
329
|
project: projectField(offer).optional(),
|
|
330
330
|
provider: z.string().min(1).optional(),
|
|
@@ -332,7 +332,7 @@ function buildServer(caller, base, offer) {
|
|
|
332
332
|
cols: z.number().int().min(1).max(1000).default(100),
|
|
333
333
|
rows: z.number().int().min(1).max(500).default(30),
|
|
334
334
|
}, (body) => act(() => { if (typeof body.conversation === "string")
|
|
335
|
-
seen(body.conversation.trim()); return openTerminal(body); }));
|
|
335
|
+
seen(body.conversation.trim()); return openTerminal(body, caller); }));
|
|
336
336
|
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(), seen(id))));
|
|
337
337
|
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 () => { seen(id); await nativeTerminal(personId(), id).input(data, binary); return { id, sent: true }; }));
|
|
338
338
|
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 () => { seen(id); const size = dimensions({ cols, rows }); await nativeTerminal(personId(), id).resize(size.cols, size.rows); return { id, ...size }; }));
|
|
@@ -352,7 +352,7 @@ function buildServer(caller, base, offer) {
|
|
|
352
352
|
}));
|
|
353
353
|
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 () => {
|
|
354
354
|
const file = stagedLifecycle();
|
|
355
|
-
return press === "state" ? createRequire(file)(file).row(
|
|
355
|
+
return press === "state" ? createRequire(file)(file).row().state() : pressLifecycle(file, press);
|
|
356
356
|
}));
|
|
357
357
|
return server;
|
|
358
358
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
import { createServer, request as httpRequest } from "http";
|
|
24
24
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
25
25
|
import { createMcpServer, sessionIdentity } from "../notify.js";
|
|
26
|
-
import { answerShutdown, healthBody, TAKEOVER_BIND } from "../shared/webhost/originHandover.js";
|
|
26
|
+
import { answerShutdown, healthBody, holdBuildFolder, 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
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;
|
|
@@ -155,6 +155,7 @@ export function startNotifyDoor(onBound, port = NOTIFY_DOOR_PORT, resident) {
|
|
|
155
155
|
bound = true;
|
|
156
156
|
attempting = false;
|
|
157
157
|
lastCause = "";
|
|
158
|
+
holdBuildFolder();
|
|
158
159
|
onBound(server.address().port);
|
|
159
160
|
say(`serving the chat tools on http://127.0.0.1:${server.address().port}${NOTIFY_DOOR_PATH}`);
|
|
160
161
|
});
|