oh-my-codex 0.21.48 → 0.22.1
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/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/README.md +15 -0
- package/crates/omx-mux/src/herdr.rs +481 -0
- package/crates/omx-mux/src/lib.rs +5 -0
- package/dist/cli/__tests__/plugin-cache-live-pin-3790.test.js +104 -3
- package/dist/cli/__tests__/plugin-cache-live-pin-3790.test.js.map +1 -1
- package/dist/cli/__tests__/question.test.js +33 -0
- package/dist/cli/__tests__/question.test.js.map +1 -1
- package/dist/cli/__tests__/session-compare.test.d.ts +2 -0
- package/dist/cli/__tests__/session-compare.test.d.ts.map +1 -0
- package/dist/cli/__tests__/session-compare.test.js +183 -0
- package/dist/cli/__tests__/session-compare.test.js.map +1 -0
- package/dist/cli/__tests__/team.test.js +8 -0
- package/dist/cli/__tests__/team.test.js.map +1 -1
- package/dist/cli/plugin-marketplace.d.ts.map +1 -1
- package/dist/cli/plugin-marketplace.js +11 -4
- package/dist/cli/plugin-marketplace.js.map +1 -1
- package/dist/cli/question.d.ts.map +1 -1
- package/dist/cli/question.js +8 -1
- package/dist/cli/question.js.map +1 -1
- package/dist/cli/session-compare.d.ts +11 -0
- package/dist/cli/session-compare.d.ts.map +1 -0
- package/dist/cli/session-compare.js +172 -0
- package/dist/cli/session-compare.js.map +1 -0
- package/dist/cli/session-search.d.ts.map +1 -1
- package/dist/cli/session-search.js +7 -0
- package/dist/cli/session-search.js.map +1 -1
- package/dist/cli/team.d.ts.map +1 -1
- package/dist/cli/team.js +2 -0
- package/dist/cli/team.js.map +1 -1
- package/dist/config/__tests__/multiplexer.test.d.ts +2 -0
- package/dist/config/__tests__/multiplexer.test.d.ts.map +1 -0
- package/dist/config/__tests__/multiplexer.test.js +118 -0
- package/dist/config/__tests__/multiplexer.test.js.map +1 -0
- package/dist/config/multiplexer.d.ts +29 -0
- package/dist/config/multiplexer.d.ts.map +1 -0
- package/dist/config/multiplexer.js +91 -0
- package/dist/config/multiplexer.js.map +1 -0
- package/dist/question/__tests__/ui.test.js +40 -1
- package/dist/question/__tests__/ui.test.js.map +1 -1
- package/dist/question/ui.d.ts.map +1 -1
- package/dist/question/ui.js +37 -7
- package/dist/question/ui.js.map +1 -1
- package/dist/scripts/__tests__/codex-native-hook.test.js +281 -1
- package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -1
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +8 -2
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker-lease.d.ts +15 -0
- package/dist/scripts/notify-hook/team-worker-lease.d.ts.map +1 -0
- package/dist/scripts/notify-hook/team-worker-lease.js +63 -0
- package/dist/scripts/notify-hook/team-worker-lease.js.map +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts +1 -0
- package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker-posttooluse.js +16 -5
- package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -1
- package/dist/scripts/notify-hook/team-worker.d.ts +12 -1
- package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-worker.js +16 -4
- package/dist/scripts/notify-hook/team-worker.js.map +1 -1
- package/dist/session-history/__tests__/compare.test.d.ts +2 -0
- package/dist/session-history/__tests__/compare.test.d.ts.map +1 -0
- package/dist/session-history/__tests__/compare.test.js +257 -0
- package/dist/session-history/__tests__/compare.test.js.map +1 -0
- package/dist/session-history/compare.d.ts +74 -0
- package/dist/session-history/compare.d.ts.map +1 -0
- package/dist/session-history/compare.js +165 -0
- package/dist/session-history/compare.js.map +1 -0
- package/dist/team/__tests__/api-interop.test.js +3 -3
- package/dist/team/__tests__/completion-evidence.test.js +31 -1
- package/dist/team/__tests__/completion-evidence.test.js.map +1 -1
- package/dist/team/__tests__/cross-rebase-smoke.test.js +263 -31
- package/dist/team/__tests__/cross-rebase-smoke.test.js.map +1 -1
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js +68 -0
- package/dist/team/__tests__/herdr-session-realherdr.test.js.map +1 -0
- package/dist/team/__tests__/herdr-session.test.d.ts +2 -0
- package/dist/team/__tests__/herdr-session.test.d.ts.map +1 -0
- package/dist/team/__tests__/herdr-session.test.js +228 -0
- package/dist/team/__tests__/herdr-session.test.js.map +1 -0
- package/dist/team/__tests__/hook-primary-e2e-contract.test.js +9 -3
- package/dist/team/__tests__/hook-primary-e2e-contract.test.js.map +1 -1
- package/dist/team/__tests__/idle-nudge.test.js +84 -0
- package/dist/team/__tests__/idle-nudge.test.js.map +1 -1
- package/dist/team/__tests__/mcp-comm.test.js +25 -1
- package/dist/team/__tests__/mcp-comm.test.js.map +1 -1
- package/dist/team/__tests__/rebalance-policy.test.js +27 -9
- package/dist/team/__tests__/rebalance-policy.test.js.map +1 -1
- package/dist/team/__tests__/runtime-delivery.test.d.ts +2 -0
- package/dist/team/__tests__/runtime-delivery.test.d.ts.map +1 -0
- package/dist/team/__tests__/runtime-delivery.test.js +570 -0
- package/dist/team/__tests__/runtime-delivery.test.js.map +1 -0
- package/dist/team/__tests__/runtime.test.js +938 -70
- package/dist/team/__tests__/runtime.test.js.map +1 -1
- package/dist/team/__tests__/scaling.test.js +645 -1
- package/dist/team/__tests__/scaling.test.js.map +1 -1
- package/dist/team/__tests__/state-renewal.test.d.ts +2 -0
- package/dist/team/__tests__/state-renewal.test.d.ts.map +1 -0
- package/dist/team/__tests__/state-renewal.test.js +555 -0
- package/dist/team/__tests__/state-renewal.test.js.map +1 -0
- package/dist/team/__tests__/state.test.js +121 -2
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/__tests__/task-lease.test.d.ts +2 -0
- package/dist/team/__tests__/task-lease.test.d.ts.map +1 -0
- package/dist/team/__tests__/task-lease.test.js +179 -0
- package/dist/team/__tests__/task-lease.test.js.map +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js +1 -0
- package/dist/team/__tests__/team-ops-contract.test.js.map +1 -1
- package/dist/team/__tests__/worker-bootstrap.test.js +2 -0
- package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
- package/dist/team/api-interop.d.ts +1 -1
- package/dist/team/api-interop.d.ts.map +1 -1
- package/dist/team/api-interop.js +13 -1
- package/dist/team/api-interop.js.map +1 -1
- package/dist/team/completion-evidence.d.ts +1 -1
- package/dist/team/completion-evidence.d.ts.map +1 -1
- package/dist/team/completion-evidence.js +9 -0
- package/dist/team/completion-evidence.js.map +1 -1
- package/dist/team/goal-workflow.js +1 -1
- package/dist/team/herdr-session.d.ts +234 -0
- package/dist/team/herdr-session.d.ts.map +1 -0
- package/dist/team/herdr-session.js +489 -0
- package/dist/team/herdr-session.js.map +1 -0
- package/dist/team/idle-nudge.d.ts +16 -4
- package/dist/team/idle-nudge.d.ts.map +1 -1
- package/dist/team/idle-nudge.js +51 -19
- package/dist/team/idle-nudge.js.map +1 -1
- package/dist/team/mcp-comm.d.ts +6 -4
- package/dist/team/mcp-comm.d.ts.map +1 -1
- package/dist/team/mcp-comm.js +4 -0
- package/dist/team/mcp-comm.js.map +1 -1
- package/dist/team/rebalance-policy.d.ts.map +1 -1
- package/dist/team/rebalance-policy.js +5 -2
- package/dist/team/rebalance-policy.js.map +1 -1
- package/dist/team/runtime.d.ts.map +1 -1
- package/dist/team/runtime.js +463 -166
- package/dist/team/runtime.js.map +1 -1
- package/dist/team/scaling.d.ts +3 -3
- package/dist/team/scaling.d.ts.map +1 -1
- package/dist/team/scaling.js +394 -200
- package/dist/team/scaling.js.map +1 -1
- package/dist/team/state/monitor.d.ts +3 -0
- package/dist/team/state/monitor.d.ts.map +1 -1
- package/dist/team/state/monitor.js +3 -0
- package/dist/team/state/monitor.js.map +1 -1
- package/dist/team/state/tasks.d.ts +4 -1
- package/dist/team/state/tasks.d.ts.map +1 -1
- package/dist/team/state/tasks.js +36 -5
- package/dist/team/state/tasks.js.map +1 -1
- package/dist/team/state/types.d.ts +9 -0
- package/dist/team/state/types.d.ts.map +1 -1
- package/dist/team/state/types.js.map +1 -1
- package/dist/team/state.d.ts +15 -2
- package/dist/team/state.d.ts.map +1 -1
- package/dist/team/state.js +73 -5
- package/dist/team/state.js.map +1 -1
- package/dist/team/task-lease.d.ts +4 -0
- package/dist/team/task-lease.d.ts.map +1 -0
- package/dist/team/task-lease.js +74 -0
- package/dist/team/task-lease.js.map +1 -0
- package/dist/team/team-ops.d.ts +2 -1
- package/dist/team/team-ops.d.ts.map +1 -1
- package/dist/team/team-ops.js +1 -0
- package/dist/team/team-ops.js.map +1 -1
- package/dist/team/tmux-session.d.ts +1 -1
- package/dist/team/tmux-session.d.ts.map +1 -1
- package/dist/team/tmux-session.js +10 -2
- package/dist/team/tmux-session.js.map +1 -1
- package/dist/team/worker-bootstrap.d.ts.map +1 -1
- package/dist/team/worker-bootstrap.js +16 -3
- package/dist/team/worker-bootstrap.js.map +1 -1
- package/package.json +1 -1
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/oh-my-codex/hooks/codex-native-hook.mjs +4 -1
- package/plugins/oh-my-codex/skills/worker/SKILL.md +7 -1
- package/skills/worker/SKILL.md +7 -1
- package/src/scripts/__tests__/codex-native-hook.test.ts +279 -0
- package/src/scripts/codex-native-hook.ts +8 -2
- package/src/scripts/notify-hook/team-worker-lease.ts +69 -0
- package/src/scripts/notify-hook/team-worker-posttooluse.ts +16 -4
- package/src/scripts/notify-hook/team-worker.ts +15 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { teamReadTask, teamRenewTaskClaim, teamSendMessage, type RenewTaskClaimResult, type TeamTask } from '../../team/team-ops.js';
|
|
4
|
+
import { resolveCanonicalTeamStateRoot } from '../../team/state-root.js';
|
|
5
|
+
|
|
6
|
+
type WorkerTaskLeaseRenewalResult = RenewTaskClaimResult
|
|
7
|
+
| { ok: false; error: string }
|
|
8
|
+
// Local automatic-hook outcome only: terminal handoff grants no lease or editing authority.
|
|
9
|
+
| { ok: true; task: TeamTask; terminalHandoff: true };
|
|
10
|
+
|
|
11
|
+
/** Heartbeats carry the worker's captured token, never a token looked up from the current task. */
|
|
12
|
+
export async function renewWorkerTaskLease(
|
|
13
|
+
stateRoot: string,
|
|
14
|
+
teamName: string,
|
|
15
|
+
workerName: string,
|
|
16
|
+
): Promise<WorkerTaskLeaseRenewalResult | null> {
|
|
17
|
+
let status: { state?: string; current_task_id?: string; current_claim_token?: string };
|
|
18
|
+
try {
|
|
19
|
+
status = JSON.parse(await readFile(join(stateRoot, 'team', teamName, 'workers', workerName, 'status.json'), 'utf8'));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT' || error instanceof SyntaxError) return null;
|
|
22
|
+
return { ok: false, error: `renewal_error:${String(error)}` };
|
|
23
|
+
}
|
|
24
|
+
if (!status) return null;
|
|
25
|
+
if (status.state !== 'working' || typeof status.current_task_id !== 'string' || typeof status.current_claim_token !== 'string'
|
|
26
|
+
|| !status.current_task_id || !status.current_claim_token) return null;
|
|
27
|
+
try {
|
|
28
|
+
const config = JSON.parse(await readFile(join(stateRoot, 'team', teamName, 'config.json'), 'utf8'));
|
|
29
|
+
const cwd = typeof config.leader_cwd === 'string' && config.leader_cwd ? config.leader_cwd : resolve(stateRoot, '../..');
|
|
30
|
+
// Do not let a cross-worktree hook renew a different team's local state.
|
|
31
|
+
if (resolveCanonicalTeamStateRoot(cwd) !== resolve(stateRoot)) return null;
|
|
32
|
+
const renewal = await teamRenewTaskClaim(teamName, status.current_task_id, workerName, status.current_claim_token, cwd);
|
|
33
|
+
if (!renewal.ok && renewal.error === 'already_terminal') {
|
|
34
|
+
const task = await teamReadTask(teamName, status.current_task_id, cwd);
|
|
35
|
+
if (task && (task.status === 'completed' || task.status === 'failed') && task.owner === workerName && !task.claim) {
|
|
36
|
+
return { ok: true, task, terminalHandoff: true };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return renewal;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// Automatic callers must report STOP, not lose renewal exceptions in their outer hook catch.
|
|
42
|
+
return { ok: false, error: `renewal_error:${String(error)}` };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Keep lease loss visible even when notify treats hook errors as non-critical. */
|
|
47
|
+
export async function reportWorkerTaskLeaseLoss(
|
|
48
|
+
stateRoot: string,
|
|
49
|
+
teamName: string,
|
|
50
|
+
workerName: string,
|
|
51
|
+
error: string,
|
|
52
|
+
): Promise<string> {
|
|
53
|
+
const message = `LEASE LOST: ${teamName}/${workerName} renewal rejected (${error}). STOP editing and claim-dependent work; contact the leader. Do not adopt another token or revive an expired claim.`;
|
|
54
|
+
const warn = (detail = ''): void => {
|
|
55
|
+
try { process.stderr.write(`${message}${detail}\n`); } catch { /* Diagnostics must not erase the returned STOP. */ }
|
|
56
|
+
};
|
|
57
|
+
warn();
|
|
58
|
+
const config = await readFile(join(stateRoot, 'team', teamName, 'config.json'), 'utf8').then(JSON.parse).catch(() => ({}));
|
|
59
|
+
const cwd = typeof config?.leader_cwd === 'string' && config.leader_cwd ? config.leader_cwd : resolve(stateRoot, '../..');
|
|
60
|
+
await writeFile(join(stateRoot, 'team', teamName, 'workers', workerName, 'lease-loss.json'), JSON.stringify({ message, error, updated_at: new Date().toISOString() })).catch((cause) => {
|
|
61
|
+
warn(` Lease-loss record failed: ${String(cause)}`);
|
|
62
|
+
});
|
|
63
|
+
for (const recipient of [workerName, 'leader-fixed']) {
|
|
64
|
+
await teamSendMessage(teamName, workerName, recipient, message, cwd).catch((cause) => {
|
|
65
|
+
warn(` Notification to ${recipient} failed: ${String(cause)}`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return message;
|
|
69
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renewWorkerTaskLease, reportWorkerTaskLeaseLoss } from './team-worker-lease.js';
|
|
1
2
|
import { execFile } from 'child_process';
|
|
2
3
|
import { existsSync } from 'fs';
|
|
3
4
|
import { mkdir, readFile, writeFile } from 'fs/promises';
|
|
@@ -18,6 +19,7 @@ export interface TeamWorkerPostToolUseResult {
|
|
|
18
19
|
handled: boolean;
|
|
19
20
|
status: PostToolUseStatus;
|
|
20
21
|
reason?: string;
|
|
22
|
+
stopMessage?: string;
|
|
21
23
|
teamName?: string;
|
|
22
24
|
workerName?: string;
|
|
23
25
|
stateRoot?: string;
|
|
@@ -397,9 +399,6 @@ export async function handleTeamWorkerPostToolUseSuccess(
|
|
|
397
399
|
): Promise<TeamWorkerPostToolUseResult> {
|
|
398
400
|
try {
|
|
399
401
|
if (readHookEvent(payload) !== 'PostToolUse') return { handled: false, status: 'skipped', reason: 'not_posttooluse', operationKinds: [] };
|
|
400
|
-
if (readToolName(payload) !== 'Bash') return { handled: false, status: 'skipped', reason: 'not_bash', operationKinds: [] };
|
|
401
|
-
if (readExitCode(payload) !== 0) return { handled: false, status: 'skipped', reason: 'nonzero_exit', operationKinds: [] };
|
|
402
|
-
|
|
403
402
|
const parsedWorker = parseTeamWorkerEnv(env.OMX_TEAM_INTERNAL_WORKER ?? env.OMX_TEAM_WORKER);
|
|
404
403
|
if (!parsedWorker) return { handled: false, status: 'skipped', reason: 'missing_worker_env', operationKinds: [] };
|
|
405
404
|
|
|
@@ -423,7 +422,20 @@ export async function handleTeamWorkerPostToolUseSuccess(
|
|
|
423
422
|
}
|
|
424
423
|
|
|
425
424
|
const nowIso = new Date().toISOString();
|
|
426
|
-
|
|
425
|
+
// Best-effort heartbeat telemetry must not bypass authoritative renewal.
|
|
426
|
+
await writeHeartbeat(stateRoot, teamName, workerName, nowIso).catch(() => {});
|
|
427
|
+
const renewal = await renewWorkerTaskLease(stateRoot, teamName, workerName);
|
|
428
|
+
if (renewal && 'terminalHandoff' in renewal) {
|
|
429
|
+
return { handled: true, status: 'skipped', reason: 'terminal_handoff', teamName, workerName, stateRoot, worktreePath, operationKinds: [] };
|
|
430
|
+
}
|
|
431
|
+
if (renewal && !renewal.ok) {
|
|
432
|
+
const stopMessage = await reportWorkerTaskLeaseLoss(stateRoot, teamName, workerName, renewal.error);
|
|
433
|
+
return { handled: true, status: 'skipped', reason: `lease_lost:${renewal.error}`, stopMessage, teamName, workerName, stateRoot, worktreePath, operationKinds: [] };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Tool activity renews the claim; only explicit Bash success authorizes checkpointing.
|
|
437
|
+
if (readToolName(payload) !== 'Bash') return { handled: false, status: 'skipped', reason: 'not_bash', operationKinds: [] };
|
|
438
|
+
if (readExitCode(payload) !== 0) return { handled: false, status: 'skipped', reason: 'nonzero_exit', operationKinds: [] };
|
|
427
439
|
|
|
428
440
|
const config = await readTeamConfig(stateRoot, teamName);
|
|
429
441
|
const leaderArtifactCwd = readLeaderArtifactCwd(config, cwd);
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Team worker: heartbeat, idle detection, and leader notification.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { renewWorkerTaskLease, reportWorkerTaskLeaseLoss } from './team-worker-lease.js';
|
|
7
|
+
import { readFile, writeFile, mkdir, appendFile, rename, stat, readdir, rm } from 'fs/promises';
|
|
7
8
|
import { existsSync } from 'fs';
|
|
8
9
|
import { join } from 'path';
|
|
9
10
|
import { resolveWorkerNotifyTeamStateRootPath } from '../../team/state-root.js';
|
|
@@ -342,10 +343,20 @@ export async function updateWorkerHeartbeat(stateDir, teamName, workerName) {
|
|
|
342
343
|
turn_count: turnCount + 1,
|
|
343
344
|
alive: true,
|
|
344
345
|
};
|
|
345
|
-
//
|
|
346
|
+
// Best-effort heartbeat telemetry must not bypass authoritative renewal.
|
|
346
347
|
const tmpPath = heartbeatPath + '.tmp.' + process.pid;
|
|
347
|
-
|
|
348
|
-
|
|
348
|
+
try {
|
|
349
|
+
await writeFile(tmpPath, JSON.stringify(heartbeat, null, 2));
|
|
350
|
+
await rename(tmpPath, heartbeatPath);
|
|
351
|
+
} catch {
|
|
352
|
+
await rm(tmpPath, { force: true }).catch(() => {});
|
|
353
|
+
}
|
|
354
|
+
const renewal = await renewWorkerTaskLease(stateDir, teamName, workerName);
|
|
355
|
+
if (renewal && !renewal.ok) {
|
|
356
|
+
const stopMessage = await reportWorkerTaskLeaseLoss(stateDir, teamName, workerName, renewal.error);
|
|
357
|
+
return { ok: false, error: renewal.error, stopMessage };
|
|
358
|
+
}
|
|
359
|
+
return renewal;
|
|
349
360
|
}
|
|
350
361
|
|
|
351
362
|
export async function maybeNotifyLeaderAllWorkersIdle({ cwd, stateDir, logsDir, parsedTeamWorker }) {
|