omni-notify-mcp 1.3.394 → 1.3.395

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.
@@ -310,7 +310,7 @@ async function cliAttach(id,origin){
310
310
  },true);
311
311
  term.onData(function(data){ordered(id,"input",{data:data});});term.onBinary(function(data){ordered(id,"input",{data:btoa(data),binary:true});});
312
312
  refit=function(){if(mine!==view||!socket||socket.readyState!==WebSocket.OPEN)return;fitAddon.fit();ordered(id,"resize",{cols:term.cols,rows:term.rows});};
313
- observer=new ResizeObserver(refit);host.addEventListener("pointerdown",refit);host.addEventListener("touchstart",refit,{passive:true});window.addEventListener("focus",refit);document.addEventListener("visibilitychange",function(){if(!document.hidden)refit();});
313
+ if(observer)observer.disconnect();observer=new ResizeObserver(refit);host.addEventListener("pointerdown",refit);host.addEventListener("touchstart",refit,{passive:true});var wake=function(){if(!document.hidden)refit();},off=observer.disconnect.bind(observer);window.addEventListener("focus",wake);document.addEventListener("visibilitychange",wake);observer.disconnect=function(){window.removeEventListener("focus",wake);document.removeEventListener("visibilitychange",wake);off();};
314
314
  reattach.onclick=function(){cliAttach(id,origin);};
315
315
  back.onclick=goBack;
316
316
  close.onclick=async function(){close.disabled=true;try{await api("DELETE","/v1/terminals/"+id);swap("list");}catch(error){close.disabled=false;fail(error);}};
@@ -2830,6 +2830,8 @@ export async function recordQueueNativeStopResult(board, tokens, result, now) {
2830
2830
  });
2831
2831
  }
2832
2832
  const IN_LINE = new Set(["queued", "starting", "running", "retrying", "failed"]);
2833
+ /** The states that wait to be started: his places count among these only, so a story that started or finished never shifts a place he chose. */
2834
+ const WAITING_STATES = new Set(["queued", "retrying", "failed"]);
2833
2835
  const rankIn = (order, value) => order.indexOf(value);
2834
2836
  /**
2835
2837
  * The queue's order: automatic entries P0 → P5, then XS → XL inside a priority, then arrival; each entry he placed sits at
@@ -2837,19 +2839,21 @@ const rankIn = (order, value) => order.indexOf(value);
2837
2839
  */
2838
2840
  export function queueOrder(store) {
2839
2841
  const line = store.entries.filter((e) => IN_LINE.has(e.state));
2840
- const auto = line.filter((e) => e.manual === undefined).sort((a, b) => rankIn(PRI_ORDER, a.pri) - rankIn(PRI_ORDER, b.pri) || rankIn(EFFORT_ORDER, a.effort) - rankIn(EFFORT_ORDER, b.effort) || a.seq - b.seq);
2841
- const placed = line.filter((e) => e.manual !== undefined).sort((a, b) => a.manual - b.manual || a.seq - b.seq);
2842
- const out = [...auto];
2843
- for (const e of placed)
2844
- out.splice(Math.min(e.manual, out.length), 0, e);
2845
- return out;
2842
+ const byPriority = (x, y) => rankIn(PRI_ORDER, x.pri) - rankIn(PRI_ORDER, y.pri) || rankIn(EFFORT_ORDER, x.effort) - rankIn(EFFORT_ORDER, y.effort) || x.seq - y.seq;
2843
+ const started = line.filter((e) => !WAITING_STATES.has(e.state)).sort(byPriority);
2844
+ const waiting = line.filter((e) => WAITING_STATES.has(e.state));
2845
+ const placed = waiting.filter((e) => e.manual !== undefined).sort((x, y) => x.manual - y.manual || x.seq - y.seq);
2846
+ return [...started, ...placed, ...waiting.filter((e) => e.manual === undefined).sort(byPriority)];
2847
+ }
2848
+ /** His order of the waiting stories: each is stamped with its place in `order`, so the order holds whichever story starts, finishes or arrives — a story he never placed waits behind the ones he ordered, by priority and size. */
2849
+ function stampOrder(order) {
2850
+ order.forEach((e, place) => { e.manual = place; });
2846
2851
  }
2847
- /** His placement of `e` at the 0-based place `k`: every other entry he placed at `k` or after moves down one, so no two of his places tie and his newest move holds the place he chose. */
2852
+ /** His placement of `e` at the 0-based place `k` among the waiting stories (a place past the line is its end). */
2848
2853
  function placeAt(store, e, k) {
2849
- for (const o of store.entries)
2850
- if (o !== e && o.manual !== undefined && o.manual >= k)
2851
- o.manual += 1;
2852
- e.manual = k;
2854
+ const rest = queueOrder(store).filter((x) => x !== e && WAITING_STATES.has(x.state));
2855
+ rest.splice(Math.min(k, rest.length), 0, e);
2856
+ stampOrder(rest);
2853
2857
  }
2854
2858
  const step = (e, at, stage, detail) => {
2855
2859
  const last = e.trace[e.trace.length - 1];
@@ -3095,6 +3099,8 @@ export const RETRY_BASE_MS = 60_000;
3095
3099
  export const REARM_BASE_MS = RETRY_BASE_MS * 2 ** WORKER_ATTEMPTS;
3096
3100
  // GATE: how many times the wait before a given-up story is offered again doubles — past it the story is offered every REARM_BASE_MS * 2^REARM_DOUBLINGS (32 min), so an open story is never left unworked for good
3097
3101
  export const REARM_DOUBLINGS = 2;
3102
+ // GATE: how long a done story's archived Claude Code conversation is kept after its archive — past it the queue deletes every file of it, and a story that comes back later starts afresh
3103
+ export const ARCHIVE_KEPT_DAYS = 7;
3098
3104
  /** 🔴 #4123 — how long after the queue gave up on a story it is offered to the line again. */
3099
3105
  export const rearmDelayMs = (attempts) => REARM_BASE_MS * 2 ** Math.min(Math.max(attempts - WORKER_ATTEMPTS, 0), REARM_DOUBLINGS);
3100
3106
  /** The acks the passes' requests call for: one per request read, carrying its entry's state and place, rewritten only when one of them changed. */
@@ -3242,6 +3248,24 @@ const inArchive = (worker) => worker !== undefined && (worker.archivedAt !== und
3242
3248
  /** 🔴 #4188 — a queued row that keeps a parked worker no process runs: it waits in line, to be woken in its own session — it is no running worker, and it has one to wake. */
3243
3249
  // NULL-OK: field parkedAt is OPTIONAL and therefore it is ok to check for NULL
3244
3250
  const parkedInLine = (e) => e.state === "queued" && e.worker?.parkedAt !== undefined && !inArchive(e.worker);
3251
+ /**
3252
+ * 🔴 #4234 — why a done story's archived Claude Code conversations are past the days they are kept, or undefined while they are not:
3253
+ * an archived worker ages from its own archive, and an entry left holding only archived sessions from the last thing that happened
3254
+ * to it — a refusal of its own delete is no such thing. A Codex worker's archive is Codex's own, brought back through its thread, so it never ages out here.
3255
+ */
3256
+ function agedOutWhy(e, now) {
3257
+ const worker = e.worker;
3258
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3259
+ if (worker !== undefined && (worker.provider !== "claude" || worker.session === undefined))
3260
+ return undefined;
3261
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3262
+ const since = worker === undefined ? e.trace.slice().reverse().find((t) => t.stage !== "archive-refused").at : worker.archivedAt;
3263
+ if (now < since + ARCHIVE_KEPT_DAYS * 86_400_000)
3264
+ return undefined;
3265
+ const day = new Date(since).toISOString().slice(0, 10);
3266
+ // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
3267
+ return `${worker === undefined ? `nothing has happened to it since ${day}` : `its conversation was archived on ${day}`}, past the ${ARCHIVE_KEPT_DAYS} days an archive is kept`;
3268
+ }
3245
3269
  /** 🔴 #4143 — an archive or bring-back is tried at once, and one that was refused only after the wake's wait for its run of refusals. */
3246
3270
  // NULL-OK: field archiveRefused is OPTIONAL and therefore it is ok to check for NULL
3247
3271
  const archiveDue = (holder, now) => holder.archiveRefused === undefined || now >= holder.archiveRefused.at + wakeDelayMs(holder.archiveRefused.times - 1);
@@ -3328,7 +3352,7 @@ export async function driveStoryQueue(board, world, now) {
3328
3352
  // NULL-OK: field holder is OPTIONAL and therefore it is ok to check for NULL
3329
3353
  if (!IN_LINE.has(e.state) && holder !== undefined && archiveDue(holder, now)) {
3330
3354
  const worker = e.worker;
3331
- const cold = world.coldWhy(e.storyId);
3355
+ const cold = world.coldWhy(e.storyId) ?? agedOutWhy(e, now);
3332
3356
  // NULL-OK: field cold is OPTIONAL and therefore it is ok to check for NULL
3333
3357
  if (cold !== undefined) {
3334
3358
  // NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
@@ -3762,6 +3786,7 @@ export async function driveStoryQueue(board, world, now) {
3762
3786
  save();
3763
3787
  // NULL-OK: field stopped is OPTIONAL and therefore it is ok to check for NULL
3764
3788
  const halted = store.stopped === undefined ? undefined : `the queue is stopped (${store.stopped.by}), so nothing more starts or wakes until ▶ Run`;
3789
+ let lanes = world.lanesRunning();
3765
3790
  for (const e of queueOrder(store)) {
3766
3791
  try {
3767
3792
  const sessionId = wakeable.get(e);
@@ -3783,6 +3808,11 @@ export async function driveStoryQueue(board, world, now) {
3783
3808
  unwoken(`its worker ${parked.jobId} is parked, and ${halted}`);
3784
3809
  continue;
3785
3810
  }
3811
+ if (lanes >= world.limit && e.forced !== true) {
3812
+ unwoken(`its worker ${parked.jobId} is parked, and ${lanes} lanes run with this workspace's lane limit at ${world.limit}, so it is woken when one finishes`);
3813
+ continue;
3814
+ }
3815
+ lanes += 1;
3786
3816
  const wakes = (parked.wakes ?? 0) + 1;
3787
3817
  try {
3788
3818
  const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId), worker => { e.worker = worker; save(); });
@@ -3919,6 +3949,11 @@ export async function driveStoryQueue(board, world, now) {
3919
3949
  continue;
3920
3950
  }
3921
3951
  }
3952
+ if (lanes >= world.limit && e.forced !== true) {
3953
+ holdBack(e, now, "held-back", `${lanes} lanes run and this workspace's lane limit is ${world.limit}, so it starts when one finishes`);
3954
+ continue;
3955
+ }
3956
+ lanes += 1;
3922
3957
  world.seat(e);
3923
3958
  // NULL-OK: field forcedBy is OPTIONAL and therefore it is ok to check for NULL
3924
3959
  const forcer = e.forcedBy ?? "an unrecorded presser's";
@@ -4111,51 +4146,35 @@ export async function placeStory(board, storyId, place, now, by) {
4111
4146
  if (place === "auto")
4112
4147
  delete e.manual;
4113
4148
  else
4114
- placeAt(store, e, place);
4149
+ placeAt(store, e, Math.max(0, place - store.entries.filter((x) => IN_LINE.has(x.state) && !WAITING_STATES.has(x.state)).length));
4115
4150
  step(e, now, "placed", place === "auto" ? `${by} move handed it back to priority and size` : `${by} move put it at place ${place + 1}`);
4116
4151
  writeStore(board, store);
4117
4152
  return e;
4118
4153
  });
4119
4154
  }
4120
- const WAITING_STATES = new Set(["queued", "retrying", "failed"]);
4121
4155
  /**
4122
4156
  * 🔴 #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
4157
  * 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
4158
  * 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
4159
  * 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.
4160
+ * for a story the line does not wait on; a move that changes nothing writes nothing; answers the new waiting order.
4127
4161
  */
4128
4162
  export async function placeWaiting(board, now, by, decide, visible) {
4129
4163
  return withQueueLock(board, now, async () => {
4130
4164
  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);
4165
+ const line = queueOrder(store).filter((e) => WAITING_STATES.has(e.state));
4166
+ const waiting = line.filter((e) => visible === undefined || visible.includes(e.storyId)).map((e) => e.storyId);
4133
4167
  const { next, moved } = decide(waiting);
4134
4168
  for (const id of moved)
4135
4169
  if (!waiting.includes(id))
4136
4170
  throw new NotInQueue(board, id);
4171
+ if (next.join() === waiting.join())
4172
+ return waiting;
4137
4173
  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);
4174
+ const ordered = line.map((e) => (waiting.includes(e.storyId) ? refill.shift() : e.storyId));
4175
+ stampOrder(ordered.map((id) => line.find((e) => e.storyId === id)));
4157
4176
  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}`);
4177
+ step(line.find((e) => e.storyId === id), now, "placed", `${by} move put it at place ${ordered.indexOf(id) + 1}`);
4159
4178
  writeStore(board, store);
4160
4179
  return queueOrder(store).filter((e) => waiting.includes(e.storyId)).map((e) => e.storyId);
4161
4180
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omni-notify-mcp",
3
- "version": "1.3.394",
3
+ "version": "1.3.395",
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",