omni-notify-mcp 1.3.361 → 1.3.363
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/gateway/conversations.js +70 -4
- package/dist/gateway/mcpDoor.js +48 -18
- package/dist/gateway/panelPage.js +2 -1
- package/dist/gateway/restDoor.js +7 -3
- package/dist/gateway/terminalDoor.js +17 -5
- package/dist/gateway/terminalPage.js +2 -1
- package/dist/shared/agentSession.js +38 -8
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renam
|
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
13
|
import { performance } from "perf_hooks";
|
|
14
14
|
import { EventEmitter } from "events";
|
|
15
|
-
import { basename, dirname, join } from "path";
|
|
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
18
|
import { workspacesFile, workspacesHere } from "../shared/webhost/workspaceList.js";
|
|
@@ -197,8 +197,28 @@ export function listConversations() {
|
|
|
197
197
|
.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
198
198
|
}
|
|
199
199
|
/** The conversations a door shows on one shelf, newest first; a deleted one is on neither. */
|
|
200
|
-
export function shelvedConversations(shelf) {
|
|
201
|
-
return listConversations().filter((c) => c.shelf !== "deleted" && (c.shelf === "archived") === (shelf === "archived"));
|
|
200
|
+
export function shelvedConversations(shelf, viewer) {
|
|
201
|
+
return listConversations().filter((c) => c.shelf !== "deleted" && (c.shelf === "archived") === (shelf === "archived") && inScope(c, viewer));
|
|
202
|
+
}
|
|
203
|
+
/** Whether a conversation is shown to a viewer: one in the viewer's workspace, or one the viewer itself created. */
|
|
204
|
+
export function inScope(meta, viewer) {
|
|
205
|
+
if (viewer === undefined)
|
|
206
|
+
return true;
|
|
207
|
+
// NULL-OK: field project is OPTIONAL and therefore it is ok to check for NULL
|
|
208
|
+
if (meta.project !== undefined && sameFolder(meta.project, viewer.folder))
|
|
209
|
+
return true;
|
|
210
|
+
// NULL-OK: field chat is OPTIONAL and therefore it is ok to check for NULL
|
|
211
|
+
return meta.chat !== undefined && meta.chat === viewer.creator;
|
|
212
|
+
}
|
|
213
|
+
/** A viewer is refused a conversation outside its scope in the words a missing one gets: it never learns another workspace's work exists. */
|
|
214
|
+
export function requireInScope(meta, viewer) {
|
|
215
|
+
if (!inScope(meta, viewer))
|
|
216
|
+
throw new GatewayError(404, "conversation not found in this workspace");
|
|
217
|
+
return meta;
|
|
218
|
+
}
|
|
219
|
+
/** The conversation an id names, proven to be in the viewer's scope: every door that takes an id reads it through here. */
|
|
220
|
+
export function scopedConversation(id, viewer) {
|
|
221
|
+
return requireInScope(readConversation(id), viewer);
|
|
202
222
|
}
|
|
203
223
|
/** The conversation a chat is holding — its newest one not stopped — so the chat's next message goes on with the same agent. */
|
|
204
224
|
export function openConversationOf(chat) {
|
|
@@ -449,6 +469,51 @@ export function allowedFolder(folder) {
|
|
|
449
469
|
throw notAllowedProject();
|
|
450
470
|
return folder;
|
|
451
471
|
}
|
|
472
|
+
/** The header a caller names the workspace it is scoped to in (#4120) — the one name BB, FV and BN callers carry. */
|
|
473
|
+
export const SCOPE_HEADER = "x-bullseye-project";
|
|
474
|
+
/** Whether `child` is `parent` or sits inside it. */
|
|
475
|
+
function within(child, parent) {
|
|
476
|
+
const shape = (folder) => folder.replace(/[\\/]+$/, "").replace(/[\\/]/g, "/");
|
|
477
|
+
const [c, p] = process.platform === "win32" ? [shape(child).toLowerCase(), shape(parent).toLowerCase()] : [shape(child), shape(parent)];
|
|
478
|
+
return c === p || c.startsWith(`${p}/`);
|
|
479
|
+
}
|
|
480
|
+
/** The repository a lane worktree was cut from: its `.git` file names `<repo>/.git/worktrees/<name>`. A folder with no such file is no worktree. */
|
|
481
|
+
function worktreeRepo(folder) {
|
|
482
|
+
const marker = join(folder, ".git");
|
|
483
|
+
// NULL-OK: field .git is OPTIONAL and therefore it is ok to check for NULL
|
|
484
|
+
if (!existsSync(marker) || !statSync(marker).isFile())
|
|
485
|
+
return undefined;
|
|
486
|
+
const named = /^gitdir:\s*(.+)$/m.exec(readFileSync(marker, "utf8"));
|
|
487
|
+
// NULL-OK: field gitdir is OPTIONAL and therefore it is ok to check for NULL
|
|
488
|
+
return named === null ? undefined : resolve(folder, named[1].trim(), "..", "..", "..");
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* #4120 — the listed workspace a header's folder belongs to: the folder itself, a folder inside one, or a lane worktree (under .aw-wt or anywhere) cut from a repository inside one.
|
|
492
|
+
* A folder that belongs to no listed workspace is refused without naming any other workspace's path.
|
|
493
|
+
*/
|
|
494
|
+
export function workspaceOf(named) {
|
|
495
|
+
const listed = projectsHere().map((p) => p.folder);
|
|
496
|
+
const repo = worktreeRepo(named);
|
|
497
|
+
const owner = listed.find((folder) => within(named, folder) || (repo !== undefined && within(repo, folder)));
|
|
498
|
+
// NULL-OK: field owner is OPTIONAL and therefore it is ok to check for NULL
|
|
499
|
+
if (owner === undefined)
|
|
500
|
+
throw new GatewayError(400, `the ${SCOPE_HEADER} header names a folder that belongs to no workspace on this machine's list`);
|
|
501
|
+
return owner;
|
|
502
|
+
}
|
|
503
|
+
/** Whether the conversation an id names is in the viewer's scope: a terminal whose id names no conversation is not. */
|
|
504
|
+
export function conversationInScope(id, viewer) {
|
|
505
|
+
return listConversations().some((c) => c.id === id && inScope(c, viewer));
|
|
506
|
+
}
|
|
507
|
+
/** The viewer a REST request is scoped to by its header (#4120), or undefined — the machine view — when it names none. A REST caller never creates a conversation outside its workspace, so its creator name matches nothing the MCP door stamps. */
|
|
508
|
+
export function viewerOfHeaders(headers) {
|
|
509
|
+
const raw = headers[SCOPE_HEADER];
|
|
510
|
+
const named = (Array.isArray(raw) ? raw[0] : raw)?.trim();
|
|
511
|
+
// NULL-OK: field header x-bullseye-project is OPTIONAL and therefore it is ok to check for NULL
|
|
512
|
+
if (named === undefined || named === "")
|
|
513
|
+
return undefined;
|
|
514
|
+
const folder = workspaceOf(named);
|
|
515
|
+
return { folder, creator: `rest:${folder}` };
|
|
516
|
+
}
|
|
452
517
|
/** Whether two folder paths name the same folder: a trailing separator, and on Windows letter case, do not name another folder. */
|
|
453
518
|
function sameFolder(a, b) {
|
|
454
519
|
const shape = (folder) => folder.replace(/[\\/]+$/, "").replace(/[\\/]/g, "/");
|
|
@@ -525,8 +590,9 @@ export function requireOwnCli(id) {
|
|
|
525
590
|
throw new GatewayError(409, `This conversation's agent is "${named}", which this gateway does not run, so it has no CLI to open.`);
|
|
526
591
|
}
|
|
527
592
|
/** #3849 — every listed project folder present on this machine, by name, with whether it is a Git repository and holds a board; `list` is the workspace list file they come from. */
|
|
528
|
-
export function listProjects() {
|
|
593
|
+
export function listProjects(viewer) {
|
|
529
594
|
const projects = projectsHere()
|
|
595
|
+
.filter((p) => viewer === undefined || sameFolder(p.folder, viewer.folder))
|
|
530
596
|
.filter((p) => existsSync(p.folder) && statSync(p.folder).isDirectory())
|
|
531
597
|
.map((p) => ({ name: p.name, path: p.folder, git: existsSync(join(p.folder, ".git")), board: hasBoard(p.folder) }))
|
|
532
598
|
.sort((a, b) => a.name.localeCompare(b.name));
|
package/dist/gateway/mcpDoor.js
CHANGED
|
@@ -21,7 +21,7 @@ import { performance } from "perf_hooks";
|
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
23
23
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
24
|
-
import { GatewayError, MAX_WAIT_SECONDS, archiveConversation, deleteConversation, describeConversation, lastEventNumber, listProjects, namedProject, namedProvider, openConversation, readConversation, routeAsk, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, stampWaitReturn, startConversation, stopConversation, unarchiveConversation, waitForEvents, waitForTurn, workspaceRoot, allowedProjects, requireOwnCli, } from "./conversations.js";
|
|
24
|
+
import { GatewayError, MAX_WAIT_SECONDS, archiveConversation, deleteConversation, describeConversation, lastEventNumber, listProjects, namedProject, namedProvider, openConversation, readConversation, routeAsk, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, stampWaitReturn, startConversation, stopConversation, unarchiveConversation, waitForEvents, waitForTurn, workspaceRoot, allowedProjects, requireOwnCli, scopedConversation, workspaceOf, SCOPE_HEADER, } from "./conversations.js";
|
|
25
25
|
import { workspacesFile } from "../shared/webhost/workspaceList.js";
|
|
26
26
|
import { PROVIDER_NAMES } from "./providers.js";
|
|
27
27
|
import { iconsFor } from "./iconDoor.js";
|
|
@@ -140,6 +140,11 @@ function arrivalOf(requestId, call) {
|
|
|
140
140
|
* beside the call instead of being fixed inside the server the first call built.
|
|
141
141
|
*/
|
|
142
142
|
const serving = new AsyncLocalStorage();
|
|
143
|
+
/** The workspace the POST being served is scoped to (#4120), or undefined for the machine view of a phone or the public gateway: read at call time, because a caller's server outlives the POST that built it. */
|
|
144
|
+
const viewerNow = () => serving.getStore()?.viewer;
|
|
145
|
+
/** The id of a conversation the caller may see: a scoped caller is refused another workspace's, the machine view is not asked, so a CLI console session that is no conversation still answers it. */
|
|
146
|
+
const seen = (id) => { const viewer = viewerNow(); if (viewer !== undefined)
|
|
147
|
+
scopedConversation(id, viewer); return id; };
|
|
143
148
|
/** The trace header of the POST this tool call arrived on: the call's own, never the one of the call that built the server. */
|
|
144
149
|
const requestIdOf = () => serving.getStore()?.requestId;
|
|
145
150
|
/** How many servers the door has built in this process: a caller's next POST adds none, because it takes the server its previous call left behind. */
|
|
@@ -186,6 +191,20 @@ async function consoleRead(live, after, wait) {
|
|
|
186
191
|
clearTimeout(timer);
|
|
187
192
|
}
|
|
188
193
|
}
|
|
194
|
+
/** The open terminals a viewer may see: its workspace's, and the ones of conversations it created. */
|
|
195
|
+
function scopedListing(listing) {
|
|
196
|
+
if (viewerNow() === undefined)
|
|
197
|
+
return listing;
|
|
198
|
+
return { ...listing, terminals: listing.terminals.filter((t) => { try {
|
|
199
|
+
seen(t.id);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
if (err instanceof GatewayError)
|
|
204
|
+
return false;
|
|
205
|
+
throw err;
|
|
206
|
+
} }) };
|
|
207
|
+
}
|
|
189
208
|
function buildServer(caller, base, offer) {
|
|
190
209
|
built += 1;
|
|
191
210
|
const server = new McpServer({ name: "notify-agent-gateway", version: PACKAGE_VERSION, icons: iconsFor(base) }, { instructions: instructions(offer), capabilities: EVENTS_CAPABILITY });
|
|
@@ -203,11 +222,11 @@ function buildServer(caller, base, offer) {
|
|
|
203
222
|
const arrival = arrivalOf(requestIdOf(), call);
|
|
204
223
|
process.stderr.write(`[agent-gateway] agent_prompt ${call} recv trace=${arrival.trace}\n`);
|
|
205
224
|
// NULL-OK: field conversation is OPTIONAL and therefore it is ok to check for NULL
|
|
206
|
-
const target = conversation
|
|
225
|
+
const target = conversation !== undefined ? seen(conversation) : (fresh === true ? undefined : routeAsk(caller, text)?.id);
|
|
207
226
|
// NULL-OK: field target is OPTIONAL and therefore it is ok to check for NULL
|
|
208
227
|
const sent = target === undefined
|
|
209
228
|
? { id: startConversation({ platform: "mcp", technical: true, chat: caller, project: namedProject(project), provider: namedProvider(provider), model, text, receivedMs: Math.round(performance.now() - arrived), arrival }).id, turn: 1 }
|
|
210
|
-
: { id: target, turn: sendToConversation(target, text, Math.round(performance.now() - arrived), arrival).n };
|
|
229
|
+
: { id: seen(target), turn: sendToConversation(target, text, Math.round(performance.now() - arrived), arrival).n };
|
|
211
230
|
const { events, ended, turn } = await waitForTurn(sent.id, sent.turn, MAX_WAIT_SECONDS);
|
|
212
231
|
const meta = readConversation(sent.id);
|
|
213
232
|
const reply = events.filter((e) => e.turn === turn && REPLY_FIELD[e.kind] !== undefined).at(-1);
|
|
@@ -233,7 +252,7 @@ function buildServer(caller, base, offer) {
|
|
|
233
252
|
return { ...head, stopped: true, waitedMs, events: others, after };
|
|
234
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` };
|
|
235
254
|
}));
|
|
236
|
-
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()));
|
|
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())));
|
|
237
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(() => {
|
|
238
257
|
const arrived = performance.now();
|
|
239
258
|
const arrival = arrivalOf(requestIdOf(), randomUUID().slice(0, 8));
|
|
@@ -246,7 +265,7 @@ function buildServer(caller, base, offer) {
|
|
|
246
265
|
}));
|
|
247
266
|
server.tool("agent_send", `Sends a message to a conversation that already exists (agent_start or agent_prompt made it) and returns {n} at once without waiting for the agent. n is the message's position in the log and the number of the turn it starts: read its answer with agent_wait {id, after:n, wait:${MAX_WAIT_SECONDS}}. A message sent while a turn runs is queued behind that turn, not an interrupt — also while a conversation's agent waits on a question on its own CLI screen, which the user answers there by opening the conversation in BN, never by a message to it. A stopped or archived conversation resumes. Each call submits its text once more, so do not repeat a send that returned.`, { id: z.string().min(1).describe("The conversation id agent_start returned, or the 'conversation' agent_prompt returned"), text: z.string().min(1).describe("The follow-up message; the first task belongs in agent_start") }, ({ id, text }) => act(() => {
|
|
248
267
|
const arrived = performance.now();
|
|
249
|
-
return { n: sendToConversation(id, text, Math.round(performance.now() - arrived), arrivalOf(requestIdOf(), randomUUID().slice(0, 8))).n };
|
|
268
|
+
return { n: sendToConversation(seen(id), text, Math.round(performance.now() - arrived), arrivalOf(requestIdOf(), randomUUID().slice(0, 8))).n };
|
|
250
269
|
}));
|
|
251
270
|
server.tool("agent_wait", `Reads a conversation's events past position 'after' — a long-poll read the caller repeats, not a notification BN pushes. With wait=0 (the default) it returns at once with whatever is there; with wait above 0 it holds the call until a new event arrives or the wait (at most ${MAX_WAIT_SECONDS} seconds) runs out, and an empty events list means nothing new yet. Repeat the call with the reply's after value (the position it leaves you at, a line it wrote itself included) until the turn you wait on ends: an event of kind answer or failed whose turn is that turn's number (1 after agent_start, the n agent_send returned), or an event of kind stopped. A question the agent asks does not end the turn: a status event says it waits on its own CLI screen, and the turn goes on once the user answers there. after=0 reads the log from the start, earlier turns' answers included. The state is not the end of the turn, because a conversation stays running until its idle process is freed. Reading sends nothing, so it is always safe to call again. Each answer or failed event carries its timing, in which a reply's time is three separate figures rather than one number: bnMs, the end-to-end elapsed time from the request arriving at BN's door to the answer being stored; queuedMs (beside queued, whether it stood in line at all — false is the store's own statement that it never stood in line, absent is unmeasured), the part of it the message waited for a free slot or the turn ahead; and agentMs, the part the agent itself worked. totalMs is BN's own total from the message being stored to the answer being stored, never the agent's time, and rows carries the turn layer by layer.`, { id: z.string().min(1), after: z.number().int().min(0).default(0).describe("The last event position n already read; events past it are returned. 1 right after agent_start, the n agent_send returned after a send"), wait: z.number().min(0).default(0).describe(`Seconds to hold the call for a new event, capped at ${MAX_WAIT_SECONDS}; 0 returns at once`) }, ({ id, after, wait }) => {
|
|
252
271
|
const arrived = performance.now();
|
|
@@ -257,6 +276,7 @@ function buildServer(caller, base, offer) {
|
|
|
257
276
|
};
|
|
258
277
|
return act(async () => {
|
|
259
278
|
try {
|
|
279
|
+
seen(id);
|
|
260
280
|
const arrivedAt = lastEventNumber(id);
|
|
261
281
|
const events = await waitForEvents(id, after, wait);
|
|
262
282
|
const last = events.at(-1);
|
|
@@ -274,9 +294,10 @@ function buildServer(caller, base, offer) {
|
|
|
274
294
|
}
|
|
275
295
|
}).then((result) => { row(outcome ?? `refused why=${result.content[0]?.text ?? "the call was refused"}`); return result; }, (err) => { row(outcome ?? `refused why=${err instanceof Error ? err.message : String(err)}`); throw err; });
|
|
276
296
|
});
|
|
277
|
-
server.tool("agent_project", `Sets or switches the project folder a conversation's agent works in — before its first message, or between any two turns, also after work in another project. The next turn's agent runs in that folder and writes to its board, while the conversation's id, its whole transcript and the agent itself stay: the same session carries on in the new folder with its earlier turns in hand, so this NEVER starts a new agent and never makes a new conversation. A switch is refused at two safe boundaries — while a turn is running, named with the running turn's number, and while a browser CLI is running the conversation's own session, because a running process is never moved under itself. Either refusal leaves the record on its old project.`, { id: z.string().min(1).describe("The conversation id agent_open or agent_start returned, or the 'conversation' agent_prompt returned"), project: projectField(offer).describe(`Exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted`) }, ({ id, project }) => act(() => setConversationProject(id, project)));
|
|
278
|
-
server.tool("agent_status", "One conversation's project (absent until one is chosen), provider, model and state, with its title (the name its session carries in Claude's session list), its lifecycle (active while a turn runs, is queued or waits on the user's answer; idle when open with no turn; completed once stopped or archived) and beside (the conversation of the same connection it was opened next to, if any).", { id: z.string().min(1) }, ({ id }) => act(() => describeConversation(
|
|
297
|
+
server.tool("agent_project", `Sets or switches the project folder a conversation's agent works in — before its first message, or between any two turns, also after work in another project. The next turn's agent runs in that folder and writes to its board, while the conversation's id, its whole transcript and the agent itself stay: the same session carries on in the new folder with its earlier turns in hand, so this NEVER starts a new agent and never makes a new conversation. A switch is refused at two safe boundaries — while a turn is running, named with the running turn's number, and while a browser CLI is running the conversation's own session, because a running process is never moved under itself. Either refusal leaves the record on its old project.`, { id: z.string().min(1).describe("The conversation id agent_open or agent_start returned, or the 'conversation' agent_prompt returned"), project: projectField(offer).describe(`Exactly one of ${offer.either}, resolved under ${offer.under}; no path is accepted`) }, ({ id, project }) => act(() => setConversationProject(seen(id), project)));
|
|
298
|
+
server.tool("agent_status", "One conversation's project (absent until one is chosen), provider, model and state, with its title (the name its session carries in Claude's session list), its lifecycle (active while a turn runs, is queued or waits on the user's answer; idle when open with no turn; completed once stopped or archived) and beside (the conversation of the same connection it was opened next to, if any).", { id: z.string().min(1) }, ({ id }) => act(() => describeConversation(scopedConversation(id, viewerNow()))));
|
|
279
299
|
server.tool("agent_stream", `Where to attach to a conversation's LIVE stream: what its agent shows AS IT HAPPENS, not only the finished reply that agent_prompt and agent_wait carry. Every conversation on claude, codex, copilot or opencode runs in ONE interactive CLI of its own — the same process the browser shows and agent_send types into — and this returns {conversation, url, after, console:true}, url being that CLI's own console output at /v1/terminals/<id>/console. Attach with a plain HTTP GET; the answer is a Server-Sent Events stream of frames {seq, ts, kind:"output", text, reset} carrying its raw screen bytes (its prompt, tool traces and any question it waits on). Reconnect with ?after=<seq> of the last frame you read and you are handed every byte past it. It is a read — it starts no agent, spends nothing and changes nothing.`, { id: z.string().min(1).describe("The conversation id agent_start, agent_prompt or agent_open returned"), after: z.number().int().min(0).optional().describe("The last frame seq you already have; the stream resumes past it") }, ({ id, after }) => act(() => {
|
|
300
|
+
seen(id);
|
|
280
301
|
requireOwnCli(id);
|
|
281
302
|
const url = new URL(`/v1/terminals/${id}/console`, base);
|
|
282
303
|
// NULL-OK: field after is OPTIONAL and therefore it is ok to check for NULL
|
|
@@ -289,6 +310,7 @@ function buildServer(caller, base, offer) {
|
|
|
289
310
|
after: z.number().int().min(0).default(0).describe("The last frame seq already read; frames past it are returned. 0 reads the stream from its start"),
|
|
290
311
|
wait: z.number().min(0).default(0).describe(`Seconds to hold the call for a new frame, capped at ${MAX_WAIT_SECONDS}; 0 returns at once`),
|
|
291
312
|
}, ({ id, after, wait }) => act(async () => {
|
|
313
|
+
seen(id);
|
|
292
314
|
requireOwnCli(id);
|
|
293
315
|
const asked = Date.now();
|
|
294
316
|
const live = liveConsole(id) ?? await consoleArriving(id, wait);
|
|
@@ -297,11 +319,11 @@ function buildServer(caller, base, offer) {
|
|
|
297
319
|
const frames = read.text === "" && !read.reset ? [] : [{ seq: read.after, ts: new Date().toISOString(), kind: "output", text: read.text, reset: read.reset }];
|
|
298
320
|
return { conversation: id, console: true, frames, seq: read.after, after: read.after };
|
|
299
321
|
}));
|
|
300
|
-
server.tool("agent_list", "Every agent conversation BN holds on this machine, newest first (conversations, not projects — agent_projects lists projects), each with its title, lifecycle (active, idle or completed) and beside as agent_status gives them. archived=true lists the archived ones instead; BN archives a conversation by itself once it has sat 15 minutes with no turn in flight, and a message to it brings it back.", { archived: z.boolean().default(false).describe("true lists the Archived conversations instead of the default list") }, ({ archived }) => act(() => ({ conversations: shelvedConversations(archived ? "archived" : "active").map(describeConversation) })));
|
|
301
|
-
server.tool("agent_stop", "Stop a conversation and free its agent; a later message resumes it.", { id: z.string().min(1) }, ({ id }) => act(() => stopConversation(id)));
|
|
302
|
-
server.tool("agent_archive", "Archive a conversation: it is stopped and moved off the default list to the Archived list with its transcript kept. agent_list archived=true shows it; a message to it (agent_send or agent_prompt) brings it back and resumes it.", { id: z.string().min(1), restore: z.boolean().default(false).describe("true moves an archived conversation back to the default list instead") }, ({ id, restore }) => act(() => (restore ? unarchiveConversation(id) : archiveConversation(id))));
|
|
303
|
-
server.tool("agent_delete", "Delete a conversation for good: a running agent is stopped first, then the conversation and its transcript are removed from BN. It cannot be undone — agent_archive keeps the transcript instead.", { id: z.string().min(1) }, ({ id }) => act(() => deleteConversation(id)));
|
|
304
|
-
server.tool("agent_terminals", "The agent CLIs this person has open on this machine (what the CLI page lists) with the CLIs New Agent can open and whether each takes a model; id names one terminal and answers only its facts. A read — it starts nothing.", { id: z.string().min(1).optional().describe("One terminal's conversation id; without it every open terminal is listed beside the CLIs New Agent offers") }, ({ id }) => act(async () => (id === undefined ? terminalListing(personId()) : nativeTerminal(personId(), id).info())));
|
|
322
|
+
server.tool("agent_list", "Every agent conversation BN holds on this machine, newest first (conversations, not projects — agent_projects lists projects), each with its title, lifecycle (active, idle or completed) and beside as agent_status gives them. archived=true lists the archived ones instead; BN archives a conversation by itself once it has sat 15 minutes with no turn in flight, and a message to it brings it back.", { archived: z.boolean().default(false).describe("true lists the Archived conversations instead of the default list") }, ({ archived }) => act(() => ({ conversations: shelvedConversations(archived ? "archived" : "active", viewerNow()).map(describeConversation) })));
|
|
323
|
+
server.tool("agent_stop", "Stop a conversation and free its agent; a later message resumes it.", { id: z.string().min(1) }, ({ id }) => act(() => stopConversation(seen(id))));
|
|
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
|
+
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
|
+
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()))));
|
|
305
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.`, {
|
|
306
328
|
conversation: z.string().min(1).optional().describe("An existing conversation id whose own CLI to open"),
|
|
307
329
|
project: projectField(offer).optional(),
|
|
@@ -309,11 +331,13 @@ function buildServer(caller, base, offer) {
|
|
|
309
331
|
model: z.string().min(1).optional(),
|
|
310
332
|
cols: z.number().int().min(1).max(1000).default(100),
|
|
311
333
|
rows: z.number().int().min(1).max(500).default(30),
|
|
312
|
-
}, (body) => act(() =>
|
|
313
|
-
|
|
314
|
-
server.tool("
|
|
315
|
-
server.tool("
|
|
334
|
+
}, (body) => act(() => { if (typeof body.conversation === "string")
|
|
335
|
+
seen(body.conversation.trim()); return openTerminal(body); }));
|
|
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
|
+
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
|
+
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 }; }));
|
|
316
339
|
server.tool("agent_terminal_files", "Hands files to a terminal's CLI as the CLI page's drop does: each file is written where the CLI can read it and its path is returned, to be named in a message. Each file is a name and its base64 contents.", { id: z.string().min(1), files: z.array(z.object({ name: z.string().min(1), data: z.string() })).min(1) }, ({ id, files }) => act(async () => {
|
|
340
|
+
seen(id);
|
|
317
341
|
if (!validFiles(files))
|
|
318
342
|
throw new GatewayError(400, "File transfer failed: expected file names and base64 contents.");
|
|
319
343
|
return { id, paths: await nativeTerminal(personId(), id).inputFiles(files) };
|
|
@@ -336,7 +360,13 @@ const ready = new Map();
|
|
|
336
360
|
export async function handleMcp(req, res) {
|
|
337
361
|
if (req.method !== "POST")
|
|
338
362
|
throw new GatewayError(405, "the MCP door takes POST only; it holds no session to stream or close");
|
|
339
|
-
const
|
|
363
|
+
const machineCaller = callerOf(req);
|
|
364
|
+
const named = headerOf(req, SCOPE_HEADER);
|
|
365
|
+
// NULL-OK: field header x-bullseye-project is OPTIONAL and therefore it is ok to check for NULL
|
|
366
|
+
const folder = named === undefined ? undefined : workspaceOf(named);
|
|
367
|
+
// The caller's name carries its workspace, so two workspaces sharing the gateway token never share a current agent or each other's created conversations.
|
|
368
|
+
const caller = folder === undefined ? machineCaller : `${machineCaller}@${folder}`;
|
|
369
|
+
const viewer = folder === undefined ? undefined : { folder, creator: caller };
|
|
340
370
|
const base = publicBase(req);
|
|
341
371
|
const pooled = ready.get(caller);
|
|
342
372
|
ready.delete(caller);
|
|
@@ -350,7 +380,7 @@ export async function handleMcp(req, res) {
|
|
|
350
380
|
void transport.close(); });
|
|
351
381
|
await server.connect(transport);
|
|
352
382
|
try {
|
|
353
|
-
await serving.run({ requestId: headerOf(req, "x-request-id") }, () => transport.handleRequest(req, res));
|
|
383
|
+
await serving.run({ requestId: headerOf(req, "x-request-id"), viewer }, () => transport.handleRequest(req, res));
|
|
354
384
|
}
|
|
355
385
|
finally {
|
|
356
386
|
answered = true;
|
|
@@ -85,7 +85,8 @@ function needSignIn(why) {
|
|
|
85
85
|
box.append(input, go);
|
|
86
86
|
}
|
|
87
87
|
async function call(method, path, body) {
|
|
88
|
-
|
|
88
|
+
function scoped(h) { var p = new URLSearchParams(location.search).get("project"); if (p !== null) h["x-bullseye-project"] = p; return h; }
|
|
89
|
+
var r = await fetch(path, { method: method, headers: scoped({ authorization: "Bearer " + token, "content-type": "application/json" }), body: body === undefined ? undefined : JSON.stringify(body) });
|
|
89
90
|
var j = await r.json().catch(function () { return {}; });
|
|
90
91
|
if (r.status === 401) { needSignIn("This sign-in was not accepted. Sign in again."); throw new Error("not signed in"); }
|
|
91
92
|
if (!r.ok) throw new Error(j.error || ("HTTP " + r.status));
|
package/dist/gateway/restDoor.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* once a passkey is enrolled the gateway token is honoured only on a request from this machine.
|
|
10
10
|
*/
|
|
11
11
|
import { createServer } from "http";
|
|
12
|
-
import { GatewayError, archiveConversation, deleteConversation, listProjects, monotonicMs, namedProject, namedProvider, openConversation, readConversation, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, startConversation, stopConversation, unarchiveConversation, waitForEvents, } from "./conversations.js";
|
|
12
|
+
import { GatewayError, archiveConversation, deleteConversation, listProjects, monotonicMs, scopedConversation, viewerOfHeaders, namedProject, namedProvider, openConversation, readConversation, requireConversationEnabled, sendToConversation, setConversationProject, shelvedConversations, startConversation, stopConversation, unarchiveConversation, waitForEvents, } from "./conversations.js";
|
|
13
13
|
import { CHAT_HEADERS } from "./chatPage.js";
|
|
14
14
|
import { isIconPath, serveIcon } from "./iconDoor.js";
|
|
15
15
|
import { handleMcp } from "./mcpDoor.js";
|
|
@@ -125,13 +125,17 @@ async function route(req, url, arrivedAt) {
|
|
|
125
125
|
}
|
|
126
126
|
// The conversation page's project picker offers the folders that hold a board (#2723), so it reads them from the one list BN resolves projects with.
|
|
127
127
|
if (resource === "projects" && parts.length === 2 && method === "GET")
|
|
128
|
-
return { status: 200, body: listProjects() };
|
|
128
|
+
return { status: 200, body: listProjects(viewerOfHeaders(req.headers)) };
|
|
129
129
|
if (resource !== "conversations")
|
|
130
130
|
throw new GatewayError(404, "unknown route");
|
|
131
131
|
requireConversationEnabled();
|
|
132
|
+
// Every route that names a conversation reads it through the caller's scope (#4120).
|
|
133
|
+
const viewer = viewerOfHeaders(req.headers);
|
|
134
|
+
if (id !== undefined && viewer !== undefined)
|
|
135
|
+
scopedConversation(id, viewer);
|
|
132
136
|
if (id === undefined) {
|
|
133
137
|
if (method === "GET")
|
|
134
|
-
return { status: 200, body: { conversations: shelvedConversations(shelfOf(url)) } };
|
|
138
|
+
return { status: 200, body: { conversations: shelvedConversations(shelfOf(url), viewer) } };
|
|
135
139
|
if (method === "POST") {
|
|
136
140
|
const body = await readJson(req);
|
|
137
141
|
const provider = namedProvider(body.provider);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketServer, WebSocket } from "ws";
|
|
2
|
-
import { GatewayError, deleteConversation, namedProject, namedProvider, openConversation, requireOwnCli, requireConversationEnabled } from "./conversations.js";
|
|
2
|
+
import { GatewayError, deleteConversation, namedProject, namedProvider, openConversation, requireOwnCli, requireConversationEnabled, scopedConversation, conversationInScope, viewerOfHeaders } from "./conversations.js";
|
|
3
3
|
import { closeNativeTerminal, consoleSession, nativeTerminal, nativeTerminals, terminalArriving } from "./nativeTerminal.js";
|
|
4
4
|
import { AgentGateway } from "../agentGateway.js";
|
|
5
5
|
import { bearer, bearerAdmitted, personId, sessionExpiresAt } from "./passkeyDoor.js";
|
|
@@ -139,6 +139,9 @@ export async function terminalConsole(req, res, url) {
|
|
|
139
139
|
throw new GatewayError(400, "after must be a non-negative whole number");
|
|
140
140
|
const disconnected = new AbortController();
|
|
141
141
|
req.on("close", () => disconnected.abort());
|
|
142
|
+
const viewer = viewerOfHeaders(req.headers);
|
|
143
|
+
if (viewer !== undefined)
|
|
144
|
+
scopedConversation(id, viewer);
|
|
142
145
|
requireOwnCli(id);
|
|
143
146
|
const running = consoleSession(id) !== undefined ? nativeTerminal(personId(), id) : undefined;
|
|
144
147
|
res.writeHead(200, { "content-type": "text/event-stream; charset=utf-8", "cache-control": "no-cache", connection: "keep-alive", "x-accel-buffering": "no" });
|
|
@@ -218,14 +221,23 @@ export async function openTerminal(body) {
|
|
|
218
221
|
export async function terminalRoute(req, url, readJson) {
|
|
219
222
|
requireConversationEnabled();
|
|
220
223
|
const owner = personId();
|
|
224
|
+
const viewer = viewerOfHeaders(req.headers);
|
|
221
225
|
const parts = url.pathname.split("/").filter(Boolean);
|
|
222
226
|
const method = req.method;
|
|
223
227
|
if (parts.length === 2) {
|
|
224
|
-
if (method === "GET")
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
if (method === "GET") {
|
|
229
|
+
const listing = await terminalListing(owner);
|
|
230
|
+
return { status: 200, body: viewer === undefined ? listing : { ...listing, terminals: listing.terminals.filter((t) => conversationInScope(t.id, viewer)) } };
|
|
231
|
+
}
|
|
232
|
+
if (method === "POST") {
|
|
233
|
+
const body = await readJson();
|
|
234
|
+
if (typeof body.conversation === "string" && viewer !== undefined)
|
|
235
|
+
scopedConversation(body.conversation.trim(), viewer);
|
|
236
|
+
return { status: 201, body: await openTerminal(body) };
|
|
237
|
+
}
|
|
228
238
|
}
|
|
239
|
+
if (viewer !== undefined)
|
|
240
|
+
scopedConversation(parts[2], viewer);
|
|
229
241
|
const terminal = nativeTerminal(owner, parts[2]);
|
|
230
242
|
if (parts.length === 3 && method === "DELETE")
|
|
231
243
|
return { status: 200, body: await closeNativeTerminal(owner, parts[2]) };
|
|
@@ -67,6 +67,7 @@ var storedStamp = ${storedStamp.toString()};
|
|
|
67
67
|
var carried=/(?:^#|&)token=([^&]+)/.exec(location.hash);
|
|
68
68
|
if(carried){token=decodeURIComponent(carried[1]);keep(token);history.replaceState(history.state,"",location.pathname+location.search);}
|
|
69
69
|
// A link may name the view to open on arrival: /terminal?view=term&id=<id> or ?view=chat&id=<id>.
|
|
70
|
+
var scope=new URLSearchParams(location.search).get("project");
|
|
70
71
|
var deepLink=new URLSearchParams(location.search);
|
|
71
72
|
if(deepLink.get("view")&&deepLink.get("id")){arrival={view:deepLink.get("view"),id:deepLink.get("id")};}
|
|
72
73
|
|
|
@@ -94,7 +95,7 @@ function show(name,heading){
|
|
|
94
95
|
return view;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
async function api(method,path,body,signal){var response=await fetch(path,{method:method,headers:{authorization:"Bearer "+token,"content-type":"application/json"},body:body===undefined?undefined:JSON.stringify(body),signal:signal});var data=await response.json();if(!response.ok){if(response.status===401)signIn("Sign in again to reach your CLI.");var error=Error(data.error||"Request failed");error.status=response.status;throw error;}return data;}
|
|
98
|
+
function scoped(h){if(scope!==null)h["x-bullseye-project"]=scope;return h}async function api(method,path,body,signal){var response=await fetch(path,{method:method,headers:scoped({authorization:"Bearer "+token,"content-type":"application/json"}),body:body===undefined?undefined:JSON.stringify(body),signal:signal});var data=await response.json();if(!response.ok){if(response.status===401)signIn("Sign in again to reach your CLI.");var error=Error(data.error||"Request failed");error.status=response.status;throw error;}return data;}
|
|
98
99
|
function fail(error){note.textContent=error.message;}
|
|
99
100
|
function ordered(id,act,body){if(!socket||socket.readyState!==WebSocket.OPEN)return;socket.send(JSON.stringify(Object.assign({kind:act},body)));}
|
|
100
101
|
/** The last folder of a path, so a row names its project without printing the whole path. */
|
|
@@ -1793,6 +1793,9 @@ export class OpenCodeTurn extends JsonlCliTurn {
|
|
|
1793
1793
|
export const STORY_QUEUE_WIRE = 1;
|
|
1794
1794
|
const PRI_ORDER = ["P0", "P1", "P2", "P3", "P4", "P5"];
|
|
1795
1795
|
const EFFORT_ORDER = ["XS", "S", "M", "L", "XL"];
|
|
1796
|
+
/** 🔴 #4116 — the act a blocked worker waits on, in words. */
|
|
1797
|
+
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
1798
|
+
export const blockedAct = (worker) => (worker.needs === undefined ? "an act its job record does not name" : worker.needs);
|
|
1796
1799
|
export const storyQueueDir = (board) => path.join(board, ".fleetview", "queue");
|
|
1797
1800
|
const requestFile = (board, id) => path.join(storyQueueDir(board), "requests", `${id}.json`);
|
|
1798
1801
|
const ackFile = (board, id) => path.join(storyQueueDir(board), "acks", `${id}.json`);
|
|
@@ -2016,6 +2019,8 @@ function placeAt(store, e, k) {
|
|
|
2016
2019
|
const step = (e, at, stage, detail) => {
|
|
2017
2020
|
e.trace.push({ at, stage, detail });
|
|
2018
2021
|
};
|
|
2022
|
+
/** The provider values a request may carry: the two the queue starts workers on, and `auto`, which it resolves to one of them at the start. */
|
|
2023
|
+
export const QUEUE_PROVIDER_CHOICES = ["claude", "codex", "auto"];
|
|
2019
2024
|
/** Why a request cannot be queued at all, or undefined: the wire version and the two fields its order is made of, checked at this boundary. */
|
|
2020
2025
|
function refusalOf(r) {
|
|
2021
2026
|
if (r.v !== STORY_QUEUE_WIRE)
|
|
@@ -2024,8 +2029,8 @@ function refusalOf(r) {
|
|
|
2024
2029
|
return `priority "${r.pri}" is none of ${PRI_ORDER.join(" ")}`;
|
|
2025
2030
|
if (rankIn(EFFORT_ORDER, r.effort) === -1)
|
|
2026
2031
|
return `size "${r.effort}" is none of ${EFFORT_ORDER.join(" ")}`;
|
|
2027
|
-
if (r.eligible &&
|
|
2028
|
-
return `provider "${r.provider}" is not started by this queue — it starts Claude workers
|
|
2032
|
+
if (r.eligible && !QUEUE_PROVIDER_CHOICES.includes(r.provider))
|
|
2033
|
+
return `provider "${r.provider}" is not started by this queue — it starts Claude workers, posts Codex-owned stories into the board's one Codex main, and starts an AUTO story on whichever of the two has subscription room`;
|
|
2029
2034
|
return undefined;
|
|
2030
2035
|
}
|
|
2031
2036
|
/** One request applied to the store: an entry made, updated, withdrawn or put back in line; answers the refusal when it cannot be queued. */
|
|
@@ -2141,7 +2146,7 @@ function afterWorker(e, now, why, retried = true) {
|
|
|
2141
2146
|
/**
|
|
2142
2147
|
* 🔴 ONE PASS OF FLEETVIEW'S STORY QUEUE ON ONE BOARD, under its lock: every request BB wrote is applied and acknowledged,
|
|
2143
2148
|
* every worker is checked (a story shipped closes its entry; a worker that ended with the story still open is started
|
|
2144
|
-
* again after its backoff), and the entries first in line are started while the
|
|
2149
|
+
* again after its backoff), and the entries first in line are started while the board runs fewer lanes than Meni's
|
|
2145
2150
|
* limit. An entry is written `starting` BEFORE its worker is launched, so a crash mid-start is found by its story on the
|
|
2146
2151
|
* next pass and never gets a second worker.
|
|
2147
2152
|
*/
|
|
@@ -2213,6 +2218,25 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2213
2218
|
e.state = "running";
|
|
2214
2219
|
step(e, now, "started", w.why);
|
|
2215
2220
|
}
|
|
2221
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
2222
|
+
if (e.worker !== undefined && ((w.blocked === true) !== (e.worker.blocked === true) || w.needs !== e.worker.needs)) {
|
|
2223
|
+
if (w.blocked === true) {
|
|
2224
|
+
e.worker.blocked = true;
|
|
2225
|
+
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
2226
|
+
if (w.needs === undefined)
|
|
2227
|
+
delete e.worker.needs;
|
|
2228
|
+
else
|
|
2229
|
+
e.worker.needs = w.needs;
|
|
2230
|
+
e.why = `its ${e.provider} worker ${e.worker.jobId} stopped and needs an act before it goes on: ${blockedAct(e.worker)}`;
|
|
2231
|
+
step(e, now, "blocked", e.why);
|
|
2232
|
+
}
|
|
2233
|
+
else {
|
|
2234
|
+
delete e.worker.blocked;
|
|
2235
|
+
delete e.worker.needs;
|
|
2236
|
+
e.why = w.why;
|
|
2237
|
+
step(e, now, "progress", `its worker ${e.worker.jobId} works again — ${w.why}`);
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2216
2240
|
if (w.progressAt !== undefined && e.worker !== undefined && w.progressAt !== e.worker.progressAt) {
|
|
2217
2241
|
if (e.worker.progressAt === undefined)
|
|
2218
2242
|
step(e, now, "progress", `its work first moved at ${new Date(w.progressAt).toISOString()}`);
|
|
@@ -2237,7 +2261,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2237
2261
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
2238
2262
|
if (e.worker !== undefined && world.worker(e, board).alive) {
|
|
2239
2263
|
e.state = "running";
|
|
2240
|
-
e.why = `its ${e.provider} worker ${e.worker.jobId} still runs, so no second worker is started`;
|
|
2264
|
+
e.why = `its ${e.worker.provider} worker ${e.worker.jobId} still runs, so no second worker is started`;
|
|
2241
2265
|
step(e, now, "started", e.why);
|
|
2242
2266
|
continue;
|
|
2243
2267
|
}
|
|
@@ -2252,7 +2276,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2252
2276
|
e.worker = sent;
|
|
2253
2277
|
save();
|
|
2254
2278
|
});
|
|
2255
|
-
e.why = `its ${e.provider} worker ${e.worker.jobId} was started`;
|
|
2279
|
+
e.why = `its ${e.worker.provider} worker ${e.worker.jobId} was started`;
|
|
2256
2280
|
step(e, Date.now(), "started", e.why);
|
|
2257
2281
|
}
|
|
2258
2282
|
catch (err) {
|
|
@@ -2265,7 +2289,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2265
2289
|
if (made.alive && made.found !== undefined) {
|
|
2266
2290
|
// OWNER: ITER/LOOP — the start answered no job id, yet the provider made the story's job: that job is the entry's worker, so no second one is started.
|
|
2267
2291
|
e.worker = made.found;
|
|
2268
|
-
e.why = `its ${
|
|
2292
|
+
e.why = `its ${made.found.provider} worker ${made.found.jobId} runs, though its start answered: ${err.message}`;
|
|
2269
2293
|
step(e, Date.now(), "started", e.why);
|
|
2270
2294
|
save();
|
|
2271
2295
|
continue;
|
|
@@ -2369,16 +2393,22 @@ const mtimeOf = (file) => {
|
|
|
2369
2393
|
/** A story worker's liveness: a `claude --bg` job whose session a live process runs, with the moment its transcript last moved. */
|
|
2370
2394
|
export function storyWorkerLiveness(worker, now, home = claudeHome()) {
|
|
2371
2395
|
const job = jobRecordOf(worker.jobId, home);
|
|
2396
|
+
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
2397
|
+
const asLastRead = worker.blocked === true ? { blocked: true, ...(worker.needs === undefined ? {} : { needs: worker.needs }) } : {};
|
|
2372
2398
|
if (job === "torn")
|
|
2373
|
-
return { alive: true, why: `its job ${worker.jobId}'s record was caught mid-rewrite, so it is read again on the next pass` };
|
|
2399
|
+
return { alive: true, ...asLastRead, why: `its job ${worker.jobId}'s record was caught mid-rewrite, so it is read again on the next pass` };
|
|
2374
2400
|
if (job === "gone")
|
|
2375
2401
|
return { alive: false, why: `its job ${worker.jobId} is no longer on Claude Code's record` };
|
|
2376
2402
|
const at = job.linkScanPath === undefined ? undefined : mtimeOf(job.linkScanPath);
|
|
2377
2403
|
const progress = at === undefined ? {} : { progressAt: at };
|
|
2378
2404
|
if (job.state === "done" || job.state === "stopped")
|
|
2379
2405
|
return { alive: false, ...progress, why: `its job ${worker.jobId} ended ${job.state}` };
|
|
2380
|
-
if (liveClaudeSessions(home).has(job.sessionId))
|
|
2406
|
+
if (liveClaudeSessions(home).has(job.sessionId)) {
|
|
2407
|
+
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
2408
|
+
if (job.state === "blocked")
|
|
2409
|
+
return { alive: true, ...progress, blocked: true, ...(job.needs === undefined ? {} : { needs: job.needs }), why: `its job ${worker.jobId} is blocked` };
|
|
2381
2410
|
return { alive: true, ...progress, why: `its job ${worker.jobId} runs as session ${job.sessionId} (${job.state})` };
|
|
2411
|
+
}
|
|
2382
2412
|
if (now - worker.startedAt < WORKER_START_GRACE_MS)
|
|
2383
2413
|
return { alive: true, ...progress, why: `its job ${worker.jobId} was started ${Math.round((now - worker.startedAt) / 1000)}s ago and its process has not recorded itself yet` };
|
|
2384
2414
|
return { alive: false, ...progress, why: `its job ${worker.jobId} reads ${job.state}, but no process on this machine runs session ${job.sessionId}` };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.363",
|
|
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",
|