codex-supervisor-mcp 0.9.3 → 0.9.5
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 +2 -1
- package/README.md +2 -1
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +17 -1
- package/src/sandbox-roots.js +46 -10
package/README.en.md
CHANGED
|
@@ -31,6 +31,7 @@ Point several agents at one repository and they overwrite each other, nobody can
|
|
|
31
31
|
| A new session cannot pick up an old worker | `resume_codex_worker` runs `codex exec resume <thread_id>`: the same Codex conversation |
|
|
32
32
|
| "Failed" and "process gone" look alike | The state machine keeps `failed` and `lost` apart |
|
|
33
33
|
| No view of where a batch is | `codex-supervisor-web`, a board that shows every worker by session |
|
|
34
|
+
| Work sits uncommitted or unpushed | Collecting a worker means `land_codex_worker` by default; the main thread commits and pushes its own edits; before deploying, check the remote SHA really contains the files |
|
|
34
35
|
|
|
35
36
|
Workers run `codex exec` with `model` passed through: the main thread stays on Claude, workers can run DeepSeek or any model Codex has a provider for, and the bills stay separate.
|
|
36
37
|
|
|
@@ -198,7 +199,7 @@ Declare externalOutputs:[{path,sha256?}] and acceptance for shared writes. Targe
|
|
|
198
199
|
|
|
199
200
|
workspace-write defaults to networkAccess:false; explicitly enable it for ssh/network checks. Resume/follow-up inherit the setting. maxRunMs bounds one run and maxTotalMs bounds wall time since dispatch; exceeding either stops the worker and preserves actionable partial results without automatic retry. A wait budget does not change these quotas.
|
|
200
201
|
|
|
201
|
-
Besides the worktree and the temp directory the sandbox writes the OS cache directory
|
|
202
|
+
Besides the worktree and the temp directory the sandbox writes the OS cache directory (macOS `~/Library/Caches`, Linux `~/.cache`, Windows `%LOCALAPPDATA%`), the toolchain cache directories that exist under the home directory (`.cargo`, `.npm`, `.yarn`, `.pnpm-store`, `.bun`, `.m2`, `.gradle`, `.nuget`, `.ivy2`, `.bundle`, `.composer`, `.pub-cache`, `.mix`, `.hex`, `.stack`, `.cpanm`, `.deno`, `.conda`, `go/pkg`) Credential directories (`.ssh`, `.gnupg`, `.config`, `.aws`, `.docker`, `.kube`, `.netrc`, `.git-credentials`, `~/Library/Keychains`) are never granted automatically: a dispatch that needs ssh, kubectl, a private registry or a signed commit names the directory in `writableRoots` for that run. `SUPERVISOR_NO_AUTO_CACHE_ROOTS=1` turns every automatic cache root off; an explicit `writableRoots` still applies. Toolchains that cache there, Go's build cache among them, need no per-language variable and no patch when a new language shows up. Codex refuses a writable root with a symlink component, and such a root fails every command in the worker, so both the cache directory and every declared `writableRoots` entry are resolved through realpath first and a root that cannot be resolved to a symlink-free path is dropped. A toolchain that caches elsewhere (`~/.m2`, `~/.gradle`, a vendored mirror) passes `writableRoots:[absolute paths]`: existing directories, at most 20, workspace-write only, inherited by resume/follow-up. Read-only reuse needs nothing.
|
|
202
203
|
|
|
203
204
|
Dispatch checks required hooks/output-schema support (Codex 0.162+); unsupported capability returns settled start_failed. get_worker_goal.native_goal_read distinguishes missing_goal, missing_database, locked and read_error; a read failure is not evidence that no goal exists. Native budget/usage limits need attention. Cleanup preserves ignored artifacts, shared evidence and unresolved attention.
|
|
204
205
|
|
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
| 分不清「跑失败」和「进程没了」 | 状态机把 `failed` 和 `lost` 分开 |
|
|
32
32
|
| worker 说做完了其实没有 | 派单给 `acceptance` 验收命令,worker 退出后 supervisor 在它的 worktree 里跑,失败 `land` 拒绝 |
|
|
33
33
|
| 看不见一批活现在到哪了 | `codex-supervisor-web` 开一个看板,按 session 看每路 worker 在干什么 |
|
|
34
|
+
| 改动留在本地没上线 | 收活默认 `land_codex_worker` 合回主分支;主线程自己的改动必须 commit + push;部署前用远端 SHA 核对文件真的在线上 |
|
|
34
35
|
|
|
35
36
|
worker 跑的是 `codex exec`,`model` 透传:主线程留在 Claude,worker 可以挂 DeepSeek 或任何 Codex 配了 provider 的模型,账单分开算。
|
|
36
37
|
|
|
@@ -198,7 +199,7 @@ context用绝对文件路径与可选sha256声明材料,最多20份、与contr
|
|
|
198
199
|
|
|
199
200
|
workspace-write默认networkAccess:false;需要ssh/联网验证显式true,随resume/followup继承,不以danger-full-access代替。maxRunMs限制单轮、maxTotalMs限制从派单开始的总时长;超限中止worker并保留needs_attention/partial work,不自动重试。wait预算不改变这些quota。
|
|
200
201
|
|
|
201
|
-
|
|
202
|
+
沙箱除工作区和临时目录外,自动放开 OS cache 目录(macOS `~/Library/Caches`、Linux `~/.cache`、Windows `%LOCALAPPDATA%`)、home 下已存在的工具链缓存目录(`.cargo`/`.npm`/`.yarn`/`.pnpm-store`/`.bun`/`.m2`/`.gradle`/`.nuget`/`.ivy2`/`.bundle`/`.composer`/`.pub-cache`/`.mix`/`.hex`/`.stack`/`.cpanm`/`.deno`/`.conda`、`go/pkg`):Go 的 build cache 这类默认落在 cache 目录的工具链直接可用,换语言也不用改 supervisor;**凭据目录一律不自动放开**(`.ssh`/`.gnupg`/`.config`/`.aws`/`.docker`/`.kube`/`.netrc`/`.git-credentials`/`~/Library/Keychains`):ssh 连服务器要写 known_hosts、kubectl、推私有镜像、签名提交这类需求,派单时显式传 `writableRoots`,只在这一路生效。`SUPERVISOR_NO_AUTO_CACHE_ROOTS=1` 关掉全部自动缓存根,显式声明的照常生效。Codex 拒绝带软链的可写根(这种根会让 worker 所有命令都失败),所以 cache 目录和 `writableRoots` 都先按 realpath 解析,解析不出无软链路径的根直接不带。cache 放在别处(`~/.m2`、`~/.gradle`、vendor 镜像)就传 `writableRoots:[绝对路径]`,要求是已存在目录、最多 20 个、只对 workspace-write 生效、随 resume/followup 继承;只读复用就不用传。
|
|
202
203
|
|
|
203
204
|
运行前核验Codex CLI是否具备hooks/output-schema(要求0.162+);能力不足返回start_failed,wait可正常结算。get_worker_goal.native_goal_read区分missing_goal、missing_database、locked和read_error,不能把读取失败当没建goal。原生budget/usage限制也进入needs_attention。cleanup保留ignored artifacts、共享证据和未解决attention。
|
|
204
205
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
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.",
|
|
@@ -24,6 +24,7 @@ description: 把 Codex CLI 当并行 worker 派活、盯进度、收结果。用
|
|
|
24
24
|
| `cwd` | 项目根目录。worker 在自己的 worktree 里干活,不动你的工作区 |
|
|
25
25
|
| `acceptance` | 这一步"做完了"的判据,shell 命令列表,worker 退出后 supervisor 在它的 worktree 里逐条跑,退出码 0 算过,worker 在 prompt 里看得到。任务书里的验证命令原样抄:查那个文件在不在、那个接口通不通、那个测试文件过不过。写能判这一步的,不写全仓回归;远端机器的检查包进 `ssh`。命令用 supervisor 自己的权限跑,等于你自己跑 |
|
|
26
26
|
| `forbid` / `allowedCommands` | 原样声明红线与验证命令;守卫拒绝未声明Shell程序,编辑用apply_patch |
|
|
27
|
+
| `writableRoots` | 只有需要凭据目录时才传(绝对路径、已存在、自动解析软链、只对 workspace-write 生效):ssh/远程测试 → `["~/.ssh"]`;kubectl → `["~/.kube"]`;推私有镜像 → `["~/.docker"]`;aws cli → `["~/.aws"]`;签名提交 → `["~/.gnupg"]`。缓存目录不用写,已经自动加 |
|
|
27
28
|
| `ownedPaths` | 必填。这路允许写的路径,和在跑的 worker 重叠会被拒(**读不排他**,多路读同一份共享文件合法)。冲突是好事,说明该改拆法。传 `[]` 表示这路不落地:只读验证或研究 |
|
|
28
29
|
| `goal.objective` | 必填。一句话说目标,worker 会建成 Codex 原生 goal |
|
|
29
30
|
| `session_id` | 同一批传同一个值。第一路顺手带 `session_title`(30 字内,看板和 `get_session_works` 显示它),漏了用 `describe_session` 补 |
|
|
@@ -65,7 +66,7 @@ check_workers可对已死的第1轮lost/no_work/invalid_report自动resume一次
|
|
|
65
66
|
|
|
66
67
|
远端编译/ssh在workspace-write显式networkAccess:true,默认false,resume/followup继承;不要用danger-full-access代替联网配置。需要时声明maxRunMs/maxTotalMs,超限保留partial work并提示处理,不自动恢复;wait预算与quota分开。
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
沙箱只放工作区、临时目录、OS cache目录(macOS ~/Library/Caches、Linux ~/.cache、Windows %LOCALAPPDATA%)以及home下已存在的工具链缓存目录(.cargo/.npm/.yarn/.pnpm-store/.bun/.m2/.gradle/.nuget/.ivy2/.bundle/.composer/.pub-cache/.mix/.hex/.stack/.cpanm/.deno/.conda、go/pkg):Go 这类默认把build cache写那儿的工具链不用再单独设 GOCACHE,加语言也不用改supervisor;**凭据目录一律不自动放开**(.ssh/.gnupg/.config/.aws/.docker/.kube/.netrc/.git-credentials/~/Library/Keychains):ssh 连服务器要写 known_hosts、kubectl、推私有镜像、签名提交这类需求,派单时按参数表显式传 writableRoots,只在这一路生效、随 resume/followup 继承。SUPERVISOR_NO_AUTO_CACHE_ROOTS=1 关掉全部自动缓存根,显式声明的照常生效。Codex 拒绝含软链的可写根(给了这种根worker连命令都起不来),所以cache目录和writableRoots都会被realpath解析后再交给沙箱;解析不到无软链路径就直接不带这个根。cache在别处(如 ~/.m2、~/.gradle、vendor镜像)就传 `writableRoots:[绝对路径]`(已存在目录、最多20个、只对workspace-write生效、随resume/followup继承);能只读复用就不用传。
|
|
69
70
|
|
|
70
71
|
Codex需0.162+支持hooks/output-schema,能力不够派单start_failed先修CLI。goal查询看native_goal_read,missing与locked/read_error分开;budget/usage限制也要处理。cleanup保留ignored成果、共享证据及未解决attention。
|
|
71
72
|
|
|
@@ -90,6 +91,21 @@ Codex需0.162+支持hooks/output-schema,能力不够派单start_failed先修CL
|
|
|
90
91
|
|
|
91
92
|
高风险的步(迁移、改公共接口、"做完了"写不成命令的)再派一路 verifier:`sandbox: "read-only"`、`ownedPaths: []`,task 只给这一步的目标和原 worker 的 `worktree_path`,不给它的汇报,不说你怀疑什么,让它答"目标达成没有,证据是哪几行"。它不改东西,只读只跑。两路说法对不上,两边都别信,自己看 diff。
|
|
92
93
|
|
|
94
|
+
|
|
95
|
+
## 收工口径:活儿必须落地
|
|
96
|
+
|
|
97
|
+
**"文件写好了"不等于交付。** 本地 worktree / 未提交改动 / 未 push 的 commit,线上都看不到 —— 部署会因为缺类、缺文件、缺 bean 直接挂。派单和主线程自己的改动都按这四条走:
|
|
98
|
+
|
|
99
|
+
1. **worker 的产出默认要合并**:每个终态 worker 走 `get_worker_result` → `get_worker_diff`,过了就 `land_codex_worker`(sandbox 是 workspace-write 的 worker 没提交,带 `commitMessage` 一起提交再落)。不合并必须在报告里写清原因(验收失败 / 越界 / 等审批),不能默认留在 codex/<id> 分支上。
|
|
100
|
+
2. **主线程自己的改动必须 add + commit + push**:`git add <paths> && git commit -m ... && git push`。跳过任何一步都要显式说明,不允许说"改好了"然后留在工作区。
|
|
101
|
+
3. **上线前核对远端,不认本地**:部署或重启服务前先 `git fetch`,再确认目标提交里真有那些改动 —— `git log --oneline origin/<branch> -1`、`git ls-tree -r --name-only origin/<branch> | rg <新文件>`、必要时 `git show origin/<branch>:<path>`。线上报 `NoSuchBeanDefinition`、找不到类/模块、404,先查这一条,再查代码逻辑。
|
|
102
|
+
4. **交付报告三件套**:本地改动 → commit SHA → push 后的远端 SHA(以及部署状态)。缺远端 SHA 就不算完成。
|
|
103
|
+
|
|
104
|
+
典型事故:两个实现类只存在于主线程的 worktree 里,没 add / 没 commit / 没 push,线上跑的还是上一个提交,Spring 找不到 bean 启动失败 —— 不是代码错,是没上线。
|
|
105
|
+
|
|
106
|
+
多 worktree 场景同理:worker 的分支、主线程的改动、集成 worktree 的合并,三者都要各自 push 到远端;只在自己 worktree 里"跑通了"不算。
|
|
107
|
+
|
|
108
|
+
|
|
93
109
|
## 读结果别把上下文撑爆
|
|
94
110
|
|
|
95
111
|
| 想干什么 | 用哪个 |
|
package/src/sandbox-roots.js
CHANGED
|
@@ -2,8 +2,8 @@ import { lstatSync, realpathSync } from "node:fs";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
4
|
|
|
5
|
-
// Codex
|
|
6
|
-
//
|
|
5
|
+
// Codex refuses a writable root that contains a symlink component: the worker
|
|
6
|
+
// does not merely lose that directory, every command in it fails with
|
|
7
7
|
// UnsupportedOperation("writable root ... contains symlink component ...").
|
|
8
8
|
// ~/.cache is a symlink on the machine this was found on, so every candidate is
|
|
9
9
|
// resolved to a symlink-free absolute path before the sandbox sees it, and a
|
|
@@ -34,14 +34,50 @@ export function resolveWritableRoot(candidate) {
|
|
|
34
34
|
return { path: resolved };
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
// Cache locations a build writes to outside the worktree. The OS cache
|
|
38
|
+
// directory covers everything that follows XDG or the platform convention
|
|
39
|
+
// (Go build cache, pip, uv, huggingface, gh, ...). Toolchains that keep their
|
|
40
|
+
// own store under the home directory are listed by directory instead, because
|
|
41
|
+
// naming one environment variable per language stops working the moment a new
|
|
42
|
+
// language shows up: a directory that exists is granted, one that does not is
|
|
43
|
+
// not, and a new toolchain only adds a line here at most.
|
|
44
|
+
export const TOOLCHAIN_CACHE_DIRS = [
|
|
45
|
+
".cargo", // Rust: registry, git checkouts, .package-cache
|
|
46
|
+
".npm", // Node: _cacache, _logs
|
|
47
|
+
".yarn",
|
|
48
|
+
".pnpm-store",
|
|
49
|
+
".bun",
|
|
50
|
+
".m2", // Maven local repository
|
|
51
|
+
".gradle", // Gradle user home
|
|
52
|
+
".nuget", // NuGet global packages
|
|
53
|
+
".ivy2", // sbt / Ivy
|
|
54
|
+
".bundle", // Ruby Bundler
|
|
55
|
+
".composer", // PHP Composer
|
|
56
|
+
".pub-cache", // Dart / Flutter
|
|
57
|
+
".mix", // Elixir
|
|
58
|
+
".hex",
|
|
59
|
+
".stack", // Haskell
|
|
60
|
+
".cpanm", // Perl
|
|
61
|
+
".deno",
|
|
62
|
+
".conda", // conda package cache
|
|
63
|
+
"go/pkg" // Go module cache
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
// Credentials are never granted automatically. A dispatcher that needs them
|
|
67
|
+
// names the directory in writableRoots for that one dispatch: an ssh test wants
|
|
68
|
+
// ~/.ssh (known_hosts, ControlMaster sockets), a kubectl test ~/.kube, a registry
|
|
69
|
+
// push ~/.docker, an aws test ~/.aws, a signed commit ~/.gnupg. Everything here is
|
|
70
|
+
// granted automatically only when it holds build state, not secrets, so a worker
|
|
71
|
+
// steered by injected text cannot persist a key or swap a trust anchor.
|
|
72
|
+
export const EXPLICIT_ONLY_DIRS = [".ssh", ".gnupg", ".config", ".aws", ".docker", ".kube", ".netrc", ".git-credentials", "Library/Keychains"];
|
|
73
|
+
function osCacheCandidates({ env, platform, home }) {
|
|
74
|
+
if (platform === "win32") return [env.LOCALAPPDATA];
|
|
75
|
+
return [env.XDG_CACHE_HOME, platform === "darwin" ? join(home, "Library", "Caches") : null, join(home, ".cache")];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function cacheRoots({ env = process.env, platform = process.platform, home = homedir(), resolveRoot = resolveWritableRoot, includeToolchain = true } = {}) {
|
|
79
|
+
if (/^(1|true|yes)$/i.test((env.SUPERVISOR_NO_AUTO_CACHE_ROOTS ?? "").trim())) return [];
|
|
80
|
+
const candidates = [...osCacheCandidates({ env, platform, home }), ...(includeToolchain ? TOOLCHAIN_CACHE_DIRS.map((dir) => join(home, dir)) : [])];
|
|
45
81
|
const roots = [];
|
|
46
82
|
for (const candidate of candidates) {
|
|
47
83
|
if (!candidate?.trim()) continue;
|