Commit 03f49e9
feat(desktop): add Codex (GPT-5.5) as a local-CLI harness (#492)
## What
Adds **Codex (GPT-5.5)** as a third pluggable agent harness in Freebuff
Desktop, alongside Claude Code and the hosted Freebuff agent. It drives
the user's **local, ChatGPT-authenticated Codex CLI** via
`@openai/codex-sdk` — reusing `~/.codex` login with no key plumbing,
exactly like the Claude Code harness reuses the Anthropic subscription.
## How it works
- **Model picker** gains a CODEX group (GPT-5.5). The per-thread pick
persists (schema **v16** `codex_model`). The `-codex` model variants are
rejected because they 400 on ChatGPT-account auth.
- **Rendering**: Codex's JSONL events fold into the shared `parts` model
— reasoning, assistant messages, and tool calls (`command_execution` /
`file_change` / `mcp_tool_call` / `web_search`) render in stream order
with friendly labels (`formatTool`).
- **Auth**: reuses `~/.codex/auth.json` (strips
`OPENAI_API_KEY`/`CODEX_API_KEY` so the subscription login wins).
Signed-out → a `codex-auth` recovery card (Open Terminal + copy `codex
login`), mirroring the Claude Code card.
- **Freebuff custom tools** (`suggest_prompts` / `write_doc` /
`browser_check`): Codex has no in-process tool transport, so each turn
hosts a tiny **dependency-free localhost streamable-HTTP MCP server**
bound to that turn's `toolDeps`, wired via `config.mcp_servers`. (The
MCP SDK is deliberately avoided — the monorepo pins zod v4 and the SDK
needs v3.)
- **Not bundled**: the ~240 MB platform binary is too heavy to ship, so
we use the user's **installed** codex. When none is available, the
picker shows the Codex agent **disabled** ("Not installed", with an
install tooltip) and the agent route rejects the pick.
`FREEBUFF_CODEX_DISABLED=1` is an ops/test kill-switch.
## Autonomy
Runs with `sandbox = danger-full-access` + `approval = never` — the
analog of Claude Code's `bypassPermissions` (each thread is an isolated
worktree). `workspace-write` invokes Codex's own macOS seatbelt, which
SIGKILLs under nested sandboxing.
## Verification
Driven end-to-end against a real, isolated orchestrator (fresh `HOME`,
scratch repo):
- ✅ CODEX picker group renders; GPT-5.5 selectable & persists; invalid
model rejected (400).
- ✅ A real turn ran on Codex — tool calls + assistant messages render in
order; file created.
- ✅ `suggest_prompts` MCP tool round-trips → suggestion parked in the
thread queue.
- ✅ Resume carries context across turns.
- ✅ Signed-out CLI → `codex-auth` recovery card.
- ✅ Unavailable → Codex option `disabled=True` + route 400; available →
`disabled=False` + 200.
- ✅ **226 desktop tests pass**; both tsconfigs typecheck; UI builds.
## Notes / follow-ups
- Adds `@openai/codex-sdk` (which pulls the platform `@openai/codex`
binary in dev).
- In dev, `@openai/codex` is in `node_modules` so the SDK self-resolves;
a packaged build with no installed codex → the disabled flow applies.
- `scripts/codex-smoke.ts` added as a dev harness (mirrors
`claude-smoke.ts`).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent e7e906c commit 03f49e9
23 files changed
Lines changed: 1726 additions & 42 deletions
File tree
- freebuff-desktop
- docs
- scripts
- src
- app
- agents
- ui
- components
- lib
- store
- styles
- core
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
0 commit comments