codex-supervisor-mcp 0.5.6 → 0.5.8
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 +214 -257
- package/README.md +211 -254
- package/package.json +14 -4
- package/skills/codex-supervisor/SKILL.md +14 -3
- package/src/codex-runner.js +11 -0
- package/src/mcp-server.js +103 -9
- package/src/task-store.js +57 -1
- package/src/update-check.js +206 -0
- package/src/web-server.js +302 -0
- package/src/worktree.js +13 -1
- package/web/dist/assets/index-DPTvsjxI.js +85 -0
- package/web/dist/assets/index-DnCjDsN6.css +2 -0
- package/web/dist/index.html +15 -0
package/README.en.md
CHANGED
|
@@ -8,287 +8,206 @@ English | [中文](README.md)
|
|
|
8
8
|
[](https://github.com/zriyox/codex-supervisor-mcp/actions/workflows/ci.yml)
|
|
9
9
|
[](package.json)
|
|
10
10
|
|
|
11
|
-
Let one main thread (Claude Code, Codex, any MCP client) run several Codex workers at once.
|
|
11
|
+
Let one main thread (Claude Code, Codex, or any MCP client) run several Codex workers at once. One Git worktree per worker, every state change on disk, and a web board to watch the batch.
|
|
12
12
|
|
|
13
|
-

|
|
14
14
|
|
|
15
|
-
*30 seconds, recorded live
|
|
15
|
+
*30 seconds, recorded live: the main thread calls `create_codex_worker` three times, the workers run in parallel in their own worktrees, the main thread collects three diffs and makes one commit.*
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## What it is
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Point several agents at one repository and they overwrite each other, and nobody can say afterwards who changed what. This MCP takes dispatching and bookkeeping out of the model's context and puts them on disk:
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
| Problem | How it's handled |
|
|
21
|
+
| Problem | What happens here |
|
|
24
22
|
|---|---|
|
|
25
|
-
| Workers
|
|
26
|
-
|
|
|
27
|
-
| One read
|
|
28
|
-
|
|
|
29
|
-
| A new session
|
|
30
|
-
| "It failed" and "the process
|
|
31
|
-
|
|
32
|
-
## How is this different from Claude Code subagents?
|
|
23
|
+
| Workers step on each other's files | One Git worktree per worker; `ownedPaths` is checked for overlap before anything starts |
|
|
24
|
+
| A worker's output floods the main thread | Events go to `data/runs/<taskId>.jsonl`; reads have `limit` / `maxChars` / `kinds` gates |
|
|
25
|
+
| One status read fills the context | `get_orchestration_overview` fits every worker into 7000 bytes |
|
|
26
|
+
| Nobody knows who is still running after a restart | `supervisor.sqlite` has one row per work, with the `thread_id` |
|
|
27
|
+
| A new session cannot pick up an old worker | `resume_codex_worker` runs `codex exec resume <thread_id>`, the same Codex conversation |
|
|
28
|
+
| "It failed" and "the process vanished" look alike | The state machine keeps `failed` and `lost` apart |
|
|
29
|
+
| You cannot see where a batch is | `codex-supervisor-web` opens a board, one session at a time, one line per worker |
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
Workers are `codex exec` processes and `model` is passed straight through. The main thread stays on Claude for judgement; the workers can run DeepSeek or whatever Codex has a provider for, on a separate bill.
|
|
35
32
|
|
|
36
|
-
|
|
33
|
+
## Five minutes to a running batch
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| | Claude Code subagent | codex-supervisor worker |
|
|
41
|
-
|---|---|---|
|
|
42
|
-
| Models it can run | Claude only: an alias or a full Claude model ID | `model` goes to the Codex CLI, so DeepSeek works |
|
|
43
|
-
| What does the work | Claude Code itself | A separate `codex exec` process |
|
|
44
|
-
| Working directory | Shared with the main thread by default, or `isolation: worktree` | One Git worktree per worker |
|
|
45
|
-
| Two workers writing the same file | Separated by worktrees, with no declared paths and no conflict check | `ownedPaths` is intersected before dispatch; on overlap no worktree is created and you get `ownership_conflict` |
|
|
46
|
-
| Main thread context | Subagent results come back into it | Events go to `data/runs/<taskId>.jsonl`; the overview runs on a hard 7000-byte budget (`src/mcp-server.js:32`) |
|
|
47
|
-
| Main thread process dies | Workers die with it | `thread_id` is in sqlite; `resume_codex_worker` reattaches the same session |
|
|
48
|
-
| What can drive it | Claude Code only | Any MCP client |
|
|
49
|
-
| Watching a worker work | Only the conclusion it returns | Raw JSONL, read through `kinds` / `limit` / `maxChars` |
|
|
35
|
+
Requirements: Node.js 22.13.0 or newer, and the `codex` CLI on `PATH`. macOS, Linux and Windows.
|
|
50
36
|
|
|
51
|
-
|
|
37
|
+
### 1. Install
|
|
52
38
|
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
│ stdio (MCP)
|
|
56
|
-
▼
|
|
57
|
-
codex-supervisor-mcp
|
|
58
|
-
│ spawn: codex exec --json
|
|
59
|
-
▼
|
|
60
|
-
Codex worker ──► data/runs/<taskId>.jsonl raw JSONL event stream
|
|
61
|
-
──► supervisor.sqlite tasks + task_events
|
|
62
|
-
──► worktrees/<taskId>/ the worker's own Git worktree
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g codex-supervisor-mcp
|
|
63
41
|
```
|
|
64
42
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Requirements: **Node.js >= 22.13.0** (`node:sqlite` had no unflagged build before that) and the `codex` CLI on `PATH`. macOS, Linux, and Windows are all supported.
|
|
68
|
-
|
|
69
|
-
### Quick start
|
|
43
|
+
A global install's `postinstall` does two things: it copies the bundled skill into `~/.claude/skills/`, `~/.agents/skills/` and `~/.codex/skills/`, and it registers the MCP with `claude mcp add -s user` and `codex mcp add`. Check:
|
|
70
44
|
|
|
71
45
|
```bash
|
|
72
|
-
# 1. install
|
|
73
|
-
npm install -g codex-supervisor-mcp
|
|
74
|
-
|
|
75
|
-
# 2. confirm it registered
|
|
76
46
|
claude mcp list | grep codex-supervisor
|
|
77
47
|
codex mcp list | grep codex-supervisor
|
|
78
48
|
```
|
|
79
49
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
1. Copies the bundled skill into whichever client directories it finds: `~/.claude/skills/`, `~/.agents/skills/`, `~/.codex/skills/`.
|
|
83
|
-
2. Registers the MCP server through the client's own CLI: `claude mcp add -s user` / `codex mcp add`, pointing at `node <absolute path inside the package>`.
|
|
84
|
-
|
|
85
|
-
If a skill already exists with different content, it writes `SKILL.md.bak-<timestamp>` first and then overwrites. A failure in either step does not fail the install.
|
|
86
|
-
|
|
87
|
-
### Registering by hand
|
|
88
|
-
|
|
89
|
-
When `postinstall` doesn't run (`--ignore-scripts`, `npx`, pnpm, and similar), add the line yourself:
|
|
90
|
-
|
|
91
|
-
| Client | Command |
|
|
92
|
-
|---|---|
|
|
93
|
-
| Claude Code | `claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp` |
|
|
94
|
-
| Codex | `codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp` |
|
|
95
|
-
|
|
96
|
-
To re-run it, repair it, target one client only, or just see what it plans to do:
|
|
50
|
+
If it is missing (`npx`, `--ignore-scripts` and pnpm installs skip `postinstall`), add it by hand:
|
|
97
51
|
|
|
98
52
|
```bash
|
|
99
|
-
codex-supervisor
|
|
100
|
-
codex-supervisor
|
|
101
|
-
codex-supervisor-setup --skill-only # skill only, leave MCP config alone
|
|
102
|
-
codex-supervisor-setup --mcp-only # register MCP only, no skill
|
|
103
|
-
codex-supervisor-setup --dry-run # print the plan, change nothing
|
|
53
|
+
claude mcp add -s user codex-supervisor -- npx -y codex-supervisor-mcp
|
|
54
|
+
codex mcp add codex-supervisor -- npx -y codex-supervisor-mcp
|
|
104
55
|
```
|
|
105
56
|
|
|
106
|
-
|
|
57
|
+
Restart Claude Code / Codex so the MCP process is the new one.
|
|
107
58
|
|
|
108
|
-
|
|
59
|
+
### 2. Dispatch a batch
|
|
109
60
|
|
|
110
|
-
|
|
111
|
-
{
|
|
112
|
-
"mcpServers": {
|
|
113
|
-
"codex-supervisor": {
|
|
114
|
-
"command": "npx",
|
|
115
|
-
"args": ["-y", "codex-supervisor-mcp"]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
```
|
|
61
|
+
In Claude Code, say it in plain words; the skill makes it follow the right sequence:
|
|
120
62
|
|
|
121
|
-
|
|
122
|
-
|---|---|---|---|
|
|
123
|
-
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | `%APPDATA%\Claude\claude_desktop_config.json` | `~/.config/Claude/claude_desktop_config.json` |
|
|
124
|
-
| Cursor | `~/.cursor/mcp.json` | `%APPDATA%\Cursor\mcp.json` | `~/.config/cursor/mcp.json` |
|
|
125
|
-
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `%APPDATA%\Codeium\windsurf\mcp_config.json` | `~/.config/.codeium/windsurf/mcp_config.json` |
|
|
126
|
-
|
|
127
|
-
### The npx gotcha
|
|
63
|
+
> Fill in the unit tests for these three modules. Use codex-supervisor, three workers in parallel, session title "unit tests".
|
|
128
64
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
### Upgrading
|
|
65
|
+
What the main thread does underneath (you can call the tools yourself):
|
|
132
66
|
|
|
133
|
-
```bash
|
|
134
|
-
npm install -g codex-supervisor-mcp@latest
|
|
135
|
-
npm ls -g --depth=0 | grep codex-supervisor # confirm the version actually changed
|
|
136
67
|
```
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
Three known traps:
|
|
141
|
-
|
|
142
|
-
- **A freshly published version lags a few minutes behind the registry's `latest`.** If the version number didn't move, wait and reinstall, or pin it: `npm install -g codex-supervisor-mcp@0.5.3`.
|
|
143
|
-
- **`npm link` / `npm i -g .` produce a symlink.** Editing `src/` takes effect immediately, but editing `skills/SKILL.md` does not sync on its own; run `codex-supervisor-setup` once. To go back to a normal install, `npm install -g codex-supervisor-mcp@latest` overwrites the symlink.
|
|
144
|
-
- **Switching Node versions breaks the registration.** What gets registered is an absolute path (`~/.nvm/versions/node/<version>/lib/node_modules/...`), and `postinstall` sees "already registered" and skips, so the path is never rewritten. Remove it first, then install:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
claude mcp remove -s user codex-supervisor
|
|
148
|
-
codex mcp remove codex-supervisor
|
|
149
|
-
npm install -g codex-supervisor-mcp@latest
|
|
68
|
+
create_codex_worker ×3 each with session_id, session_title, ownedPaths, goal
|
|
69
|
+
wait_codex_workers two-minute budget by default; returns a snapshot, call again if still running
|
|
70
|
+
get_worker_result ×3 the full report and change list per worker
|
|
150
71
|
```
|
|
151
72
|
|
|
152
|
-
|
|
73
|
+
Each worker's changes sit on its own `codex/<taskId>` branch. Whether and how to merge is the main thread's call.
|
|
153
74
|
|
|
154
|
-
###
|
|
75
|
+
### 3. Open the board
|
|
155
76
|
|
|
156
77
|
```bash
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
codex
|
|
160
|
-
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor
|
|
161
|
-
rm -rf ~/.codex-supervisor # state directory: sqlite, event streams, worktrees
|
|
78
|
+
codex-supervisor-web
|
|
79
|
+
# without a global install:
|
|
80
|
+
npx -p codex-supervisor-mcp codex-supervisor-web
|
|
162
81
|
```
|
|
163
82
|
|
|
164
|
-
|
|
83
|
+
Open `http://127.0.0.1:7877`. The left column lists sessions with the title given at dispatch and how many workers are still running; a session opens into its worker ledger; a worker opens a drawer with its full report, change list, commands, event stream, task text and token usage. It refreshes every 2.5 seconds while something runs, every 8 seconds otherwise.
|
|
165
84
|
|
|
166
|
-
|
|
167
|
-
- Cross-process cancel uses `taskkill /PID <pid> /T /F` to take down the whole tree. Confirming that pid is still Codex reads its command line through PowerShell's `Get-CimInstance Win32_Process`, falling back to `tasklist`. `ps` is only used on macOS and Linux.
|
|
168
|
-
- Besides `PATH`, it probes `%APPDATA%\npm`, `%LOCALAPPDATA%\pnpm`, `%LOCALAPPDATA%\Volta\bin`, and `%ProgramFiles%\nodejs`.
|
|
85
|
+
`SUPERVISOR_WEB_PORT` changes the port; `SUPERVISOR_HOME` points it at a state directory (it has to be the one the MCP uses). The board reads. It does not dispatch or cancel.
|
|
169
86
|
|
|
170
|
-
|
|
87
|
+
## What the board shows
|
|
171
88
|
|
|
172
|
-
|
|
89
|
+
| Where | What |
|
|
90
|
+
|---|---|
|
|
91
|
+
| Left column | One line per session: title (the `session_title` from dispatch, or a line built from the workers' goals when none was given), worker count, how many are running, last activity. The current version and any update notice sit at the bottom |
|
|
92
|
+
| Session page | Title, note, first dispatch and last activity; a count line (total / running / completed / failed / lost); while workers run, the command each one is executing; when idle, the last report |
|
|
93
|
+
| Worker ledger | One row per worker: status, title, the running command or the last line reported, time taken, files changed (the worktree's real diff, committed work included), commands run, last update. Hovering the title shows the full goal, the owned paths and the branch |
|
|
94
|
+
| Worker drawer | Duration / exit code / run count; model, tokens, sandbox, thread, session; branch, base commit, worktree path; Codex startup notices folded away; five tabs: report (rendered markdown), changes, commands, events (virtualized), task text |
|
|
173
95
|
|
|
174
|
-
|
|
175
|
-
|---|---|---|
|
|
176
|
-
| `claude mcp list` has no `codex-supervisor` | `npx` / `--ignore-scripts` installs don't run `postinstall` | Run `codex-supervisor-setup`, or register by hand above |
|
|
177
|
-
| Dispatch fails with `codex only resolved to a shell shim` | On Windows only the `.cmd` was found and the npm package entry point behind it is gone | Reinstall `@openai/codex`, or point `CODEX_BIN` at the real executable / `codex.js` |
|
|
178
|
-
| A worker goes `failed` immediately with `spawn codex ENOENT` | The process started by a GUI client has no `codex` on `PATH` | Set `CODEX_BIN` explicitly in the client config |
|
|
179
|
-
| `Cannot find module 'node:sqlite'` | Node < 22.13.0 | Upgrade Node |
|
|
180
|
-
| A worker is stuck in `lost` | The MCP process was killed and the worker was orphaned | Let `list_codex_workers` settle it, or pick it back up with `resume_codex_worker` |
|
|
181
|
-
| `ownedPaths overlap with active worker(s)` | Two workers claimed the same path | Change the path, or `cancel_codex_worker` whichever is holding it |
|
|
96
|
+
Light and dark follow the system. System fonts only, nothing fetched from the network.
|
|
182
97
|
|
|
183
98
|
## Tools
|
|
184
99
|
|
|
185
|
-
|
|
100
|
+
Sixteen.
|
|
186
101
|
|
|
187
102
|
| Tool | Arguments | What it does |
|
|
188
103
|
|---|---|---|
|
|
189
|
-
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `baseRef` picks the commit the worktree is cut from (default: the repository's `HEAD`)
|
|
190
|
-
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, plus the
|
|
191
|
-
| `resume_codex_worker` | `task_id`, `prompt` | Continue the
|
|
192
|
-
| `
|
|
193
|
-
| `get_orchestration_overview` | `status`, `limit` |
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `get_session_works` | `session_id` | Every worker
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
`
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
104
|
+
| `create_codex_worker` | `task`, `cwd`, **`ownedPaths`**, **`goal`**, `session_id`, `session_title`, `session_note`, `dependsOn`, `baseRef`, `sandbox`, `model`, `reasoningEffort`, `title`, `skipGitRepoCheck` | Start a worker. `session_title` / `session_note` say what the batch is for; `baseRef` picks the commit the worktree is cut from (default: the repository's `HEAD`), pass another worker's `codex/<id>` branch to build on work not yet on the main line |
|
|
105
|
+
| `create_codex_followup_worker` | `task_id`, `followup_prompt`, `session_id`, plus the above | A new session seeded with the old worker's prompt, status and recent events |
|
|
106
|
+
| `resume_codex_worker` | `task_id`, `prompt` | Continue the same Codex conversation; `thread_id` stays |
|
|
107
|
+
| `wait_codex_workers` | `task_ids`, `mode` (any/all), `timeoutMinutes`, `timeoutMs`, `includeEvents`, `eventLimit`, `eventMaxChars`, `eventKinds` | Wait for terminal states. Two minutes by default, then a snapshot; `still_running: true` means call again with the same ids. Events off by default |
|
|
108
|
+
| `get_orchestration_overview` | `status`, `limit` | Every worker in one table, capped at 7000 bytes. Carries `version` and `update` |
|
|
109
|
+
| `get_worker_result` | `task_id`, `limit`, `maxChars` | The worker's own full report plus `status` / `exit_code` / `changed_files`. The door for conclusions |
|
|
110
|
+
| `get_worker_summary` | `task_id` | One paragraph: goal, status, changes, last command and message |
|
|
111
|
+
| `get_codex_worker_status` | `task_id`, `includePrompt`, `promptMaxChars` | One worker in detail; the prompt is clipped to 300 characters unless asked for |
|
|
112
|
+
| `get_codex_worker_events` | `task_id`, `limit`, `maxChars`, `kinds` | The raw event stream |
|
|
113
|
+
| `get_worker_goal` | `task_id` | The goal recorded at dispatch plus the native Codex goal (tokens, time) |
|
|
114
|
+
| `list_codex_workers` | `status`, `includeHistory`, `includeDetails` | List workers, active ones by default |
|
|
115
|
+
| `get_session_works` | `session_id` | Every worker of one session, with its title and note. The way back after a main-thread restart |
|
|
116
|
+
| `describe_session` | `session_id`, `title`, `note` | Record a title and note; fields left out keep their value |
|
|
117
|
+
| `search_works` | `query`, `limit` | Substring search over title / goal / prompt / last_message, newest first |
|
|
118
|
+
| `check_for_update` | `force` | Ask the registry for a newer version and whether the installed files match the published tarball |
|
|
119
|
+
| `cancel_codex_worker` | `task_id` | Stop a worker. Falls back to the pid when the handle is in another process, after confirming that pid runs codex |
|
|
120
|
+
|
|
121
|
+
### The three things to always pass
|
|
122
|
+
|
|
123
|
+
- `ownedPaths`: the paths this worker may write. Checked against every running worker before dispatch; an overlap refuses the call with the conflicting `task_id` and no worktree is created. It is a dispatch-time check, not a runtime sandbox.
|
|
124
|
+
- `goal.objective`: one line on what the worker is for. The worker creates a native Codex goal from it and marks it complete when done.
|
|
125
|
+
- `session_id`: not required by the schema, but without it nothing groups the batch and neither the board nor `get_session_works` can find it again. Same value for the whole batch, and `session_title` on the first dispatch.
|
|
126
|
+
|
|
127
|
+
### Reading results without filling the context
|
|
128
|
+
|
|
129
|
+
| Want | Use | Cost |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| Status of every worker | `get_orchestration_overview` | 7000 bytes, hard cap |
|
|
132
|
+
| One worker's conclusion | `get_worker_result` | The full report, tens of thousands of characters for a big job |
|
|
133
|
+
| Alive or finished | `get_worker_summary` | A paragraph |
|
|
134
|
+
| What it did | `get_codex_worker_events` | Filter with `kinds`, bound with `limit`, clip with `maxChars` |
|
|
214
135
|
|
|
215
|
-
|
|
216
|
-
|---|---|
|
|
217
|
-
| `limit` | At most this many events |
|
|
218
|
-
| `maxChars` | Long strings inside a single event are truncated in the middle, keeping head and tail |
|
|
219
|
-
| `kinds` | Only these event types; the filter runs before `limit` is applied |
|
|
136
|
+
The dispatch receipt is small and does not echo the task text. `wait_codex_workers` clips `last_message` to 400 characters and `current_action` to 300; the full text is behind `get_worker_result` and `get_codex_worker_events`. That clipping is what takes a five-worker wait from tens of KB to a few KB, which matters when a client backgrounds a timed-out call and replays the result as a notification.
|
|
220
137
|
|
|
221
|
-
|
|
138
|
+
## How this differs from Claude Code subagents
|
|
222
139
|
|
|
223
|
-
|
|
224
|
-
Warning: truncated output (original token count: N)
|
|
225
|
-
Total output lines: M
|
|
226
|
-
```
|
|
140
|
+
File isolation is not the difference: subagents can open their own worktree (`isolation: worktree`). The difference is the model and the process.
|
|
227
141
|
|
|
228
|
-
|
|
142
|
+
| | Claude Code subagent | codex-supervisor worker |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| Models | Claude only | `model` goes to the Codex CLI; DeepSeek works |
|
|
145
|
+
| Who does the work | Claude Code itself | A separate `codex exec` process |
|
|
146
|
+
| Two workers, one file | Separate worktrees, no path declaration | `ownedPaths` intersection before dispatch; overlap is refused |
|
|
147
|
+
| Main thread dies | Workers die with it | `thread_id` is in SQLite; `resume_codex_worker` picks the conversation back up |
|
|
148
|
+
| Who can drive it | Claude Code only | Any MCP client |
|
|
149
|
+
| Watching the work | Only the returned conclusion | Raw JSONL and the web board |
|
|
229
150
|
|
|
230
|
-
## The
|
|
151
|
+
## The state machine
|
|
231
152
|
|
|
232
|
-
`status` is the lifecycle
|
|
153
|
+
`status` is the lifecycle, one value per work:
|
|
233
154
|
|
|
234
155
|
| Value | Meaning |
|
|
235
156
|
|---|---|
|
|
236
157
|
| `queued` | Dispatched, not started |
|
|
237
158
|
| `running` | Running |
|
|
238
|
-
| `completed` |
|
|
239
|
-
| `failed` |
|
|
240
|
-
| `cancelled` |
|
|
241
|
-
| `lost` | Killed by an
|
|
159
|
+
| `completed` | Finished with exit code 0 |
|
|
160
|
+
| `failed` | Non-zero exit, `turn.failed`, or spawn failure |
|
|
161
|
+
| `cancelled` | Stopped by `cancel_codex_worker` |
|
|
162
|
+
| `lost` | Killed by an outside signal, the MCP process vanished, or the row was written and no process ever started |
|
|
242
163
|
|
|
243
|
-
`phase`
|
|
164
|
+
`phase` has a value only while `running`: `starting → thinking → command → editing → reporting`.
|
|
244
165
|
|
|
245
|
-
|
|
246
|
-
starting → thinking → command → editing → reporting
|
|
247
|
-
```
|
|
166
|
+
`failed` sends you to the logs; `lost` means run it again. A terminal state lands in two steps: `turn.completed` sets `completed`, the process exit writes `exit_code`. `wait_codex_workers` waits for the second step; a direct status read that sees `completed` with `exit_code: null` is in the gap, read again.
|
|
248
167
|
|
|
249
|
-
|
|
168
|
+
Windows has no signals. An outside kill and the process calling `exit(1)` look the same to the parent, so there it reports `failed` with the exit code.
|
|
250
169
|
|
|
251
|
-
|
|
170
|
+
Native Codex goal states map like this: `active` / `paused` / `blocked` are `running` (the last two land in `needs_attention`), `usageLimited` / `budgetLimited` are `failed`, `complete` is `completed`.
|
|
252
171
|
|
|
253
|
-
|
|
172
|
+
## Where state lives
|
|
254
173
|
|
|
255
|
-
|
|
174
|
+
`~/.codex-supervisor/` by default:
|
|
256
175
|
|
|
257
|
-
|
|
|
258
|
-
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
261
|
-
| `
|
|
262
|
-
| `
|
|
263
|
-
| `budgetLimited` / `budget_limited` | `failed` | Budget exhausted |
|
|
264
|
-
| `complete` | `completed` | Done |
|
|
176
|
+
| File | Content |
|
|
177
|
+
|---|---|
|
|
178
|
+
| `data/supervisor.sqlite` | `tasks` (one row per work), `task_events` (structured events), `sessions` (titles and notes) |
|
|
179
|
+
| `data/runs/<taskId>.jsonl` | The raw `codex --json` output |
|
|
180
|
+
| `data/update-check.json` | Cache for the update check |
|
|
181
|
+
| `worktrees/<taskId>/` | That worker's Git worktree |
|
|
265
182
|
|
|
266
|
-
`
|
|
183
|
+
`changed_files` has three sources: Codex's `file_change` events; `git status --porcelain` in the worktree (uncommitted); `git diff --name-only <base_commit> HEAD` (committed). The last two exist because a worker editing through the shell emits no `file_change` event, and once it commits `git status` is clean again. A real batch of five did exactly that and every read came back empty. `base_commit` is recorded at dispatch; older rows fall back to the oldest reflog entry of the branch. Every git read passes `core.quotePath=false`, so non-ASCII file names come back as written instead of octal-escaped.
|
|
267
184
|
|
|
268
|
-
|
|
185
|
+
A 0.1.x database migrates itself the first time it is opened, without losing a row.
|
|
269
186
|
|
|
270
|
-
|
|
187
|
+
## Update check
|
|
271
188
|
|
|
272
|
-
|
|
273
|
-
|---|---|
|
|
274
|
-
| `data/supervisor.sqlite` | `tasks` (one row per work) and `task_events` (structured events with a `seq`) |
|
|
275
|
-
| `data/runs/<taskId>.jsonl` | Codex `--json` raw output, one event per line |
|
|
276
|
-
| `worktrees/<taskId>/` | That worker's own Git worktree |
|
|
189
|
+
When the MCP process starts it asks the npm registry which version is `latest` and what that tarball's integrity is, then compares two things with the install:
|
|
277
190
|
|
|
278
|
-
|
|
191
|
+
- The version. If it is behind, `get_orchestration_overview`, the dispatch receipt and the `wait_codex_workers` response gain an `update` field with `latest_version` and `npm i -g codex-supervisor-mcp@latest`. The skill tells the main thread to pass that on.
|
|
192
|
+
- The files. A global install records the unpacked tarball's integrity in `node_modules/.package-lock.json`; if it differs from the registry's value for that version, the files on disk are not the published build and the notice says to reinstall. A git checkout has no such value and reports its commit.
|
|
279
193
|
|
|
280
|
-
|
|
194
|
+
Cached an hour, re-checked every six while running. An unreachable registry is not an error; the result says `source: "offline"`. The board shows the same result in the lower left. `CODEX_SUPERVISOR_NO_UPDATE_CHECK=1` turns it off, `CODEX_SUPERVISOR_REGISTRY` points at a private registry.
|
|
281
195
|
|
|
282
196
|
## Environment variables
|
|
283
197
|
|
|
284
198
|
| Variable | Default | Effect |
|
|
285
199
|
|---|---|---|
|
|
286
|
-
| `SUPERVISOR_HOME` | `~/.codex-supervisor` | State root.
|
|
287
|
-
| `CODEX_HOME` | `~/.codex` | Read-only
|
|
288
|
-
| `CODEX_BIN` | `codex`
|
|
289
|
-
| `GIT_BIN` | `git`
|
|
290
|
-
|
|
291
|
-
|
|
200
|
+
| `SUPERVISOR_HOME` | `~/.codex-supervisor` | State root. The MCP and the board must use the same one |
|
|
201
|
+
| `CODEX_HOME` | `~/.codex` | Read-only, for Codex's native `goals_1.sqlite` |
|
|
202
|
+
| `CODEX_BIN` | `codex` | Path to the Codex CLI. The Windows `.cmd` shim is bypassed; a `.js` target is started with `node` |
|
|
203
|
+
| `GIT_BIN` | `git` | Path to git |
|
|
204
|
+
| `SUPERVISOR_WEB_PORT` / `SUPERVISOR_WEB_HOST` | `7877` / `127.0.0.1` | Where the board listens |
|
|
205
|
+
| `CODEX_SUPERVISOR_NO_UPDATE_CHECK` | unset | `1` disables the update check |
|
|
206
|
+
| `CODEX_SUPERVISOR_REGISTRY` | `https://registry.npmjs.org` | Registry for the update check |
|
|
207
|
+
| `CODEX_SUPERVISOR_UPDATE_TIMEOUT_MS` | `4000` | How long to wait for the registry |
|
|
208
|
+
| `CODEX_SUPERVISOR_SKIP_SETUP` | unset | `1` skips the `postinstall` setup |
|
|
209
|
+
|
|
210
|
+
A process started by a GUI client often has no `codex` on `PATH`; set `CODEX_BIN` in the config:
|
|
292
211
|
|
|
293
212
|
```json
|
|
294
213
|
{
|
|
@@ -302,76 +221,114 @@ When the MCP client starts without `codex` on `PATH`, which is common for GUI-la
|
|
|
302
221
|
}
|
|
303
222
|
```
|
|
304
223
|
|
|
305
|
-
##
|
|
224
|
+
## Install details
|
|
306
225
|
|
|
307
|
-
|
|
308
|
-
- **The worktree is created from a commit, so uncommitted work isn't in it.** The default is the repository's `HEAD`; `baseRef` accepts any branch, tag or sha (one that doesn't resolve refuses the dispatch with `invalid_base_ref` instead of quietly falling back to `HEAD`). Modified and untracked files sitting in the main thread's checkout don't exist inside the worker's worktree. Give the task absolute paths, or commit first. The worker's own changes land on the `codex/<taskId>` branch and never touch the main checkout.
|
|
309
|
-
- **Only the working directory is isolated.** Temp directories (`TMPDIR`), databases, and ports are process-level resources and stay shared, so two workers writing the same temp file still collide. Give each one its own paths, database name, and port in the task if you need that.
|
|
310
|
-
- **`ownedPaths` is a pre-dispatch conflict check, not a runtime sandbox.** It stops two workers from registering the same file; it does not stop a worker from creating a file it never listed, because the sandbox is `workspace-write` and any path inside its own worktree is writable. Verify the output from the diff.
|
|
311
|
-
- **It reports "it finished", not "it's correct".** Terminal states come from Codex's `turn.completed` and the process exit code; `exit_code: 0` only means it didn't crash. Judging the output is the main thread's job: run the checks, spot-read the content.
|
|
312
|
-
- **A terminal state lands in two steps, and wait only returns once both have.** `turn.completed` flips `status` to `completed` first; `exit_code` is written when the process exits. `wait_codex_workers` counts a worker as finished only once `exit_code` is recorded (or nobody is left to record it), so the snapshot it returns matches the next `get_codex_worker_status` read. A direct status read can still land between the two steps: `completed` with `exit_code: null` is that gap, read again a moment later.
|
|
313
|
-
- **Don't expect one `wait_codex_workers` call to cover a long job.** Your client's MCP tool timeout is a hard wall (the `timeout` field in `.mcp.json`, or `MCP_TOOL_TIMEOUT`), and hitting it kills the call. The default wait returns after 2 minutes with a progress snapshot; loop instead of waiting once.
|
|
314
|
-
- **Long text comes back clipped by default.** `current_action` is cut at 300 characters, the prompt inside `get_codex_worker_status` is cut at 300 (`includePrompt: true` lifts that), and `last_message` is cut at 400 in the overview and the wait response (4000 in the status response). Nothing is lost: the full command stream is in `get_codex_worker_events` and the full report is in `get_worker_result`. This is what takes one `wait_codex_workers` round trip from tens of KB down to a few KB - which matters because a client that backgrounds a timed-out call replays the whole result as a notification.
|
|
315
|
-
- **Nothing is written to Codex's native goal store.** `goals_1.sqlite` belongs to Codex and this MCP only reads it. Once a worker starts, it calls Codex's own `create_goal`; this MCP only splices that instruction into the prompt at dispatch time.
|
|
316
|
-
- **Native goals depend on the model complying.** `codex exec` does not create a goal on its own; the instruction at dispatch time is what makes the worker create one. The model occasionally skips it, in which case `native_goal` is `null` and `get_worker_goal` falls back to the copy recorded at dispatch. The state machine is unaffected.
|
|
317
|
-
- **`search_works` is substring matching, not a full-text index.** At a few hundred works, a `LIKE` scan is fast enough and costs nothing to maintain. Talk about something else at tens of thousands.
|
|
318
|
-
- **Cross-process cancel goes through the pid.** When the process handle isn't in this process, it first confirms the pid's command line contains `codex` (`ps` on macOS and Linux, CIM on Windows, `tasklist` as a fallback), then sends `SIGTERM` (`taskkill /T /F` on Windows), so a recycled pid doesn't get killed by mistake.
|
|
319
|
-
- **`create_codex_followup_worker` and `resume_codex_worker` are not the same thing.** The first opens a new session and restates the context in prose; the second reattaches the same session. Use the second when details matter.
|
|
320
|
-
- **`session_id` comes from the dispatcher; this MCP doesn't generate it.** Pass the same value for a batch of work and `get_session_works` can group it afterwards. Without it the column is `NULL` and the batch is unrecoverable by session.
|
|
226
|
+
### GUI clients
|
|
321
227
|
|
|
322
|
-
|
|
228
|
+
GUI clients do not run `postinstall`; add the JSON above to the config file:
|
|
323
229
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|---|---|
|
|
340
|
-
| Vector search | `search_works` substring matching is faster and needs zero maintenance at a few hundred works. Both vendors' official memory systems (Codex `memories`, Claude auto-memory) are file search too, not vectors |
|
|
341
|
-
| Sorting by `usage_count` | Measured: of 80 works, only 2 were ever referenced again. Every counter sat at 0 or 1, so sorting did nothing |
|
|
342
|
-
| Reusing Codex's `usage_count` | That number counts how often a memory entry was cited, which is a different question from how often the main thread looked it up |
|
|
343
|
-
| A three-layer memory index | The current data volume can't justify one layer. `get_worker_summary` is enough |
|
|
230
|
+
| Client | macOS | Windows | Linux |
|
|
231
|
+
|---|---|---|---|
|
|
232
|
+
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | `%APPDATA%\Claude\claude_desktop_config.json` | `~/.config/Claude/claude_desktop_config.json` |
|
|
233
|
+
| Cursor | `~/.cursor/mcp.json` | `%APPDATA%\Cursor\mcp.json` | `~/.config/cursor/mcp.json` |
|
|
234
|
+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` | `%APPDATA%\Codeium\windsurf\mcp_config.json` | `~/.config/.codeium/windsurf/mcp_config.json` |
|
|
235
|
+
|
|
236
|
+
### Running the setup again
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
codex-supervisor-setup # detect clients, install the skill, register the MCP
|
|
240
|
+
codex-supervisor-setup --target claude,codex
|
|
241
|
+
codex-supervisor-setup --skill-only
|
|
242
|
+
codex-supervisor-setup --mcp-only
|
|
243
|
+
codex-supervisor-setup --dry-run # print the plan only
|
|
244
|
+
```
|
|
344
245
|
|
|
345
|
-
|
|
246
|
+
An existing skill with different content is backed up to `SKILL.md.bak-<timestamp>` before it is overwritten.
|
|
346
247
|
|
|
347
|
-
|
|
248
|
+
### Upgrading
|
|
348
249
|
|
|
349
250
|
```bash
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
251
|
+
npm install -g codex-supervisor-mcp@latest
|
|
252
|
+
npm ls -g --depth=0 | grep codex-supervisor
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Then restart Claude Code / Codex. Three things to know:
|
|
256
|
+
|
|
257
|
+
- The registry takes a few minutes to move `latest` after a publish. If the version did not change, wait, or pin the version.
|
|
258
|
+
- `npm link` installs a symlink: `src/` changes apply at once, the skill does not sync by itself; run `codex-supervisor-setup`.
|
|
259
|
+
- Switching Node versions breaks the registered absolute path. Run `claude mcp remove -s user codex-supervisor` and `codex mcp remove codex-supervisor` first, then install.
|
|
353
260
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
261
|
+
### Uninstall
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
npm uninstall -g codex-supervisor-mcp
|
|
265
|
+
claude mcp remove -s user codex-supervisor
|
|
266
|
+
codex mcp remove codex-supervisor
|
|
267
|
+
rm -rf ~/.claude/skills/codex-supervisor ~/.agents/skills/codex-supervisor ~/.codex/skills/codex-supervisor
|
|
268
|
+
rm -rf ~/.codex-supervisor
|
|
357
269
|
```
|
|
358
270
|
|
|
359
|
-
|
|
271
|
+
### Windows
|
|
272
|
+
|
|
273
|
+
- The npm-installed CLI is `codex.cmd`, and Node refuses to spawn it directly since 18.20 / 20.12 (the behaviour after CVE-2024-27980). `shell: true` is not used, because cancelling would then only kill the shell. Instead the package's own entry, `node_modules/@openai/codex/bin/codex.js`, is started with `node`.
|
|
274
|
+
- Cross-process cancel runs `taskkill /PID <pid> /T /F` on the whole tree, after `Get-CimInstance Win32_Process` confirms the pid runs codex.
|
|
275
|
+
- Beyond `PATH` it probes `%APPDATA%\npm`, `%LOCALAPPDATA%\pnpm`, `%LOCALAPPDATA%\Volta\bin` and `%ProgramFiles%\nodejs`.
|
|
276
|
+
|
|
277
|
+
### Troubleshooting
|
|
278
|
+
|
|
279
|
+
| Symptom | Cause | Fix |
|
|
280
|
+
|---|---|---|
|
|
281
|
+
| Not in `claude mcp list` | The install method skipped `postinstall` | `codex-supervisor-setup`, or `claude mcp add` by hand |
|
|
282
|
+
| Dispatch says `codex only resolved to a shell shim` | Windows found only the `.cmd`; the package entry behind it is gone | Reinstall `@openai/codex`, or point `CODEX_BIN` at `codex.js` |
|
|
283
|
+
| Worker is `failed` at once with `spawn codex ENOENT` | No `codex` on the process's `PATH` | Set `CODEX_BIN` in the config |
|
|
284
|
+
| `Cannot find module 'node:sqlite'` | Node older than 22.13.0 | Upgrade Node |
|
|
285
|
+
| Worker stuck in `lost` | The MCP process was killed and the worker orphaned | `resume_codex_worker`, or dispatch again |
|
|
286
|
+
| `ownedPaths overlap with active worker(s)` | Two workers claimed the same paths | Split differently, or cancel the one holding them |
|
|
287
|
+
| The board is empty | The board and the MCP use different `SUPERVISOR_HOME`s | Start the board with the same one |
|
|
288
|
+
|
|
289
|
+
## Known limitations
|
|
290
|
+
|
|
291
|
+
- A worker's lifetime is tied to the MCP process. Kill the MCP and the worker is left behind, settled as `lost` on the next read. The fix is a resident daemon; see the Roadmap.
|
|
292
|
+
- The worktree is cut from a commit, so uncommitted work in your checkout is not in it. Give the task absolute paths, or commit first.
|
|
293
|
+
- Only the working directory is isolated. Temp directories, databases and ports are shared; workers that would hit the same dev server need to be kept apart in the task.
|
|
294
|
+
- `ownedPaths` is checked at dispatch only; it does not stop a worker from creating a file it never listed. Review the diff.
|
|
295
|
+
- It reports "finished", not "correct". `exit_code: 0` means it did not crash; acceptance is the main thread's job.
|
|
296
|
+
- Do not expect one `wait_codex_workers` call to cover a long job. The client's MCP tool timeout is a hard wall; the default returns a snapshot after two minutes, loop instead.
|
|
297
|
+
- Nothing is written to Codex's native goal store; `goals_1.sqlite` is read-only here. The worker creates its own goal and sometimes skips it, in which case `native_goal` is `null` and the state machine is unaffected.
|
|
298
|
+
- `search_works` is substring matching. Fine at hundreds of rows; revisit at tens of thousands.
|
|
299
|
+
|
|
300
|
+
## Roadmap
|
|
301
|
+
|
|
302
|
+
1. ~~`CODEX_BIN` / `SUPERVISOR_HOME` / `GIT_BIN`~~ ✅
|
|
303
|
+
2. ~~`status` and `phase` split, `lost` added~~ ✅
|
|
304
|
+
3. ~~`ownedPaths` / `goal` / `dependsOn`, event gates~~ ✅
|
|
305
|
+
4. ~~`thread_id` on disk + `resume_codex_worker`~~ ✅
|
|
306
|
+
5. ~~Concurrency: crash points, ownership conflicts, multi-process writes~~ ✅
|
|
307
|
+
6. ~~`session_id` + `get_session_works`~~ ✅
|
|
308
|
+
7. ~~`search_works`~~ ✅
|
|
309
|
+
8. ~~Native worker goals~~ ✅
|
|
310
|
+
9. ~~Windows~~ ✅
|
|
311
|
+
10. ~~Web board~~ ✅
|
|
312
|
+
11. ~~Session titles, update check, `baseRef`, committed changes visible~~ ✅
|
|
313
|
+
12. Resident daemon: move dispatch and process lifetime out of the MCP process
|
|
314
|
+
|
|
315
|
+
Not planned: vector search (substring matching is faster at this scale and costs nothing to maintain), `usage_count` ordering (2 of 80 real works were ever referenced again), a layered memory index (not enough data to need one).
|
|
360
316
|
|
|
361
317
|
## Development
|
|
362
318
|
|
|
363
319
|
```bash
|
|
364
320
|
npm install
|
|
365
|
-
npm test #
|
|
366
|
-
npm run test:
|
|
367
|
-
npm run
|
|
321
|
+
npm test # truncation, state machine, migration, setup, Windows routing, 23 regression cases, 40 edge cases
|
|
322
|
+
npm run test:edge # test/edge only: update check against a fake registry, session titles, baseRef, non-ASCII paths, ghost rows, board API
|
|
323
|
+
npm run test:real # end to end with the real codex CLI
|
|
368
324
|
npm run smoke:mcp # MCP protocol smoke test
|
|
369
325
|
npm run monitor # Ink terminal board
|
|
326
|
+
npm run web:install # board dependencies
|
|
327
|
+
npm run web:dev # board with hot reload, /api proxied to 7877
|
|
328
|
+
npm run web:build # bundle into web/dist; runs before publish
|
|
370
329
|
```
|
|
371
330
|
|
|
372
|
-
`npm test` replays
|
|
373
|
-
|
|
374
|
-
CI runs on Ubuntu, macOS, and Windows, plus a separate Node 22.13.0 job that pins the lower bound declared in `engines`, since `node:sqlite` had no unflagged build before it. The four `setup-windows-test.js` cases use a real filesystem to simulate the `.cmd` shim under `%APPDATA%\npm`, verifying that automatic MCP registration genuinely works rather than just passing a parser unit test.
|
|
331
|
+
`npm test` replays fixed Codex event streams through `src/test-fixtures/fake-codex.js`, fast and deterministic; `npm run test:real` is the evidence of compatibility with the current Codex. CI runs Ubuntu / macOS / Windows plus one Node 22.13.0 job that pins the `engines` floor.
|
|
375
332
|
|
|
376
333
|
## License
|
|
377
334
|
|