omni-notify-mcp 1.3.372 → 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.
@@ -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 [...new Set(projectsHere().map((p) => dirname(p.folder)))].join(", ");
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 is refused here by name with what to send — nothing is ever
570
- * minted on a folder the caller did not choose, and no request's own text stands in for it.
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 !== "string" || project.trim() === "")
574
- throw new GatewayError(400, `a new session needs the workspace it runs in: send project as exactly one of ${allowedProjects().join(", ")}`);
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): nothing is minted on a provider the caller never named. */
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, `a new session needs the agent CLI it runs: send provider as exactly one of ${PROVIDER_NAMES.join(", ")}`);
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
  /**
@@ -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 names the folder it works in and the agent CLI it runs, in the same call that creates it: project and provider are both required, and a call that leaves either out is refused with what to send — nothing is ever started in a folder or on a CLI the caller did not choose. project is exactly one of ${offer.list}, under the workspace root (${offer.under}), never a path, and agent_projects lists them with their paths; provider is exactly one of ${PROVIDER_NAMES.join(", ")}. 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 names its project and provider as above, 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 works on the project it runs in: its own folder is the board it writes to, so work belonging to another project is never done from this agent — 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.
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. Required whenever this call creates one — no conversation named and no agent open to go on with, or new=true — and 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(", ")}. Required whenever this call creates one, beside project`),
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. Required here, because this call creates the conversation — 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(", ")}. Required here, beside project`), model: z.string().min(1).optional() }, ({ project, text, provider, model }) => act(() => {
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 required here, because a conversation is never minted on either without the caller choosing it. 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. Required here, because this call creates the conversation — 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(", ")}. Required here, beside project`), model: z.string().min(1).optional() }, ({ project, provider, model }) => act(() => {
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 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.`, {
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 }; }));
@@ -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
  });
@@ -144,10 +144,11 @@ async function route(req, url, arrivedAt) {
144
144
  const project = namedProject(body.project);
145
145
  // A text that is left out opens an empty conversation (#2723); one that is sent must carry something, so a blank text is still refused.
146
146
  const text = body.text === undefined ? undefined : requiredText(body, "text");
147
- // The workspace and the agent CLI are named by this call and bound by it (#3640): neither is resolved from the text and neither has a default.
147
+ // The workspace and the agent CLI are bound by this call (#3640): the text never resolves either; a call that names none runs at the workspace root on the default CLI (#4157), and a scoped caller is stamped as its creator so it still reads what it started there.
148
+ const chat = viewer?.creator;
148
149
  const meta = text === undefined
149
- ? openConversation({ platform: "rest", project, provider, model })
150
- : startConversation({ platform: "rest", project, provider, model, text, receivedMs });
150
+ ? openConversation({ platform: "rest", chat, project, provider, model })
151
+ : startConversation({ platform: "rest", chat, project, provider, model, text, receivedMs });
151
152
  return { status: 201, body: { id: meta.id, state: meta.state, receivedMs } };
152
153
  }
153
154
  }
@@ -182,12 +182,12 @@ export function nativeCatalog() {
182
182
  return PROVIDER_NAMES.map((name) => providerFor(name)).map((provider) => ({ name: provider.name, label: provider.label, model: provider.nativeArgs !== undefined }));
183
183
  }
184
184
  /** The conversation New Agent makes: an empty one on the CLI and folder the form named, with no turn and nothing spent. */
185
- function newAgent(body) {
185
+ function newAgent(body, chat) {
186
186
  const provider = providerFor(namedProvider(body.provider));
187
187
  const model = typeof body.model === "string" && body.model.trim() ? body.model.trim() : undefined;
188
188
  if (model !== undefined && !/^[a-zA-Z0-9._:/-]+$/.test(model))
189
189
  throw new GatewayError(400, "Model must be its CLI name, without spaces or shell characters.");
190
- return openConversation({ platform: "rest", project: namedProject(body.project), provider: provider.name, model }).id;
190
+ return openConversation({ platform: "rest", chat, project: namedProject(body.project), provider: provider.name, model }).id;
191
191
  }
192
192
  /** The conversation's own CLI, opened by the session driver — never a second one — once it is running, or the reason this machine could not start it. */
193
193
  async function opened(id) {
@@ -209,11 +209,11 @@ export async function terminalListing(owner) {
209
209
  return { terminals: await nativeTerminals(owner), providers: nativeCatalog() };
210
210
  }
211
211
  /** 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. */
212
- export async function openTerminal(body) {
212
+ export async function openTerminal(body, creator) {
213
213
  // New Agent makes a conversation exactly as agent_open does — it names BOTH the CLI that runs and the folder it runs
214
214
  // in (#3640), neither defaulted — and opens that conversation's own CLI, so a session the browser started and one MCP
215
215
  // started are one kind: the same driven CLI, typed into by agent_send and shown here (#3916).
216
- const terminal = typeof body.conversation === "string" && body.conversation.trim().length > 0 ? await opened(body.conversation.trim()) : await openedNew(newAgent(body));
216
+ const terminal = typeof body.conversation === "string" && body.conversation.trim().length > 0 ? await opened(body.conversation.trim()) : await openedNew(newAgent(body, creator));
217
217
  const size = dimensions(body);
218
218
  await terminal.resize(size.cols, size.rows);
219
219
  return terminal.info();
@@ -233,7 +233,7 @@ export async function terminalRoute(req, url, readJson) {
233
233
  const body = await readJson();
234
234
  if (typeof body.conversation === "string" && viewer !== undefined)
235
235
  scopedConversation(body.conversation.trim(), viewer);
236
- return { status: 201, body: await openTerminal(body) };
236
+ return { status: 201, body: await openTerminal(body, viewer?.creator) };
237
237
  }
238
238
  }
239
239
  if (viewer !== undefined)
@@ -181,23 +181,18 @@ async function newAgentView(){
181
181
  var mine=show("new","New Agent");
182
182
  var setup=el("div","setup"),provider=el("select"),project=el("select"),model=el("input"),open=el("button","go","▶ New Agent");
183
183
  provider.setAttribute("aria-label","CLI provider");project.setAttribute("aria-label","Project");model.setAttribute("aria-label","Model");model.placeholder="Model (CLI default if empty)";
184
- // Both selects open on an empty "choose" option and ▶ New Agent is pressed only once BOTH carry a real choice (#3640):
185
- // nothing is posted while either is unset, so no session is ever started in a folder or on a CLI that was not chosen,
186
- // and the notice says in plain words what is still to be chosen.
187
- var cliPlaceholder=el("option","","Choose a CLI…"),folderPlaceholder=el("option","","Choose a workspace…");
184
+ // Neither select forces a pick (#4157): no workspace runs the agent at the workspace root, where the rules of every project route each prompt, and no CLI runs the default one.
185
+ var cliPlaceholder=el("option","","Default CLI"),folderPlaceholder=el("option","","Workspace root (any project)");
188
186
  cliPlaceholder.value="";folderPlaceholder.value="";provider.append(cliPlaceholder);project.append(folderPlaceholder);
189
187
  setup.append(provider,project,model,open);main.append(setup);
190
188
  var folders=[],catalog=[];
191
189
  function sync(){
192
190
  var chosen=catalog.filter(function(entry){return entry.name===provider.value;})[0];
193
191
  model.hidden=!(chosen&&chosen.model);if(model.hidden)model.value="";
194
- var missing=[];
195
- if(catalog.length===0)missing.push("a CLI to run (this gateway lists none)");else if(provider.value==="")missing.push("the CLI to run");
196
- if(folders.length===0)missing.push("a workspace to run in (no project here holds a BACKLOG.md)");else if(project.value==="")missing.push("the workspace to run in");
197
- open.disabled=missing.length>0;
198
- note.textContent=missing.length>0
199
- ?"Choose "+missing.join(" and ")+" before starting a session."
200
- :"Starts a session with "+(chosen.label||chosen.name)+" in "+project.value+". Its conversation then opens in the same view.";
192
+ open.disabled=catalog.length===0;
193
+ note.textContent=catalog.length===0
194
+ ?"This gateway lists no CLI to run."
195
+ :"Starts a session with "+(chosen?(chosen.label||chosen.name):"the default CLI")+" "+(project.value===""?"at the workspace root, where each prompt is routed to its project":"in "+project.value)+". Its conversation then opens in the same view.";
201
196
  }
202
197
  try{var listed=await api("GET","/v1/projects");if(mine!==view)return;folders=listed.projects.filter(function(p){return p.board;});folders.forEach(function(p){var option=el("option","",p.name);option.value=p.name;project.append(option);});
203
198
  var sessions=await api("GET","/v1/terminals");if(mine!==view)return;
@@ -206,10 +201,8 @@ async function newAgentView(){
206
201
  }catch(error){fail(error);}
207
202
  provider.onchange=sync;project.onchange=sync;sync();
208
203
  open.onclick=async function(){
209
- // The one place that posts a New Agent request: an unset field is never sent for a door to fill in.
210
- if(provider.value===""||project.value===""){sync();return;}
211
204
  open.disabled=true;
212
- try{var s=await api("POST","/v1/terminals",{provider:provider.value,project:project.value,model:model.hidden?"":model.value,cols:100,rows:30});if(mine===view)swap("term",s.id);}catch(error){fail(error);open.disabled=false;}
205
+ try{var s=await api("POST","/v1/terminals",{provider:provider.value||undefined,project:project.value||undefined,model:model.hidden?"":model.value,cols:100,rows:30});if(mine===view)swap("term",s.id);}catch(error){fail(error);open.disabled=false;}
213
206
  };
214
207
  }
215
208
 
@@ -148,7 +148,7 @@ function heldAnswer(server, port) {
148
148
  async function doorAnswer(port) {
149
149
  const answer = await ask(port, "GET", "/health");
150
150
  if (!answer.ok) {
151
- return answer.refused ? { state: "nothing" } : { state: "unreadable", why: `GET /health on 127.0.0.1:${port} failed: ${answer.why}` };
151
+ return answer.refused ? { state: "nothing" } : { state: "unreadable", transient: true, why: `GET /health on 127.0.0.1:${port} failed: ${answer.why}` };
152
152
  }
153
153
  if (answer.status !== 200) {
154
154
  return { state: "unreadable", why: `127.0.0.1:${port}/health answered ${answer.status}, which is not one of our servers` };
@@ -509,6 +509,56 @@ function announceTakeover() {
509
509
  if (process.connected)
510
510
  process.send({ takeover: TAKEOVER_READY }, () => process.disconnect());
511
511
  }
512
+ const HOLD_PREFIX = ".held-by-";
513
+ const MAX_PID = 2 ** 31 - 1;
514
+ /** The version folder directly under an `extensions` directory that holds `entry` — its own, or BullseyeUber's when the entry is one of its members — or undefined when `entry` is not inside an installed extension. */
515
+ function installedFolderOf(entry) {
516
+ for (let folder = path.dirname(entry); path.dirname(folder) !== folder; folder = path.dirname(folder)) {
517
+ if (path.basename(path.dirname(folder)) === "extensions")
518
+ return folder;
519
+ }
520
+ return undefined;
521
+ }
522
+ /**
523
+ * #4159 — marks the installed version folder this process serves from with `.held-by-<pid>`, the marker prune-superseded.js already honours
524
+ * while that pid lives. An install of the next release deletes every superseded version folder, and the running service reads its page files
525
+ * from the one it started in: without the marker the install removed them and the service answered "cannot be served" until it was replaced.
526
+ * Markers of pids that have ended are removed here, so the folder never carries more than the live ones. A process that does not run from an
527
+ * installed extension (a launcher, a probe) holds nothing and writes nothing.
528
+ */
529
+ function holdBuildFolder(entry = process.argv[1], pid = process.pid) {
530
+ const folder = installedFolderOf(entry);
531
+ if (folder === undefined)
532
+ return undefined;
533
+ try {
534
+ for (const name of fs.readdirSync(folder).filter((file) => file.startsWith(HOLD_PREFIX))) {
535
+ const holder = Number(name.slice(HOLD_PREFIX.length));
536
+ if (holder !== pid && (!Number.isInteger(holder) || holder <= 0 || holder > MAX_PID || !pidAlive(holder)))
537
+ fs.rmSync(path.join(folder, name), { force: true });
538
+ }
539
+ fs.writeFileSync(path.join(folder, `${HOLD_PREFIX}${pid}`), "");
540
+ }
541
+ catch (failed) {
542
+ if (failed.syscall === undefined)
543
+ throw failed;
544
+ // OWNER: the hold protects the folder and is not what serves — a service the disk refuses it to still serves, and says what the next install may then delete.
545
+ console.error(`[bullseye] ${folder} could not be marked held by pid ${pid} (${failed.code}) — the next install's prune may delete the folder this process runs from`);
546
+ }
547
+ return folder;
548
+ }
549
+ function pidAlive(pid) {
550
+ try {
551
+ process.kill(pid, 0);
552
+ return true;
553
+ }
554
+ catch (failed) {
555
+ if (failed.code === "ESRCH")
556
+ return false;
557
+ if (failed.code === "EPERM")
558
+ return true;
559
+ throw failed;
560
+ }
561
+ }
512
562
  /** How the next release waits for the port: it retries the bind every `retryMs` and gives up once `giveUpMs` has passed since it started. */
513
563
  const TAKEOVER_BIND = { retryMs: BIND_RETRY_MS, giveUpMs: READY_BOUND_MS };
514
564
  /**
@@ -519,6 +569,11 @@ const TAKEOVER_BIND = { retryMs: BIND_RETRY_MS, giveUpMs: READY_BOUND_MS };
519
569
  * supervisor that predates the hold.
520
570
  */
521
571
  function listenWithHandover(httpServer, { server, port, version, onServing }) {
572
+ // #4159 — the build folder this process runs from is held by its pid for as long as it serves, so an install's prune-superseded.js keeps it
573
+ const serving = () => {
574
+ holdBuildFolder();
575
+ onServing();
576
+ };
522
577
  const takeover = process.argv.includes("--takeover");
523
578
  if (!takeover && holdOf(server).word === "stopped") {
524
579
  console.error(`[${server}-mcp] Meni stopped ${server} on 127.0.0.1:${port} — it stays stopped until Start or a reboot, so this process serves nothing`);
@@ -546,7 +601,7 @@ function listenWithHandover(httpServer, { server, port, version, onServing }) {
546
601
  console.error(`[${server}-mcp] takeover: waiting for 127.0.0.1:${port}, which an earlier release holds`);
547
602
  announceTakeover();
548
603
  }
549
- httpServer.once("listening", onServing);
604
+ httpServer.once("listening", serving);
550
605
  httpServer.listen(port, "127.0.0.1");
551
606
  }
552
- module.exports = { existsAsync, writeIfChangedAsync, nodeOnPath, inThisBoot, takeStartLock, bundleRelease, spawnBundle, residentLogFile, keepDoor, servedDoor, ensureResidentDoor, doorAnswer, servesUntil, healthBody, answerShutdown, announceTakeover, TAKEOVER_BIND, listenWithHandover, holdOf, holdStopped, releaseHold };
607
+ module.exports = { holdBuildFolder, existsAsync, writeIfChangedAsync, nodeOnPath, inThisBoot, takeStartLock, bundleRelease, spawnBundle, residentLogFile, keepDoor, servedDoor, ensureResidentDoor, doorAnswer, servesUntil, healthBody, answerShutdown, announceTakeover, TAKEOVER_BIND, listenWithHandover, holdOf, holdStopped, releaseHold };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.372",
3
+ "version": "1.3.374",
4
4
  "description": "Reach your AI agents from anywhere — and let them reach you. One resident process on 127.0.0.1:7475 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/daemon.js",
6
6
  "type": "module",