This package is the contract-testable shell. It does not spawn
codex, a fresh CodexDriver is minted per run via the injected driverFactory, and the real driver (createCodexDriver) lives in apps/web/server/lib/runtimes/. Same shape as the Claude Code adapter (per-run injected driver, eager subscribe, late-bound runId); the two Codex realities, no USD cost and session-id resume, live entirely in mapCodexEvent and the driver, so the trait surface is identical.
Public API
All exports come fromsrc/index.ts. The package declares a single . export in package.json (no subpath barrels).
Classes
CodexAdapter members:
capabilities(): Capabilities, returns{ streaming: true, mcp: true, worktrees: true, resume: true, toolApproval: true, models: ['gpt-5-codex','gpt-5','o4-mini'], runtimeClass: 'wrapped-oneshot', nativeHome: { scope: 'per-identity', persist: true }, nativeSkills: 'none', nativeMemory: 'none', nativeChannels: 'none', nativeScheduler: false }.nativeHomedeclares a persistent managed per-agentCODEX_HOME(the host materializes it; the driver falls back to a throwawaymkdtempwhen no identity home is supplied), which is what makescodex exec resumecontinuity possible. The adapter defines asessionCodec(serializes the captured session id per sessionKey, the Hermes mirror); there is nocontextWindowTokens.health(): Promise<HealthResult>, races the injectedhealthCheckagainst a 2 s timeout ({ ok: false, message: 'health check timed out' }on timeout); any throw →{ ok: false, message }.start(_task: TaskHandle, opts: StartOpts): Promise<RunHandle>, mints a driver viadriverFactory(opts), stores it byopts.sessionKey, callsdriver.start(), returns{ adapterId: 'codex', sessionKey, runId: null }. TherunIdlate-binds inevents()from the first native frame carrying a thread id, falling back tosessionKey.events(run: RunHandle): AsyncIterable<RuntimeEvent>, subscribes to the run’s driver stream, late-bindsrunId, accumulates non-reasoningtext-deltatext, and yields the mapped normalized stream via a boundedcreateAsyncQueue(max: 1000). Consumer termination (return()) unsubscribes the driver. Returns an empty (closed) queue if no driver is registered for the run.abort(run: RunHandle): Promise<void>, delegates to the run’s driverabort().setModel(run: RunHandle, model: string): Promise<void>, delegates to the run’s driversetModel().writeContext(run: RunHandle, key: string, value: string): Promise<void>, delegates to the run’s driverwriteContext().
Functions
Types & interfaces
The
Capabilities, HealthResult, RunHandle, RuntimeAdapter, RuntimeEvent, StartOpts, TaskHandle, and Usage types referenced above are owned by @clawboo/executor, not re-exported here.Used by
apps/web/server/lib/runtimes/index.ts, instantiatesCodexAdapter, injectingcreateCodexDriver(the realcodex exec-backed driver) and a CLI health probe.apps/web/server/lib/runtimes/codexDriver.ts, imports theCodexDriver+CodexNativeEventtypes to implement the server-side driver againstcodex exec.
Source
packages/adapters/codex/src/index.ts (barrel; re-exports ./adapter, ./types, ./mapCodexEvent).
See also
- @clawboo/executor, the
RuntimeAdaptertrait +RuntimeEventunion this adapter implements. - RuntimeAdapter trait, the cross-runtime contract.
- Codex runtime, using the runtime end-to-end.
- Sibling adapters: @clawboo/adapter-claude-code, @clawboo/adapter-hermes, @clawboo/adapter-native, @clawboo/adapter-openclaw.