omni-notify-mcp 1.3.392 → 1.3.393

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.
@@ -53,7 +53,13 @@ main.cli-style .badge.history{color:#c3cad6;border-color:#3a4150;background:tran
53
53
  .line .tm table{border-collapse:collapse;width:100%}
54
54
  .line .tm td{padding:1px 4px;border-top:1px solid #2a303c;vertical-align:top;overflow-wrap:anywhere}
55
55
  main.cli-style p.system{color:var(--mut)}
56
- @media(max-width:480px) and (pointer:coarse){header{flex-wrap:nowrap}main{padding:6px}.setup select,.setup input{flex:1 1 100%;min-height:40px}.setup.toolbar{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch}.setup.toolbar>*{flex:none}#status{padding:2px 8px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.origin{display:inline-flex;align-items:center;min-height:32px}}
56
+ @media(max-width:480px) and (pointer:coarse){header{flex-wrap:nowrap}main{padding:6px}.setup select,.setup input{flex:1 1 100%;min-height:40px}#status{padding:2px 8px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.origin{display:inline-flex;align-items:center;min-height:32px}}
57
+ /* A phone's CLI view shows the terminal and its few controls and nothing wider than the glass: the account links, the delivery panel and the build line belong to the list, and the toolbar wraps, its buttons icon-only. */
58
+ body.phone.term header>a,body.phone.term #convs,body.phone.term #logout,body.phone.term #serving,body.phone.term #notification-status{display:none!important}
59
+ body.phone.term header{overflow:visible;flex-wrap:nowrap}body.phone.term header h1{flex:1 1 0;min-width:0;max-width:none}
60
+ body.phone.term .setup.toolbar{flex-wrap:wrap;overflow:visible;gap:6px}body.phone .toolbar .lbl{display:none}body.phone .toolbar button{min-width:44px;justify-content:center}
61
+ body.phone.term #status{display:block;-webkit-line-clamp:unset;overflow:visible}
62
+ body.phone.term header,body.phone.term #status,body.phone.term .toolbar{zoom:var(--k,1)}
57
63
  </style></head><body><header><button id="back" hidden>Back</button><h1 id="title">Conversations</h1><a href="/settings" style="color:inherit">⚙️ Settings</a><a href="/public-access" style="color:inherit">🌐 Public access</a><button id="newagent" hidden>+ New Agent</button><button id="convs" hidden title="Back to the live Conversations list">📋 Conversations</button><button id="logout" hidden>🚪 Logout</button></header>
58
64
  ${servingLine()}<div id="status" role="status" hidden></div><main id="main"></main>
59
65
  <script>${js}
@@ -63,7 +69,15 @@ ${SIGN_IN_SCRIPT}
63
69
  var main=document.getElementById("main"),note=document.getElementById("status"),title=document.getElementById("title");
64
70
  var btnBack=document.getElementById("back");
65
71
  var btnNew=document.getElementById("newagent"),btnConvs=document.getElementById("convs");
72
+ // 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.
73
+ var phone,phoneScale,refit=function(){};
74
+ function sizePhone(){
75
+ phone=matchMedia("(pointer:coarse)").matches&&Math.min(screen.width,screen.height)<=600;phoneScale=phone?Math.min(3,Math.max(1,innerWidth/screen.width)):1;
76
+ document.body.classList.toggle("phone",phone);document.documentElement.style.setProperty("--k",String(phoneScale));
77
+ if(terminal&&terminal.options.fontSize!==Math.round(15*phoneScale)){terminal.options.fontSize=Math.round(15*phoneScale);refit();}
78
+ }
66
79
  var view=0,sent={},listResize=null,terminal,fitAddon,socket,reconnect,observer,arrival=null;
80
+ sizePhone();window.addEventListener("resize",sizePhone);
67
81
  var AGENTS = ${JSON.stringify(PROVIDER_CHOICES)};
68
82
  var storedStamp = ${storedStamp.toString()};
69
83
  // The panel that hosts this page (#2726) hands its token over once in the URL fragment, which no request and no
@@ -78,6 +92,9 @@ if(deepLink.get("view")&&deepLink.get("id")){arrival={view:deepLink.get("view"),
78
92
 
79
93
  function el(tag,cls,content){var node=document.createElement(tag);if(cls)node.className=cls;if(content!==undefined)node.textContent=content;return node;}
80
94
 
95
+ /** A toolbar button: its icon always, its words beside it except on a phone, where the icon alone keeps every control on the screen. */
96
+ function tool(icon,label,cls){var b=el("button",cls,icon);b.append(" ",el("span","lbl",label));b.setAttribute("aria-label",label);return b;}
97
+
81
98
  function show(name,heading){
82
99
  view++;
83
100
  if(name!=="terminal"){clearTimeout(reconnect);if(socket){socket.onclose=null;socket.close();socket=null;}if(observer){observer.disconnect();observer=null;}if(terminal){terminal.dispose();terminal=null;}main.style.display="";main.style.flexDirection="";}
@@ -91,6 +108,7 @@ function show(name,heading){
91
108
  btnLogout.hidden=name==="signin";
92
109
  expiryNotice.hidden=name==="signin";
93
110
  main.classList.toggle("scroll",name!=="terminal");
111
+ document.body.classList.toggle("term",name==="terminal");
94
112
  main.classList.toggle("cli-style",name==="terminal"||name==="gone");
95
113
  document.body.classList.toggle("wide",inList);
96
114
  main.replaceChildren();
@@ -208,8 +226,8 @@ async function newAgentView(){
208
226
  }
209
227
 
210
228
  async function cliAttach(id,origin){
211
- var mine=show("terminal","Native CLI · "+id),toolbar=el("div","setup toolbar"),back=el("button","","↩ Back"),reattach=el("button","","🔌 Reattach"),copy=el("button","","⧉ Copy selection"),latest=el("button","latest","↓ Newest"),close=el("button","","⏹ Close CLI"),host=el("div");host.id="terminal";main.style.display="flex";main.style.flexDirection="column";host.style.flex="1";host.style.minHeight="0";toolbar.append(back,reattach,copy,latest,close,el("span","origin",origin));main.append(toolbar,host);
212
- terminal=new Terminal({cursorBlink:true,fontFamily:"ui-monospace,SFMono-Regular,Menlo,Consolas,Roboto Mono,DejaVu Sans Mono,monospace",scrollback:${CLI_SCROLLBACK_LINES},theme:{background:"#101217"},allowProposedApi:true});fitAddon=new FitAddon.FitAddon();terminal.loadAddon(fitAddon);
229
+ var mine=show("terminal","Native CLI · "+(phone?id.slice(0,8):id)),toolbar=el("div","setup toolbar"),back=tool("↩","Back",""),reattach=tool("🔌","Reattach",""),copy=tool("⧉","Copy selection",""),latest=tool("↓","Newest","latest"),close=tool("⏹","Close CLI",""),host=el("div");host.id="terminal";main.style.display="flex";main.style.flexDirection="column";host.style.flex="1";host.style.minHeight="0";toolbar.append(back,reattach,copy,latest,close,el("span","origin",origin));main.append(toolbar,host);
230
+ terminal=new Terminal({cursorBlink:true,fontSize:Math.round(15*phoneScale),fontFamily:"ui-monospace,SFMono-Regular,Menlo,Consolas,Roboto Mono,DejaVu Sans Mono,monospace",scrollback:${CLI_SCROLLBACK_LINES},theme:{background:"#101217"},allowProposedApi:true});fitAddon=new FitAddon.FitAddon();terminal.loadAddon(fitAddon);
213
231
  terminal.loadAddon(new Unicode11Addon.Unicode11Addon());terminal.unicode.activeVersion="11";
214
232
  terminal.open(host);terminal.textarea.enterKeyHint="send";terminal.focus();var term=terminal;
215
233
  // Reading back through the scrollback is the reader's own act, so it is never taken away from them: output arriving
@@ -277,7 +295,8 @@ async function cliAttach(id,origin){
277
295
  event.preventDefault();event.stopImmediatePropagation();upload(files);term.focus();
278
296
  },true);
279
297
  term.onData(function(data){ordered(id,"input",{data:data});});term.onBinary(function(data){ordered(id,"input",{data:btoa(data),binary:true});});
280
- observer=new ResizeObserver(function(){if(mine!==view||!socket||socket.readyState!==WebSocket.OPEN)return;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});});
298
+ refit=function(){if(mine!==view||!socket||socket.readyState!==WebSocket.OPEN)return;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});};
299
+ observer=new ResizeObserver(refit);
281
300
  reattach.onclick=function(){cliAttach(id,origin);};
282
301
  back.onclick=goBack;
283
302
  close.onclick=async function(){close.disabled=true;try{await api("DELETE","/v1/terminals/"+id);swap("list");}catch(error){close.disabled=false;fail(error);}};
@@ -288,7 +307,7 @@ async function cliAttach(id,origin){
288
307
  var ws=new WebSocket((location.protocol==="https:"?"wss://":"ws://")+location.host+"/v1/terminals/"+id+"/ws",["bn-terminal","bn-bearer."+token]);socket=ws;
289
308
  var frames=Promise.resolve();
290
309
  ws.onopen=function(){if(mine!==view){ws.close();return;}term.options.disableStdin=false;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});term.focus();};
291
- 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;}if(frame.reset)term.reset();await new Promise(function(done){term.write(frame.data,done);});if(mine!==view)return;note.textContent=frame.provider+" · "+frame.project+(frame.ended?" · CLI ended":" · connected")+(frame.failure?" · "+frame.failure:"")+(fileNotice?" · "+fileNotice:"");}).catch(fail);};
310
+ 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;}if(frame.reset)term.reset();await new Promise(function(done){term.write(frame.data,done);});if(mine!==view)return;note.textContent=frame.provider+" · "+(phone?base(frame.project):frame.project)+(frame.ended?" · CLI ended":" · connected")+(frame.failure?" · "+frame.failure:"")+(fileNotice?" · "+fileNotice:"");}).catch(fail);};
292
311
  ws.onclose=function(event){if(mine!==view)return;term.options.disableStdin=true;if(event.code===1000){note.textContent="CLI ended.";return;}if(event.code===1008){note.textContent="Disconnected: "+event.reason+". Press Reattach or sign in again.";return;}note.textContent="Disconnected. Reattaching to the same CLI…";reconnect=setTimeout(connect,1000);};
293
312
  ws.onerror=function(){note.textContent="Terminal connection failed. Reconnecting…";};
294
313
  }
@@ -406,11 +406,11 @@ export class CodexControl {
406
406
  return { id: turn.id, status: turn.status };
407
407
  }
408
408
  /** A new Codex main opened in `cwd` under `name`, idle until a press is posted into it. */
409
- async startMain(cwd, name, held, maximumThreads, model, created) {
409
+ async startMain(cwd, name, held, model, created) {
410
410
  await this.open();
411
411
  const idle = await this.unboundRoot(cwd, held, model);
412
412
  fenceStart("codex", `the Codex main ${name}`);
413
- const thread = idle ?? (await this.request("thread/start", { cwd, ...this.capacityConfig(maximumThreads), ...(model === undefined ? {} : { model }) })).thread;
413
+ const thread = idle ?? (await this.request("thread/start", { cwd, ...(model === undefined ? {} : { model }) })).thread;
414
414
  const main = { threadId: thread.id, cwd: thread.cwd, name, ownedThreadIds: [], working: false };
415
415
  created?.(main);
416
416
  await this.request("thread/name/set", { threadId: thread.id, name });
@@ -465,14 +465,14 @@ export class CodexControl {
465
465
  }
466
466
  return working;
467
467
  }
468
- async resumeStory(threadId, message, maximumThreads, beforeSend, name) {
468
+ async resumeStory(threadId, message, beforeSend, name) {
469
469
  await this.daemonUp();
470
470
  await this.open();
471
471
  const thread = (await this.request("thread/read", { threadId, includeTurns: false })).thread;
472
472
  if (thread.source !== "cli" && thread.source !== "vscode")
473
473
  throw new CodexRefused("the recorded direct story worker is not a native root; no input was posted");
474
474
  if (!(await this.request("thread/loaded/list", {})).data.includes(threadId))
475
- await this.request("thread/resume", { threadId, excludeTurns: true, ...this.capacityConfig(maximumThreads) });
475
+ await this.request("thread/resume", { threadId, excludeTurns: true });
476
476
  if (name !== undefined)
477
477
  await this.request("thread/name/set", { threadId, name });
478
478
  await this.post(threadId, message, beforeSend);
@@ -491,29 +491,6 @@ export class CodexControl {
491
491
  await this.open();
492
492
  await this.request("thread/unarchive", { threadId });
493
493
  }
494
- capacityConfig(maximumThreads) {
495
- if (maximumThreads === undefined)
496
- return {};
497
- if (!Number.isSafeInteger(maximumThreads) || maximumThreads < 2)
498
- throw new CodexControlFailed("Codex concurrency must include its parent and at least one child");
499
- return { config: { "agents.max_concurrent_threads_per_session": maximumThreads - 1 } };
500
- }
501
- /** Resize only a quiescent root and its quiescent children; active native turns are never rebuilt. */
502
- async resumeMainWithCapacity(threadId, maximumThreads) {
503
- const config = this.capacityConfig(maximumThreads);
504
- const main = (await this.mains()).find((candidate) => candidate.threadId === threadId);
505
- if (main === undefined)
506
- throw new CodexControlFailed("the Codex root is not loaded; its ownership cannot be verified");
507
- if (main.working)
508
- throw new CodexControlFailed("the Codex root is still working; pause its turns before changing capacity");
509
- for (const childId of main.ownedThreadIds) {
510
- const { thread } = await this.request("thread/read", { threadId: childId, includeTurns: false });
511
- if (thread.status.type === "active")
512
- throw new CodexControlFailed("Codex child " + childId + " is still working; pause its turn before changing capacity");
513
- }
514
- await this.request("thread/unsubscribe", { threadId });
515
- await this.request("thread/resume", { threadId, excludeTurns: true, ...config });
516
- }
517
494
  /** Record manual intent for the proven generation and, for a root, its current native descendants. */
518
495
  async requestStopIntent(threadId, expectedTurnId, stateDir, kind, descendants = false) {
519
496
  await this.daemonUp();
@@ -692,7 +669,7 @@ export class CodexControl {
692
669
  await this.postOwnedChild(threadId, threadId, post.turnId, post.text);
693
670
  }
694
671
  /** Follow the native parent chain and recover the same owner, never a replacement conversation. */
695
- async postOwnedChild(parentId, childId, expectedTurnId, message, maximumThreads, onSubmit) {
672
+ async postOwnedChild(parentId, childId, expectedTurnId, message, onSubmit) {
696
673
  const nonce = createHash("sha256").update(JSON.stringify([parentId, childId, expectedTurnId, message])).digest("hex");
697
674
  const marker = `FleetView native message ${nonce}`;
698
675
  const dir = path.join(this.project, ".fleetview", "codex-posts");
@@ -765,7 +742,7 @@ export class CodexControl {
765
742
  if (owner.source !== "cli" && owner.source !== "vscode")
766
743
  throw new CodexRefused("the selected native Codex owner is not a root conversation");
767
744
  if (!(await this.mains()).some((root) => root.threadId === owner.id))
768
- await this.request("thread/resume", { threadId: owner.id, excludeTurns: true, ...this.capacityConfig(maximumThreads) });
745
+ await this.request("thread/resume", { threadId: owner.id, excludeTurns: true });
769
746
  let loaded = (await this.mains()).find((root) => root.threadId === owner.id);
770
747
  if (loaded !== undefined && childId !== owner.id && !loaded.ownedThreadIds.includes(childId)) {
771
748
  await this.request("thread/resume", { threadId: childId, excludeTurns: true });
@@ -2507,17 +2484,14 @@ const lockFile = (board) => path.join(storyQueueDir(board), "entries.lock");
2507
2484
  const servedFile = (board) => path.join(storyQueueDir(board), "served.json");
2508
2485
  const historyFile = (board) => path.join(storyQueueDir(board), "history.jsonl");
2509
2486
  const FINISHED = new Set(["done", "withdrawn"]);
2510
- /** The store written whole, each finished entry's middle steps and the body of its brief (all but the first line, which names the story) first appended to the history file the queue never reads, so the file every pass parses holds only what the queue still acts on. */
2487
+ /** The store written whole, each finished entry's middle steps first appended to the history file the queue never reads, so the file every pass parses holds only what the queue still acts on. */
2511
2488
  function writeStore(board, store) {
2512
- const moved = store.entries.filter((e) => FINISHED.has(e.state) && (e.trace.length > 2 || e.brief.includes("\n")));
2489
+ const moved = store.entries.filter((e) => FINISHED.has(e.state) && e.trace.length > 2);
2513
2490
  if (moved.length > 0) {
2514
2491
  fs.mkdirSync(storyQueueDir(board), { recursive: true });
2515
- fs.appendFileSync(historyFile(board), moved.map((e) => JSON.stringify({ storyId: e.storyId, requestId: e.requestId, state: e.state, trace: e.trace.slice(1, -1), brief: e.brief })).join("\n") + "\n");
2516
- for (const e of moved) {
2517
- if (e.trace.length > 2)
2518
- e.trace = [e.trace[0], e.trace[e.trace.length - 1]];
2519
- e.brief = e.brief.split("\n")[0];
2520
- }
2492
+ fs.appendFileSync(historyFile(board), moved.map((e) => JSON.stringify({ storyId: e.storyId, requestId: e.requestId, state: e.state, trace: e.trace.slice(1, -1) })).join("\n") + "\n");
2493
+ for (const e of moved)
2494
+ e.trace = [e.trace[0], e.trace[e.trace.length - 1]];
2521
2495
  }
2522
2496
  writeWhole(board, storeFile(board), store);
2523
2497
  }
@@ -2855,25 +2829,6 @@ export async function recordQueueNativeStopResult(board, tokens, result, now) {
2855
2829
  writeStore(board, store);
2856
2830
  });
2857
2831
  }
2858
- /** The resident queue owns this per-story hold, not a legacy hand-over file or the whole queue's Stop switch. */
2859
- export async function holdQueuedStoryAtCapacity(board, story, reason, by, carrier, limit, activeIds, now) {
2860
- return withQueueLock(board, now, async () => {
2861
- const store = readQueueStore(board);
2862
- const entry = queueOrder(store).find(entry => entry.storyId === story);
2863
- if (entry === undefined)
2864
- return { kind: "absent" };
2865
- if (entry.forced === true || entry.forceStartedAt !== undefined)
2866
- return { kind: "forced", forcedAt: entry.forceStartedAt ?? now };
2867
- if (entry.worker === undefined || entry.worker.jobId !== carrier)
2868
- throw new StoryPressRefused(`the caller does not own #${story}'s recorded native carrier; no capacity hold was written`);
2869
- entry.capacityHold = { by, reason, at: entry.capacityHold?.at ?? now, carrier, limit, activeIds: [...new Set(activeIds)] };
2870
- entry.state = "queued";
2871
- entry.why = `${by} holds #${story} for a native lane slot: ${reason}`;
2872
- step(entry, now, "updated", entry.why);
2873
- writeStore(board, store);
2874
- return { kind: "held", board, story, reason };
2875
- });
2876
- }
2877
2832
  const IN_LINE = new Set(["queued", "starting", "running", "retrying", "failed"]);
2878
2833
  const rankIn = (order, value) => order.indexOf(value);
2879
2834
  /**
@@ -3026,7 +2981,6 @@ function applyRequest(store, r, now) {
3026
2981
  }
3027
2982
  /** 🔴 #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. */
3028
2983
  function forceEntry(e, now, by, eventAt = now) {
3029
- delete e.capacityHold;
3030
2984
  e.forceStartedAt = eventAt;
3031
2985
  e.forceEventAt = eventAt;
3032
2986
  e.state = "queued";
@@ -3313,38 +3267,13 @@ function movedWords(moved) {
3313
3267
  /** 🔴 #4123 — a parked worker's idle process is stopped at once, and a stop that did not take is tried again only after its wait. */
3314
3268
  // NULL-OK: field stoppedAt is OPTIONAL and therefore it is ok to check for NULL
3315
3269
  const stopDue = (worker, now) => worker.stoppedAt === undefined || now >= worker.stoppedAt + wakeDelayMs(worker.wakes ?? 0);
3316
- export const providerActivityIdentity = (provider, sessionId) => provider + "\u0000" + (sessionId.startsWith(provider + ":") ? sessionId.slice(provider.length + 1) : sessionId);
3317
- const workerActivityIdentity = (worker) => worker.activity?.identity ?? providerActivityIdentity(worker.provider, worker.session?.id ?? worker.jobId);
3318
- class QueueLaneBudget {
3319
- floor;
3320
- known;
3321
- added = new Set();
3322
- observed;
3323
- constructor(observed, entries) {
3324
- this.observed = observed;
3325
- this.floor = observed();
3326
- this.known = new Set(entries.filter((e) => e.worker !== undefined && ((e.state === "queued" && e.worker.carried !== undefined) || (e.state === "failed" && e.worker.startUnconfirmed !== undefined) || ((e.state === "starting" || e.state === "running") && e.worker.blocked !== true && e.worker.parkedAt === undefined))).map((e) => workerActivityIdentity(e.worker)));
3327
- }
3328
- count() { return Math.max(this.observed(), this.floor); }
3329
- reserve() { this.floor += 1; return { pending: true }; }
3330
- accepted(reservation, worker) {
3331
- if (!reservation.pending)
3332
- return;
3333
- reservation.pending = false;
3334
- const identity = workerActivityIdentity(worker);
3335
- if (worker.activity?.newlyActive === false || this.added.has(identity) || (worker.activity === undefined && this.known.has(identity)))
3336
- this.floor -= 1;
3337
- else
3338
- this.added.add(identity);
3339
- this.known.add(identity);
3340
- }
3341
- refused(reservation) {
3342
- if (reservation.pending) {
3343
- reservation.pending = false;
3344
- this.floor -= 1;
3345
- }
3346
- }
3347
- }
3270
+ /**
3271
+ * 🔴 ONE PASS OF FLEETVIEW'S STORY QUEUE ON ONE BOARD, under its lock: every request BB wrote is applied and acknowledged,
3272
+ * every worker is checked (a story shipped closes its entry; a worker that ended with the story still open is started
3273
+ * again after its backoff), and every entry in line is started on that same pass — only his ⏸ Stop keeps one waiting,
3274
+ * 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
3275
+ * next pass and never gets a second worker.
3276
+ */
3348
3277
  export async function driveStoryQueue(board, world, now) {
3349
3278
  return withQueueLock(board, now, async () => {
3350
3279
  const newer = newerDriver(board, world.driverVersion);
@@ -3428,17 +3357,6 @@ export async function driveStoryQueue(board, world, now) {
3428
3357
  judge: {
3429
3358
  const workerNow = once(() => clearRefusal(e, world.worker(e, board)));
3430
3359
  const closed = world.closedWhy(e.storyId);
3431
- if (closed === undefined && e.capacityHold !== undefined && e.forced !== true && e.handStop === undefined) {
3432
- const capacity = world.capacityReleased?.(e, e.capacityHold);
3433
- if (capacity?.released !== true) {
3434
- e.state = "queued";
3435
- e.why = `${e.capacityHold.by} holds this story at its carrier's capacity: ${e.capacityHold.reason}; ${capacity?.why ?? "no authoritative capacity change has been observed"}`;
3436
- continue;
3437
- }
3438
- const why = capacity.why;
3439
- delete e.capacityHold;
3440
- step(e, now, "updated", `capacity hold released: ${why}`);
3441
- }
3442
3360
  if (e.state === "withdrawn") {
3443
3361
  const reading = workerNow;
3444
3362
  idle = idleWorker(e.worker, reading, now);
@@ -3844,14 +3762,7 @@ export async function driveStoryQueue(board, world, now) {
3844
3762
  save();
3845
3763
  // NULL-OK: field stopped is OPTIONAL and therefore it is ok to check for NULL
3846
3764
  const halted = store.stopped === undefined ? undefined : `the queue is stopped (${store.stopped.by}), so nothing more starts or wakes until ▶ Run`;
3847
- const budget = new QueueLaneBudget(() => world.lanesRunning(), store.entries);
3848
- let lanes = budget.count();
3849
3765
  for (const e of queueOrder(store)) {
3850
- if (e.capacityHold !== undefined && e.forced !== true)
3851
- continue;
3852
- lanes = budget.count();
3853
- let laneTaken = false;
3854
- let reservation;
3855
3766
  try {
3856
3767
  const sessionId = wakeable.get(e);
3857
3768
  // NULL-OK: field sessionId is OPTIONAL and therefore it is ok to check for NULL
@@ -3872,16 +3783,10 @@ export async function driveStoryQueue(board, world, now) {
3872
3783
  unwoken(`its worker ${parked.jobId} is parked, and ${halted}`);
3873
3784
  continue;
3874
3785
  }
3875
- reservation = budget.reserve();
3876
- lanes = budget.count();
3877
- laneTaken = true;
3878
3786
  const wakes = (parked.wakes ?? 0) + 1;
3879
3787
  try {
3880
3788
  const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId), worker => { e.worker = worker; save(); });
3881
3789
  e.worker = { ...woken, wakes, ...(woken.provider === parked.provider && woken.jobId === parked.jobId ? keptSession(parked) : {}) };
3882
- budget.accepted(reservation, e.worker);
3883
- laneTaken = false;
3884
- lanes = budget.count();
3885
3790
  delete e.forced;
3886
3791
  delete e.forcedBy;
3887
3792
  if (noteCarried(e, { alive: true, why: "", carried: e.worker.carried }, now)) {
@@ -3889,7 +3794,7 @@ export async function driveStoryQueue(board, world, now) {
3889
3794
  continue;
3890
3795
  }
3891
3796
  e.state = "running";
3892
- e.why = `its ${woken.provider} worker ${woken.jobId} was woken in its own session (wake ${wakes}), with ${lanes} lanes running`;
3797
+ e.why = `its ${woken.provider} worker ${woken.jobId} was woken in its own session (wake ${wakes})`;
3893
3798
  step(e, now, "woken", e.why);
3894
3799
  }
3895
3800
  catch (err) {
@@ -3897,9 +3802,6 @@ export async function driveStoryQueue(board, world, now) {
3897
3802
  throw err;
3898
3803
  if (err.retained !== undefined) {
3899
3804
  e.worker = { ...(pressedAfterCarrierStarted(e, parked) ? parked : err.retained), wakes };
3900
- budget.refused(reservation);
3901
- laneTaken = false;
3902
- lanes = budget.count();
3903
3805
  e.state = "queued";
3904
3806
  e.why = `its existing native context is retained; the new follow-up was not sent: ${err.message}`;
3905
3807
  save();
@@ -3907,18 +3809,12 @@ export async function driveStoryQueue(board, world, now) {
3907
3809
  }
3908
3810
  if (err instanceof WorkerStartUnconfirmed) {
3909
3811
  e.worker = { ...(e.worker ?? parked), startedAt: now, wakes };
3910
- budget.accepted(reservation, e.worker);
3911
- laneTaken = false;
3912
- lanes = budget.count();
3913
3812
  delete e.worker.parkedAt;
3914
3813
  noteStartUnconfirmed(e, e.worker, err.message, err.deadlineAt, Date.now());
3915
3814
  continue;
3916
3815
  }
3917
3816
  if (err instanceof SessionStillRunning) {
3918
3817
  // OWNER: ITER/LOOP — the session still ran when it was woken, so Claude Code started a copy, which took the message and was stopped: the session's own process never got it, so the worker stays parked and is stopped and woken again; the next entry is read.
3919
- budget.refused(reservation);
3920
- laneTaken = false;
3921
- lanes = budget.count();
3922
3818
  e.worker = { ...parked, startedAt: now, parkedAt: now, wakes };
3923
3819
  e.state = "queued";
3924
3820
  delete e.forced;
@@ -3939,9 +3835,6 @@ export async function driveStoryQueue(board, world, now) {
3939
3835
  noteTranscriptRefused(e, now, refusal.message);
3940
3836
  }
3941
3837
  if (after !== undefined && noteCarried(e, after, now)) {
3942
- budget.refused(reservation);
3943
- laneTaken = false;
3944
- lanes = budget.count();
3945
3838
  save();
3946
3839
  continue;
3947
3840
  }
@@ -3957,9 +3850,6 @@ export async function driveStoryQueue(board, world, now) {
3957
3850
  }
3958
3851
  else if (!err.unsent) {
3959
3852
  // 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.
3960
- budget.refused(reservation);
3961
- laneTaken = false;
3962
- lanes = budget.count();
3963
3853
  e.worker = { ...parked, startedAt: now, parkedAt: now, wakes };
3964
3854
  e.state = "queued";
3965
3855
  delete e.forced;
@@ -3969,9 +3859,6 @@ export async function driveStoryQueue(board, world, now) {
3969
3859
  }
3970
3860
  else {
3971
3861
  // 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.
3972
- budget.refused(reservation);
3973
- laneTaken = false;
3974
- lanes = budget.count();
3975
3862
  const why = `its ${parked.provider} worker ${parked.jobId} could not be woken: ${err.message}`;
3976
3863
  delete e.worker;
3977
3864
  delete e.forced;
@@ -4042,19 +3929,13 @@ export async function driveStoryQueue(board, world, now) {
4042
3929
  e.state = "starting";
4043
3930
  e.attempts += 1;
4044
3931
  delete e.worker;
4045
- step(e, now, "selected", `start ${e.attempts}${e.attempts > WORKER_ATTEMPTS ? ", past the attempts a story is given" : ` of ${WORKER_ATTEMPTS}`}, with ${lanes} lanes running${forced ? ` — ${forcer} ⚡ Force start, past the queue's ⏸ Stop` : ""}`);
3932
+ 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 the queue's ⏸ Stop` : ""}`);
4046
3933
  save();
4047
- reservation = budget.reserve();
4048
- lanes = budget.count();
4049
- laneTaken = true;
4050
3934
  try {
4051
3935
  e.worker = await world.launch(e, board, (sent) => {
4052
3936
  e.worker = sent;
4053
3937
  save();
4054
3938
  });
4055
- budget.accepted(reservation, e.worker);
4056
- laneTaken = false;
4057
- lanes = budget.count();
4058
3939
  if (noteCarried(e, { alive: true, why: "", carried: e.worker.carried }, now)) {
4059
3940
  save();
4060
3941
  continue;
@@ -4066,9 +3947,6 @@ export async function driveStoryQueue(board, world, now) {
4066
3947
  if (!(err instanceof WorkerNotStarted))
4067
3948
  throw err;
4068
3949
  if (err instanceof WorkerStartUnconfirmed && e.worker !== undefined) {
4069
- budget.accepted(reservation, e.worker);
4070
- laneTaken = false;
4071
- lanes = budget.count();
4072
3950
  noteStartUnconfirmed(e, e.worker, err.message, err.deadlineAt, Date.now());
4073
3951
  continue;
4074
3952
  }
@@ -4078,9 +3956,6 @@ export async function driveStoryQueue(board, world, now) {
4078
3956
  delete e.worker;
4079
3957
  const made = clearRefusal(e, world.worker(e, board));
4080
3958
  if (noteCarried(e, made, now)) {
4081
- budget.accepted(reservation, e.worker);
4082
- laneTaken = false;
4083
- lanes = budget.count();
4084
3959
  save();
4085
3960
  continue;
4086
3961
  }
@@ -4088,18 +3963,12 @@ export async function driveStoryQueue(board, world, now) {
4088
3963
  if (made.alive && made.found !== undefined) {
4089
3964
  // OWNER: ITER/LOOP — the start answered no job id, yet the provider made the story's job: that job is the entry's worker, so no second one is started.
4090
3965
  e.worker = made.found;
4091
- budget.accepted(reservation, e.worker);
4092
- laneTaken = false;
4093
- lanes = budget.count();
4094
3966
  e.why = `its ${made.found.provider} worker ${made.found.jobId} runs, though its start answered: ${err.message}`;
4095
3967
  step(e, Date.now(), "started", e.why);
4096
3968
  save();
4097
3969
  continue;
4098
3970
  }
4099
3971
  // OWNER: ITER/LOOP — the provider refused this story's start, so its entry carries the provider's words and is started again on its backoff like a worker that ended, or stops failed when the provider refused it for good; the next entry in line is started.
4100
- budget.refused(reservation);
4101
- laneTaken = false;
4102
- lanes = budget.count();
4103
3972
  step(e, Date.now(), "worker-ended", `its ${e.provider} worker could not be started: ${err.message}`);
4104
3973
  afterWorker(e, now, `its ${e.provider} worker could not be started: ${err.message}`, err.retried);
4105
3974
  }
@@ -4108,11 +3977,7 @@ export async function driveStoryQueue(board, world, now) {
4108
3977
  catch (err) {
4109
3978
  if (!(err instanceof TranscriptRefused))
4110
3979
  throw err;
4111
- // OWNER: ITER/LOOP — the disk refused this one worker's transcript while its entry was read for a start or wake: it keeps its state, the refusal names the file on its why and trace once, the lane it took is given back, the next entry in line is started, and the next pass reads it again.
4112
- if (laneTaken) {
4113
- budget.refused(reservation);
4114
- lanes = budget.count();
4115
- }
3980
+ // OWNER: ITER/LOOP — the disk refused this one worker's transcript while its entry was read for a start or wake: it keeps its state, the refusal names the file on its why and trace once, the next entry in line is started, and the next pass reads it again.
4116
3981
  noteTranscriptRefused(e, now, err.message);
4117
3982
  save();
4118
3983
  }
@@ -4252,6 +4117,49 @@ export async function placeStory(board, storyId, place, now, by) {
4252
4117
  return e;
4253
4118
  });
4254
4119
  }
4120
+ const WAITING_STATES = new Set(["queued", "retrying", "failed"]);
4121
+ /**
4122
+ * 🔴 #4354 — HIS MOVE OF ONE OR SEVERAL WAITING STORIES, ATOMIC AND MINIMAL: under ONE lock the line is read, `decide` is handed the waiting
4123
+ * stories (the ones named in `visible` when given) in their order and answers the new order and which stories moved, and the store is
4124
+ * written ONCE with each moved story, and each story he placed before, put at the place it holds in the new line — so a queue pass never
4125
+ * reads half a move, and a story that arrives later still sorts by priority and size around the places he pinned. Throws {@link NotInQueue}
4126
+ * for a story the line does not wait on, and {@link StoryPressRefused} when the new order cannot be reproduced; answers the new waiting order.
4127
+ */
4128
+ export async function placeWaiting(board, now, by, decide, visible) {
4129
+ return withQueueLock(board, now, async () => {
4130
+ const store = readQueueStore(board);
4131
+ const line = queueOrder(store);
4132
+ const waiting = line.filter((e) => WAITING_STATES.has(e.state) && (visible === undefined || visible.includes(e.storyId))).map((e) => e.storyId);
4133
+ const { next, moved } = decide(waiting);
4134
+ for (const id of moved)
4135
+ if (!waiting.includes(id))
4136
+ throw new NotInQueue(board, id);
4137
+ const refill = next.slice();
4138
+ const slotOf = new Map();
4139
+ line.forEach((e, slot) => slotOf.set(refill.length > 0 && waiting.includes(e.storyId) ? refill.shift() : e.storyId, slot));
4140
+ const place = (target, ids) => {
4141
+ for (const id of [...ids].sort((a, b) => slotOf.get(a) - slotOf.get(b)))
4142
+ placeAt(target, target.entries.find((x) => x.storyId === id && IN_LINE.has(x.state)), slotOf.get(id));
4143
+ };
4144
+ const wanted = (target) => queueOrder(target).filter((e) => waiting.includes(e.storyId)).map((e) => e.storyId).join() === next.join();
4145
+ const placed = new Set([...moved, ...line.filter((e) => e.manual !== undefined).map((e) => e.storyId)]);
4146
+ let pins = placed;
4147
+ const probe = structuredClone(store);
4148
+ place(probe, pins);
4149
+ if (!wanted(probe)) {
4150
+ pins = new Set([...placed, ...waiting]);
4151
+ const all = structuredClone(store);
4152
+ place(all, pins);
4153
+ if (!wanted(all))
4154
+ throw new StoryPressRefused(`the new order of ${next.map((id) => `#${id}`).join(", ")} could not be held by the line as it stands, so nothing was moved`);
4155
+ }
4156
+ place(store, pins);
4157
+ for (const id of moved)
4158
+ step(store.entries.find((x) => x.storyId === id && IN_LINE.has(x.state)), now, "placed", `${by} move put it at place ${slotOf.get(id) + 1}`);
4159
+ writeStore(board, store);
4160
+ return queueOrder(store).filter((e) => waiting.includes(e.storyId)).map((e) => e.storyId);
4161
+ });
4162
+ }
4255
4163
  /** 🔴 #4154 — FleetView's investigator ruled ABORT on the worker `jobId` of this story: its entry leaves the line, so the stopped worker is never woken, and his next Start press brings the story back; undefined when no entry in line runs that worker. */
4256
4164
  export async function withdrawStory(board, storyId, jobId, why, now) {
4257
4165
  return withQueueLock(board, now, async () => {
@@ -4959,7 +4867,7 @@ export async function launchClaudeJob(name, model, brief, cwd, cli, now, env = l
4959
4867
  * as its identity is known and again right before the post is sent. No login is {@link WorkerRefused}; an unsent first input keeps
4960
4868
  * that same session with its input pending; a lost answer to the sent input is {@link WorkerStartUnconfirmed}.
4961
4869
  */
4962
- export async function postCodexStory(control, board, name, message, now, record, held, maximumThreads, model) {
4870
+ export async function postCodexStory(control, board, name, message, now, record, held, model) {
4963
4871
  let submitted = false;
4964
4872
  let worker;
4965
4873
  try {
@@ -4967,11 +4875,11 @@ export async function postCodexStory(control, board, name, message, now, record,
4967
4875
  if (!login.signedIn)
4968
4876
  throw new WorkerRefused(login.why);
4969
4877
  await control.daemonUp();
4970
- const main = await control.startMain(board, name, held, maximumThreads, model, made => {
4971
- worker = { provider: "codex", codexDirect: true, nativeInputPending: true, startedAt: now, jobId: made.threadId, ...(model === undefined ? {} : { nativeModel: model }), activity: { identity: providerActivityIdentity("codex", made.threadId), newlyActive: true } };
4878
+ const main = await control.startMain(board, name, held, model, made => {
4879
+ worker = { provider: "codex", codexDirect: true, nativeInputPending: true, startedAt: now, jobId: made.threadId, ...(model === undefined ? {} : { nativeModel: model }) };
4972
4880
  record(worker);
4973
4881
  });
4974
- await control.post(main.threadId, message, (working) => { worker.activity.newlyActive = !working; delete worker.nativeInputPending; record(worker); submitted = true; });
4882
+ await control.post(main.threadId, message, () => { delete worker.nativeInputPending; record(worker); submitted = true; });
4975
4883
  return worker;
4976
4884
  }
4977
4885
  catch (err) {
@@ -3,7 +3,7 @@ import { spawn, spawnSync } from "child_process";
3
3
  import { EventEmitter } from "events";
4
4
  import { appendFile, readdir, rm } from "fs/promises";
5
5
  import { existsSync, mkdtempSync, writeFileSync, createReadStream, rmSync } from "fs";
6
- import { tmpdir } from "os";
6
+ import { tmpdir, release } from "os";
7
7
  import { join } from "path";
8
8
  import { fileURLToPath } from "url";
9
9
  import headless from "@xterm/headless";
@@ -12,6 +12,8 @@ import { GatewayError, MAX_WAIT_SECONDS } from "./conversations.js";
12
12
  import { nativeAgentEnv } from "./provider.js";
13
13
  // GATE: the lines of a CLI's earlier output its screen keeps above the visible rows, on the server and in the browser alike; a line older than this scrolls off the top
14
14
  export const CLI_SCROLLBACK_LINES = 100_000;
15
+ /** How a Windows pty's screen is mirrored: ConPTY repaints its viewport by absolute position and never pulls scrollback down when rows grow, so the server's screen and the browser's must resize the way ConPTY does or a line is lost; absent off Windows. */
16
+ export const CLI_WINDOWS_PTY = process.platform === "win32" ? { backend: "conpty", buildNumber: Number(release().split(".")[2]) } : undefined;
15
17
  export function createTerminalOwner(host) {
16
18
  const { Terminal } = headless;
17
19
  const { SerializeAddon } = serializer;
@@ -100,7 +102,7 @@ export function createTerminalOwner(host) {
100
102
  }
101
103
  this.started = new Promise((resolve) => { this.settleStarted = (refusal) => { clearTimeout(this.startTimer); resolve(refusal); }; });
102
104
  this.startTimer = setTimeout(() => this.fail(`${spec.provider.label} was not running ${MAX_WAIT_SECONDS} s after it was asked to start.`), MAX_WAIT_SECONDS * 1000);
103
- this.screen = new Terminal({ cols: spec.cols, rows: spec.rows, scrollback: CLI_SCROLLBACK_LINES, allowProposedApi: true });
105
+ this.screen = new Terminal({ cols: spec.cols, rows: spec.rows, scrollback: CLI_SCROLLBACK_LINES, allowProposedApi: true, windowsPty: CLI_WINDOWS_PTY });
104
106
  this.screen.loadAddon(this.serialize);
105
107
  writeFileSync(this.spool, "");
106
108
  const bundled = new URL("./nativeTerminalWorker.mjs", import.meta.url);
@@ -115,6 +117,8 @@ export function createTerminalOwner(host) {
115
117
  }
116
118
  else if (message.kind === "data")
117
119
  this.deliver(message.data);
120
+ else if (message.kind === "resized")
121
+ this.resized(message.cols, message.rows);
118
122
  else if (message.kind === "unavailable")
119
123
  this.fail(message.message);
120
124
  else if (message.kind === "closeFailed") {
@@ -137,6 +141,8 @@ export function createTerminalOwner(host) {
137
141
  this.child.on("error", (error) => this.fail(error.message));
138
142
  this.child.on("exit", () => {
139
143
  this.end();
144
+ for (const applied of this.resizeApplied.splice(0))
145
+ applied();
140
146
  // The worker can die before it ever reports a pid — a missing or unloadable worker exits silently — and the open
141
147
  // waiting on `started` would then never answer: its own stderr is the reason it is given.
142
148
  this.settleStarted(this.processId === undefined ? (this.failure ?? `${this.provider} ended before it started.`) : undefined);
@@ -332,11 +338,28 @@ export function createTerminalOwner(host) {
332
338
  });
333
339
  }
334
340
  fileRequest = 0;
341
+ /** Takes the browser's size unless the CLI already has it; the screen follows only once the pty confirms. */
335
342
  resize(cols, rows) {
336
343
  this.live();
337
- return this.send({ kind: "resize", cols, rows }).then(() => {
338
- this.screen.resize(cols, rows);
344
+ if (cols === this.screen.cols && rows === this.screen.rows)
345
+ return Promise.resolve();
346
+ const applied = new Promise((resolve) => {
347
+ const timer = setTimeout(() => { this.fail(`The CLI did not confirm its new size ${MAX_WAIT_SECONDS} s after it was asked.`); resolve(); }, MAX_WAIT_SECONDS * 1000); // GATE: the door holds no request longer than MAX_WAIT_SECONDS
348
+ this.resizeApplied.push(() => { clearTimeout(timer); resolve(); });
339
349
  });
350
+ return this.send({ kind: "resize", cols, rows }).then(() => applied);
351
+ }
352
+ /** Counts every size the screen has taken; a reader that last saw an older count is handed the whole screen again. */
353
+ sizeRevision = 0;
354
+ resizeApplied = [];
355
+ /** The pty has taken its new size: the screen takes it after every chunk already read from the pty. */
356
+ resized(cols, rows) {
357
+ this.writing = this.writing.then(() => {
358
+ this.screen.resize(cols, rows);
359
+ this.sizeRevision++;
360
+ this.events.emit("change");
361
+ this.resizeApplied.shift()?.();
362
+ }).catch((error) => this.fail(`The terminal could not take its new size: ${error.message}`));
340
363
  }
341
364
  /** One close per terminal: every later caller — a second tab, a reap after an exit, a failure — awaits the same
342
365
  * promise, so the record is removed, the screen disposed and the spool deleted exactly once. */
@@ -149,8 +149,8 @@ process.on("message", (message) => {
149
149
  }
150
150
  }
151
151
  else if (message.kind === "resize") {
152
- if (terminal)
153
- terminal.resize(message.cols, message.rows);
152
+ terminal?.resize(message.cols, message.rows);
153
+ send({ kind: "resized", cols: message.cols, rows: message.rows });
154
154
  }
155
155
  else if (message.kind === "close")
156
156
  end();
@@ -65,7 +65,12 @@ export function attachTerminalSocket(ws, terminal, access) {
65
65
  });
66
66
  void (async () => {
67
67
  let after;
68
+ let seen = terminal.sizeRevision;
68
69
  while (!disconnected.signal.aborted && ws.readyState === WebSocket.OPEN) {
70
+ if (seen !== terminal.sizeRevision) {
71
+ after = undefined;
72
+ seen = terminal.sizeRevision;
73
+ }
69
74
  const frame = await terminal.read(after, disconnected.signal);
70
75
  if (!access.admitted()) {
71
76
  ws.close(1008, "Sign in again");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.392",
3
+ "version": "1.3.393",
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",