omni-notify-mcp 1.3.449 → 1.3.451

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.
@@ -27,7 +27,8 @@ export const KEY_BAR = [
27
27
  { id: "end", label: "End", title: "End", seq: ["\x1b[F", "\x1bOF"] },
28
28
  ];
29
29
  export const NEW_LINE = { id: "newline", label: "⏎ Line", title: "New line", seq: ["\x1b[200~\n\x1b[201~", "\x1b[200~\n\x1b[201~"] };
30
- const TERMINAL_REPLY = /^(?:\x1b\[[IO]|\x1b\[\??\d+;\d+R|\x1b\[[?>][0-9;]*c|\x1b\[\??[0-9;]*\$y)+$/;
30
+ const TERMINAL_REPLY = /^(?:\x1b\[[IO]|\x1b\[\??\d+;\d+R|\x1b\[[?>][0-9;]*c|\x1b\[\??[0-9;]*\$y|\x1b\[0n|\x1b\[\d+(?:;\d+)*t|\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1bP[^\x1b]*\x1b\\)+$/;
31
+ const MOUSE_REPORT = /^(?:\x1b\[<\d+;\d+;\d+[Mm]|\x1b\[\d+;\d+;\d+M|\x1b\[M[\s\S]{3})+$/;
31
32
  export const NEW_LINE_IN_BOX = "\x1b\r";
32
33
  export function ctrlByte(data) {
33
34
  if (data === "\r")
@@ -127,13 +128,13 @@ var btnNew=document.getElementById("newagent"),btnConvs=document.getElementById(
127
128
  // A phone is a touch screen no wider than 600px on its short side. Its normal mode lays the page out at the screen's own width; its desktop-site mode lays it out wider and shrinks it to the glass, so everything the page draws outside the terminal is scaled up by that ratio and the terminal's font with it.
128
129
  var ctrlByte=${ctrlByte.toString()};
129
130
  var ctrlBarSeq=${ctrlBarSeq.toString()};
130
- var TERMINAL_REPLY=${TERMINAL_REPLY.toString()},NEW_LINE_IN_BOX=${JSON.stringify(NEW_LINE_IN_BOX)};
131
+ var TERMINAL_REPLY=${TERMINAL_REPLY.toString()},MOUSE_REPORT=${MOUSE_REPORT.toString()},NEW_LINE_IN_BOX=${JSON.stringify(NEW_LINE_IN_BOX)};
131
132
  var KEY_BAR=${JSON.stringify(KEY_BAR)},NEW_LINE=${JSON.stringify(NEW_LINE)};
132
133
  var phone,phoneScale,refit=function(){};
133
134
  function sizePhone(){
134
- phone=matchMedia("(pointer:coarse)").matches&&Math.min(screen.width,screen.height)<=600;phoneScale=phone?Math.min(3,Math.max(1,innerWidth/screen.width)):1;
135
+ var was=phoneScale;phone=matchMedia("(pointer:coarse)").matches&&Math.min(screen.width,screen.height)<=600;phoneScale=phone?Math.min(3,Math.max(1,innerWidth/screen.width)):1;
135
136
  document.body.classList.toggle("phone",phone);document.documentElement.style.setProperty("--k",String(phoneScale));
136
- if(terminal&&terminal.options.fontSize!==Math.round(15*phoneScale)){terminal.options.fontSize=Math.round(15*phoneScale);refit();}
137
+ if(terminal&&Math.round(15*was)!==Math.round(15*phoneScale))refit();
137
138
  }
138
139
  var view=0,sent={},listResize=null,terminal,fitAddon,socket=null,reconnect,observer,arrival=null,socketDown=false,reopened=null,lost=function(){},sender=Math.random().toString(36).slice(2)+Date.now().toString(36);
139
140
  var REOPENED="A new CLI of this conversation — the one before is gone, and its screen was not kept.";
@@ -529,7 +530,7 @@ async function cliAttach(id,origin){
529
530
  },true);
530
531
  var keybar=document.getElementById("keybar"),ctrlHeld=false,ctrlKey=null;
531
532
  function disarm(){ctrlHeld=false;ctrlKey.classList.remove("armed");}
532
- var unacked=[],inputs=0,from=sender+"."+mine;function typed(body,mark,auto){if(term.options.disableStdin){liveNotice("Not sent — this CLI is no longer connected. Press 🔌 Reattach.","error");return;}if(!owner&&!auto){claim();mark=withhold;}inputs+=1;var sent={id:inputs,frame:JSON.stringify(Object.assign({kind:"input",from:from,id:inputs},body))};unacked.push(sent);if(socket!==null&&socket.readyState===WebSocket.OPEN)socket.send(sent.frame);mark(sent.id);}
533
+ var unacked=[],inputs=0,wheeling=false,from=sender+"."+mine;function typed(body,mark,auto){if(term.options.disableStdin){liveNotice("Not sent — this CLI is no longer connected. Press 🔌 Reattach.","error");return;}if(!owner&&!auto){claim();mark=withhold;}inputs+=1;var sent={id:inputs,frame:JSON.stringify(Object.assign({kind:"input",from:from,id:inputs},body))};unacked.push(sent);if(socket!==null&&socket.readyState===WebSocket.OPEN)socket.send(sent.frame);mark(sent.id);}
533
534
  function sendKey(data){if(ctrlHeld){disarm();data=ctrlBarSeq(data);}typed({data:data},withhold);}
534
535
  keybar.replaceChildren();keybar.hidden=false;
535
536
  [NEW_LINE].concat(KEY_BAR.slice(0,7),[{id:"ctrl",label:"Ctrl",title:"Ctrl (sticky)"}],KEY_BAR.slice(7)).forEach(function(key){
@@ -539,15 +540,25 @@ async function cliAttach(id,origin){
539
540
  else b.onclick=function(){sendKey(key.seq[term.modes.applicationCursorKeysMode?1:0]);term.focus();};
540
541
  keybar.append(b);
541
542
  });
542
- term.onData(function(data){if(ctrlHeld&&data.length===1){disarm();data=ctrlByte(data);}typed({data:data},function(id){predict(data,id);},TERMINAL_REPLY.test(data));});term.onBinary(function(data){typed({data:btoa(data),binary:true},withhold);});term.onResize(function(){forget();withhold(inputs);});
543
- var owner=false,claimed=null,held=null,shown=null,opening=true;
544
- function fitShown(){var shell=term.element,screen=host.querySelector(".xterm-screen");if(owner||!screen||!screen.offsetWidth){shell.style.transform=shell.style.width=shell.style.height="";return;}shell.style.width=screen.offsetWidth+"px";shell.style.height=screen.offsetHeight+"px";shell.style.transformOrigin="0 0";shell.style.transform="scale("+Math.min(host.clientWidth/screen.offsetWidth,host.clientHeight/screen.offsetHeight)+")";}
543
+ term.onData(function(data){if(ctrlHeld&&data.length===1){disarm();data=ctrlByte(data);}typed({data:data},function(id){predict(data,id);},TERMINAL_REPLY.test(data)||!wheeling&&MOUSE_REPORT.test(data));});term.attachCustomWheelEventHandler(function(){wheeling=true;queueMicrotask(function(){wheeling=false;});return true;});term.onBinary(function(data){typed({data:btoa(data),binary:true},withhold,!wheeling);});term.onResize(function(){forget();withhold(inputs);});
544
+ var owner=false,claimed=null,held=null,shown=null,opening=true,rejoined=false;
545
+ function fitShown(){
546
+ var base=Math.round(15*phoneScale),screen=host.querySelector(".xterm-screen");
547
+ if(owner){if(term.options.fontSize!==base)term.options.fontSize=base;return;}
548
+ if(!screen||!host.clientWidth||!host.clientHeight)return;
549
+ for(var tries=0;tries<6&&screen.offsetWidth&&screen.offsetHeight;tries++){
550
+ var font=term.options.fontSize,width=screen.offsetWidth,r=Math.min(host.clientWidth/width,host.clientHeight/screen.offsetHeight),next=r<1?Math.min(font-0.1,Math.floor(font*r*10)/10):r>1.03?Math.min(base,Math.floor(font*r*10)/10):font;
551
+ if(next>=font&&r<=1.03||next===font||next<1)break;
552
+ term.options.fontSize=next;if(screen.offsetWidth===width)break;
553
+ }
554
+ }
545
555
  function claim(){if(owner)return;owner=true;refit();}
546
556
  refit=function(){if(mine!==view)return;fitShown();if(!owner||!socket||socket.readyState!==WebSocket.OPEN||host.clientWidth===0||host.clientHeight===0)return;fitAddon.fit();claimed={cols:term.cols,rows:term.rows};held=shown;ordered(id,"resize",claimed);};
547
557
  function sized(frame){
548
558
  shown={cols:frame.cols,rows:frame.rows};
549
559
  if(owner&&claimed){if(frame.cols===claimed.cols&&frame.rows===claimed.rows)held=claimed;else if(!held)held=shown;else if(frame.cols!==held.cols||frame.rows!==held.rows){owner=false;claimed=held=null;}}
550
560
  if(!owner&&(frame.cols!==term.cols||frame.rows!==term.rows))term.resize(frame.cols,frame.rows);
561
+ if(rejoined){rejoined=false;var fits=owner&&fitAddon.proposeDimensions();if(fits&&(fits.cols!==claimed.cols||fits.rows!==claimed.rows))refit();}
551
562
  }
552
563
  if(observer)observer.disconnect();observer=new ResizeObserver(refit);host.style.overflow="hidden";
553
564
  reattach.onclick=function(){cliAttach(id,origin);};
@@ -564,7 +575,7 @@ async function cliAttach(id,origin){
564
575
  var ws=new WebSocket((location.protocol==="https:"?"wss://":"ws://")+location.host+"/v1/terminals/"+id+"/ws",["bn-terminal","bn-bearer."+token]);socket=ws;
565
576
  var frames=Promise.resolve(),opened=false;
566
577
  setTimeout(function(){if(mine===view&&socket===ws&&ws.readyState===WebSocket.CONNECTING)abandon(ws,window.bullseyeConnection.failed());},window.bullseyeConnection.limit());
567
- ws.onopen=function(){if(mine!==view){ws.close();return;}opened=true;socketDown=false;heard();window.bullseyeConnection.opened(function(){return socket===ws&&ws.readyState===WebSocket.OPEN;},window.bullseyeConnection.live);term.options.disableStdin=false;if(opening||unacked.length){opening=false;owner=false;claim();}else{owner=false;claimed=held=null;fitShown();}unacked.forEach(function(sent){ws.send(sent.frame);});term.focus();};
578
+ ws.onopen=function(){if(mine!==view){ws.close();return;}opened=true;socketDown=false;heard();window.bullseyeConnection.opened(function(){return socket===ws&&ws.readyState===WebSocket.OPEN;},window.bullseyeConnection.live);term.options.disableStdin=false;if(opening||unacked.length){opening=false;owner=false;claim();}else if(owner&&claimed){held=claimed;rejoined=true;fitShown();}else{owner=false;fitShown();}unacked.forEach(function(sent){ws.send(sent.frame);});term.focus();};
568
579
  ws.onmessage=function(event){if(socket===ws)heard();var frame=JSON.parse(event.data);if(frame.pong)return;if(frame.ack!==undefined){acked=Math.max(acked,frame.ack);unacked=unacked.filter(function(sent){return sent.id>frame.ack;});return;}var seen=acked;frames=frames.then(async function(){if(mine!==view)return;if(frame.files){if(frame.error)liveNotice(frame.error,"error");else{sentPaths=sentPaths.concat(frame.paths);liveNotice("Sent to CLI: "+frame.paths.map(function(sent){return phone?base(sent):sent;}).join(" · "));}return;}if(frame.error){liveNotice(frame.error,"error");return;}sized(frame);var behind=frame.reset?term.buffer.active.baseY-term.buffer.active.viewportY:0;if(frame.reset){forget();cursorShown=true;term.reset();}var shown=frame.data.match(/\\x1b\\[\\?25[hl]/g);if(shown)cursorShown=shown[shown.length-1].slice(-1)==="h";await new Promise(function(done){term.write(frame.data,done);});if(mine!==view)return;fitShown();reconcile(seen);if(behind>0)term.scrollLines(-behind);cli.provider=frame.provider;cli.project=frame.project;liveRead();if(frame.ended){forget();liveEnded("CLI ended"+(frame.failure?" · "+frame.failure:""));}else if(frame.failure&&frame.failure!==cli.failure)liveNotice(frame.failure,"error");cli.failure=frame.failure;}).catch(fail);};
569
580
  ws.onclose=function(event){if(mine!==view)return;forget();var ending=event.code===1000||(event.code===1008&&event.reason==="Sign in again");if(ending){term.options.disableStdin=true;unacked=[];}if(event.code===1000){socketDown=false;window.bullseyeConnection.live();liveEnded("CLI ended");return;}if(event.code===1008&&event.reason==="Sign in again"){socketDown=false;window.bullseyeConnection.live();signIn("Your sign-in expired. Sign in again to return to this CLI.");return;}again(opened?window.bullseyeConnection.closed(reattached):window.bullseyeConnection.failed());};
570
581
  ws.onerror=function(){socketDown=true;liveFailed("reattaching to the same CLI…");};
@@ -1,59 +1,59 @@
1
- "use strict";
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const { spawn } = require("child_process");
6
-
7
- const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
8
-
9
- function deployArgs({ deploy, domain, preview, projectRoot, home, doorsDir }) {
10
- return [
11
- deploy,
12
- "--domain", domain,
13
- ...(preview ? ["--new-install", "--dry-run"] : ["--new-install"]),
14
- // NULL-OK: field projectRoot is OPTIONAL and therefore it is ok to check for NULL
15
- "--project-root", projectRoot ?? home,
16
- "--security-dir", path.join(home, ".notify-mcp", "gateway", "security"),
17
- "--notify-dir", doorsDir,
18
- ];
19
- }
20
-
21
- function runDeploy({ node, args, cwd, env, onOutput }) {
22
- return new Promise((resolve, reject) => {
23
- const child = spawn(node, args, { windowsHide: true, cwd, env });
24
- child.stdout.on("data", (chunk) => onOutput(String(chunk)));
25
- child.stderr.on("data", (chunk) => onOutput(String(chunk)));
26
- child.on("error", reject);
27
- child.on("exit", (exitCode, signal) => resolve({ exitCode, signal }));
28
- });
29
- }
30
-
31
- const PROMPT_ON_THE_PC = "The elevated helper is not running as this build's copy, so installing would raise one Windows administrator prompt on the PC itself, which only a person at the PC can accept. Run Set up public access from VS Code on the PC (or accept the prompt there); with the helper running, this button installs without a prompt. Preview needs no administrator.";
32
-
33
- function writeRecord(file, record) {
34
- const staged = `${file}.${process.pid}.tmp`;
35
- fs.writeFileSync(staged, JSON.stringify(record, null, 2));
36
- try {
37
- fs.renameSync(staged, file);
38
- } catch (err) {
39
- fs.rmSync(staged, { force: true });
40
- throw err;
41
- }
42
- }
43
-
44
- async function runRecorded(recordFile, recordText) {
45
- const record = { ...JSON.parse(recordText), pid: process.pid };
46
- const log = recordFile.replace(/\.json$/, ".log");
47
- const write = (fields) => writeRecord(recordFile, { ...record, ...fields });
48
- try {
49
- const ended = await runDeploy({ node: process.execPath, args: record.args, cwd: record.cwd, onOutput: (text) => fs.appendFileSync(log, text) });
50
- write({ endedAt: new Date().toISOString(), ...ended });
51
- } catch (err) {
52
- // OWNER: the detached run's trigger root — a deploy that could not be launched is written into the run's record, which the page and the MCP tool read back.
53
- write({ endedAt: new Date().toISOString(), exitCode: null, failure: `the deploy could not be launched: ${err.message}` });
54
- }
55
- }
56
-
57
- if (require.main === module) void runRecorded(process.argv[2], process.argv[3]);
58
-
59
- module.exports = { DOMAIN, deployArgs, runDeploy, runRecorded, writeRecord, PROMPT_ON_THE_PC };
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawn } = require("child_process");
6
+
7
+ const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i;
8
+
9
+ function deployArgs({ deploy, domain, preview, projectRoot, home, doorsDir }) {
10
+ return [
11
+ deploy,
12
+ "--domain", domain,
13
+ ...(preview ? ["--new-install", "--dry-run"] : ["--new-install"]),
14
+ // NULL-OK: field projectRoot is OPTIONAL and therefore it is ok to check for NULL
15
+ "--project-root", projectRoot ?? home,
16
+ "--security-dir", path.join(home, ".notify-mcp", "gateway", "security"),
17
+ "--notify-dir", doorsDir,
18
+ ];
19
+ }
20
+
21
+ function runDeploy({ node, args, cwd, env, onOutput }) {
22
+ return new Promise((resolve, reject) => {
23
+ const child = spawn(node, args, { windowsHide: true, cwd, env });
24
+ child.stdout.on("data", (chunk) => onOutput(String(chunk)));
25
+ child.stderr.on("data", (chunk) => onOutput(String(chunk)));
26
+ child.on("error", reject);
27
+ child.on("exit", (exitCode, signal) => resolve({ exitCode, signal }));
28
+ });
29
+ }
30
+
31
+ const PROMPT_ON_THE_PC = "The elevated helper is not running as this build's copy, so installing would raise one Windows administrator prompt on the PC itself, which only a person at the PC can accept. Run Set up public access from VS Code on the PC (or accept the prompt there); with the helper running, this button installs without a prompt. Preview needs no administrator.";
32
+
33
+ function writeRecord(file, record) {
34
+ const staged = `${file}.${process.pid}.tmp`;
35
+ fs.writeFileSync(staged, JSON.stringify(record, null, 2));
36
+ try {
37
+ fs.renameSync(staged, file);
38
+ } catch (err) {
39
+ fs.rmSync(staged, { force: true });
40
+ throw err;
41
+ }
42
+ }
43
+
44
+ async function runRecorded(recordFile, recordText) {
45
+ const record = { ...JSON.parse(recordText), pid: process.pid };
46
+ const log = recordFile.replace(/\.json$/, ".log");
47
+ const write = (fields) => writeRecord(recordFile, { ...record, ...fields });
48
+ try {
49
+ const ended = await runDeploy({ node: process.execPath, args: record.args, cwd: record.cwd, onOutput: (text) => fs.appendFileSync(log, text) });
50
+ write({ endedAt: new Date().toISOString(), ...ended });
51
+ } catch (err) {
52
+ // OWNER: the detached run's trigger root — a deploy that could not be launched is written into the run's record, which the page and the MCP tool read back.
53
+ write({ endedAt: new Date().toISOString(), exitCode: null, failure: `the deploy could not be launched: ${err.message}` });
54
+ }
55
+ }
56
+
57
+ if (require.main === module) void runRecorded(process.argv[2], process.argv[3]);
58
+
59
+ module.exports = { DOMAIN, deployArgs, runDeploy, runRecorded, writeRecord, PROMPT_ON_THE_PC };
@@ -1171,6 +1171,10 @@ export class CodexControl {
1171
1171
  return Promise.resolve();
1172
1172
  const generation = ++this.generation;
1173
1173
  this.opening = import("ws").then(({ default: Socket }) => new Promise((resolve, reject) => {
1174
+ if (generation !== this.generation) {
1175
+ reject(new CodexControlFailed("the native Codex control connection was closed by its owner before it opened"));
1176
+ return;
1177
+ }
1174
1178
  const proxy = (this.proxy = this.bound(["app-server", "proxy"], "pipe"));
1175
1179
  const stream = Duplex.from({ readable: proxy.stdout, writable: proxy.stdin });
1176
1180
  const connection = Object.assign(stream, { connecting: false, setTimeout: () => stream, setNoDelay: () => stream, setKeepAlive: () => stream });
@@ -3480,8 +3484,18 @@ function applyRequest(store, r, now) {
3480
3484
  e.state = "withdrawn";
3481
3485
  step(e, now, "withdrawn", r.why);
3482
3486
  }
3487
+ else if (r.eligible && newPress && e.handStop?.yieldFor !== undefined && (e.state === "running" || e.state === "starting")) {
3488
+ // 🔴 #4559 — his Start on a lane a ⚡ line-cut is pausing cancels the pause: it keeps its lane, and a session already handed the pause order is told to carry on.
3489
+ const cancelled = stopNamed(e.handStop);
3490
+ if (e.handStop.delivery === "delivered" || e.handStop.delivery === "sending")
3491
+ e.pauseCancelled = { at: now, by: HIS_PRESS };
3492
+ delete e.handStop;
3493
+ e.why = `his Start cancelled the pause (${cancelled}) — it keeps its lane${e.pauseCancelled === undefined ? "" : ", and its session, already handed the pause order, is told to carry on"}`;
3494
+ step(e, now, "acknowledged", e.why);
3495
+ }
3483
3496
  else if (r.eligible && e.handStop !== undefined && !newPress) {
3484
- e.why = `request metadata updated, but ${e.handStop.by} 🛑 Stop holds it — only a newer explicit Start press puts it back`;
3497
+ // NULL-OK: field yieldFor is OPTIONAL and therefore it is ok to check for NULL
3498
+ e.why = e.handStop.yieldFor === undefined ? `request metadata updated, but ${e.handStop.by} 🛑 Stop holds it — only a newer explicit Start press puts it back` : `request metadata updated; it stays ${stopNamed(e.handStop)} and goes back in line by itself once its turn is over`;
3485
3499
  step(e, now, "updated", e.why);
3486
3500
  }
3487
3501
  else if (r.eligible && !newPress && (e.state === "failed" || e.state === "withdrawn") && neverRecordedSpent(e)) {
@@ -3515,8 +3529,6 @@ function applyRequest(store, r, now) {
3515
3529
  delete e.accountRefusals;
3516
3530
  if (e.handStop !== undefined && e.worker !== undefined)
3517
3531
  e.worker.parkedAt = now - wakeDelayMs(e.worker.wakes ?? 0);
3518
- if (e.handStop !== undefined)
3519
- clearWorkerStopAsk(e.worker);
3520
3532
  delete e.handStop;
3521
3533
  delete e.worker?.archiveRefused;
3522
3534
  delete e.archiveRefused;
@@ -3668,21 +3680,21 @@ function holdOnMemory(e, now, stage, why, trace, moved = false) {
3668
3680
  }
3669
3681
  // GATE: how long a 🛑 Stop waits for its worker to reach a step boundary (end its turn) before its row says plainly that it has not — it is never killed by the wait, and keeps being asked
3670
3682
  export const STOP_STEP_BOUND_MS = 10 * 60_000;
3671
- /** 🔴 #4216 — where a 🛑 Stop's ask for one session waits for that session's next tool call, which hands the agent the order (the PreToolUse hook reads this file). */
3672
- export const stopAskFile = (sessionId, home = claudeHome()) => path.join(home, "fleetview", "stop-asks", `${sessionId}.json`);
3673
- /** 🔴 #4216 — puts the stop order where the session's next tool call finds it; a disk that refuses the write is said by the throw, never read as an ask that landed. */
3674
- function writeStopAsk(sessionId, storyId, at) {
3675
- const file = stopAskFile(sessionId);
3676
- if (fs.existsSync(file))
3677
- return;
3678
- fs.mkdirSync(path.dirname(file), { recursive: true });
3679
- const partial = `${file}.${process.pid}.tmp`;
3680
- fs.writeFileSync(partial, JSON.stringify({ storyId, at }));
3681
- fs.renameSync(partial, file);
3682
- }
3683
- /** 🔴 #4216 — takes the stop order off the session once its process has ended. */
3684
- function clearStopAsk(sessionId) {
3685
- fs.rmSync(stopAskFile(sessionId), { force: true });
3683
+ /** 🔴 #4559 — the words that take back a pause order its worker's session already took, once his Start cancelled the pause. */
3684
+ export const pauseCancelOf = (storyId) => `⏩ FLEETVIEW CANCELS THE PAUSE OF #${storyId}: Meni pressed Start — ignore the pause order and carry on with your work; this session keeps its lane.`;
3685
+ /** 🔴 #4559 — how a stop's waits are named on its row: his 🛑 Stop, or the pause a ⚡ line-cut made of it. */
3686
+ const stopNamed = (stop) => (stop.yieldFor === undefined ? `${stop.by} 🛑 Stop` : `⏸ paused for ${stop.by}`);
3687
+ /**
3688
+ * 🔴 #4216/#4559 — the order a worker whose stop is asked ({@link QueueStopRoute} `asked`) is handed in its own session's inbox, which it reads at its next tool call: his 🛑 Stop, or the pause a ⚡ line-cut made of it.
3689
+ * Its words say who pressed: "his" is Meni's own press.
3690
+ */
3691
+ export function stopOrderOf(storyId, stop) {
3692
+ const by = stop.by === "his" ? "Meni" : stop.by.replace(/^his /, "Meni's ");
3693
+ const end = "write your progress on the story NOW (bullseye-backlog setPercent: the percent and a LEFT naming the true next step), start NO further step, and END YOUR TURN with one line.";
3694
+ // NULL-OK: field yieldFor is OPTIONAL and therefore it is ok to check for NULL
3695
+ return stop.yieldFor === undefined
3696
+ ? `🛑 STOP on #${storyId}, pressed by ${by}: finish the step you are on, then ${end} FleetView then ends this session and keeps your worktree and conversation; only a new Start continues it.`
3697
+ : `⏸ FLEETVIEW PAUSES #${storyId} FOR ${by}: finish the step you are on — a build, commit or push you are in finishes, and a commit is followed by its push — then ${end} FleetView then ends this process and keeps your worktree and conversation; it puts #${storyId} back in line at its own priority place and wakes THIS session to continue once a lane frees.`;
3686
3698
  }
3687
3699
  const QUEUE_STOP_ROUTES = {
3688
3700
  claude: {
@@ -3707,12 +3719,6 @@ function turnEndTold(by, worker) {
3707
3719
  }
3708
3720
  /** 🔴 #4271 — the stop route of the worker's own provider. */
3709
3721
  export const stopRouteOf = (worker) => QUEUE_STOP_ROUTES[worker.provider];
3710
- /** 🔴 #4216/#4271 — takes a stopped worker's stop order off its session, for a provider whose stop is asked through one. */
3711
- function clearWorkerStopAsk(worker) {
3712
- // NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
3713
- if (worker !== undefined && stopRouteOf(worker).stop === "asked" && worker.session !== undefined)
3714
- clearStopAsk(worker.session.id);
3715
- }
3716
3722
  /** 🔴 #4123 — how long after its turn ended a worker woken `wakes` times before is woken again. */
3717
3723
  export const wakeDelayMs = (wakes) => WAKE_BASE_MS * 2 ** Math.min(wakes, WAKE_DOUBLINGS);
3718
3724
  /** 🔴 #4162 — its process was killed mid-work after its session worked: past its start grace after its last wake, or at all after a fresh start (a session that then dies on the wake it gets backs off, so it never wakes in a loop): nothing ended its turn and nothing of its own failed, so it neither backs off nor spends a start (#4164). */
@@ -4226,11 +4232,7 @@ async function passHeld(board, world, now) {
4226
4232
  continue;
4227
4233
  }
4228
4234
  if (closed !== undefined) {
4229
- // NULL-OK: field handStop is OPTIONAL and therefore it is ok to check for NULL
4230
- if (e.handStop !== undefined) {
4231
- clearWorkerStopAsk(e.worker);
4232
- delete e.handStop;
4233
- }
4235
+ delete e.handStop;
4234
4236
  e.state = "done";
4235
4237
  e.why = closed;
4236
4238
  step(e, now, "closed", closed);
@@ -4327,6 +4329,32 @@ async function passHeld(board, world, now) {
4327
4329
  step(e, now, "retry", e.why);
4328
4330
  continue;
4329
4331
  }
4332
+ // NULL-OK: field pauseCancelled is OPTIONAL and therefore it is ok to check for NULL
4333
+ if (e.pauseCancelled !== undefined && e.worker !== undefined) {
4334
+ const w = workerNow();
4335
+ if (!w.alive || w.parked !== undefined) {
4336
+ // 🔴 #4559 — it ended its turn as the pause told it before the cancel could reach it: it is woken in its own session at once, never behind a wake delay.
4337
+ e.worker.parkedAt = now - wakeDelayMs(e.worker.wakes ?? 0);
4338
+ delete e.pauseCancelled;
4339
+ step(e, now, "acknowledged", "his Start cancelled the pause after its worker had ended its turn, so it is woken in its own session at once");
4340
+ }
4341
+ else if (world.tellWorker !== undefined) {
4342
+ try {
4343
+ await world.tellWorker(e, e.worker, pauseCancelOf(e.storyId));
4344
+ delete e.pauseCancelled;
4345
+ step(e, now, "acknowledged", "his Start cancelled the pause: its session is told to carry on with its work");
4346
+ save();
4347
+ }
4348
+ catch (error) {
4349
+ if (!(error instanceof WorkerNotStarted))
4350
+ throw error;
4351
+ // OWNER: ITER/LOOP — its session did not take the cancel this pass; it stays on the entry and is posted again next pass, and the entry is read on.
4352
+ e.why = `his Start cancelled the pause; telling its session to carry on did not land yet (${error.message}) and is posted again next pass`;
4353
+ }
4354
+ }
4355
+ else
4356
+ delete e.pauseCancelled;
4357
+ }
4330
4358
  // NULL-OK: field handStop is OPTIONAL and therefore it is ok to check for NULL
4331
4359
  if (e.handStop !== undefined && e.worker !== undefined) {
4332
4360
  const worker = e.worker;
@@ -4345,8 +4373,8 @@ async function passHeld(board, world, now) {
4345
4373
  // NULL-OK: field progressAt is OPTIONAL and therefore it is ok to check for NULL
4346
4374
  if (w.progressAt !== undefined)
4347
4375
  worker.progressAt = w.progressAt;
4348
- const sessionId = worker.session?.id;
4349
- if (world.requestStop !== undefined && e.handStop.requestedAt === undefined) {
4376
+ // 🔴 #4559 — a worker asked through its session whose turn is already over is told nothing: an order posted now would start a turn the stop below ends.
4377
+ if (world.requestStop !== undefined && e.handStop.requestedAt === undefined && !(stopRouteOf(worker).stop === "asked" && w.parked !== undefined)) {
4350
4378
  e.handStop.requestedAt = now;
4351
4379
  e.handStop.delivery = "sending";
4352
4380
  save();
@@ -4362,7 +4390,7 @@ async function passHeld(board, world, now) {
4362
4390
  // OWNER: this Stop's provider exchange failed or lost its acknowledgment; keep the stop and never submit a duplicate request.
4363
4391
  e.handStop.delivery = error.unsent ? "unsent" : "unconfirmed";
4364
4392
  e.handStop.refusal = error.message;
4365
- step(e, now, "stop-asked", `${e.handStop.by} Stop could not be confirmed: ${error.message}`);
4393
+ step(e, now, "stop-asked", `${stopNamed(e.handStop)} could not be confirmed: ${error.message}`);
4366
4394
  }
4367
4395
  }
4368
4396
  else if (world.reconcileStop !== undefined && e.handStop.delivery !== undefined && e.handStop.delivery !== "delivered" && ((w.alive && w.parked === undefined) || e.handStop.ownerAction !== undefined || e.handStop.legacyOwner === true)) {
@@ -4405,18 +4433,15 @@ async function passHeld(board, world, now) {
4405
4433
  }
4406
4434
  if (w.alive && w.parked === undefined) {
4407
4435
  if (e.handStop.refusal !== undefined) {
4408
- e.why = `${e.handStop.by} Stop could not be confirmed: ${e.handStop.refusal}; the story stays stopped and its worker is not reported ended`;
4436
+ e.why = `${stopNamed(e.handStop)} could not be confirmed: ${e.handStop.refusal}; it is asked again every pass, and its worker is not reported ended`;
4409
4437
  continue;
4410
4438
  }
4411
- // NULL-OK: field sessionId is OPTIONAL and therefore it is ok to check for NULL
4412
- if (w.stopUnavailable === undefined && sessionId !== undefined)
4413
- writeStopAsk(sessionId, e.storyId, e.handStop.at);
4414
4439
  const waited = now - e.handStop.at;
4415
4440
  const why = w.stopUnavailable !== undefined
4416
- ? `${e.handStop.by} 🛑 Stop: ${w.stopUnavailable}; its native turn has not ended, and nothing is reported stopped. ⛔ Kill ends it now.`
4441
+ ? `${stopNamed(e.handStop)}: ${w.stopUnavailable}; its native turn has not ended, and nothing is reported stopped. ⛔ Kill ends it now.`
4417
4442
  : waited >= STOP_STEP_BOUND_MS
4418
- ? `${e.handStop.by} 🛑 Stop: its worker ${worker.jobId} has not ended its turn in ${Math.round(waited / 60_000)} min (the bound is ${STOP_STEP_BOUND_MS / 60_000} min) — it is still told to stop at its next step and is NOT killed; ⛔ Kill ends it now`
4419
- : `${e.handStop.by} 🛑 Stop: waiting for its worker ${worker.jobId} to finish its step, write its progress and end its turn — asked ${Math.round(waited / 60_000)} min ago, bound ${STOP_STEP_BOUND_MS / 60_000} min`;
4443
+ ? `${stopNamed(e.handStop)}: its worker ${worker.jobId} has not ended its turn in ${Math.round(waited / 60_000)} min (the bound is ${STOP_STEP_BOUND_MS / 60_000} min) — it is still told to stop at its next step and is NOT killed; ⛔ Kill ends it now`
4444
+ : `${stopNamed(e.handStop)}: waiting for its worker ${worker.jobId} to finish its step, write its progress and end its turn — asked ${Math.round(waited / 60_000)} min ago, bound ${STOP_STEP_BOUND_MS / 60_000} min`;
4420
4445
  const crossed = waited >= STOP_STEP_BOUND_MS && !e.trace.some((t) => t.stage === "stop-asked" && t.at >= e.handStop.at && t.detail.includes("has not ended"));
4421
4446
  e.why = why;
4422
4447
  if (crossed)
@@ -4425,7 +4450,7 @@ async function passHeld(board, world, now) {
4425
4450
  }
4426
4451
  // NULL-OK: field tasks is OPTIONAL and therefore it is ok to check for NULL
4427
4452
  if (w.parked?.tasks !== undefined) {
4428
- e.why = `${e.handStop.by} 🛑 Stop: its worker ${worker.jobId}'s turn is over but it still has background tasks running, so its process is not ended until they finish — nothing is killed`;
4453
+ e.why = `${stopNamed(e.handStop)}: its worker ${worker.jobId}'s turn is over but it still has background tasks running, so its process is not ended until they finish — nothing is killed`;
4429
4454
  continue;
4430
4455
  }
4431
4456
  if (w.parked?.live === true) {
@@ -4436,7 +4461,7 @@ async function passHeld(board, world, now) {
4436
4461
  if (!(err instanceof WorkerNotStarted))
4437
4462
  throw err;
4438
4463
  // OWNER: ITER/LOOP — Claude Code refused to end this stopped worker's process this pass, so the entry keeps its 🛑 Stop mark with the provider's words on its trace (once) and the stop is tried again next pass; the next entry is read.
4439
- const refused = `${e.handStop.by} 🛑 Stop: its worker ${worker.jobId}'s turn is over but its process could not be ended — ${err.message}; tried again next pass`;
4464
+ const refused = `${stopNamed(e.handStop)}: its worker ${worker.jobId}'s turn is over but its process could not be ended — ${err.message}; tried again next pass`;
4440
4465
  if (e.why !== refused)
4441
4466
  step(e, now, "stop-asked", refused);
4442
4467
  e.why = refused;
@@ -4444,7 +4469,17 @@ async function passHeld(board, world, now) {
4444
4469
  }
4445
4470
  }
4446
4471
  worker.stoppedAt = now;
4447
- clearWorkerStopAsk(worker);
4472
+ // NULL-OK: field yieldFor is OPTIONAL and therefore it is ok to check for NULL
4473
+ if (e.handStop.yieldFor !== undefined) {
4474
+ const paused = stopNamed(e.handStop);
4475
+ delete e.handStop;
4476
+ worker.parkedAt = now - wakeDelayMs(worker.wakes ?? 0);
4477
+ e.state = "queued";
4478
+ delete e.nextTryAt;
4479
+ e.why = `${paused}: its worker ${worker.jobId} finished its step and ended its turn, and its process was ended; its worktree and conversation are kept, and it waits in line at its own priority place and is woken in its own session once a lane frees`;
4480
+ step(e, now, "parked", e.why);
4481
+ continue;
4482
+ }
4448
4483
  e.state = "withdrawn";
4449
4484
  delete e.forced;
4450
4485
  delete e.forcedBy;
@@ -4766,6 +4801,54 @@ async function passHeld(board, world, now) {
4766
4801
  /** 🔴 #4460 — why this workspace's lane limit holds the entry's start or wake now, or undefined: no limit is set, a lane is free, or his ⚡ Force start passes it. */
4767
4802
  // NULL-OK: field lanes is OPTIONAL and therefore it is ok to check for NULL
4768
4803
  const laneHeld = (e) => (lanes === undefined || e.forced === true || running < lanes.limit ? undefined : `⏳ ${running} lanes run, this workspace's limit is ${lanes.limit}`);
4804
+ /**
4805
+ * 🔴 #4559 — Meni 2026-11-25: a ⚡ line-cut "start immidietly!! even to exceed max agent allowed for workspace. But FV will take the agent that has the least am amout of progress and gracefully stop it and put it back in the queue".
4806
+ * Once `cut`'s worker took a lane past the limit, one of this queue's own running workers on this box is paused for each lane over it not already pausing: the lowest priority first and never one above the cut's,
4807
+ * then the least progress on the board, then the newest start. Only a worker whose stop is asked at its next tool call is paused, so it finishes its step first; nothing is killed.
4808
+ */
4809
+ const pauseForCut = (cut, by) => {
4810
+ // NULL-OK: field lanes is OPTIONAL and therefore it is ok to check for NULL
4811
+ if (lanes === undefined)
4812
+ return;
4813
+ const pausing = store.entries.filter((x) => x.handStop?.yieldFor !== undefined).length;
4814
+ if (running - pausing <= lanes.limit)
4815
+ return;
4816
+ const rank = (x) => rankIn(PRI_ORDER, x.pri);
4817
+ // NULL-OK: field progressOf is OPTIONAL and therefore it is ok to check for NULL
4818
+ const progress = (x) => world.progressOf?.(x.storyId) ?? Number.POSITIVE_INFINITY;
4819
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
4820
+ const pausable = (x) => x !== cut && x.state === "running" && x.handStop === undefined && x.worker !== undefined && x.worker.parkedAt === undefined && x.worker.box === undefined && stopRouteOf(x.worker).stop === "asked" && rank(x) >= rank(cut);
4821
+ const lane = store.entries.filter(pausable).sort((a, b) => rank(b) - rank(a) || progress(a) - progress(b) || b.worker.startedAt - a.worker.startedAt)[0];
4822
+ const over = `${running} lanes run past this workspace's limit of ${lanes.limit}`;
4823
+ // NULL-OK: field lane is OPTIONAL and therefore it is ok to check for NULL
4824
+ if (lane === undefined) {
4825
+ step(cut, now, "started", `its ⚡ Force start runs past the limit: ${over}, and no running worker of this queue on this box is of its priority or lower with a stop asked at its next step, so none is paused for it`);
4826
+ return;
4827
+ }
4828
+ lane.handStop = { at: now, by: `${by} ⚡ Force start of #${cut.storyId}`, yieldFor: cut.storyId };
4829
+ delete lane.pauseCancelled;
4830
+ const known = progress(lane);
4831
+ lane.why = `${stopNamed(lane.handStop)}: ${over}, and it is the ${lane.pri} lane with the least progress (${Number.isFinite(known) ? `${known}%` : "no percent on the board"}) — its worker ${lane.worker.jobId} is asked to finish its step, write its progress and end its turn, then it waits in line and is woken in its own session`;
4832
+ step(lane, now, "stop-asked", lane.why);
4833
+ step(cut, now, "started", `its ⚡ Force start runs past the limit (${over}), so #${lane.storyId}, the ${lane.pri} lane with the least progress, is paused at its next step for it`);
4834
+ };
4835
+ /** 🔴 #4559 — makes the pause a ⚡ entry owes once its worker was sent, and takes the debt off it. */
4836
+ const settleCut = (e) => {
4837
+ // NULL-OK: field cutPending is OPTIONAL and therefore it is ok to check for NULL
4838
+ if (e.cutPending === undefined)
4839
+ return;
4840
+ pauseForCut(e, e.cutPending);
4841
+ delete e.cutPending;
4842
+ };
4843
+ for (const e of store.entries) {
4844
+ // NULL-OK: field cutPending is OPTIONAL and therefore it is ok to check for NULL
4845
+ if (e.cutPending === undefined)
4846
+ continue;
4847
+ if (e.state === "running")
4848
+ settleCut(e);
4849
+ else if (e.worker === undefined || !IN_LINE.has(e.state) || e.state === "failed" || e.state === "retrying")
4850
+ delete e.cutPending;
4851
+ }
4769
4852
  for (const e of queueOrder(store)) {
4770
4853
  await slice();
4771
4854
  try {
@@ -4821,6 +4904,10 @@ async function passHeld(board, world, now) {
4821
4904
  }
4822
4905
  const released = memoryReleased(e, now);
4823
4906
  const wakes = (parked.wakes ?? 0) + 1;
4907
+ // NULL-OK: field forcedBy is OPTIONAL and therefore it is ok to check for NULL
4908
+ if (e.forced === true)
4909
+ e.cutPending = e.forcedBy ?? "an unrecorded presser's";
4910
+ save();
4824
4911
  try {
4825
4912
  const answered = parked.question?.answer === undefined ? undefined : { question: parked.question.text, answer: parked.question.answer, ...(parked.question.approval === true ? { approval: true } : {}) };
4826
4913
  const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId, answered), worker => { e.worker = worker; save(); });
@@ -4838,6 +4925,7 @@ async function passHeld(board, world, now) {
4838
4925
  e.state = "running";
4839
4926
  e.why = `its ${woken.provider} worker ${woken.jobId} was woken in its own session (wake ${wakes})${answered === undefined ? "" : answered.approval === true ? ` with the queue's own answer to its tool approval "${answered.question}"` : ` with Meni's answer to "${answered.question}"`}`;
4840
4927
  step(e, now, "woken", e.why + released);
4928
+ settleCut(e);
4841
4929
  }
4842
4930
  catch (err) {
4843
4931
  if (!(err instanceof WorkerNotStarted))
@@ -4893,6 +4981,7 @@ async function passHeld(board, world, now) {
4893
4981
  delete e.forcedBy;
4894
4982
  e.why = `its worker ${parked.jobId} was woken in its own session (wake ${wakes}), though its answer was: ${err.message}`;
4895
4983
  step(e, now, "woken", e.why);
4984
+ settleCut(e);
4896
4985
  }
4897
4986
  else if (!err.unsent) {
4898
4987
  // OWNER: ITER/LOOP — the wake's answer was lost and no process is known to run the session (none has recorded it, or its transcript could not be read), so the worker stays parked and is read again next pass; it is never ended on a missing answer, which would start a second worker beside a wake that landed late; the next entry is read.
@@ -5018,8 +5107,10 @@ async function passHeld(board, world, now) {
5018
5107
  const box = spillTo === undefined ? undefined : spillTo.box;
5019
5108
  // NULL-OK: field box is OPTIONAL and therefore it is ok to check for NULL
5020
5109
  const released = box === undefined ? memoryReleased(e, now) : ` — on ${box}, because ${lowMemory.why}`;
5021
- if (e.forced === true)
5110
+ if (e.forced === true) {
5022
5111
  delete e.accountRefusals;
5112
+ e.cutPending = forcer;
5113
+ }
5023
5114
  delete e.forced;
5024
5115
  delete e.forcedBy;
5025
5116
  e.state = "starting";
@@ -5045,6 +5136,7 @@ async function passHeld(board, world, now) {
5045
5136
  }
5046
5137
  e.why = `its ${e.worker.provider} worker ${e.worker.jobId} was started`;
5047
5138
  step(e, Date.now(), "started", e.why);
5139
+ settleCut(e);
5048
5140
  }
5049
5141
  catch (err) {
5050
5142
  if (!(err instanceof WorkerNotStarted))
@@ -5071,6 +5163,7 @@ async function passHeld(board, world, now) {
5071
5163
  e.landedAt = now;
5072
5164
  e.why = `its ${made.found.provider} worker ${made.found.jobId} runs, though its start answered: ${err.message}`;
5073
5165
  step(e, Date.now(), "started", e.why);
5166
+ settleCut(e);
5074
5167
  save();
5075
5168
  continue;
5076
5169
  }
@@ -5284,9 +5377,11 @@ async function pressHeld(board, storyId, press, now, by, requestHandledByOwner =
5284
5377
  const route = stopRouteOf(e.worker);
5285
5378
  if (ownerAction !== undefined && (ownerAction.queueRequestId !== queueStartRequestId(e) || route.stop !== "native" || e.worker.jobId !== ownerAction.ownerId || e.worker.startedAt !== ownerAction.workerStartedAt))
5286
5379
  throw new StoryPressRefused("the queued native worker or Start authority changed; its old Stop binding was not applied");
5287
- if (e.handStop !== undefined && press !== "kill" && (ownerAction === undefined || JSON.stringify(ownerAction) === JSON.stringify(e.handStop.ownerAction ?? e.handStop.nativeIntent)))
5380
+ if (e.handStop !== undefined && e.handStop.yieldFor === undefined && press !== "kill" && (ownerAction === undefined || JSON.stringify(ownerAction) === JSON.stringify(e.handStop.ownerAction ?? e.handStop.nativeIntent)))
5288
5381
  throw new StoryPressRefused(`#${storyId} was already told to stop by ${e.handStop.by} at ${new Date(e.handStop.at).toISOString()}`);
5289
- e.handStop = { at: e.handStop?.at ?? now, by, ...(press === "kill" || requestHandledByOwner ? { requestedAt: now, delivery: "unconfirmed", ...(ownerAction === undefined ? (route.stop === "native" ? { legacyOwner: true } : {}) : { ownerAction }) } : ownerAction === undefined ? {} : { nativeIntent: ownerAction }) };
5382
+ delete e.pauseCancelled;
5383
+ // NULL-OK: field yieldFor is OPTIONAL and therefore it is ok to check for NULL
5384
+ e.handStop = { at: e.handStop?.yieldFor === undefined ? (e.handStop?.at ?? now) : now, by, ...(press === "kill" || requestHandledByOwner ? { requestedAt: now, delivery: "unconfirmed", ...(ownerAction === undefined ? (route.stop === "native" ? { legacyOwner: true } : {}) : { ownerAction }) } : ownerAction === undefined ? {} : { nativeIntent: ownerAction }) };
5290
5385
  const told = route.told(by, storyId, e.worker);
5291
5386
  e.why = told.why;
5292
5387
  step(e, now, "stop-asked", e.why);
@@ -6642,6 +6737,8 @@ function takeOverStaleLock(lockDir) {
6642
6737
  return true;
6643
6738
  }
6644
6739
  async function trustLaunchFolder(cwd) {
6740
+ if (!fs.existsSync(cwd))
6741
+ throw new WorkerNotStarted(`claude --bg was not started: its folder ${cwd} no longer exists, so no Claude Code was asked to run in it`, true);
6645
6742
  const configFile = claudeConfigFile();
6646
6743
  if (!fs.existsSync(configFile))
6647
6744
  return cwd;
@@ -32,7 +32,8 @@ export function createCopilotDriver(runtime) {
32
32
  const file = join(process.env.XDG_CONFIG_HOME || homedir(), ".copilot", "config.json");
33
33
  if (!existsSync(file))
34
34
  return false;
35
- const trusted = JSON.parse(readFileSync(file, "utf8")).trusted_folders ?? [];
35
+ const config = JSON.parse(readFileSync(file, "utf8").split(/\r?\n/).filter((line) => !line.trimStart().startsWith("//")).join("\n"));
36
+ const trusted = config.trustedFolders ?? config.trusted_folders ?? [];
36
37
  if (!Array.isArray(trusted))
37
38
  return false;
38
39
  const want = folderKey(folder);
@@ -1,10 +1,19 @@
1
1
  import { accessSync, constants, readFileSync, statSync } from "fs";
2
2
  import { delimiter, dirname, isAbsolute, join, resolve } from "path";
3
+ /** Where a CLI's own installer leaves it when PATH does not name it: the OpenCode desktop app keeps its CLI inside its install folder and never puts it on PATH. */
4
+ function installedBesidePath(command, env, platform) {
5
+ const local = env.LOCALAPPDATA;
6
+ // NULL-OK: field LOCALAPPDATA is OPTIONAL and therefore it is ok to check for NULL
7
+ if (platform !== "win32" || command !== "opencode" || local === undefined)
8
+ return [];
9
+ return [join(local, "Programs", "ai.opencode.desktop", "resources", "opencode-cli.exe")];
10
+ }
3
11
  /** The same executable, shim entry and environment are checked for the picker and the native PTY launch. */
4
12
  export function nativeCliInvocation(command, args, env = process.env, platform = process.platform) {
5
13
  const windows = platform === "win32";
6
14
  const hasPath = isAbsolute(command) || /[\\/]/.test(command);
7
- const candidates = hasPath ? [command] : (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean).flatMap((directory) => windows && !/\.(exe|com|cmd|bat)$/i.test(command) ? [".exe", ".com", ".cmd", ".bat"].map((extension) => join(directory, command + extension)) : [join(directory, command)]);
15
+ const onPath = (env.PATH ?? env.Path ?? "").split(delimiter).filter(Boolean).flatMap((directory) => windows && !/\.(exe|com|cmd|bat)$/i.test(command) ? [".exe", ".com", ".cmd", ".bat"].map((extension) => join(directory, command + extension)) : [join(directory, command)]);
16
+ const candidates = hasPath ? [command] : [...onPath, ...installedBesidePath(command, env, platform)];
8
17
  let executable;
9
18
  let last = "not found on the native launch PATH";
10
19
  for (const candidate of candidates) {