omni-notify-mcp 1.3.360 → 1.3.361
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 +320 -9
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { execFile, spawn, spawnSync } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
|
+
import { Agent } from "node:http";
|
|
4
5
|
import { homedir, tmpdir } from "node:os";
|
|
5
6
|
import * as path from "node:path";
|
|
7
|
+
import { Duplex } from "node:stream";
|
|
6
8
|
export function isProcessAlive(pid) {
|
|
7
9
|
try {
|
|
8
10
|
process.kill(pid, 0);
|
|
@@ -176,6 +178,258 @@ export function ownerBoundLaunch(invocation, ownerPid, cwd, guardDir) {
|
|
|
176
178
|
args: [path.join(guardDir, "ownerGuard.cjs"), String(ownerPid), encoded(invocation.cmd), encoded(JSON.stringify(invocation.args)), encoded(cwd)],
|
|
177
179
|
};
|
|
178
180
|
}
|
|
181
|
+
// GATE: how long one request to the native Codex daemon may take before it is refused with that wait named — the daemon answers these in well under a second
|
|
182
|
+
const CODEX_REQUEST_MS = 10_000;
|
|
183
|
+
// GATE: how long one Codex CLI command (`login status`, `app-server daemon start`) may run before its tree is ended and refused with that wait named — each answers in about a second
|
|
184
|
+
const CODEX_CLI_MS = 60_000;
|
|
185
|
+
/** 🔴 #3951 — the Codex CLI or its daemon could not be reached, refused a request, or answered outside its documented outcomes; the message carries its words. */
|
|
186
|
+
export class CodexControlFailed extends Error {
|
|
187
|
+
}
|
|
188
|
+
/** The native Codex daemon answered a request with an error, so what it was asked was not done. */
|
|
189
|
+
export class CodexRefused extends CodexControlFailed {
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 🔴 #3504/#3951 — THE ONE CONTROL OF THE NATIVE CODEX DAEMON every Bullseye host shares: FleetView's window posts a press into
|
|
193
|
+
* a Codex main through it, and a host with no window brings the daemon up, reuses the board's live Codex main or opens ONE,
|
|
194
|
+
* and posts into it the same way (Meni, Q796: "Service creates one Codex main, then posts"). It speaks the daemon's own
|
|
195
|
+
* app-server protocol over `codex app-server proxy`, bound to this process by the owner guard, so it never runs a second
|
|
196
|
+
* app server or a `codex exec`.
|
|
197
|
+
*/
|
|
198
|
+
export class CodexControl {
|
|
199
|
+
proxy;
|
|
200
|
+
socket;
|
|
201
|
+
opening;
|
|
202
|
+
nextId = 0;
|
|
203
|
+
generation = 0;
|
|
204
|
+
pending = new Map();
|
|
205
|
+
project;
|
|
206
|
+
guardDir;
|
|
207
|
+
cli;
|
|
208
|
+
constructor(project, guardDir, cli = { cmd: "codex", args: [] }) {
|
|
209
|
+
this.project = project;
|
|
210
|
+
this.guardDir = guardDir;
|
|
211
|
+
this.cli = cli;
|
|
212
|
+
}
|
|
213
|
+
/** The Codex CLI's own word on this box's sign-in: signed in, not signed in, or not installed — anything else it says is refused. */
|
|
214
|
+
async login() {
|
|
215
|
+
const ran = await this.run(["login", "status"]);
|
|
216
|
+
if (ran.code === 0)
|
|
217
|
+
return { signedIn: true };
|
|
218
|
+
if (ran.code === 1 && /not logged in/i.test(ran.said))
|
|
219
|
+
return { signedIn: false, why: `the Codex CLI on this box is not signed in ("codex login status" says: ${ran.said.split(/\r?\n/).pop()})` };
|
|
220
|
+
if (ran.code === 96 || ran.code === 127)
|
|
221
|
+
return { signedIn: false, why: `the Codex CLI could not be started on this box, so no Codex login exists here (${ran.said})` };
|
|
222
|
+
throw new CodexControlFailed(`"codex login status" ended ${ran.code}: ${ran.said || "it printed nothing"}`);
|
|
223
|
+
}
|
|
224
|
+
/** The native daemon running on this box: started when it is not, left alone when it is (`codex app-server daemon start` is both). */
|
|
225
|
+
async daemonUp() {
|
|
226
|
+
const ran = await this.run(["app-server", "daemon", "start"]);
|
|
227
|
+
if (ran.code !== 0)
|
|
228
|
+
throw new CodexControlFailed(`"codex app-server daemon start" ended ${ran.code}: ${ran.said || "it printed nothing"}`);
|
|
229
|
+
}
|
|
230
|
+
/** Every Codex main the daemon holds loaded right now, each with the threads it spawned and whether it is mid-turn. */
|
|
231
|
+
async mains() {
|
|
232
|
+
await this.open();
|
|
233
|
+
const loaded = (await this.request("thread/loaded/list", {}));
|
|
234
|
+
const threads = await Promise.all(loaded.data.map(async (threadId) => (await this.request("thread/read", { threadId, includeTurns: false })).thread));
|
|
235
|
+
const rootOf = (thread) => {
|
|
236
|
+
const seen = new Set();
|
|
237
|
+
let current = thread;
|
|
238
|
+
while (!seen.has(current.id)) {
|
|
239
|
+
seen.add(current.id);
|
|
240
|
+
const parentId = typeof current.source === "object" ? current.source.subAgent?.thread_spawn?.parent_thread_id : undefined;
|
|
241
|
+
if (parentId === undefined)
|
|
242
|
+
return current.id;
|
|
243
|
+
const parent = threads.find((candidate) => candidate.id === parentId);
|
|
244
|
+
if (parent === undefined)
|
|
245
|
+
return parentId;
|
|
246
|
+
current = parent;
|
|
247
|
+
}
|
|
248
|
+
throw new CodexControlFailed("the native Codex daemon reported a cycle in its parent links");
|
|
249
|
+
};
|
|
250
|
+
return threads
|
|
251
|
+
.filter((thread) => thread.source === "vscode" || thread.source === "cli")
|
|
252
|
+
.map((thread) => ({
|
|
253
|
+
threadId: thread.id,
|
|
254
|
+
cwd: thread.cwd,
|
|
255
|
+
// NULL-OK: field name is OPTIONAL and therefore it is ok to check for NULL
|
|
256
|
+
name: thread.name ?? `Codex ${thread.id.slice(0, 8)}`,
|
|
257
|
+
ownedThreadIds: threads.filter((child) => child.id !== thread.id && rootOf(child) === thread.id).map((child) => child.id),
|
|
258
|
+
working: thread.status.type === "active",
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
/** A new Codex main opened in `cwd` under `name` — the one a host with no live Codex main for its board opens, idle until a press is posted into it. */
|
|
262
|
+
async startMain(cwd, name) {
|
|
263
|
+
await this.open();
|
|
264
|
+
const started = (await this.request("thread/start", { cwd }));
|
|
265
|
+
await this.request("thread/name/set", { threadId: started.thread.id, name });
|
|
266
|
+
return { threadId: started.thread.id, cwd: started.thread.cwd, name, ownedThreadIds: [], working: false };
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 🔴 #3951 — THE ONE CODEX MAIN OF A BOARD, for a host with no window (Meni, Q796: "Service creates one Codex main, then
|
|
270
|
+
* posts"): the daemon is brought up, a live Codex main whose folder `reaches` is reused, and only when none is alive is ONE
|
|
271
|
+
* opened in `cwd` under `name`.
|
|
272
|
+
*/
|
|
273
|
+
async mainFor(reaches, cwd, name) {
|
|
274
|
+
await this.daemonUp();
|
|
275
|
+
const live = (await this.mains()).find((m) => reaches(m.cwd));
|
|
276
|
+
// NULL-OK: field live is OPTIONAL and therefore it is ok to check for NULL
|
|
277
|
+
return live !== undefined ? { main: live, opened: false } : { main: await this.startMain(cwd, name), opened: true };
|
|
278
|
+
}
|
|
279
|
+
/** `message` posted into the main's thread as his next turn: steered into the turn it is running, else started as a new one; `beforeSend` runs right before it goes and may refuse it by throwing. */
|
|
280
|
+
async post(threadId, message, beforeSend = () => { }) {
|
|
281
|
+
await this.open();
|
|
282
|
+
const input = [{ type: "text", text: message }];
|
|
283
|
+
const active = await this.activeTurn(threadId);
|
|
284
|
+
beforeSend();
|
|
285
|
+
if (active !== undefined)
|
|
286
|
+
await this.request("turn/steer", { threadId, expectedTurnId: active.id, input });
|
|
287
|
+
else
|
|
288
|
+
await this.request("turn/start", { threadId, input });
|
|
289
|
+
}
|
|
290
|
+
dispose() {
|
|
291
|
+
++this.generation;
|
|
292
|
+
this.failPending(new CodexControlFailed("the native Codex control connection was closed by its owner"));
|
|
293
|
+
this.socket?.terminate();
|
|
294
|
+
this.proxy?.kill();
|
|
295
|
+
this.socket = undefined;
|
|
296
|
+
this.opening = undefined;
|
|
297
|
+
}
|
|
298
|
+
/** The CLI behind this process's owner guard, which also finds the CLI's .cmd shim on Windows. */
|
|
299
|
+
bound(invocation) {
|
|
300
|
+
return ownerBoundLaunch(invocation, process.pid, this.project, this.guardDir);
|
|
301
|
+
}
|
|
302
|
+
run(args) {
|
|
303
|
+
const launch = this.bound({ cmd: this.cli.cmd, args: [...this.cli.args, ...args] });
|
|
304
|
+
return new Promise((resolve, reject) => {
|
|
305
|
+
const child = spawn(launch.cmd, launch.args, { cwd: this.project, windowsHide: true, stdio: ["ignore", "pipe", "pipe"], env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" } });
|
|
306
|
+
let said = "";
|
|
307
|
+
child.stdout.on("data", (chunk) => (said += chunk.toString("utf8")));
|
|
308
|
+
child.stderr.on("data", (chunk) => (said += chunk.toString("utf8")));
|
|
309
|
+
const bound = setTimeout(() => {
|
|
310
|
+
killTree(child);
|
|
311
|
+
reject(new CodexControlFailed(`"codex ${args.join(" ")}" did not end within ${CODEX_CLI_MS / 1000} seconds, so its process tree was ended: ${said.trim() || "it printed nothing"}`));
|
|
312
|
+
}, CODEX_CLI_MS);
|
|
313
|
+
child.on("error", (cause) => {
|
|
314
|
+
clearTimeout(bound);
|
|
315
|
+
reject(cause);
|
|
316
|
+
});
|
|
317
|
+
child.on("exit", (code, signal) => {
|
|
318
|
+
clearTimeout(bound);
|
|
319
|
+
if (code === null)
|
|
320
|
+
reject(new CodexControlFailed(`"codex ${args.join(" ")}" was ended by ${signal}: ${said.trim() || "it printed nothing"}`));
|
|
321
|
+
else
|
|
322
|
+
resolve({ code, said: said.trim() });
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
open() {
|
|
327
|
+
// NULL-OK: field opening is OPTIONAL and therefore it is ok to check for NULL
|
|
328
|
+
if (this.opening !== undefined)
|
|
329
|
+
return this.opening;
|
|
330
|
+
if (this.socket !== undefined && this.socket.readyState === this.socket.OPEN)
|
|
331
|
+
return Promise.resolve();
|
|
332
|
+
const generation = ++this.generation;
|
|
333
|
+
this.opening = import("ws").then(({ default: Socket }) => new Promise((resolve, reject) => {
|
|
334
|
+
const launch = this.bound({ cmd: this.cli.cmd, args: [...this.cli.args, "app-server", "proxy"] });
|
|
335
|
+
const proxy = (this.proxy = spawn(launch.cmd, launch.args, { cwd: this.project, windowsHide: true, stdio: ["pipe", "pipe", "pipe"], env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" } }));
|
|
336
|
+
const stream = Duplex.from({ readable: proxy.stdout, writable: proxy.stdin });
|
|
337
|
+
const connection = Object.assign(stream, { connecting: false, setTimeout: () => stream, setNoDelay: () => stream, setKeepAlive: () => stream });
|
|
338
|
+
const agent = new Agent();
|
|
339
|
+
agent.createConnection = () => connection;
|
|
340
|
+
const socket = (this.socket = new Socket("ws://localhost/", { agent, handshakeTimeout: CODEX_REQUEST_MS }));
|
|
341
|
+
let said = "";
|
|
342
|
+
proxy.stderr.on("data", (chunk) => (said += chunk.toString("utf8")));
|
|
343
|
+
const ended = new Promise((done) => {
|
|
344
|
+
proxy.once("exit", (code) => done(`the native Codex control proxy ended (exit ${code}): ${said.trim() || "it printed nothing"}`));
|
|
345
|
+
proxy.once("error", (cause) => done(`the native Codex control proxy could not be started: ${cause.message}`));
|
|
346
|
+
});
|
|
347
|
+
let initialized = false;
|
|
348
|
+
const failed = (cause) => {
|
|
349
|
+
if (!initialized)
|
|
350
|
+
void ended.then((why) => reject(new CodexControlFailed(`${cause.message}; ${why}`)));
|
|
351
|
+
if (this.generation === generation) {
|
|
352
|
+
this.socket = undefined;
|
|
353
|
+
this.failPending(cause instanceof CodexControlFailed ? cause : new CodexControlFailed(`the native Codex control connection failed: ${cause.message}`));
|
|
354
|
+
}
|
|
355
|
+
socket.terminate();
|
|
356
|
+
proxy.kill();
|
|
357
|
+
};
|
|
358
|
+
proxy.on("error", failed);
|
|
359
|
+
stream.on("error", failed);
|
|
360
|
+
proxy.on("exit", () => failed(new CodexControlFailed("the native Codex control proxy exited")));
|
|
361
|
+
socket.on("error", failed);
|
|
362
|
+
socket.on("close", () => failed(new CodexControlFailed("the native Codex control connection closed")));
|
|
363
|
+
socket.on("message", (data) => {
|
|
364
|
+
if (this.generation !== generation)
|
|
365
|
+
return;
|
|
366
|
+
let message;
|
|
367
|
+
try {
|
|
368
|
+
message = JSON.parse(data.toString());
|
|
369
|
+
}
|
|
370
|
+
catch (cause) {
|
|
371
|
+
if (!(cause instanceof SyntaxError))
|
|
372
|
+
throw cause;
|
|
373
|
+
failed(cause);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
// NULL-OK: field id is OPTIONAL and therefore it is ok to check for NULL
|
|
377
|
+
if (message.id === undefined)
|
|
378
|
+
return;
|
|
379
|
+
const pending = this.pending.get(message.id);
|
|
380
|
+
// NULL-OK: field pending is OPTIONAL and therefore it is ok to check for NULL
|
|
381
|
+
if (pending === undefined)
|
|
382
|
+
return;
|
|
383
|
+
clearTimeout(pending.timer);
|
|
384
|
+
this.pending.delete(message.id);
|
|
385
|
+
// NULL-OK: field error is OPTIONAL and therefore it is ok to check for NULL
|
|
386
|
+
if (message.error !== undefined)
|
|
387
|
+
pending.reject(new CodexRefused(message.error.message));
|
|
388
|
+
else
|
|
389
|
+
pending.resolve(message.result);
|
|
390
|
+
});
|
|
391
|
+
socket.once("open", () => {
|
|
392
|
+
void this.request("initialize", { clientInfo: { name: "bullseye", version: "1.0.0" }, capabilities: { experimentalApi: true } }).then(() => {
|
|
393
|
+
socket.send(JSON.stringify({ method: "initialized", params: {} }));
|
|
394
|
+
initialized = true;
|
|
395
|
+
resolve();
|
|
396
|
+
}, failed);
|
|
397
|
+
});
|
|
398
|
+
})).finally(() => {
|
|
399
|
+
if (this.generation === generation)
|
|
400
|
+
this.opening = undefined;
|
|
401
|
+
});
|
|
402
|
+
return this.opening;
|
|
403
|
+
}
|
|
404
|
+
failPending(cause) {
|
|
405
|
+
for (const pending of this.pending.values()) {
|
|
406
|
+
clearTimeout(pending.timer);
|
|
407
|
+
pending.reject(cause);
|
|
408
|
+
}
|
|
409
|
+
this.pending.clear();
|
|
410
|
+
}
|
|
411
|
+
request(method, params) {
|
|
412
|
+
const socket = this.socket;
|
|
413
|
+
if (socket === undefined || socket.readyState !== socket.OPEN)
|
|
414
|
+
return Promise.reject(new CodexControlFailed("the native Codex control connection is not open"));
|
|
415
|
+
const id = ++this.nextId;
|
|
416
|
+
return new Promise((resolve, reject) => {
|
|
417
|
+
const timer = setTimeout(() => {
|
|
418
|
+
this.pending.delete(id);
|
|
419
|
+
reject(new CodexControlFailed(`native Codex ${method} did not answer within ${CODEX_REQUEST_MS / 1000} seconds`));
|
|
420
|
+
}, CODEX_REQUEST_MS);
|
|
421
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
422
|
+
socket.send(JSON.stringify({ id, method, params }));
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
async activeTurn(threadId) {
|
|
426
|
+
const { thread } = (await this.request("thread/read", { threadId, includeTurns: false }));
|
|
427
|
+
if (thread.status.type !== "active")
|
|
428
|
+
return undefined;
|
|
429
|
+
const turns = (await this.request("thread/turns/list", { threadId, limit: 1, sortDirection: "desc", itemsView: "notLoaded" }));
|
|
430
|
+
return turns.data.find((turn) => turn.status === "inProgress");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
179
433
|
// GATE: how long a CLI tree gets to exit on SIGTERM before it is SIGKILLed — POSIX only; Windows stops it at once
|
|
180
434
|
const KILL_GRACE_MS = 2_000;
|
|
181
435
|
export function killTree(child) {
|
|
@@ -1614,6 +1868,13 @@ export function requestedStories(board) {
|
|
|
1614
1868
|
return [];
|
|
1615
1869
|
return fs.readdirSync(dir).filter((f) => /^\d+\.json$/.test(f)).map((f) => Number(f.slice(0, -".json".length)));
|
|
1616
1870
|
}
|
|
1871
|
+
/** 🔴 #3951 — every story FleetView's story queue stopped on the board, with the queue's own words: the ack that answers its standing request reads `failed`. */
|
|
1872
|
+
export function storyQueueStops(board) {
|
|
1873
|
+
return requestedStories(board).flatMap((id) => {
|
|
1874
|
+
const ack = readStoryAck(board, id);
|
|
1875
|
+
return ack?.state === "failed" && ack.requestId === readStoryRequest(board, id)?.requestId ? [[id, `FleetView's story queue could not start it: ${ack.why}`]] : [];
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1617
1878
|
// GATE: how long a request no ack names waits before BB writes it again — FV acks within one beat, so past this the request or its ack was lost, or FV is down
|
|
1618
1879
|
export const ACK_LATE_MS = 60_000;
|
|
1619
1880
|
// GATE: how long an unacknowledged request may stand before the board's OWN SURFACE says FleetView has not answered it — a reading of the page's words, never a re-send, so a beat that lags no longer tells Meni FleetView is down while it is working
|
|
@@ -1763,8 +2024,8 @@ function refusalOf(r) {
|
|
|
1763
2024
|
return `priority "${r.pri}" is none of ${PRI_ORDER.join(" ")}`;
|
|
1764
2025
|
if (rankIn(EFFORT_ORDER, r.effort) === -1)
|
|
1765
2026
|
return `size "${r.effort}" is none of ${EFFORT_ORDER.join(" ")}`;
|
|
1766
|
-
if (r.eligible && r.provider !== "claude")
|
|
1767
|
-
return `provider "${r.provider}" is not started by this queue —
|
|
2027
|
+
if (r.eligible && r.provider !== "claude" && r.provider !== "codex")
|
|
2028
|
+
return `provider "${r.provider}" is not started by this queue — it starts Claude workers and posts Codex-owned stories into the board's one Codex main`;
|
|
1768
2029
|
return undefined;
|
|
1769
2030
|
}
|
|
1770
2031
|
/** One request applied to the store: an entry made, updated, withdrawn or put back in line; answers the refusal when it cannot be queued. */
|
|
@@ -1809,11 +2070,24 @@ function applyRequest(store, r, now) {
|
|
|
1809
2070
|
}
|
|
1810
2071
|
/** The provider refused to start a story's worker: its own words, which the entry carries and the queue starts again on its backoff. */
|
|
1811
2072
|
export class WorkerNotStarted extends Error {
|
|
1812
|
-
|
|
2073
|
+
/** Whether the queue starts it again on its backoff. */
|
|
2074
|
+
retried = true;
|
|
2075
|
+
/** Whether the provider answered that the start never reached it, so a worker recorded right before the send stands for nothing. */
|
|
2076
|
+
unsent;
|
|
2077
|
+
constructor(message, unsent = false) {
|
|
1813
2078
|
super(message);
|
|
2079
|
+
this.unsent = unsent;
|
|
1814
2080
|
this.name = "WorkerNotStarted";
|
|
1815
2081
|
}
|
|
1816
2082
|
}
|
|
2083
|
+
/** 🔴 #3951 — the provider cannot start the story as this box stands (its CLI has no login): the entry stops `failed` with the provider's words at once, spends no attempt, and the box is read again after {@link RETRY_BASE_MS}, so a login made later starts it. */
|
|
2084
|
+
export class WorkerRefused extends WorkerNotStarted {
|
|
2085
|
+
retried = false;
|
|
2086
|
+
constructor(message) {
|
|
2087
|
+
super(message);
|
|
2088
|
+
this.name = "WorkerRefused";
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
1817
2091
|
// 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
|
|
1818
2092
|
export const WORKER_ATTEMPTS = 3;
|
|
1819
2093
|
// GATE: the wait before a story whose worker ended is started again: this, doubled for each earlier attempt
|
|
@@ -1838,14 +2112,22 @@ function writeAcks(board, store, refusals, applied, now) {
|
|
|
1838
2112
|
writeWhole(board, ackFile(board, storyId), ack);
|
|
1839
2113
|
}
|
|
1840
2114
|
}
|
|
1841
|
-
/** A worker that ended with its story still open: started again after its backoff,
|
|
1842
|
-
function afterWorker(e, now, why) {
|
|
2115
|
+
/** A worker that ended with its story still open: started again after its backoff, stopped in `failed` past {@link WORKER_ATTEMPTS}, or at once when its provider refused it as the box stands (`retried` false), read again after the first backoff. */
|
|
2116
|
+
function afterWorker(e, now, why, retried = true) {
|
|
1843
2117
|
if (!e.eligible) {
|
|
1844
2118
|
e.state = "withdrawn";
|
|
1845
2119
|
step(e, now, "withdrawn", e.why);
|
|
1846
2120
|
}
|
|
2121
|
+
else if (!retried) {
|
|
2122
|
+
e.state = "failed";
|
|
2123
|
+
e.attempts -= 1;
|
|
2124
|
+
e.nextTryAt = now + RETRY_BASE_MS;
|
|
2125
|
+
e.why = `${why}; the box is read again at ${new Date(e.nextTryAt).toISOString()}`;
|
|
2126
|
+
step(e, now, "failed", e.why);
|
|
2127
|
+
}
|
|
1847
2128
|
else if (e.attempts >= WORKER_ATTEMPTS) {
|
|
1848
2129
|
e.state = "failed";
|
|
2130
|
+
delete e.nextTryAt;
|
|
1849
2131
|
e.why = `its worker was started ${e.attempts} times and the story is still open — the last: ${why}`;
|
|
1850
2132
|
step(e, now, "failed", e.why);
|
|
1851
2133
|
}
|
|
@@ -1940,7 +2222,8 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
1940
2222
|
save();
|
|
1941
2223
|
let lanes = world.lanesRunning();
|
|
1942
2224
|
for (const e of queueOrder(store)) {
|
|
1943
|
-
|
|
2225
|
+
// NULL-OK: field nextTryAt is OPTIONAL and therefore it is ok to check for NULL
|
|
2226
|
+
if (!e.eligible || !(e.state === "queued" || ((e.state === "retrying" || e.state === "failed") && e.nextTryAt !== undefined && e.nextTryAt <= now)))
|
|
1944
2227
|
continue;
|
|
1945
2228
|
const held = world.heldBy(e.storyId);
|
|
1946
2229
|
if (held !== undefined) {
|
|
@@ -1965,13 +2248,18 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
1965
2248
|
save();
|
|
1966
2249
|
lanes += 1;
|
|
1967
2250
|
try {
|
|
1968
|
-
e.worker = await world.launch(e, board)
|
|
2251
|
+
e.worker = await world.launch(e, board, (sent) => {
|
|
2252
|
+
e.worker = sent;
|
|
2253
|
+
save();
|
|
2254
|
+
});
|
|
1969
2255
|
e.why = `its ${e.provider} worker ${e.worker.jobId} was started`;
|
|
1970
2256
|
step(e, Date.now(), "started", e.why);
|
|
1971
2257
|
}
|
|
1972
2258
|
catch (err) {
|
|
1973
2259
|
if (!(err instanceof WorkerNotStarted))
|
|
1974
2260
|
throw err;
|
|
2261
|
+
if (err.unsent)
|
|
2262
|
+
delete e.worker;
|
|
1975
2263
|
const made = world.worker(e, board);
|
|
1976
2264
|
// NULL-OK: field found is OPTIONAL and therefore it is ok to check for NULL
|
|
1977
2265
|
if (made.alive && made.found !== undefined) {
|
|
@@ -1982,10 +2270,10 @@ export async function driveStoryQueue(board, world, now) {
|
|
|
1982
2270
|
save();
|
|
1983
2271
|
continue;
|
|
1984
2272
|
}
|
|
1985
|
-
// 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; the next entry in line is started.
|
|
2273
|
+
// 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.
|
|
1986
2274
|
lanes -= 1;
|
|
1987
2275
|
step(e, Date.now(), "worker-ended", `its ${e.provider} worker could not be started: ${err.message}`);
|
|
1988
|
-
afterWorker(e, now, `its ${e.provider} worker could not be started: ${err.message}
|
|
2276
|
+
afterWorker(e, now, `its ${e.provider} worker could not be started: ${err.message}`, err.retried);
|
|
1989
2277
|
}
|
|
1990
2278
|
save();
|
|
1991
2279
|
}
|
|
@@ -2109,3 +2397,26 @@ export function launchStoryWorker(entry, board, cli, now) {
|
|
|
2109
2397
|
});
|
|
2110
2398
|
});
|
|
2111
2399
|
}
|
|
2400
|
+
/**
|
|
2401
|
+
* 🔴 #3951 — A CODEX-OWNED STORY'S START (Meni, Q796: "Service creates one Codex main, then posts"): the box's Codex login is
|
|
2402
|
+
* read, a live Codex main whose folder `reaches` the board is reused or ONE is opened in the board's folder under `name`, and
|
|
2403
|
+
* `message` is posted into it — never a Claude chat, a `codex exec` or a second app server; `record` is handed the worker right
|
|
2404
|
+
* before the post is sent. No login is {@link WorkerRefused}; a daemon that cannot be reached or refuses is
|
|
2405
|
+
* {@link WorkerNotStarted}, started again on the queue's backoff.
|
|
2406
|
+
*/
|
|
2407
|
+
export async function postCodexStory(control, board, reaches, name, message, now, record) {
|
|
2408
|
+
try {
|
|
2409
|
+
const login = await control.login();
|
|
2410
|
+
if (!login.signedIn)
|
|
2411
|
+
throw new WorkerRefused(login.why);
|
|
2412
|
+
const { main } = await control.mainFor(reaches, board, name);
|
|
2413
|
+
const worker = { provider: "codex", startedAt: now, jobId: main.threadId };
|
|
2414
|
+
await control.post(main.threadId, message, () => record(worker));
|
|
2415
|
+
return worker;
|
|
2416
|
+
}
|
|
2417
|
+
catch (err) {
|
|
2418
|
+
if (!(err instanceof CodexControlFailed))
|
|
2419
|
+
throw err;
|
|
2420
|
+
throw new WorkerNotStarted(err.message, err instanceof CodexRefused);
|
|
2421
|
+
}
|
|
2422
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omni-notify-mcp",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.361",
|
|
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",
|