omni-notify-mcp 1.3.437 → 1.3.439

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.
@@ -2790,19 +2790,88 @@ export function markQueueStopped(board, why, now, version) {
2790
2790
  return;
2791
2791
  writeWhole(board, servedFile(board), { pid: process.pid, at: now, version, stopped: why });
2792
2792
  }
2793
- /** Whether FleetView's story queue drives this board: the process that marked its last pass still runs and its beat has not stopped, with the reason its last pass failed when it did — else why not, in plain words. A live FleetView that stops answering shows as requests its acks never name ({@link ACK_LATE_MS}). */
2794
- export function queueServed(board) {
2793
+ // GATE: how long the live FleetView that marked a board may go without a pass over it before the board says its queue has stalled; past it the board's switch names the stall, when FleetView last answered a request, the last request written and their ages, and nothing is refused on it
2794
+ export const QUEUE_PASS_LATE_MS = 5 * 60_000;
2795
+ /** 🔴 #4266 — a span in plain words: seconds under a minute, minutes under an hour, else hours and minutes. */
2796
+ function spanWords(ms) {
2797
+ const s = Math.round(ms / 1000);
2798
+ if (s < 60)
2799
+ return `${s}s`;
2800
+ const m = Math.floor(s / 60);
2801
+ return m < 60 ? `${m}m` : `${Math.floor(m / 60)}h ${m % 60}m`;
2802
+ }
2803
+ /** 🔴 #4266 — what this board's queue folder says of FleetView's intake: the newest request BB wrote, the newest ack FleetView wrote, how many requests no ack names, and how many request or ack files could not be read — a torn file is counted, never taken for none. */
2804
+ function queueIntake(board) {
2805
+ let torn = 0;
2806
+ let waiting = 0;
2807
+ let written;
2808
+ let taken;
2809
+ const ids = requestedStories(board);
2810
+ for (const id of ids) {
2811
+ const r = readableRequestView(board, id);
2812
+ let ack;
2813
+ try {
2814
+ ack = readStoryAckView(board, id);
2815
+ }
2816
+ catch (err) {
2817
+ if (!(err instanceof SyntaxError))
2818
+ throw err;
2819
+ // OWNER: ITER/LOOP — a torn ack is counted among the files that could not be read and the request beside it is read on
2820
+ torn += 1;
2821
+ }
2822
+ // NULL-OK: field r is OPTIONAL and therefore it is ok to check for NULL
2823
+ if (r === undefined)
2824
+ torn += 1;
2825
+ else {
2826
+ if (written === undefined || r.submittedAt > written.submittedAt)
2827
+ written = r;
2828
+ if (ack?.requestId !== r.requestId)
2829
+ waiting += 1;
2830
+ }
2831
+ // NULL-OK: field ack is OPTIONAL and therefore it is ok to check for NULL
2832
+ if (ack !== undefined && (taken === undefined || ack.ackedAt > taken.ackedAt))
2833
+ taken = ack;
2834
+ }
2835
+ return { ...(written === undefined ? {} : { written }), ...(taken === undefined ? {} : { taken }), requests: ids.length, waiting, torn };
2836
+ }
2837
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
2838
+ /**
2839
+ * 🔴 #4266 — what FleetView has answered of BB's requests on this board: when it last wrote an ack, and how
2840
+ * many wait for it. A stalled queue writes no ack, and BB's rewrite of a waiting request keeps its id, so these words change
2841
+ * only when the queue does — the time BB last rewrote a request is in {@link queueAges}, never here.
2842
+ */
2843
+ function intakeWords(board) {
2844
+ const { taken, requests, waiting, torn } = queueIntake(board);
2845
+ if (requests === 0)
2846
+ return "BullseyeBacklog has written no request on this board";
2847
+ // NULL-OK: field taken is OPTIONAL and therefore it is ok to check for NULL
2848
+ const last = taken === undefined ? "FleetView has acknowledged no request here" : `FleetView last answered a request here at ${new Date(taken.ackedAt).toISOString()}`;
2849
+ const unread = torn === 0 ? "" : `, and ${plural(torn, "file", "files")} of them could not be read`;
2850
+ return `${last}; ${plural(waiting, "request", "requests")} of BullseyeBacklog's ${requests} here ${waiting === 1 ? "waits" : "wait"} unacknowledged${unread}`;
2851
+ }
2852
+ /** 🔴 #4266 — how long ago FleetView last passed over this board, last answered a request, and BB last wrote one, for a surface that draws a queue that is not healthy; empty when it holds none of them. */
2853
+ export function queueAges(board, now) {
2854
+ const beat = readJson(servedFile(board));
2855
+ const { written, taken } = queueIntake(board);
2856
+ // NULL-OK: field beat is OPTIONAL and therefore it is ok to check for NULL
2857
+ const ages = [...(beat === undefined ? [] : [`its last pass ${spanWords(now - beat.at)} ago`]), ...(taken === undefined ? [] : [`its last answer ${spanWords(now - taken.ackedAt)} ago`]), ...(written === undefined ? [] : [`the last request written #${written.storyId}, ${spanWords(now - written.submittedAt)} ago`])];
2858
+ return ages.join(", ");
2859
+ }
2860
+ /** Whether FleetView's story queue drives this board: the process that marked its last pass still runs and its beat has not stopped, with the reason its last pass failed when it did — else why not, in plain words. 🔴 #4266 — a live FleetView whose last pass here is older than {@link QUEUE_PASS_LATE_MS} reads as trouble naming that pass, when FleetView last answered a request and how many wait, and every not-served reading names that intake too, so a stalled queue is seen on the board's next poll; the words carry times, never a running age ({@link queueAges} says that), so a reading changes only when the queue does. */
2861
+ export function queueServed(board, now = Date.now()) {
2795
2862
  const beat = readJson(servedFile(board));
2796
2863
  // NULL-OK: field beat is OPTIONAL and therefore it is ok to check for NULL
2797
2864
  if (beat === undefined)
2798
- return { served: false, why: `FleetView's story queue has never driven ${board}`, exited: false };
2865
+ return { served: false, why: `FleetView's story queue has never driven ${board}; ${intakeWords(board)}`, exited: false };
2799
2866
  if (!isProcessAlive(beat.pid))
2800
- return { served: false, why: `the FleetView process ${beat.pid} that drove ${board}'s story queue has exited`, exited: true };
2867
+ return { served: false, why: `the FleetView process ${beat.pid} that drove ${board}'s story queue has exited, its last pass at ${new Date(beat.at).toISOString()}; ${intakeWords(board)}`, exited: true };
2801
2868
  // NULL-OK: field stopped is OPTIONAL and therefore it is ok to check for NULL
2802
2869
  if (beat.stopped !== undefined)
2803
- return { served: false, why: `FleetView process ${beat.pid} stopped driving ${board}'s story queue: ${beat.stopped}`, exited: false };
2870
+ return { served: false, why: `FleetView process ${beat.pid} stopped driving ${board}'s story queue: ${beat.stopped}; ${intakeWords(board)}`, exited: false };
2871
+ const late = now - beat.at > QUEUE_PASS_LATE_MS ? `FleetView process ${beat.pid} is alive but has made no pass over this board since ${new Date(beat.at).toISOString()}, longer than the ${spanWords(QUEUE_PASS_LATE_MS)} a pass may take; ${intakeWords(board)}` : undefined;
2804
2872
  // NULL-OK: field trouble is OPTIONAL and therefore it is ok to check for NULL
2805
- return beat.trouble === undefined ? { served: true } : { served: true, trouble: beat.trouble };
2873
+ const trouble = [late, beat.trouble].filter((t) => t !== undefined);
2874
+ return trouble.length === 0 ? { served: true } : { served: true, trouble: trouble.join("; and its last pass failed: ") };
2806
2875
  }
2807
2876
  /** 🔴 #4123 — whether dotted version `a` is later than `b`, part by part as numbers. */
2808
2877
  export function newerVersion(a, b) {
@@ -3724,10 +3793,20 @@ const stopDue = (worker, now) => worker.stoppedAt === undefined || now >= worker
3724
3793
  */
3725
3794
  export async function driveStoryQueue(board, world, now) {
3726
3795
  return withQueueLock(board, now, async () => {
3796
+ const store = await passHeld(board, world, now);
3797
+ // 🔴 #4529 — a ⚡ Force start recorded while this pass held the lock is taken in by one more round before the lock is let go, so it starts now, never on the next tick, and no press waiting in this process's line loses its turn to it
3798
+ return pendingPresses(board).length === 0 ? store : passHeld(board, world, Math.max(now, Date.now()));
3799
+ }, true);
3800
+ }
3801
+ /** One pass's work, run by {@link driveStoryQueue} under the lock it holds. */
3802
+ async function passHeld(board, world, now) {
3803
+ {
3727
3804
  const newer = newerDriver(board, world.driverVersion);
3728
3805
  // NULL-OK: field newer is OPTIONAL and therefore it is ok to check for NULL
3729
3806
  if (newer !== undefined)
3730
3807
  throw new QueueBusy(board, newer);
3808
+ // 🔴 #4529 — every ⚡ Force start recorded while another driver held the lock is pressed before the pass reads its line
3809
+ await takePendingPresses(board, now);
3731
3810
  // 🔴 #4336 — each pass makes its queue folders and .gitignore again once, so one removed by hand comes back on the next pass
3732
3811
  madeQueueDirs.clear();
3733
3812
  writeWhole(board, servedFile(board), { pid: process.pid, at: now, version: world.driverVersion });
@@ -4644,7 +4723,7 @@ export async function driveStoryQueue(board, world, now) {
4644
4723
  save();
4645
4724
  await writeAcks(board, store, refusals, applied, now);
4646
4725
  return store;
4647
- }, true);
4726
+ }
4648
4727
  }
4649
4728
  /** 🔴 #4188 — whose press a queue act records when no agent session made it: Meni's own, from the panel or the gateway-signed web page. */
4650
4729
  export const HIS_PRESS = "his";
@@ -4687,7 +4766,98 @@ function forceAhead(board, store, storyId, now, by) {
4687
4766
  * {@link StoryPressRefused}; one on a story not in line throws {@link NotInQueue}, except 🔴 #4522 a ⚡ Force start, which takes in the board's standing request or keeps the force for the request to come. Answers what it did, in words.
4688
4767
  */
4689
4768
  export async function pressStory(board, storyId, press, now, by, requestHandledByOwner = false, ownerAction) {
4690
- return withQueueLock(board, now, async () => {
4769
+ try {
4770
+ return await withQueueLock(board, now, () => pressHeld(board, storyId, press, now, by, requestHandledByOwner, ownerAction));
4771
+ }
4772
+ catch (err) {
4773
+ if (!(err instanceof QueueBusy) || press !== "force")
4774
+ throw err;
4775
+ // OWNER: ITER/LOOP — 🔴 #4529 another driver holds the queue's lock for its pass: his ⚡ Force start is recorded beside the queue, and the pass that holds the lock takes it in before it lets go (or the next pass does) — never refused.
4776
+ writeWhole(board, pressFile(board, storyId), { press, at: now, by });
4777
+ try {
4778
+ // the holder may have let go meanwhile: one look, never a second wait in line behind it
4779
+ const answered = await withQueueLock(board, now, () => takePendingPresses(board, now), true);
4780
+ const mine = answered.get(storyId);
4781
+ // the caller's own press, pressed here, answers as a direct press does: a refusal is thrown, never returned as words of success
4782
+ if (mine instanceof Error)
4783
+ throw mine;
4784
+ // NULL-OK: field mine is OPTIONAL and therefore it is ok to check for NULL
4785
+ if (mine !== undefined)
4786
+ return mine;
4787
+ }
4788
+ catch (again) {
4789
+ if (!(again instanceof QueueBusy))
4790
+ throw again;
4791
+ }
4792
+ return `#${storyId}'s ⚡ Force start is recorded — ${err.message}, and the queue's pass takes it in and starts it — the pass holding the queue now before it lets go, or the next one — past a ⏸ Stop and this workspace's lane limit`;
4793
+ }
4794
+ }
4795
+ const pressDir = (board) => path.join(storyQueueDir(board), "presses");
4796
+ const pressFile = (board, id) => path.join(pressDir(board), `${id}.json`);
4797
+ /** 🔴 #4529 — the stories a ⚡ Force start was recorded on while another driver held the queue's lock. */
4798
+ function pendingPresses(board) {
4799
+ const dir = pressDir(board);
4800
+ if (!fs.existsSync(dir))
4801
+ return [];
4802
+ return fs.readdirSync(dir).filter((f) => /^\d+\.json$/.test(f)).map((f) => Number(f.slice(0, -".json".length)));
4803
+ }
4804
+ /**
4805
+ * 🔴 #4529 — UNDER THE QUEUE'S LOCK: every ⚡ Force start recorded while another driver held it is pressed now, as his press
4806
+ * would have been, and its record removed; answers each story's words. A press that does not apply leaves its refusal on the
4807
+ * story's entry, where the queue's row shows it.
4808
+ */
4809
+ async function takePendingPresses(board, now) {
4810
+ const answered = new Map();
4811
+ for (const id of pendingPresses(board)) {
4812
+ const file = pressFile(board, id);
4813
+ let pending;
4814
+ try {
4815
+ pending = readJson(file);
4816
+ }
4817
+ catch (err) {
4818
+ // OWNER: ITER/LOOP — a press record that cannot be read (torn, not JSON, a folder by its name, the disk refusing it) is dropped with its words on the answer, so one bad record never stalls the board's queue; the next record is read.
4819
+ answered.set(id, new StoryPressRefused(`#${id}'s recorded ⚡ Force start could not be read, so it was dropped: ${err instanceof Error ? err.message : String(err)}`));
4820
+ pending = undefined;
4821
+ }
4822
+ try {
4823
+ fs.rmSync(file, { force: true, recursive: true });
4824
+ }
4825
+ catch (err) {
4826
+ // OWNER: ITER/LOOP — a record the disk will not let go of is left, and pressed again only when it reads as a press; the next record is read.
4827
+ if (!answered.has(id))
4828
+ answered.set(id, new StoryPressRefused(`#${id}'s recorded ⚡ Force start could not be removed: ${err instanceof Error ? err.message : String(err)}`));
4829
+ continue;
4830
+ }
4831
+ // NULL-OK: field pending is OPTIONAL and therefore it is ok to check for NULL
4832
+ if (pending === undefined || pending === null)
4833
+ continue;
4834
+ if (pending.press !== "force" || typeof pending.by !== "string" || typeof pending.at !== "number") {
4835
+ answered.set(id, new StoryPressRefused(`#${id}'s recorded press is not a ⚡ Force start this queue knows, so it was dropped`));
4836
+ continue;
4837
+ }
4838
+ const by = pending.by;
4839
+ try {
4840
+ answered.set(id, await pressHeld(board, id, "force", now, by, false, undefined, pending.at));
4841
+ }
4842
+ catch (err) {
4843
+ if (!(err instanceof StoryPressRefused) && !(err instanceof NotInQueue))
4844
+ throw err;
4845
+ // OWNER: ITER/LOOP — the recorded force does not apply (the board says the story is not to be started, or it is already at work): its words are kept on the story's entry and returned as the refusal; the next record is pressed.
4846
+ answered.set(id, err);
4847
+ const store = readQueueStore(board);
4848
+ const e = store.entries.find((x) => x.storyId === id);
4849
+ // NULL-OK: field e is OPTIONAL and therefore it is ok to check for NULL
4850
+ if (e !== undefined) {
4851
+ step(e, now, "updated", `${by} ⚡ Force start, recorded while another driver held the queue, was not applied — ${err.message}`);
4852
+ writeStore(board, store);
4853
+ }
4854
+ }
4855
+ }
4856
+ return answered;
4857
+ }
4858
+ /** {@link pressStory}'s press, run by a caller that already holds the queue's lock. */
4859
+ async function pressHeld(board, storyId, press, now, by, requestHandledByOwner = false, ownerAction, eventAt = now) {
4860
+ {
4691
4861
  const store = readQueueStore(board);
4692
4862
  const inLine = () => store.entries.find((x) => x.storyId === storyId && IN_LINE.has(x.state));
4693
4863
  const taken = press === "force" && inLine() === undefined ? takeStandingRequest(board, store, storyId, now) : undefined;
@@ -4697,7 +4867,7 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
4697
4867
  const left = store.entries.find((x) => x.storyId === storyId);
4698
4868
  // NULL-OK: field left is OPTIONAL and therefore it is ok to check for NULL
4699
4869
  if (press === "force" && left === undefined)
4700
- return forceAhead(board, store, storyId, now, by);
4870
+ return forceAhead(board, store, storyId, eventAt, by);
4701
4871
  throw new NotInQueue(board, storyId, left);
4702
4872
  }
4703
4873
  const working = e.state === "starting" || e.state === "running";
@@ -4736,7 +4906,7 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
4736
4906
  else if (press === "force") {
4737
4907
  if (working)
4738
4908
  throw new StoryPressRefused(`#${storyId} already has a worker at work, so there is nothing to force`);
4739
- forceEntry(e, now, by);
4909
+ forceEntry(e, now, by, eventAt);
4740
4910
  did = `#${storyId} ${taken === undefined ? "" : "was taken into the queue from BullseyeBacklog's request and "}starts on the next pass, past a ⏸ Stop and this workspace's lane limit`;
4741
4911
  }
4742
4912
  else if (press === "stop" || press === "kill") {
@@ -4784,7 +4954,7 @@ export async function pressStory(board, storyId, press, now, by, requestHandledB
4784
4954
  writeStore(board, store);
4785
4955
  await writeAcks(board, store, new Map(), new Map([[e.storyId, e.requestId]]), now);
4786
4956
  return did;
4787
- });
4957
+ }
4788
4958
  }
4789
4959
  export function autoStartHeld(board) {
4790
4960
  const hold = "so only his Start press or ⚡ Force start starts or wakes a story";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.437",
3
+ "version": "1.3.439",
4
4
  "homepage": "https://www.npmjs.com/package/omni-notify-mcp",
5
5
  "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.",
6
6
  "main": "dist/daemon.js",