omni-notify-mcp 1.3.404 → 1.3.405

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.
@@ -3357,15 +3357,15 @@ function once(read) {
3357
3357
  return () => (held ??= { value: read() }).value;
3358
3358
  }
3359
3359
  /**
3360
- * 🔴 #4143 — a done story's Claude worker that no process holds any more is retired: taken off Claude Code's background
3360
+ * 🔴 #4143 — a done story's worker that no process holds any more is retired: a Claude one taken off Claude Code's background
3361
3361
  * list and its conversation moved out of every history list into the archive. One still at its prompt is stopped first
3362
- * ({@link idleWorker}) and one still mid-turn finishes its own last acts; a Codex worker is a post into a shared main, never retired.
3362
+ * ({@link idleWorker}) and one still mid-turn finishes its own last acts; a worker of any other provider is retired by its own provider (#4271).
3363
3363
  * An archive cut off half-way is finished whatever its worker reads: its job is already removed, so the reading says nothing of a process,
3364
3364
  * and its session was proven to have none before anything moved.
3365
3365
  */
3366
3366
  function retireable(worker, reading, now) {
3367
3367
  // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3368
- if (worker === undefined || (worker.provider !== "claude" && worker.codexDirect !== true) || worker.archivedAt !== undefined || !archiveDue(worker, now))
3368
+ if (worker === undefined || worker.archivedAt !== undefined || !archiveDue(worker, now))
3369
3369
  return undefined;
3370
3370
  if (worker.archiving === true)
3371
3371
  return worker;
@@ -3384,12 +3384,12 @@ const parkedInLine = (e) => e.state === "queued" && e.worker?.parkedAt !== undef
3384
3384
  /**
3385
3385
  * 🔴 #4234 — why a done story's archived conversations are past the days they are kept, or undefined while they are not:
3386
3386
  * an archived worker ages from its own archive, and an entry left holding only archived sessions from the last thing that happened
3387
- * to it — a refusal of its own delete is no such thing. A direct Codex worker ages the same way, and its thread is deleted through Codex's own `thread/delete`.
3387
+ * to it — a refusal of its own delete is no such thing. A worker of every other provider ages the same way (#4271): a direct Codex worker's thread is deleted through Codex's own `thread/delete`, and the earlier Claude sessions a provider with no archive of its own swept are deleted with it.
3388
3388
  */
3389
3389
  function agedOutWhy(e, now) {
3390
3390
  const worker = e.worker;
3391
3391
  // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3392
- if (worker !== undefined && worker.codexDirect !== true && (worker.provider !== "claude" || worker.session === undefined))
3392
+ if (worker !== undefined && worker.provider === "claude" && worker.session === undefined && (e.archivedSessions ?? []).length === 0)
3393
3393
  return undefined;
3394
3394
  // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3395
3395
  const since = worker === undefined ? e.trace.slice().reverse().find((t) => t.stage !== "archive-refused").at : worker.archivedAt;
@@ -3413,10 +3413,23 @@ function noteArchiveRefusal(e, holder, now, why) {
3413
3413
  if (last === undefined || last.why !== why)
3414
3414
  step(e, now, "archive-refused", e.why);
3415
3415
  }
3416
+ /** 🔴 #4271 — what a cold purge deleted, in words: a direct Codex worker's thread through Codex, a Claude worker's files with its earlier jobs', or nothing of a worker whose provider keeps no archive of its own — and, for the last two that are not Claude, the story's earlier Claude Code sessions whenever it had any. */
3417
+ function purgedWords(worker, earlier, freed) {
3418
+ const sessions = earlier === 0 ? "the story had no earlier Claude Code session to delete" : `the files of the story's ${earlier} earlier Claude Code session${earlier === 1 ? "" : "s"} were deleted — ${freed} bytes freed`;
3419
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3420
+ if (worker?.codexDirect === true)
3421
+ return `its archived Codex thread ${worker.jobId} was deleted through Codex${earlier === 0 ? "" : `, and ${sessions}`}`;
3422
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3423
+ if (worker !== undefined && worker.provider !== "claude")
3424
+ return `its agent keeps no archive of its own, so nothing of its worker was deleted, and ${sessions}`;
3425
+ return `every file they left on this box was deleted — ${freed} bytes freed`;
3426
+ }
3416
3427
  /** 🔴 #4143 — what an archive or a bring-back moved, in words. */
3417
3428
  function movedWords(moved) {
3418
3429
  if (moved === "unknown")
3419
3430
  return "no session of it is named on its entry or its job record, so no conversation of it could be found to move";
3431
+ if (moved === "no archive")
3432
+ return "its agent keeps no archive of its own, so nothing of it was moved";
3420
3433
  if (moved.length === 0)
3421
3434
  return "every file of its conversation had already been moved, or it never wrote one";
3422
3435
  return `its ${moved.join(" and its ")} moved`;
@@ -3469,7 +3482,7 @@ export async function driveStoryQueue(board, world, now) {
3469
3482
  const moved = await world.restore(worker);
3470
3483
  delete worker.archiving;
3471
3484
  delete worker.archiveRefused;
3472
- step(e, now, "restored", `its worker ${worker.jobId}'s conversation was brought back from the archive (${movedWords(moved)}), so the story's return wakes its own session`);
3485
+ step(e, now, "restored", `${moved === "no archive" ? `its worker ${worker.jobId} returns from the queue's archive alone (${movedWords(moved)})` : moved !== "unknown" && moved.includes("thread") ? `its worker ${worker.jobId}'s Codex thread was brought back through Codex` : `its worker ${worker.jobId}'s conversation was brought back from the archive (${movedWords(moved)})`}, so the story's return wakes its own session`);
3473
3486
  }
3474
3487
  catch (err) {
3475
3488
  if (!(err instanceof WorkerNotStarted))
@@ -3492,15 +3505,14 @@ export async function driveStoryQueue(board, world, now) {
3492
3505
  const whose = worker === undefined ? "its archived sessions" : `its archived worker ${worker.jobId}`;
3493
3506
  try {
3494
3507
  // NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
3495
- const own = worker?.session === undefined || (e.archivedSessions ?? []).some((s) => s.id === worker.session.id) ? [] : [worker.session];
3508
+ const own = worker?.session === undefined || worker.provider !== "claude" || (e.archivedSessions ?? []).some((s) => s.id === worker.session.id) ? [] : [worker.session];
3509
+ const earlier = (e.archivedSessions ?? []).length;
3496
3510
  // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3497
3511
  const freed = await world.purge([...own, ...(e.archivedSessions ?? [])], worker?.codexDirect === true ? worker.jobId : undefined);
3498
3512
  delete e.worker;
3499
3513
  delete e.archivedSessions;
3500
3514
  delete e.archiveRefused;
3501
- step(e, now, "purged", worker?.codexDirect === true
3502
- ? `${cold}, so ${whose} can never be woken again, and its archived Codex thread ${worker.jobId} was deleted through Codex`
3503
- : `${cold}, so ${whose} can never be woken again, and every file they left on this box was deleted — ${freed} bytes freed`);
3515
+ step(e, now, "purged", `${cold}, so ${whose} can never be woken again, and ${purgedWords(worker, earlier, freed)}`);
3504
3516
  }
3505
3517
  catch (err) {
3506
3518
  if (!(err instanceof WorkerNotStarted))
@@ -3906,7 +3918,7 @@ export async function driveStoryQueue(board, world, now) {
3906
3918
  worker.archivedAt = now;
3907
3919
  delete worker.archiving;
3908
3920
  delete worker.archiveRefused;
3909
- step(e, now, "archived", `its story is done and no process holds its worker ${worker.jobId}, so it left Claude Code's background list and ${movedWords(moved)} out of the history lists into the archive`);
3921
+ step(e, now, "archived", `its story is done and no process holds its worker ${worker.jobId}, so ${moved === "no archive" ? `it is archived on the queue alone — ${movedWords(moved)}` : `${moved !== "unknown" && moved.includes("thread") ? "its Codex thread was archived through Codex" : `it left Claude Code's background list and ${movedWords(moved)} out of the history lists into the archive`}`}`);
3910
3922
  }
3911
3923
  catch (err) {
3912
3924
  if (!(err instanceof WorkerNotStarted))
@@ -4953,10 +4965,15 @@ export async function retireStoryWorker(worker, cli, record, home = claudeHome()
4953
4965
  * story is archived once every process of it has gone; answers what of the worker's own conversation moved.
4954
4966
  */
4955
4967
  export async function retireStory(entry, board, worker, cli, record, home = claudeHome()) {
4968
+ await retireEarlierClaudeJobs(entry, board, worker.jobId, cli, (session) => record(session, "earlier"), home);
4969
+ return retireStoryWorker(worker, cli, (session) => record(session, "own"), home);
4970
+ }
4971
+ /** 🔴 #4271 — every Claude job started on a done story in `board` other than `workerJob` leaves every history list for the archive, whichever provider ran its last worker; refuses while a process of one still holds it. */
4972
+ export async function retireEarlierClaudeJobs(entry, board, workerJob, cli, record, home = claudeHome()) {
4956
4973
  const storyId = entry.storyId;
4957
4974
  const held = [];
4958
4975
  const earlier = new Set([...claudeJobsOfStory(storyId, board, 0, home), ...claudeJobsBriefed(entry.brief, home)]);
4959
- earlier.delete(worker.jobId);
4976
+ earlier.delete(workerJob);
4960
4977
  for (const jobId of earlier) {
4961
4978
  const job = jobRecordOf(jobId, home);
4962
4979
  if (job !== "torn" && job !== "gone" && liveClaudeSessions(home).has(job.sessionId)) {
@@ -4966,11 +4983,10 @@ export async function retireStory(entry, board, worker, cli, record, home = clau
4966
4983
  held.push(`${jobId} (${atPrompt ? "stopped at its prompt" : `still ${job.state}`})`);
4967
4984
  continue;
4968
4985
  }
4969
- await retireStoryWorker({ provider: "claude", startedAt: 0, jobId }, cli, (session) => record(session, "earlier"), home);
4986
+ await retireStoryWorker({ provider: "claude", startedAt: 0, jobId }, cli, record, home);
4970
4987
  }
4971
4988
  if (held.length > 0)
4972
4989
  throw new WorkerNotStarted(`an earlier job of #${storyId} still has a process — ${held.join(", ")} — so the story is archived once it has gone`);
4973
- return retireStoryWorker(worker, cli, (session) => record(session, "own"), home);
4974
4990
  }
4975
4991
  /** 🔴 #4143 — an archived worker's conversation goes back into `projects/`, where `claude --bg --resume` finds it to wake; answers which of its files moved. */
4976
4992
  export function restoreStoryWorker(worker, home = claudeHome()) {
@@ -50,6 +50,8 @@ function recordDirectory(extension) {
50
50
  const WORKSPACE_FILE = path.join(os.homedir(), ".bullseye", "webhost", "workspace.json");
51
51
  // GATE: a workspace pick body larger than this is answered 413 and never parsed.
52
52
  const PICK_BODY_BYTES = 4_096;
53
+ // GATE: a page socket is pinged this often so no tunnel or carrier idles it out; one that sent nothing (not even the browser's automatic pong) for a whole beat is ended, and its page reconnects.
54
+ const SOCKET_BEAT_MS = 20_000;
53
55
  /** Whether a parsed window record carries everything an entry address to that window needs. */
54
56
  function wholeRecord(record) {
55
57
  return record !== null && typeof record === "object" && Number.isInteger(record.port) && /^[0-9a-f]+$/.test(String(record.token)) && typeof record.label === "string" && typeof record.extension === "string" && record.pages !== null && typeof record.pages === "object";
@@ -640,6 +642,10 @@ class Page {
640
642
  socket.packed = true;
641
643
  return;
642
644
  }
645
+ if (frame !== null && frame.type === "ping") {
646
+ writeFrame(socket, '{"type":"pong"}');
647
+ return;
648
+ }
643
649
  // NULL-OK: field mirror is OPTIONAL and therefore it is ok to check for NULL
644
650
  if (frame === null || frame.type !== "message" || this.mirror === undefined) {
645
651
  return;
@@ -1217,7 +1223,19 @@ class WebHost {
1217
1223
  socket.packed = false;
1218
1224
  // NULL-OK: field at is OPTIONAL and therefore it is ok to check for NULL
1219
1225
  socket.at = new URLSearchParams(url.searchParams.get("at") ?? "");
1220
- const leave = () => page.sockets.delete(socket);
1226
+ socket.heard = true;
1227
+ const beat = setInterval(() => {
1228
+ if (!socket.heard) {
1229
+ socket.destroy();
1230
+ return;
1231
+ }
1232
+ socket.heard = false;
1233
+ writeFrameWithOpcode(socket, 0x9, Buffer.alloc(0));
1234
+ }, SOCKET_BEAT_MS);
1235
+ const leave = () => {
1236
+ clearInterval(beat);
1237
+ page.sockets.delete(socket);
1238
+ };
1221
1239
  page.sockets.add(socket);
1222
1240
  // NULL-OK: field mirror is OPTIONAL and therefore it is ok to check for NULL
1223
1241
  page.mirror?.forget();
@@ -1344,6 +1362,7 @@ function frameReader(socket, onText) {
1344
1362
  let buffer = Buffer.alloc(0);
1345
1363
  let parts = [];
1346
1364
  return (chunk) => {
1365
+ socket.heard = true;
1347
1366
  buffer = Buffer.concat([buffer, chunk]);
1348
1367
  for (;;) {
1349
1368
  if (buffer.length < 2) {
@@ -421,10 +421,33 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
421
421
 
422
422
  ` + PICKER_SOURCE + String.raw `
423
423
  var WHAT = "this page's live connection to its service";
424
+ // GATE: one health read is abandoned after this times the square of the tries so far (capped at 8000), then asked again
425
+ var ANSWER_MS = 700;
426
+ var healthTries = 0;
427
+ var lastHeard = Date.now();
428
+ var gone = false;
429
+
430
+ function hostGone() {
431
+ if (gone) {
432
+ return;
433
+ }
434
+ gone = true;
435
+ if (socket !== null) {
436
+ socket.close();
437
+ socket = null;
438
+ }
439
+ awaitHost();
440
+ }
424
441
 
425
442
  function awaitHost() {
426
443
  window.bullseyeConnection.reconnecting(WHAT, 250);
427
- window.fetch("/__bullseye/health", { cache: "no-store" }).then(function (response) {
444
+ var asking = new AbortController();
445
+ healthTries += 1;
446
+ window.setTimeout(function () {
447
+ asking.abort();
448
+ }, Math.min(ANSWER_MS * healthTries * healthTries, 8000));
449
+ window.fetch("/__bullseye/health", { cache: "no-store", signal: asking.signal }).then(function (response) {
450
+ healthTries = 0;
428
451
  if (response.ok) {
429
452
  window.bullseyeConnection.live();
430
453
  window.location.reload();
@@ -458,6 +481,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
458
481
  var unpacking = Promise.resolve();
459
482
  var unpackingCount = 0;
460
483
  socket.addEventListener("message", function (event) {
484
+ lastHeard = Date.now();
461
485
  if (typeof event.data === "string" && unpackingCount === 0) {
462
486
  handle(event.data);
463
487
  return;
@@ -497,7 +521,7 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
497
521
  socket = null;
498
522
  if (opened) {
499
523
  window.bullseyeConnection.reconnecting(WHAT, 250);
500
- window.setTimeout(awaitHost, 250);
524
+ window.setTimeout(hostGone, 250);
501
525
  return;
502
526
  }
503
527
  window.fetch("/__bullseye/health", { cache: "no-store" }).then(function (response) {
@@ -510,6 +534,62 @@ const SHIM_SOURCE = CONNECTION_SOURCE + ";" + String.raw `(function () {
510
534
  });
511
535
  }
512
536
 
537
+ // GATE: the page pings this often while visible; a socket a tunnel or a suspended phone tab cut sends no close, and one that hears nothing back goes to the reload path
538
+ var BEAT_MS = 20000;
539
+ // GATE: a ping sent on being seen again must come back within this, or the page treats the socket as dead; the steady beat instead ends a socket that heard nothing for a whole beat
540
+ var PING_ANSWER_MS = 1200;
541
+
542
+ var lastBeat = lastHeard;
543
+
544
+ function beat() {
545
+ if (gone || socket === null || socket.readyState !== 1) {
546
+ return;
547
+ }
548
+ if (lastHeard < lastBeat) {
549
+ hostGone();
550
+ return;
551
+ }
552
+ lastBeat = Date.now();
553
+ socket.send('{"type":"ping"}');
554
+ }
555
+
556
+ function probe() {
557
+ if (gone) {
558
+ return;
559
+ }
560
+ if (socket === null || socket.readyState === 0) {
561
+ return;
562
+ }
563
+ if (socket.readyState !== 1) {
564
+ hostGone();
565
+ return;
566
+ }
567
+ var asked = Date.now();
568
+ socket.send('{"type":"ping"}');
569
+ window.setTimeout(function () {
570
+ if (lastHeard < asked) {
571
+ hostGone();
572
+ }
573
+ }, PING_ANSWER_MS);
574
+ }
575
+
576
+ window.setInterval(function () {
577
+ if (document.visibilityState === "visible") {
578
+ beat();
579
+ }
580
+ }, BEAT_MS);
581
+ document.addEventListener("visibilitychange", function () {
582
+ if (document.visibilityState === "visible") {
583
+ probe();
584
+ }
585
+ });
586
+ window.addEventListener("pageshow", function (event) {
587
+ if (event.persisted) {
588
+ probe();
589
+ }
590
+ });
591
+ window.addEventListener("online", probe);
592
+
513
593
  window.acquireVsCodeApi = function () {
514
594
  if (acquired) {
515
595
  throw new Error("An instance of the VS Code API has already been acquired");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.404",
3
+ "version": "1.3.405",
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",