codex-supervisor-mcp 0.13.3 → 0.13.4

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/README.en.md CHANGED
@@ -151,7 +151,7 @@ Thirty-nine.
151
151
 
152
152
  | Tool | Arguments | What it does |
153
153
  |---|---|---|
154
- | `check_workers` | none | Report newly settled runs and actionable changes; recover a new-format first `lost`, `no_work` or `invalid_report` run once. Unchanged state is quiet. Call from a host-scheduled loop and use a distinct CODEX_SUPERVISOR_OBSERVER_ID for each reconnecting main thread |
154
+ | `check_workers` | none | Report newly settled runs, actionable failures and active-thread handoff reminders once per run; never cancel or replace a live worker for its token count. Recover a new-format first `lost`, `no_work` or `invalid_report` run once; unchanged state is quiet and a host-scheduled loop with a distinct observer ID supports reconnecting |
155
155
  | `overview_delta` | `cursor` | Main-thread incremental view: counters, changed summaries, short attention reason / next action and next_cursor; no prompt, diff, event or capsule history |
156
156
  | `check_acceptance` | `cwd`, `acceptance`, `baseRef`, `timeoutMs` | Execute supplied checks before dispatch, without creating a worker or proving completion; warns that failure-count greps do not establish an approved failure list or required execution |
157
157
  | `preflight_codex_worker` | `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, `ownedPaths`, `probeCommands`, `baseRef`, `sandbox`, `allowedCommands`, `context`, `contracts`, `networkAccess`, `writableRoots` | Run a short probe worker under the exact workspace/base/sandbox/guard contract intended for the later worker; wait for `get_worker_preflight` to report passed before dispatch |
@@ -159,7 +159,7 @@ Thirty-nine.
159
159
  | `create_codex_worker` | `task`, `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, **`ownedPaths`**, **`goal`**, `preflight_id`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `maxRunMs`, `maxTotalMs`, `acceptance`, `acceptanceTimeoutMs`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Git defaults to an isolated worktree. A non-Git write must choose `scratch`, or an authorized `in_place_write` with paths and acceptance. `workspaceSetup` prepares dependencies before the worker starts; when `preflight_id` is present its complete runtime contract must match. |
160
160
  | `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, `session_title`, `title`, `cwd`, `sandbox`, `model`, `ownedPaths`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `workspaceKind`, `workspaceSetup`, `goal`, `baseRef`, `acceptance` | A fresh session inherits the parent's current branch commit before landing, or the current target HEAD after landing; explicit `baseRef` takes precedence. Parent drafts are not copied; `preflight_id`, `dependsOn` and `skipGitRepoCheck` are unsupported. |
161
161
  | `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance`, `context` | Continue the same Codex conversation; `thread_id` stays. When the native goal is still active or its state database cannot prove completion, the resume omits the output schema for that turn to avoid `ActiveTurnOutputSchemaMismatch`. `rebaseOnto` first moves the worktree onto the project's newer commit (stash, skip integrated patches, replay new commits, unstash); a conflict puts it back and does not start the worker |
162
- | `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `pollMs`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. 60 seconds by default. `termination_reason` distinguishes settled, exhausted budget and client cancellation. `emitProgress: true` emits progress every 30 seconds when the client supplies a progress token. `compact` returns one row per worker |
162
+ | `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `allowLongWait`, `pollMs`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states with a call budget capped at 60 seconds unless the caller explicitly sets `allowLongWait: true` after verifying its client timeout. Returns requested/effective budgets, `timeout_capped` and a termination reason; `compact` gives one row per worker and `emitProgress` optionally sends progress notifications |
163
163
  | `get_orchestration_overview` | `status`, `limit` | Every worker in one table, capped at 7000 bytes. Carries `version` and `update` |
164
164
  | `get_worker_result` | `task_id`, `limit`, `maxChars`, `includeFiles` | The worker's own report, clipped past 6000 bytes with `truncated` and the size to ask for. `acceptance` is whether the supervisor's own checks passed, `verification` the commands the worker ran with exit codes, `base_behind` how far main has moved (`behind` is `null` with a note when `contains_base` is false, meaning the directory switched lines) |
165
165
  | `get_worker_diff` | `task_id`, `file`, `hunk`, `pageSize`, `cursor`, `maxChars`, `paths` | What the worker actually changed. The default response is a complete file/hunk index. Select one file and page hunks with `hunk` or `cursor`; `maxChars` without `file` keeps the legacy bounded full-diff mode |
@@ -229,9 +229,11 @@ Structured acceptance entries use `{command, reportPath, baseline}`. The baselin
229
229
 
230
230
  Landing checks the real diff against ownedPaths before committing drafts; only use allowOutsideOwned for an explicitly approved exception.
231
231
 
232
+ Worker acceptance runs before the dispatcher commits draft edits, so it should validate functionality and tests. Check clean Git status, commit counts and messages after landing. Inspect the failing check and its run before claiming a verdict is stale; a newer report, external test run or manual commit does not replace supervisor acceptance. Route conflicting requirements to the integration owner for revision and fresh acceptance instead of bypassing the gate with a manual cherry-pick.
233
+
232
234
  Session default_acceptance is prepended to local checks; resume uses the latest policy. describe_session returns policy_revision and expected_revision prevents stale edits. waiting_user blocks dispatch/resume until approved. host_goal_sync returns a current-policy /goal command. Replace an active native goal through /goal, or propose the same condition through ProposeGoal for host approval when available. The condition reads the latest session revision and approved scope; MCP does not silently modify or disable the host Stop hook.
233
235
 
234
- Wait defaults to 60 seconds and compact rows; includeEvents selects details unless compact is explicit. Clients supplying a progress token receive notifications every 30 seconds. MCP SDK and real Claude 2.1.299 are verified: a 65-second wait succeeds with a 35-second idle timeout after three progress notifications. Native /loop scheduling is also verified.
236
+ Wait defaults to 60 seconds and compact rows; longer requests are capped unless `allowLongWait: true` explicitly opts in. `requested_timeout_ms`, `timeout_ms` and `timeout_capped` expose the applied budget. Progress requires both `emitProgress` and a client progress token; it does not extend a host's hard timeout. Reattach an existing background wait instead of creating duplicates, and schedule `check_workers` for long monitoring.
235
237
 
236
238
  Each run injects the shipped PreToolUse guard: apply_patch checks every target including renames and symlinks; forbid rejects red lines. Shell allows simple reads and explicitly declared allowedCommands/acceptance. Declared validation scripts run with dispatcher privileges and may have side effects; this is not a filesystem sandbox for arbitrary programs. Resume/follow-up inherit the policy without changing global hooks. Empty write runs use current output and command evidence and surface no_work; read-only tasks are not empty merely for having no diff.
237
239
 
package/README.md CHANGED
@@ -161,7 +161,7 @@ land_codex_worker 核过了,带 commitMessage 代提交并落进集成
161
161
 
162
162
  | 工具 | 入参 | 作用 |
163
163
  |---|---|---|
164
- | `check_workers` | 无参 | 交付新终态、验收失败和需处理goal;新格式第1轮 `lost` / `no_work` / `invalid_report` 自动恢复一次,未变返回quiet;用宿主定时唤醒调用,每个主线程设独立CODEX_SUPERVISOR_OBSERVER_ID可在重启后接回 |
164
+ | `check_workers` | 无参 | 返回新终态、故障及长线程交接提醒;同一 run 的 handoff 只提醒一次,不中止或复制活跃 worker。已死的第1轮 `lost` / `no_work` / `invalid_report` 最多恢复一次;用宿主定时调用及独立 CODEX_SUPERVISOR_OBSERVER_ID 接回 |
165
165
  | `overview_delta` | `cursor` | 主线程默认轮询入口:只返回 active / needs_attention / ready_to_land / ready_to_clean、cursor 后变化、短版 attention_reason / next_action 和 next_cursor;不返回全量历史、prompt、diff、event 或 worker capsule |
166
166
  | `check_acceptance` | `cwd`, `acceptance`, `baseRef`, `timeoutMs` | 派单前实际运行给定验收命令,不建 worker,不证明 worker 完成;数量 grep 会提示不能证明失败名单和必跑执行 |
167
167
  | `preflight_codex_worker` | `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, `ownedPaths`, `probeCommands`, `baseRef`, `sandbox`, `allowedCommands`, `context`, `contracts`, `networkAccess`, `writableRoots` | 用与目标 worker 相同的 workspace/base/sandbox/guard 起短 probe worker;它必须实际跑完每条 probe command。probe 自动获得本次 guard-only 允许,但不进入目标 worker contract;联网和凭据目录仍须显式授权 |
@@ -169,7 +169,7 @@ land_codex_worker 核过了,带 commitMessage 代提交并落进集成
169
169
  | `create_codex_worker` | `task`, `cwd`, `workspaceKind`, `inPlaceAuthorization`, `workspaceSetup`, **`ownedPaths`**, **`goal`**, `preflight_id`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `maxRunMs`, `maxTotalMs`, `acceptance`, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Git 默认隔离 worktree;非 Git 写入必须选 `scratch` 或有授权、paths、acceptance 的 `in_place_write`。`workspaceSetup` 在起 worker 前链接依赖、初始化子模块、跑 prepare;`preflight_id` 给了就必须是通过的同环境 probe |
170
170
  | `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, `session_title`, `title`, `cwd`, `sandbox`, `model`, `ownedPaths`, `forbid`, `allowedCommands`, `context`, `contracts`, `externalOutputs`, `networkAccess`, `writableRoots`, `workspaceKind`, `workspaceSetup`, `goal`, `baseRef`, `acceptance` | 新会话继承父任务上下文:未 land 用父分支当前提交,已 land 用当前集成 HEAD,显式 `baseRef` 优先。未提交父改动不复制;不支持 `preflight_id`、`dependsOn`、`skipGitRepoCheck` |
171
171
  | `resume_codex_worker` | `task_id`, `prompt`, `rebaseOnto`, `acceptance`, `context` | 接同一个 Codex 会话继续跑,`thread_id` 不变。原生 goal 仍 active 或 goal 状态库不可判定时,本轮自动省略 output schema,避免 `ActiveTurnOutputSchemaMismatch`。`rebaseOnto` 先把 worktree 挪到主线新头(stash、跳过已合入补丁、重放新增提交、放回),冲突原样退回不起 worker |
172
- | `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态。默认 60 秒且不推周期 heartbeat;显式 `emitProgress: true` 才每 30 秒通知。`termination_reason` 区分 settled / budget_exhausted / client_cancelled;`compact` 每路一行 |
172
+ | `wait_codex_workers` | `task_ids`, `mode`(any/all), `timeoutMinutes`, `timeoutMs`, `allowLongWait`, `compact`, `emitProgress`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | 等终态,单次预算默认最多 60 秒,只有确认宿主超时允许后才传 `allowLongWait: true`。返回实际/请求预算与 `timeout_capped`,`termination_reason` 区分 settled / budget_exhausted / client_cancelled;`emitProgress` 可选,每路摘要用 `compact` |
173
173
  | `get_orchestration_overview` | `status`, `limit` | 全部 worker 的状态表,封顶 7000 字节。带 `version` 和 `update` |
174
174
  | `get_worker_result` | `task_id`, `limit`, `maxChars`, `includeFiles` | worker 自己的汇报,默认截 6000 字节、`truncated` 提示读全。`acceptance` 是 supervisor 替你跑的验收过没过,`verification` 是它自己跑过的命令和退出码,`base_behind` 是主线走了多远(`contains_base: false` 时 `behind` 为 `null`,那是换了线) |
175
175
  | `get_worker_diff` | `task_id`, `file`, `hunk`, `pageSize`, `cursor`, `maxChars`, `paths` | worker 实际改了什么。默认完整文件索引与 hunk 数;按 `file` + `hunk`/`cursor` 分页读 patch。显式 `maxChars` 且不传 `file` 保留旧整份限流模式 |
@@ -243,9 +243,11 @@ worker 进程和 supervisor 验收子进程都包含当前 `CODEX_SUPERVISOR_TAS
243
243
 
244
244
  落地前按真实 diff 核对 ownedPaths,越界拒绝且不提交草稿;只有用户明确授权时才用 allowOutsideOwned。
245
245
 
246
+ worker 的 acceptance 在代提交之前执行,应检查功能和测试;`test -z "$(git status --porcelain)"`、提交数量和提交信息检查由主线程放到 land 后执行。验收失败先核对当前 run 的具体失败项,不能仅因报告更新、外部测试通过或主线程补过提交就视旧失败为已解决;契约冲突交规划/集成负责人修订并重新验收,不手工 cherry-pick 绕过。
247
+
246
248
  同 session 的 `default_acceptance` 自动加到每路本地检查前;resume 会取最新策略。`describe_session` 返回 policy_revision,改目标/门禁可传 expected_revision 防旧窗口覆盖;waiting_user 拒绝派单与恢复,approved 后再继续。回执host_goal_sync包含按当前策略生成的/goal命令;宿主已有原生goal时用/goal替换条件,支持ProposeGoal时可提议同一条件并走宿主批准。条件要求读取最新session revision及批准范围;MCP不会偷偷修改或禁用宿主Stop hook。
247
249
 
248
- wait 默认预算60秒、默认compact;includeEvents会选择详细结果(显式compact优先)。带progress token的客户端每30秒收到通知;已验证MCP SDK及真实Claude2.1.299:idle35秒、wait65秒,三次progress后正常返回;原生/loop定时调用也已实测。
250
+ wait 默认预算60秒、默认compact,过长请求也限制为60秒,返回 `requested_timeout_ms` / `timeout_ms` / `timeout_capped`。确认客户端允许长调用后可显式 `allowLongWait: true`;`emitProgress` 只在请求且客户端传 progress token 时通知,不能延长宿主的硬超时。已有后台 wait 就接回它,不重复开长 wait;长期监控用宿主定时调用 `check_workers`。
249
251
 
250
252
  每路临时注入随包PreToolUse守卫:apply_patch核对全部目标路径(含rename和symlink),forbid拒绝红线;安全只读检查(rg/cat/sed无-i/git只读/jq无-i/find无-exec或-delete)默认允许且不占其他 worker 的写路径,写入/执行/有副作用的 Shell 命令必须显式声明。声明的验证脚本以派单者权限执行,可有副作用,不能当作任意程序的文件沙箱。guard策略随resume/followup继承,不写全局hooks。空跑write run按本轮输出前后内容和命令判断,no_work进入needs_attention;只读任务不因没改文件判空跑。
251
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-supervisor-mcp",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "mcpName": "io.github.zriyox/codex-supervisor-mcp",
5
5
  "type": "module",
6
6
  "description": "MCP server that dispatches and supervises parallel Codex CLI workers, one isolated Git worktree each, with a persisted work state machine.",
@@ -20,6 +20,7 @@ description: 用 Codex CLI 并行做可独立验收的功能包,每路一个 G
20
20
  5. 写 worker 先跑同 contract 的 `preflight_codex_worker`。`get_worker_preflight` 必须是 `passed`,再把 preflight task id 填进 `preflight_id`。`check_acceptance` 不能代替 worker 环境预检。
21
21
  6. 只要 worker 会 land,就必须有能证明结果的 acceptance。文件存在检查只能当附加条件,不能单独当完成证据。
22
22
  7. `workspace-write` worker 不执行 `git add`、`git commit` 或 `amend`。验收通过后由主线程 `land_codex_worker(commitMessage)` 代提交并落地。
23
+ worker acceptance 验功能与实际测试;Git 干净、提交数量和提交信息由主线程在 land 后检查,不能让未提交编辑的 worker 同时满足“必须无 diff”。契约冲突先报告规划/集成负责人修订,不手工 cherry-pick 或忽略门禁绕过。
23
24
  8. worker 不 push、不合并、不再派生 worker。临时 `codex/<id>` 分支不是交付物。
24
25
 
25
26
  `preflight_id` 是 AI 派单硬规则。MCP schema 为了兼容旧客户端仍允许省略,但不能把“没被 schema 拒绝”当成可以跳过预检。
@@ -75,8 +76,9 @@ description: 用 Codex CLI 并行做可独立验收的功能包,每路一个 G
75
76
  ## 等待与状态
76
77
 
77
78
  - 日常增量看 `overview_delta`,保存 `next_cursor`。需要全量状态时才用 `get_orchestration_overview`。
78
- - 短等用 `wait_codex_workers`,建议 `timeoutMs: 60000`、`compact: true`。`still_running: true` 只表示这次等待预算用完。
79
+ - 短等用 `wait_codex_workers`,默认最多60秒、`compact: true`;`timeout_capped` 表示长请求被限为短等,`still_running` 只表示预算用完。仅确认宿主允许长调用时才传 `allowLongWait: true`;已有后台 wait 就接回,不重复创建。
79
80
  - 长任务用宿主 `/loop 5m check_workers`。不同主线程设置不同的 `CODEX_SUPERVISOR_OBSERVER_ID`。
81
+ - `check_workers` 在活跃线程超过交接阈值时每个 run 提醒一次;先看状态与 stage,等当前步骤结算或明确取消后再整理 checkpoint 接续,不能因 token 多重复起同一任务。
80
82
  - `idle_seconds` 是距上一条 Codex 事件的时间。`command_running: true` 时长命令可能仍在跑;没有命令且长时间无事件,再查 `get_codex_worker_events`。
81
83
  - 不要用 shell 循环 grep `data/runs/*.jsonl` 判断状态。`failed`、`lost`、退出码和恢复状态以 supervisor 状态机为准。
82
84
 
package/src/mcp-server.js CHANGED
@@ -765,7 +765,7 @@ server.registerTool(
765
765
  );
766
766
  server.registerTool("check_workers", {
767
767
  title: "Check changed workers",
768
- description: "Check newly settled runs and actionable failures; automatically resume a dead lost/no_work first run once, except approval, authentication, permission and quota waits. Returns recovery receipts; unchanged state is quiet. Call from a host-scheduled loop; it cannot wake a closed host. Set a distinct CODEX_SUPERVISOR_OBSERVER_ID per main thread to retain its cursor across restarts.",
768
+ description: "Check newly settled runs, actionable failures and active threads crossing the handoff threshold; automatically resume a dead lost/no_work first run once, except approval, authentication, permission and quota waits. Handoff reminders occur once per run and never cancel, replace or resume a live worker. Unchanged state is quiet. Call from a host-scheduled loop; it cannot wake a closed host. Set a distinct CODEX_SUPERVISOR_OBSERVER_ID per main thread to retain its cursor across restarts.",
769
769
  inputSchema: {}
770
770
  }, async () => {
771
771
  const read = observerRead.then(async () => {
@@ -1090,12 +1090,13 @@ server.registerTool(
1090
1090
  {
1091
1091
  title: "Wait for Codex workers",
1092
1092
  description:
1093
- "Block until selected Codex workers reach a terminal status, then return summaries. The wait budget bounds this call, not the workers: when it runs out you get a progress snapshot and the workers keep running, so call this again with the same task_ids to keep waiting. Keep the budget under your client's MCP tool timeout, or the client kills the call instead of the wait returning. compact: true returns one line per worker: status, phase, exit_code, changed_file_count, acceptance (passed / failed / null when none was configured or it did not run), plus idle_seconds since the last Codex event of this run, command_running and current_command. Codex emits nothing while a command runs or while the model thinks, so a long idle with command_running: true is a long command and a long idle without it is thinking (or a process that reconcile will report as lost).",
1093
+ "Block until selected Codex workers reach a terminal status, then return summaries. Each call is capped at 60 seconds unless allowLongWait is explicitly true and the caller has verified its MCP timeout supports the requested budget. A spent wait budget returns a snapshot while workers continue; reuse the same task_ids or schedule check_workers for longer monitoring. compact: true returns one line per worker with status, phase, exit_code, changed_file_count, acceptance and liveness. command_running means a command may still be working despite a long idle interval.",
1094
1094
  inputSchema: {
1095
1095
  task_ids: z.array(z.string().min(1)).min(1),
1096
1096
  mode: z.enum(["any", "all"]).default("all"),
1097
1097
  timeoutMinutes: z.number().int().min(1).max(360).default(1),
1098
1098
  timeoutMs: z.number().int().min(1000).max(21600000).optional(),
1099
+ allowLongWait: z.boolean().default(false),
1099
1100
  pollMs: z.number().int().min(250).max(10000).default(1000),
1100
1101
  emitProgress: z.boolean().default(false),
1101
1102
  // Off by default. A wait is the call clients background and then replay
@@ -1121,6 +1122,7 @@ server.registerTool(
1121
1122
  mode,
1122
1123
  timeoutMinutes,
1123
1124
  timeoutMs,
1125
+ allowLongWait,
1124
1126
  pollMs,
1125
1127
  emitProgress,
1126
1128
  includeEvents,
@@ -1131,7 +1133,8 @@ server.registerTool(
1131
1133
  }, extra) => {
1132
1134
  const compact = requestedCompact ?? !includeEvents;
1133
1135
  const startedAt = Date.now();
1134
- const effectiveTimeoutMs = timeoutMs ?? timeoutMinutes * 60 * 1000;
1136
+ const requestedTimeoutMs = timeoutMs ?? timeoutMinutes * 60 * 1000;
1137
+ const effectiveTimeoutMs = allowLongWait ? requestedTimeoutMs : Math.min(requestedTimeoutMs, 60000);
1135
1138
  let tasks = [];
1136
1139
  const progressToken = extra?._meta?.progressToken;
1137
1140
  let lastProgressAt = -Infinity;
@@ -1152,7 +1155,7 @@ server.registerTool(
1152
1155
  } }).catch(() => {});
1153
1156
  lastProgressAt = elapsed;
1154
1157
  }
1155
- await sleep(pollMs);
1158
+ await sleep(Math.min(pollMs, Math.max(0, effectiveTimeoutMs - (Date.now() - startedAt))));
1156
1159
  }
1157
1160
 
1158
1161
  await reconcileDetachedActiveTasks();
@@ -1184,10 +1187,12 @@ server.registerTool(
1184
1187
  still_running: timedOut,
1185
1188
  termination_reason: clientCancelled ? "client_cancelled" : timedOut ? "budget_exhausted" : "settled",
1186
1189
  next_step: timedOut
1187
- ? `Workers are still running; the ${budgetLabel} wait budget ran out, not the workers. Call wait_codex_workers again with the same task_ids, or use get_orchestration_overview for a cheap progress read. Raise timeoutMinutes only if your client's MCP tool timeout allows it.`
1190
+ ? `Workers are still running; the ${budgetLabel} wait budget ran out. Reuse the same task_ids for a short wait, or schedule check_workers for long monitoring. Set allowLongWait only after verifying the client's MCP timeout supports the requested budget; do not start another long wait while a background wait is active.`
1188
1191
  : null,
1189
1192
  waited_ms: Date.now() - startedAt,
1190
1193
  timeout_ms: effectiveTimeoutMs,
1194
+ requested_timeout_ms: requestedTimeoutMs,
1195
+ timeout_capped: effectiveTimeoutMs !== requestedTimeoutMs,
1191
1196
  timeout_minutes: Math.round(effectiveTimeoutMs / 60000),
1192
1197
  missing_ids: missingIds,
1193
1198
  completed_count: tasks.filter((task) => task.status === "completed").length,
package/src/prompt.js CHANGED
@@ -82,7 +82,10 @@ export function buildGuardPreamble({ sandbox, ownedPaths = [], allowedCommands =
82
82
  // shell as a heredoc; the guard accepts that shape too, so the worker is told
83
83
  // about it instead of stalling on a tool it does not have.
84
84
  const shellEdit = "If your toolset has no apply_patch tool, run it through the shell as apply_patch <<'EOF' ... EOF; the guard checks the file paths the same way. A declared command ending in * is a prefix, so go test ./internal/* covers go test ./internal/service -run TestX.";
85
- return `Runtime supervisor guard: edits must use apply_patch within ${JSON.stringify(ownedPaths)}. ${shellEdit} Safe read-only inspection commands (rg, cat, sed without -i, git status/diff/log, jq without -i, find without -exec/-delete) are allowed and never reserve another worker's paths. Commands that validate, write, execute code or have side effects must exactly match declared commands ${JSON.stringify(allowedCommands)}. Forbidden: ${forbidden}. Undeclared shell programs are denied; report a needed validation command instead of bypassing the guard. ${stage}`;
85
+ const delivery = sandbox === "workspace-write" && (!workspaceKind || workspaceKind === "git_worktree")
86
+ ? "Do not run git add, git commit or git commit --amend: the dispatcher commits reviewed edits with land_codex_worker({commitMessage}). Leave your edits uncommitted; clean status and commit-count checks belong after landing. If the task or acceptance requires a self-commit or a clean edited worktree, report the contract conflict instead of bypassing the guard."
87
+ : "";
88
+ return `Runtime supervisor guard: edits must use apply_patch within ${JSON.stringify(ownedPaths)}. ${shellEdit} ${delivery} Safe read-only inspection commands (rg, cat, sed without -i, git status/diff/log, jq without -i, find without -exec/-delete) are allowed and never reserve another worker's paths. Commands that validate, write, execute code or have side effects must exactly match declared commands ${JSON.stringify(allowedCommands)}. Forbidden: ${forbidden}. Undeclared shell programs are denied; report a needed validation command instead of bypassing the guard. ${stage}`;
86
89
  }
87
90
 
88
91
  // The acceptance commands are shown to the worker. Hiding them would not
@@ -1,4 +1,5 @@
1
- import { TERMINAL_STATUSES, isGoalNeedingAttention } from "./status.js";
1
+ import { ACTIVE_STATUSES, TERMINAL_STATUSES, isGoalNeedingAttention } from "./status.js";
2
+ import { threadHealth } from "./thread-health.js";
2
3
 
3
4
  // Cursors belong to observers, not workers. A resumed run gets a new receipt;
4
5
  // old acceptance cannot produce a current-run completion or failure notice.
@@ -8,6 +9,25 @@ export function collectWorkerChanges(tasks, cursor = {}) {
8
9
  const attention = [];
9
10
  for (const task of tasks) {
10
11
  const acceptance = task.acceptance_results?.run === task.run_count ? task.acceptance_results : null;
12
+ const health = threadHealth(task);
13
+ const healthKey = `${task.id}:thread_health`;
14
+ if (cursor[healthKey]) next[healthKey] = cursor[healthKey];
15
+ if (ACTIVE_STATUSES.has(task.status) && health.state === "handoff_recommended") {
16
+ const healthFingerprint = JSON.stringify([task.run_count, health.state]);
17
+ next[healthKey] = healthFingerprint;
18
+ if (cursor[healthKey] !== healthFingerprint) {
19
+ const receipt = {
20
+ id: task.id, title: task.title ?? task.id, run: task.run_count, status: task.status,
21
+ reason: "handoff_recommended", tokens_used: health.tokens_used, threshold: health.threshold,
22
+ next_step: {
23
+ tool: "get_codex_worker_status", arguments: { task_id: task.id },
24
+ instruction: "Inspect the live command and stage. Let this bounded step settle or explicitly cancel it before preparing a reviewed checkpoint and a fresh follow-up; do not launch a duplicate while it is active."
25
+ }
26
+ };
27
+ transitions.push(receipt);
28
+ attention.push(receipt);
29
+ }
30
+ }
11
31
  let reason = null;
12
32
  if (isGoalNeedingAttention(task.goal_status)) reason = `goal_${task.goal_status}`;
13
33
  else if (task.attention_reason) reason = task.attention_reason;