refactor: trim wasm blockers from shared api dependencies

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.
This commit is contained in:
Jeremy Lewi
2026-04-13 09:55:19 -07:00
parent ee4138c363
commit 5bc4c5c997
8 changed files with 44 additions and 5 deletions
+2
View File
@@ -1,7 +1,9 @@
pub mod compact;
pub mod memories;
pub mod models;
#[cfg(not(target_arch = "wasm32"))]
pub mod realtime_websocket;
pub mod responses;
#[cfg(not(target_arch = "wasm32"))]
pub mod responses_websocket;
mod session;
+10
View File
@@ -30,20 +30,30 @@ pub use crate::common::response_create_client_metadata;
pub use crate::endpoint::compact::CompactClient;
pub use crate::endpoint::memories::MemoriesClient;
pub use crate::endpoint::models::ModelsClient;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::realtime_websocket::RealtimeEventParser;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::realtime_websocket::RealtimeSessionConfig;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::realtime_websocket::RealtimeSessionMode;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::realtime_websocket::RealtimeWebsocketClient;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::realtime_websocket::RealtimeWebsocketConnection;
pub use crate::endpoint::responses::ResponsesClient;
pub use crate::endpoint::responses::ResponsesOptions;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::responses_websocket::ResponsesWebsocketClient;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::endpoint::responses_websocket::ResponsesWebsocketConnection;
pub use crate::error::ApiError;
pub use crate::provider::Provider;
pub use crate::provider::is_azure_responses_wire_base_url;
pub use crate::sse::stream_from_fixture;
pub use crate::telemetry::SseTelemetry;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::telemetry::WebsocketTelemetry;
#[cfg(not(target_arch = "wasm32"))]
pub use codex_protocol::protocol::RealtimeAudioFrame;
#[cfg(not(target_arch = "wasm32"))]
pub use codex_protocol::protocol::RealtimeEvent;
+3
View File
@@ -11,7 +11,9 @@ use std::future::Future;
use std::sync::Arc;
use std::time::Duration;
use tokio::time::Instant;
#[cfg(not(target_arch = "wasm32"))]
use tokio_tungstenite::tungstenite::Error;
#[cfg(not(target_arch = "wasm32"))]
use tokio_tungstenite::tungstenite::Message;
/// Generic telemetry.
@@ -31,6 +33,7 @@ pub trait SseTelemetry: Send + Sync {
);
}
#[cfg(not(target_arch = "wasm32"))]
/// Telemetry for Responses WebSocket transport.
pub trait WebsocketTelemetry: Send + Sync {
fn on_ws_request(&self, duration: Duration, error: Option<&ApiError>, connection_reused: bool);