catherd-cli 1.4.0 → 2.0.0-beta.20261022113309
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 +188 -169
- package/THIRD_PARTY_NOTICES.md +217 -35
- package/catalog/jev.json +27 -1
- package/catalog/models.json +56 -239
- package/package.json +6 -8
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/bin/catherd-mcp +1 -1
- package/plugin/commands/catherd.md +2 -2
- package/plugin/skills/catherd/SKILL.md +97 -356
- package/plugin/skills/catherd-setup/SKILL.md +21 -20
- package/src/adapters/all.ts +0 -4
- package/src/adapters/backend.ts +19 -4
- package/src/adapters/claude-code/index.ts +126 -14
- package/src/adapters/codex/events.ts +10 -0
- package/src/adapters/codex/index.ts +17 -5
- package/src/adapters/cursor/home.ts +1 -1
- package/src/adapters/cursor/index.ts +10 -4
- package/src/adapters/opencode/index.ts +38 -1
- package/src/cli.ts +27 -27
- package/src/domain/agents.ts +3 -1
- package/src/domain/bars.ts +33 -107
- package/src/domain/blocked.ts +72 -0
- package/src/domain/branch.ts +51 -0
- package/src/domain/brief.ts +106 -0
- package/src/domain/catalog.ts +69 -313
- package/src/domain/changes.ts +23 -1
- package/src/domain/cost.ts +19 -29
- package/src/domain/errors.ts +6 -2
- package/src/domain/fail-lines.ts +26 -0
- package/src/domain/failover.ts +37 -75
- package/src/domain/findings.ts +47 -0
- package/src/domain/gate-brief.ts +53 -0
- package/src/domain/hints.ts +13 -2
- package/src/domain/ids.ts +13 -2
- package/src/domain/jev.ts +47 -2
- package/src/domain/judge.ts +124 -0
- package/src/domain/lane.ts +118 -3
- package/src/domain/milestone-memory.ts +53 -0
- package/src/domain/notice.ts +32 -8
- package/src/domain/notify.ts +32 -0
- package/src/domain/plan-doc.ts +198 -0
- package/src/domain/plan-lint.ts +141 -0
- package/src/domain/profile-rules.ts +175 -138
- package/src/domain/profile.ts +140 -63
- package/src/domain/record.ts +68 -3
- package/src/domain/reply.ts +29 -0
- package/src/domain/role-prompts.ts +182 -56
- package/src/domain/role-scope.ts +76 -0
- package/src/domain/role-tools.ts +34 -0
- package/src/domain/roles.ts +2 -0
- package/src/domain/route.ts +90 -0
- package/src/domain/rules.ts +33 -0
- package/src/domain/run-events.ts +298 -0
- package/src/domain/run-machine.ts +668 -0
- package/src/domain/run-state.ts +1310 -0
- package/src/domain/scorecard.ts +197 -0
- package/src/domain/select.ts +229 -72
- package/src/domain/slopalytics.ts +72 -0
- package/src/domain/state.ts +5 -0
- package/src/domain/util.ts +22 -0
- package/src/domain/workspace.ts +130 -0
- package/src/entry/answer-command.ts +39 -0
- package/src/entry/catalog-command.ts +24 -165
- package/src/entry/check-bin.ts +17 -0
- package/src/entry/cli-kit.ts +18 -2
- package/src/entry/daemon-bin.ts +22 -0
- package/src/entry/deps.ts +2 -0
- package/src/entry/doctor-command.ts +20 -2
- package/src/entry/glyphs.ts +15 -2
- package/src/entry/host-arg.ts +28 -0
- package/src/entry/init-command.ts +20 -69
- package/src/entry/knowledge-command.ts +121 -5
- package/src/entry/lock-command.ts +103 -8
- package/src/entry/mcp/handshake.ts +6 -2
- package/src/entry/mcp/role-bin.ts +20 -0
- package/src/entry/mcp/role-server.ts +134 -0
- package/src/entry/mcp/server.ts +85 -21
- package/src/entry/mcp/session-tools.ts +149 -0
- package/src/entry/panel/openapi.ts +189 -0
- package/src/entry/panel/server.ts +410 -0
- package/src/entry/panel-command.ts +68 -0
- package/src/entry/pause-command.ts +67 -0
- package/src/entry/profile-command.ts +33 -18
- package/src/entry/role-cli-command.ts +159 -0
- package/src/entry/runs-command.ts +81 -27
- package/src/entry/scorecard-command.ts +187 -0
- package/src/entry/supervise-bin.ts +1 -1
- package/src/entry/supervise-command.ts +30 -3
- package/src/entry/workspace-command.ts +44 -0
- package/src/infra/boot-lock.ts +25 -0
- package/src/infra/delivery.ts +3 -0
- package/src/infra/dispatch-dir.ts +2 -0
- package/src/infra/env.ts +11 -3
- package/src/infra/git.ts +70 -0
- package/src/infra/heavy-lock.ts +133 -6
- package/src/infra/host-probe.ts +16 -0
- package/src/infra/launch.ts +63 -7
- package/src/infra/lock-activity.ts +88 -0
- package/src/infra/login-env.ts +48 -0
- package/src/infra/memory.ts +45 -0
- package/src/infra/ntfy.ts +40 -0
- package/src/infra/open-url.ts +42 -0
- package/src/infra/paths.ts +37 -2
- package/src/infra/role-mcp.ts +69 -0
- package/src/infra/slopalytics.ts +30 -0
- package/src/infra/store.ts +6 -1
- package/src/infra/supervisor.ts +107 -16
- package/src/services/admission.ts +133 -31
- package/src/services/backends.ts +4 -6
- package/src/services/budget.ts +26 -6
- package/src/services/capture.ts +1 -22
- package/src/services/catalog-service.ts +155 -254
- package/src/services/credentials.ts +15 -26
- package/src/services/daemon.ts +181 -0
- package/src/services/dispatch-service.ts +209 -17
- package/src/services/dispatches.ts +30 -2
- package/src/services/doctor-access.ts +8 -3
- package/src/services/doctor-backends.ts +1 -1
- package/src/services/doctor-checks.ts +47 -0
- package/src/services/doctor-docker.ts +221 -0
- package/src/services/doctor-role-mcp.ts +65 -0
- package/src/services/doctor.ts +72 -15
- package/src/services/end-push.ts +157 -0
- package/src/services/failover-rungs.ts +109 -0
- package/src/services/finalize.ts +24 -2
- package/src/services/gate-env.ts +217 -0
- package/src/services/gate-service.ts +231 -45
- package/src/services/global-install.ts +46 -13
- package/src/services/jev-service.ts +2 -4
- package/src/services/lane-edit.ts +154 -0
- package/src/services/lane-service.ts +291 -55
- package/src/services/milestone-check.ts +433 -0
- package/src/services/milestone-tree.ts +170 -0
- package/src/services/milestones.ts +167 -29
- package/src/services/notifier.ts +124 -4
- package/src/services/notify-service.ts +26 -0
- package/src/services/orchestrator-wait.ts +82 -0
- package/src/services/panel-setup.ts +116 -0
- package/src/services/pause.ts +161 -0
- package/src/services/peek.ts +79 -17
- package/src/services/plan-input.ts +151 -0
- package/src/services/ports.ts +60 -5
- package/src/services/preflight.ts +232 -24
- package/src/services/profile-service.ts +31 -3
- package/src/services/profile-store.ts +18 -6
- package/src/services/protocol.ts +123 -25
- package/src/services/provenance.ts +34 -89
- package/src/services/questions.ts +24 -0
- package/src/services/reconcile.ts +33 -1
- package/src/services/reentry.ts +7 -6
- package/src/services/role-access.ts +27 -0
- package/src/services/routing-service.ts +161 -42
- package/src/services/run-briefs.ts +477 -0
- package/src/services/run-client.ts +217 -0
- package/src/services/run-effects.ts +837 -0
- package/src/services/run-events-store.ts +174 -0
- package/src/services/run-evidence.ts +1 -1
- package/src/services/run-pin.ts +125 -0
- package/src/services/run-read.ts +221 -0
- package/src/services/run-report.ts +176 -0
- package/src/services/run-service.ts +204 -23
- package/src/services/run-store.ts +159 -18
- package/src/services/scorecard-metrics.ts +86 -0
- package/src/services/scorecard.ts +382 -0
- package/src/services/scratch.ts +60 -0
- package/src/services/sessions.ts +3 -1
- package/src/services/state.ts +21 -0
- package/src/services/summary.ts +76 -12
- package/src/services/tree-path.ts +27 -0
- package/src/services/verifier-brief.ts +23 -0
- package/src/services/verifier-step.ts +48 -0
- package/src/services/workspace-admission.ts +259 -0
- package/src/services/workspace-service.ts +259 -0
- package/src/services/workspace-store.ts +95 -0
- package/web/dist/assets/Brand-PKlUX5TE.js +1 -0
- package/web/dist/assets/Brand-PKlUX5TE.js.br +0 -0
- package/web/dist/assets/Brand-PKlUX5TE.js.gz +0 -0
- package/web/dist/assets/Modal-Dxc5so53.js +1 -0
- package/web/dist/assets/Modal-Dxc5so53.js.br +0 -0
- package/web/dist/assets/Modal-Dxc5so53.js.gz +0 -0
- package/web/dist/assets/Pressable-C8-T6Ed_.js +1 -0
- package/web/dist/assets/StatusChip-B5xfI_Mn.js +153 -0
- package/web/dist/assets/StatusChip-B5xfI_Mn.js.br +0 -0
- package/web/dist/assets/StatusChip-B5xfI_Mn.js.gz +0 -0
- package/web/dist/assets/_app-Ea5cpyKe.js +1 -0
- package/web/dist/assets/_app-Ea5cpyKe.js.br +0 -0
- package/web/dist/assets/_app-Ea5cpyKe.js.gz +0 -0
- package/web/dist/assets/_runId-pTG0fXVo.js +1 -0
- package/web/dist/assets/_runId-pTG0fXVo.js.br +0 -0
- package/web/dist/assets/_runId-pTG0fXVo.js.gz +0 -0
- package/web/dist/assets/drawer-Du3cdlok.js +1 -0
- package/web/dist/assets/drawer-Du3cdlok.js.br +0 -0
- package/web/dist/assets/drawer-Du3cdlok.js.gz +0 -0
- package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/web/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/web/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/web/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/web/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/web/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/web/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/web/dist/assets/index-B6GiwDkh.js +11 -0
- package/web/dist/assets/index-B6GiwDkh.js.br +0 -0
- package/web/dist/assets/index-B6GiwDkh.js.gz +0 -0
- package/web/dist/assets/index-C5IbylvM.css +2 -0
- package/web/dist/assets/index-C5IbylvM.css.br +0 -0
- package/web/dist/assets/index-C5IbylvM.css.gz +0 -0
- package/web/dist/assets/label-DFSYBc62.js +1 -0
- package/web/dist/assets/label-DFSYBc62.js.br +0 -0
- package/web/dist/assets/label-DFSYBc62.js.gz +0 -0
- package/web/dist/assets/link-D8EcKZUt.js +1 -0
- package/web/dist/assets/link-D8EcKZUt.js.br +0 -0
- package/web/dist/assets/link-D8EcKZUt.js.gz +0 -0
- package/web/dist/assets/login-DaN5HPPW.js +1 -0
- package/web/dist/assets/login-DaN5HPPW.js.br +0 -0
- package/web/dist/assets/login-DaN5HPPW.js.gz +0 -0
- package/web/dist/assets/query-Cu--ccT3.js +1 -0
- package/web/dist/assets/questions-shoO9OVj.js +1 -0
- package/web/dist/assets/questions-shoO9OVj.js.br +0 -0
- package/web/dist/assets/questions-shoO9OVj.js.gz +0 -0
- package/web/dist/assets/react-query.gen-Bu2yV-qJ.js +12 -0
- package/web/dist/assets/react-query.gen-Bu2yV-qJ.js.br +0 -0
- package/web/dist/assets/react-query.gen-Bu2yV-qJ.js.gz +0 -0
- package/web/dist/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/web/dist/assets/run-status-C0DRuV7U.js +1 -0
- package/web/dist/assets/runs-C3rg2zZc.js +1 -0
- package/web/dist/assets/runs-C3rg2zZc.js.br +0 -0
- package/web/dist/assets/runs-C3rg2zZc.js.gz +0 -0
- package/web/dist/assets/setup-5I4Vl9fR.js +1 -0
- package/web/dist/assets/setup-5I4Vl9fR.js.br +0 -0
- package/web/dist/assets/setup-5I4Vl9fR.js.gz +0 -0
- package/web/dist/assets/table-BOxXhqS4.js +1 -0
- package/web/dist/assets/table-BOxXhqS4.js.br +0 -0
- package/web/dist/assets/table-BOxXhqS4.js.gz +0 -0
- package/web/dist/assets/textfield-BzRFkxBF.js +1 -0
- package/web/dist/assets/textfield-BzRFkxBF.js.br +0 -0
- package/web/dist/assets/textfield-BzRFkxBF.js.gz +0 -0
- package/web/dist/assets/time--9kSQbbp.js +1 -0
- package/web/dist/assets/use-css-variable-CpnN9WtA.js +5 -0
- package/web/dist/assets/use-css-variable-CpnN9WtA.js.br +0 -0
- package/web/dist/assets/use-css-variable-CpnN9WtA.js.gz +0 -0
- package/web/dist/assets/useMutation-CVPKlR34.js +1 -0
- package/web/dist/assets/useMutation-CVPKlR34.js.br +0 -0
- package/web/dist/assets/useMutation-CVPKlR34.js.gz +0 -0
- package/web/dist/index.html +15 -0
- package/catalog/ATTRIBUTION.md +0 -36
- package/catalog/scores.json +0 -3202
- package/catalog/sources.json +0 -97
- package/src/adapters/antigravity/events.ts +0 -131
- package/src/adapters/antigravity/home.ts +0 -46
- package/src/adapters/antigravity/index.ts +0 -320
- package/src/adapters/antigravity/models.ts +0 -37
- package/src/adapters/grok/events.ts +0 -112
- package/src/adapters/grok/home.ts +0 -132
- package/src/adapters/grok/index.ts +0 -339
- package/src/adapters/grok/models.ts +0 -48
- package/src/domain/calibration.ts +0 -125
- package/src/domain/sources.ts +0 -144
- package/src/entry/mcp/dispatch-tools.ts +0 -52
- package/src/entry/mcp/lane-tools.ts +0 -84
- package/src/entry/mcp/protocol-tools.ts +0 -57
- package/src/entry/mcp/run-tools.ts +0 -148
- package/src/entry/mcp/setup-tools.ts +0 -108
- package/src/entry/tui/commands.ts +0 -563
- package/src/entry/tui/effects.ts +0 -381
- package/src/entry/tui/fixtures.ts +0 -637
- package/src/entry/tui/profile-edits.ts +0 -146
- package/src/entry/tui/profile-tree.ts +0 -429
- package/src/entry/tui/providers/app.tsx +0 -162
- package/src/entry/tui/providers/boundary.tsx +0 -57
- package/src/entry/tui/providers/data.tsx +0 -160
- package/src/entry/tui/providers/keymap.tsx +0 -166
- package/src/entry/tui/providers/root.tsx +0 -45
- package/src/entry/tui/providers/theme.tsx +0 -17
- package/src/entry/tui/providers/toast.tsx +0 -77
- package/src/entry/tui/run.tsx +0 -114
- package/src/entry/tui/state.ts +0 -373
- package/src/entry/tui/stories.ts +0 -114
- package/src/entry/tui/text.ts +0 -130
- package/src/entry/tui/theme.ts +0 -140
- package/src/entry/tui/views/app.tsx +0 -208
- package/src/entry/tui/views/dialogs.tsx +0 -41
- package/src/entry/tui/views/profile-actions.ts +0 -331
- package/src/entry/tui/views/profiles.tsx +0 -520
- package/src/entry/tui/views/runs.tsx +0 -573
- package/src/entry/tui/views/save-dialog.tsx +0 -340
- package/src/entry/tui/views/status.tsx +0 -209
- package/src/entry/tui/widgets/chrome.tsx +0 -114
- package/src/entry/tui/widgets/dialog-confirm.tsx +0 -58
- package/src/entry/tui/widgets/dialog-prompt.tsx +0 -52
- package/src/entry/tui/widgets/dialog-select.tsx +0 -212
- package/src/entry/tui/widgets/dialog.tsx +0 -68
- package/src/entry/tui/widgets/line.tsx +0 -92
- package/src/entry/tui/widgets/list.tsx +0 -197
- package/src/entry/tui/widgets/spinner.tsx +0 -49
- package/src/entry/tui/widgets/toast.tsx +0 -62
- package/src/infra/sources/arena.ts +0 -87
- package/src/infra/sources/artificial-analysis.ts +0 -112
- package/src/infra/sources/cache.ts +0 -124
- package/src/infra/sources/csv.ts +0 -38
- package/src/infra/sources/epoch.ts +0 -82
- package/src/infra/sources/http.ts +0 -75
- package/src/infra/sources/litellm.ts +0 -58
- package/src/infra/sources/models-dev.ts +0 -59
- package/src/infra/sources/openrouter-endpoints.ts +0 -52
- package/src/infra/sources/openrouter-models.ts +0 -60
- package/src/infra/sources/rows.ts +0 -38
- package/src/infra/sources/vectara.ts +0 -69
- package/src/infra/sources/zip.ts +0 -48
- package/src/services/catalog-refresh.ts +0 -201
- package/src/services/doctor-sources.ts +0 -76
- package/src/services/runs-page.ts +0 -255
- package/src/services/source-derive.ts +0 -374
- package/src/services/source-sync.ts +0 -305
- package/src/services/standins.ts +0 -204
- package/src/services/treat-likes.ts +0 -97
|
@@ -7,7 +7,7 @@ description: Use when the user wants to tune catherd — which models and effort
|
|
|
7
7
|
|
|
8
8
|
You tune the user's catherd profile in conversation. A profile says, per role, which rungs it may run on (`backend:model#effort`, in ladder order) and what it may touch (its access mode); whether routing favours cost or speed; how each backend is billed; whether Jev picks the rung; which rung stands in when a backend hits its usage limit; the run budget and timeouts; whether each vendor harness runs with the user's customizations or isolated; how many heavy commands run at once; and when to push.
|
|
9
9
|
|
|
10
|
-
**You never edit a file by hand.** Use `
|
|
10
|
+
**You never edit a file by hand.** Use `profile({ action: "set" })` for patches and the existing reviewed CLI reset below; both go through ProfileService, as do the `catherd profile` commands and the panel.
|
|
11
11
|
|
|
12
12
|
**Discover the host first with `status()`.** Use the host's available MCP discovery facility; names and deferred tools differ. Claude Code may use `ToolSearch`; Codex never needs invented Claude tools or native Claude agents. Pass the actual project `repo` explicitly to profile, setup and catalog calls that accept it: native Codex starts the MCP server in the installed plugin root, not the project. An unknown terminal can use `catherd init --host codex` or `--host claude-code` for setup; this does not create a conversation owner. Conflicting identity must be resolved before ownership or push.
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ You tune the user's catherd profile in conversation. A profile says, per role, w
|
|
|
15
15
|
|
|
16
16
|
- **One question at a time.** Each question carries your recommended answer and one line on why, so the user can simply say yes.
|
|
17
17
|
- **The user steers.** When they reverse a proposal, take the reversal and never re-argue it.
|
|
18
|
-
- **Talk in their terms:** minutes, their subscriptions, how often a rung climbed on their own runs, tokens per run.
|
|
18
|
+
- **Talk in their terms:** minutes, their subscriptions, how often a rung climbed on their own runs, tokens per run. Name the Slopalytics intelligence index only when they ask.
|
|
19
19
|
- **Every number you quote comes from a tool result in this conversation.** When there is no data yet, say so instead of estimating.
|
|
20
20
|
|
|
21
21
|
## 1. Learn the goals
|
|
@@ -23,16 +23,17 @@ You tune the user's catherd profile in conversation. A profile says, per role, w
|
|
|
23
23
|
Ask these, one at a time, each with its recommended answer:
|
|
24
24
|
|
|
25
25
|
1. **Their order of speed, cost and quality.** Recommend cost first, the default `objective`: catherd climbs a rung when a cheap one cannot do the work, so the lanes that need speed get it anyway, and the reviewer and the verifier hold quality either way.
|
|
26
|
-
2. **The subscriptions they hold:** a ChatGPT plan (Codex), a Claude plan, OpenCode Go, Zen credit or API keys. They set `billing` per key (`codex`, `claude`, `claude-code`, `opencode-go`, `opencode`, `cursor
|
|
27
|
-
3. **The kind of work they orchestrate:** front-end screens, back-end services, terminal and ops work, docs. Recommend from their own runs when `
|
|
26
|
+
2. **The subscriptions they hold:** a ChatGPT plan (Codex), a Claude plan, OpenCode Go, Zen credit or API keys. They set `billing` per key (`codex`, `claude`, `claude-code`, `opencode-go`, `opencode`, `cursor`): `chatgpt-plan`, `claude-plan`, `subscription` or `metered`. Recommend leaning on subscriptions before metered spend. Explain which workers share this conversation's quota from the actual host and billing facts.
|
|
27
|
+
3. **The kind of work they orchestrate:** front-end screens, back-end services, terminal and ops work, docs. Recommend from their own runs when the catalog's `runs:` evidence has any.
|
|
28
28
|
|
|
29
29
|
## 2. Read the facts before proposing
|
|
30
30
|
|
|
31
31
|
In one message, call:
|
|
32
32
|
|
|
33
|
-
- `
|
|
34
|
-
- `
|
|
35
|
-
|
|
33
|
+
- `catherd catalog list --role <role> --json` (in a shell, from their repo) for each role you will discuss: the models that can fill it, their indexed rungs (each with its `intelligence`, the one number catherd ranks on), each rung's cost under their billing, whether their backend's last listing offers it (`listed: false` means their account does not), and the `runs:` evidence of how each rung has done on their own runs (runs, refusals, climbs, time). The session has no catalog tool;
|
|
34
|
+
- `profile({ action: "get", repo })`: where they stand now, with each role's `access` and `enforcement`. Pass the user's repo: without a name, the profile tools act on the profile this repo runs on (the one bound to it, else the active one), which `here` names; `active` is the global active profile.
|
|
35
|
+
|
|
36
|
+
There is no per-run harness figure in the session: say so when isolation comes up.
|
|
36
37
|
|
|
37
38
|
Verify the exact omitted Codex model ID `gpt-6.1-sol` against native catalog discovery and validation. If its spelling differs, report the mismatch and resolve it explicitly with the owner; never silently normalize or substitute a model. Retain architect high and verifier low effort.
|
|
38
39
|
|
|
@@ -44,7 +45,7 @@ Go through these in order, and skip any the user does not care about:
|
|
|
44
45
|
2. `billing`, from step 1;
|
|
45
46
|
3. the worker's `rungs` and its `defaultRung`;
|
|
46
47
|
4. the reviewer and the UI reviewer;
|
|
47
|
-
5. the architect and the verifier. Recommend omitted host defaults: on Codex, exactly `codex:gpt-6.1-sol#high` and `codex:gpt-6.1-sol#low`; on Claude Code, the existing native Claude defaults. A `claude:` rung requires a Claude Code host
|
|
48
|
+
5. the architect and the verifier. Recommend omitted host defaults: on Codex, exactly `codex:gpt-6.1-sol#high` and `codex:gpt-6.1-sol#low`; on Claude Code, the existing native Claude defaults. A `claude:` rung requires a Claude Code host; the daemon runs it as its headless `claude-code:` twin, and `claude-code:` is that headless rung on either host. Codex architect and verifier run as headless processes the daemon starts. Preserve explicit model IDs, efforts, ladder order and all other fields. Never silently convert `claude:` into `claude-code:` in the profile;
|
|
48
49
|
6. the writer, the researcher and the artist;
|
|
49
50
|
7. each role's `access` (below);
|
|
50
51
|
8. `failover` (below);
|
|
@@ -52,7 +53,7 @@ Go through these in order, and skip any the user does not care about:
|
|
|
52
53
|
10. harness isolation, per harness (below);
|
|
53
54
|
11. `lock.heavy` and `notify`.
|
|
54
55
|
|
|
55
|
-
Existing materialized profiles remain unchanged on read, init, upgrade or host switch. To deliberately opt into host defaults, use the existing CLI from the project directory, naming the profile returned by `
|
|
56
|
+
Existing materialized profiles remain unchanged on read, init, upgrade or host switch. To deliberately opt into host defaults, use the existing CLI from the project directory, naming the profile returned by `profile({ action: "get" })`:
|
|
56
57
|
|
|
57
58
|
```sh
|
|
58
59
|
catherd profile reset-host-defaults <profile> --host codex --preview --json > /tmp/catherd-host-defaults-review.json
|
|
@@ -64,28 +65,28 @@ Use `--host claude-code` for that host. This reviewed reset removes only archite
|
|
|
64
65
|
|
|
65
66
|
Each proposal has three parts: the change, a worked example from their facts, and the tradeoff in their terms. For instance: "Luna high on build lanes: about 5 min slower than Sol medium, no Claude quota, climbs on 1 in 5 of your runs so far."
|
|
66
67
|
|
|
67
|
-
- Offer only the rungs `
|
|
68
|
-
-
|
|
68
|
+
- Offer only the rungs `catherd catalog list` shows as capable for the role, written `backend:model#effort`.
|
|
69
|
+
- Offer only the indexed pairs `catherd catalog list` shows. A model or effort the Slopalytics index does not list is not offered, and a rung that names one is an error: if the user wants it, say it is not indexed yet and propose the nearest indexed pair. Never pick a worker rung below `#medium`. Use `maxEffort` to keep a model from its highest efforts, and `bars` to move a difficulty's bar for one role, rather than removing rungs.
|
|
69
70
|
|
|
70
|
-
**Access.** Each role runs `read-only`, `workspace-write` or `full`. The defaults: architect, reviewer and researcher `read-only`; worker, writer and artist `workspace-write`; verifier and UI reviewer `full`. `
|
|
71
|
+
**Access.** Each role runs `read-only`, `workspace-write` or `full`. The defaults: architect, reviewer and researcher `read-only`; worker, writer and artist `workspace-write`; verifier and UI reviewer `full`. `profile({ action: "get" })` says per role whether its backend holds it to that mode (`enforced`: Codex's sandbox) or only asks (`advisory`: claude-code, opencode and native subagents, where the model can still reach past it). Recommend the defaults; when the user wants a role tighter or looser, say what it can no longer do (a read-only reviewer on claude-code or opencode has no shell, so it cannot run `git diff`) and that `profile({ action: "validate" })` will warn about it. A `workspace-write` role also writes catherd's lock dir and the temp dir, reaches the network, binds loopback ports and talks to a local Docker socket, so it runs its own installs and tests; `roles.<role>.network: false` takes the network, loopback and Docker away from that role (Codex enforces it; claude-code drops its web tools; opencode has no sandbox to enforce it). `catherd doctor` probes each of these per backend.
|
|
71
72
|
|
|
72
|
-
**Failover.** `failover` maps a rung to its stand-in when that rung's backend hits a usage limit. A stand-in must be
|
|
73
|
+
**Failover.** `failover` maps a rung to its stand-in when that rung's backend hits a usage limit. A stand-in must be indexed, on another quota and at least as intelligent as its rung (Go and Zen bill apart; native `claude` and `claude-code` share the Claude plan). The default profile fails a Codex rung over only to an indexed stand-in at least as intelligent: Go's GPT-6 Luna for Luna high, and Kimi K3 for Sol medium. Sol high and xhigh have none in the profile. Beyond the profile's stand-ins, the daemon moves a unit that hit a limit to the nearest indexed rung, on a free quota, of any backend they have configured that is not weaker (a Claude rung last); when none qualifies, the lane waits for the hold rather than dropping a tier. Say so, and offer to change the profile's stand-ins when they have no Go subscription. `null` removes an entry.
|
|
73
74
|
|
|
74
|
-
**Budget and timeouts.** `budget` (`minutes`, `tokens`, `usd`) is a soft cap: from 80 % routing starts at the cheapest rung that clears the bar, and at 100 % no new role starts. `timeouts.idleMin` (15) stops a role that has gone quiet, `timeouts.wallMin` (90) one that runs too long. `preflight.confirm: true` makes `preflight` show its commands for the user to approve first.
|
|
75
|
+
**Budget and timeouts.** `budget` (`minutes`, `tokens`, `usd`) is a soft cap: from 80 % routing starts at the cheapest rung that clears the bar, and at 100 % no new role starts. `timeouts.idleMin` (15) stops a role that has gone quiet, `timeouts.wallMin` (90) one that runs too long; `roles.<role>.timeouts.idleMin` and `wallMin` override them for one role (a verifier with a long gate), and `null` removes the override. `preflight.confirm: true` makes `preflight` show its commands for the user to approve first.
|
|
75
76
|
|
|
76
|
-
**Notifications
|
|
77
|
+
**Notifications.** `notify` controls the milestone, finish and blocked moments. Where a parked question reaches the owner is `notify.url`, an ntfy topic url: set it with `profile({ action: "set", notify_url })` (ask them for the url; never invent one). The daemon sends to it from the machine, so a question reaches the phone with no session open. `catherd doctor --test-push` sends a labeled test notice.
|
|
77
78
|
|
|
78
|
-
**Harness isolation.** For each harness they use (`codex`, `claude-code`, `opencode`, `cursor
|
|
79
|
+
**Harness isolation.** For each harness they use (`codex`, `claude-code`, `opencode`, `cursor`), offer `harness.<name>.isolated` and this tradeoff: "native keeps your hooks, skills and AGENTS.md; isolated saves some tokens per run, but the role loses them." Recommend native. The session reads no harness line, so quote no number. Codex reports no per-request input, so it has no harness figure (Codex has none: it reports no per-request input).
|
|
79
80
|
|
|
80
81
|
## 4. Write it
|
|
81
82
|
|
|
82
|
-
- Call `
|
|
83
|
+
- Call `profile({ action: "set", repo, patch })` with only what changed; pass `name` only to edit a profile other than the one this repo runs on (a name that does not exist yet starts a new profile from the default one). Lists (`rungs`, `notify`) replace, maps (`billing`, `failover`, `budget`) merge, and `null` removes a key. A key it does not know is refused with `E_INPUT_INVALID`. It validates before it writes:
|
|
83
84
|
- `saved: false` comes with `errors`, each with a `path`, a `message` and often a `fix`. Explain each in their terms, fix the patch, and propose again.
|
|
84
85
|
- `saved: true` comes with the `diff` (`path`, `before`, `after`) and any `warnings`. Read the diff back to the user, one line per change, and each warning with it.
|
|
85
|
-
- Then call `
|
|
86
|
+
- Then call `profile({ action: "validate", repo })`. `errors` block a save: the worker disabled, an enabled role with no usable rung, a rung or failover stand-in the index does not list ("has no Slopalytics intelligence index"), a failover stand-in on the same quota, a backend catherd cannot run. `warnings` do not: an access mode other than the role's default, a model the backend's listing lacks, a stand-in that never runs, a stand-in less intelligent than its rung ("downgrade"), a Claude stand-in while another plan could stand in ("spends Claude quota"), a ladder whose rung is less intelligent than the one before it ("the ladder goes down"). Each has a `fix`; offer it.
|
|
86
87
|
|
|
87
88
|
## 5. Say what applies when
|
|
88
89
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
90
|
+
- Rung and ladder changes apply at the next dispatch, even in a run already under way. Access and isolation are pinned per run when it starts: a run under way keeps them until it is re-pinned (`catherd runs pin <run>`). Isolating Cursor needs `CURSOR_API_KEY` in the environment catherd runs in; `profile` validation refuses it without.
|
|
91
|
+
- Every role runs headless, so no agent file needs a new session: a change applies at the next dispatch. `newSessionNeededFor` stays empty unless a native Claude agent file is linked.
|
|
91
92
|
- ProfileService manages Claude agent files/links only when native Claude roles are used. Codex-only setup and profile operations do not write under `~/.claude`; Claude CLI/login is needed only by an enabled selected role or reachable failover that uses it. Editing an inactive Claude-dependent profile writes its managed files but links none; they apply once active or repo-bound. Keep role-disabled, access, isolation, budget and failover choices intact.
|
package/src/adapters/all.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { antigravityAdapter } from "./antigravity/index.ts";
|
|
2
1
|
import { claudeCodeAdapter } from "./claude-code/index.ts";
|
|
3
2
|
import { codexAdapter } from "./codex/index.ts";
|
|
4
3
|
import { cursorAdapter } from "./cursor/index.ts";
|
|
5
|
-
import { grokAdapter } from "./grok/index.ts";
|
|
6
4
|
import { opencodeAdapter } from "./opencode/index.ts";
|
|
7
5
|
import { registerAdapter } from "./registry.ts";
|
|
8
6
|
|
|
@@ -10,5 +8,3 @@ registerAdapter(codexAdapter);
|
|
|
10
8
|
registerAdapter(claudeCodeAdapter);
|
|
11
9
|
registerAdapter(opencodeAdapter);
|
|
12
10
|
registerAdapter(cursorAdapter);
|
|
13
|
-
registerAdapter(grokAdapter);
|
|
14
|
-
registerAdapter(antigravityAdapter);
|
package/src/adapters/backend.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ADAPTER_IDS, Rung } from "../domain/ids.ts";
|
|
|
3
3
|
import type { BillingMode } from "../domain/cost.ts";
|
|
4
4
|
import type { Access, ExitInfo, RunStatus, Tokens } from "../domain/record.ts";
|
|
5
5
|
import type { CliResult } from "./cli.ts";
|
|
6
|
+
import type { RoleMcpContext } from "../domain/role-tools.ts";
|
|
6
7
|
type AdapterId = (typeof ADAPTER_IDS)[number];
|
|
7
8
|
|
|
8
9
|
export interface Probe {
|
|
@@ -43,6 +44,10 @@ export interface DiscoveredModel {
|
|
|
43
44
|
export interface RunRequest {
|
|
44
45
|
rung: Rung;
|
|
45
46
|
access: Access;
|
|
47
|
+
/** Native catherd roles receive a dedicated, run-bound control-plane server. */
|
|
48
|
+
roleMcp?: RoleMcpContext;
|
|
49
|
+
/** spec 1.5 plan 21: the role's TMPDIR (`<run>/scratch/<name>`), a write root besides the repo */
|
|
50
|
+
scratch?: string;
|
|
46
51
|
/** spec §5: a workspace-write role's network and loopback grants; false only when the profile says `network: false` */
|
|
47
52
|
network?: boolean;
|
|
48
53
|
thread: string | null;
|
|
@@ -82,6 +87,11 @@ export interface EventDelta {
|
|
|
82
87
|
limit?: boolean;
|
|
83
88
|
tooOld?: boolean;
|
|
84
89
|
retrying?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* plan 23: a model step started (opencode's step_start). Two in a row with nothing between are a provider retry,
|
|
92
|
+
* which the supervisor never counts as progress
|
|
93
|
+
*/
|
|
94
|
+
step?: boolean;
|
|
85
95
|
/** the stream's terminal event: the supervisor may kill a CLI that lingers after it */
|
|
86
96
|
final?: boolean;
|
|
87
97
|
/** a tool call starting (`open`) or ending: while one is open the run is busy, however quiet */
|
|
@@ -147,14 +157,20 @@ export interface BackendAdapter {
|
|
|
147
157
|
interrupt?(thread: string, cwd: string): Promise<void>;
|
|
148
158
|
/** `sinceMs`: when this run started, so what an earlier run on the thread left behind does not count */
|
|
149
159
|
isBusy?(thread: string, cwd: string, sinceMs?: number): Promise<boolean>;
|
|
160
|
+
/**
|
|
161
|
+
* Plan 23: the provider retry the session is waiting out, by its attempt number, when its newest message since
|
|
162
|
+
* `sinceMs` is retrying (a 503, an overloaded backend); null when it is not
|
|
163
|
+
*/
|
|
164
|
+
providerRetry?(thread: string, cwd: string, sinceMs: number): Promise<number | null>;
|
|
150
165
|
/** Spec §4.5: this backend's own stand-in for a rung on a usage limit, when the profile names none. */
|
|
151
166
|
failoverFor?(rung: Rung, repo?: string): Rung | null;
|
|
152
167
|
/**
|
|
153
168
|
* Spec §5 and §12: a shell that runs a command the way this backend's workspace-write worker runs one,
|
|
154
169
|
* with the grants the worker gets, for doctor's access probes; a string says why it cannot be tested here.
|
|
155
|
-
* Absent: the CLI has no way to run a shell in its sandbox without a model turn (spec 1.3 §3.4).
|
|
170
|
+
* Absent: the CLI has no way to run a shell in its sandbox without a model turn (spec 1.3 §3.4). `repos`: the
|
|
171
|
+
* repositories workers run in (doctor's own and every bound one), for a backend whose sandbox is set per repo.
|
|
156
172
|
*/
|
|
157
|
-
accessShell?(o: { network: boolean }): Promise<AccessShell | string>;
|
|
173
|
+
accessShell?(o: { network: boolean; repos?: string[] }): Promise<AccessShell | string>;
|
|
158
174
|
/** Spec §10.3: why this backend's isolation is weak; doctor warns when a profile uses it. */
|
|
159
175
|
isolationNote?: string;
|
|
160
176
|
/**
|
|
@@ -163,8 +179,7 @@ export interface BackendAdapter {
|
|
|
163
179
|
*/
|
|
164
180
|
isolationKey?: string;
|
|
165
181
|
/**
|
|
166
|
-
* Spec 1.3 §9 Q2: the access modes this backend holds a role to only when isolated (
|
|
167
|
-
* its deny rules live in the settings catherd writes in its own home). A native role at one does not validate.
|
|
182
|
+
* Spec 1.3 §9 Q2: the access modes this backend holds a role to only when isolated (one with no read-only flag). A native role at one does not validate.
|
|
168
183
|
*/
|
|
169
184
|
isolatedOnly?: Access[];
|
|
170
185
|
/** Spec 1.3 §6.6: the plan quota left, in the CLI's words, read without spending a model turn (doctor's row). */
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
import { claudeHome } from "../../infra/paths.ts";
|
|
19
|
+
import { ROLE_MCP_SERVER, roleMcpTools } from "../../domain/role-tools.ts";
|
|
20
|
+
import { roleMcpConfig } from "../../infra/role-mcp.ts";
|
|
19
21
|
import { dockerSocket, scratchShell, writableRoots } from "../access.ts";
|
|
20
22
|
import { jsonOf, runCli } from "../cli.ts";
|
|
21
23
|
import {
|
|
@@ -74,15 +76,21 @@ export const CLAUDE_ACCESS: Record<Access, string[]> = {
|
|
|
74
76
|
* them Docker: the socket and `docker *` are network grants) and sets `allowLocalBinding: false`, so the
|
|
75
77
|
* user's own `true` does not carry over (their allowedDomains and other array grants merge in and stay;
|
|
76
78
|
* doctor says `network: false` is not enforced by claude-code's shell). With the user's sandbox on, `enabled: true`
|
|
77
|
-
* goes in too, so a merge that replaces the whole `sandbox` object cannot turn it off.
|
|
79
|
+
* goes in too, so a merge that replaces the whole `sandbox` object cannot turn it off. A `repo` of null reads the
|
|
80
|
+
* user's settings only: a run that drops the project's settings files (`--setting-sources ""`).
|
|
78
81
|
*/
|
|
79
|
-
export function claudeAccessArgs(
|
|
82
|
+
export function claudeAccessArgs(
|
|
83
|
+
access: Access,
|
|
84
|
+
network = true,
|
|
85
|
+
repo?: string | null,
|
|
86
|
+
extra: string[] = [],
|
|
87
|
+
): string[] {
|
|
80
88
|
const base = CLAUDE_ACCESS[access];
|
|
81
89
|
if (access !== "workspace-write") return base;
|
|
82
90
|
const sock = dockerSocket();
|
|
83
91
|
const sandbox = {
|
|
84
92
|
...(claudeSandboxOn(repo) ? { enabled: true } : {}),
|
|
85
|
-
filesystem: { allowWrite: writableRoots() },
|
|
93
|
+
filesystem: { allowWrite: [...new Set([...writableRoots(), ...extra])] },
|
|
86
94
|
...(network
|
|
87
95
|
? {
|
|
88
96
|
network: { allowLocalBinding: true, ...(sock ? { allowUnixSockets: [sock] } : {}) },
|
|
@@ -113,12 +121,14 @@ function sandboxEnabledIn(file: string): boolean | undefined {
|
|
|
113
121
|
* Whether Claude Code's Bash sandbox is on for a worker in `repo` (`sandbox.enabled`): the most specific
|
|
114
122
|
* settings file that says wins, as Claude Code layers them: the user's settings.json, then the project's
|
|
115
123
|
* .claude/settings.json and .claude/settings.local.json (Claude Code has no user-level settings.local.json).
|
|
124
|
+
* A `repo` of null reads the user's settings.json only.
|
|
116
125
|
*/
|
|
117
|
-
export function claudeSandboxOn(repo: string = process.cwd()): boolean {
|
|
126
|
+
export function claudeSandboxOn(repo: string | null = process.cwd()): boolean {
|
|
118
127
|
const files = [
|
|
119
128
|
join(claudeHome(), "settings.json"),
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
...(repo === null
|
|
130
|
+
? []
|
|
131
|
+
: [join(repo, ".claude", "settings.json"), join(repo, ".claude", "settings.local.json")]),
|
|
122
132
|
];
|
|
123
133
|
return files.map(sandboxEnabledIn).findLast((on) => on !== undefined) ?? false;
|
|
124
134
|
}
|
|
@@ -128,17 +138,114 @@ export function claudeSandboxOn(repo: string = process.cwd()): boolean {
|
|
|
128
138
|
* shell, which doctor probes as is. With it on, only a model turn runs inside it, so doctor says what to
|
|
129
139
|
* check instead of spending one.
|
|
130
140
|
*/
|
|
131
|
-
async function accessShell(): Promise<AccessShell | string> {
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
async function accessShell(o: { repos?: string[] } = {}): Promise<AccessShell | string> {
|
|
142
|
+
// the setting is per repo (its .claude/settings*.json over the user's): each repo a worker runs in counts,
|
|
143
|
+
// not only the directory doctor runs in
|
|
144
|
+
const repos = o.repos?.length ? o.repos : [process.cwd()];
|
|
145
|
+
const on = repos.filter((r) => claudeSandboxOn(r));
|
|
146
|
+
if (on.length)
|
|
147
|
+
return `Claude Code's own sandbox is on (sandbox.enabled)${o.repos?.length ? ` in ${on.join(", ")}` : ""}: catherd passes the lock, temp, loopback and Docker grants in --settings; outbound HTTPS reaches only sandbox.network.allowedDomains, so add registry.npmjs.org and the hosts your checks need there`;
|
|
134
148
|
return scratchShell("an unsandboxed shell (Claude Code's sandbox is off)", []);
|
|
135
149
|
}
|
|
136
150
|
|
|
151
|
+
/**
|
|
152
|
+
* An isolated run without the user's customizations. --bare would also drop OAuth, so a Claude plan could not
|
|
153
|
+
* log in; --safe-mode keeps auth, but drops every --mcp-config server too (Claude Code 2.1.287: "--mcp-config:
|
|
154
|
+
* … ignored (safe mode)"). A run with the role server (spec 1.5 plan 21, #42 finding 1) gets the same isolation
|
|
155
|
+
* piece by piece instead: only the --mcp-config servers, no settings file (so no hooks, no enabled plugins), no
|
|
156
|
+
* skills, CLAUDE.md and auto-memory off through the env, and the user's auth, provider, model, deny rules and
|
|
157
|
+
* allowed domains carried into --settings (carriedUserSettings).
|
|
158
|
+
*/
|
|
159
|
+
/** The user settings keys --setting-sources "" would drop that a run needs: auth, provider and model. */
|
|
160
|
+
const CARRIED_SETTINGS = [
|
|
161
|
+
"apiKeyHelper",
|
|
162
|
+
"env",
|
|
163
|
+
"awsAuthRefresh",
|
|
164
|
+
"awsCredentialExport",
|
|
165
|
+
"gcpAuthRefresh",
|
|
166
|
+
"model",
|
|
167
|
+
] as const;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* What an isolated run with the role server keeps of the user's settings.json (plan 21 review, finding 1):
|
|
171
|
+
* --safe-mode keeps the settings files and drops only customizations, while `--setting-sources ""` drops the
|
|
172
|
+
* files, so a Bedrock, Vertex, gateway or apiKeyHelper login would fail. Carried: the auth and provider keys,
|
|
173
|
+
* `model`, `permissions.deny` and `sandbox.network`; never hooks, plugins, allow rules or the rest.
|
|
174
|
+
*/
|
|
175
|
+
function carriedUserSettings(): Record<string, unknown> {
|
|
176
|
+
let user: Record<string, any>;
|
|
177
|
+
try {
|
|
178
|
+
user = JSON.parse(readFileSync(join(claudeHome(), "settings.json"), "utf8"));
|
|
179
|
+
} catch {
|
|
180
|
+
return {};
|
|
181
|
+
}
|
|
182
|
+
if (!user || typeof user !== "object") return {};
|
|
183
|
+
const out: Record<string, unknown> = {};
|
|
184
|
+
for (const k of CARRIED_SETTINGS) if (user[k] !== undefined) out[k] = user[k];
|
|
185
|
+
const deny = user.permissions?.deny;
|
|
186
|
+
if (Array.isArray(deny) && deny.length) out.permissions = { deny };
|
|
187
|
+
const network = user.sandbox?.network;
|
|
188
|
+
if (network && typeof network === "object") out.sandbox = { network };
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** `--settings` with the user's carried keys merged under catherd's own: catherd's sandbox grants win. */
|
|
193
|
+
function withCarriedSettings(args: string[]): string[] {
|
|
194
|
+
const carried = carriedUserSettings();
|
|
195
|
+
if (!Object.keys(carried).length) return args;
|
|
196
|
+
const at = args.indexOf("--settings");
|
|
197
|
+
const own: Record<string, any> = at >= 0 ? JSON.parse(args[at + 1] as string) : {};
|
|
198
|
+
const userNet: Record<string, unknown> = (carried.sandbox as any)?.network ?? {};
|
|
199
|
+
const ownNet: Record<string, unknown> = own.sandbox?.network ?? {};
|
|
200
|
+
const sockets = [
|
|
201
|
+
...((userNet.allowUnixSockets as string[] | undefined) ?? []),
|
|
202
|
+
...((ownNet.allowUnixSockets as string[] | undefined) ?? []),
|
|
203
|
+
];
|
|
204
|
+
const sandbox =
|
|
205
|
+
carried.sandbox || own.sandbox
|
|
206
|
+
? {
|
|
207
|
+
sandbox: {
|
|
208
|
+
...own.sandbox,
|
|
209
|
+
network: {
|
|
210
|
+
...userNet,
|
|
211
|
+
...ownNet,
|
|
212
|
+
...(sockets.length ? { allowUnixSockets: [...new Set(sockets)] } : {}),
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
: {};
|
|
217
|
+
const json = JSON.stringify({ ...carried, ...own, ...sandbox });
|
|
218
|
+
if (at < 0) return [...args, "--settings", json];
|
|
219
|
+
const out = [...args];
|
|
220
|
+
out[at + 1] = json;
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function isolationArgs(r: RunRequest): string[] {
|
|
225
|
+
if (!r.roleMcp) return ["--safe-mode"];
|
|
226
|
+
return ["--strict-mcp-config", "--setting-sources", "", "--disable-slash-commands"];
|
|
227
|
+
}
|
|
228
|
+
|
|
137
229
|
function plan(r: RunRequest): SpawnPlan {
|
|
138
230
|
if (r.thread !== null && !THREAD.test(r.thread))
|
|
139
231
|
throw new CatherdError("E_ADMIT_THREAD", `"${r.thread}" is not a Claude Code session id`, {
|
|
140
232
|
fix: "pass the thread from the earlier RunRecord",
|
|
141
233
|
});
|
|
234
|
+
// isolated with the role server, `--setting-sources ""` drops the project's settings (its network grants too),
|
|
235
|
+
// so only the user's carried settings.json decides whether the sandbox is on (PR #46)
|
|
236
|
+
const carried = r.isolated && !!r.roleMcp;
|
|
237
|
+
const access = claudeAccessArgs(r.access, r.network, carried ? null : r.repo, r.scratch ? [r.scratch] : []);
|
|
238
|
+
const accessArgs = carried ? withCarriedSettings(access) : [...access];
|
|
239
|
+
if (r.roleMcp) {
|
|
240
|
+
const tools = roleMcpTools(r.roleMcp.role).map((tool) => `mcp__${ROLE_MCP_SERVER}__${tool}`);
|
|
241
|
+
const allowed = accessArgs.indexOf("--allowedTools");
|
|
242
|
+
if (allowed >= 0) accessArgs[allowed + 1] = [accessArgs[allowed + 1], ...tools].join(",");
|
|
243
|
+
else accessArgs.push("--allowedTools", tools.join(","));
|
|
244
|
+
accessArgs.push(
|
|
245
|
+
"--mcp-config",
|
|
246
|
+
JSON.stringify({ mcpServers: { [ROLE_MCP_SERVER]: roleMcpConfig(r.roleMcp) } }),
|
|
247
|
+
);
|
|
248
|
+
}
|
|
142
249
|
return {
|
|
143
250
|
cmd: "claude",
|
|
144
251
|
args: [
|
|
@@ -154,11 +261,14 @@ function plan(r: RunRequest): SpawnPlan {
|
|
|
154
261
|
...(r.thread === null ? ["--session-id", crypto.randomUUID()] : ["--resume", r.thread]),
|
|
155
262
|
"--permission-prompts",
|
|
156
263
|
"none",
|
|
157
|
-
...
|
|
158
|
-
|
|
159
|
-
...(r.isolated ? ["--safe-mode"] : []),
|
|
264
|
+
...accessArgs,
|
|
265
|
+
...(r.isolated ? isolationArgs(r) : []),
|
|
160
266
|
],
|
|
161
|
-
|
|
267
|
+
// CLAUDE.md and auto-memory off, as --safe-mode turns them off (spec 1.5 plan 21)
|
|
268
|
+
env:
|
|
269
|
+
r.isolated && r.roleMcp
|
|
270
|
+
? { CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" }
|
|
271
|
+
: {},
|
|
162
272
|
cwd: r.repo,
|
|
163
273
|
stdinPath: r.briefPath,
|
|
164
274
|
};
|
|
@@ -232,7 +342,9 @@ function claudeActivity(e: Record<string, any>): string | undefined {
|
|
|
232
342
|
if (typeof input.command === "string") return `$ ${input.command}`;
|
|
233
343
|
if (typeof input.file_path === "string")
|
|
234
344
|
return `${EDIT_TOOLS.has(c.name) ? "edit" : String(c.name)} ${input.file_path}`;
|
|
235
|
-
|
|
345
|
+
// another tool shows its first string argument, as opencode's activity does
|
|
346
|
+
const first = Object.values(input).find((v) => typeof v === "string");
|
|
347
|
+
return `${String(c.name ?? "tool")}${typeof first === "string" ? ` ${first}` : ""}`;
|
|
236
348
|
}
|
|
237
349
|
if (c?.type === "text" && typeof c.text === "string") return c.text;
|
|
238
350
|
return undefined;
|
|
@@ -8,6 +8,8 @@ export interface CodexFold {
|
|
|
8
8
|
limit: boolean;
|
|
9
9
|
tooOld: boolean;
|
|
10
10
|
lastEvent: string | null;
|
|
11
|
+
/** plan 22: the agent message that ended each completed turn, in order */
|
|
12
|
+
finals: string[];
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
@@ -43,10 +45,18 @@ export function foldCodexEvents(lines: string[]): CodexFold {
|
|
|
43
45
|
limit: false,
|
|
44
46
|
tooOld: false,
|
|
45
47
|
lastEvent: null,
|
|
48
|
+
finals: [],
|
|
46
49
|
};
|
|
50
|
+
let said: string | null = null;
|
|
47
51
|
for (const line of lines) {
|
|
48
52
|
const e = parseCodexLine(line);
|
|
49
53
|
if (!e) continue;
|
|
54
|
+
if (e.type === "item.completed" && e.item?.type === "agent_message" && typeof e.item.text === "string")
|
|
55
|
+
said = e.item.text;
|
|
56
|
+
if (e.type === "turn.completed" && said !== null) {
|
|
57
|
+
f.finals.push(said);
|
|
58
|
+
said = null;
|
|
59
|
+
}
|
|
50
60
|
f.lastEvent = e.item?.type ? `${e.type}/${e.item.type}` : e.type;
|
|
51
61
|
const msg: string = e.message ?? e.error?.message ?? e.item?.message ?? "";
|
|
52
62
|
if (CODEX_TOO_OLD.some((r) => r.test(msg))) f.tooOld = true;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { codexRoleMcpArgs } from "../../infra/role-mcp.ts";
|
|
3
4
|
import { CatherdError } from "../../domain/errors.ts";
|
|
4
5
|
import type { Access, RunStatus } from "../../domain/record.ts";
|
|
6
|
+
import { composeReply } from "../../domain/reply.ts";
|
|
5
7
|
import {
|
|
6
8
|
type AccessShell,
|
|
7
9
|
type BackendAdapter,
|
|
@@ -57,9 +59,14 @@ export function userWritableRoots(): string[] {
|
|
|
57
59
|
* The same `-c` overrides go to `codex sandbox` in doctor's probes, so doctor tests exactly what a worker gets. `-c …writable_roots=` replaces the
|
|
58
60
|
* user's own roots, so theirs go in too; an isolated run ignores the user's config, so it has none.
|
|
59
61
|
*/
|
|
60
|
-
export function codexGrants(
|
|
62
|
+
export function codexGrants(
|
|
63
|
+
access: Access,
|
|
64
|
+
network = true,
|
|
65
|
+
isolated = false,
|
|
66
|
+
extra: string[] = [],
|
|
67
|
+
): string[] {
|
|
61
68
|
if (access !== "workspace-write") return [];
|
|
62
|
-
const roots = [...new Set([...(isolated ? [] : userWritableRoots()), ...writableRoots()])];
|
|
69
|
+
const roots = [...new Set([...(isolated ? [] : userWritableRoots()), ...writableRoots(), ...extra])];
|
|
63
70
|
return [
|
|
64
71
|
"-c",
|
|
65
72
|
`sandbox_workspace_write.network_access=${network}`,
|
|
@@ -89,7 +96,8 @@ function plan(r: RunRequest): SpawnPlan {
|
|
|
89
96
|
"--json",
|
|
90
97
|
"-o",
|
|
91
98
|
r.replyPath,
|
|
92
|
-
...codexGrants(r.access, r.network, r.isolated),
|
|
99
|
+
...codexGrants(r.access, r.network, r.isolated, r.scratch ? [r.scratch] : []),
|
|
100
|
+
...(r.roleMcp ? codexRoleMcpArgs(r.roleMcp) : []),
|
|
93
101
|
];
|
|
94
102
|
const sandbox = SANDBOX[r.access];
|
|
95
103
|
const args =
|
|
@@ -125,6 +133,7 @@ function finalize(run: FinishedRun): Outcome {
|
|
|
125
133
|
: "ok";
|
|
126
134
|
const lastErr = run.stderr.trim().split("\n").at(-1) ?? "";
|
|
127
135
|
const home = run.request.isolated ? isolatedCodexHomePath() : userCodexHome();
|
|
136
|
+
const reply = composeReply(f.finals, run.reply);
|
|
128
137
|
return {
|
|
129
138
|
status,
|
|
130
139
|
thread: f.thread ?? run.request.thread,
|
|
@@ -138,6 +147,8 @@ function finalize(run: FinishedRun): Outcome {
|
|
|
138
147
|
code: status,
|
|
139
148
|
message: f.failure ?? (lastErr || `${stopped}, exit ${run.exit.code ?? run.exit.signal}`),
|
|
140
149
|
},
|
|
150
|
+
// plan 22: -o keeps the last turn's message; a later turn never overwrites the report
|
|
151
|
+
...(reply !== run.reply ? { reply } : {}),
|
|
141
152
|
};
|
|
142
153
|
}
|
|
143
154
|
|
|
@@ -243,7 +254,7 @@ function codexActivity(e: Record<string, any>): string | undefined {
|
|
|
243
254
|
return `edit ${it.changes
|
|
244
255
|
.map((c: { path?: unknown }) => c.path)
|
|
245
256
|
.filter((p: unknown) => typeof p === "string")
|
|
246
|
-
.join(", ")}
|
|
257
|
+
.join(", ")}`.trimEnd();
|
|
247
258
|
if (it.type === "agent_message" && typeof it.text === "string") return it.text;
|
|
248
259
|
return undefined;
|
|
249
260
|
}
|
|
@@ -263,12 +274,13 @@ export const codexAdapter: BackendAdapter = {
|
|
|
263
274
|
// Not a todo_list: update_plan opens one that only completes with the turn, and would mute the watchdog
|
|
264
275
|
const id = typeof e.item?.id === "string" && CODEX_TOOL_ITEMS.has(e.item.type) ? e.item.id : null;
|
|
265
276
|
const open = e.type === "item.started" ? true : e.type === "item.completed" ? false : null;
|
|
277
|
+
const activity = codexActivity(e);
|
|
266
278
|
return {
|
|
267
279
|
...(f.thread ? { thread: f.thread } : {}),
|
|
268
280
|
...(id !== null && open !== null ? { item: { id, open } } : {}),
|
|
269
281
|
...(e.type === "turn.completed" ? { tokens: f.tokens } : {}),
|
|
270
282
|
lastEvent: f.lastEvent ?? undefined,
|
|
271
|
-
...(
|
|
283
|
+
...(activity ? { activity } : {}),
|
|
272
284
|
...(f.turnFailed ? { failure: f.failure ?? "turn failed" } : {}),
|
|
273
285
|
...(f.limit ? { limit: true } : {}),
|
|
274
286
|
...(f.tooOld ? { tooOld: true } : {}),
|
|
@@ -18,7 +18,7 @@ export const isolatedCursorHome = (access: Access, network = true): string =>
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The env of an isolated run: the moved HOME (the only thing that stops Cursor's hard-coded `~/.claude`,
|
|
21
|
-
* `~/.codex
|
|
21
|
+
* `~/.codex` and `~/.agents` reads, research §2.8), and Cursor's config and data dirs inside it, so a
|
|
22
22
|
* CURSOR_CONFIG_DIR or XDG_CONFIG_HOME of the user's cannot point it back. Its credentials stay in memory: on
|
|
23
23
|
* macOS Cursor otherwise saves the CURSOR_API_KEY login to the moved HOME's keychain, which does not exist, and
|
|
24
24
|
* the failed `security` call raises a "Keychain Not Found" dialog.
|
|
@@ -39,7 +39,7 @@ export { isolatedCursorHome, isolatedCursorRoot } from "./home.ts";
|
|
|
39
39
|
export const CURSOR_MIN_VERSION = "2026.09.28";
|
|
40
40
|
export const CURSOR_INSTALL = "curl https://cursor.com/install -fsS | bash";
|
|
41
41
|
const THREAD = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
42
|
-
/** Cursor's versions are a date and a hash (`2026.09.28-64d2043`)
|
|
42
|
+
/** Cursor's versions are a date and a hash (`2026.09.28-64d2043`). */
|
|
43
43
|
const CURSOR_VERSION = /^\s*\d{4}\.\d{1,2}\.\d{1,2}-[0-9a-f]+\b/;
|
|
44
44
|
const DAY_MS = 24 * 60 * 60_000;
|
|
45
45
|
const LOGIN_FIX = "cursor-agent login, or export CURSOR_API_KEY=<key>";
|
|
@@ -50,7 +50,7 @@ export const cursorShell = { timeoutMs: 15_000 };
|
|
|
50
50
|
const which = (bin: string): string | null => Bun.which(bin, { PATH: process.env.PATH ?? "" });
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Spec 1.3 §4.1: `cursor-agent` first.
|
|
53
|
+
* Spec 1.3 §4.1: `cursor-agent` first. Another CLI's installer may also link `agent` (research §2.1,
|
|
54
54
|
* §3.1), so `agent` is taken only when `cursor-agent` is missing, and the probe checks what it is.
|
|
55
55
|
*/
|
|
56
56
|
export function cursorBin(): "cursor-agent" | "agent" {
|
|
@@ -100,7 +100,13 @@ function plan(r: RunRequest): SpawnPlan {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async function listModels(): Promise<DiscoveredModel[]> {
|
|
103
|
-
const
|
|
103
|
+
const bin = cursorBin();
|
|
104
|
+
// an `agent` that is not Cursor's (another CLI's) is never asked for models: nothing to list, as when absent
|
|
105
|
+
if (bin === "agent") {
|
|
106
|
+
const v = await runCli(bin, ["--version"], cursorShell).catch(() => null);
|
|
107
|
+
if (!v || !CURSOR_VERSION.test(v.out)) return [];
|
|
108
|
+
}
|
|
109
|
+
const r = await runCli(bin, ["models"], { ...cursorShell, env: { NO_OPEN_BROWSER: "1" } });
|
|
104
110
|
return r?.ok ? parseCursorModels(r.out) : [];
|
|
105
111
|
}
|
|
106
112
|
|
|
@@ -213,7 +219,7 @@ async function probe(): Promise<Probe> {
|
|
|
213
219
|
try {
|
|
214
220
|
v = await runCli(bin, ["--version"], cursorShell);
|
|
215
221
|
} catch (e) {
|
|
216
|
-
// an `agent` that is not Cursor's may not even run here (
|
|
222
|
+
// an `agent` that is not Cursor's may not even run here (a Linux build on macOS, research §3.1)
|
|
217
223
|
if (bin === "agent") v = { ok: false, out: "", err: String(e) };
|
|
218
224
|
else throw e;
|
|
219
225
|
}
|