codex-supervisor-mcp 0.9.2 → 0.9.3
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 +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/skills/codex-supervisor/SKILL.md +1 -1
- package/src/codex-runner.js +10 -4
- package/src/sandbox-roots.js +47 -12
package/README.en.md
CHANGED
|
@@ -198,7 +198,7 @@ Declare externalOutputs:[{path,sha256?}] and acceptance for shared writes. Targe
|
|
|
198
198
|
|
|
199
199
|
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
200
|
|
|
201
|
-
Besides the worktree and the temp directory the sandbox writes the OS cache directory only (macOS `~/Library/Caches`, Linux `~/.cache`, Windows `%LOCALAPPDATA%`). Toolchains that cache there, Go's build cache among them, need no per-language variable and no patch when a new language shows up. 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.
|
|
201
|
+
Besides the worktree and the temp directory the sandbox writes the OS cache directory only (macOS `~/Library/Caches`, Linux `~/.cache`, Windows `%LOCALAPPDATA%`). 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
202
|
|
|
203
203
|
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
204
|
|
package/README.md
CHANGED
|
@@ -198,7 +198,7 @@ context用绝对文件路径与可选sha256声明材料,最多20份、与contr
|
|
|
198
198
|
|
|
199
199
|
workspace-write默认networkAccess:false;需要ssh/联网验证显式true,随resume/followup继承,不以danger-full-access代替。maxRunMs限制单轮、maxTotalMs限制从派单开始的总时长;超限中止worker并保留needs_attention/partial work,不自动重试。wait预算不改变这些quota。
|
|
200
200
|
|
|
201
|
-
沙箱除工作区和临时目录外,只再放开 OS cache 目录(macOS `~/Library/Caches`、Linux `~/.cache`、Windows `%LOCALAPPDATA%`):Go 的 build cache 这类默认落在 cache 目录的工具链直接可用,换语言也不用改 supervisor。cache 放在别处(`~/.m2`、`~/.gradle`、vendor 镜像)就传 `writableRoots:[绝对路径]`,要求是已存在目录、最多 20 个、只对 workspace-write 生效、随 resume/followup 继承;只读复用就不用传。
|
|
201
|
+
沙箱除工作区和临时目录外,只再放开 OS cache 目录(macOS `~/Library/Caches`、Linux `~/.cache`、Windows `%LOCALAPPDATA%`):Go 的 build cache 这类默认落在 cache 目录的工具链直接可用,换语言也不用改 supervisor。Codex 拒绝带软链的可写根(这种根会让 worker 所有命令都失败),所以 cache 目录和 `writableRoots` 都先按 realpath 解析,解析不出无软链路径的根直接不带。cache 放在别处(`~/.m2`、`~/.gradle`、vendor 镜像)就传 `writableRoots:[绝对路径]`,要求是已存在目录、最多 20 个、只对 workspace-write 生效、随 resume/followup 继承;只读复用就不用传。
|
|
202
202
|
|
|
203
203
|
运行前核验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
204
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-supervisor-mcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
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.",
|
|
@@ -65,7 +65,7 @@ check_workers可对已死的第1轮lost/no_work/invalid_report自动resume一次
|
|
|
65
65
|
|
|
66
66
|
远端编译/ssh在workspace-write显式networkAccess:true,默认false,resume/followup继承;不要用danger-full-access代替联网配置。需要时声明maxRunMs/maxTotalMs,超限保留partial work并提示处理,不自动恢复;wait预算与quota分开。
|
|
67
67
|
|
|
68
|
-
沙箱只放工作区、临时目录和OS cache目录(macOS ~/Library/Caches、Linux ~/.cache、Windows %LOCALAPPDATA%):Go 这类默认把build cache写那儿的工具链不用再单独设 GOCACHE,加语言也不用改supervisor。cache在别处(如 ~/.m2、~/.gradle、vendor镜像)就传 `writableRoots:[绝对路径]`(已存在目录、最多20个、只对workspace-write生效、随resume/followup继承);能只读复用就不用传。
|
|
68
|
+
沙箱只放工作区、临时目录和OS cache目录(macOS ~/Library/Caches、Linux ~/.cache、Windows %LOCALAPPDATA%):Go 这类默认把build cache写那儿的工具链不用再单独设 GOCACHE,加语言也不用改supervisor。Codex 拒绝含软链的可写根(给了这种根worker连命令都起不来),所以cache目录和writableRoots都会被realpath解析后再交给沙箱;解析不到无软链路径就直接不带这个根。cache在别处(如 ~/.m2、~/.gradle、vendor镜像)就传 `writableRoots:[绝对路径]`(已存在目录、最多20个、只对workspace-write生效、随resume/followup继承);能只读复用就不用传。
|
|
69
69
|
|
|
70
70
|
Codex需0.162+支持hooks/output-schema,能力不够派单start_failed先修CLI。goal查询看native_goal_read,missing与locked/read_error分开;budget/usage限制也要处理。cleanup保留ignored成果、共享证据及未解决attention。
|
|
71
71
|
|
package/src/codex-runner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createWriteStream, existsSync
|
|
1
|
+
import { createWriteStream, existsSync } from "node:fs";
|
|
2
2
|
import { mkdir, rm, stat } from "node:fs/promises";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { execFileSync, spawn } from "node:child_process";
|
|
@@ -23,7 +23,7 @@ import { applyCodexEvent } from "./event-parser.js";
|
|
|
23
23
|
import { ACTIVE_STATUSES, TERMINAL_STATUSES } from "./status.js";
|
|
24
24
|
import { worktreesDir } from "./paths.js";
|
|
25
25
|
import { buildGuardPreamble, frameWorkerPrompt } from "./prompt.js";
|
|
26
|
-
import { cacheRoots } from "./sandbox-roots.js";
|
|
26
|
+
import { cacheRoots, resolveWritableRoot } from "./sandbox-roots.js";
|
|
27
27
|
import { readTaskChanges, snapshotTaskOutput } from "./worktree.js";
|
|
28
28
|
import { rebaseWorktree } from "./landing.js";
|
|
29
29
|
import { DEFAULT_ACCEPTANCE_TIMEOUT_MS, normalizeAcceptance, runAcceptance } from "./acceptance.js";
|
|
@@ -624,8 +624,14 @@ export async function createCodexWorker({
|
|
|
624
624
|
throw new Error("writableRoots must be a list of at most 20 absolute paths");
|
|
625
625
|
}
|
|
626
626
|
if (writableRoots.length && sandbox !== "workspace-write") throw new Error("writableRoots is only configurable for workspace-write workers");
|
|
627
|
+
// Codex refuses a writable root with a symlink component and then fails every
|
|
628
|
+
// command in the worker, so a declared root is stored resolved. Passing the
|
|
629
|
+
// alias would look fine in the receipt and break the run.
|
|
630
|
+
const resolvedWritableRoots = [];
|
|
627
631
|
for (const root of writableRoots) {
|
|
628
|
-
|
|
632
|
+
const resolved = resolveWritableRoot(root);
|
|
633
|
+
if (resolved.error) throw new Error(`writableRoots entry is unusable: ${root} (${resolved.error}); pass an existing directory whose path has no symlink component`);
|
|
634
|
+
resolvedWritableRoots.push(resolved.path);
|
|
629
635
|
}
|
|
630
636
|
for (const value of [maxRunMs, maxTotalMs]) if (value !== null && (!Number.isInteger(value) || value < 1000)) throw new Error("time limits must be integer milliseconds of at least 1000");
|
|
631
637
|
for (const [name, values] of Object.entries({ forbid, allowedCommands })) {
|
|
@@ -673,7 +679,7 @@ export async function createCodexWorker({
|
|
|
673
679
|
session_id: sessionId ?? null,
|
|
674
680
|
thread_id: null,
|
|
675
681
|
owned_paths: normalizedOwnedPaths,
|
|
676
|
-
guard_policy: { forbid, allowedCommands, externalOutputs, networkAccess, writableRoots, maxRunMs, maxTotalMs },
|
|
682
|
+
guard_policy: { forbid, allowedCommands, externalOutputs, networkAccess, writableRoots: [...new Set(resolvedWritableRoots)], maxRunMs, maxTotalMs },
|
|
677
683
|
input_context: { context, contracts },
|
|
678
684
|
depends_on: Array.isArray(dependsOn) ? dependsOn : [],
|
|
679
685
|
goal_objective: validatedGoal.objective,
|
package/src/sandbox-roots.js
CHANGED
|
@@ -1,18 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lstatSync, realpathSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
export function
|
|
5
|
+
// Codex 0.162 refuses a writable root that contains a symlink component: the
|
|
6
|
+
// worker does not merely lose that directory, every command in it fails with
|
|
7
|
+
// UnsupportedOperation("writable root ... contains symlink component ...").
|
|
8
|
+
// ~/.cache is a symlink on the machine this was found on, so every candidate is
|
|
9
|
+
// resolved to a symlink-free absolute path before the sandbox sees it, and a
|
|
10
|
+
// candidate that cannot be resolved that way is dropped instead of poisoning
|
|
11
|
+
// the whole run. allow_symlinked_codex_home does not help here: it only covers
|
|
12
|
+
// writable roots under CODEX_HOME.
|
|
13
|
+
export function symlinkComponents(target) {
|
|
14
|
+
const links = [];
|
|
15
|
+
let current = resolve(target);
|
|
16
|
+
for (;;) {
|
|
17
|
+
try { if (lstatSync(current).isSymbolicLink()) links.push(current); }
|
|
18
|
+
catch { /* a missing component is reported by the caller */ }
|
|
19
|
+
const parent = dirname(current);
|
|
20
|
+
if (parent === current) break;
|
|
21
|
+
current = parent;
|
|
22
|
+
}
|
|
23
|
+
return links;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resolveWritableRoot(candidate) {
|
|
27
|
+
if (typeof candidate !== "string" || !candidate.trim()) return { error: "empty path" };
|
|
28
|
+
if (!isAbsolute(candidate)) return { error: "not an absolute path" };
|
|
29
|
+
let resolved;
|
|
30
|
+
try { resolved = realpathSync(candidate.trim()); } catch { return { error: "does not exist" }; }
|
|
31
|
+
try { if (!lstatSync(resolved).isDirectory()) return { error: "not a directory" }; } catch { return { error: "not a directory" }; }
|
|
32
|
+
const links = symlinkComponents(resolved);
|
|
33
|
+
if (links.length) return { error: "resolved path still contains a symlink component: " + links.join(", ") };
|
|
34
|
+
return { path: resolved };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// The OS cache directory is where default build caches live on every platform:
|
|
38
|
+
// macOS ~/Library/Caches, Linux/XDG ~/.cache, Windows %LOCALAPPDATA%. It is
|
|
39
|
+
// offered to the sandbox as one generic root, so a new language needs no new
|
|
40
|
+
// environment variable and no patch.
|
|
41
|
+
export function cacheRoots({ env = process.env, platform = process.platform, home = homedir(), resolveRoot = resolveWritableRoot } = {}) {
|
|
14
42
|
const candidates = platform === "win32"
|
|
15
43
|
? [env.LOCALAPPDATA]
|
|
16
44
|
: [env.XDG_CACHE_HOME, platform === "darwin" ? join(home, "Library", "Caches") : null, join(home, ".cache")];
|
|
17
|
-
|
|
45
|
+
const roots = [];
|
|
46
|
+
for (const candidate of candidates) {
|
|
47
|
+
if (!candidate?.trim()) continue;
|
|
48
|
+
const resolved = resolveRoot(candidate.trim());
|
|
49
|
+
if (resolved?.path) roots.push(resolved.path);
|
|
50
|
+
}
|
|
51
|
+
return [...new Set(roots)];
|
|
18
52
|
}
|
|
53
|
+
|