mirror of
https://github.com/openai/codex.git
synced 2026-11-02 19:43:24 +00:00
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:
@@ -15,9 +15,7 @@ http = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["macros", "net", "rt", "sync", "time"] }
|
||||
tokio-tungstenite = { workspace = true }
|
||||
tungstenite = { workspace = true }
|
||||
tokio = { workspace = true, features = ["macros", "rt", "sync", "time"] }
|
||||
tracing = { workspace = true }
|
||||
eventsource-stream = { workspace = true }
|
||||
regex-lite = { workspace = true }
|
||||
@@ -32,5 +30,10 @@ tokio-test = { workspace = true }
|
||||
wiremock = { workspace = true }
|
||||
reqwest = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
tokio = { workspace = true, features = ["net"] }
|
||||
tokio-tungstenite = { workspace = true }
|
||||
tungstenite = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -17,7 +17,6 @@ schemars = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
tempfile = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["macros", "process", "rt", "time"] }
|
||||
ts-rs = { workspace = true, features = [
|
||||
"uuid-impl",
|
||||
"serde-json-impl",
|
||||
@@ -28,3 +27,6 @@ walkdir = { workspace = true }
|
||||
[dev-dependencies]
|
||||
assert_matches = { workspace = true }
|
||||
pretty_assertions = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
tokio = { workspace = true, features = ["macros", "process", "rt", "time"] }
|
||||
|
||||
@@ -5,6 +5,7 @@ mod apply;
|
||||
mod branch;
|
||||
mod errors;
|
||||
mod ghost_commits;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod info;
|
||||
mod operations;
|
||||
mod platform;
|
||||
@@ -29,20 +30,35 @@ pub use ghost_commits::create_ghost_commit_with_report;
|
||||
pub use ghost_commits::restore_ghost_commit;
|
||||
pub use ghost_commits::restore_ghost_commit_with_options;
|
||||
pub use ghost_commits::restore_to_commit;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::CommitLogEntry;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::GitDiffToRemote;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::GitInfo;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::collect_git_info;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::current_branch_name;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::default_branch_name;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::get_git_remote_urls;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::get_git_remote_urls_assume_git_repo;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::get_git_repo_root;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::get_has_changes;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::get_head_commit_hash;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::git_diff_to_remote;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::local_git_branches;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::recent_commits;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub use info::resolve_root_git_project_for_trust;
|
||||
pub use platform::create_symlink;
|
||||
use schemars::JsonSchema;
|
||||
|
||||
@@ -42,6 +42,9 @@ anyhow = { workspace = true }
|
||||
pretty_assertions = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
uuid = { workspace = true, features = ["js"] }
|
||||
|
||||
[package.metadata.cargo-shear]
|
||||
# Required because:
|
||||
# `icu_provider`: contains a required `sync` feature for `icu_decimal`
|
||||
|
||||
@@ -13,7 +13,7 @@ image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] }
|
||||
codex-utils-cache = { workspace = true }
|
||||
mime_guess = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
tokio = { workspace = true, features = ["fs", "rt", "rt-multi-thread", "macros"] }
|
||||
|
||||
[dev-dependencies]
|
||||
image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] }
|
||||
tokio = { workspace = true, features = ["fs", "rt", "rt-multi-thread", "macros"] }
|
||||
|
||||
Reference in New Issue
Block a user