omni-notify-mcp 1.3.368 โ 1.3.369
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.
- package/dist/shared/agentSession.js +228 -107
- package/package.json +1 -1
|
@@ -2124,16 +2124,27 @@ export const WAKE_BASE_MS = 60_000;
|
|
|
2124
2124
|
export const WAKE_DOUBLINGS = 5;
|
|
2125
2125
|
/** ๐ด #4123 โ how long after its turn ended a worker woken `wakes` times before is woken again. */
|
|
2126
2126
|
export const wakeDelayMs = (wakes) => WAKE_BASE_MS * 2 ** Math.min(wakes, WAKE_DOUBLINGS);
|
|
2127
|
+
/** ๐ด #4123 โ where every queue worker stands, said at its start and at each wake: what it clears itself, and how a decision of Meni's reaches him and comes back. */
|
|
2128
|
+
const workerStanding = (storyId) => `A stop you named that you or another agent can clear (a board write refused, the board MCP not loaded yet, a release step) is yours to clear now โ never a reason to end your turn. A run the box's CPU ceiling refuses is handled as its refusal says; never stop or kill a process to make room.
|
|
2129
|
+
If a decision only Meni can make stands in the way, record it on #${storyId} with bullseye-backlog \`ask\` and ask him with the notify MCP \`ask\` tool, which reaches his email and text; when its wait ends unanswered, keep calling \`wait_for_inbox\` until his reply arrives, then \`rule\` his answer onto #${storyId} verbatim, apply it and go on. End your turn only once the story is shipped.`;
|
|
2127
2130
|
/** ๐ด #4123 โ what a parked worker is told when the queue wakes it in its own session. */
|
|
2128
2131
|
export const wakeMessage = (storyId) => `FleetView's story queue woke you: #${storyId} is still OPEN on the board and you are its one worker. Re-read it with bullseye-backlog \`get\` and carry it to \`ship\` in this turn.
|
|
2129
|
-
|
|
2130
|
-
|
|
2132
|
+
${workerStanding(storyId)}`;
|
|
2133
|
+
/** ๐ด #4123 โ the brief a queue worker is started with: the story's own brief first, so its job is still found by its first line, then where a worker with no main session above it stands. */
|
|
2134
|
+
export const workerBrief = (entry) => `${entry.brief}
|
|
2135
|
+
|
|
2136
|
+
FleetView's story queue started you on #${entry.storyId}, and no main session stands above you. Where the brief above speaks of main โ a finding sent to main, a turn end that hands you back to main โ nobody is there to take it: a finding with no tie to this story is appended to #${entry.storyId}'s Remaining line โ read it with bullseye-backlog \`get\`, then \`update\` it with the old text plus the finding, pinned with the \`expectHash\` the read gave โ and the review, the land, the release and the ship are yours.
|
|
2137
|
+
${workerStanding(entry.storyId)}`;
|
|
2131
2138
|
// GATE: how many times one story's worker is started before the queue gives up on it and its entry stops in `failed` โ each start that ends with the story still open is one
|
|
2132
2139
|
export const WORKER_ATTEMPTS = 3;
|
|
2133
2140
|
// GATE: the wait before a story whose worker ended is started again: this, doubled for each earlier attempt
|
|
2134
2141
|
export const RETRY_BASE_MS = 60_000;
|
|
2135
2142
|
// GATE: the wait before a story the queue gave up on is offered to the line again: this, doubled for each start past WORKER_ATTEMPTS
|
|
2136
2143
|
export const REARM_BASE_MS = RETRY_BASE_MS * 2 ** WORKER_ATTEMPTS;
|
|
2144
|
+
// 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
|
|
2145
|
+
export const REARM_DOUBLINGS = 2;
|
|
2146
|
+
/** ๐ด #4123 โ how long after the queue gave up on a story it is offered to the line again. */
|
|
2147
|
+
export const rearmDelayMs = (attempts) => REARM_BASE_MS * 2 ** Math.min(Math.max(attempts - WORKER_ATTEMPTS, 0), REARM_DOUBLINGS);
|
|
2137
2148
|
/** 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. */
|
|
2138
2149
|
function writeAcks(board, store, refusals, applied, now) {
|
|
2139
2150
|
const order = queueOrder(store);
|
|
@@ -2178,6 +2189,24 @@ function afterWorker(e, now, why, retried = true) {
|
|
|
2178
2189
|
step(e, now, "retry", e.why);
|
|
2179
2190
|
}
|
|
2180
2191
|
}
|
|
2192
|
+
/**
|
|
2193
|
+
* ๐ด #14202 โ a story the queue no longer works gives back its Claude worker's process the moment that worker's turn is over:
|
|
2194
|
+
* Claude Code's daemon keeps a settled worker at its prompt until the box runs low on memory, so a process the queue leaves
|
|
2195
|
+
* behind holds its memory for good. The entry KEEPS its worker, so a story that comes back to the line wakes that same session;
|
|
2196
|
+
* a worker still mid-turn is read again on the next pass, so its own last acts are never cut off; a stop the provider refused
|
|
2197
|
+
* is tried again after the worker's wait. A Codex worker is a post into a shared Codex main, which has no process to give back.
|
|
2198
|
+
*/
|
|
2199
|
+
function idleWorker(worker, reading, now) {
|
|
2200
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
2201
|
+
if (worker === undefined || worker.provider !== "claude")
|
|
2202
|
+
return undefined;
|
|
2203
|
+
const parked = reading().parked;
|
|
2204
|
+
// NULL-OK: field parked is OPTIONAL and therefore it is ok to check for NULL
|
|
2205
|
+
return parked !== undefined && parked.live && stopDue(worker, now) ? worker : undefined;
|
|
2206
|
+
}
|
|
2207
|
+
/** ๐ด #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. */
|
|
2208
|
+
// NULL-OK: field stoppedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2209
|
+
const stopDue = (worker, now) => worker.stoppedAt === undefined || now >= worker.stoppedAt + wakeDelayMs(worker.wakes ?? 0);
|
|
2181
2210
|
/**
|
|
2182
2211
|
* ๐ด ONE PASS OF FLEETVIEW'S STORY QUEUE ON ONE BOARD, under its lock: every request BB wrote is applied and acknowledged,
|
|
2183
2212
|
* every worker is checked (a story shipped closes its entry; a worker that ended with the story still open is started
|
|
@@ -2211,116 +2240,151 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2211
2240
|
applied.set(id, r.requestId);
|
|
2212
2241
|
}
|
|
2213
2242
|
for (const e of store.entries) {
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2243
|
+
let idle;
|
|
2244
|
+
judge: {
|
|
2245
|
+
if (e.state === "withdrawn") {
|
|
2246
|
+
idle = idleWorker(e.worker, () => world.worker(e, board), now);
|
|
2247
|
+
break judge;
|
|
2248
|
+
}
|
|
2249
|
+
const closed = world.closedWhy(e.storyId);
|
|
2250
|
+
if (e.state === "done") {
|
|
2251
|
+
// NULL-OK: field closed is OPTIONAL and therefore it is ok to check for NULL
|
|
2252
|
+
if (closed !== undefined || !e.eligible) {
|
|
2253
|
+
idle = idleWorker(e.worker, () => world.worker(e, board), now);
|
|
2254
|
+
break judge;
|
|
2255
|
+
}
|
|
2256
|
+
e.state = "queued";
|
|
2257
|
+
e.attempts = 0;
|
|
2258
|
+
delete e.nextTryAt;
|
|
2259
|
+
e.why = "its story is an open row on the board again";
|
|
2260
|
+
step(e, now, "acknowledged", e.why);
|
|
2220
2261
|
continue;
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
e.state
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2262
|
+
}
|
|
2263
|
+
if (closed !== undefined) {
|
|
2264
|
+
e.state = "done";
|
|
2265
|
+
e.why = closed;
|
|
2266
|
+
step(e, now, "closed", closed);
|
|
2267
|
+
idle = idleWorker(e.worker, () => world.worker(e, board), now);
|
|
2268
|
+
break judge;
|
|
2269
|
+
}
|
|
2270
|
+
if (e.state === "failed") {
|
|
2271
|
+
const gaveUp = e.trace.filter((t) => t.stage === "failed").pop();
|
|
2272
|
+
if (!e.eligible || gaveUp === undefined)
|
|
2273
|
+
continue;
|
|
2274
|
+
if (now - gaveUp.at < rearmDelayMs(e.attempts))
|
|
2275
|
+
continue;
|
|
2276
|
+
e.state = "queued";
|
|
2277
|
+
delete e.nextTryAt;
|
|
2278
|
+
e.why = `the queue gave up on it ${Math.round((now - gaveUp.at) / 60_000)}m ago and the story is still open, so it is offered to the line again`;
|
|
2279
|
+
step(e, now, "retry", e.why);
|
|
2237
2280
|
continue;
|
|
2238
|
-
|
|
2281
|
+
}
|
|
2282
|
+
if (e.state !== "starting" && e.state !== "running")
|
|
2239
2283
|
continue;
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
e.
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2284
|
+
const w = world.worker(e, board);
|
|
2285
|
+
// NULL-OK: field found is OPTIONAL and therefore it is ok to check for NULL
|
|
2286
|
+
if (e.worker === undefined && w.found !== undefined)
|
|
2287
|
+
e.worker = w.found;
|
|
2288
|
+
if (!w.alive) {
|
|
2289
|
+
step(e, now, "worker-ended", w.why);
|
|
2290
|
+
afterWorker(e, now, w.why);
|
|
2291
|
+
continue;
|
|
2292
|
+
}
|
|
2293
|
+
if (e.state === "starting") {
|
|
2294
|
+
e.state = "running";
|
|
2295
|
+
step(e, now, "started", w.why);
|
|
2296
|
+
}
|
|
2297
|
+
// NULL-OK: field worker is OPTIONAL and therefore it is ok to check for NULL
|
|
2298
|
+
if (e.worker !== undefined && ((w.blocked === true) !== (e.worker.blocked === true) || w.needs !== e.worker.needs)) {
|
|
2299
|
+
if (w.blocked === true) {
|
|
2300
|
+
e.worker.blocked = true;
|
|
2301
|
+
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
2302
|
+
if (w.needs === undefined)
|
|
2303
|
+
delete e.worker.needs;
|
|
2304
|
+
else
|
|
2305
|
+
e.worker.needs = w.needs;
|
|
2306
|
+
e.why = `its ${e.provider} worker ${e.worker.jobId} stopped and needs an act before it goes on: ${blockedAct(e.worker)}`;
|
|
2307
|
+
step(e, now, "blocked", e.why);
|
|
2308
|
+
}
|
|
2309
|
+
else {
|
|
2310
|
+
delete e.worker.blocked;
|
|
2267
2311
|
delete e.worker.needs;
|
|
2268
|
-
|
|
2269
|
-
e.worker.
|
|
2270
|
-
|
|
2271
|
-
step(e, now, "blocked", e.why);
|
|
2312
|
+
e.why = w.why;
|
|
2313
|
+
step(e, now, "progress", `its worker ${e.worker.jobId} works again โ ${w.why}`);
|
|
2314
|
+
}
|
|
2272
2315
|
}
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
e.
|
|
2277
|
-
step(e, now, "progress", `its worker ${e.worker.jobId} works again โ ${w.why}`);
|
|
2316
|
+
if (w.progressAt !== undefined && e.worker !== undefined && w.progressAt !== e.worker.progressAt) {
|
|
2317
|
+
if (e.worker.progressAt === undefined)
|
|
2318
|
+
step(e, now, "progress", `its work first moved at ${new Date(w.progressAt).toISOString()}`);
|
|
2319
|
+
e.worker.progressAt = w.progressAt;
|
|
2278
2320
|
}
|
|
2321
|
+
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
2322
|
+
if (w.session !== undefined)
|
|
2323
|
+
e.worker.session = w.session;
|
|
2324
|
+
// NULL-OK: field parked is OPTIONAL and therefore it is ok to check for NULL
|
|
2325
|
+
if (w.parked === undefined) {
|
|
2326
|
+
delete e.worker?.parkedAt;
|
|
2327
|
+
delete e.worker?.stoppedAt;
|
|
2328
|
+
continue;
|
|
2329
|
+
}
|
|
2330
|
+
const worker = e.worker;
|
|
2331
|
+
if (!e.eligible) {
|
|
2332
|
+
const why = `its ${e.provider} worker ${worker.jobId}'s turn is over and the story is no longer the queue's to work, so it is not woken`;
|
|
2333
|
+
step(e, now, "worker-ended", why);
|
|
2334
|
+
afterWorker(e, now, why);
|
|
2335
|
+
idle = idleWorker(worker, () => w, now);
|
|
2336
|
+
break judge;
|
|
2337
|
+
}
|
|
2338
|
+
// NULL-OK: field parkedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2339
|
+
if (worker.parkedAt === undefined && w.parked.failed === true) {
|
|
2340
|
+
if (e.attempts >= WORKER_ATTEMPTS) {
|
|
2341
|
+
idle = idleWorker(worker, () => w, now);
|
|
2342
|
+
delete e.worker;
|
|
2343
|
+
step(e, now, "worker-ended", w.why);
|
|
2344
|
+
afterWorker(e, now, w.why);
|
|
2345
|
+
break judge;
|
|
2346
|
+
}
|
|
2347
|
+
e.attempts += 1;
|
|
2348
|
+
}
|
|
2349
|
+
// NULL-OK: field parkedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2350
|
+
if (worker.parkedAt === undefined) {
|
|
2351
|
+
worker.parkedAt = now;
|
|
2352
|
+
step(e, now, "parked", `its ${e.provider} worker ${worker.jobId}'s turn is over with the story open, so it is woken in its own session from ${new Date(now + wakeDelayMs(worker.wakes ?? 0)).toISOString()}`);
|
|
2353
|
+
}
|
|
2354
|
+
if (!w.parked.live) {
|
|
2355
|
+
if (now >= worker.parkedAt + wakeDelayMs(worker.wakes ?? 0))
|
|
2356
|
+
wakeable.set(e, w.parked.sessionId);
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
if (stopDue(worker, now))
|
|
2360
|
+
idle = worker;
|
|
2279
2361
|
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
step(e, now, "progress", `its work first moved at ${new Date(w.progressAt).toISOString()}`);
|
|
2283
|
-
e.worker.progressAt = w.progressAt;
|
|
2284
|
-
}
|
|
2285
|
-
// NULL-OK: field parked is OPTIONAL and therefore it is ok to check for NULL
|
|
2286
|
-
if (w.parked === undefined) {
|
|
2287
|
-
delete e.worker?.parkedAt;
|
|
2288
|
-
delete e.worker?.stoppedAt;
|
|
2289
|
-
continue;
|
|
2290
|
-
}
|
|
2291
|
-
const worker = e.worker;
|
|
2292
|
-
if (!e.eligible) {
|
|
2293
|
-
const why = `its ${e.provider} worker ${worker.jobId}'s turn is over and the story is no longer the queue's to work, so it is not woken`;
|
|
2294
|
-
step(e, now, "worker-ended", why);
|
|
2295
|
-
afterWorker(e, now, why);
|
|
2296
|
-
continue;
|
|
2297
|
-
}
|
|
2298
|
-
// NULL-OK: field parkedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2299
|
-
if (worker.parkedAt === undefined) {
|
|
2300
|
-
worker.parkedAt = now;
|
|
2301
|
-
step(e, now, "parked", `its ${e.provider} worker ${worker.jobId}'s turn is over with the story open, so it is woken in its own session from ${new Date(now + wakeDelayMs(worker.wakes ?? 0)).toISOString()}`);
|
|
2302
|
-
}
|
|
2303
|
-
if (now < worker.parkedAt + wakeDelayMs(worker.wakes ?? 0))
|
|
2304
|
-
continue;
|
|
2305
|
-
if (!w.parked.live) {
|
|
2306
|
-
wakeable.set(e, w.parked.sessionId);
|
|
2362
|
+
// NULL-OK: field idle is OPTIONAL and therefore it is ok to check for NULL
|
|
2363
|
+
if (idle === undefined)
|
|
2307
2364
|
continue;
|
|
2308
|
-
|
|
2365
|
+
const open = e.state === "running";
|
|
2366
|
+
const kept = e.worker === idle;
|
|
2309
2367
|
// NULL-OK: field stoppedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
const again = worker.stoppedAt !== undefined;
|
|
2313
|
-
worker.stoppedAt = now;
|
|
2368
|
+
const again = idle.stoppedAt !== undefined;
|
|
2369
|
+
idle.stoppedAt = now;
|
|
2314
2370
|
save();
|
|
2315
2371
|
try {
|
|
2316
|
-
await world.stop(
|
|
2317
|
-
|
|
2372
|
+
await world.stop(idle);
|
|
2373
|
+
if (open)
|
|
2374
|
+
step(e, now, "parked", again ? `its worker ${idle.jobId}'s session was still held at the prompt after it was stopped, so it was stopped again` : `its worker ${idle.jobId}'s idle process was stopped, so its session is woken once the process has gone`);
|
|
2375
|
+
else if (kept)
|
|
2376
|
+
step(e, now, "worker-ended", `its worker ${idle.jobId}'s turn is over and the queue no longer works the story, so its idle process was stopped and its session is kept for the story's return`);
|
|
2377
|
+
else
|
|
2378
|
+
step(e, now, "worker-ended", `its worker ${idle.jobId} kept failing and was given up on, so its idle process was stopped`);
|
|
2318
2379
|
}
|
|
2319
2380
|
catch (err) {
|
|
2320
2381
|
if (!(err instanceof WorkerNotStarted))
|
|
2321
2382
|
throw err;
|
|
2322
|
-
// OWNER: ITER/LOOP โ the provider would not stop this worker's idle process this pass, so it stays
|
|
2323
|
-
|
|
2383
|
+
// OWNER: ITER/LOOP โ the provider would not stop this worker's idle process this pass, so it stays at its prompt with the provider's words on its trace and, while its entry still names it, the stop is tried again after its wait; the next entry is read.
|
|
2384
|
+
if (kept)
|
|
2385
|
+
step(e, now, "parked", `its worker ${idle.jobId}'s idle process could not be stopped, so it is stopped again at ${new Date(now + wakeDelayMs(idle.wakes ?? 0)).toISOString()}: ${err.message}`);
|
|
2386
|
+
else
|
|
2387
|
+
step(e, now, "worker-ended", `its worker ${idle.jobId} was given up on and its idle process could not be stopped: ${err.message}`);
|
|
2324
2388
|
}
|
|
2325
2389
|
}
|
|
2326
2390
|
save();
|
|
@@ -2344,7 +2408,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2344
2408
|
const wakes = (parked.wakes ?? 0) + 1;
|
|
2345
2409
|
try {
|
|
2346
2410
|
const woken = await world.wake(e, board, sessionId, wakeMessage(e.storyId));
|
|
2347
|
-
e.worker = { ...woken, wakes };
|
|
2411
|
+
e.worker = { ...woken, wakes, ...keptSession(parked) };
|
|
2348
2412
|
e.why = `its ${woken.provider} worker ${woken.jobId} was woken in its own session (wake ${wakes}), with ${lanes} of ${world.limit} lanes running`;
|
|
2349
2413
|
step(e, now, "woken", e.why);
|
|
2350
2414
|
}
|
|
@@ -2355,7 +2419,7 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
2355
2419
|
// NULL-OK: field parked is OPTIONAL and therefore it is ok to check for NULL
|
|
2356
2420
|
if (after.alive && (after.parked === undefined || after.parked.live)) {
|
|
2357
2421
|
// OWNER: ITER/LOOP โ the wake's answer was lost (a timeout on a busy box) but a process now runs the worker's session, so the wake landed: the entry keeps that worker and no second one is started; the next entry is read.
|
|
2358
|
-
e.worker = { provider: parked.provider, startedAt: now, jobId: parked.jobId, wakes };
|
|
2422
|
+
e.worker = { provider: parked.provider, startedAt: now, jobId: parked.jobId, wakes, ...keptSession(parked) };
|
|
2359
2423
|
e.why = `its worker ${parked.jobId} was woken in its own session (wake ${wakes}), though its answer was: ${err.message}`;
|
|
2360
2424
|
step(e, now, "woken", e.why);
|
|
2361
2425
|
}
|
|
@@ -2522,13 +2586,62 @@ const mtimeOf = (file) => {
|
|
|
2522
2586
|
return undefined;
|
|
2523
2587
|
}
|
|
2524
2588
|
};
|
|
2589
|
+
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
2590
|
+
const keptSession = (worker) => (worker.session === undefined ? {} : { session: worker.session });
|
|
2591
|
+
/** ๐ด #4123 โ a worker whose job record Claude Code no longer keeps: still the story's worker while a process runs its session or that process is inside its start grace, woken in its own session once none does and its transcript is on disk, ended when there is no session to wake. */
|
|
2592
|
+
function goneWorker(worker, now, home) {
|
|
2593
|
+
const gone = `its job ${worker.jobId} is no longer on Claude Code's record`;
|
|
2594
|
+
// NULL-OK: field session is OPTIONAL and therefore it is ok to check for NULL
|
|
2595
|
+
if (worker.session === undefined || mtimeOf(worker.session.transcript) === undefined)
|
|
2596
|
+
return { alive: false, why: gone };
|
|
2597
|
+
if (liveClaudeSessions(home).has(worker.session.id))
|
|
2598
|
+
return { alive: true, why: `${gone}, and a process runs its session ${worker.session.id}, so it is still this story's worker` };
|
|
2599
|
+
if (now - worker.startedAt < WORKER_START_GRACE_MS)
|
|
2600
|
+
return { alive: true, why: `${gone}, and it was started ${Math.round((now - worker.startedAt) / 1000)}s ago, so its process may not have recorded its session ${worker.session.id} yet` };
|
|
2601
|
+
return { alive: true, parked: { sessionId: worker.session.id, live: false }, why: `${gone} โ its session ${worker.session.id} is on disk and no process runs it, so it is parked and woken there` };
|
|
2602
|
+
}
|
|
2603
|
+
/** ๐ด #4123 โ a job's last whole timeline step, which ends `failed` for a provider's refusal and mid-work for a job killed with the daemon, and whether a step after it is caught mid-append. */
|
|
2604
|
+
function lastTimelineStep(jobId, home) {
|
|
2605
|
+
let text;
|
|
2606
|
+
try {
|
|
2607
|
+
text = fs.readFileSync(path.join(home, "jobs", jobId, "timeline.jsonl"), "utf8");
|
|
2608
|
+
}
|
|
2609
|
+
catch (err) {
|
|
2610
|
+
if (err.code !== "ENOENT")
|
|
2611
|
+
throw err;
|
|
2612
|
+
return { tornTail: false };
|
|
2613
|
+
}
|
|
2614
|
+
const lines = text.split("\n").filter((l) => l.trim() !== "");
|
|
2615
|
+
const tail = lines.pop();
|
|
2616
|
+
// NULL-OK: field tail is OPTIONAL and therefore it is ok to check for NULL
|
|
2617
|
+
if (tail === undefined)
|
|
2618
|
+
return { tornTail: false };
|
|
2619
|
+
const whole = timelineStepOf(tail);
|
|
2620
|
+
if (whole !== "torn")
|
|
2621
|
+
return { state: whole, tornTail: false };
|
|
2622
|
+
const before = lines.pop();
|
|
2623
|
+
// NULL-OK: field before is OPTIONAL and therefore it is ok to check for NULL
|
|
2624
|
+
return before === undefined ? { tornTail: true } : { state: JSON.parse(before).state, tornTail: true };
|
|
2625
|
+
}
|
|
2626
|
+
/** ๐ด #4123 โ one timeline line's step state, or "torn" while Claude Code is still appending it. */
|
|
2627
|
+
function timelineStepOf(line) {
|
|
2628
|
+
try {
|
|
2629
|
+
return JSON.parse(line).state;
|
|
2630
|
+
}
|
|
2631
|
+
catch (err) {
|
|
2632
|
+
if (!(err instanceof SyntaxError))
|
|
2633
|
+
throw err;
|
|
2634
|
+
return "torn";
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2525
2637
|
/** ๐ด #4123 โ the job states whose turn is over: a process still holding one waits at the prompt, working nothing. */
|
|
2526
2638
|
const TURN_OVER = new Set(["done", "blocked", "stopped"]);
|
|
2527
2639
|
/**
|
|
2528
2640
|
* A story worker's liveness: a `claude --bg` job, with the moment its transcript last moved. ๐ด #4123 โ a job whose turn is
|
|
2529
2641
|
* over (`done` or `blocked`, with no background task of its own still running) or whose process the daemon retired is
|
|
2530
|
-
* PARKED, alive in its session and woken there
|
|
2531
|
-
* stopped by anyone but the queue
|
|
2642
|
+
* PARKED, alive in its session and woken there, and so is one killed with the daemon or one Claude Code no longer records
|
|
2643
|
+
* whose session is still on disk; a job whose provider call failed, one stopped by anyone but the queue, or one no longer
|
|
2644
|
+
* recorded with no session left to wake has ended.
|
|
2532
2645
|
*/
|
|
2533
2646
|
export function storyWorkerLiveness(worker, now, home = claudeHome()) {
|
|
2534
2647
|
const job = jobRecordOf(worker.jobId, home);
|
|
@@ -2537,18 +2650,26 @@ export function storyWorkerLiveness(worker, now, home = claudeHome()) {
|
|
|
2537
2650
|
if (job === "torn")
|
|
2538
2651
|
return { alive: true, ...asLastRead, why: `its job ${worker.jobId}'s record was caught mid-rewrite, so it is read again on the next pass` };
|
|
2539
2652
|
if (job === "gone")
|
|
2540
|
-
return
|
|
2653
|
+
return goneWorker(worker, now, home);
|
|
2541
2654
|
const at = job.linkScanPath === undefined ? undefined : mtimeOf(job.linkScanPath);
|
|
2542
|
-
|
|
2655
|
+
// NULL-OK: field linkScanPath is OPTIONAL and therefore it is ok to check for NULL
|
|
2656
|
+
const progress = { ...(at === undefined ? {} : { progressAt: at }), ...(job.linkScanPath === undefined ? {} : { session: { id: job.sessionId, transcript: job.linkScanPath } }) };
|
|
2543
2657
|
if (now - worker.startedAt < WORKER_START_GRACE_MS)
|
|
2544
2658
|
return { alive: true, ...progress, why: `its job ${worker.jobId} was started ${Math.round((now - worker.startedAt) / 1000)}s ago and its process has not recorded itself yet` };
|
|
2545
2659
|
// NULL-OK: field stoppedAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2546
2660
|
if (job.state === "stopped" && worker.stoppedAt === undefined)
|
|
2547
2661
|
return { alive: false, ...progress, why: `its job ${worker.jobId} ended stopped` };
|
|
2548
|
-
// NULL-OK: field detail is OPTIONAL and therefore it is ok to check for NULL
|
|
2549
|
-
if (job.state === "failed")
|
|
2550
|
-
return { alive: false, ...progress, why: `its job ${worker.jobId} failed: ${job.detail ?? "its record names no cause"}` };
|
|
2551
2662
|
const live = liveClaudeSessions(home).has(job.sessionId);
|
|
2663
|
+
if (job.state === "failed") {
|
|
2664
|
+
// NULL-OK: field detail is OPTIONAL and therefore it is ok to check for NULL
|
|
2665
|
+
const said = `its job ${worker.jobId} failed: ${job.detail ?? "its record names no cause"}`;
|
|
2666
|
+
const step = lastTimelineStep(worker.jobId, home);
|
|
2667
|
+
if (step.tornTail && live)
|
|
2668
|
+
return { alive: true, ...progress, why: `${said} โ its timeline's last step is still being written by its running process, so it is read again on the next pass` };
|
|
2669
|
+
if (step.state === "failed" || at === undefined || at <= worker.startedAt)
|
|
2670
|
+
return { alive: false, ...progress, why: said };
|
|
2671
|
+
return { alive: true, ...progress, parked: { sessionId: job.sessionId, live, failed: true }, why: `${said} โ it was killed mid-work and its session worked after it was started, so it is parked and woken there` };
|
|
2672
|
+
}
|
|
2552
2673
|
// NULL-OK: field inFlight is OPTIONAL and therefore it is ok to check for NULL
|
|
2553
2674
|
const waitsOnTasks = job.inFlight !== undefined && job.inFlight.tasks + job.inFlight.queued + job.inFlight.drainableMonitors > 0;
|
|
2554
2675
|
// NULL-OK: field needs is OPTIONAL and therefore it is ok to check for NULL
|
|
@@ -2585,7 +2706,7 @@ const LAUNCH_TIMEOUT_MS = 60_000;
|
|
|
2585
2706
|
/** A story's worker, started windowless in the board's folder as a `claude --bg` session whose lifetime is the story's; `cli` is Claude Code's program as this machine runs it. */
|
|
2586
2707
|
export function launchStoryWorker(entry, board, cli, now) {
|
|
2587
2708
|
return new Promise((resolve, reject) => {
|
|
2588
|
-
execFile(cli.cmd, [...cli.args, "--bg", "--name", entry.name, "--model", entry.model, "--permission-mode", "bypassPermissions", entry
|
|
2709
|
+
execFile(cli.cmd, [...cli.args, "--bg", "--name", entry.name, "--model", entry.model, "--permission-mode", "bypassPermissions", workerBrief(entry)], { cwd: board, windowsHide: true, timeout: LAUNCH_TIMEOUT_MS }, (err, stdout, stderr) => {
|
|
2589
2710
|
const said = `${stdout}${stderr}`;
|
|
2590
2711
|
const job = /^backgrounded ยท (\S+) ยท /m.exec(said);
|
|
2591
2712
|
if (job !== null)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.369",
|
|
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",
|