moi-computer 0.3.0-next.2 → 0.3.0
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 +1 -1
- package/client/AGENTS.md +2 -2
- package/client/api/http.ts +1 -1
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +14 -5
- package/client/app/routes/HomeRoute.tsx +1 -1
- package/client/app/routes/WorkspaceRoute.tsx +8 -2
- package/client/app/shell/SidebarLayout.tsx +10 -5
- package/client/assets/openai.svg +3 -0
- package/client/components/shared/BottomPanel.tsx +2 -2
- package/client/components/ui/button.tsx +3 -2
- package/client/components/ui/input.tsx +1 -1
- package/client/features/applets/AppletMount.tsx +44 -0
- package/client/features/applets/WidgetShell.tsx +4 -1
- package/client/features/applets/applet-cache.ts +8 -0
- package/client/features/applets/applet-styles.ts +61 -0
- package/client/features/chat/ChatComposer.tsx +2 -2
- package/client/features/chat/ChatPanel.tsx +8 -25
- package/client/features/chat/ChatPopup.tsx +3 -3
- package/client/features/chat/{ThreadSelector.tsx → ChatSelector.tsx} +4 -4
- package/client/features/chat/TurnView.tsx +8 -9
- package/client/features/chat/api.ts +1 -1
- package/client/features/chat/chat-send.ts +57 -0
- package/client/features/chat/tool-group/ToolCallGroup.tsx +2 -1
- package/client/features/chat/tool-group/format.ts +117 -0
- package/client/features/chat/useChat.ts +10 -34
- package/client/features/connectors/McpMenu.tsx +4 -21
- package/client/features/dev/DevRoutes.tsx +18 -0
- package/client/features/dev/HarnessDebugPage.tsx +468 -0
- package/client/{components/playground → features/dev}/PlaygroundPage.tsx +1 -1
- package/client/features/home/CreateWorkspaceDialog.tsx +64 -158
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
- package/client/features/home/HomeLogo.tsx +344 -0
- package/client/features/home/HomePage.tsx +15 -21
- package/client/features/home/WorkspacePreview.tsx +12 -5
- package/client/features/home/api.ts +11 -3
- package/client/features/home/workspace-presentation.tsx +4 -4
- package/client/features/settings/GeneralSettings.tsx +3 -3
- package/client/features/settings/IconPicker.tsx +4 -3
- package/client/features/settings/icon-picker-options.ts +0 -131
- package/client/features/views/ViewBuilderTab.tsx +153 -0
- package/client/features/views/api.ts +124 -0
- package/client/features/views/useViewBuilderActions.ts +72 -0
- package/client/features/widgets/WidgetGrid.tsx +36 -20
- package/client/features/widgets/Widgets.tsx +140 -90
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -9
- package/client/features/workspace/WorkspaceScreen.tsx +179 -40
- package/client/features/workspace/WorkspaceTabs.tsx +4 -4
- package/client/index.css +0 -35
- package/client/index.html +1 -1
- package/client/lib/app-icon-registry.ts +145 -0
- package/client/runtime/useWorkspaceEvents.ts +3 -1
- package/client/theme.css +1 -1
- package/dist/chunk-4vf1t6v1.js +10 -0
- package/dist/chunk-4z52b2av.css +1 -0
- package/dist/chunk-6c8cwpzc.js +1 -0
- package/dist/chunk-b4b276wx.js +15 -0
- package/dist/{chunk-c4j722at.js → chunk-cs8vbert.js} +2 -2
- package/dist/chunk-fjksw6xf.js +1 -0
- package/dist/chunk-kxmvv1ax.js +48 -0
- package/dist/{chunk-p68fnz3q.js → chunk-vkvb3hjm.js} +1 -1
- package/dist/chunk-y82s1jxm.js +61 -0
- package/dist/chunk-zpxrb1ce.js +2 -0
- package/dist/index.html +2 -2
- package/dist/openai-h13pza4b.svg +3 -0
- package/lib/format.ts +2 -2
- package/lib/types.ts +38 -2
- package/lib/view-builder-meta.ts +35 -0
- package/lib/workspace-layout.ts +14 -0
- package/package.json +2 -1
- package/server/AGENTS.md +3 -3
- package/server/api.ts +165 -51
- package/server/applets.ts +1 -1
- package/server/bundle-queue.ts +19 -0
- package/server/bundler/applet-css.ts +50 -0
- package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
- package/server/cli.ts +79 -2
- package/server/control.ts +106 -8
- package/server/env-apply.ts +2 -2
- package/server/harness/README.md +228 -0
- package/server/harness/claude-code/NOTES.md +578 -0
- package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
- package/server/harness/claude-code/index.ts +124 -0
- package/server/{mcp.ts → harness/claude-code/mcp.ts} +1 -1
- package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
- package/server/harness/claude-code/sessions.ts +42 -0
- package/server/harness/codex/NOTES.md +326 -0
- package/server/harness/codex/adapter.ts +414 -0
- package/server/harness/codex/client.ts +343 -0
- package/server/harness/codex/index.ts +68 -0
- package/server/harness/codex/probe.ts +186 -0
- package/server/harness/codex/session.ts +617 -0
- package/server/harness/debug.ts +57 -0
- package/server/harness/openclaw/NOTES.md +316 -0
- package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
- package/server/harness/openclaw/index.ts +93 -0
- package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
- package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
- package/server/harness/registry.ts +36 -0
- package/server/harness/types.ts +87 -0
- package/server/layout.ts +6 -12
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +14 -52
- package/server/state.ts +5 -38
- package/server/status.ts +7 -46
- package/server/vendor.ts +1 -1
- package/server/view-builders.ts +428 -0
- package/server/views.ts +0 -0
- package/server/web.ts +18 -40
- package/server/workspace-init.ts +6 -6
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
- package/client/assets/hermes-nous.png +0 -0
- package/client/hooks/useScrollFade.ts +0 -38
- package/dist/chunk-23cgr1tz.css +0 -1
- package/dist/chunk-3hy3qy6d.js +0 -10
- package/dist/chunk-dyfaffyz.js +0 -119
- package/dist/chunk-kpe40hm8.js +0 -1
- package/dist/chunk-ty6dvda0.js +0 -1
- package/dist/hermes-nous-pznd63x9.png +0 -0
- /package/client/{components/playground → features/dev}/PixelPainter.tsx +0 -0
- /package/client/{components/playground → features/dev}/ToolCallsPage.tsx +0 -0
- /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
- /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
- /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# Codex — integration research
|
|
2
|
+
|
|
3
|
+
Research notes on driving OpenAI Codex as a moi harness (July 2026). The
|
|
4
|
+
adapter shipped on the app-server path recommended below — see §5 for what
|
|
5
|
+
implementation against CLI 0.144.5 confirmed/corrected. Codex exposes **two**
|
|
6
|
+
programmable surfaces, and they differ enough that the choice shapes the
|
|
7
|
+
whole adapter:
|
|
8
|
+
|
|
9
|
+
1. **`@openai/codex-sdk`** (npm, TypeScript) — a thin wrapper that spawns
|
|
10
|
+
`codex exec` as a fresh subprocess per turn.
|
|
11
|
+
2. **`codex app-server`** — a long-lived JSON-RPC 2.0 server bundled with the
|
|
12
|
+
CLI; the protocol behind the official VS Code extension.
|
|
13
|
+
|
|
14
|
+
**Recommendation: target the app-server.** The exec SDK is missing too much
|
|
15
|
+
(no interrupt method, no model list, no token deltas, no steering); the
|
|
16
|
+
app-server covers essentially the whole adapter checklist in
|
|
17
|
+
[../README.md](../README.md) and even exceeds the Claude Agent SDK in places.
|
|
18
|
+
|
|
19
|
+
Sources: [SDK TypeScript source](https://github.com/openai/codex/tree/main/sdk/typescript/src),
|
|
20
|
+
[app-server README](https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md),
|
|
21
|
+
[Codex SDK docs](https://developers.openai.com/codex/sdk).
|
|
22
|
+
|
|
23
|
+
## 1. The exec SDK (`@openai/codex-sdk`)
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const codex = new Codex({ env, config }) // env REPLACES process.env, not merged
|
|
27
|
+
const thread = codex.startThread({
|
|
28
|
+
model,
|
|
29
|
+
sandboxMode,
|
|
30
|
+
workingDirectory,
|
|
31
|
+
modelReasoningEffort,
|
|
32
|
+
approvalPolicy
|
|
33
|
+
})
|
|
34
|
+
const { events } = await thread.runStreamed(input, { outputSchema, signal })
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Every `run()`/`runStreamed()` spawns `codex exec` (`resume <threadId>` after
|
|
38
|
+
the first turn) and exits when the turn ends. Thread state persists in
|
|
39
|
+
`~/.codex/sessions`; the in-memory `Thread` is just an id + options.
|
|
40
|
+
- Because each turn is a new process, _every_ setting is effectively per-turn
|
|
41
|
+
(`resumeThread(id, newOptions)`) — but there's also no live process to
|
|
42
|
+
interrupt (`AbortSignal` kills it) or steer.
|
|
43
|
+
- Events are **item-level**, not token-level: `thread.started`, `turn.started`,
|
|
44
|
+
`item.started/updated/completed`, `turn.completed { usage }`, `turn.failed`.
|
|
45
|
+
Item union: `agent_message`, `reasoning`, `command_execution` (aggregated
|
|
46
|
+
output + exit code), `file_change` (patch summary), `mcp_tool_call`,
|
|
47
|
+
`web_search`, `todo_list`, `error`.
|
|
48
|
+
- Input: plain string or `{type:"text"}` / `{type:"local_image", path}` — no
|
|
49
|
+
base64 image blocks; uploads must be materialized to disk (we already do
|
|
50
|
+
this for OpenClaw).
|
|
51
|
+
- No model list, no session list API, no MCP status probe, no approval
|
|
52
|
+
callbacks. Structured output via `outputSchema` (JSON Schema/Zod) is the one
|
|
53
|
+
feature CC lacks.
|
|
54
|
+
|
|
55
|
+
Fine for CI-style one-shot runs; too thin for a moi chat harness.
|
|
56
|
+
|
|
57
|
+
## 2. The app-server (`codex app-server`)
|
|
58
|
+
|
|
59
|
+
JSON-RPC 2.0 over **stdio** (newline-delimited JSON, `"jsonrpc"` header
|
|
60
|
+
omitted — same transport style as a stdio MCP server). Other transports
|
|
61
|
+
(unix socket, websocket) exist but stdio is the only production-supported one.
|
|
62
|
+
|
|
63
|
+
### Topology
|
|
64
|
+
|
|
65
|
+
- **One process serves N threads in N different cwds.** `cwd` is per-thread
|
|
66
|
+
(`thread/start`) and overridable per-turn. `thread/loaded/list` shows what's
|
|
67
|
+
in memory; a thread with no subscribers and no activity for 30 min is
|
|
68
|
+
unloaded (`thread/closed`). This replaces most of `claude-code/session.ts`'s
|
|
69
|
+
eviction/idle-TTL machinery.
|
|
70
|
+
- **Env vars are process-level.** There is no per-thread env injection, so
|
|
71
|
+
moi's per-workspace `workspaceEnv` doesn't map onto a single shared process.
|
|
72
|
+
Options: one app-server per workspace (env frozen at spawn, restart on env
|
|
73
|
+
change — same semantics as `restartWorkspaceSessions`), or accept
|
|
74
|
+
process-level env.
|
|
75
|
+
- Handshake: one `initialize` request per connection (with `clientInfo`), then
|
|
76
|
+
an `initialized` notification. Everything before that is rejected.
|
|
77
|
+
- The wire carries three shapes the client must route: responses (matched by
|
|
78
|
+
`id`), notifications, and **server-initiated requests** the client must
|
|
79
|
+
answer (approvals, dynamic tool calls).
|
|
80
|
+
- Backpressure: overload → error `-32001`, retry with backoff.
|
|
81
|
+
- Crash recovery: respawn + `thread/resume` (threads persist in
|
|
82
|
+
`~/.codex/sessions`).
|
|
83
|
+
|
|
84
|
+
### Core flow
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
thread/start | thread/resume | thread/fork → thread id, auto-subscribes
|
|
88
|
+
turn/start { threadId, input, model?, effort?, outputSchema?, ... }
|
|
89
|
+
← turn/started
|
|
90
|
+
← item/started / item/*/delta / item/completed (per item)
|
|
91
|
+
← turn/completed { status: completed|interrupted|failed }
|
|
92
|
+
turn/steer { expectedTurnId, input } — append input to the RUNNING turn
|
|
93
|
+
turn/interrupt { threadId, turnId }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Per-turn overrides (`model`, `effort`, `summary`, sandbox/approval policy)
|
|
97
|
+
become the thread's defaults for later turns — no drain-then-rebuild dance at
|
|
98
|
+
all. `thread/settings/update` queues setting changes without starting a turn.
|
|
99
|
+
|
|
100
|
+
### Feature map vs the adapter checklist
|
|
101
|
+
|
|
102
|
+
- **Models**: `model/list` — models with ordered `supportedReasoningEfforts`,
|
|
103
|
+
exactly what the picker needs.
|
|
104
|
+
- **Streaming**: `item/agentMessage/delta`, `item/reasoning/summaryTextDelta`
|
|
105
|
+
(+ raw `textDelta`), `item/commandExecution/outputDelta` (live command
|
|
106
|
+
output — CC has no equivalent). Per-connection opt-out via
|
|
107
|
+
`initialize.capabilities.optOutNotificationMethods`, so non-streaming mode
|
|
108
|
+
is a handshake flag, not a session rebuild.
|
|
109
|
+
- **Items**: `userMessage` (echoes our `clientUserMessageId` as `clientId` —
|
|
110
|
+
native optimistic-id rendezvous), `agentMessage`, `reasoning`
|
|
111
|
+
(summary vs raw content), `commandExecution` (cwd, exit code, duration),
|
|
112
|
+
`fileChange` (structured per-file diffs), `mcpToolCall`, `collabToolCall`
|
|
113
|
+
(subagents: spawn/send/wait/close), `webSearch`, `todoList`/`plan`
|
|
114
|
+
(`turn/plan/updated`), `imageView`, `contextCompaction`, review items.
|
|
115
|
+
Plus `turn/diff/updated` — an aggregated unified diff for the whole turn.
|
|
116
|
+
- **Approvals**: interactive server→client JSON-RPC requests
|
|
117
|
+
(`item/commandExecution/requestApproval`, `item/fileChange/requestApproval`,
|
|
118
|
+
`item/permissions/requestApproval`) answered with
|
|
119
|
+
`accept | acceptForSession | decline | cancel`. Or delegate with
|
|
120
|
+
`approvalsReviewer: "auto_review"`. Sandbox modes / named permission
|
|
121
|
+
profiles (`:read-only`, `:workspace`).
|
|
122
|
+
- **Input**: `{type:"text"}`, `{type:"image", url:"data:..."}` (inline data
|
|
123
|
+
URL — our base64 upload path works), `{type:"localImage", path}`, plus
|
|
124
|
+
skill invocation items (`{type:"skill", name, path}`).
|
|
125
|
+
- **History**: `thread/list` (cursor pagination, cwd filter, search),
|
|
126
|
+
`thread/read` (without resuming), `thread/turns/list`, archive/unarchive/
|
|
127
|
+
delete, `thread/name/set`. Replaces jsonl-scraping entirely.
|
|
128
|
+
- **MCP**: `mcpServerStatus/list` (tools + auth status — our whole `mcp.ts`
|
|
129
|
+
probe becomes one call), `mcpServer/oauth/login`, `config/mcpServer/reload`.
|
|
130
|
+
- **Usage**: `thread/tokenUsage/updated` streamed live (restored on resume);
|
|
131
|
+
`account/rateLimits/read` + `/updated`, `account/usage/read`.
|
|
132
|
+
- **Errors**: typed `codexErrorInfo` enum (`ContextWindowExceeded`,
|
|
133
|
+
`UsageLimitExceeded`, `HttpConnectionFailed{status}`, …).
|
|
134
|
+
- **Auth**: `account/read`, `account/login/start` (API key / ChatGPT OAuth /
|
|
135
|
+
device code), `account/updated` notifications.
|
|
136
|
+
- **Extras with no CC equivalent**: `review/start` (built-in reviewer),
|
|
137
|
+
`thread/shellCommand` (user `!` commands injected into the turn),
|
|
138
|
+
`command/exec` / `process/spawn` (sandboxed/unsandboxed exec with PTY),
|
|
139
|
+
`fs/*` + `fs/watch`, **dynamic client-provided tools** (`item/tool/call` —
|
|
140
|
+
the agent calls back into moi), `thread/compact/start`, structured
|
|
141
|
+
`outputSchema` per turn.
|
|
142
|
+
|
|
143
|
+
### Caveats
|
|
144
|
+
|
|
145
|
+
- Much of the surface is gated behind `capabilities.experimentalApi` or marked
|
|
146
|
+
under development (plugins, environments, realtime). The core
|
|
147
|
+
thread/turn/item/approval/model surface is stable — it's what the VS Code
|
|
148
|
+
extension runs on.
|
|
149
|
+
- Typed bindings are generated, version-matched to the installed binary:
|
|
150
|
+
`codex app-server generate-ts --out DIR` (or `generate-json-schema`).
|
|
151
|
+
|
|
152
|
+
### Binary availability (Codex Desktop caveat)
|
|
153
|
+
|
|
154
|
+
Don't assume Codex Desktop puts `codex` on PATH. The desktop app is a CLI
|
|
155
|
+
_consumer_: it resolves an external codex binary (honoring `CODEX_CLI_PATH`,
|
|
156
|
+
then PATH) and on first launch can install/update `@openai/codex` with a Node
|
|
157
|
+
runtime bundled inside the app — app-managed, not necessarily a shell-visible
|
|
158
|
+
`codex` command. Officially the CLI is a separate install (`npm i -g
|
|
159
|
+
@openai/codex`, brew, or the standalone installer). The adapter should detect
|
|
160
|
+
the binary: explicit config → `CODEX_CLI_PATH` → `codex` on PATH → error with
|
|
161
|
+
install instructions.
|
|
162
|
+
|
|
163
|
+
## 3. Client libraries
|
|
164
|
+
|
|
165
|
+
- **TypeScript: nothing official.** `@openai/codex-sdk` wraps exec only.
|
|
166
|
+
- **Python: official** — `openai-codex` on PyPI (`sdk/python` in openai/codex)
|
|
167
|
+
is a real app-server client: subprocess + stdio JSON-RPC, message router,
|
|
168
|
+
generated pydantic models, approval handler callbacks. Good design
|
|
169
|
+
reference.
|
|
170
|
+
- Community TS/JS bridges exist (see the
|
|
171
|
+
[`codex-app-server` GitHub topic](https://github.com/topics/codex-app-server))
|
|
172
|
+
but are small/young.
|
|
173
|
+
- **Plan for moi**: write the thin client ourselves (~200 lines in Bun — spawn,
|
|
174
|
+
line-split stdio, id→promise map, notification + server-request routing;
|
|
175
|
+
same pattern as `../openclaw/gateway.ts`) and use `generate-ts` for
|
|
176
|
+
types.
|
|
177
|
+
|
|
178
|
+
## 4. Adapter shape
|
|
179
|
+
|
|
180
|
+
A Codex harness would look much closer to `openclaw/session.ts` than
|
|
181
|
+
`claude-code/session.ts`: one long-lived connection to a server that owns session
|
|
182
|
+
lifecycle, subscribe per thread, map `item/*` notifications onto
|
|
183
|
+
`StreamEvent`s. Capability flags: `liveSettingsPerTurn`, `steering`,
|
|
184
|
+
`interactiveApprovals`, `nativeThreadList`, `imagesInline: 'data-url'`.
|
|
185
|
+
|
|
186
|
+
## 5. Implementation notes (shipped, CLI 0.144.5)
|
|
187
|
+
|
|
188
|
+
The adapter landed as `client.ts` (process + stdio JSON-RPC client, one
|
|
189
|
+
app-server per workspace for env injection), `adapter.ts` (item →
|
|
190
|
+
`Turn` mapping, hand-written types), and `session.ts` (per-thread
|
|
191
|
+
state, steer/interrupt, previews, usage). Empirical findings beyond §2:
|
|
192
|
+
|
|
193
|
+
- **Always pass absolute `cwd`.** A relative `thread/start.cwd` is resolved
|
|
194
|
+
against the app-server process cwd, silently nesting paths.
|
|
195
|
+
- **Deltas stream by default** — no opt-in needed; moi's `stream` flag only
|
|
196
|
+
gates forwarding them as preview frames.
|
|
197
|
+
- **Reasoning summaries need `summary: "auto"` on `turn/start`.** Without it
|
|
198
|
+
the model still reasons (nonzero `reasoningOutputTokens`) but the
|
|
199
|
+
`reasoning` item arrives with EMPTY `summary`/`content` — thinking is
|
|
200
|
+
invisible. With it, summaries stream via `item/reasoning/summaryTextDelta`
|
|
201
|
+
and land populated. Also note reasoning is adaptive: trivial prompts at low
|
|
202
|
+
effort legitimately produce no reasoning item at all.
|
|
203
|
+
- **Subagents (collab tools) work unflagged**: the parent emits
|
|
204
|
+
`collabAgentToolCall` (spawn/send/wait/close) and `subAgentActivity` items;
|
|
205
|
+
the child agent runs as its own thread whose full item stream arrives on
|
|
206
|
+
the same connection under `agentThreadId`.
|
|
207
|
+
- **`clientUserMessageId` echo confirmed**: the `userMessage` item carries it
|
|
208
|
+
as `clientId`, on live frames only. `thread/read` replay _renumbers_ item
|
|
209
|
+
ids (`item-1`, `item-2`, …) and drops `clientId`, so replayed turn ids never
|
|
210
|
+
match live ones — harmless under upsert-by-id, but don't key anything
|
|
211
|
+
durable on them.
|
|
212
|
+
- **`turn/completed` carries no items** (`itemsView: "notLoaded"`); items
|
|
213
|
+
arrive only via `item/started`/`item/completed`.
|
|
214
|
+
- **The npm `codex` bin is a Node shim** that spawns the platform binary;
|
|
215
|
+
killing the shim tears down the server via stdin EOF, so no orphans — but
|
|
216
|
+
binary detection must tolerate shim paths (`CODEX_CLI_PATH` → PATH).
|
|
217
|
+
- **User-level config bleeds in**: threads start MCP servers and hooks from
|
|
218
|
+
`~/.codex/config.toml` / `hooks.json` per thread; their failures arrive as
|
|
219
|
+
notifications (`mcpServer/startupStatus/updated`, `hook/completed`) we
|
|
220
|
+
currently ignore.
|
|
221
|
+
- `thread/start` responses label threads `source: "vscode"` — app-server
|
|
222
|
+
clients are indistinguishable from the VS Code extension in `thread/list`.
|
|
223
|
+
|
|
224
|
+
## 6. MCP servers & connectors (probed at CLI 0.144.5)
|
|
225
|
+
|
|
226
|
+
One-off probe: `bun server/harness/codex/probe.ts rpc . mcpServerStatus/list '{}'`.
|
|
227
|
+
|
|
228
|
+
### `mcpServerStatus/list` payload
|
|
229
|
+
|
|
230
|
+
`{ data: McpServerStatus[] }`, one entry per server Codex loaded:
|
|
231
|
+
|
|
232
|
+
- `name` — the registry key (config.toml table name, or injected name).
|
|
233
|
+
- `serverInfo` — the server's MCP `initialize` result (`name`, `title`,
|
|
234
|
+
`version`, `description`, `icons`, `websiteUrl`), `null` if it never
|
|
235
|
+
answered. A server can list with `serverInfo: null` and an empty `tools`
|
|
236
|
+
map and still be "configured" — that's what a dead/misbehaving remote
|
|
237
|
+
looks like (no error field).
|
|
238
|
+
- `tools` — a **map keyed by tool name**, each value a full MCP tool def:
|
|
239
|
+
`name`, `title`, `description`, `inputSchema`, `outputSchema`,
|
|
240
|
+
`annotations` (`readOnlyHint`/`destructiveHint`/`openWorldHint`), `_meta`.
|
|
241
|
+
This payload is BIG (~0.5 MB with ChatGPT connectors installed) — don't
|
|
242
|
+
fold it into anything broadcast.
|
|
243
|
+
- `resources`, `resourceTemplates` — arrays.
|
|
244
|
+
- `authStatus` — `bearerToken` (authed HTTP/OAuth), `notLoggedIn` (OAuth
|
|
245
|
+
awaiting `mcpServer/oauth/login`; the one `getCodexMcpStatus` maps to
|
|
246
|
+
`needs-auth`), `unsupported` (stdio server, no auth concept).
|
|
247
|
+
|
|
248
|
+
### `codex_apps` — the ChatGPT connector aggregator
|
|
249
|
+
|
|
250
|
+
Injected automatically when signed in with a ChatGPT account; **absent from
|
|
251
|
+
config.toml**. `serverInfo.name` is `plugin-runtime`. It flattens every
|
|
252
|
+
connector installed on the user's ChatGPT account (GitHub, Figma, Granola, …)
|
|
253
|
+
into ONE server whose tool names are dotted `<connector>.<tool>`
|
|
254
|
+
(`figma.generate_deck`). The true brand lives in each tool's `_meta`:
|
|
255
|
+
`connector_id`, `connector_name` ("Figma"), `connector_description`,
|
|
256
|
+
`link_id` (the user's authorization to that connector), plus Apps SDK widget
|
|
257
|
+
hints (`openai/outputTemplate: "ui://widget/….html"`). This is why the
|
|
258
|
+
client's `parseCodexMcp` brands dotted `codex_apps` calls by the prefix
|
|
259
|
+
before the dot, not the server name. The adapter does not currently carry
|
|
260
|
+
`_meta.connector_name` through to the `ToolCall` — icon/brand matching is
|
|
261
|
+
name-based.
|
|
262
|
+
|
|
263
|
+
### Where MCP servers can be defined (config layers)
|
|
264
|
+
|
|
265
|
+
From the 0.144.5 binary's config-layer enum, lowest to highest:
|
|
266
|
+
|
|
267
|
+
1. **User** — `$CODEX_HOME/config.toml` (`[mcp_servers.<name>]`). Shared by
|
|
268
|
+
three writers: hand edits, `codex mcp add/remove`, and other apps (the
|
|
269
|
+
ChatGPT desktop app writes `node_repl` / `computer-use` entries here).
|
|
270
|
+
2. **Profile v2** — `$CODEX_HOME/<name>.config.toml`, layered via `-p <name>`
|
|
271
|
+
(legacy `[profiles.<name>]` tables in config.toml also exist).
|
|
272
|
+
3. **Project** — `.codex/config.toml` in a trusted repo ("sandbox, MCP,
|
|
273
|
+
hooks, model, or reasoning defaults").
|
|
274
|
+
4. **Session flags** — `-c 'mcp_servers.foo.command="…"'` per invocation.
|
|
275
|
+
5. **Plugins** — an enabled plugin can provide MCP servers ("not configured
|
|
276
|
+
in config.toml or an enabled plugin").
|
|
277
|
+
6. **Account-injected** — `codex_apps` (above); server-side, no local file.
|
|
278
|
+
7. **Admin layers** — system config.toml, MDM managed preferences, legacy
|
|
279
|
+
`managed_config.toml`, and an enterprise-managed cloud layer;
|
|
280
|
+
`requirements.toml` restricts (never defines) what the others may set.
|
|
281
|
+
|
|
282
|
+
The app-server can also edit the user layer programmatically
|
|
283
|
+
(`config/value/write`, `config/batchWrite`) — unused by moi.
|
|
284
|
+
|
|
285
|
+
### The full MCP RPC surface (from the 0.144.5 binary's method enums)
|
|
286
|
+
|
|
287
|
+
Requests:
|
|
288
|
+
|
|
289
|
+
- `mcpServerStatus/list` — the registry dump above.
|
|
290
|
+
- `mcpServer/tool/call` — **direct one-off tool invocation, no model turn**:
|
|
291
|
+
`{ threadId, server, tool, arguments }` → a raw MCP `CallToolResult`
|
|
292
|
+
(`{ content: [...], isError }`). Requires a live `threadId` (MCP servers
|
|
293
|
+
are started per thread), but `thread/start` + call works without ever
|
|
294
|
+
running a turn — verified against `mastra_docs`. Argument validation
|
|
295
|
+
errors come back as `isError: true` content, not JSON-RPC errors.
|
|
296
|
+
- `mcpServer/resource/read` — read an MCP resource by uri.
|
|
297
|
+
- `mcpServer/oauth/login` — start OAuth for a `notLoggedIn` server;
|
|
298
|
+
completion arrives as the `mcpServer/oauthLogin/completed` notification.
|
|
299
|
+
- `config/mcpServer/reload` — re-read server definitions without a restart.
|
|
300
|
+
- `config/read`, `config/value/write`, `config/batchWrite`,
|
|
301
|
+
`configRequirements/read` — inspect/edit the config layers that define
|
|
302
|
+
servers.
|
|
303
|
+
|
|
304
|
+
Notifications: `mcpServer/startupStatus/updated` (per-thread startup
|
|
305
|
+
progress/failures — we currently ignore it), `mcpServer/oauthLogin/completed`,
|
|
306
|
+
`item/mcpToolCall/progress` (progress of an in-turn MCP call).
|
|
307
|
+
|
|
308
|
+
Server→client request: `mcpServer/elicitation/request` — an MCP server
|
|
309
|
+
asking the user for input mid-call, forwarded for the client to answer.
|
|
310
|
+
|
|
311
|
+
## 7. Type maintenance (`generate-ts`)
|
|
312
|
+
|
|
313
|
+
The wire types in `adapter.ts`/`client.ts` are a hand-written defensive
|
|
314
|
+
subset of the protocol, produced against the bindings from:
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
codex app-server generate-ts --out /tmp/codex-types # CLI 0.144.5
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
They are deliberately NOT generated at build time: users run arbitrary codex
|
|
321
|
+
CLI versions, so the runtime reads frames defensively regardless, and
|
|
322
|
+
vendoring ~600 generated files (or generating in CI) would couple typecheck
|
|
323
|
+
to an installed codex binary. When bumping the supported CLI version, re-run
|
|
324
|
+
`generate-ts` into a scratch dir and diff the relevant definitions
|
|
325
|
+
(`v2/ThreadItem`, `v2/TurnStartParams`, `ServerNotification`, `ServerRequest`)
|
|
326
|
+
against the subset here.
|