omni-notify-mcp 1.3.405 → 1.3.407
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 +7 -7
- package/dist/shared/agentSession.js +70 -46
- package/dist/shared/webhost/autoSwitch.cjs +2 -2
- package/dist/shared/webhost/bullseyeWebHost.js +35 -14
- package/dist/shared/webhost/webviewShim.js +125 -30
- 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 if(method==="GET"&&path.indexOf("/v1/terminals/")===0)window.bullseyeConnection.reconnecting(what,1000);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. */
|
|
@@ -382,11 +382,11 @@ async function cliAttach(id,origin){
|
|
|
382
382
|
if(mine!==view)return;
|
|
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
|
-
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();};
|
|
385
|
+
var frames=Promise.resolve(),opened=false;
|
|
386
|
+
ws.onopen=function(){if(mine!==view){ws.close();return;}opened=true;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…";if(opened){reconnect=setTimeout(connect,1000);return;}api("GET","/v1/terminals/"+id).then(function(){if(mine===view)reconnect=setTimeout(connect,1000);},function(error){if(mine!==view)return;if(error.status!==404){reconnect=setTimeout(connect,1000);return;}window.bullseyeConnection.disconnected("the terminal connection to the CLI","this CLI no longer exists — press Back to pick another");note.textContent="This CLI no longer exists. Press Back to pick another.";});};
|
|
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. */
|
|
@@ -3440,8 +3445,7 @@ const stopDue = (worker, now) => worker.stoppedAt === undefined || now >= worker
|
|
|
3440
3445
|
/**
|
|
3441
3446
|
* 🔴 ONE PASS OF FLEETVIEW'S STORY QUEUE ON ONE BOARD, under its lock: every request BB wrote is applied and acknowledged,
|
|
3442
3447
|
* every worker is checked (a story shipped closes its entry; a worker that ended with the story still open is started
|
|
3443
|
-
* again after its backoff), and every entry in line is started
|
|
3444
|
-
* 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
|
|
3445
3449
|
* next pass and never gets a second worker.
|
|
3446
3450
|
*/
|
|
3447
3451
|
export async function driveStoryQueue(board, world, now) {
|
|
@@ -3510,6 +3514,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3510
3514
|
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
3511
3515
|
const freed = await world.purge([...own, ...(e.archivedSessions ?? [])], worker?.codexDirect === true ? worker.jobId : undefined);
|
|
3512
3516
|
delete e.worker;
|
|
3517
|
+
delete e.lastSession;
|
|
3513
3518
|
delete e.archivedSessions;
|
|
3514
3519
|
delete e.archiveRefused;
|
|
3515
3520
|
step(e, now, "purged", `${cold}, so ${whose} can never be woken again, and ${purgedWords(worker, earlier, freed)}`);
|
|
@@ -3612,7 +3617,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3612
3617
|
e.why = replacement.why;
|
|
3613
3618
|
if (replacement.ended) {
|
|
3614
3619
|
const held = hisOwn(e) ? undefined : autoStartHeld(board);
|
|
3615
|
-
|
|
3620
|
+
dropWorker(e);
|
|
3616
3621
|
delete e.nextTryAt;
|
|
3617
3622
|
e.state = "queued";
|
|
3618
3623
|
step(e, now, "worker-ended", replacement.why);
|
|
@@ -3880,7 +3885,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3880
3885
|
if (worker.parkedAt === undefined && w.parked.failed === true && !killedAfterWork(worker, w.parked)) {
|
|
3881
3886
|
if (e.attempts >= WORKER_ATTEMPTS || ACCOUNT_REFUSAL.test(w.why)) {
|
|
3882
3887
|
idle = idleWorker(worker, () => w, now);
|
|
3883
|
-
|
|
3888
|
+
dropWorker(e);
|
|
3884
3889
|
step(e, now, "worker-ended", w.why);
|
|
3885
3890
|
afterWorker(e, now, w.why);
|
|
3886
3891
|
break judge;
|
|
@@ -3984,11 +3989,17 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3984
3989
|
continue;
|
|
3985
3990
|
}
|
|
3986
3991
|
const parked = e.worker;
|
|
3992
|
+
const held = world.heldBy(e.storyId);
|
|
3987
3993
|
const unwoken = (why) => {
|
|
3988
3994
|
const moved = e.state !== "queued";
|
|
3989
3995
|
e.state = "queued";
|
|
3990
3996
|
holdBack(e, now, "parked", why, moved, `${why} — no process runs its session, so the story waits in line and is no running worker`);
|
|
3991
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
|
+
}
|
|
3992
4003
|
const wakeHeld = heldWhy(e);
|
|
3993
4004
|
if (wakeHeld !== undefined) {
|
|
3994
4005
|
unwoken(`its worker ${parked.jobId} is parked, and ${wakeHeld}`);
|
|
@@ -3997,7 +4008,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
3997
4008
|
const roomless = world.noRoomFor === undefined ? undefined : await world.noRoomFor(e);
|
|
3998
4009
|
if (roomless !== undefined) {
|
|
3999
4010
|
const moved = `its ${parked.provider} worker ${parked.jobId} is not woken: ${roomless}`;
|
|
4000
|
-
|
|
4011
|
+
dropWorker(e);
|
|
4001
4012
|
delete e.forced;
|
|
4002
4013
|
delete e.forcedBy;
|
|
4003
4014
|
step(e, now, "worker-ended", moved);
|
|
@@ -4009,7 +4020,8 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4009
4020
|
try {
|
|
4010
4021
|
const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId), worker => { e.worker = worker; save(); });
|
|
4011
4022
|
e.landedAt = now;
|
|
4012
|
-
|
|
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 }) };
|
|
4013
4025
|
delete e.forced;
|
|
4014
4026
|
delete e.forcedBy;
|
|
4015
4027
|
if (noteCarried(e, { alive: true, why: "", carried: e.worker.carried }, now)) {
|
|
@@ -4084,7 +4096,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4084
4096
|
else {
|
|
4085
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.
|
|
4086
4098
|
const why = `its ${parked.provider} worker ${parked.jobId} could not be woken: ${err.message}`;
|
|
4087
|
-
|
|
4099
|
+
dropWorker(e);
|
|
4088
4100
|
delete e.forced;
|
|
4089
4101
|
delete e.forcedBy;
|
|
4090
4102
|
step(e, now, "worker-ended", why);
|
|
@@ -4110,6 +4122,12 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4110
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`;
|
|
4111
4123
|
continue;
|
|
4112
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
|
+
}
|
|
4113
4131
|
const startHeld = heldWhy(e);
|
|
4114
4132
|
if (startHeld !== undefined) {
|
|
4115
4133
|
holdBack(e, now, "held-back", startHeld);
|
|
@@ -4143,7 +4161,6 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4143
4161
|
continue;
|
|
4144
4162
|
}
|
|
4145
4163
|
}
|
|
4146
|
-
world.seat(e);
|
|
4147
4164
|
// NULL-OK: field forcedBy is OPTIONAL and therefore it is ok to check for NULL
|
|
4148
4165
|
const forcer = e.forcedBy ?? "an unrecorded presser's";
|
|
4149
4166
|
// NULL-OK: field halted is OPTIONAL and therefore it is ok to check for NULL
|
|
@@ -4157,7 +4174,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4157
4174
|
e.state = "starting";
|
|
4158
4175
|
e.attempts += 1;
|
|
4159
4176
|
delete e.accountRefused;
|
|
4160
|
-
|
|
4177
|
+
dropWorker(e);
|
|
4161
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}` : ""}`);
|
|
4162
4179
|
save();
|
|
4163
4180
|
try {
|
|
@@ -4184,7 +4201,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
4184
4201
|
if (err.retained !== undefined)
|
|
4185
4202
|
e.worker = err.retained;
|
|
4186
4203
|
else if (err.unsent)
|
|
4187
|
-
|
|
4204
|
+
dropWorker(e);
|
|
4188
4205
|
const made = clearRefusal(e, world.worker(e, board));
|
|
4189
4206
|
if (noteCarried(e, made, now)) {
|
|
4190
4207
|
save();
|
|
@@ -4233,8 +4250,8 @@ export class StoryPressRefused extends Error {
|
|
|
4233
4250
|
/**
|
|
4234
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
|
|
4235
4252
|
* next new request puts it back), ↻ Retry puts a failed or retrying story back in line with its attempts reset, ⚡ Force start starts
|
|
4236
|
-
* it on the next pass past a ⏸ Stop and
|
|
4237
|
-
*
|
|
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
|
|
4238
4255
|
* {@link StoryPressRefused}; one on a story no longer in line throws {@link NotInQueue}. Answers what it did, in words.
|
|
4239
4256
|
*/
|
|
4240
4257
|
export async function pressStory(board, storyId, press, now, by, requestHandledByOwner = false, ownerAction) {
|
|
@@ -4280,7 +4297,7 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
|
|
|
4280
4297
|
if (working)
|
|
4281
4298
|
throw new StoryPressRefused(`#${storyId} already has a worker at work, so there is nothing to force`);
|
|
4282
4299
|
forceEntry(e, now, by);
|
|
4283
|
-
did = `#${storyId} starts on the next pass, past a ⏸ Stop
|
|
4300
|
+
did = `#${storyId} starts on the next pass, past a ⏸ Stop`;
|
|
4284
4301
|
}
|
|
4285
4302
|
else if (press === "stop" || press === "kill") {
|
|
4286
4303
|
if (e.worker === undefined || !(working || parkedInLine(e) || e.worker.carried !== undefined || ownerAction !== undefined))
|
|
@@ -4314,12 +4331,12 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
|
|
|
4314
4331
|
did = `#${storyId} is tried on the next pass${afterStop}`;
|
|
4315
4332
|
}
|
|
4316
4333
|
else {
|
|
4317
|
-
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" : ""}`);
|
|
4318
4335
|
}
|
|
4319
4336
|
step(e, now, "retry", e.why);
|
|
4320
4337
|
}
|
|
4321
4338
|
else {
|
|
4322
|
-
throw new StoryPressRefused(
|
|
4339
|
+
throw new StoryPressRefused(`${String(press)} is not a press FleetView's queue knows; #${storyId} reads: ${e.why}`);
|
|
4323
4340
|
}
|
|
4324
4341
|
writeStore(board, store);
|
|
4325
4342
|
writeAcks(board, store, new Map(), new Map([[e.storyId, e.requestId]]), now);
|
|
@@ -4444,7 +4461,8 @@ export async function rewakeStoryWorker(board, storyId, jobId, sessionId, messag
|
|
|
4444
4461
|
await stopStoryWorker(jobId, cli);
|
|
4445
4462
|
let woken;
|
|
4446
4463
|
try {
|
|
4447
|
-
|
|
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);
|
|
4448
4466
|
}
|
|
4449
4467
|
catch (err) {
|
|
4450
4468
|
if (!(err instanceof WorkerRefused))
|
|
@@ -4516,15 +4534,18 @@ export function claudeJobSession(jobId, home = claudeHome()) {
|
|
|
4516
4534
|
}
|
|
4517
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. */
|
|
4518
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) {
|
|
4519
4542
|
const dir = path.join(home, "jobs");
|
|
4520
4543
|
if (!fs.existsSync(dir))
|
|
4521
4544
|
return [];
|
|
4522
|
-
|
|
4523
|
-
const jobs = fs.readdirSync(dir).flatMap((id) => {
|
|
4545
|
+
return fs.readdirSync(dir).flatMap((id) => {
|
|
4524
4546
|
const job = jobRecordOf(id, home);
|
|
4525
|
-
return typeof job !== "string" && job
|
|
4526
|
-
});
|
|
4527
|
-
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);
|
|
4528
4549
|
}
|
|
4529
4550
|
/**
|
|
4530
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`
|
|
@@ -4552,18 +4573,14 @@ export function claudeJobsNamed(name, home = claudeHome()) {
|
|
|
4552
4573
|
}
|
|
4553
4574
|
});
|
|
4554
4575
|
}
|
|
4555
|
-
/**
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
const first = brief.split("\n")[0];
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
return fs.readdirSync(dir).filter((id) => {
|
|
4564
|
-
const job = jobRecordOf(id, home);
|
|
4565
|
-
return typeof job !== "string" && job.intent.split("\n")[0] === first;
|
|
4566
|
-
});
|
|
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);
|
|
4567
4584
|
}
|
|
4568
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)
|
|
4569
4586
|
export const WORKER_START_GRACE_MS = 2 * 60_000;
|
|
@@ -4578,8 +4595,15 @@ const mtimeOf = (file) => {
|
|
|
4578
4595
|
return undefined;
|
|
4579
4596
|
}
|
|
4580
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
|
+
}
|
|
4581
4605
|
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
4582
|
-
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 }) });
|
|
4583
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. */
|
|
4584
4608
|
function goneWorker(worker, now, home) {
|
|
4585
4609
|
const gone = `its job ${worker.jobId} is no longer on Claude Code's record`;
|
|
@@ -4766,11 +4790,11 @@ export function storyWorkerLiveness(worker, now, home = claudeHome()) {
|
|
|
4766
4790
|
const BACKGROUNDED = /^backgrounded · (\S+)/m;
|
|
4767
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>.` */
|
|
4768
4792
|
const STARTED_A_COPY = /session (\S+) is already running in the background, so this started a copy as ([^\s.]+)/;
|
|
4769
|
-
/** 🔴 #4123 — wakes a parked `claude --bg` session in place with `message
|
|
4770
|
-
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) {
|
|
4771
4795
|
return new Promise((resolve, reject) => {
|
|
4772
4796
|
fenceStart("claude", `claude --bg --resume ${sessionId}`);
|
|
4773
|
-
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) => {
|
|
4774
4798
|
const said = `${stdout}${stderr}`;
|
|
4775
4799
|
const copy = STARTED_A_COPY.exec(said);
|
|
4776
4800
|
if (copy !== null) {
|
|
@@ -4972,7 +4996,7 @@ export async function retireStory(entry, board, worker, cli, record, home = clau
|
|
|
4972
4996
|
export async function retireEarlierClaudeJobs(entry, board, workerJob, cli, record, home = claudeHome()) {
|
|
4973
4997
|
const storyId = entry.storyId;
|
|
4974
4998
|
const held = [];
|
|
4975
|
-
const earlier = new Set(
|
|
4999
|
+
const earlier = new Set(claudeJobsOfStoryAnywhere(entry, board, 0, home));
|
|
4976
5000
|
earlier.delete(workerJob);
|
|
4977
5001
|
for (const jobId of earlier) {
|
|
4978
5002
|
const job = jobRecordOf(jobId, home);
|
|
@@ -5078,9 +5102,9 @@ export function purgeStoryWorker(sessions, home = claudeHome(), temp = tmpdir())
|
|
|
5078
5102
|
}
|
|
5079
5103
|
// GATE: how long a provider CLI is given to answer a worker start before the start is read as refused
|
|
5080
5104
|
const LAUNCH_TIMEOUT_MS = 60_000;
|
|
5081
|
-
/** A story's worker, started windowless in the
|
|
5082
|
-
export function launchStoryWorker(entry,
|
|
5083
|
-
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);
|
|
5084
5108
|
}
|
|
5085
5109
|
const CLAUDE_MODEL = /^(default|best|inherit|opus|sonnet|haiku|fable|opusplan)(\[1m\])?$|^claude-/i;
|
|
5086
5110
|
const PINNED_MODELS = ["ANTHROPIC_SMALL_FAST_MODEL", "ANTHROPIC_DEFAULT_OPUS_MODEL", "ANTHROPIC_DEFAULT_SONNET_MODEL", "ANTHROPIC_DEFAULT_HAIKU_MODEL", "ANTHROPIC_DEFAULT_FABLE_MODEL"];
|
|
@@ -5132,12 +5156,12 @@ export async function launchClaudeJob(name, model, brief, cwd, cli, now, env = l
|
|
|
5132
5156
|
}
|
|
5133
5157
|
/**
|
|
5134
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
|
|
5135
|
-
*
|
|
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
|
|
5136
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
|
|
5137
5161
|
* as its identity is known and again right before the post is sent. No login is {@link WorkerRefused}; an unsent first input keeps
|
|
5138
5162
|
* that same session with its input pending; a lost answer to the sent input is {@link WorkerStartUnconfirmed}.
|
|
5139
5163
|
*/
|
|
5140
|
-
export async function postCodexStory(control,
|
|
5164
|
+
export async function postCodexStory(control, cwd, name, message, now, record, held, model) {
|
|
5141
5165
|
let submitted = false;
|
|
5142
5166
|
let worker;
|
|
5143
5167
|
try {
|
|
@@ -5145,7 +5169,7 @@ export async function postCodexStory(control, board, name, message, now, record,
|
|
|
5145
5169
|
if (!login.signedIn)
|
|
5146
5170
|
throw new WorkerRefused(login.why);
|
|
5147
5171
|
await control.daemonUp();
|
|
5148
|
-
const main = await control.startMain(
|
|
5172
|
+
const main = await control.startMain(cwd, name, held, model, made => {
|
|
5149
5173
|
worker = { provider: "codex", codexDirect: true, nativeInputPending: true, startedAt: now, jobId: made.threadId, ...(model === undefined ? {} : { nativeModel: model }) };
|
|
5150
5174
|
record(worker);
|
|
5151
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 {
|
|
@@ -266,7 +266,7 @@ function cookieOf(request, name) {
|
|
|
266
266
|
function escapeAttribute(value) {
|
|
267
267
|
return String(value).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
268
268
|
}
|
|
269
|
-
function webDocument(source, { page, roots, theme }) {
|
|
269
|
+
function webDocument(source, { page, drawn, roots, theme }) {
|
|
270
270
|
let html = repoint(source, roots).replace(/<meta\b[^>]*http-equiv\s*=\s*["']?Content-Security-Policy["']?[^>]*>/gi, "");
|
|
271
271
|
const nonces = [...source.matchAll(/\bnonce\s*=\s*["']([^"']+)["']/g)].map((match) => `'nonce-${match[1]}'`);
|
|
272
272
|
const policy = [
|
|
@@ -286,7 +286,7 @@ function webDocument(source, { page, roots, theme }) {
|
|
|
286
286
|
const head = viewport +
|
|
287
287
|
`<meta http-equiv="Content-Security-Policy" content="${policy}">` +
|
|
288
288
|
`<style id="_defaultStyles">${known ? theme.defaultCss.replace(/<\/style/gi, "<\\/style") : ""}</style>` +
|
|
289
|
-
`<script src="/__bullseye/host.js" data-page="${escapeAttribute(page)}" data-theme="${known ? "captured" : "missing"}"></script>`;
|
|
289
|
+
`<script src="/__bullseye/host.js" data-page="${escapeAttribute(page)}" data-drawn="${escapeAttribute(drawn)}" data-theme="${known ? "captured" : "missing"}"></script>`;
|
|
290
290
|
html = html.replace(/<html\b([^>]*)>/i, (tag, attributes) => {
|
|
291
291
|
const without = attributes.replace(/\sstyle\s*=\s*("[^"]*"|'[^']*')/i, "");
|
|
292
292
|
return known ? `<html${without} style="${escapeAttribute(vars)}">` : tag;
|
|
@@ -581,6 +581,11 @@ class Page {
|
|
|
581
581
|
this.title = options.title ?? name;
|
|
582
582
|
this.mirror = undefined;
|
|
583
583
|
this.sockets = new Set();
|
|
584
|
+
this.drawing = 0;
|
|
585
|
+
}
|
|
586
|
+
/** Which drawing of this page a document is: this process and how many times the page was redrawn in it, so a browser that missed a redraw while its socket was down reloads instead of reconnecting to the old page. */
|
|
587
|
+
get drawn() {
|
|
588
|
+
return `${process.pid}.${this.drawing}`;
|
|
584
589
|
}
|
|
585
590
|
get mark() {
|
|
586
591
|
return `${this.host.extension}/${this.name}/${process.pid}`;
|
|
@@ -615,6 +620,7 @@ class Page {
|
|
|
615
620
|
this.host.publish();
|
|
616
621
|
}
|
|
617
622
|
redrawn() {
|
|
623
|
+
this.drawing += 1;
|
|
618
624
|
for (const socket of this.sockets) {
|
|
619
625
|
writeFrame(socket, JSON.stringify({ type: "reload" }));
|
|
620
626
|
}
|
|
@@ -1021,6 +1027,7 @@ class WebHost {
|
|
|
1021
1027
|
const pages = Object.fromEntries([...this.pages.values()].map((page) => [page.name, {
|
|
1022
1028
|
url: page.url,
|
|
1023
1029
|
live: page.live,
|
|
1030
|
+
drawn: page.drawn,
|
|
1024
1031
|
browsers: page.sockets.size,
|
|
1025
1032
|
}]));
|
|
1026
1033
|
return send(response, 200, MIME[".json"], JSON.stringify({ extension: this.extension, label: this.label, pid: process.pid, pages }, null, 2), { "Cache-Control": "no-store" });
|
|
@@ -1030,7 +1037,7 @@ class WebHost {
|
|
|
1030
1037
|
return send(response, 200, MIME[".html"], closedPage(this.extension, page), { "Cache-Control": "no-store" });
|
|
1031
1038
|
}
|
|
1032
1039
|
const source = page.mirror.html;
|
|
1033
|
-
return send(response, 200, MIME[".html"], webDocument(source, { page: page.name, roots: page.mirror.roots(), theme: this.theme() }), {
|
|
1040
|
+
return send(response, 200, MIME[".html"], webDocument(source, { page: page.name, drawn: page.drawn, roots: page.mirror.roots(), theme: this.theme() }), {
|
|
1034
1041
|
"Cache-Control": "no-store",
|
|
1035
1042
|
"X-Bullseye-Source-Sha256": sha256(source),
|
|
1036
1043
|
});
|
|
@@ -1237,6 +1244,10 @@ class WebHost {
|
|
|
1237
1244
|
page.sockets.delete(socket);
|
|
1238
1245
|
};
|
|
1239
1246
|
page.sockets.add(socket);
|
|
1247
|
+
const drawn = url.searchParams.get("drawn");
|
|
1248
|
+
// NULL-OK: field drawn is OPTIONAL and therefore it is ok to check for NULL
|
|
1249
|
+
if (drawn !== null && drawn !== page.drawn)
|
|
1250
|
+
writeFrame(socket, JSON.stringify({ type: "reload" }));
|
|
1240
1251
|
// NULL-OK: field mirror is OPTIONAL and therefore it is ok to check for NULL
|
|
1241
1252
|
page.mirror?.forget();
|
|
1242
1253
|
socket.on("data", frameReader(socket, (text) => setImmediate(() => page.received(socket, text))));
|
|
@@ -1335,19 +1346,29 @@ function closedPage(extension, page) {
|
|
|
1335
1346
|
return `<!DOCTYPE html><html><head><meta charset="utf-8">${PHONE_VIEWPORT}<title>${escapeAttribute(extension)} · ${escapeAttribute(page.title)}</title></head>
|
|
1336
1347
|
<body style="font:14px system-ui,sans-serif;padding:24px;background:#1e1e1e;color:#ccc">⚪ ${escapeAttribute(page.title)} is not open in VS Code right now, so there is nothing to show here — this page loads it the moment it opens.<div id="said" style="margin-top:8px"></div>
|
|
1337
1348
|
<script>${CONNECTION_SOURCE}</script><script>(function () {
|
|
1338
|
-
var
|
|
1339
|
-
var
|
|
1349
|
+
var WHAT = "this page's live connection to its host";
|
|
1350
|
+
var reconnected = false;
|
|
1351
|
+
function connect() {
|
|
1352
|
+
var opened = false;
|
|
1353
|
+
var socket = new WebSocket((location.protocol === "https:" ? "wss:" : "ws:") + "//" + location.host + "/__bullseye/ws?page=${encodeURIComponent(page.name)}&peek=1");
|
|
1354
|
+
socket.addEventListener("open", function () {
|
|
1355
|
+
opened = true;
|
|
1356
|
+
var mine = socket;
|
|
1357
|
+
window.bullseyeConnection.opened(function () { return mine.readyState === 1; }, function () {
|
|
1358
|
+
window.bullseyeConnection.live();
|
|
1359
|
+
document.getElementById("said").textContent = "";
|
|
1360
|
+
});
|
|
1361
|
+
fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { return r.json(); }).then(function (health) { if (health.pages[${JSON.stringify(page.name)}].live) location.reload(); });
|
|
1362
|
+
});
|
|
1363
|
+
socket.addEventListener("message", function (event) { if (JSON.parse(String(event.data)).type === "reload") location.reload(); });
|
|
1364
|
+
socket.addEventListener("close", function () { if (opened) { var w = window.bullseyeConnection.closed(reconnected); reconnected = true; window.bullseyeConnection.reconnecting(WHAT, w); setTimeout(awaitHost, w); } else if (reconnected) { var refused = window.bullseyeConnection.failed(); window.bullseyeConnection.reconnecting(WHAT, refused); setTimeout(awaitHost, refused); } else { window.bullseyeConnection.disconnected(WHAT, "the host did not accept the connection — reload this page to try again"); document.getElementById("said").textContent = "⚠️ This page could not reach its host, so it cannot load the page when it opens — reload it to try again"; } });
|
|
1365
|
+
}
|
|
1340
1366
|
function awaitHost() {
|
|
1341
|
-
window.bullseyeConnection.reconnecting(
|
|
1342
|
-
document.getElementById("said").textContent = "⏳ This page's host is not answering — this page
|
|
1343
|
-
fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { if (r.ok) {
|
|
1367
|
+
window.bullseyeConnection.reconnecting(WHAT, 250);
|
|
1368
|
+
document.getElementById("said").textContent = "⏳ This page's host is not answering — this page reconnects the moment it does";
|
|
1369
|
+
fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { if (r.ok) { connect(); } else if (r.status === 401) location.assign("/"); else setTimeout(awaitHost, 250); }, function () { setTimeout(awaitHost, 250); });
|
|
1344
1370
|
}
|
|
1345
|
-
|
|
1346
|
-
opened = true;
|
|
1347
|
-
fetch("/__bullseye/health", { cache: "no-store" }).then(function (r) { return r.json(); }).then(function (health) { if (health.pages[${JSON.stringify(page.name)}].live) location.reload(); });
|
|
1348
|
-
});
|
|
1349
|
-
socket.addEventListener("message", function (event) { if (JSON.parse(String(event.data)).type === "reload") location.reload(); });
|
|
1350
|
-
socket.addEventListener("close", function () { if (opened) { window.bullseyeConnection.reconnecting("this page's live connection to its host", 0); awaitHost(); } else { window.bullseyeConnection.disconnected("this page's live connection to its host", "the host did not accept the connection — reload this page to try again"); document.getElementById("said").textContent = "⚠️ This page could not reach its host, so it cannot load the page when it opens — reload it to try again"; } });
|
|
1371
|
+
connect();
|
|
1351
1372
|
})();</script></body></html>`;
|
|
1352
1373
|
}
|
|
1353
1374
|
function codeDefect(err) {
|
|
@@ -365,7 +365,39 @@ const CONNECTION_SOURCE = String.raw `(function () {
|
|
|
365
365
|
ticker = window.setInterval(paint, 1000);
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
// GATE: a socket that drops sooner than this after opening counts as a failed attempt, so each retry waits twice as long and LIVE shows only once a socket has stayed up this long
|
|
369
|
+
var SETTLED_MS = 3000;
|
|
370
|
+
var drops = 0;
|
|
371
|
+
var openedAt = 0;
|
|
372
|
+
|
|
368
373
|
window.bullseyeConnection = {
|
|
374
|
+
attempts: function () {
|
|
375
|
+
return drops;
|
|
376
|
+
},
|
|
377
|
+
forget: function () {
|
|
378
|
+
drops = 0;
|
|
379
|
+
},
|
|
380
|
+
failed: function () {
|
|
381
|
+
drops += 1;
|
|
382
|
+
return Math.min(250 * Math.pow(2, drops - 1), 30000);
|
|
383
|
+
},
|
|
384
|
+
opened: function (stillOpen, settle) {
|
|
385
|
+
openedAt = Date.now();
|
|
386
|
+
if (drops === 0) {
|
|
387
|
+
settle();
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
window.setTimeout(function () {
|
|
391
|
+
if (stillOpen()) {
|
|
392
|
+
drops = 0;
|
|
393
|
+
settle();
|
|
394
|
+
}
|
|
395
|
+
}, SETTLED_MS);
|
|
396
|
+
},
|
|
397
|
+
closed: function (reopened) {
|
|
398
|
+
drops = reopened && Date.now() - openedAt < SETTLED_MS ? drops + 1 : 0;
|
|
399
|
+
return Math.min(250 * Math.pow(2, drops), 30000);
|
|
400
|
+
},
|
|
369
401
|
reconnecting: function (what, retryInMs) {
|
|
370
402
|
show("reconnecting", what, { retryAt: Date.now() + retryInMs });
|
|
371
403
|
},
|
|
@@ -395,6 +427,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
395
427
|
};
|
|
396
428
|
var themeMissing = script.getAttribute("data-theme") === "missing";
|
|
397
429
|
var stateKey = "bullseye-webhost:" + page;
|
|
430
|
+
var drawn = script.getAttribute("data-drawn");
|
|
398
431
|
var socket = null;
|
|
399
432
|
var queue = [];
|
|
400
433
|
var acquired = false;
|
|
@@ -423,42 +456,71 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
423
456
|
var WHAT = "this page's live connection to its service";
|
|
424
457
|
// GATE: one health read is abandoned after this times the square of the tries so far (capped at 8000), then asked again
|
|
425
458
|
var ANSWER_MS = 700;
|
|
459
|
+
// GATE: how long a reopened socket may stay connecting before it is given up and the host is asked again, times the give-ups in a row (capped at 30000)
|
|
460
|
+
var CONNECT_MS = 5000;
|
|
426
461
|
var healthTries = 0;
|
|
427
462
|
var lastHeard = Date.now();
|
|
428
|
-
var
|
|
463
|
+
var reconnects = 0;
|
|
429
464
|
|
|
430
465
|
function hostGone() {
|
|
431
|
-
if (
|
|
466
|
+
if (socket === null) {
|
|
432
467
|
return;
|
|
433
468
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
469
|
+
var dropped = socket;
|
|
470
|
+
window.bullseyeConnection.forget();
|
|
471
|
+
socket = null;
|
|
472
|
+
dropped.close();
|
|
439
473
|
awaitHost();
|
|
440
474
|
}
|
|
441
475
|
|
|
476
|
+
function unreached(err) {
|
|
477
|
+
if (err.name === "AbortError") {
|
|
478
|
+
awaitHost();
|
|
479
|
+
} else if (err instanceof TypeError) {
|
|
480
|
+
window.setTimeout(awaitHost, 250);
|
|
481
|
+
} else {
|
|
482
|
+
window.bullseyeConnection.disconnected(WHAT, "the host answered its health read with something that is not its own reply — reload this page to try again");
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function reconnectOrReload(health) {
|
|
487
|
+
if (health.pages === undefined) {
|
|
488
|
+
window.bullseyeConnection.disconnected(WHAT, "the host answered its health read with something that is not its own reply — reload this page to try again");
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
var served = health.pages[page];
|
|
492
|
+
if (served === undefined || served.live !== true || served.drawn !== drawn || typeof window.bullseyeHello !== "function") {
|
|
493
|
+
window.location.reload();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
reconnects += 1;
|
|
497
|
+
open();
|
|
498
|
+
}
|
|
499
|
+
|
|
442
500
|
function awaitHost() {
|
|
443
501
|
window.bullseyeConnection.reconnecting(WHAT, 250);
|
|
444
502
|
var asking = new AbortController();
|
|
445
503
|
healthTries += 1;
|
|
446
|
-
window.setTimeout(function () {
|
|
504
|
+
var abandon = window.setTimeout(function () {
|
|
447
505
|
asking.abort();
|
|
448
506
|
}, Math.min(ANSWER_MS * healthTries * healthTries, 8000));
|
|
449
507
|
window.fetch("/__bullseye/health", { cache: "no-store", signal: asking.signal }).then(function (response) {
|
|
450
|
-
healthTries = 0;
|
|
451
508
|
if (response.ok) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
509
|
+
response.json().then(function (health) {
|
|
510
|
+
window.clearTimeout(abandon);
|
|
511
|
+
healthTries = 0;
|
|
512
|
+
reconnectOrReload(health);
|
|
513
|
+
}, unreached);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
window.clearTimeout(abandon);
|
|
517
|
+
healthTries = 0;
|
|
518
|
+
if (response.status === 401) {
|
|
455
519
|
window.location.assign("/");
|
|
456
520
|
} else {
|
|
457
521
|
window.setTimeout(awaitHost, 250);
|
|
458
522
|
}
|
|
459
|
-
},
|
|
460
|
-
window.setTimeout(awaitHost, 250);
|
|
461
|
-
});
|
|
523
|
+
}, unreached);
|
|
462
524
|
}
|
|
463
525
|
|
|
464
526
|
function open() {
|
|
@@ -466,21 +528,46 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
466
528
|
notice("__bullseye-theme-missing", "⚪ VS Code colours not captured yet — open the Bullseye tab in VS Code once and reload this page");
|
|
467
529
|
}
|
|
468
530
|
var scheme = window.location.protocol === "https:" ? "wss:" : "ws:";
|
|
469
|
-
|
|
531
|
+
var mine = new WebSocket(scheme + "//" + window.location.host + "/__bullseye/ws?page=" + encodeURIComponent(page) + "&at=" + encodeURIComponent(window.location.search) + "&drawn=" + encodeURIComponent(drawn) + (new URLSearchParams(window.location.search).get("bullseye-peek") === null ? "" : "&peek=1"));
|
|
532
|
+
socket = mine;
|
|
533
|
+
if (reconnects > 0) {
|
|
534
|
+
window.setTimeout(function () {
|
|
535
|
+
if (socket === mine && mine.readyState === 0) {
|
|
536
|
+
window.bullseyeConnection.failed();
|
|
537
|
+
socket = null;
|
|
538
|
+
mine.close();
|
|
539
|
+
awaitHost();
|
|
540
|
+
}
|
|
541
|
+
}, Math.min(CONNECT_MS * (window.bullseyeConnection.attempts() + 1), 30000));
|
|
542
|
+
}
|
|
470
543
|
var opened = false;
|
|
471
|
-
|
|
544
|
+
var reopened = reconnects > 0;
|
|
545
|
+
mine.addEventListener("open", function () {
|
|
472
546
|
opened = true;
|
|
547
|
+
lastHeard = Date.now();
|
|
548
|
+
lastBeat = lastHeard;
|
|
473
549
|
if (typeof DecompressionStream === "function") {
|
|
474
|
-
|
|
550
|
+
mine.send(JSON.stringify({ type: "packed" }));
|
|
551
|
+
}
|
|
552
|
+
if (reconnects > 0) {
|
|
553
|
+
mine.send(JSON.stringify({ type: "message", message: window.bullseyeHello() }));
|
|
475
554
|
}
|
|
476
555
|
while (queue.length > 0) {
|
|
477
|
-
|
|
556
|
+
mine.send(queue.shift());
|
|
557
|
+
}
|
|
558
|
+
if (reconnects > 0) {
|
|
559
|
+
window.bullseyeConnection.opened(function () {
|
|
560
|
+
return socket === mine && mine.readyState === 1;
|
|
561
|
+
}, window.bullseyeConnection.live);
|
|
478
562
|
}
|
|
479
563
|
});
|
|
480
|
-
|
|
564
|
+
mine.binaryType = "blob";
|
|
481
565
|
var unpacking = Promise.resolve();
|
|
482
566
|
var unpackingCount = 0;
|
|
483
|
-
|
|
567
|
+
mine.addEventListener("message", function (event) {
|
|
568
|
+
if (mine !== socket) {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
484
571
|
lastHeard = Date.now();
|
|
485
572
|
if (typeof event.data === "string" && unpackingCount === 0) {
|
|
486
573
|
handle(event.data);
|
|
@@ -517,11 +604,21 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
517
604
|
}
|
|
518
605
|
}
|
|
519
606
|
}
|
|
520
|
-
|
|
607
|
+
mine.addEventListener("close", function () {
|
|
608
|
+
if (mine !== socket) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
521
611
|
socket = null;
|
|
522
612
|
if (opened) {
|
|
523
|
-
window.bullseyeConnection.
|
|
524
|
-
window.
|
|
613
|
+
var wait = window.bullseyeConnection.closed(reopened);
|
|
614
|
+
window.bullseyeConnection.reconnecting(WHAT, wait);
|
|
615
|
+
window.setTimeout(awaitHost, wait);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (reopened) {
|
|
619
|
+
var refusedWait = window.bullseyeConnection.failed();
|
|
620
|
+
window.bullseyeConnection.reconnecting(WHAT, refusedWait);
|
|
621
|
+
window.setTimeout(awaitHost, refusedWait);
|
|
525
622
|
return;
|
|
526
623
|
}
|
|
527
624
|
window.fetch("/__bullseye/health", { cache: "no-store" }).then(function (response) {
|
|
@@ -534,7 +631,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
534
631
|
});
|
|
535
632
|
}
|
|
536
633
|
|
|
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
|
|
634
|
+
// 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 is reopened in place
|
|
538
635
|
var BEAT_MS = 20000;
|
|
539
636
|
// 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
637
|
var PING_ANSWER_MS = 1200;
|
|
@@ -542,7 +639,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
542
639
|
var lastBeat = lastHeard;
|
|
543
640
|
|
|
544
641
|
function beat() {
|
|
545
|
-
if (
|
|
642
|
+
if (socket === null || socket.readyState !== 1) {
|
|
546
643
|
return;
|
|
547
644
|
}
|
|
548
645
|
if (lastHeard < lastBeat) {
|
|
@@ -554,9 +651,6 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
554
651
|
}
|
|
555
652
|
|
|
556
653
|
function probe() {
|
|
557
|
-
if (gone) {
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
654
|
if (socket === null || socket.readyState === 0) {
|
|
561
655
|
return;
|
|
562
656
|
}
|
|
@@ -565,9 +659,10 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
|
|
|
565
659
|
return;
|
|
566
660
|
}
|
|
567
661
|
var asked = Date.now();
|
|
662
|
+
var asking = socket;
|
|
568
663
|
socket.send('{"type":"ping"}');
|
|
569
664
|
window.setTimeout(function () {
|
|
570
|
-
if (lastHeard < asked) {
|
|
665
|
+
if (socket === asking && lastHeard < asked) {
|
|
571
666
|
hostGone();
|
|
572
667
|
}
|
|
573
668
|
}, PING_ANSWER_MS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.407",
|
|
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",
|