oh-my-codex 0.21.48 → 0.22.0

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.
Files changed (152) hide show
  1. package/Cargo.lock +6 -6
  2. package/Cargo.toml +1 -1
  3. package/README.md +15 -0
  4. package/crates/omx-mux/src/herdr.rs +481 -0
  5. package/crates/omx-mux/src/lib.rs +5 -0
  6. package/dist/cli/__tests__/session-compare.test.d.ts +2 -0
  7. package/dist/cli/__tests__/session-compare.test.d.ts.map +1 -0
  8. package/dist/cli/__tests__/session-compare.test.js +183 -0
  9. package/dist/cli/__tests__/session-compare.test.js.map +1 -0
  10. package/dist/cli/__tests__/team.test.js +8 -0
  11. package/dist/cli/__tests__/team.test.js.map +1 -1
  12. package/dist/cli/session-compare.d.ts +11 -0
  13. package/dist/cli/session-compare.d.ts.map +1 -0
  14. package/dist/cli/session-compare.js +172 -0
  15. package/dist/cli/session-compare.js.map +1 -0
  16. package/dist/cli/session-search.d.ts.map +1 -1
  17. package/dist/cli/session-search.js +7 -0
  18. package/dist/cli/session-search.js.map +1 -1
  19. package/dist/cli/team.d.ts.map +1 -1
  20. package/dist/cli/team.js +2 -0
  21. package/dist/cli/team.js.map +1 -1
  22. package/dist/config/__tests__/multiplexer.test.d.ts +2 -0
  23. package/dist/config/__tests__/multiplexer.test.d.ts.map +1 -0
  24. package/dist/config/__tests__/multiplexer.test.js +118 -0
  25. package/dist/config/__tests__/multiplexer.test.js.map +1 -0
  26. package/dist/config/multiplexer.d.ts +29 -0
  27. package/dist/config/multiplexer.d.ts.map +1 -0
  28. package/dist/config/multiplexer.js +91 -0
  29. package/dist/config/multiplexer.js.map +1 -0
  30. package/dist/scripts/__tests__/codex-native-hook.test.js +281 -1
  31. package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -1
  32. package/dist/scripts/codex-native-hook.d.ts.map +1 -1
  33. package/dist/scripts/codex-native-hook.js +8 -2
  34. package/dist/scripts/codex-native-hook.js.map +1 -1
  35. package/dist/scripts/notify-hook/team-worker-lease.d.ts +15 -0
  36. package/dist/scripts/notify-hook/team-worker-lease.d.ts.map +1 -0
  37. package/dist/scripts/notify-hook/team-worker-lease.js +63 -0
  38. package/dist/scripts/notify-hook/team-worker-lease.js.map +1 -0
  39. package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts +1 -0
  40. package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts.map +1 -1
  41. package/dist/scripts/notify-hook/team-worker-posttooluse.js +16 -5
  42. package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -1
  43. package/dist/scripts/notify-hook/team-worker.d.ts +12 -1
  44. package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -1
  45. package/dist/scripts/notify-hook/team-worker.js +16 -4
  46. package/dist/scripts/notify-hook/team-worker.js.map +1 -1
  47. package/dist/session-history/__tests__/compare.test.d.ts +2 -0
  48. package/dist/session-history/__tests__/compare.test.d.ts.map +1 -0
  49. package/dist/session-history/__tests__/compare.test.js +257 -0
  50. package/dist/session-history/__tests__/compare.test.js.map +1 -0
  51. package/dist/session-history/compare.d.ts +74 -0
  52. package/dist/session-history/compare.d.ts.map +1 -0
  53. package/dist/session-history/compare.js +165 -0
  54. package/dist/session-history/compare.js.map +1 -0
  55. package/dist/team/__tests__/api-interop.test.js +3 -3
  56. package/dist/team/__tests__/cross-rebase-smoke.test.js +263 -31
  57. package/dist/team/__tests__/cross-rebase-smoke.test.js.map +1 -1
  58. package/dist/team/__tests__/herdr-session-realherdr.test.d.ts +2 -0
  59. package/dist/team/__tests__/herdr-session-realherdr.test.d.ts.map +1 -0
  60. package/dist/team/__tests__/herdr-session-realherdr.test.js +68 -0
  61. package/dist/team/__tests__/herdr-session-realherdr.test.js.map +1 -0
  62. package/dist/team/__tests__/herdr-session.test.d.ts +2 -0
  63. package/dist/team/__tests__/herdr-session.test.d.ts.map +1 -0
  64. package/dist/team/__tests__/herdr-session.test.js +228 -0
  65. package/dist/team/__tests__/herdr-session.test.js.map +1 -0
  66. package/dist/team/__tests__/idle-nudge.test.js +84 -0
  67. package/dist/team/__tests__/idle-nudge.test.js.map +1 -1
  68. package/dist/team/__tests__/rebalance-policy.test.js +27 -9
  69. package/dist/team/__tests__/rebalance-policy.test.js.map +1 -1
  70. package/dist/team/__tests__/runtime-delivery.test.d.ts +2 -0
  71. package/dist/team/__tests__/runtime-delivery.test.d.ts.map +1 -0
  72. package/dist/team/__tests__/runtime-delivery.test.js +570 -0
  73. package/dist/team/__tests__/runtime-delivery.test.js.map +1 -0
  74. package/dist/team/__tests__/runtime.test.js +332 -18
  75. package/dist/team/__tests__/runtime.test.js.map +1 -1
  76. package/dist/team/__tests__/scaling.test.js +293 -0
  77. package/dist/team/__tests__/scaling.test.js.map +1 -1
  78. package/dist/team/__tests__/state-renewal.test.d.ts +2 -0
  79. package/dist/team/__tests__/state-renewal.test.d.ts.map +1 -0
  80. package/dist/team/__tests__/state-renewal.test.js +555 -0
  81. package/dist/team/__tests__/state-renewal.test.js.map +1 -0
  82. package/dist/team/__tests__/task-lease.test.d.ts +2 -0
  83. package/dist/team/__tests__/task-lease.test.d.ts.map +1 -0
  84. package/dist/team/__tests__/task-lease.test.js +179 -0
  85. package/dist/team/__tests__/task-lease.test.js.map +1 -0
  86. package/dist/team/__tests__/team-ops-contract.test.js +1 -0
  87. package/dist/team/__tests__/team-ops-contract.test.js.map +1 -1
  88. package/dist/team/__tests__/worker-bootstrap.test.js +2 -0
  89. package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -1
  90. package/dist/team/api-interop.d.ts +1 -1
  91. package/dist/team/api-interop.d.ts.map +1 -1
  92. package/dist/team/api-interop.js +13 -1
  93. package/dist/team/api-interop.js.map +1 -1
  94. package/dist/team/goal-workflow.js +1 -1
  95. package/dist/team/herdr-session.d.ts +234 -0
  96. package/dist/team/herdr-session.d.ts.map +1 -0
  97. package/dist/team/herdr-session.js +489 -0
  98. package/dist/team/herdr-session.js.map +1 -0
  99. package/dist/team/idle-nudge.d.ts +16 -4
  100. package/dist/team/idle-nudge.d.ts.map +1 -1
  101. package/dist/team/idle-nudge.js +51 -19
  102. package/dist/team/idle-nudge.js.map +1 -1
  103. package/dist/team/mcp-comm.d.ts +1 -1
  104. package/dist/team/mcp-comm.d.ts.map +1 -1
  105. package/dist/team/rebalance-policy.d.ts.map +1 -1
  106. package/dist/team/rebalance-policy.js +5 -2
  107. package/dist/team/rebalance-policy.js.map +1 -1
  108. package/dist/team/runtime.d.ts.map +1 -1
  109. package/dist/team/runtime.js +356 -81
  110. package/dist/team/runtime.js.map +1 -1
  111. package/dist/team/scaling.d.ts.map +1 -1
  112. package/dist/team/scaling.js +332 -143
  113. package/dist/team/scaling.js.map +1 -1
  114. package/dist/team/state/monitor.d.ts +3 -0
  115. package/dist/team/state/monitor.d.ts.map +1 -1
  116. package/dist/team/state/monitor.js +3 -0
  117. package/dist/team/state/monitor.js.map +1 -1
  118. package/dist/team/state/tasks.d.ts +2 -1
  119. package/dist/team/state/tasks.d.ts.map +1 -1
  120. package/dist/team/state/tasks.js +28 -0
  121. package/dist/team/state/tasks.js.map +1 -1
  122. package/dist/team/state/types.d.ts +8 -0
  123. package/dist/team/state/types.d.ts.map +1 -1
  124. package/dist/team/state/types.js.map +1 -1
  125. package/dist/team/state.d.ts +14 -2
  126. package/dist/team/state.d.ts.map +1 -1
  127. package/dist/team/state.js +29 -5
  128. package/dist/team/state.js.map +1 -1
  129. package/dist/team/task-lease.d.ts +4 -0
  130. package/dist/team/task-lease.d.ts.map +1 -0
  131. package/dist/team/task-lease.js +74 -0
  132. package/dist/team/task-lease.js.map +1 -0
  133. package/dist/team/team-ops.d.ts +2 -1
  134. package/dist/team/team-ops.d.ts.map +1 -1
  135. package/dist/team/team-ops.js +1 -0
  136. package/dist/team/team-ops.js.map +1 -1
  137. package/dist/team/tmux-session.d.ts +1 -1
  138. package/dist/team/tmux-session.d.ts.map +1 -1
  139. package/dist/team/tmux-session.js +10 -2
  140. package/dist/team/tmux-session.js.map +1 -1
  141. package/dist/team/worker-bootstrap.d.ts.map +1 -1
  142. package/dist/team/worker-bootstrap.js +14 -1
  143. package/dist/team/worker-bootstrap.js.map +1 -1
  144. package/package.json +1 -1
  145. package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
  146. package/plugins/oh-my-codex/skills/worker/SKILL.md +7 -1
  147. package/skills/worker/SKILL.md +7 -1
  148. package/src/scripts/__tests__/codex-native-hook.test.ts +279 -0
  149. package/src/scripts/codex-native-hook.ts +8 -2
  150. package/src/scripts/notify-hook/team-worker-lease.ts +69 -0
  151. package/src/scripts/notify-hook/team-worker-posttooluse.ts +16 -4
  152. package/src/scripts/notify-hook/team-worker.ts +15 -4
@@ -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
- await writeHeartbeat(stateRoot, teamName, workerName, nowIso);
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 { readFile, writeFile, mkdir, appendFile, rename, stat, readdir } from 'fs/promises';
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
- // Atomic write: tmp + rename
346
+ // Best-effort heartbeat telemetry must not bypass authoritative renewal.
346
347
  const tmpPath = heartbeatPath + '.tmp.' + process.pid;
347
- await writeFile(tmpPath, JSON.stringify(heartbeat, null, 2));
348
- await rename(tmpPath, heartbeatPath);
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 }) {