Skip to content

Run Codex Agent Hareness in the browser#1

Draft
jlewi wants to merge 20 commits intomainfrom
dev/jlewi/wasm
Draft

Run Codex Agent Hareness in the browser#1
jlewi wants to merge 20 commits intomainfrom
dev/jlewi/wasm

Conversation

@jlewi
Copy link
Copy Markdown
Owner

@jlewi jlewi commented Apr 13, 2026

No description provided.

jlewi-openai and others added 20 commits April 10, 2026 16:41
Extract a CodeModeRuntime trait from codex-code-mode and make the core code-mode wrapper hold an injected runtime instead of constructing the native implementation inline. Thread an optional runtime override through Codex spawn/session startup and expose a ThreadManager entrypoint that can start a thread with a caller-provided runtime. Re-export the runtime trait from codex-core so downstream browser harness code can consume the seam without reaching into transitive dependencies.
Gate the native V8 dependency out of wasm builds and provide a wasm-specific default CodeModeService that preserves the shared request/response/runtime trait surface while returning clear errors unless a browser runtime is injected. Keep the public code-mode types available on wasm and mark the V8-backed runtime internals as native-only so codex-code-mode now checks cleanly for wasm32-unknown-unknown.
Compile websocket-only exports out of codex-api on wasm and stop enabling Tokio net there by default. Also cut the Tokio process dependency out of wasm builds of codex-git-utils by gating the async git-info module, move codex-utils-image's Tokio dependency to tests, and enable uuid's js RNG feature for wasm in codex-protocol. Native cargo checks passed for codex-api, codex-git-utils, and codex-protocol after the refactor.
Move native-only path and Tokio dependencies behind cfg gates so shared crates can compile for wasm32. Replace the absolute-path implementation with a lexical normalization fallback on wasm, use a std mutex for the cache helper on wasm, and degrade git symlink creation to an unsupported-platform error instead of a compile-time failure.
Move the direct tokio-tungstenite dependency behind a non-wasm cfg and teach ModelClientSession to compile without websocket transport on wasm. The browser path now cleanly defaults to HTTP-only Responses usage while native builds retain the existing websocket flow.
Upgrade the wasm harness from a one-shot sampler to a real Responses API loop that uses the Codex prompt, handles function_call / function_call_output turns, and exposes a browser exec_js callback. The example page now provisions a sandboxed iframe kernel, persists the API key in localStorage, surfaces browser errors inline, and has been verified in Chrome Testing with a live prompt that executes JavaScript and completes the turn.
Expose a pure Rust EmbeddedHarness API in codex-wasm-harness so downstream browser apps can depend on the crate directly without going through the demo-specific wasm_bindgen wrapper. Introduce trait seams for Responses transport, tool execution, and event delivery, move shared response/event types into dedicated modules, and keep BrowserCodex as a thin compatibility adapter so the existing browser demo continues to build and run unchanged.
Signed-off-by: Jeremy lewi <jeremy@lewi.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants