omni-notify-mcp 1.3.404 → 1.3.406
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/mcpDoor.js +1 -1
- package/dist/gateway/terminalPage.js +6 -6
- package/dist/shared/agentSession.js +100 -60
- package/dist/shared/webhost/autoSwitch.cjs +2 -2
- package/dist/shared/webhost/bullseyeWebHost.js +20 -1
- package/dist/shared/webhost/webviewShim.js +82 -2
- package/package.json +1 -1
package/dist/gateway/mcpDoor.js
CHANGED
|
@@ -93,7 +93,7 @@ agent_prompt sends the user's request to that agent and returns its answer. It c
|
|
|
93
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(", ")}; left out, it is the agent CLI whose subscription has room, by DeepAgent's provider_room, subscription before any key. A call that goes on with a conversation that already exists needs neither, because both were bound when it was created.
|
|
94
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
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
|
-
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.
|
|
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. No Story is executed twice: FleetView's queue starts a Story's agent only when the live process list shows none working it, and a message that only names a Story — a question about it, a status check — starts nothing. 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.
|
|
99
99
|
Pass new=true whenever the question does not depend on the work already running: a fresh agent takes the question in a conversation of its own instead of waiting behind this connection's current turn, which can be minutes on a long one. Naming a conversation sends the call to that agent whatever new says, so to start a fresh one, pass new=true and leave conversation out.
|
|
@@ -120,7 +120,7 @@ function sizePhone(){
|
|
|
120
120
|
document.body.classList.toggle("phone",phone);document.documentElement.style.setProperty("--k",String(phoneScale));
|
|
121
121
|
if(terminal&&terminal.options.fontSize!==Math.round(15*phoneScale)){terminal.options.fontSize=Math.round(15*phoneScale);refit();}
|
|
122
122
|
}
|
|
123
|
-
var view=0,sent={},listResize=null,terminal,fitAddon,socket,reconnect,observer,arrival=null;
|
|
123
|
+
var view=0,sent={},listResize=null,terminal,fitAddon,socket,reconnect,observer,arrival=null,socketDown=false;
|
|
124
124
|
sizePhone();window.addEventListener("resize",sizePhone);
|
|
125
125
|
if(window.visualViewport){var fitKeyboard=function(){document.body.style.height=phone?visualViewport.height+"px":"";};visualViewport.addEventListener("resize",fitKeyboard);fitKeyboard();}
|
|
126
126
|
var AGENTS = ${JSON.stringify(PROVIDER_CHOICES)};
|
|
@@ -142,7 +142,7 @@ function tool(icon,label,cls){var b=el("button",cls,icon);b.append(" ",el("span"
|
|
|
142
142
|
|
|
143
143
|
function show(name,heading){
|
|
144
144
|
view++;
|
|
145
|
-
if(name!=="terminal"){window.bullseyeConnection.live();clearTimeout(reconnect);if(socket){socket.onclose=null;socket.close();socket=null;}if(observer){observer.disconnect();observer=null;}document.getElementById("keybar").hidden=true;if(terminal){terminal.dispose();terminal=null;}main.style.display="";main.style.flexDirection="";}
|
|
145
|
+
if(name!=="terminal"){socketDown=false;window.bullseyeConnection.live();clearTimeout(reconnect);if(socket){socket.onclose=null;socket.close();socket=null;}if(observer){observer.disconnect();observer=null;}document.getElementById("keybar").hidden=true;if(terminal){terminal.dispose();terminal=null;}main.style.display="";main.style.flexDirection="";}
|
|
146
146
|
title.textContent=heading;
|
|
147
147
|
var inList=name==="list";
|
|
148
148
|
btnBack.hidden=inList||name==="signin";
|
|
@@ -160,7 +160,7 @@ function show(name,heading){
|
|
|
160
160
|
return view;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
function down(what,method,path){if(method==="GET"&&path==="/v1/conversations")window.bullseyeConnection.reconnecting(what,8000);else if(method==="GET"&&path==="/v1/panel")window.bullseyeConnection.reconnecting(what,5000);else window.bullseyeConnection.disconnected(what,"this request did not go through — repeat it");}function scoped(h){if(scope!==null)h["x-bullseye-project"]=scope;return h}async function api(method,path,body,signal){var response;try{response=await fetch(path,{method:method,headers:scoped({authorization:"Bearer "+token,"content-type":"application/json"}),body:body===undefined?undefined:JSON.stringify(body),signal:signal});}catch(e){if(e.name!=="AbortError")down("the connection to the Notify service",method,path);throw e;}if(response.status>=502)down("the connection to the Notify service (HTTP "+response.status+")",method,path);else window.bullseyeConnection.live();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;}
|
|
163
|
+
function down(what,method,path){if(method==="GET"&&path==="/v1/conversations")window.bullseyeConnection.reconnecting(what,8000);else if(method==="GET"&&path==="/v1/panel")window.bullseyeConnection.reconnecting(what,5000);else window.bullseyeConnection.disconnected(what,"this request did not go through — repeat it");}function scoped(h){if(scope!==null)h["x-bullseye-project"]=scope;return h}async function api(method,path,body,signal){var response;try{response=await fetch(path,{method:method,headers:scoped({authorization:"Bearer "+token,"content-type":"application/json"}),body:body===undefined?undefined:JSON.stringify(body),signal:signal});}catch(e){if(e.name!=="AbortError")down("the connection to the Notify service",method,path);throw e;}if(response.status>=502)down("the connection to the Notify service (HTTP "+response.status+")",method,path);else if(!socketDown)window.bullseyeConnection.live();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;}
|
|
164
164
|
function fail(error){note.textContent=error.message;}
|
|
165
165
|
function ordered(id,act,body){if(!socket||socket.readyState!==WebSocket.OPEN)return;socket.send(JSON.stringify(Object.assign({kind:act},body)));}
|
|
166
166
|
/** The last folder of a path, so a row names its project without printing the whole path. */
|
|
@@ -383,10 +383,10 @@ async function cliAttach(id,origin){
|
|
|
383
383
|
term.options.disableStdin=true;
|
|
384
384
|
var ws=new WebSocket((location.protocol==="https:"?"wss://":"ws://")+location.host+"/v1/terminals/"+id+"/ws",["bn-terminal","bn-bearer."+token]);socket=ws;
|
|
385
385
|
var frames=Promise.resolve();
|
|
386
|
-
ws.onopen=function(){if(mine!==view){ws.close();return;}window.bullseyeConnection.live();term.options.disableStdin=false;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});term.focus();};
|
|
386
|
+
ws.onopen=function(){if(mine!==view){ws.close();return;}socketDown=false;window.bullseyeConnection.live();term.options.disableStdin=false;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});term.focus();};
|
|
387
387
|
ws.onmessage=function(event){frames=frames.then(async function(){if(mine!==view)return;var frame=JSON.parse(event.data);if(frame.files){fileNotice=frame.error||"Sent to CLI: "+frame.paths.join(" · ");note.textContent=fileNotice;return;}if(frame.error){note.textContent=frame.error;return;}var behind=frame.reset?term.buffer.active.baseY-term.buffer.active.viewportY:0;if(frame.reset)term.reset();await new Promise(function(done){term.write(frame.data,done);});if(mine!==view)return;if(behind>0)term.scrollLines(-behind);note.textContent=frame.provider+" · "+(phone?base(frame.project):frame.project)+(frame.ended?" · CLI ended":" · connected")+(frame.failure?" · "+frame.failure:"")+(fileNotice?" · "+fileNotice:"");}).catch(fail);};
|
|
388
|
-
ws.onclose=function(event){if(mine!==view)return;term.options.disableStdin=true;if(event.code===1000){window.bullseyeConnection.live();note.textContent="CLI ended.";return;}if(event.code===1008){window.bullseyeConnection.disconnected("the terminal connection to the CLI",event.reason+" — press Reattach or sign in again");note.textContent="Disconnected: "+event.reason+". Press Reattach or sign in again.";return;}window.bullseyeConnection.reconnecting("the terminal connection to the CLI",1000);note.textContent="Disconnected. Reattaching to the same CLI…";reconnect=setTimeout(connect,1000);};
|
|
389
|
-
ws.onerror=function(){window.bullseyeConnection.reconnecting("the terminal connection to the CLI",1000);note.textContent="Terminal connection failed. Reconnecting…";};
|
|
388
|
+
ws.onclose=function(event){if(mine!==view)return;term.options.disableStdin=true;if(event.code===1000){socketDown=false;window.bullseyeConnection.live();note.textContent="CLI ended.";return;}if(event.code===1008){socketDown=true;window.bullseyeConnection.disconnected("the terminal connection to the CLI",event.reason+" — press Reattach or sign in again");note.textContent="Disconnected: "+event.reason+". Press Reattach or sign in again.";return;}socketDown=true;window.bullseyeConnection.reconnecting("the terminal connection to the CLI",1000);note.textContent="Disconnected. Reattaching to the same CLI…";reconnect=setTimeout(connect,1000);};
|
|
389
|
+
ws.onerror=function(){socketDown=true;window.bullseyeConnection.reconnecting("the terminal connection to the CLI",1000);note.textContent="Terminal connection failed. Reconnecting…";};
|
|
390
390
|
}
|
|
391
391
|
connect();
|
|
392
392
|
}
|
|
@@ -2701,6 +2701,11 @@ function clearRefusal(e, reading) {
|
|
|
2701
2701
|
delete e.transcriptRefused;
|
|
2702
2702
|
return reading;
|
|
2703
2703
|
}
|
|
2704
|
+
/** 🔴 #4318 — whether the lane `held` names is this entry's own worker whose job record reads dead: a dead worker holds nothing, so the story is not kept from a fresh worker by it. */
|
|
2705
|
+
function holdIsItsDeadWorker(e, held, reading) {
|
|
2706
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
2707
|
+
return e.worker !== undefined && held.includes(e.worker.jobId) && !reading().alive;
|
|
2708
|
+
}
|
|
2704
2709
|
/** A board pass failed before it could select: each queued entry it held back gets one `held-back` trace step naming why, written again only when the reason changes, so a stalled entry's own trace says why it waits. */
|
|
2705
2710
|
export async function traceHeldBack(board, why, now) {
|
|
2706
2711
|
await withQueueLock(board, now, async () => {
|
|
@@ -3100,7 +3105,7 @@ function applyRequest(store, r, now) {
|
|
|
3100
3105
|
}
|
|
3101
3106
|
return undefined;
|
|
3102
3107
|
}
|
|
3103
|
-
/** 🔴 #4156 — his ⚡ Force start on an entry in line: it starts on the next pass past a ⏸ Stop
|
|
3108
|
+
/** 🔴 #4156 — his ⚡ Force start on an entry in line: it starts on the next pass past a ⏸ Stop; the request that carries it (#4177) and the queue's own ⚡ press both force it here. */
|
|
3104
3109
|
function forceEntry(e, now, by, eventAt = now) {
|
|
3105
3110
|
e.forceStartedAt = eventAt;
|
|
3106
3111
|
e.forceEventAt = eventAt;
|
|
@@ -3110,7 +3115,7 @@ function forceEntry(e, now, by, eventAt = now) {
|
|
|
3110
3115
|
e.forcedBy = by;
|
|
3111
3116
|
if (by === HIS_PRESS)
|
|
3112
3117
|
e.startPressedAt = Math.max(e.startPressedAt ?? 0, eventAt);
|
|
3113
|
-
e.why = `${by} ⚡ Force start starts it on the next pass, past a ⏸ Stop
|
|
3118
|
+
e.why = `${by} ⚡ Force start starts it on the next pass, past a ⏸ Stop`;
|
|
3114
3119
|
step(e, now, "placed", e.why);
|
|
3115
3120
|
}
|
|
3116
3121
|
/** The provider refused to start a story's worker: its own words, which the entry carries and the queue starts again on its backoff. */
|
|
@@ -3357,15 +3362,15 @@ function once(read) {
|
|
|
3357
3362
|
return () => (held ??= { value: read() }).value;
|
|
3358
3363
|
}
|
|
3359
3364
|
/**
|
|
3360
|
-
* 🔴 #4143 — a done story's
|
|
3365
|
+
* 🔴 #4143 — a done story's worker that no process holds any more is retired: a Claude one taken off Claude Code's background
|
|
3361
3366
|
* list and its conversation moved out of every history list into the archive. One still at its prompt is stopped first
|
|
3362
|
-
* ({@link idleWorker}) and one still mid-turn finishes its own last acts; a
|
|
3367
|
+
* ({@link idleWorker}) and one still mid-turn finishes its own last acts; a worker of any other provider is retired by its own provider (#4271).
|
|
3363
3368
|
* An archive cut off half-way is finished whatever its worker reads: its job is already removed, so the reading says nothing of a process,
|
|
3364
3369
|
* and its session was proven to have none before anything moved.
|
|
3365
3370
|
*/
|
|
3366
3371
|
function retireable(worker, reading, now) {
|
|
3367
3372
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3368
|
-
if (worker === undefined ||
|
|
3373
|
+
if (worker === undefined || worker.archivedAt !== undefined || !archiveDue(worker, now))
|
|
3369
3374
|
return undefined;
|
|
3370
3375
|
if (worker.archiving === true)
|
|
3371
3376
|
return worker;
|
|
@@ -3384,12 +3389,12 @@ const parkedInLine = (e) => e.state === "queued" && e.worker?.parkedAt !== undef
|
|
|
3384
3389
|
/**
|
|
3385
3390
|
* 🔴 #4234 — why a done story's archived conversations are past the days they are kept, or undefined while they are not:
|
|
3386
3391
|
* an archived worker ages from its own archive, and an entry left holding only archived sessions from the last thing that happened
|
|
3387
|
-
* to it — a refusal of its own delete is no such thing. A
|
|
3392
|
+
* to it — a refusal of its own delete is no such thing. A worker of every other provider ages the same way (#4271): a direct Codex worker's thread is deleted through Codex's own `thread/delete`, and the earlier Claude sessions a provider with no archive of its own swept are deleted with it.
|
|
3388
3393
|
*/
|
|
3389
3394
|
function agedOutWhy(e, now) {
|
|
3390
3395
|
const worker = e.worker;
|
|
3391
3396
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3392
|
-
if (worker !== undefined && worker.
|
|
3397
|
+
if (worker !== undefined && worker.provider === "claude" && worker.session === undefined && (e.archivedSessions ?? []).length === 0)
|
|
3393
3398
|
return undefined;
|
|
3394
3399
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3395
3400
|
const since = worker === undefined ? e.trace.slice().reverse().find((t) => t.stage !== "archive-refused").at : worker.archivedAt;
|
|
@@ -3413,10 +3418,23 @@ function noteArchiveRefusal(e, holder, now, why) {
|
|
|
3413
3418
|
if (last === undefined || last.why !== why)
|
|
3414
3419
|
step(e, now, "archive-refused", e.why);
|
|
3415
3420
|
}
|
|
3421
|
+
/** 🔴 #4271 — what a cold purge deleted, in words: a direct Codex worker's thread through Codex, a Claude worker's files with its earlier jobs', or nothing of a worker whose provider keeps no archive of its own — and, for the last two that are not Claude, the story's earlier Claude Code sessions whenever it had any. */
|
|
3422
|
+
function purgedWords(worker, earlier, freed) {
|
|
3423
|
+
const sessions = earlier === 0 ? "the story had no earlier Claude Code session to delete" : `the files of the story's ${earlier} earlier Claude Code session${earlier === 1 ? "" : "s"} were deleted — ${freed} bytes freed`;
|
|
3424
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3425
|
+
if (worker?.codexDirect === true)
|
|
3426
|
+
return `its archived Codex thread ${worker.jobId} was deleted through Codex${earlier === 0 ? "" : `, and ${sessions}`}`;
|
|
3427
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3428
|
+
if (worker !== undefined && worker.provider !== "claude")
|
|
3429
|
+
return `its agent keeps no archive of its own, so nothing of its worker was deleted, and ${sessions}`;
|
|
3430
|
+
return `every file they left on this box was deleted — ${freed} bytes freed`;
|
|
3431
|
+
}
|
|
3416
3432
|
/** 🔴 #4143 — what an archive or a bring-back moved, in words. */
|
|
3417
3433
|
function movedWords(moved) {
|
|
3418
3434
|
if (moved === "unknown")
|
|
3419
3435
|
return "no session of it is named on its entry or its job record, so no conversation of it could be found to move";
|
|
3436
|
+
if (moved === "no archive")
|
|
3437
|
+
return "its agent keeps no archive of its own, so nothing of it was moved";
|
|
3420
3438
|
if (moved.length === 0)
|
|
3421
3439
|
return "every file of its conversation had already been moved, or it never wrote one";
|
|
3422
3440
|
return `its ${moved.join(" and its ")} moved`;
|
|
@@ -3427,8 +3445,7 @@ const stopDue = (worker, now) => worker.stoppedAt === undefined || now >= worker
|
|
|
3427
3445
|
/**
|
|
3428
3446
|
* 🔴 ONE PASS OF FLEETVIEW'S STORY QUEUE ON ONE BOARD, under its lock: every request BB wrote is applied and acknowledged,
|
|
3429
3447
|
* every worker is checked (a story shipped closes its entry; a worker that ended with the story still open is started
|
|
3430
|
-
* again after its backoff), and every entry in line is started
|
|
3431
|
-
* never a lane count, a session count or another holder (Meni 2026-11-20). An entry is written `starting` BEFORE its worker is launched, so a crash mid-start is found by its story on the
|
|
3448
|
+
* again after its backoff), and every entry in line with no agent working its story is started. An entry is written `starting` BEFORE its worker is launched, so a crash mid-start is found by its story on the
|
|
3432
3449
|
* next pass and never gets a second worker.
|
|
3433
3450
|
*/
|
|
3434
3451
|
export async function driveStoryQueue(board, world, now) {
|
|
@@ -3469,7 +3486,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3469
3486
|
const moved = await world.restore(worker);
|
|
3470
3487
|
delete worker.archiving;
|
|
3471
3488
|
delete worker.archiveRefused;
|
|
3472
|
-
step(e, now, "restored", `its worker ${worker.jobId}'s conversation was brought back from the archive (${movedWords(moved)}), so the story's return wakes its own session`);
|
|
3489
|
+
step(e, now, "restored", `${moved === "no archive" ? `its worker ${worker.jobId} returns from the queue's archive alone (${movedWords(moved)})` : moved !== "unknown" && moved.includes("thread") ? `its worker ${worker.jobId}'s Codex thread was brought back through Codex` : `its worker ${worker.jobId}'s conversation was brought back from the archive (${movedWords(moved)})`}, so the story's return wakes its own session`);
|
|
3473
3490
|
}
|
|
3474
3491
|
catch (err) {
|
|
3475
3492
|
if (!(err instanceof WorkerNotStarted))
|
|
@@ -3492,15 +3509,15 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3492
3509
|
const whose = worker === undefined ? "its archived sessions" : `its archived worker ${worker.jobId}`;
|
|
3493
3510
|
try {
|
|
3494
3511
|
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
3495
|
-
const own = worker?.session === undefined || (e.archivedSessions ?? []).some((s) => s.id === worker.session.id) ? [] : [worker.session];
|
|
3512
|
+
const own = worker?.session === undefined || worker.provider !== "claude" || (e.archivedSessions ?? []).some((s) => s.id === worker.session.id) ? [] : [worker.session];
|
|
3513
|
+
const earlier = (e.archivedSessions ?? []).length;
|
|
3496
3514
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3497
3515
|
const freed = await world.purge([...own, ...(e.archivedSessions ?? [])], worker?.codexDirect === true ? worker.jobId : undefined);
|
|
3498
3516
|
delete e.worker;
|
|
3517
|
+
delete e.lastSession;
|
|
3499
3518
|
delete e.archivedSessions;
|
|
3500
3519
|
delete e.archiveRefused;
|
|
3501
|
-
step(e, now, "purged", worker
|
|
3502
|
-
? `${cold}, so ${whose} can never be woken again, and its archived Codex thread ${worker.jobId} was deleted through Codex`
|
|
3503
|
-
: `${cold}, so ${whose} can never be woken again, and every file they left on this box was deleted — ${freed} bytes freed`);
|
|
3520
|
+
step(e, now, "purged", `${cold}, so ${whose} can never be woken again, and ${purgedWords(worker, earlier, freed)}`);
|
|
3504
3521
|
}
|
|
3505
3522
|
catch (err) {
|
|
3506
3523
|
if (!(err instanceof WorkerNotStarted))
|
|
@@ -3600,7 +3617,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3600
3617
|
e.why = replacement.why;
|
|
3601
3618
|
if (replacement.ended) {
|
|
3602
3619
|
const held = hisOwn(e) ? undefined : autoStartHeld(board);
|
|
3603
|
-
|
|
3620
|
+
dropWorker(e);
|
|
3604
3621
|
delete e.nextTryAt;
|
|
3605
3622
|
e.state = "queued";
|
|
3606
3623
|
step(e, now, "worker-ended", replacement.why);
|
|
@@ -3868,7 +3885,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3868
3885
|
if (worker.parkedAt === undefined && w.parked.failed === true && !killedAfterWork(worker, w.parked)) {
|
|
3869
3886
|
if (e.attempts >= WORKER_ATTEMPTS || ACCOUNT_REFUSAL.test(w.why)) {
|
|
3870
3887
|
idle = idleWorker(worker, () => w, now);
|
|
3871
|
-
|
|
3888
|
+
dropWorker(e);
|
|
3872
3889
|
step(e, now, "worker-ended", w.why);
|
|
3873
3890
|
afterWorker(e, now, w.why);
|
|
3874
3891
|
break judge;
|
|
@@ -3906,7 +3923,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3906
3923
|
worker.archivedAt = now;
|
|
3907
3924
|
delete worker.archiving;
|
|
3908
3925
|
delete worker.archiveRefused;
|
|
3909
|
-
step(e, now, "archived", `its story is done and no process holds its worker ${worker.jobId}, so it left Claude Code's background list and ${movedWords(moved)} out of the history lists into the archive`);
|
|
3926
|
+
step(e, now, "archived", `its story is done and no process holds its worker ${worker.jobId}, so ${moved === "no archive" ? `it is archived on the queue alone — ${movedWords(moved)}` : `${moved !== "unknown" && moved.includes("thread") ? "its Codex thread was archived through Codex" : `it left Claude Code's background list and ${movedWords(moved)} out of the history lists into the archive`}`}`);
|
|
3910
3927
|
}
|
|
3911
3928
|
catch (err) {
|
|
3912
3929
|
if (!(err instanceof WorkerNotStarted))
|
|
@@ -3972,11 +3989,17 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3972
3989
|
continue;
|
|
3973
3990
|
}
|
|
3974
3991
|
const parked = e.worker;
|
|
3992
|
+
const held = world.heldBy(e.storyId);
|
|
3975
3993
|
const unwoken = (why) => {
|
|
3976
3994
|
const moved = e.state !== "queued";
|
|
3977
3995
|
e.state = "queued";
|
|
3978
3996
|
holdBack(e, now, "parked", why, moved, `${why} — no process runs its session, so the story waits in line and is no running worker`);
|
|
3979
3997
|
};
|
|
3998
|
+
// NULL-OK: field held is OPTIONAL and therefore it is ok to check for NULL
|
|
3999
|
+
if (held !== undefined) {
|
|
4000
|
+
unwoken(`worked by ${held}`);
|
|
4001
|
+
continue;
|
|
4002
|
+
}
|
|
3980
4003
|
const wakeHeld = heldWhy(e);
|
|
3981
4004
|
if (wakeHeld !== undefined) {
|
|
3982
4005
|
unwoken(`its worker ${parked.jobId} is parked, and ${wakeHeld}`);
|
|
@@ -3985,7 +4008,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3985
4008
|
const roomless = world.noRoomFor === undefined ? undefined : await world.noRoomFor(e);
|
|
3986
4009
|
if (roomless !== undefined) {
|
|
3987
4010
|
const moved = `its ${parked.provider} worker ${parked.jobId} is not woken: ${roomless}`;
|
|
3988
|
-
|
|
4011
|
+
dropWorker(e);
|
|
3989
4012
|
delete e.forced;
|
|
3990
4013
|
delete e.forcedBy;
|
|
3991
4014
|
step(e, now, "worker-ended", moved);
|
|
@@ -3997,7 +4020,8 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3997
4020
|
try {
|
|
3998
4021
|
const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId), worker => { e.worker = worker; save(); });
|
|
3999
4022
|
e.landedAt = now;
|
|
4000
|
-
|
|
4023
|
+
// NULL-OK: field cwd is OPTIONAL and therefore it is ok to check for NULL
|
|
4024
|
+
e.worker = { ...woken, wakes, ...(woken.provider === parked.provider && woken.jobId === parked.jobId ? keptSession(parked) : {}), ...(parked.cwd === undefined ? {} : { cwd: parked.cwd }) };
|
|
4001
4025
|
delete e.forced;
|
|
4002
4026
|
delete e.forcedBy;
|
|
4003
4027
|
if (noteCarried(e, { alive: true, why: "", carried: e.worker.carried }, now)) {
|
|
@@ -4072,7 +4096,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4072
4096
|
else {
|
|
4073
4097
|
// OWNER: ITER/LOOP — Claude Code refused to wake this story's session and no process runs it, so the worker has ended: its entry carries the provider's words and a fresh worker is started on its backoff; the next entry is read.
|
|
4074
4098
|
const why = `its ${parked.provider} worker ${parked.jobId} could not be woken: ${err.message}`;
|
|
4075
|
-
|
|
4099
|
+
dropWorker(e);
|
|
4076
4100
|
delete e.forced;
|
|
4077
4101
|
delete e.forcedBy;
|
|
4078
4102
|
step(e, now, "worker-ended", why);
|
|
@@ -4098,6 +4122,12 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4098
4122
|
e.why = `its worker ${e.worker.jobId}'s conversation is brought back from the archive on the next pass, and only then woken — never a fresh worker beside it`;
|
|
4099
4123
|
continue;
|
|
4100
4124
|
}
|
|
4125
|
+
const held = world.heldBy(e.storyId);
|
|
4126
|
+
// NULL-OK: field held is OPTIONAL and therefore it is ok to check for NULL
|
|
4127
|
+
if (held !== undefined && !holdIsItsDeadWorker(e, held, () => clearRefusal(e, world.worker(e, board)))) {
|
|
4128
|
+
holdBack(e, now, "held-back", `worked by ${held}`);
|
|
4129
|
+
continue;
|
|
4130
|
+
}
|
|
4101
4131
|
const startHeld = heldWhy(e);
|
|
4102
4132
|
if (startHeld !== undefined) {
|
|
4103
4133
|
holdBack(e, now, "held-back", startHeld);
|
|
@@ -4131,7 +4161,6 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4131
4161
|
continue;
|
|
4132
4162
|
}
|
|
4133
4163
|
}
|
|
4134
|
-
world.seat(e);
|
|
4135
4164
|
// NULL-OK: field forcedBy is OPTIONAL and therefore it is ok to check for NULL
|
|
4136
4165
|
const forcer = e.forcedBy ?? "an unrecorded presser's";
|
|
4137
4166
|
// NULL-OK: field halted is OPTIONAL and therefore it is ok to check for NULL
|
|
@@ -4145,7 +4174,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4145
4174
|
e.state = "starting";
|
|
4146
4175
|
e.attempts += 1;
|
|
4147
4176
|
delete e.accountRefused;
|
|
4148
|
-
|
|
4177
|
+
dropWorker(e);
|
|
4149
4178
|
step(e, now, "selected", `start ${e.attempts}${e.attempts > WORKER_ATTEMPTS ? ", past the attempts a story is given" : ` of ${WORKER_ATTEMPTS}`}${forced ? ` — ${forcer} ⚡ Force start, past ${forcedPast}` : ""}`);
|
|
4150
4179
|
save();
|
|
4151
4180
|
try {
|
|
@@ -4172,7 +4201,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4172
4201
|
if (err.retained !== undefined)
|
|
4173
4202
|
e.worker = err.retained;
|
|
4174
4203
|
else if (err.unsent)
|
|
4175
|
-
|
|
4204
|
+
dropWorker(e);
|
|
4176
4205
|
const made = clearRefusal(e, world.worker(e, board));
|
|
4177
4206
|
if (noteCarried(e, made, now)) {
|
|
4178
4207
|
save();
|
|
@@ -4221,8 +4250,8 @@ export class StoryPressRefused extends Error {
|
|
|
4221
4250
|
/**
|
|
4222
4251
|
* 🔴 #4156 — HIS PRESS ON ONE STORY OF FLEETVIEW'S QUEUE, under the queue's lock: ✕ Remove takes it out of the line (BullseyeBacklog's
|
|
4223
4252
|
* next new request puts it back), ↻ Retry puts a failed or retrying story back in line with its attempts reset, ⚡ Force start starts
|
|
4224
|
-
* it on the next pass past a ⏸ Stop and
|
|
4225
|
-
*
|
|
4253
|
+
* it on the next pass past a ⏸ Stop, and 🔔 Nudge ends the wait it stands on (a retry's backoff, a parked worker's wake delay). A press
|
|
4254
|
+
* that does not apply throws
|
|
4226
4255
|
* {@link StoryPressRefused}; one on a story no longer in line throws {@link NotInQueue}. Answers what it did, in words.
|
|
4227
4256
|
*/
|
|
4228
4257
|
export async function pressStory(board, storyId, press, now, by, requestHandledByOwner = false, ownerAction) {
|
|
@@ -4268,7 +4297,7 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
|
|
|
4268
4297
|
if (working)
|
|
4269
4298
|
throw new StoryPressRefused(`#${storyId} already has a worker at work, so there is nothing to force`);
|
|
4270
4299
|
forceEntry(e, now, by);
|
|
4271
|
-
did = `#${storyId} starts on the next pass, past a ⏸ Stop
|
|
4300
|
+
did = `#${storyId} starts on the next pass, past a ⏸ Stop`;
|
|
4272
4301
|
}
|
|
4273
4302
|
else if (press === "stop" || press === "kill") {
|
|
4274
4303
|
if (e.worker === undefined || !(working || parkedInLine(e) || e.worker.carried !== undefined || ownerAction !== undefined))
|
|
@@ -4302,12 +4331,12 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
|
|
|
4302
4331
|
did = `#${storyId} is tried on the next pass${afterStop}`;
|
|
4303
4332
|
}
|
|
4304
4333
|
else {
|
|
4305
|
-
throw new StoryPressRefused(`#${storyId} waits on nothing a nudge ends — it reads: ${e.why}${e.state === "queued" ? "; ⚡ Force start runs it past a ⏸ Stop
|
|
4334
|
+
throw new StoryPressRefused(`#${storyId} waits on nothing a nudge ends — it reads: ${e.why}${e.state === "queued" ? "; ⚡ Force start runs it past a ⏸ Stop" : ""}`);
|
|
4306
4335
|
}
|
|
4307
4336
|
step(e, now, "retry", e.why);
|
|
4308
4337
|
}
|
|
4309
4338
|
else {
|
|
4310
|
-
throw new StoryPressRefused(
|
|
4339
|
+
throw new StoryPressRefused(`${String(press)} is not a press FleetView's queue knows; #${storyId} reads: ${e.why}`);
|
|
4311
4340
|
}
|
|
4312
4341
|
writeStore(board, store);
|
|
4313
4342
|
writeAcks(board, store, new Map(), new Map([[e.storyId, e.requestId]]), now);
|
|
@@ -4432,7 +4461,8 @@ export async function rewakeStoryWorker(board, storyId, jobId, sessionId, messag
|
|
|
4432
4461
|
await stopStoryWorker(jobId, cli);
|
|
4433
4462
|
let woken;
|
|
4434
4463
|
try {
|
|
4435
|
-
|
|
4464
|
+
// NULL-OK: field cwd is OPTIONAL and therefore it is ok to check for NULL
|
|
4465
|
+
woken = await wakeStoryWorker(sessionId, message, parked.cwd ?? board, cli, now);
|
|
4436
4466
|
}
|
|
4437
4467
|
catch (err) {
|
|
4438
4468
|
if (!(err instanceof WorkerRefused))
|
|
@@ -4504,15 +4534,18 @@ export function claudeJobSession(jobId, home = claudeHome()) {
|
|
|
4504
4534
|
}
|
|
4505
4535
|
/** The `claude --bg` jobs on this machine started on `storyId` in `board` at or after `since`, oldest first — what a crash mid-start left behind, found by the brief's first line. */
|
|
4506
4536
|
export function claudeJobsOfStory(storyId, board, since, home = claudeHome()) {
|
|
4537
|
+
return claudeJobsWhere((job) => startedOnStory(job, storyId, board), since, home);
|
|
4538
|
+
}
|
|
4539
|
+
const startedOnStory = (job, storyId, board) => job.intent.startsWith(`Stories: #${storyId} `) && path.resolve(job.cwd).toLowerCase() === path.resolve(board).toLowerCase();
|
|
4540
|
+
/** Every `claude --bg` job on this machine whose record `matches`, created at or after `since`, oldest first; a record gone or caught mid-rewrite is not listed. */
|
|
4541
|
+
function claudeJobsWhere(matches, since, home) {
|
|
4507
4542
|
const dir = path.join(home, "jobs");
|
|
4508
4543
|
if (!fs.existsSync(dir))
|
|
4509
4544
|
return [];
|
|
4510
|
-
|
|
4511
|
-
const jobs = fs.readdirSync(dir).flatMap((id) => {
|
|
4545
|
+
return fs.readdirSync(dir).flatMap((id) => {
|
|
4512
4546
|
const job = jobRecordOf(id, home);
|
|
4513
|
-
return typeof job !== "string" && job
|
|
4514
|
-
});
|
|
4515
|
-
return jobs.filter((j) => j.at >= since).sort((a, b) => a.at - b.at).map((j) => j.id);
|
|
4547
|
+
return typeof job !== "string" && matches(job) && Date.parse(job.createdAt) >= since ? [{ id, at: Date.parse(job.createdAt) }] : [];
|
|
4548
|
+
}).sort((a, b) => a.at - b.at).map((j) => j.id);
|
|
4516
4549
|
}
|
|
4517
4550
|
/**
|
|
4518
4551
|
* #4230 — the `claude --bg` jobs on this machine launched with `--name <name>`, by the launch flags each job's own record keeps (the list `claude agents`
|
|
@@ -4540,18 +4573,14 @@ export function claudeJobsNamed(name, home = claudeHome()) {
|
|
|
4540
4573
|
}
|
|
4541
4574
|
});
|
|
4542
4575
|
}
|
|
4543
|
-
/**
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
const first = brief.split("\n")[0];
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
return fs.readdirSync(dir).filter((id) => {
|
|
4552
|
-
const job = jobRecordOf(id, home);
|
|
4553
|
-
return typeof job !== "string" && job.intent.split("\n")[0] === first;
|
|
4554
|
-
});
|
|
4576
|
+
/**
|
|
4577
|
+
* 🔴 #4143/#4337 — the story's jobs created at or after `since`, oldest first: those started on it in `board` ({@link claudeJobsOfStory}), and those in any
|
|
4578
|
+
* folder whose brief opens with the same `Stories: #N — <title>` line as `brief` — a story's job started in a worktree or a nested repo is still that story's.
|
|
4579
|
+
*/
|
|
4580
|
+
export function claudeJobsOfStoryAnywhere(entry, board, since, home = claudeHome()) {
|
|
4581
|
+
const first = entry.brief.split("\n")[0];
|
|
4582
|
+
const briefed = /^Stories: #\d+ — \S/.test(first);
|
|
4583
|
+
return claudeJobsWhere((job) => startedOnStory(job, entry.storyId, board) || (briefed && job.intent.split("\n")[0] === first), since, home);
|
|
4555
4584
|
}
|
|
4556
4585
|
// GATE: how long a just-started worker is read as alive before its process has written its own live record (1.4 s measured on HP)
|
|
4557
4586
|
export const WORKER_START_GRACE_MS = 2 * 60_000;
|
|
@@ -4566,8 +4595,15 @@ const mtimeOf = (file) => {
|
|
|
4566
4595
|
return undefined;
|
|
4567
4596
|
}
|
|
4568
4597
|
};
|
|
4598
|
+
/** 🔴 #4337 — drops the entry's worker, keeping the conversation it recorded as the story's last one, so the story's next worker reads that agent's own transcript first. */
|
|
4599
|
+
function dropWorker(e) {
|
|
4600
|
+
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
4601
|
+
if (e.worker?.session !== undefined)
|
|
4602
|
+
e.lastSession = e.worker.session;
|
|
4603
|
+
delete e.worker;
|
|
4604
|
+
}
|
|
4569
4605
|
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
4570
|
-
const keptSession = (worker) => (worker.session === undefined ? {} : { session: worker.session });
|
|
4606
|
+
const keptSession = (worker) => ({ ...(worker.session === undefined ? {} : { session: worker.session }), ...(worker.cwd === undefined ? {} : { cwd: worker.cwd }) });
|
|
4571
4607
|
/** 🔴 #4123 — a worker whose job record Claude Code no longer keeps: still the story's worker while a process runs its session or that process is inside its start grace, woken in its own session once none does and its transcript is on disk, ended when there is no session to wake. */
|
|
4572
4608
|
function goneWorker(worker, now, home) {
|
|
4573
4609
|
const gone = `its job ${worker.jobId} is no longer on Claude Code's record`;
|
|
@@ -4754,11 +4790,11 @@ export function storyWorkerLiveness(worker, now, home = claudeHome()) {
|
|
|
4754
4790
|
const BACKGROUNDED = /^backgrounded · (\S+)/m;
|
|
4755
4791
|
/** What `claude --bg --resume` adds when the session it was handed still runs, having started a second process on that session: `note: session <id> is already running in the background, so this started a copy as <copy>.` */
|
|
4756
4792
|
const STARTED_A_COPY = /session (\S+) is already running in the background, so this started a copy as ([^\s.]+)/;
|
|
4757
|
-
/** 🔴 #4123 — wakes a parked `claude --bg` session in place with `message
|
|
4758
|
-
export function wakeStoryWorker(sessionId, message,
|
|
4793
|
+
/** 🔴 #4123 — wakes a parked `claude --bg` session in place with `message`, run from `cwd`, the folder it was started in: passed no flags, Claude Code continues the same job with its own saved options. */
|
|
4794
|
+
export function wakeStoryWorker(sessionId, message, cwd, cli, now) {
|
|
4759
4795
|
return new Promise((resolve, reject) => {
|
|
4760
4796
|
fenceStart("claude", `claude --bg --resume ${sessionId}`);
|
|
4761
|
-
execFile(cli.cmd, [...cli.args, "--bg", "--resume", sessionId, message], { cwd
|
|
4797
|
+
execFile(cli.cmd, [...cli.args, "--bg", "--resume", sessionId, message], { cwd, windowsHide: true, timeout: LAUNCH_TIMEOUT_MS }, (err, stdout, stderr) => {
|
|
4762
4798
|
const said = `${stdout}${stderr}`;
|
|
4763
4799
|
const copy = STARTED_A_COPY.exec(said);
|
|
4764
4800
|
if (copy !== null) {
|
|
@@ -4953,10 +4989,15 @@ export async function retireStoryWorker(worker, cli, record, home = claudeHome()
|
|
|
4953
4989
|
* story is archived once every process of it has gone; answers what of the worker's own conversation moved.
|
|
4954
4990
|
*/
|
|
4955
4991
|
export async function retireStory(entry, board, worker, cli, record, home = claudeHome()) {
|
|
4992
|
+
await retireEarlierClaudeJobs(entry, board, worker.jobId, cli, (session) => record(session, "earlier"), home);
|
|
4993
|
+
return retireStoryWorker(worker, cli, (session) => record(session, "own"), home);
|
|
4994
|
+
}
|
|
4995
|
+
/** 🔴 #4271 — every Claude job started on a done story in `board` other than `workerJob` leaves every history list for the archive, whichever provider ran its last worker; refuses while a process of one still holds it. */
|
|
4996
|
+
export async function retireEarlierClaudeJobs(entry, board, workerJob, cli, record, home = claudeHome()) {
|
|
4956
4997
|
const storyId = entry.storyId;
|
|
4957
4998
|
const held = [];
|
|
4958
|
-
const earlier = new Set(
|
|
4959
|
-
earlier.delete(
|
|
4999
|
+
const earlier = new Set(claudeJobsOfStoryAnywhere(entry, board, 0, home));
|
|
5000
|
+
earlier.delete(workerJob);
|
|
4960
5001
|
for (const jobId of earlier) {
|
|
4961
5002
|
const job = jobRecordOf(jobId, home);
|
|
4962
5003
|
if (job !== "torn" && job !== "gone" && liveClaudeSessions(home).has(job.sessionId)) {
|
|
@@ -4966,11 +5007,10 @@ export async function retireStory(entry, board, worker, cli, record, home = clau
|
|
|
4966
5007
|
held.push(`${jobId} (${atPrompt ? "stopped at its prompt" : `still ${job.state}`})`);
|
|
4967
5008
|
continue;
|
|
4968
5009
|
}
|
|
4969
|
-
await retireStoryWorker({ provider: "claude", startedAt: 0, jobId }, cli,
|
|
5010
|
+
await retireStoryWorker({ provider: "claude", startedAt: 0, jobId }, cli, record, home);
|
|
4970
5011
|
}
|
|
4971
5012
|
if (held.length > 0)
|
|
4972
5013
|
throw new WorkerNotStarted(`an earlier job of #${storyId} still has a process — ${held.join(", ")} — so the story is archived once it has gone`);
|
|
4973
|
-
return retireStoryWorker(worker, cli, (session) => record(session, "own"), home);
|
|
4974
5014
|
}
|
|
4975
5015
|
/** 🔴 #4143 — an archived worker's conversation goes back into `projects/`, where `claude --bg --resume` finds it to wake; answers which of its files moved. */
|
|
4976
5016
|
export function restoreStoryWorker(worker, home = claudeHome()) {
|
|
@@ -5062,9 +5102,9 @@ export function purgeStoryWorker(sessions, home = claudeHome(), temp = tmpdir())
|
|
|
5062
5102
|
}
|
|
5063
5103
|
// GATE: how long a provider CLI is given to answer a worker start before the start is read as refused
|
|
5064
5104
|
const LAUNCH_TIMEOUT_MS = 60_000;
|
|
5065
|
-
/** A story's worker, started windowless in the
|
|
5066
|
-
export function launchStoryWorker(entry,
|
|
5067
|
-
return launchClaudeJob(entry.name, entry.model, workerBrief(entry),
|
|
5105
|
+
/** A story's worker, started windowless in `dir` (the story's own worktree when it has one, else the board) as a `claude --bg` session whose lifetime is the story's; `cli` is Claude Code's program as this machine runs it. */
|
|
5106
|
+
export function launchStoryWorker(entry, dir, cli, now, env) {
|
|
5107
|
+
return launchClaudeJob(entry.name, entry.model, workerBrief(entry), dir, cli, now, env);
|
|
5068
5108
|
}
|
|
5069
5109
|
const CLAUDE_MODEL = /^(default|best|inherit|opus|sonnet|haiku|fable|opusplan)(\[1m\])?$|^claude-/i;
|
|
5070
5110
|
const PINNED_MODELS = ["ANTHROPIC_SMALL_FAST_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL"];
|
|
@@ -5116,12 +5156,12 @@ export async function launchClaudeJob(name, model, brief, cwd, cli, now, env = l
|
|
|
5116
5156
|
}
|
|
5117
5157
|
/**
|
|
5118
5158
|
* 🔴 #4306 — A CODEX-OWNED STORY'S START: the box's Codex login is read, ONE native session of the story's own is opened in the
|
|
5119
|
-
*
|
|
5159
|
+
* folder `cwd` (the story's own worktree when it has one, else the board) under `name` with the daemon's own configuration and the explicitly selected `model`, and `message` is posted
|
|
5120
5160
|
* into it — never a Claude chat, a `codex exec`, a second app server or a shared carrier; `record` is handed the worker as soon
|
|
5121
5161
|
* as its identity is known and again right before the post is sent. No login is {@link WorkerRefused}; an unsent first input keeps
|
|
5122
5162
|
* that same session with its input pending; a lost answer to the sent input is {@link WorkerStartUnconfirmed}.
|
|
5123
5163
|
*/
|
|
5124
|
-
export async function postCodexStory(control,
|
|
5164
|
+
export async function postCodexStory(control, cwd, name, message, now, record, held, model) {
|
|
5125
5165
|
let submitted = false;
|
|
5126
5166
|
let worker;
|
|
5127
5167
|
try {
|
|
@@ -5129,7 +5169,7 @@ export async function postCodexStory(control, board, name, message, now, record,
|
|
|
5129
5169
|
if (!login.signedIn)
|
|
5130
5170
|
throw new WorkerRefused(login.why);
|
|
5131
5171
|
await control.daemonUp();
|
|
5132
|
-
const main = await control.startMain(
|
|
5172
|
+
const main = await control.startMain(cwd, name, held, model, made => {
|
|
5133
5173
|
worker = { provider: "codex", codexDirect: true, nativeInputPending: true, startedAt: now, jobId: made.threadId, ...(model === undefined ? {} : { nativeModel: model }) };
|
|
5134
5174
|
record(worker);
|
|
5135
5175
|
});
|
|
@@ -727,7 +727,7 @@ function readMove(home, providerId) {
|
|
|
727
727
|
return undefined;
|
|
728
728
|
const move = JSON.parse(text);
|
|
729
729
|
if (!move || typeof move.at !== "number" || typeof move.kind !== "string" || typeof move.to !== "string") {
|
|
730
|
-
throw new
|
|
730
|
+
throw new UnreadableSettings(`${file} does not record a move (${text.slice(0, 200)}) — delete it and the next move writes it again`);
|
|
731
731
|
}
|
|
732
732
|
return move;
|
|
733
733
|
}
|
|
@@ -990,7 +990,7 @@ function keyRefusalId(identityId) {
|
|
|
990
990
|
function markKeyRefused(home, identityId, reason, at = Date.now()) {
|
|
991
991
|
markRefused(home, keyRefusalId(identityId), reason, at);
|
|
992
992
|
}
|
|
993
|
-
/** A settings value the shared reader refuses because what it holds cannot be read: a login map that is no map, a comment never closed, an identity list that is no list, a record with no id, two records sharing an id. */
|
|
993
|
+
/** A settings value the shared reader refuses because what it holds cannot be read: a login map that is no map, a comment never closed, an identity list that is no list, a record with no id, two records sharing an id, a move record that is not a move. */
|
|
994
994
|
class UnreadableSettings extends Error {
|
|
995
995
|
}
|
|
996
996
|
class NoOpenCodeKey extends Error {
|
|
@@ -50,6 +50,8 @@ function recordDirectory(extension) {
|
|
|
50
50
|
const WORKSPACE_FILE = path.join(os.homedir(), ".bullseye", "webhost", "workspace.json");
|
|
51
51
|
// GATE: a workspace pick body larger than this is answered 413 and never parsed.
|
|
52
52
|
const PICK_BODY_BYTES = 4_096;
|
|
53
|
+
// GATE: a page socket is pinged this often so no tunnel or carrier idles it out; one that sent nothing (not even the browser's automatic pong) for a whole beat is ended, and its page reconnects.
|
|
54
|
+
const SOCKET_BEAT_MS = 20_000;
|
|
53
55
|
/** Whether a parsed window record carries everything an entry address to that window needs. */
|
|
54
56
|
function wholeRecord(record) {
|
|
55
57
|
return record !== null && typeof record === "object" && Number.isInteger(record.port) && /^[0-9a-f]+$/.test(String(record.token)) && typeof record.label === "string" && typeof record.extension === "string" && record.pages !== null && typeof record.pages === "object";
|
|
@@ -640,6 +642,10 @@ class Page {
|
|
|
640
642
|
socket.packed = true;
|
|
641
643
|
return;
|
|
642
644
|
}
|
|
645
|
+
if (frame !== null && frame.type === "ping") {
|
|
646
|
+
writeFrame(socket, '{"type":"pong"}');
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
643
649
|
// NULL-OK: field mirror is OPTIONAL and therefore it is ok to check for NULL
|
|
644
650
|
if (frame === null || frame.type !== "message" || this.mirror === undefined) {
|
|
645
651
|
return;
|
|
@@ -1217,7 +1223,19 @@ class WebHost {
|
|
|
1217
1223
|
socket.packed = false;
|
|
1218
1224
|
// NULL-OK: field at is OPTIONAL and therefore it is ok to check for NULL
|
|
1219
1225
|
socket.at = new URLSearchParams(url.searchParams.get("at") ?? "");
|
|
1220
|
-
|
|
1226
|
+
socket.heard = true;
|
|
1227
|
+
const beat = setInterval(() => {
|
|
1228
|
+
if (!socket.heard) {
|
|
1229
|
+
socket.destroy();
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
socket.heard = false;
|
|
1233
|
+
writeFrameWithOpcode(socket, 0x9, Buffer.alloc(0));
|
|
1234
|
+
}, SOCKET_BEAT_MS);
|
|
1235
|
+
const leave = () => {
|
|
1236
|
+
clearInterval(beat);
|
|
1237
|
+
page.sockets.delete(socket);
|
|
1238
|
+
};
|
|
1221
1239
|
page.sockets.add(socket);
|
|
1222
1240
|
// NULL-OK: field mirror is OPTIONAL and therefore it is ok to check for NULL
|
|
1223
1241
|
page.mirror?.forget();
|
|
@@ -1344,6 +1362,7 @@ function frameReader(socket, onText) {
|
|
|
1344
1362
|
let buffer = Buffer.alloc(0);
|
|
1345
1363
|
let parts = [];
|
|
1346
1364
|
return (chunk) => {
|
|
1365
|
+
socket.heard = true;
|
|
1347
1366
|
buffer = Buffer.concat([buffer, chunk]);
|
|
1348
1367
|
for (;;) {
|
|
1349
1368
|
if (buffer.length < 2) {
|
|
@@ -421,10 +421,33 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
421
421
|
|
|
422
422
|
` + PICKER_SOURCE + String.raw `
|
|
423
423
|
var WHAT = "this page's live connection to its service";
|
|
424
|
+
// GATE: one health read is abandoned after this times the square of the tries so far (capped at 8000), then asked again
|
|
425
|
+
var ANSWER_MS = 700;
|
|
426
|
+
var healthTries = 0;
|
|
427
|
+
var lastHeard = Date.now();
|
|
428
|
+
var gone = false;
|
|
429
|
+
|
|
430
|
+
function hostGone() {
|
|
431
|
+
if (gone) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
gone = true;
|
|
435
|
+
if (socket !== null) {
|
|
436
|
+
socket.close();
|
|
437
|
+
socket = null;
|
|
438
|
+
}
|
|
439
|
+
awaitHost();
|
|
440
|
+
}
|
|
424
441
|
|
|
425
442
|
function awaitHost() {
|
|
426
443
|
window.bullseyeConnection.reconnecting(WHAT, 250);
|
|
427
|
-
|
|
444
|
+
var asking = new AbortController();
|
|
445
|
+
healthTries += 1;
|
|
446
|
+
window.setTimeout(function () {
|
|
447
|
+
asking.abort();
|
|
448
|
+
}, Math.min(ANSWER_MS * healthTries * healthTries, 8000));
|
|
449
|
+
window.fetch("/__bullseye/health", { cache: "no-store", signal: asking.signal }).then(function (response) {
|
|
450
|
+
healthTries = 0;
|
|
428
451
|
if (response.ok) {
|
|
429
452
|
window.bullseyeConnection.live();
|
|
430
453
|
window.location.reload();
|
|
@@ -458,6 +481,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
458
481
|
var unpacking = Promise.resolve();
|
|
459
482
|
var unpackingCount = 0;
|
|
460
483
|
socket.addEventListener("message", function (event) {
|
|
484
|
+
lastHeard = Date.now();
|
|
461
485
|
if (typeof event.data === "string" && unpackingCount === 0) {
|
|
462
486
|
handle(event.data);
|
|
463
487
|
return;
|
|
@@ -497,7 +521,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
497
521
|
socket = null;
|
|
498
522
|
if (opened) {
|
|
499
523
|
window.bullseyeConnection.reconnecting(WHAT, 250);
|
|
500
|
-
window.setTimeout(
|
|
524
|
+
window.setTimeout(hostGone, 250);
|
|
501
525
|
return;
|
|
502
526
|
}
|
|
503
527
|
window.fetch("/__bullseye/health", { cache: "no-store" }).then(function (response) {
|
|
@@ -510,6 +534,62 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
510
534
|
});
|
|
511
535
|
}
|
|
512
536
|
|
|
537
|
+
// GATE: the page pings this often while visible; a socket a tunnel or a suspended phone tab cut sends no close, and one that hears nothing back goes to the reload path
|
|
538
|
+
var BEAT_MS = 20000;
|
|
539
|
+
// GATE: a ping sent on being seen again must come back within this, or the page treats the socket as dead; the steady beat instead ends a socket that heard nothing for a whole beat
|
|
540
|
+
var PING_ANSWER_MS = 1200;
|
|
541
|
+
|
|
542
|
+
var lastBeat = lastHeard;
|
|
543
|
+
|
|
544
|
+
function beat() {
|
|
545
|
+
if (gone || socket === null || socket.readyState !== 1) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (lastHeard < lastBeat) {
|
|
549
|
+
hostGone();
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
lastBeat = Date.now();
|
|
553
|
+
socket.send('{"type":"ping"}');
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function probe() {
|
|
557
|
+
if (gone) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (socket === null || socket.readyState === 0) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (socket.readyState !== 1) {
|
|
564
|
+
hostGone();
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
var asked = Date.now();
|
|
568
|
+
socket.send('{"type":"ping"}');
|
|
569
|
+
window.setTimeout(function () {
|
|
570
|
+
if (lastHeard < asked) {
|
|
571
|
+
hostGone();
|
|
572
|
+
}
|
|
573
|
+
}, PING_ANSWER_MS);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
window.setInterval(function () {
|
|
577
|
+
if (document.visibilityState === "visible") {
|
|
578
|
+
beat();
|
|
579
|
+
}
|
|
580
|
+
}, BEAT_MS);
|
|
581
|
+
document.addEventListener("visibilitychange", function () {
|
|
582
|
+
if (document.visibilityState === "visible") {
|
|
583
|
+
probe();
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
window.addEventListener("pageshow", function (event) {
|
|
587
|
+
if (event.persisted) {
|
|
588
|
+
probe();
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
window.addEventListener("online", probe);
|
|
592
|
+
|
|
513
593
|
window.acquireVsCodeApi = function () {
|
|
514
594
|
if (acquired) {
|
|
515
595
|
throw new Error("An instance of the VS Code API has already been acquired");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.406",
|
|
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",
|