codex-supervisor-mcp 0.12.0 → 0.12.2
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.md +2 -0
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +2 -2
- package/src/codex-runner.js +2 -1
- package/src/prompt.js +3 -1
- package/src/tool-guard.js +16 -0
- package/src/worker-preflight.js +2 -1
package/README.md
CHANGED
|
@@ -223,6 +223,8 @@ wait 默认预算60秒、默认compact;includeEvents会选择详细结果(
|
|
|
223
223
|
|
|
224
224
|
每路临时注入随包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;只读任务不因没改文件判空跑。
|
|
225
225
|
|
|
226
|
+
守卫同时拦截 `create_goal` 的预算:派单未传 `goal.tokenBudget` 时,worker 必须完全省略 `token_budget`;模型自行填写 `0`、`1` 或 `null` 会被拒绝,不会被误当成“不限预算”。显式传预算时只允许逐值一致,缺失或改动都拒绝。原生 goal 仍用于完成状态与 token 用量统计。
|
|
227
|
+
|
|
226
228
|
没有独立 `apply_patch` 工具的模型(实测 Codex 0.162 + DeepSeek/cc-switch)把补丁当 shell 命令发过来:`apply_patch <<'EOF' ... EOF`。守卫认这个形状,用同一套 ownedPaths 规则判每个目标路径,所以这种模型也能改文件;未加引号的 heredoc、后面还接 `&&`/`;` 的都拒绝。
|
|
227
229
|
|
|
228
230
|
`allowedCommands` 里以 `*` 结尾的条目是前缀匹配(如 `go test ./internal/*` 覆盖 `go test ./internal/service -run TestX`),只对没有 shell 元字符的单条命令生效。编辑器 worker 的只读白名单覆盖 grep/sed(无 `-i`)/find(无 `-exec`/`-delete`)/jq(无 `-i`)/awk、git 只读子命令和 `cmd | head|tail|wc|sort|uniq` 纯读管道;`tee`、重定向、`env` 仍拒。守卫不是文件沙箱,漏网的写入只会落在 worker 自己的 worktree,land 会拒。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
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.",
|
|
@@ -32,7 +32,7 @@ worker 默认不是调度员:启动时会禁用它继承到的 `codex-supervis
|
|
|
32
32
|
| `forbid` / `allowedCommands` | 原样声明红线与验证命令;守卫拒绝未声明Shell程序,编辑用apply_patch |
|
|
33
33
|
| `writableRoots` | 只有需要凭据目录时才传(绝对路径、已存在、自动解析软链、只对 workspace-write 生效):ssh/远程测试 → `["~/.ssh"]`;kubectl → `["~/.kube"]`;推私有镜像 → `["~/.docker"]`;aws cli → `["~/.aws"]`;签名提交 → `["~/.gnupg"]`。缓存目录不用写,已经自动加 |
|
|
34
34
|
| `ownedPaths` | 必填。这路允许写的路径,和在跑的 worker 重叠会被拒(**读不排他**,多路读同一份共享文件合法)。冲突是好事,说明该改拆法。传 `[]` 表示这路不落地:只读验证或研究 |
|
|
35
|
-
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal |
|
|
35
|
+
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal;不传 `goal.tokenBudget` 就是不限预算,runtime guard 会拒绝 worker 自填 `token_budget` |
|
|
36
36
|
| `session_id` | 同一批传同一个值。只管批次、默认验收和审批,不是上下文继承边界;第一路顺手带 `session_title`(30 字内,看板和 `get_session_works` 显示它),漏了用 `describe_session` 补 |
|
|
37
37
|
| `dependsOn` | 有先后依赖填上游的 `task_id`,它是硬门禁:上游必须同 `project_root`、成功结算、配置了 acceptance 就已通过、已 `land_codex_worker`,并且本路实际 `baseRef` 包含上游 `landed_head`。没满足先集成/修验收,不会启动下游 |
|
|
38
38
|
| `baseRef` | worktree 从哪个提交切,默认 `HEAD`。第 N+1 步要建立在第 N 步上,填 `codex/<第 N 步 task_id>` |
|
|
@@ -40,7 +40,7 @@ worker 默认不是调度员:启动时会禁用它继承到的 `codex-supervis
|
|
|
40
40
|
|
|
41
41
|
`probeCommands` 会自动加入这次 probe worker 的 guard-only allowlist,不会进入目标 worker 的 runtime contract;目标 worker 仍只声明自己真正需要的 `allowedCommands`。ssh 等联网探针仍要显式 `networkAccess: true`,需要写 `known_hosts` 时同时声明 `writableRoots: ["~/.ssh"]`。
|
|
42
42
|
|
|
43
|
-
预检结论以 probe command evidence 为准,不把模型最终 JSON
|
|
43
|
+
预检结论以 probe command evidence 为准,不把模型最终 JSON 或进程 close handler 当环境事实:所有探针都实际执行且通过、没有失败命令时,最终报告格式错误不会让预检失败;probe-only worker 即使最终变 `lost` 且退出码未记录,也只记诊断,不重跑。命令未执行、非零或取消仍失败。
|
|
44
44
|
| `sandbox` | 默认 `workspace-write`,worker 提交不了(Codex 把 `.git` 设成只读)。要它自己提交就 `danger-full-access`,否则收活时让 supervisor 替它提交 |
|
|
45
45
|
|
|
46
46
|
验收用 Bash 的 `errexit` + `pipefail`:`npm test | tail` 不能吞失败;文件存在只可做附加门禁,不能单独证明业务完成。预期失败用 `if` / `||` 显式判。超时、`no tests to run`、`[no test files]` 都失败,别只看退出码 0。Windows 要有 Git for Windows Bash;缺失先修工具,别换回 cmd。
|
package/src/codex-runner.js
CHANGED
|
@@ -370,6 +370,7 @@ async function trackRunInHost({ record, args, prompt, logPath, spawnOptions = {}
|
|
|
370
370
|
const externalBefore = await captureExternalOutputs(record.guard_policy?.externalOutputs ?? [], { checkBaseline: (record.run_count ?? 0) === 0 });
|
|
371
371
|
const owned = [...findOutsideOwnedChanges(record, []).mapping.map((entry) => entry.worker), ...externalBefore.map((entry) => entry.path)];
|
|
372
372
|
const guardPolicy = { cwd: record.cwd, worktree: record.cwd, sandbox: record.sandbox, ownedPaths: owned, ...(record.guard_policy ?? {}),
|
|
373
|
+
goalTokenBudget: record.goal_token_budget ?? null,
|
|
373
374
|
allowedCommands: [
|
|
374
375
|
...(record.guard_policy?.allowedCommands ?? []),
|
|
375
376
|
...(record.acceptance ?? []).map((check) => typeof check === "string" ? check : check.command),
|
|
@@ -383,7 +384,7 @@ async function trackRunInHost({ record, args, prompt, logPath, spawnOptions = {}
|
|
|
383
384
|
const quoteCommand = (path) => process.platform === "win32" ? `"${path.replace(/"/g, '""')}"` : `'${path.replace(/'/g, "'\\''")}'`;
|
|
384
385
|
const hookCommand = `${quoteCommand(process.execPath)} ${quoteCommand(guard)}`;
|
|
385
386
|
const configArgs = ["--output-schema", workerReportSchemaPath, "--dangerously-bypass-hook-trust", "-c",
|
|
386
|
-
`hooks.PreToolUse=[{matcher="Bash|apply_patch",hooks=[{type="command",command=${JSON.stringify(hookCommand)}}]}]`];
|
|
387
|
+
`hooks.PreToolUse=[{matcher="Bash|apply_patch|create_goal",hooks=[{type="command",command=${JSON.stringify(hookCommand)}}]}]`];
|
|
387
388
|
// A worker may use its explicitly configured business MCP servers, but it
|
|
388
389
|
// must not inherit this supervisor and create a second orchestration tree.
|
|
389
390
|
configArgs.push(...supervisorMcpDisableArgs());
|
package/src/prompt.js
CHANGED
|
@@ -38,7 +38,9 @@ export function buildGoalPreamble({ objective, tokenBudget = null, resume = fals
|
|
|
38
38
|
return [
|
|
39
39
|
"Do this first, before any other work:",
|
|
40
40
|
`Call the create_goal tool with objective exactly "${goal}"${budget}.`,
|
|
41
|
-
tokenBudget
|
|
41
|
+
tokenBudget
|
|
42
|
+
? "Include that token_budget exactly; a missing or different value is denied."
|
|
43
|
+
: "Omit the token_budget field entirely; any value, including 0, 1, or null, is denied.",
|
|
42
44
|
"That goal is how your supervisor tracks this work; do not skip it.",
|
|
43
45
|
'When the objective is achieved and no required work remains, call update_goal with status "complete".',
|
|
44
46
|
'If the same blocker repeats for three consecutive turns and you cannot make progress, call update_goal with status "blocked" instead.'
|
package/src/tool-guard.js
CHANGED
|
@@ -118,6 +118,22 @@ export function evaluateToolUse(event, policy) {
|
|
|
118
118
|
const tool = event.tool_name;
|
|
119
119
|
const input = event.tool_input;
|
|
120
120
|
const command = typeof input === "string" ? input : input?.command;
|
|
121
|
+
if (tool === "create_goal") {
|
|
122
|
+
const configured = policy.goalTokenBudget ?? null;
|
|
123
|
+
const supplied = input && typeof input === "object" && Object.hasOwn(input, "token_budget")
|
|
124
|
+
? input.token_budget
|
|
125
|
+
: undefined;
|
|
126
|
+
if (configured === null) {
|
|
127
|
+
if (supplied !== undefined) {
|
|
128
|
+
return deny("the dispatcher did not set a goal token budget; omit token_budget entirely (0, 1, and null are not unlimited)");
|
|
129
|
+
}
|
|
130
|
+
return { allow: true, reason: "goal created without a token budget" };
|
|
131
|
+
}
|
|
132
|
+
if (supplied !== configured) {
|
|
133
|
+
return deny(`the dispatcher set goal token_budget to ${configured}; create_goal must include exactly that value`);
|
|
134
|
+
}
|
|
135
|
+
return { allow: true, reason: `goal uses the dispatcher's token budget ${configured}` };
|
|
136
|
+
}
|
|
121
137
|
if (tool === "Bash") {
|
|
122
138
|
if (typeof command !== "string") return deny("invalid shell input");
|
|
123
139
|
const normalized = command.replace(/\\\r?\n/g, "").replace(/\s+/g, " ").trim();
|
package/src/worker-preflight.js
CHANGED
|
@@ -122,7 +122,8 @@ export function readPreflightResult(task) {
|
|
|
122
122
|
const probesPassed = probes.every((probe) => probe.passed);
|
|
123
123
|
const exitConfirmed = task.status === "completed" && task.exit_code === 0;
|
|
124
124
|
const reportWasInvalid = task.attention_reason === "invalid_report";
|
|
125
|
-
const
|
|
125
|
+
const probesProveEnvironment = probesPassed && failedCommands.length === 0;
|
|
126
|
+
const exitWasLost = task.status === "lost" && probesProveEnvironment;
|
|
126
127
|
// A preflight proves the worker environment through its command evidence.
|
|
127
128
|
// Its own final report and close-handler completion are useful diagnostics,
|
|
128
129
|
// but neither changes what those commands already proved. A completed turn
|