Draft
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.