From 413c1e1fdf60d3fe418e101eb53d20fee33ae0e6 Mon Sep 17 00:00:00 2001 From: pakrym-oai Date: Tue, 7 Apr 2026 08:03:35 -0700 Subject: [PATCH] [codex] reduce module visibility (#16978) ## Summary - reduce public module visibility across Rust crates, preferring private or crate-private modules with explicit crate-root public exports - update external call sites and tests to use the intended public crate APIs instead of reaching through module trees - add the module visibility guideline to AGENTS.md ## Validation - `cargo check --workspace --all-targets --message-format=short` passed before the final fix/format pass - `just fix` completed successfully - `just fmt` completed successfully - `git diff --check` passed --- AGENTS.md | 1 + .../app-server/src/codex_message_processor.rs | 14 ++-- .../plugin_mcp_oauth.rs | 8 +- codex-rs/backend-client/src/client.rs | 5 +- codex-rs/backend-client/src/lib.rs | 2 +- codex-rs/backend-client/src/types.rs | 1 - codex-rs/cli/src/lib.rs | 15 +++- codex-rs/cli/src/main.rs | 22 ++--- codex-rs/cli/src/mcp_cmd.rs | 18 ++--- codex-rs/cli/src/wsl_paths.rs | 2 +- codex-rs/cloud-requirements/src/lib.rs | 2 +- codex-rs/cloud-tasks/src/lib.rs | 16 ++-- codex-rs/cloud-tasks/src/scrollable_diff.rs | 4 +- codex-rs/codex-api/src/endpoint/mod.rs | 27 +++++-- .../endpoint/realtime_websocket/methods.rs | 2 +- .../src/endpoint/realtime_websocket/mod.rs | 6 +- .../endpoint/realtime_websocket/protocol.rs | 1 - codex-rs/codex-api/src/endpoint/responses.rs | 4 +- .../src/endpoint/responses_websocket.rs | 4 +- codex-rs/codex-api/src/lib.rs | 54 ++++++++----- codex-rs/codex-api/src/requests/mod.rs | 5 +- codex-rs/codex-api/src/sse/mod.rs | 5 +- codex-rs/codex-api/tests/clients.rs | 4 +- .../codex-api/tests/models_integration.rs | 4 +- .../codex-api/tests/realtime_websocket_e2e.rs | 4 +- codex-rs/codex-api/tests/sse_end_to_end.rs | 4 +- .../src/models/mod.rs | 24 +++--- codex-rs/codex-mcp/src/lib.rs | 42 +++++++++- codex-rs/codex-mcp/src/mcp/mod.rs | 17 +++- .../codex-mcp/src/mcp_connection_manager.rs | 4 +- .../config/src/requirements_exec_policy.rs | 8 +- codex-rs/core/src/agent/registry.rs | 2 +- codex-rs/core/src/apps/render.rs | 2 +- codex-rs/core/src/client.rs | 12 +-- codex-rs/core/src/client_common.rs | 2 +- codex-rs/core/src/client_common_tests.rs | 4 +- codex-rs/core/src/client_tests.rs | 2 +- codex-rs/core/src/codex.rs | 32 +++----- codex-rs/core/src/codex_tests.rs | 4 +- codex-rs/core/src/config/mod.rs | 4 +- codex-rs/core/src/connectors.rs | 16 ++-- codex-rs/core/src/connectors_tests.rs | 4 +- codex-rs/core/src/exec.rs | 2 +- codex-rs/core/src/external_agent_config.rs | 2 +- codex-rs/core/src/instructions/mod.rs | 1 - codex-rs/core/src/lib.rs | 81 ++++++++++++------- codex-rs/core/src/mcp.rs | 8 +- codex-rs/core/src/mcp_skill_dependencies.rs | 8 +- codex-rs/core/src/mcp_tool_call.rs | 2 +- codex-rs/core/src/otel_init.rs | 8 +- codex-rs/core/src/plugins/injection.rs | 4 +- codex-rs/core/src/plugins/startup_sync.rs | 6 +- codex-rs/core/src/realtime_conversation.rs | 6 +- codex-rs/core/src/rollout.rs | 33 +++++--- codex-rs/core/src/session_startup_prewarm.rs | 4 +- codex-rs/core/src/state/service.rs | 2 +- codex-rs/core/src/state_db_bridge.rs | 13 --- codex-rs/core/src/tasks/mod.rs | 8 +- codex-rs/core/src/tasks/mod_tests.rs | 6 +- codex-rs/core/src/tools/handlers/mod.rs | 2 +- .../core/src/tools/handlers/multi_agents.rs | 2 +- .../core/src/tools/handlers/tool_search.rs | 2 +- .../core/src/tools/handlers/tool_suggest.rs | 2 +- .../core/src/tools/handlers/unified_exec.rs | 2 +- codex-rs/core/src/tools/mod.rs | 22 ++--- codex-rs/core/src/tools/router.rs | 2 +- codex-rs/core/src/tools/runtimes/mod.rs | 6 +- codex-rs/core/src/tools/spec.rs | 4 +- codex-rs/core/src/tools/spec_tests.rs | 2 +- codex-rs/core/src/turn_timing.rs | 4 +- codex-rs/core/src/windows_sandbox.rs | 4 +- .../core/tests/suite/client_websockets.rs | 4 +- codex-rs/core/tests/suite/pending_input.rs | 15 +++- codex-rs/exec/src/lib.rs | 42 +++++++++- .../tests/event_processor_with_json_output.rs | 72 ++++++++--------- codex-rs/exec/tests/suite/sandbox.rs | 2 +- codex-rs/execpolicy/src/amend.rs | 1 - codex-rs/execpolicy/src/lib.rs | 17 ++-- codex-rs/execpolicy/src/main.rs | 2 +- codex-rs/execpolicy/src/parser.rs | 1 - codex-rs/execpolicy/tests/basic.rs | 6 +- codex-rs/feedback/src/lib.rs | 9 ++- codex-rs/hooks/src/lib.rs | 2 +- codex-rs/login/src/api_bridge.rs | 2 +- codex-rs/login/src/lib.rs | 1 + codex-rs/model-provider-info/src/lib.rs | 2 +- codex-rs/models-manager/src/lib.rs | 4 +- codex-rs/models-manager/src/manager.rs | 2 +- codex-rs/otel/src/events/session_telemetry.rs | 36 ++++----- codex-rs/otel/src/lib.rs | 14 ++-- codex-rs/otel/src/metrics/mod.rs | 6 +- codex-rs/otel/tests/harness/mod.rs | 6 +- codex-rs/otel/tests/suite/manager_metrics.rs | 2 +- .../otel/tests/suite/otlp_http_loopback.rs | 12 +-- codex-rs/otel/tests/suite/runtime_summary.rs | 6 +- codex-rs/otel/tests/suite/send.rs | 2 +- codex-rs/otel/tests/suite/snapshot.rs | 6 +- codex-rs/otel/tests/suite/timing.rs | 2 +- codex-rs/otel/tests/suite/validation.rs | 8 +- codex-rs/protocol/src/models.rs | 2 +- codex-rs/response-debug-context/src/lib.rs | 4 +- codex-rs/rollout/src/lib.rs | 26 ++++-- codex-rs/rollout/src/metadata.rs | 2 +- .../shell-command/src/command_safety/mod.rs | 2 +- codex-rs/shell-command/src/lib.rs | 2 +- codex-rs/shell-escalation/src/lib.rs | 4 +- codex-rs/shell-escalation/src/unix/mod.rs | 15 ++-- codex-rs/tui/src/app.rs | 10 +-- codex-rs/tui/src/app_server_session.rs | 10 ++- codex-rs/tui/src/bottom_pane/feedback_view.rs | 6 +- codex-rs/tui/src/bottom_pane/mod.rs | 4 +- codex-rs/tui/src/chatwidget.rs | 2 +- codex-rs/tui/src/chatwidget/skills.rs | 2 +- .../chatwidget/tests/popups_and_settings.rs | 24 +++--- codex-rs/tui/src/history_cell.rs | 10 +-- codex-rs/tui/src/lib.rs | 18 +++-- codex-rs/tui/src/mention_codec.rs | 4 +- codex-rs/tui/src/onboarding/mod.rs | 3 +- codex-rs/tui/src/public_widgets/mod.rs | 2 +- codex-rs/tui/src/render/mod.rs | 6 +- codex-rs/tui/src/status/helpers.rs | 2 +- codex-rs/tui/tests/suite/vt100_history.rs | 8 +- codex-rs/tui/tests/suite/vt100_live_commit.rs | 6 +- codex-rs/utils/cli/src/lib.rs | 3 +- codex-rs/utils/image/src/lib.rs | 5 +- codex-rs/utils/path-utils/src/lib.rs | 4 +- codex-rs/utils/pty/src/win/mod.rs | 2 +- .../src/elevated/command_runner_win.rs | 32 ++++---- codex-rs/windows-sandbox-rs/src/lib.rs | 26 +++++- 129 files changed, 695 insertions(+), 496 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c8d989fe9..297fb0fe1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,6 +21,7 @@ In the codex-rs folder where the rust code lives: - Newly added traits should include doc comments that explain their role and how implementations are expected to use them. - When writing tests, prefer comparing the equality of entire objects over fields one by one. - When making a change that adds or changes an API, ensure that the documentation in the `docs/` folder is up to date if applicable. +- Prefer private modules and explicitly exported public crate API. - If you change `ConfigToml` or nested config types, run `just write-config-schema` to update `codex-rs/core/config.schema.json`. - If you change Rust dependencies (`Cargo.toml` or `Cargo.lock`), run `just bazel-lock-update` from the repo root to refresh `MODULE.bazel.lock`, and include that lockfile update in the same change. diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index 6b917d699..928272082 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -248,12 +248,12 @@ use codex_login::default_client::set_default_client_residency_requirement; use codex_login::login_with_api_key; use codex_login::request_device_code; use codex_login::run_login_server; -use codex_mcp::mcp::McpSnapshotDetail; -use codex_mcp::mcp::auth::discover_supported_scopes; -use codex_mcp::mcp::auth::resolve_oauth_scopes; -use codex_mcp::mcp::collect_mcp_snapshot_with_detail; -use codex_mcp::mcp::effective_mcp_servers; -use codex_mcp::mcp::qualified_mcp_tool_name_prefix; +use codex_mcp::McpSnapshotDetail; +use codex_mcp::collect_mcp_snapshot_with_detail; +use codex_mcp::discover_supported_scopes; +use codex_mcp::effective_mcp_servers; +use codex_mcp::qualified_mcp_tool_name_prefix; +use codex_mcp::resolve_oauth_scopes; use codex_models_manager::collaboration_mode_presets::CollaborationModesConfig; use codex_protocol::ThreadId; use codex_protocol::config_types::CollaborationMode; @@ -5175,7 +5175,7 @@ impl CodexMessageProcessor { request_id: ConnectionRequestId, params: ListMcpServerStatusParams, config: Config, - mcp_config: codex_mcp::mcp::McpConfig, + mcp_config: codex_mcp::McpConfig, auth: Option, ) { let detail = match params.detail.unwrap_or(McpServerStatusDetail::Full) { diff --git a/codex-rs/app-server/src/codex_message_processor/plugin_mcp_oauth.rs b/codex-rs/app-server/src/codex_message_processor/plugin_mcp_oauth.rs index 58f4a5e8d..b027aef45 100644 --- a/codex-rs/app-server/src/codex_message_processor/plugin_mcp_oauth.rs +++ b/codex-rs/app-server/src/codex_message_processor/plugin_mcp_oauth.rs @@ -5,10 +5,10 @@ use codex_app_server_protocol::McpServerOauthLoginCompletedNotification; use codex_app_server_protocol::ServerNotification; use codex_config::types::McpServerConfig; use codex_core::config::Config; -use codex_mcp::mcp::auth::McpOAuthLoginSupport; -use codex_mcp::mcp::auth::oauth_login_support; -use codex_mcp::mcp::auth::resolve_oauth_scopes; -use codex_mcp::mcp::auth::should_retry_without_scopes; +use codex_mcp::McpOAuthLoginSupport; +use codex_mcp::oauth_login_support; +use codex_mcp::resolve_oauth_scopes; +use codex_mcp::should_retry_without_scopes; use codex_rmcp_client::perform_oauth_login_silent; use tracing::warn; diff --git a/codex-rs/backend-client/src/client.rs b/codex-rs/backend-client/src/client.rs index 3d5beb9d1..6049c1697 100644 --- a/codex-rs/backend-client/src/client.rs +++ b/codex-rs/backend-client/src/client.rs @@ -503,6 +503,7 @@ impl Client { #[cfg(test)] mod tests { use super::*; + use codex_backend_openapi_models::models::AdditionalRateLimitDetails; use pretty_assertions::assert_eq; #[test] @@ -536,7 +537,7 @@ mod tests { }))), ..Default::default() }))), - additional_rate_limits: Some(Some(vec![crate::types::AdditionalRateLimitDetails { + additional_rate_limits: Some(Some(vec![AdditionalRateLimitDetails { limit_name: "codex_other".to_string(), metered_feature: "codex_other".to_string(), rate_limit: Some(Some(Box::new(crate::types::RateLimitStatusDetails { @@ -596,7 +597,7 @@ mod tests { let payload = RateLimitStatusPayload { plan_type: crate::types::PlanType::Plus, rate_limit: None, - additional_rate_limits: Some(Some(vec![crate::types::AdditionalRateLimitDetails { + additional_rate_limits: Some(Some(vec![AdditionalRateLimitDetails { limit_name: "codex_other".to_string(), metered_feature: "codex_other".to_string(), rate_limit: None, diff --git a/codex-rs/backend-client/src/lib.rs b/codex-rs/backend-client/src/lib.rs index a3b2f3760..397c2a2cd 100644 --- a/codex-rs/backend-client/src/lib.rs +++ b/codex-rs/backend-client/src/lib.rs @@ -1,5 +1,5 @@ mod client; -pub mod types; +pub(crate) mod types; pub use client::Client; pub use client::RequestError; diff --git a/codex-rs/backend-client/src/types.rs b/codex-rs/backend-client/src/types.rs index 4ef0fb846..22e0984cd 100644 --- a/codex-rs/backend-client/src/types.rs +++ b/codex-rs/backend-client/src/types.rs @@ -1,4 +1,3 @@ -pub use codex_backend_openapi_models::models::AdditionalRateLimitDetails; pub use codex_backend_openapi_models::models::ConfigFileResponse; pub use codex_backend_openapi_models::models::CreditStatusDetails; pub use codex_backend_openapi_models::models::PaginatedListTaskListItem; diff --git a/codex-rs/cli/src/lib.rs b/codex-rs/cli/src/lib.rs index b6174efa3..848391293 100644 --- a/codex-rs/cli/src/lib.rs +++ b/codex-rs/cli/src/lib.rs @@ -1,10 +1,21 @@ -pub mod debug_sandbox; +pub(crate) mod debug_sandbox; mod exit_status; -pub mod login; +pub(crate) mod login; use clap::Parser; use codex_utils_cli::CliConfigOverrides; +pub use debug_sandbox::run_command_under_landlock; +pub use debug_sandbox::run_command_under_seatbelt; +pub use debug_sandbox::run_command_under_windows; +pub use login::read_api_key_from_stdin; +pub use login::run_login_status; +pub use login::run_login_with_api_key; +pub use login::run_login_with_chatgpt; +pub use login::run_login_with_device_code; +pub use login::run_login_with_device_code_fallback_to_browser; +pub use login::run_logout; + #[derive(Debug, Parser)] pub struct SeatbeltCommand { /// Convenience alias for low-friction sandboxed automatic execution (network-disabled sandbox that can write to cwd and TMPDIR) diff --git a/codex-rs/cli/src/main.rs b/codex-rs/cli/src/main.rs index 3007048a2..047716271 100644 --- a/codex-rs/cli/src/main.rs +++ b/codex-rs/cli/src/main.rs @@ -10,12 +10,12 @@ use codex_chatgpt::apply_command::run_apply_command; use codex_cli::LandlockCommand; use codex_cli::SeatbeltCommand; use codex_cli::WindowsCommand; -use codex_cli::login::read_api_key_from_stdin; -use codex_cli::login::run_login_status; -use codex_cli::login::run_login_with_api_key; -use codex_cli::login::run_login_with_chatgpt; -use codex_cli::login::run_login_with_device_code; -use codex_cli::login::run_logout; +use codex_cli::read_api_key_from_stdin; +use codex_cli::run_login_status; +use codex_cli::run_login_with_api_key; +use codex_cli::run_login_with_chatgpt; +use codex_cli::run_login_with_device_code; +use codex_cli::run_logout; use codex_cloud_tasks::Cli as CloudTasksCli; use codex_exec::Cli as ExecCli; use codex_exec::Command as ExecCommand; @@ -27,7 +27,7 @@ use codex_state::state_db_path; use codex_tui::AppExitInfo; use codex_tui::Cli as TuiCli; use codex_tui::ExitReason; -use codex_tui::update_action::UpdateAction; +use codex_tui::UpdateAction; use codex_utils_cli::CliConfigOverrides; use owo_colors::OwoColorize; use std::io::IsTerminal; @@ -883,7 +883,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> { &mut seatbelt_cli.config_overrides, root_config_overrides.clone(), ); - codex_cli::debug_sandbox::run_command_under_seatbelt( + codex_cli::run_command_under_seatbelt( seatbelt_cli, arg0_paths.codex_linux_sandbox_exe.clone(), ) @@ -899,7 +899,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> { &mut landlock_cli.config_overrides, root_config_overrides.clone(), ); - codex_cli::debug_sandbox::run_command_under_landlock( + codex_cli::run_command_under_landlock( landlock_cli, arg0_paths.codex_linux_sandbox_exe.clone(), ) @@ -915,7 +915,7 @@ async fn cli_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> { &mut windows_cli.config_overrides, root_config_overrides.clone(), ); - codex_cli::debug_sandbox::run_command_under_windows( + codex_cli::run_command_under_windows( windows_cli, arg0_paths.codex_linux_sandbox_exe.clone(), ) @@ -1173,7 +1173,7 @@ async fn run_debug_prompt_input_command( }); } - let prompt_input = codex_core::prompt_debug::build_prompt_input(config, input).await?; + let prompt_input = codex_core::build_prompt_input(config, input).await?; println!("{}", serde_json::to_string_pretty(&prompt_input)?); Ok(()) diff --git a/codex-rs/cli/src/mcp_cmd.rs b/codex-rs/cli/src/mcp_cmd.rs index 027a88a7c..f544ca82b 100644 --- a/codex-rs/cli/src/mcp_cmd.rs +++ b/codex-rs/cli/src/mcp_cmd.rs @@ -8,24 +8,24 @@ use anyhow::bail; use clap::ArgGroup; use codex_config::types::McpServerConfig; use codex_config::types::McpServerTransportConfig; +use codex_core::McpManager; use codex_core::config::Config; use codex_core::config::edit::ConfigEditsBuilder; use codex_core::config::find_codex_home; use codex_core::config::load_global_mcp_servers; -use codex_core::mcp::McpManager; use codex_core::plugins::PluginsManager; -use codex_mcp::mcp::auth::McpOAuthLoginSupport; -use codex_mcp::mcp::auth::ResolvedMcpOAuthScopes; -use codex_mcp::mcp::auth::compute_auth_statuses; -use codex_mcp::mcp::auth::discover_supported_scopes; -use codex_mcp::mcp::auth::oauth_login_support; -use codex_mcp::mcp::auth::resolve_oauth_scopes; -use codex_mcp::mcp::auth::should_retry_without_scopes; +use codex_mcp::McpOAuthLoginSupport; +use codex_mcp::ResolvedMcpOAuthScopes; +use codex_mcp::compute_auth_statuses; +use codex_mcp::discover_supported_scopes; +use codex_mcp::oauth_login_support; +use codex_mcp::resolve_oauth_scopes; +use codex_mcp::should_retry_without_scopes; use codex_protocol::protocol::McpAuthStatus; use codex_rmcp_client::delete_oauth_tokens; use codex_rmcp_client::perform_oauth_login; use codex_utils_cli::CliConfigOverrides; -use codex_utils_cli::format_env_display::format_env_display; +use codex_utils_cli::format_env_display; /// Subcommands: /// - `list` — list configured servers (with `--json`) diff --git a/codex-rs/cli/src/wsl_paths.rs b/codex-rs/cli/src/wsl_paths.rs index 28366579e..b90dc1e28 100644 --- a/codex-rs/cli/src/wsl_paths.rs +++ b/codex-rs/cli/src/wsl_paths.rs @@ -1,7 +1,7 @@ use std::ffi::OsStr; /// Returns true if the current process is running under WSL. -pub use codex_utils_path::env::is_wsl; +pub use codex_utils_path::is_wsl; /// Convert a Windows absolute path (`C:\foo\bar` or `C:/foo/bar`) to a WSL mount path (`/mnt/c/foo/bar`). /// Returns `None` if the input does not look like a Windows drive path. diff --git a/codex-rs/cloud-requirements/src/lib.rs b/codex-rs/cloud-requirements/src/lib.rs index 04463a7dd..ad4ebed12 100644 --- a/codex-rs/cloud-requirements/src/lib.rs +++ b/codex-rs/cloud-requirements/src/lib.rs @@ -806,7 +806,7 @@ fn status_code_tag(status_code: Option) -> String { } fn emit_metric(metric_name: &str, tags: Vec<(&str, String)>) { - if let Some(metrics) = codex_otel::metrics::global() { + if let Some(metrics) = codex_otel::global() { let tag_refs = tags .iter() .map(|(key, value)| (*key, value.as_str())) diff --git a/codex-rs/cloud-tasks/src/lib.rs b/codex-rs/cloud-tasks/src/lib.rs index f96ac62ed..7006d52b9 100644 --- a/codex-rs/cloud-tasks/src/lib.rs +++ b/codex-rs/cloud-tasks/src/lib.rs @@ -1,10 +1,10 @@ mod app; mod cli; -pub mod env_detect; +pub(crate) mod env_detect; mod new_task; -pub mod scrollable_diff; +pub(crate) mod scrollable_diff; mod ui; -pub mod util; +pub(crate) mod util; pub use cli::Cli; use anyhow::anyhow; @@ -1596,7 +1596,7 @@ pub async fn run_main(cli: Cli, _codex_linux_sandbox_exe: Option) -> an let total = ov.attempt_display_total(); let current = ov.selected_attempt + 1; app.status = format!("Viewing attempt {current} of {total}"); - ov.sd.to_top(); + ov.sd.scroll_to_top(); needs_redraw = true; } }; @@ -1672,7 +1672,7 @@ pub async fn run_main(cli: Cli, _codex_linux_sandbox_exe: Option) -> an let has_diff = ov.current_attempt().is_some_and(app::AttemptView::has_diff) || ov.base_can_apply; if has_text && has_diff { ov.set_view(app::DetailView::Prompt); - ov.sd.to_top(); + ov.sd.scroll_to_top(); needs_redraw = true; } } @@ -1683,7 +1683,7 @@ pub async fn run_main(cli: Cli, _codex_linux_sandbox_exe: Option) -> an let has_diff = ov.current_attempt().is_some_and(app::AttemptView::has_diff) || ov.base_can_apply; if has_text && has_diff { ov.set_view(app::DetailView::Diff); - ov.sd.to_top(); + ov.sd.scroll_to_top(); needs_redraw = true; } } @@ -1714,8 +1714,8 @@ pub async fn run_main(cli: Cli, _codex_linux_sandbox_exe: Option) -> an if let Some(ov) = &mut app.diff_overlay { let step = ov.sd.state.viewport_h.saturating_sub(1) as i16; ov.sd.page_by(-step); } needs_redraw = true; } - KeyCode::Home => { if let Some(ov) = &mut app.diff_overlay { ov.sd.to_top(); } needs_redraw = true; } - KeyCode::End => { if let Some(ov) = &mut app.diff_overlay { ov.sd.to_bottom(); } needs_redraw = true; } + KeyCode::Home => { if let Some(ov) = &mut app.diff_overlay { ov.sd.scroll_to_top(); } needs_redraw = true; } + KeyCode::End => { if let Some(ov) = &mut app.diff_overlay { ov.sd.scroll_to_bottom(); } needs_redraw = true; } _ => {} } } else if app.env_modal.is_some() { diff --git a/codex-rs/cloud-tasks/src/scrollable_diff.rs b/codex-rs/cloud-tasks/src/scrollable_diff.rs index 97dfb2489..59dd076b3 100644 --- a/codex-rs/cloud-tasks/src/scrollable_diff.rs +++ b/codex-rs/cloud-tasks/src/scrollable_diff.rs @@ -86,11 +86,11 @@ impl ScrollableDiff { self.scroll_by(delta); } - pub fn to_top(&mut self) { + pub fn scroll_to_top(&mut self) { self.state.scroll = 0; } - pub fn to_bottom(&mut self) { + pub fn scroll_to_bottom(&mut self) { self.state.scroll = self.max_scroll(); } diff --git a/codex-rs/codex-api/src/endpoint/mod.rs b/codex-rs/codex-api/src/endpoint/mod.rs index 6a748e533..a6c2603f7 100644 --- a/codex-rs/codex-api/src/endpoint/mod.rs +++ b/codex-rs/codex-api/src/endpoint/mod.rs @@ -1,7 +1,22 @@ -pub mod compact; -pub mod memories; -pub mod models; -pub mod realtime_websocket; -pub mod responses; -pub mod responses_websocket; +pub(crate) mod compact; +pub(crate) mod memories; +pub(crate) mod models; +pub(crate) mod realtime_websocket; +pub(crate) mod responses; +pub(crate) mod responses_websocket; mod session; + +pub use compact::CompactClient; +pub use memories::MemoriesClient; +pub use models::ModelsClient; +pub use realtime_websocket::RealtimeEventParser; +pub use realtime_websocket::RealtimeSessionConfig; +pub use realtime_websocket::RealtimeSessionMode; +pub use realtime_websocket::RealtimeWebsocketClient; +pub use realtime_websocket::RealtimeWebsocketConnection; +pub use realtime_websocket::RealtimeWebsocketEvents; +pub use realtime_websocket::RealtimeWebsocketWriter; +pub use responses::ResponsesClient; +pub use responses::ResponsesOptions; +pub use responses_websocket::ResponsesWebsocketClient; +pub use responses_websocket::ResponsesWebsocketConnection; diff --git a/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs b/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs index eed0e470a..544c7ad7a 100644 --- a/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs +++ b/codex-rs/codex-api/src/endpoint/realtime_websocket/methods.rs @@ -625,9 +625,9 @@ fn normalize_realtime_path(url: &mut Url) { #[cfg(test)] mod tests { use super::*; - use crate::endpoint::realtime_websocket::protocol::RealtimeHandoffRequested; use crate::endpoint::realtime_websocket::protocol::RealtimeTranscriptDelta; use crate::endpoint::realtime_websocket::protocol::RealtimeTranscriptEntry; + use codex_protocol::protocol::RealtimeHandoffRequested; use codex_protocol::protocol::RealtimeInputAudioSpeechStarted; use codex_protocol::protocol::RealtimeResponseCancelled; use http::HeaderValue; diff --git a/codex-rs/codex-api/src/endpoint/realtime_websocket/mod.rs b/codex-rs/codex-api/src/endpoint/realtime_websocket/mod.rs index d13585034..867ebdff6 100644 --- a/codex-rs/codex-api/src/endpoint/realtime_websocket/mod.rs +++ b/codex-rs/codex-api/src/endpoint/realtime_websocket/mod.rs @@ -1,14 +1,12 @@ -pub mod methods; +pub(crate) mod methods; mod methods_common; mod methods_v1; mod methods_v2; -pub mod protocol; +pub(crate) mod protocol; mod protocol_common; mod protocol_v1; mod protocol_v2; -pub use codex_protocol::protocol::RealtimeAudioFrame; -pub use codex_protocol::protocol::RealtimeEvent; pub use methods::RealtimeWebsocketClient; pub use methods::RealtimeWebsocketConnection; pub use methods::RealtimeWebsocketEvents; diff --git a/codex-rs/codex-api/src/endpoint/realtime_websocket/protocol.rs b/codex-rs/codex-api/src/endpoint/realtime_websocket/protocol.rs index 2c629249f..494174055 100644 --- a/codex-rs/codex-api/src/endpoint/realtime_websocket/protocol.rs +++ b/codex-rs/codex-api/src/endpoint/realtime_websocket/protocol.rs @@ -2,7 +2,6 @@ use crate::endpoint::realtime_websocket::protocol_v1::parse_realtime_event_v1; use crate::endpoint::realtime_websocket::protocol_v2::parse_realtime_event_v2; pub use codex_protocol::protocol::RealtimeAudioFrame; pub use codex_protocol::protocol::RealtimeEvent; -pub use codex_protocol::protocol::RealtimeHandoffRequested; pub use codex_protocol::protocol::RealtimeTranscriptDelta; pub use codex_protocol::protocol::RealtimeTranscriptEntry; use serde::Serialize; diff --git a/codex-rs/codex-api/src/endpoint/responses.rs b/codex-rs/codex-api/src/endpoint/responses.rs index 57a44d2e2..8e0e7384f 100644 --- a/codex-rs/codex-api/src/endpoint/responses.rs +++ b/codex-rs/codex-api/src/endpoint/responses.rs @@ -4,11 +4,11 @@ use crate::common::ResponsesApiRequest; use crate::endpoint::session::EndpointSession; use crate::error::ApiError; use crate::provider::Provider; +use crate::requests::Compression; +use crate::requests::attach_item_ids; use crate::requests::headers::build_conversation_headers; use crate::requests::headers::insert_header; use crate::requests::headers::subagent_header; -use crate::requests::responses::Compression; -use crate::requests::responses::attach_item_ids; use crate::sse::spawn_response_stream; use crate::telemetry::SseTelemetry; use codex_client::HttpTransport; diff --git a/codex-rs/codex-api/src/endpoint/responses_websocket.rs b/codex-rs/codex-api/src/endpoint/responses_websocket.rs index d3b578db6..a60d188bd 100644 --- a/codex-rs/codex-api/src/endpoint/responses_websocket.rs +++ b/codex-rs/codex-api/src/endpoint/responses_websocket.rs @@ -6,8 +6,8 @@ use crate::common::ResponsesWsRequest; use crate::error::ApiError; use crate::provider::Provider; use crate::rate_limits::parse_rate_limit_event; -use crate::sse::responses::ResponsesStreamEvent; -use crate::sse::responses::process_responses_event; +use crate::sse::ResponsesStreamEvent; +use crate::sse::process_responses_event; use crate::telemetry::WebsocketTelemetry; use codex_client::TransportError; use codex_client::maybe_build_rustls_client_config_with_custom_ca; diff --git a/codex-rs/codex-api/src/lib.rs b/codex-rs/codex-api/src/lib.rs index c7bb60705..01a563735 100644 --- a/codex-rs/codex-api/src/lib.rs +++ b/codex-rs/codex-api/src/lib.rs @@ -1,48 +1,58 @@ -pub mod api_bridge; -pub mod auth; -pub mod common; -pub mod endpoint; -pub mod error; -pub mod provider; -pub mod rate_limits; -pub mod requests; -pub mod sse; -pub mod telemetry; +pub(crate) mod api_bridge; +pub(crate) mod auth; +pub(crate) mod common; +pub(crate) mod endpoint; +pub(crate) mod error; +pub(crate) mod provider; +pub(crate) mod rate_limits; +pub(crate) mod requests; +pub(crate) mod sse; +pub(crate) mod telemetry; pub use crate::requests::headers::build_conversation_headers; pub use codex_client::RequestTelemetry; pub use codex_client::ReqwestTransport; pub use codex_client::TransportError; +pub use crate::api_bridge::CoreAuthProvider; +pub use crate::api_bridge::map_api_error; pub use crate::auth::AuthProvider; pub use crate::common::CompactionInput; pub use crate::common::MemorySummarizeInput; pub use crate::common::MemorySummarizeOutput; +pub use crate::common::OpenAiVerbosity; pub use crate::common::RawMemory; pub use crate::common::RawMemoryMetadata; +pub use crate::common::Reasoning; pub use crate::common::ResponseCreateWsRequest; pub use crate::common::ResponseEvent; pub use crate::common::ResponseStream; pub use crate::common::ResponsesApiRequest; +pub use crate::common::ResponsesWsRequest; +pub use crate::common::TextControls; pub use crate::common::WS_REQUEST_HEADER_TRACEPARENT_CLIENT_METADATA_KEY; pub use crate::common::WS_REQUEST_HEADER_TRACESTATE_CLIENT_METADATA_KEY; pub use crate::common::create_text_param_for_request; 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; -pub use crate::endpoint::realtime_websocket::RealtimeEventParser; -pub use crate::endpoint::realtime_websocket::RealtimeSessionConfig; -pub use crate::endpoint::realtime_websocket::RealtimeSessionMode; -pub use crate::endpoint::realtime_websocket::RealtimeWebsocketClient; -pub use crate::endpoint::realtime_websocket::RealtimeWebsocketConnection; -pub use crate::endpoint::responses::ResponsesClient; -pub use crate::endpoint::responses::ResponsesOptions; -pub use crate::endpoint::responses_websocket::ResponsesWebsocketClient; -pub use crate::endpoint::responses_websocket::ResponsesWebsocketConnection; +pub use crate::endpoint::CompactClient; +pub use crate::endpoint::MemoriesClient; +pub use crate::endpoint::ModelsClient; +pub use crate::endpoint::RealtimeEventParser; +pub use crate::endpoint::RealtimeSessionConfig; +pub use crate::endpoint::RealtimeSessionMode; +pub use crate::endpoint::RealtimeWebsocketClient; +pub use crate::endpoint::RealtimeWebsocketConnection; +pub use crate::endpoint::RealtimeWebsocketEvents; +pub use crate::endpoint::RealtimeWebsocketWriter; +pub use crate::endpoint::ResponsesClient; +pub use crate::endpoint::ResponsesOptions; +pub use crate::endpoint::ResponsesWebsocketClient; +pub use crate::endpoint::ResponsesWebsocketConnection; pub use crate::error::ApiError; pub use crate::provider::Provider; +pub use crate::provider::RetryConfig; pub use crate::provider::is_azure_responses_wire_base_url; +pub use crate::requests::Compression; pub use crate::sse::stream_from_fixture; pub use crate::telemetry::SseTelemetry; pub use crate::telemetry::WebsocketTelemetry; diff --git a/codex-rs/codex-api/src/requests/mod.rs b/codex-rs/codex-api/src/requests/mod.rs index 4e98bb8ca..1c357b2a6 100644 --- a/codex-rs/codex-api/src/requests/mod.rs +++ b/codex-rs/codex-api/src/requests/mod.rs @@ -1,2 +1,5 @@ pub(crate) mod headers; -pub mod responses; +pub(crate) mod responses; + +pub use responses::Compression; +pub(crate) use responses::attach_item_ids; diff --git a/codex-rs/codex-api/src/sse/mod.rs b/codex-rs/codex-api/src/sse/mod.rs index cb689afc1..06b985589 100644 --- a/codex-rs/codex-api/src/sse/mod.rs +++ b/codex-rs/codex-api/src/sse/mod.rs @@ -1,5 +1,6 @@ -pub mod responses; +pub(crate) mod responses; -pub use responses::process_sse; +pub(crate) use responses::ResponsesStreamEvent; +pub(crate) use responses::process_responses_event; pub use responses::spawn_response_stream; pub use responses::stream_from_fixture; diff --git a/codex-rs/codex-api/tests/clients.rs b/codex-rs/codex-api/tests/clients.rs index 2f3bc17e2..3c22c0120 100644 --- a/codex-rs/codex-api/tests/clients.rs +++ b/codex-rs/codex-api/tests/clients.rs @@ -6,11 +6,11 @@ use anyhow::Result; use async_trait::async_trait; use bytes::Bytes; use codex_api::AuthProvider; +use codex_api::Compression; use codex_api::Provider; use codex_api::ResponsesApiRequest; use codex_api::ResponsesClient; use codex_api::ResponsesOptions; -use codex_api::requests::responses::Compression; use codex_client::HttpTransport; use codex_client::Request; use codex_client::Response; @@ -126,7 +126,7 @@ fn provider(name: &str) -> Provider { base_url: "https://example.com/v1".to_string(), query_params: None, headers: HeaderMap::new(), - retry: codex_api::provider::RetryConfig { + retry: codex_api::RetryConfig { max_attempts: 1, base_delay: Duration::from_millis(1), retry_429: false, diff --git a/codex-rs/codex-api/tests/models_integration.rs b/codex-rs/codex-api/tests/models_integration.rs index 3ffb2496b..c6b28fa71 100644 --- a/codex-rs/codex-api/tests/models_integration.rs +++ b/codex-rs/codex-api/tests/models_integration.rs @@ -1,7 +1,7 @@ use codex_api::AuthProvider; use codex_api::ModelsClient; -use codex_api::provider::Provider; -use codex_api::provider::RetryConfig; +use codex_api::Provider; +use codex_api::RetryConfig; use codex_client::ReqwestTransport; use codex_protocol::config_types::ReasoningSummary; use codex_protocol::openai_models::ConfigShellToolType; diff --git a/codex-rs/codex-api/tests/realtime_websocket_e2e.rs b/codex-rs/codex-api/tests/realtime_websocket_e2e.rs index 130ab6fd3..42c7a92e2 100644 --- a/codex-rs/codex-api/tests/realtime_websocket_e2e.rs +++ b/codex-rs/codex-api/tests/realtime_websocket_e2e.rs @@ -2,14 +2,14 @@ use std::collections::HashMap; use std::future::Future; use std::time::Duration; +use codex_api::Provider; use codex_api::RealtimeAudioFrame; use codex_api::RealtimeEvent; use codex_api::RealtimeEventParser; use codex_api::RealtimeSessionConfig; use codex_api::RealtimeSessionMode; use codex_api::RealtimeWebsocketClient; -use codex_api::provider::Provider; -use codex_api::provider::RetryConfig; +use codex_api::RetryConfig; use codex_protocol::protocol::RealtimeHandoffRequested; use futures::SinkExt; use futures::StreamExt; diff --git a/codex-rs/codex-api/tests/sse_end_to_end.rs b/codex-rs/codex-api/tests/sse_end_to_end.rs index 80972340d..b15de296a 100644 --- a/codex-rs/codex-api/tests/sse_end_to_end.rs +++ b/codex-rs/codex-api/tests/sse_end_to_end.rs @@ -4,10 +4,10 @@ use anyhow::Result; use async_trait::async_trait; use bytes::Bytes; use codex_api::AuthProvider; +use codex_api::Compression; use codex_api::Provider; use codex_api::ResponseEvent; use codex_api::ResponsesClient; -use codex_api::requests::responses::Compression; use codex_client::HttpTransport; use codex_client::Request; use codex_client::Response; @@ -64,7 +64,7 @@ fn provider(name: &str) -> Provider { base_url: "https://example.com/v1".to_string(), query_params: None, headers: HeaderMap::new(), - retry: codex_api::provider::RetryConfig { + retry: codex_api::RetryConfig { max_attempts: 1, base_delay: Duration::from_millis(1), retry_429: false, diff --git a/codex-rs/codex-backend-openapi-models/src/models/mod.rs b/codex-rs/codex-backend-openapi-models/src/models/mod.rs index 90bc05833..2140c83f9 100644 --- a/codex-rs/codex-backend-openapi-models/src/models/mod.rs +++ b/codex-rs/codex-backend-openapi-models/src/models/mod.rs @@ -4,41 +4,41 @@ // The process for this will change // Config -pub mod config_file_response; +pub(crate) mod config_file_response; pub use self::config_file_response::ConfigFileResponse; // Cloud Tasks -pub mod code_task_details_response; +pub(crate) mod code_task_details_response; pub use self::code_task_details_response::CodeTaskDetailsResponse; -pub mod task_response; +pub(crate) mod task_response; pub use self::task_response::TaskResponse; -pub mod external_pull_request_response; +pub(crate) mod external_pull_request_response; pub use self::external_pull_request_response::ExternalPullRequestResponse; -pub mod git_pull_request; +pub(crate) mod git_pull_request; pub use self::git_pull_request::GitPullRequest; -pub mod task_list_item; +pub(crate) mod task_list_item; pub use self::task_list_item::TaskListItem; -pub mod paginated_list_task_list_item_; +pub(crate) mod paginated_list_task_list_item_; pub use self::paginated_list_task_list_item_::PaginatedListTaskListItem; // Rate Limits -pub mod additional_rate_limit_details; +pub(crate) mod additional_rate_limit_details; pub use self::additional_rate_limit_details::AdditionalRateLimitDetails; -pub mod rate_limit_status_payload; +pub(crate) mod rate_limit_status_payload; pub use self::rate_limit_status_payload::PlanType; pub use self::rate_limit_status_payload::RateLimitStatusPayload; -pub mod rate_limit_status_details; +pub(crate) mod rate_limit_status_details; pub use self::rate_limit_status_details::RateLimitStatusDetails; -pub mod rate_limit_window_snapshot; +pub(crate) mod rate_limit_window_snapshot; pub use self::rate_limit_window_snapshot::RateLimitWindowSnapshot; -pub mod credit_status_details; +pub(crate) mod credit_status_details; pub use self::credit_status_details::CreditStatusDetails; diff --git a/codex-rs/codex-mcp/src/lib.rs b/codex-rs/codex-mcp/src/lib.rs index 149578c96..48969841c 100644 --- a/codex-rs/codex-mcp/src/lib.rs +++ b/codex-rs/codex-mcp/src/lib.rs @@ -1,2 +1,40 @@ -pub mod mcp; -pub mod mcp_connection_manager; +pub(crate) mod mcp; +pub(crate) mod mcp_connection_manager; + +pub use mcp::CODEX_APPS_MCP_SERVER_NAME; +pub use mcp::McpAuthStatusEntry; +pub use mcp::McpConfig; +pub use mcp::McpManager; +pub use mcp::McpOAuthLoginConfig; +pub use mcp::McpOAuthLoginSupport; +pub use mcp::McpOAuthScopesSource; +pub use mcp::McpSnapshotDetail; +pub use mcp::ResolvedMcpOAuthScopes; +pub use mcp::ToolPluginProvenance; +pub use mcp::canonical_mcp_server_key; +pub use mcp::collect_mcp_snapshot; +pub use mcp::collect_mcp_snapshot_from_manager; +pub use mcp::collect_mcp_snapshot_from_manager_with_detail; +pub use mcp::collect_mcp_snapshot_with_detail; +pub use mcp::collect_missing_mcp_dependencies; +pub use mcp::compute_auth_statuses; +pub use mcp::configured_mcp_servers; +pub use mcp::discover_supported_scopes; +pub use mcp::effective_mcp_servers; +pub use mcp::group_tools_by_server; +pub use mcp::oauth_login_support; +pub use mcp::qualified_mcp_tool_name_prefix; +pub use mcp::resolve_oauth_scopes; +pub use mcp::should_retry_without_scopes; +pub use mcp::split_qualified_tool_name; +pub use mcp::tool_plugin_provenance; +pub use mcp::with_codex_apps_mcp; +pub use mcp_connection_manager::CodexAppsToolsCacheKey; +pub use mcp_connection_manager::DEFAULT_STARTUP_TIMEOUT; +pub use mcp_connection_manager::MCP_SANDBOX_STATE_CAPABILITY; +pub use mcp_connection_manager::MCP_SANDBOX_STATE_METHOD; +pub use mcp_connection_manager::McpConnectionManager; +pub use mcp_connection_manager::SandboxState; +pub use mcp_connection_manager::ToolInfo; +pub use mcp_connection_manager::codex_apps_tools_cache_key; +pub use mcp_connection_manager::filter_non_codex_apps_mcp_tools_only; diff --git a/codex-rs/codex-mcp/src/mcp/mod.rs b/codex-rs/codex-mcp/src/mcp/mod.rs index faa8ecc2f..9301ff100 100644 --- a/codex-rs/codex-mcp/src/mcp/mod.rs +++ b/codex-rs/codex-mcp/src/mcp/mod.rs @@ -1,5 +1,15 @@ -pub mod auth; +pub(crate) mod auth; mod skill_dependencies; +pub use auth::McpAuthStatusEntry; +pub use auth::McpOAuthLoginConfig; +pub use auth::McpOAuthLoginSupport; +pub use auth::McpOAuthScopesSource; +pub use auth::ResolvedMcpOAuthScopes; +pub use auth::compute_auth_statuses; +pub use auth::discover_supported_scopes; +pub use auth::oauth_login_support; +pub use auth::resolve_oauth_scopes; +pub use auth::should_retry_without_scopes; pub use skill_dependencies::canonical_mcp_server_key; pub use skill_dependencies::collect_missing_mcp_dependencies; @@ -23,7 +33,6 @@ use codex_protocol::protocol::McpListToolsResponseEvent; use codex_protocol::protocol::SandboxPolicy; use serde_json::Value; -use crate::mcp::auth::compute_auth_statuses; use crate::mcp_connection_manager::McpConnectionManager; use crate::mcp_connection_manager::SandboxState; use crate::mcp_connection_manager::codex_apps_tools_cache_key; @@ -388,7 +397,7 @@ pub fn group_tools_by_server( pub async fn collect_mcp_snapshot_from_manager( mcp_connection_manager: &McpConnectionManager, - auth_status_entries: HashMap, + auth_status_entries: HashMap, ) -> McpListToolsResponseEvent { collect_mcp_snapshot_from_manager_with_detail( mcp_connection_manager, @@ -400,7 +409,7 @@ pub async fn collect_mcp_snapshot_from_manager( pub async fn collect_mcp_snapshot_from_manager_with_detail( mcp_connection_manager: &McpConnectionManager, - auth_status_entries: HashMap, + auth_status_entries: HashMap, detail: McpSnapshotDetail, ) -> McpListToolsResponseEvent { let (tools, resources, resource_templates) = tokio::join!( diff --git a/codex-rs/codex-mcp/src/mcp_connection_manager.rs b/codex-rs/codex-mcp/src/mcp_connection_manager.rs index b4de70ee9..c90088c7d 100644 --- a/codex-rs/codex-mcp/src/mcp_connection_manager.rs +++ b/codex-rs/codex-mcp/src/mcp_connection_manager.rs @@ -19,10 +19,10 @@ use std::sync::atomic::Ordering; use std::time::Duration; use std::time::Instant; +use crate::McpAuthStatusEntry; use crate::mcp::CODEX_APPS_MCP_SERVER_NAME; use crate::mcp::McpConfig; use crate::mcp::ToolPluginProvenance; -use crate::mcp::auth::McpAuthStatusEntry; use crate::mcp::configured_mcp_servers; use crate::mcp::effective_mcp_servers; use crate::mcp::sanitize_responses_api_tool_name; @@ -1568,7 +1568,7 @@ fn filter_disallowed_codex_apps_tools(tools: Vec) -> Vec { } fn emit_duration(metric: &str, duration: Duration, tags: &[(&str, &str)]) { - if let Some(metrics) = codex_otel::metrics::global() { + if let Some(metrics) = codex_otel::global() { let _ = metrics.record_duration(metric, duration, tags); } } diff --git a/codex-rs/config/src/requirements_exec_policy.rs b/codex-rs/config/src/requirements_exec_policy.rs index 64d60f881..30a1a0e69 100644 --- a/codex-rs/config/src/requirements_exec_policy.rs +++ b/codex-rs/config/src/requirements_exec_policy.rs @@ -1,9 +1,9 @@ use codex_execpolicy::Decision; +use codex_execpolicy::PatternToken; use codex_execpolicy::Policy; -use codex_execpolicy::rule::PatternToken; -use codex_execpolicy::rule::PrefixPattern; -use codex_execpolicy::rule::PrefixRule; -use codex_execpolicy::rule::RuleRef; +use codex_execpolicy::PrefixPattern; +use codex_execpolicy::PrefixRule; +use codex_execpolicy::RuleRef; use multimap::MultiMap; use serde::Deserialize; use std::sync::Arc; diff --git a/codex-rs/core/src/agent/registry.rs b/codex-rs/core/src/agent/registry.rs index c600d5c64..1acd73085 100644 --- a/codex-rs/core/src/agent/registry.rs +++ b/codex-rs/core/src/agent/registry.rs @@ -220,7 +220,7 @@ impl AgentRegistry { } else { active_agents.used_agent_nicknames.clear(); active_agents.nickname_reset_count += 1; - if let Some(metrics) = codex_otel::metrics::global() { + if let Some(metrics) = codex_otel::global() { let _ = metrics.counter( "codex.multi_agent.nickname_pool_reset", /*inc*/ 1, diff --git a/codex-rs/core/src/apps/render.rs b/codex-rs/core/src/apps/render.rs index 9b93913d7..fe23a09f8 100644 --- a/codex-rs/core/src/apps/render.rs +++ b/codex-rs/core/src/apps/render.rs @@ -1,5 +1,5 @@ use codex_app_server_protocol::AppInfo; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; use codex_protocol::protocol::APPS_INSTRUCTIONS_CLOSE_TAG; use codex_protocol::protocol::APPS_INSTRUCTIONS_OPEN_TAG; diff --git a/codex-rs/core/src/client.rs b/codex-rs/core/src/client.rs index b77dda2b7..e11e4362c 100644 --- a/codex-rs/core/src/client.rs +++ b/codex-rs/core/src/client.rs @@ -31,12 +31,15 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; +use codex_api::ApiError; use codex_api::CompactClient as ApiCompactClient; use codex_api::CompactionInput as ApiCompactionInput; +use codex_api::Compression; use codex_api::MemoriesClient as ApiMemoriesClient; use codex_api::MemorySummarizeInput as ApiMemorySummarizeInput; use codex_api::MemorySummarizeOutput as ApiMemorySummarizeOutput; use codex_api::RawMemory as ApiRawMemory; +use codex_api::Reasoning; use codex_api::RequestTelemetry; use codex_api::ReqwestTransport; use codex_api::ResponseCreateWsRequest; @@ -45,15 +48,12 @@ use codex_api::ResponsesClient as ApiResponsesClient; use codex_api::ResponsesOptions as ApiResponsesOptions; use codex_api::ResponsesWebsocketClient as ApiWebSocketResponsesClient; use codex_api::ResponsesWebsocketConnection as ApiWebSocketConnection; +use codex_api::ResponsesWsRequest; use codex_api::SseTelemetry; use codex_api::TransportError; use codex_api::WebsocketTelemetry; use codex_api::build_conversation_headers; -use codex_api::common::Reasoning; -use codex_api::common::ResponsesWsRequest; use codex_api::create_text_param_for_request; -use codex_api::error::ApiError; -use codex_api::requests::responses::Compression; use codex_api::response_create_client_metadata; use codex_app_server_protocol::AuthMode; use codex_login::AuthManager; @@ -98,8 +98,8 @@ use crate::client_common::ResponseEvent; use crate::client_common::ResponseStream; use crate::flags::CODEX_RS_SSE_FIXTURE; use crate::util::emit_feedback_auth_recovery_tags; -use codex_api::api_bridge::CoreAuthProvider; -use codex_api::api_bridge::map_api_error; +use codex_api::CoreAuthProvider; +use codex_api::map_api_error; use codex_feedback::FeedbackRequestTags; use codex_feedback::emit_feedback_request_tags_with_auth_env; use codex_login::api_bridge::auth_provider_from_auth; diff --git a/codex-rs/core/src/client_common.rs b/codex-rs/core/src/client_common.rs index 828839ae7..a90d75bf0 100644 --- a/codex-rs/core/src/client_common.rs +++ b/codex-rs/core/src/client_common.rs @@ -1,4 +1,4 @@ -pub use codex_api::common::ResponseEvent; +pub use codex_api::ResponseEvent; use codex_config::types::Personality; use codex_protocol::error::Result; use codex_protocol::models::BaseInstructions; diff --git a/codex-rs/core/src/client_common_tests.rs b/codex-rs/core/src/client_common_tests.rs index 968703046..3d804cda8 100644 --- a/codex-rs/core/src/client_common_tests.rs +++ b/codex-rs/core/src/client_common_tests.rs @@ -1,6 +1,6 @@ +use codex_api::OpenAiVerbosity; use codex_api::ResponsesApiRequest; -use codex_api::common::OpenAiVerbosity; -use codex_api::common::TextControls; +use codex_api::TextControls; use codex_api::create_text_param_for_request; use codex_protocol::config_types::ServiceTier; use codex_protocol::models::FunctionCallOutputPayload; diff --git a/codex-rs/core/src/client_tests.rs b/codex-rs/core/src/client_tests.rs index a4fb68120..02d742247 100644 --- a/codex-rs/core/src/client_tests.rs +++ b/codex-rs/core/src/client_tests.rs @@ -6,7 +6,7 @@ use super::X_CODEX_PARENT_THREAD_ID_HEADER; use super::X_CODEX_TURN_METADATA_HEADER; use super::X_CODEX_WINDOW_ID_HEADER; use super::X_OPENAI_SUBAGENT_HEADER; -use codex_api::api_bridge::CoreAuthProvider; +use codex_api::CoreAuthProvider; use codex_app_server_protocol::AuthMode; use codex_model_provider_info::WireApi; use codex_model_provider_info::create_oss_provider_with_base_url; diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 237b77e38..822dbefa5 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -70,11 +70,11 @@ use codex_login::AuthManager; use codex_login::CodexAuth; use codex_login::auth_env_telemetry::collect_auth_env_telemetry; use codex_login::default_client::originator; -use codex_mcp::mcp_connection_manager::McpConnectionManager; -use codex_mcp::mcp_connection_manager::SandboxState; -use codex_mcp::mcp_connection_manager::ToolInfo as McpToolInfo; -use codex_mcp::mcp_connection_manager::codex_apps_tools_cache_key; -use codex_mcp::mcp_connection_manager::filter_non_codex_apps_mcp_tools_only; +use codex_mcp::McpConnectionManager; +use codex_mcp::SandboxState; +use codex_mcp::ToolInfo as McpToolInfo; +use codex_mcp::codex_apps_tools_cache_key; +use codex_mcp::filter_non_codex_apps_mcp_tools_only; #[cfg(test)] use codex_models_manager::collaboration_mode_presets::CollaborationModesConfig; use codex_models_manager::manager::ModelsManager; @@ -149,7 +149,6 @@ use rmcp::model::PaginatedRequestParams; use rmcp::model::ReadResourceRequestParams; use rmcp::model::ReadResourceResult; use rmcp::model::RequestId; -use serde_json; use serde_json::Value; use tokio::sync::Mutex; use tokio::sync::RwLock; @@ -322,12 +321,12 @@ use crate::util::backoff; use crate::windows_sandbox::WindowsSandboxLevelExt; use codex_async_utils::OrCancelExt; use codex_git_utils::get_git_repo_root; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_mcp::mcp::auth::compute_auth_statuses; -use codex_mcp::mcp::with_codex_apps_mcp; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::compute_auth_statuses; +use codex_mcp::with_codex_apps_mcp; use codex_otel::SessionTelemetry; +use codex_otel::THREAD_STARTED_METRIC; use codex_otel::TelemetryAuthMode; -use codex_otel::metrics::names::THREAD_STARTED_METRIC; use codex_protocol::config_types::CollaborationMode; use codex_protocol::config_types::Personality; use codex_protocol::config_types::ReasoningSummary as ReasoningSummaryConfig; @@ -407,8 +406,6 @@ pub(crate) type SessionLoopTermination = Shared>; pub struct CodexSpawnOk { pub codex: Codex, pub thread_id: ThreadId, - #[deprecated(note = "use thread_id")] - pub conversation_id: ThreadId, } pub(crate) struct CodexSpawnArgs { @@ -701,12 +698,7 @@ impl Codex { session_loop_termination: session_loop_termination_from_handle(session_loop_handle), }; - #[allow(deprecated)] - Ok(CodexSpawnOk { - codex, - thread_id, - conversation_id: thread_id, - }) + Ok(CodexSpawnOk { codex, thread_id }) } /// Submit the `op` wrapped in a `Submission` with a unique ID. @@ -4791,8 +4783,8 @@ mod handlers { use crate::tasks::UserShellCommandMode; use crate::tasks::UserShellCommandTask; use crate::tasks::execute_user_shell_command; - use codex_mcp::mcp::auth::compute_auth_statuses; - use codex_mcp::mcp::collect_mcp_snapshot_from_manager; + use codex_mcp::collect_mcp_snapshot_from_manager; + use codex_mcp::compute_auth_statuses; use codex_protocol::protocol::CodexErrorInfo; use codex_protocol::protocol::ErrorEvent; use codex_protocol::protocol::Event; diff --git a/codex-rs/core/src/codex_tests.rs b/codex-rs/core/src/codex_tests.rs index 0bfb0c303..ef9a69d34 100644 --- a/codex-rs/core/src/codex_tests.rs +++ b/codex-rs/core/src/codex_tests.rs @@ -15,7 +15,7 @@ use crate::tools::format_exec_output_str; use codex_features::Features; use codex_login::CodexAuth; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::ToolInfo; use codex_model_provider_info::ModelProviderInfo; use codex_models_manager::bundled_models_response; use codex_models_manager::model_info; @@ -36,9 +36,9 @@ use codex_protocol::request_permissions::PermissionGrantScope; use codex_protocol::request_permissions::RequestPermissionProfile; use tracing::Span; +use crate::RolloutRecorderParams; use crate::rollout::policy::EventPersistenceMode; use crate::rollout::recorder::RolloutRecorder; -use crate::rollout::recorder::RolloutRecorderParams; use crate::state::TaskKind; use crate::tasks::SessionTask; use crate::tasks::SessionTaskContext; diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index 20d3dd2f1..5b1bfe83c 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -54,7 +54,7 @@ use codex_features::FeatureConfigSource; use codex_features::FeatureOverrides; use codex_features::Features; use codex_login::AuthManagerConfig; -use codex_mcp::mcp::McpConfig; +use codex_mcp::McpConfig; use codex_model_provider_info::LEGACY_OLLAMA_CHAT_PROVIDER_ID; use codex_model_provider_info::ModelProviderInfo; use codex_model_provider_info::OLLAMA_CHAT_PROVIDER_REMOVED_ERROR; @@ -100,7 +100,7 @@ mod network_proxy_spec; mod permissions; #[cfg(test)] mod schema; -pub mod service; +pub(crate) mod service; pub use codex_config::Constrained; pub use codex_config::ConstraintError; pub use codex_config::ConstraintResult; diff --git a/codex-rs/core/src/connectors.rs b/codex-rs/core/src/connectors.rs index 334e160f1..ad3447eaf 100644 --- a/codex-rs/core/src/connectors.rs +++ b/codex-rs/core/src/connectors.rs @@ -40,14 +40,14 @@ use codex_login::CodexAuth; use codex_login::default_client::create_client; use codex_login::default_client::is_first_party_chat_originator; use codex_login::default_client::originator; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_mcp::mcp::ToolPluginProvenance; -use codex_mcp::mcp::auth::compute_auth_statuses; -use codex_mcp::mcp::with_codex_apps_mcp; -use codex_mcp::mcp_connection_manager::McpConnectionManager; -use codex_mcp::mcp_connection_manager::SandboxState; -use codex_mcp::mcp_connection_manager::ToolInfo; -use codex_mcp::mcp_connection_manager::codex_apps_tools_cache_key; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::McpConnectionManager; +use codex_mcp::SandboxState; +use codex_mcp::ToolInfo; +use codex_mcp::ToolPluginProvenance; +use codex_mcp::codex_apps_tools_cache_key; +use codex_mcp::compute_auth_statuses; +use codex_mcp::with_codex_apps_mcp; pub use codex_connectors::CONNECTORS_CACHE_TTL; const CONNECTORS_READY_TIMEOUT_ON_EMPTY_TOOLS: Duration = Duration::from_secs(30); diff --git a/codex-rs/core/src/connectors_tests.rs b/codex-rs/core/src/connectors_tests.rs index 893ab243c..7a45a97a1 100644 --- a/codex-rs/core/src/connectors_tests.rs +++ b/codex-rs/core/src/connectors_tests.rs @@ -12,8 +12,8 @@ use codex_config::types::AppToolConfig; use codex_config::types::AppToolsConfig; use codex_config::types::AppsDefaultConfig; use codex_features::Feature; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::ToolInfo; use codex_utils_absolute_path::AbsolutePathBuf; use pretty_assertions::assert_eq; use rmcp::model::JsonObject; diff --git a/codex-rs/core/src/exec.rs b/codex-rs/core/src/exec.rs index 309dbbb01..8a5572a36 100644 --- a/codex-rs/core/src/exec.rs +++ b/codex-rs/core/src/exec.rs @@ -417,7 +417,7 @@ fn record_windows_sandbox_spawn_failure( } else { "legacy" }; - if let Some(metrics) = codex_otel::metrics::global() { + if let Some(metrics) = codex_otel::global() { let _ = metrics.counter( "codex.windows_sandbox.createprocessasuserw_failed", /*inc*/ 1, diff --git a/codex-rs/core/src/external_agent_config.rs b/codex-rs/core/src/external_agent_config.rs index 6011d18ee..efa90c849 100644 --- a/codex-rs/core/src/external_agent_config.rs +++ b/codex-rs/core/src/external_agent_config.rs @@ -676,7 +676,7 @@ fn emit_migration_metric( item_type: ExternalAgentConfigMigrationItemType, skills_count: Option, ) { - let Some(metrics) = codex_otel::metrics::global() else { + let Some(metrics) = codex_otel::global() else { return; }; let tags = migration_metric_tags(item_type, skills_count); diff --git a/codex-rs/core/src/instructions/mod.rs b/codex-rs/core/src/instructions/mod.rs index 5af9a6e89..a1f77ba5e 100644 --- a/codex-rs/core/src/instructions/mod.rs +++ b/codex-rs/core/src/instructions/mod.rs @@ -1,2 +1 @@ -pub use codex_instructions::USER_INSTRUCTIONS_PREFIX; pub(crate) use codex_instructions::UserInstructions; diff --git a/codex-rs/core/src/lib.rs b/codex-rs/core/src/lib.rs index d68c2b299..e13a19b29 100644 --- a/codex-rs/core/src/lib.rs +++ b/codex-rs/core/src/lib.rs @@ -10,7 +10,7 @@ mod apps; mod arc_monitor; mod client; mod client_common; -pub mod codex; +pub(crate) mod codex; mod realtime_context; mod realtime_conversation; pub use codex::SteerInputError; @@ -38,28 +38,40 @@ mod flags; mod git_info_tests; mod guardian; mod hook_runtime; -pub mod instructions; -pub mod landlock; -pub mod mcp; +pub(crate) mod instructions; +pub(crate) mod landlock; +pub use landlock::spawn_command_under_linux_sandbox; +pub(crate) mod mcp; mod mcp_skill_dependencies; mod mcp_tool_approval_templates; mod network_policy_decision; -pub mod network_proxy_loader; +pub(crate) mod network_proxy_loader; +pub use mcp::McpManager; +pub use network_proxy_loader::MtimeConfigReloader; +pub use network_proxy_loader::build_network_proxy_state; +pub use network_proxy_loader::build_network_proxy_state_and_reloader; mod original_image_detail; -pub use codex_mcp::mcp_connection_manager; -pub use codex_mcp::mcp_connection_manager::MCP_SANDBOX_STATE_CAPABILITY; -pub use codex_mcp::mcp_connection_manager::MCP_SANDBOX_STATE_METHOD; -pub use codex_mcp::mcp_connection_manager::SandboxState; +pub use codex_mcp::MCP_SANDBOX_STATE_CAPABILITY; +pub use codex_mcp::MCP_SANDBOX_STATE_METHOD; +pub use codex_mcp::SandboxState; mod mcp_tool_call; mod memories; -pub mod mention_syntax; -pub mod message_history; -pub mod utils; +pub(crate) mod mention_syntax; +pub(crate) mod message_history; +pub(crate) mod utils; +pub use mention_syntax::PLUGIN_TEXT_MENTION_SIGIL; +pub use mention_syntax::TOOL_MENTION_SIGIL; +pub use message_history::HistoryEntry as MessageHistoryEntry; +pub use message_history::append_entry as append_message_history_entry; +pub use message_history::history_metadata as message_history_metadata; +pub use message_history::lookup as lookup_message_history_entry; pub use utils::path_utils; pub mod personality_migration; pub mod plugins; #[doc(hidden)] -pub mod prompt_debug; +pub(crate) mod prompt_debug; +#[doc(hidden)] +pub use prompt_debug::build_prompt_input; pub(crate) mod mentions { pub(crate) use crate::plugins::build_connector_slug_counts; pub(crate) use crate::plugins::build_skill_name_counts; @@ -102,54 +114,63 @@ mod event_mapping; pub mod review_format; pub mod review_prompts; mod thread_manager; -pub mod web_search; -pub mod windows_sandbox_read_grants; +pub(crate) mod web_search; +pub(crate) mod windows_sandbox_read_grants; pub use thread_manager::ForkSnapshot; pub use thread_manager::NewThread; pub use thread_manager::ThreadManager; +pub use web_search::web_search_action_detail; +pub use web_search::web_search_detail; +pub use windows_sandbox_read_grants::grant_read_root_non_elevated; #[deprecated(note = "use ThreadManager")] pub type ConversationManager = ThreadManager; #[deprecated(note = "use NewThread")] pub type NewConversation = NewThread; #[deprecated(note = "use CodexThread")] pub type CodexConversation = CodexThread; -pub mod project_doc; +pub(crate) mod project_doc; +pub use project_doc::DEFAULT_PROJECT_DOC_FILENAME; +pub use project_doc::LOCAL_PROJECT_DOC_FILENAME; +pub use project_doc::discover_project_doc_paths; +pub use project_doc::read_project_docs; mod rollout; pub(crate) mod safety; pub mod seatbelt; mod session_rollout_init_error; pub mod shell; -pub mod shell_snapshot; +pub(crate) mod shell_snapshot; pub mod spawn; -pub mod state_db_bridge; +pub(crate) mod state_db_bridge; +pub use state_db_bridge::StateDbHandle; +pub use state_db_bridge::get_state_db; mod thread_rollout_truncation; mod tools; -pub mod turn_diff_tracker; +pub(crate) mod turn_diff_tracker; mod turn_metadata; mod turn_timing; pub use rollout::ARCHIVED_SESSIONS_SUBDIR; +pub use rollout::Cursor; +pub use rollout::EventPersistenceMode; pub use rollout::INTERACTIVE_SESSION_SOURCES; pub use rollout::RolloutRecorder; pub use rollout::RolloutRecorderParams; pub use rollout::SESSIONS_SUBDIR; pub use rollout::SessionMeta; +pub use rollout::ThreadItem; +pub use rollout::ThreadSortKey; +pub use rollout::ThreadsPage; pub use rollout::append_thread_name; pub use rollout::find_archived_thread_path_by_id_str; #[deprecated(note = "use find_thread_path_by_id_str")] pub use rollout::find_conversation_path_by_id_str; pub use rollout::find_thread_name_by_id; +pub use rollout::find_thread_names_by_ids; pub use rollout::find_thread_path_by_id_str; pub use rollout::find_thread_path_by_name_str; -pub use rollout::list::Cursor; -pub use rollout::list::ThreadItem; -pub use rollout::list::ThreadSortKey; -pub use rollout::list::ThreadsPage; -pub use rollout::list::parse_cursor; -pub use rollout::list::read_head_for_summary; -pub use rollout::list::read_session_meta_line; -pub use rollout::policy::EventPersistenceMode; +pub use rollout::parse_cursor; +pub use rollout::read_head_for_summary; +pub use rollout::read_session_meta_line; pub use rollout::rollout_date_parts; -pub use rollout::session_index::find_thread_names_by_ids; mod function_tool; mod state; mod tasks; @@ -172,5 +193,7 @@ pub use exec_policy::load_exec_policy; pub use file_watcher::FileWatcherEvent; pub use turn_metadata::build_turn_metadata_header; pub mod compact; -pub mod memory_trace; +pub(crate) mod memory_trace; +pub use memory_trace::BuiltMemory; +pub use memory_trace::build_memories_from_trace_files; pub mod otel_init; diff --git a/codex-rs/core/src/mcp.rs b/codex-rs/core/src/mcp.rs index d82452c54..83becdc07 100644 --- a/codex-rs/core/src/mcp.rs +++ b/codex-rs/core/src/mcp.rs @@ -5,10 +5,10 @@ use crate::config::Config; use crate::plugins::PluginsManager; use codex_config::McpServerConfig; use codex_login::CodexAuth; -use codex_mcp::mcp::ToolPluginProvenance; -use codex_mcp::mcp::configured_mcp_servers; -use codex_mcp::mcp::effective_mcp_servers; -use codex_mcp::mcp::tool_plugin_provenance as collect_tool_plugin_provenance; +use codex_mcp::ToolPluginProvenance; +use codex_mcp::configured_mcp_servers; +use codex_mcp::effective_mcp_servers; +use codex_mcp::tool_plugin_provenance as collect_tool_plugin_provenance; #[derive(Clone)] pub struct McpManager { diff --git a/codex-rs/core/src/mcp_skill_dependencies.rs b/codex-rs/core/src/mcp_skill_dependencies.rs index dfd8a4c5c..fca38919a 100644 --- a/codex-rs/core/src/mcp_skill_dependencies.rs +++ b/codex-rs/core/src/mcp_skill_dependencies.rs @@ -21,10 +21,10 @@ use crate::SkillMetadata; use crate::codex::Session; use crate::codex::TurnContext; use crate::skills::model::SkillToolDependency; -use codex_mcp::mcp::auth::McpOAuthLoginSupport; -use codex_mcp::mcp::auth::oauth_login_support; -use codex_mcp::mcp::auth::resolve_oauth_scopes; -use codex_mcp::mcp::auth::should_retry_without_scopes; +use codex_mcp::McpOAuthLoginSupport; +use codex_mcp::oauth_login_support; +use codex_mcp::resolve_oauth_scopes; +use codex_mcp::should_retry_without_scopes; const SKILL_MCP_DEPENDENCY_PROMPT_ID: &str = "skill_mcp_dependency_install"; const MCP_DEPENDENCY_OPTION_INSTALL: &str = "Install"; diff --git a/codex-rs/core/src/mcp_tool_call.rs b/codex-rs/core/src/mcp_tool_call.rs index 344e46d0b..2a94d13f8 100644 --- a/codex-rs/core/src/mcp_tool_call.rs +++ b/codex-rs/core/src/mcp_tool_call.rs @@ -32,7 +32,7 @@ use codex_analytics::InvocationType; use codex_analytics::build_track_events_context; use codex_config::types::AppToolApproval; use codex_features::Feature; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; use codex_otel::sanitize_metric_tag_value; use codex_protocol::mcp::CallToolResult; use codex_protocol::openai_models::InputModality; diff --git a/codex-rs/core/src/otel_init.rs b/codex-rs/core/src/otel_init.rs index c732692d6..4a0e7cd98 100644 --- a/codex-rs/core/src/otel_init.rs +++ b/codex-rs/core/src/otel_init.rs @@ -3,11 +3,11 @@ use codex_config::types::OtelExporterKind as Kind; use codex_config::types::OtelHttpProtocol as Protocol; use codex_features::Feature; use codex_login::default_client::originator; +use codex_otel::OtelExporter; +use codex_otel::OtelHttpProtocol; use codex_otel::OtelProvider; -use codex_otel::config::OtelExporter; -use codex_otel::config::OtelHttpProtocol; -use codex_otel::config::OtelSettings; -use codex_otel::config::OtelTlsConfig as OtelTlsSettings; +use codex_otel::OtelSettings; +use codex_otel::OtelTlsConfig as OtelTlsSettings; use std::error::Error; /// Build an OpenTelemetry provider from the app Config. diff --git a/codex-rs/core/src/plugins/injection.rs b/codex-rs/core/src/plugins/injection.rs index e482010b2..3e5bb6ecb 100644 --- a/codex-rs/core/src/plugins/injection.rs +++ b/codex-rs/core/src/plugins/injection.rs @@ -7,8 +7,8 @@ use codex_protocol::models::ResponseItem; use crate::connectors; use crate::plugins::PluginCapabilitySummary; use crate::plugins::render_explicit_plugin_instructions; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::ToolInfo; pub(crate) fn build_plugin_injections( mentioned_plugins: &[PluginCapabilitySummary], diff --git a/codex-rs/core/src/plugins/startup_sync.rs b/codex-rs/core/src/plugins/startup_sync.rs index 14608d131..5bca32de1 100644 --- a/codex-rs/core/src/plugins/startup_sync.rs +++ b/codex-rs/core/src/plugins/startup_sync.rs @@ -6,8 +6,8 @@ use std::process::Stdio; use std::sync::Arc; use std::time::Duration; -use codex_otel::metrics::names::CURATED_PLUGINS_STARTUP_SYNC_FINAL_METRIC; -use codex_otel::metrics::names::CURATED_PLUGINS_STARTUP_SYNC_METRIC; +use codex_otel::CURATED_PLUGINS_STARTUP_SYNC_FINAL_METRIC; +use codex_otel::CURATED_PLUGINS_STARTUP_SYNC_METRIC; use reqwest::Client; use serde::Deserialize; use tempfile::TempDir; @@ -451,7 +451,7 @@ fn emit_curated_plugins_startup_sync_counter( transport: &'static str, status: &'static str, ) { - let Some(metrics) = codex_otel::metrics::global() else { + let Some(metrics) = codex_otel::global() else { return; }; let tags = [("transport", transport), ("status", status)]; diff --git a/codex-rs/core/src/realtime_conversation.rs b/codex-rs/core/src/realtime_conversation.rs index 4eb427804..16f88650a 100644 --- a/codex-rs/core/src/realtime_conversation.rs +++ b/codex-rs/core/src/realtime_conversation.rs @@ -12,9 +12,9 @@ use codex_api::RealtimeEventParser; use codex_api::RealtimeSessionConfig; use codex_api::RealtimeSessionMode; use codex_api::RealtimeWebsocketClient; -use codex_api::api_bridge::map_api_error; -use codex_api::endpoint::realtime_websocket::RealtimeWebsocketEvents; -use codex_api::endpoint::realtime_websocket::RealtimeWebsocketWriter; +use codex_api::RealtimeWebsocketEvents; +use codex_api::RealtimeWebsocketWriter; +use codex_api::map_api_error; use codex_app_server_protocol::AuthMode; use codex_config::config_toml::RealtimeWsMode; use codex_config::config_toml::RealtimeWsVersion; diff --git a/codex-rs/core/src/rollout.rs b/codex-rs/core/src/rollout.rs index c3a721871..492b0bc05 100644 --- a/codex-rs/core/src/rollout.rs +++ b/codex-rs/core/src/rollout.rs @@ -1,17 +1,26 @@ use crate::config::Config; pub use codex_rollout::ARCHIVED_SESSIONS_SUBDIR; +pub use codex_rollout::Cursor; +pub use codex_rollout::EventPersistenceMode; pub use codex_rollout::INTERACTIVE_SESSION_SOURCES; pub use codex_rollout::RolloutRecorder; pub use codex_rollout::RolloutRecorderParams; pub use codex_rollout::SESSIONS_SUBDIR; pub use codex_rollout::SessionMeta; +pub use codex_rollout::ThreadItem; +pub use codex_rollout::ThreadSortKey; +pub use codex_rollout::ThreadsPage; pub use codex_rollout::append_thread_name; pub use codex_rollout::find_archived_thread_path_by_id_str; #[deprecated(note = "use find_thread_path_by_id_str")] pub use codex_rollout::find_conversation_path_by_id_str; pub use codex_rollout::find_thread_name_by_id; +pub use codex_rollout::find_thread_names_by_ids; pub use codex_rollout::find_thread_path_by_id_str; pub use codex_rollout::find_thread_path_by_name_str; +pub use codex_rollout::parse_cursor; +pub use codex_rollout::read_head_for_summary; +pub use codex_rollout::read_session_meta_line; pub use codex_rollout::rollout_date_parts; impl codex_rollout::RolloutConfigView for Config { @@ -36,24 +45,30 @@ impl codex_rollout::RolloutConfigView for Config { } } -pub mod list { - pub use codex_rollout::list::*; +pub(crate) mod list { + pub use codex_rollout::ThreadListConfig; + pub use codex_rollout::ThreadListLayout; + pub use codex_rollout::ThreadSortKey; + pub use codex_rollout::find_thread_path_by_id_str; + pub use codex_rollout::get_threads_in_root; } pub(crate) mod metadata { - pub(crate) use codex_rollout::metadata::builder_from_items; + pub(crate) use codex_rollout::builder_from_items; } -pub mod policy { - pub use codex_rollout::policy::*; +pub(crate) mod policy { + pub use codex_rollout::EventPersistenceMode; + pub use codex_rollout::should_persist_response_item_for_memories; } -pub mod recorder { - pub use codex_rollout::recorder::*; +pub(crate) mod recorder { + pub use codex_rollout::RolloutRecorder; } -pub mod session_index { - pub use codex_rollout::session_index::*; +pub(crate) mod session_index { + pub use codex_rollout::append_thread_name; + pub use codex_rollout::find_thread_name_by_id; } pub(crate) use crate::session_rollout_init_error::map_session_init_error; diff --git a/codex-rs/core/src/session_startup_prewarm.rs b/codex-rs/core/src/session_startup_prewarm.rs index 708401aed..d3ab0e619 100644 --- a/codex-rs/core/src/session_startup_prewarm.rs +++ b/codex-rs/core/src/session_startup_prewarm.rs @@ -13,9 +13,9 @@ use crate::codex::INITIAL_SUBMIT_ID; use crate::codex::Session; use crate::codex::build_prompt; use crate::codex::built_tools; +use codex_otel::STARTUP_PREWARM_AGE_AT_FIRST_TURN_METRIC; +use codex_otel::STARTUP_PREWARM_DURATION_METRIC; use codex_otel::SessionTelemetry; -use codex_otel::metrics::names::STARTUP_PREWARM_AGE_AT_FIRST_TURN_METRIC; -use codex_otel::metrics::names::STARTUP_PREWARM_DURATION_METRIC; use codex_protocol::error::Result as CodexResult; use codex_protocol::models::BaseInstructions; diff --git a/codex-rs/core/src/state/service.rs b/codex-rs/core/src/state/service.rs index a0600ddce..e5c3a00cb 100644 --- a/codex-rs/core/src/state/service.rs +++ b/codex-rs/core/src/state/service.rs @@ -17,7 +17,7 @@ use codex_analytics::AnalyticsEventsClient; use codex_exec_server::Environment; use codex_hooks::Hooks; use codex_login::AuthManager; -use codex_mcp::mcp_connection_manager::McpConnectionManager; +use codex_mcp::McpConnectionManager; use codex_models_manager::manager::ModelsManager; use codex_otel::SessionTelemetry; use codex_rollout::state_db::StateDbHandle; diff --git a/codex-rs/core/src/state_db_bridge.rs b/codex-rs/core/src/state_db_bridge.rs index f073c498b..c588f039d 100644 --- a/codex-rs/core/src/state_db_bridge.rs +++ b/codex-rs/core/src/state_db_bridge.rs @@ -1,18 +1,5 @@ use codex_rollout::state_db as rollout_state_db; pub use codex_rollout::state_db::StateDbHandle; -pub use codex_rollout::state_db::apply_rollout_items; -pub use codex_rollout::state_db::find_rollout_path_by_id; -pub use codex_rollout::state_db::get_dynamic_tools; -pub use codex_rollout::state_db::list_thread_ids_db; -pub use codex_rollout::state_db::list_threads_db; -pub use codex_rollout::state_db::mark_thread_memory_mode_polluted; -pub use codex_rollout::state_db::normalize_cwd_for_state_db; -pub use codex_rollout::state_db::open_if_present; -pub use codex_rollout::state_db::persist_dynamic_tools; -pub use codex_rollout::state_db::read_repair_rollout_path; -pub use codex_rollout::state_db::reconcile_rollout; -pub use codex_rollout::state_db::touch_thread_updated_at; -pub use codex_state::LogEntry; use crate::config::Config; diff --git a/codex-rs/core/src/tasks/mod.rs b/codex-rs/core/src/tasks/mod.rs index f33e6886f..5da3650bf 100644 --- a/codex-rs/core/src/tasks/mod.rs +++ b/codex-rs/core/src/tasks/mod.rs @@ -33,10 +33,10 @@ use crate::state::TaskKind; use codex_login::AuthManager; use codex_models_manager::manager::ModelsManager; use codex_otel::SessionTelemetry; -use codex_otel::metrics::names::TURN_E2E_DURATION_METRIC; -use codex_otel::metrics::names::TURN_NETWORK_PROXY_METRIC; -use codex_otel::metrics::names::TURN_TOKEN_USAGE_METRIC; -use codex_otel::metrics::names::TURN_TOOL_CALL_METRIC; +use codex_otel::TURN_E2E_DURATION_METRIC; +use codex_otel::TURN_NETWORK_PROXY_METRIC; +use codex_otel::TURN_TOKEN_USAGE_METRIC; +use codex_otel::TURN_TOOL_CALL_METRIC; use codex_protocol::models::ContentItem; use codex_protocol::models::ResponseInputItem; use codex_protocol::models::ResponseItem; diff --git a/codex-rs/core/src/tasks/mod_tests.rs b/codex-rs/core/src/tasks/mod_tests.rs index 6573da5d4..22bf0a99c 100644 --- a/codex-rs/core/src/tasks/mod_tests.rs +++ b/codex-rs/core/src/tasks/mod_tests.rs @@ -1,8 +1,8 @@ use super::emit_turn_network_proxy_metric; +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; use codex_otel::SessionTelemetry; -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::names::TURN_NETWORK_PROXY_METRIC; +use codex_otel::TURN_NETWORK_PROXY_METRIC; use codex_protocol::ThreadId; use codex_protocol::protocol::SessionSource; use opentelemetry::KeyValue; diff --git a/codex-rs/core/src/tools/handlers/mod.rs b/codex-rs/core/src/tools/handlers/mod.rs index f0a62b8c1..ec6fc02cf 100644 --- a/codex-rs/core/src/tools/handlers/mod.rs +++ b/codex-rs/core/src/tools/handlers/mod.rs @@ -1,5 +1,5 @@ pub(crate) mod agent_jobs; -pub mod apply_patch; +pub(crate) mod apply_patch; mod dynamic; mod js_repl; mod list_dir; diff --git a/codex-rs/core/src/tools/handlers/multi_agents.rs b/codex-rs/core/src/tools/handlers/multi_agents.rs index df66543da..984e09a96 100644 --- a/codex-rs/core/src/tools/handlers/multi_agents.rs +++ b/codex-rs/core/src/tools/handlers/multi_agents.rs @@ -63,7 +63,7 @@ pub(crate) use send_input::Handler as SendInputHandler; pub(crate) use spawn::Handler as SpawnAgentHandler; pub(crate) use wait::Handler as WaitAgentHandler; -pub mod close_agent; +pub(crate) mod close_agent; mod resume_agent; mod send_input; mod spawn; diff --git a/codex-rs/core/src/tools/handlers/tool_search.rs b/codex-rs/core/src/tools/handlers/tool_search.rs index dd203e93b..d1033c613 100644 --- a/codex-rs/core/src/tools/handlers/tool_search.rs +++ b/codex-rs/core/src/tools/handlers/tool_search.rs @@ -7,7 +7,7 @@ use crate::tools::registry::ToolKind; use bm25::Document; use bm25::Language; use bm25::SearchEngineBuilder; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::ToolInfo; use codex_tools::TOOL_SEARCH_DEFAULT_LIMIT; use codex_tools::TOOL_SEARCH_TOOL_NAME; use codex_tools::ToolSearchResultSource; diff --git a/codex-rs/core/src/tools/handlers/tool_suggest.rs b/codex-rs/core/src/tools/handlers/tool_suggest.rs index 380aebd51..9975f5131 100644 --- a/codex-rs/core/src/tools/handlers/tool_suggest.rs +++ b/codex-rs/core/src/tools/handlers/tool_suggest.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use codex_app_server_protocol::AppInfo; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; use codex_rmcp_client::ElicitationAction; use codex_tools::DiscoverableTool; use codex_tools::DiscoverableToolAction; diff --git a/codex-rs/core/src/tools/handlers/unified_exec.rs b/codex-rs/core/src/tools/handlers/unified_exec.rs index dfe8c4275..4486cd791 100644 --- a/codex-rs/core/src/tools/handlers/unified_exec.rs +++ b/codex-rs/core/src/tools/handlers/unified_exec.rs @@ -24,7 +24,7 @@ use crate::unified_exec::UnifiedExecProcessManager; use crate::unified_exec::WriteStdinRequest; use codex_features::Feature; use codex_otel::SessionTelemetry; -use codex_otel::metrics::names::TOOL_CALL_UNIFIED_EXEC_METRIC; +use codex_otel::TOOL_CALL_UNIFIED_EXEC_METRIC; use codex_protocol::models::PermissionProfile; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::TerminalInteractionEvent; diff --git a/codex-rs/core/src/tools/mod.rs b/codex-rs/core/src/tools/mod.rs index f94f896d2..06c20d692 100644 --- a/codex-rs/core/src/tools/mod.rs +++ b/codex-rs/core/src/tools/mod.rs @@ -1,16 +1,16 @@ -pub mod code_mode; -pub mod context; -pub mod events; +pub(crate) mod code_mode; +pub(crate) mod context; +pub(crate) mod events; pub(crate) mod handlers; -pub mod js_repl; +pub(crate) mod js_repl; pub(crate) mod network_approval; -pub mod orchestrator; -pub mod parallel; -pub mod registry; -pub mod router; -pub mod runtimes; -pub mod sandboxing; -pub mod spec; +pub(crate) mod orchestrator; +pub(crate) mod parallel; +pub(crate) mod registry; +pub(crate) mod router; +pub(crate) mod runtimes; +pub(crate) mod sandboxing; +pub(crate) mod spec; use codex_protocol::exec_output::ExecToolCallOutput; use codex_utils_output_truncation::TruncationPolicy; diff --git a/codex-rs/core/src/tools/router.rs b/codex-rs/core/src/tools/router.rs index 4fd64715b..aad8c1b7d 100644 --- a/codex-rs/core/src/tools/router.rs +++ b/codex-rs/core/src/tools/router.rs @@ -8,7 +8,7 @@ use crate::tools::context::ToolPayload; use crate::tools::registry::AnyToolResult; use crate::tools::registry::ToolRegistry; use crate::tools::spec::build_specs_with_discoverable_tools; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::ToolInfo; use codex_protocol::dynamic_tools::DynamicToolSpec; use codex_protocol::models::LocalShellAction; use codex_protocol::models::ResponseItem; diff --git a/codex-rs/core/src/tools/runtimes/mod.rs b/codex-rs/core/src/tools/runtimes/mod.rs index 53890a89b..a4b44ff0e 100644 --- a/codex-rs/core/src/tools/runtimes/mod.rs +++ b/codex-rs/core/src/tools/runtimes/mod.rs @@ -12,9 +12,9 @@ use codex_sandboxing::SandboxCommand; use std::collections::HashMap; use std::path::Path; -pub mod apply_patch; -pub mod shell; -pub mod unified_exec; +pub(crate) mod apply_patch; +pub(crate) mod shell; +pub(crate) mod unified_exec; /// Shared helper to construct sandbox transform inputs from a tokenized command line. /// Validates that at least a program is present. diff --git a/codex-rs/core/src/tools/spec.rs b/codex-rs/core/src/tools/spec.rs index 90b9a382a..37a68d408 100644 --- a/codex-rs/core/src/tools/spec.rs +++ b/codex-rs/core/src/tools/spec.rs @@ -5,8 +5,8 @@ use crate::tools::handlers::multi_agents_common::DEFAULT_WAIT_TIMEOUT_MS; use crate::tools::handlers::multi_agents_common::MAX_WAIT_TIMEOUT_MS; use crate::tools::handlers::multi_agents_common::MIN_WAIT_TIMEOUT_MS; use crate::tools::registry::ToolRegistryBuilder; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; -use codex_mcp::mcp_connection_manager::ToolInfo; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::ToolInfo; use codex_protocol::dynamic_tools::DynamicToolSpec; use codex_tools::DiscoverableTool; use codex_tools::ToolHandlerKind; diff --git a/codex-rs/core/src/tools/spec_tests.rs b/codex-rs/core/src/tools/spec_tests.rs index 4615b4531..13fa4930d 100644 --- a/codex-rs/core/src/tools/spec_tests.rs +++ b/codex-rs/core/src/tools/spec_tests.rs @@ -8,7 +8,7 @@ use crate::tools::router::ToolRouterParams; use codex_app_server_protocol::AppInfo; use codex_features::Feature; use codex_features::Features; -use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME; +use codex_mcp::CODEX_APPS_MCP_SERVER_NAME; use codex_models_manager::bundled_models_response; use codex_models_manager::model_info::with_config_overrides; use codex_protocol::config_types::WebSearchMode; diff --git a/codex-rs/core/src/turn_timing.rs b/codex-rs/core/src/turn_timing.rs index a4451a52f..6c47d3b52 100644 --- a/codex-rs/core/src/turn_timing.rs +++ b/codex-rs/core/src/turn_timing.rs @@ -3,8 +3,8 @@ use std::time::Instant; use std::time::SystemTime; use std::time::UNIX_EPOCH; -use codex_otel::metrics::names::TURN_TTFM_DURATION_METRIC; -use codex_otel::metrics::names::TURN_TTFT_DURATION_METRIC; +use codex_otel::TURN_TTFM_DURATION_METRIC; +use codex_otel::TURN_TTFT_DURATION_METRIC; use codex_protocol::items::TurnItem; use codex_protocol::models::ResponseItem; use tokio::sync::Mutex; diff --git a/codex-rs/core/src/windows_sandbox.rs b/codex-rs/core/src/windows_sandbox.rs index 789b1ce34..65230b1a1 100644 --- a/codex-rs/core/src/windows_sandbox.rs +++ b/codex-rs/core/src/windows_sandbox.rs @@ -363,7 +363,7 @@ fn emit_windows_sandbox_setup_success_metrics( originator_tag: &str, duration: std::time::Duration, ) { - let Some(metrics) = codex_otel::metrics::global() else { + let Some(metrics) = codex_otel::global() else { return; }; let mode_tag = windows_sandbox_setup_mode_tag(mode); @@ -389,7 +389,7 @@ fn emit_windows_sandbox_setup_failure_metrics( duration: std::time::Duration, _err: &anyhow::Error, ) { - let Some(metrics) = codex_otel::metrics::global() else { + let Some(metrics) = codex_otel::global() else { return; }; let mode_tag = windows_sandbox_setup_mode_tag(mode); diff --git a/codex-rs/core/tests/suite/client_websockets.rs b/codex-rs/core/tests/suite/client_websockets.rs index 0a1195a11..8bf45a23d 100755 --- a/codex-rs/core/tests/suite/client_websockets.rs +++ b/codex-rs/core/tests/suite/client_websockets.rs @@ -10,11 +10,11 @@ use codex_features::Feature; use codex_login::CodexAuth; use codex_model_provider_info::ModelProviderInfo; use codex_model_provider_info::WireApi; +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; use codex_otel::SessionTelemetry; use codex_otel::TelemetryAuthMode; use codex_otel::current_span_w3c_trace_context; -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; use codex_protocol::ThreadId; use codex_protocol::account::PlanType; use codex_protocol::config_types::ReasoningSummary; diff --git a/codex-rs/core/tests/suite/pending_input.rs b/codex-rs/core/tests/suite/pending_input.rs index 2fc5bf4e3..25a08120a 100644 --- a/codex-rs/core/tests/suite/pending_input.rs +++ b/codex-rs/core/tests/suite/pending_input.rs @@ -101,6 +101,19 @@ async fn submit_user_input(codex: &CodexThread, text: &str) { .unwrap_or_else(|err| panic!("submit user input: {err}")); } +async fn steer_user_input(codex: &CodexThread, text: &str) { + codex + .steer_input( + vec![UserInput::Text { + text: text.to_string(), + text_elements: Vec::new(), + }], + /*expected_turn_id*/ None, + ) + .await + .unwrap_or_else(|err| panic!("steer user input: {err:?}")); +} + async fn submit_queue_only_agent_mail(codex: &CodexThread, text: &str) { codex .submit(Op::InterAgentCommunication { @@ -410,7 +423,7 @@ async fn user_input_does_not_preempt_after_reasoning_item() { wait_for_reasoning_item_started(&codex).await; - submit_user_input(&codex, "second prompt").await; + steer_user_input(&codex, "second prompt").await; let _ = gate_reasoning_done_tx.send(()); diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index 346e8e9e5..8c849ca80 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -7,8 +7,8 @@ mod cli; mod event_processor; mod event_processor_with_human_output; -pub mod event_processor_with_jsonl_output; -pub mod exec_events; +pub(crate) mod event_processor_with_jsonl_output; +pub(crate) mod exec_events; pub use cli::Cli; pub use cli::Command; @@ -85,7 +85,42 @@ use codex_utils_absolute_path::AbsolutePathBuf; use codex_utils_oss::ensure_oss_provider_ready; use codex_utils_oss::get_default_model_for_oss_provider; use event_processor_with_human_output::EventProcessorWithHumanOutput; -use event_processor_with_jsonl_output::EventProcessorWithJsonOutput; +pub use event_processor_with_jsonl_output::CodexStatus; +pub use event_processor_with_jsonl_output::CollectedThreadEvents; +pub use event_processor_with_jsonl_output::EventProcessorWithJsonOutput; +pub use exec_events::AgentMessageItem; +pub use exec_events::CollabAgentState; +pub use exec_events::CollabAgentStatus; +pub use exec_events::CollabTool; +pub use exec_events::CollabToolCallItem; +pub use exec_events::CollabToolCallStatus; +pub use exec_events::CommandExecutionItem; +pub use exec_events::CommandExecutionStatus; +pub use exec_events::ErrorItem; +pub use exec_events::FileChangeItem; +pub use exec_events::FileUpdateChange; +pub use exec_events::ItemCompletedEvent; +pub use exec_events::ItemStartedEvent; +pub use exec_events::ItemUpdatedEvent; +pub use exec_events::McpToolCallItem; +pub use exec_events::McpToolCallItemError; +pub use exec_events::McpToolCallItemResult; +pub use exec_events::McpToolCallStatus; +pub use exec_events::PatchApplyStatus; +pub use exec_events::PatchChangeKind; +pub use exec_events::ReasoningItem; +pub use exec_events::ThreadErrorEvent; +pub use exec_events::ThreadEvent; +pub use exec_events::ThreadItem as ExecThreadItem; +pub use exec_events::ThreadItemDetails; +pub use exec_events::ThreadStartedEvent; +pub use exec_events::TodoItem; +pub use exec_events::TodoListItem; +pub use exec_events::TurnCompletedEvent; +pub use exec_events::TurnFailedEvent; +pub use exec_events::TurnStartedEvent; +pub use exec_events::Usage; +pub use exec_events::WebSearchItem; use serde_json::Value; use std::collections::HashMap; use std::io::IsTerminal; @@ -105,7 +140,6 @@ use tracing_subscriber::prelude::*; use uuid::Uuid; use crate::cli::Command as ExecCommand; -use crate::event_processor::CodexStatus; use crate::event_processor::EventProcessor; const DEFAULT_ANALYTICS_ENABLED: bool = true; diff --git a/codex-rs/exec/tests/event_processor_with_json_output.rs b/codex-rs/exec/tests/event_processor_with_json_output.rs index c22207c91..a6b25b66b 100644 --- a/codex-rs/exec/tests/event_processor_with_json_output.rs +++ b/codex-rs/exec/tests/event_processor_with_json_output.rs @@ -37,42 +37,42 @@ use codex_protocol::protocol::SessionConfiguredEvent; use pretty_assertions::assert_eq; use serde_json::json; -use codex_exec::event_processor_with_jsonl_output::CodexStatus; -use codex_exec::event_processor_with_jsonl_output::CollectedThreadEvents; -use codex_exec::event_processor_with_jsonl_output::EventProcessorWithJsonOutput; -use codex_exec::exec_events::AgentMessageItem; -use codex_exec::exec_events::CollabAgentState; -use codex_exec::exec_events::CollabAgentStatus; -use codex_exec::exec_events::CollabTool; -use codex_exec::exec_events::CollabToolCallItem; -use codex_exec::exec_events::CollabToolCallStatus; -use codex_exec::exec_events::CommandExecutionItem; -use codex_exec::exec_events::CommandExecutionStatus; -use codex_exec::exec_events::ErrorItem; -use codex_exec::exec_events::FileChangeItem; -use codex_exec::exec_events::FileUpdateChange as ExecFileUpdateChange; -use codex_exec::exec_events::ItemCompletedEvent; -use codex_exec::exec_events::ItemStartedEvent; -use codex_exec::exec_events::ItemUpdatedEvent; -use codex_exec::exec_events::McpToolCallItem; -use codex_exec::exec_events::McpToolCallItemError; -use codex_exec::exec_events::McpToolCallItemResult; -use codex_exec::exec_events::McpToolCallStatus; -use codex_exec::exec_events::PatchApplyStatus; -use codex_exec::exec_events::PatchChangeKind; -use codex_exec::exec_events::ReasoningItem; -use codex_exec::exec_events::ThreadErrorEvent; -use codex_exec::exec_events::ThreadEvent; -use codex_exec::exec_events::ThreadItem as ExecThreadItem; -use codex_exec::exec_events::ThreadItemDetails; -use codex_exec::exec_events::ThreadStartedEvent; -use codex_exec::exec_events::TodoItem; -use codex_exec::exec_events::TodoListItem; -use codex_exec::exec_events::TurnCompletedEvent; -use codex_exec::exec_events::TurnFailedEvent; -use codex_exec::exec_events::TurnStartedEvent; -use codex_exec::exec_events::Usage; -use codex_exec::exec_events::WebSearchItem; +use codex_exec::AgentMessageItem; +use codex_exec::CodexStatus; +use codex_exec::CollabAgentState; +use codex_exec::CollabAgentStatus; +use codex_exec::CollabTool; +use codex_exec::CollabToolCallItem; +use codex_exec::CollabToolCallStatus; +use codex_exec::CollectedThreadEvents; +use codex_exec::CommandExecutionItem; +use codex_exec::CommandExecutionStatus; +use codex_exec::ErrorItem; +use codex_exec::EventProcessorWithJsonOutput; +use codex_exec::ExecThreadItem; +use codex_exec::FileChangeItem; +use codex_exec::FileUpdateChange as ExecFileUpdateChange; +use codex_exec::ItemCompletedEvent; +use codex_exec::ItemStartedEvent; +use codex_exec::ItemUpdatedEvent; +use codex_exec::McpToolCallItem; +use codex_exec::McpToolCallItemError; +use codex_exec::McpToolCallItemResult; +use codex_exec::McpToolCallStatus; +use codex_exec::PatchApplyStatus; +use codex_exec::PatchChangeKind; +use codex_exec::ReasoningItem; +use codex_exec::ThreadErrorEvent; +use codex_exec::ThreadEvent; +use codex_exec::ThreadItemDetails; +use codex_exec::ThreadStartedEvent; +use codex_exec::TodoItem; +use codex_exec::TodoListItem; +use codex_exec::TurnCompletedEvent; +use codex_exec::TurnFailedEvent; +use codex_exec::TurnStartedEvent; +use codex_exec::Usage; +use codex_exec::WebSearchItem; #[test] fn map_todo_items_preserves_text_and_completion_state() { diff --git a/codex-rs/exec/tests/suite/sandbox.rs b/codex-rs/exec/tests/suite/sandbox.rs index 70f5197e8..ee53e7d43 100644 --- a/codex-rs/exec/tests/suite/sandbox.rs +++ b/codex-rs/exec/tests/suite/sandbox.rs @@ -42,7 +42,7 @@ async fn spawn_command_under_sandbox( stdio_policy: StdioPolicy, env: HashMap, ) -> std::io::Result { - use codex_core::landlock::spawn_command_under_linux_sandbox; + use codex_core::spawn_command_under_linux_sandbox; let codex_linux_sandbox_exe = core_test_support::find_codex_linux_sandbox_exe() .map_err(|err| io::Error::new(io::ErrorKind::NotFound, err))?; spawn_command_under_linux_sandbox( diff --git a/codex-rs/execpolicy/src/amend.rs b/codex-rs/execpolicy/src/amend.rs index 7909fc14a..e25fd1bd9 100644 --- a/codex-rs/execpolicy/src/amend.rs +++ b/codex-rs/execpolicy/src/amend.rs @@ -9,7 +9,6 @@ use std::path::PathBuf; use crate::decision::Decision; use crate::rule::NetworkRuleProtocol; use crate::rule::normalize_network_rule_host; -use serde_json; use thiserror::Error; #[derive(Debug, Error)] diff --git a/codex-rs/execpolicy/src/lib.rs b/codex-rs/execpolicy/src/lib.rs index 8cb89c36e..128c9dd41 100644 --- a/codex-rs/execpolicy/src/lib.rs +++ b/codex-rs/execpolicy/src/lib.rs @@ -1,11 +1,11 @@ -pub mod amend; -pub mod decision; -pub mod error; -pub mod execpolicycheck; +pub(crate) mod amend; +pub(crate) mod decision; +pub(crate) mod error; +pub(crate) mod execpolicycheck; mod executable_name; -pub mod parser; -pub mod policy; -pub mod rule; +pub(crate) mod parser; +pub(crate) mod policy; +pub(crate) mod rule; pub use amend::AmendError; pub use amend::blocking_append_allow_prefix_rule; @@ -22,6 +22,9 @@ pub use policy::Evaluation; pub use policy::MatchOptions; pub use policy::Policy; pub use rule::NetworkRuleProtocol; +pub use rule::PatternToken; +pub use rule::PrefixPattern; +pub use rule::PrefixRule; pub use rule::Rule; pub use rule::RuleMatch; pub use rule::RuleRef; diff --git a/codex-rs/execpolicy/src/main.rs b/codex-rs/execpolicy/src/main.rs index d3b34a330..82e1bc12c 100644 --- a/codex-rs/execpolicy/src/main.rs +++ b/codex-rs/execpolicy/src/main.rs @@ -1,6 +1,6 @@ use anyhow::Result; use clap::Parser; -use codex_execpolicy::execpolicycheck::ExecPolicyCheckCommand; +use codex_execpolicy::ExecPolicyCheckCommand; /// CLI for evaluating exec policies #[derive(Parser)] diff --git a/codex-rs/execpolicy/src/parser.rs b/codex-rs/execpolicy/src/parser.rs index 46764d0e0..5d01df18b 100644 --- a/codex-rs/execpolicy/src/parser.rs +++ b/codex-rs/execpolicy/src/parser.rs @@ -1,6 +1,5 @@ use codex_utils_absolute_path::AbsolutePathBuf; use multimap::MultiMap; -use shlex; use starlark::any::ProvidesStaticType; use starlark::codemap::FileSpan; use starlark::environment::GlobalsBuilder; diff --git a/codex-rs/execpolicy/tests/basic.rs b/codex-rs/execpolicy/tests/basic.rs index bef845da6..50c3f5361 100644 --- a/codex-rs/execpolicy/tests/basic.rs +++ b/codex-rs/execpolicy/tests/basic.rs @@ -10,14 +10,14 @@ use codex_execpolicy::Error; use codex_execpolicy::Evaluation; use codex_execpolicy::MatchOptions; use codex_execpolicy::NetworkRuleProtocol; +use codex_execpolicy::PatternToken; use codex_execpolicy::Policy; use codex_execpolicy::PolicyParser; +use codex_execpolicy::PrefixPattern; +use codex_execpolicy::PrefixRule; use codex_execpolicy::RuleMatch; use codex_execpolicy::RuleRef; use codex_execpolicy::blocking_append_allow_prefix_rule; -use codex_execpolicy::rule::PatternToken; -use codex_execpolicy::rule::PrefixPattern; -use codex_execpolicy::rule::PrefixRule; use codex_utils_absolute_path::AbsolutePathBuf; use pretty_assertions::assert_eq; use tempfile::tempdir; diff --git a/codex-rs/feedback/src/lib.rs b/codex-rs/feedback/src/lib.rs index 8d9489dbe..712aeee21 100644 --- a/codex-rs/feedback/src/lib.rs +++ b/codex-rs/feedback/src/lib.rs @@ -14,8 +14,6 @@ use anyhow::anyhow; use codex_login::AuthEnvTelemetry; use codex_protocol::ThreadId; use codex_protocol::protocol::SessionSource; -use feedback_diagnostics::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME; -use feedback_diagnostics::FeedbackDiagnostics; use tracing::Event; use tracing::Level; use tracing::field::Visit; @@ -24,7 +22,10 @@ use tracing_subscriber::filter::Targets; use tracing_subscriber::fmt::writer::MakeWriter; use tracing_subscriber::registry::LookupSpan; -pub mod feedback_diagnostics; +pub(crate) mod feedback_diagnostics; +pub use feedback_diagnostics::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME; +pub use feedback_diagnostics::FeedbackDiagnostic; +pub use feedback_diagnostics::FeedbackDiagnostics; const DEFAULT_MAX_BYTES: usize = 4 * 1024 * 1024; // 4 MiB const SENTRY_DSN: &str = @@ -609,7 +610,7 @@ mod tests { use std::fs; use super::*; - use feedback_diagnostics::FeedbackDiagnostic; + use crate::FeedbackDiagnostic; use pretty_assertions::assert_eq; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; diff --git a/codex-rs/hooks/src/lib.rs b/codex-rs/hooks/src/lib.rs index 16334a647..784b41442 100644 --- a/codex-rs/hooks/src/lib.rs +++ b/codex-rs/hooks/src/lib.rs @@ -1,5 +1,5 @@ mod engine; -pub mod events; +pub(crate) mod events; mod legacy_notify; mod registry; mod schema; diff --git a/codex-rs/login/src/api_bridge.rs b/codex-rs/login/src/api_bridge.rs index 4c432ff18..d8b9dbb77 100644 --- a/codex-rs/login/src/api_bridge.rs +++ b/codex-rs/login/src/api_bridge.rs @@ -1,4 +1,4 @@ -use codex_api::api_bridge::CoreAuthProvider; +use codex_api::CoreAuthProvider; use codex_model_provider_info::ModelProviderInfo; use crate::CodexAuth; diff --git a/codex-rs/login/src/lib.rs b/codex-rs/login/src/lib.rs index f786884b3..1b52223bc 100644 --- a/codex-rs/login/src/lib.rs +++ b/codex-rs/login/src/lib.rs @@ -9,6 +9,7 @@ mod pkce; mod server; pub use codex_client::BuildCustomCaTransportError as BuildLoginHttpClientError; +pub use codex_config::types::AuthCredentialsStoreMode; pub use device_code_auth::DeviceCode; pub use device_code_auth::complete_device_code_login; pub use device_code_auth::request_device_code; diff --git a/codex-rs/model-provider-info/src/lib.rs b/codex-rs/model-provider-info/src/lib.rs index 968bcc8ed..f39ff0c7f 100644 --- a/codex-rs/model-provider-info/src/lib.rs +++ b/codex-rs/model-provider-info/src/lib.rs @@ -6,7 +6,7 @@ //! key. These override or extend the defaults at runtime. use codex_api::Provider as ApiProvider; -use codex_api::provider::RetryConfig as ApiRetryConfig; +use codex_api::RetryConfig as ApiRetryConfig; use codex_app_server_protocol::AuthMode; use codex_protocol::config_types::ModelProviderAuthInfo; use codex_protocol::error::CodexErr; diff --git a/codex-rs/models-manager/src/lib.rs b/codex-rs/models-manager/src/lib.rs index a9c0d489d..e99c33edb 100644 --- a/codex-rs/models-manager/src/lib.rs +++ b/codex-rs/models-manager/src/lib.rs @@ -1,6 +1,6 @@ -pub mod cache; +pub(crate) mod cache; pub mod collaboration_mode_presets; -pub mod config; +pub(crate) mod config; pub mod manager; pub mod model_info; pub mod model_presets; diff --git a/codex-rs/models-manager/src/manager.rs b/codex-rs/models-manager/src/manager.rs index 984c61229..a7d4aa12a 100644 --- a/codex-rs/models-manager/src/manager.rs +++ b/codex-rs/models-manager/src/manager.rs @@ -7,7 +7,7 @@ use codex_api::ModelsClient; use codex_api::RequestTelemetry; use codex_api::ReqwestTransport; use codex_api::TransportError; -use codex_api::api_bridge::map_api_error; +use codex_api::map_api_error; use codex_app_server_protocol::AuthMode; use codex_feedback::FeedbackRequestTags; use codex_feedback::emit_feedback_request_tags_with_auth_env; diff --git a/codex-rs/otel/src/events/session_telemetry.rs b/codex-rs/otel/src/events/session_telemetry.rs index 42fd6e50c..b1bf9b094 100644 --- a/codex-rs/otel/src/events/session_telemetry.rs +++ b/codex-rs/otel/src/events/session_telemetry.rs @@ -3,29 +3,29 @@ use crate::ToolDecisionSource; use crate::events::shared::log_and_trace_event; use crate::events::shared::log_event; use crate::events::shared::trace_event; +use crate::metrics::API_CALL_COUNT_METRIC; +use crate::metrics::API_CALL_DURATION_METRIC; use crate::metrics::MetricsClient; use crate::metrics::MetricsConfig; use crate::metrics::MetricsError; +use crate::metrics::PROFILE_USAGE_METRIC; +use crate::metrics::RESPONSES_API_ENGINE_IAPI_TBT_DURATION_METRIC; +use crate::metrics::RESPONSES_API_ENGINE_IAPI_TTFT_DURATION_METRIC; +use crate::metrics::RESPONSES_API_ENGINE_SERVICE_TBT_DURATION_METRIC; +use crate::metrics::RESPONSES_API_ENGINE_SERVICE_TTFT_DURATION_METRIC; +use crate::metrics::RESPONSES_API_INFERENCE_TIME_DURATION_METRIC; +use crate::metrics::RESPONSES_API_OVERHEAD_DURATION_METRIC; use crate::metrics::Result as MetricsResult; -use crate::metrics::names::API_CALL_COUNT_METRIC; -use crate::metrics::names::API_CALL_DURATION_METRIC; -use crate::metrics::names::PROFILE_USAGE_METRIC; -use crate::metrics::names::RESPONSES_API_ENGINE_IAPI_TBT_DURATION_METRIC; -use crate::metrics::names::RESPONSES_API_ENGINE_IAPI_TTFT_DURATION_METRIC; -use crate::metrics::names::RESPONSES_API_ENGINE_SERVICE_TBT_DURATION_METRIC; -use crate::metrics::names::RESPONSES_API_ENGINE_SERVICE_TTFT_DURATION_METRIC; -use crate::metrics::names::RESPONSES_API_INFERENCE_TIME_DURATION_METRIC; -use crate::metrics::names::RESPONSES_API_OVERHEAD_DURATION_METRIC; -use crate::metrics::names::SSE_EVENT_COUNT_METRIC; -use crate::metrics::names::SSE_EVENT_DURATION_METRIC; -use crate::metrics::names::TOOL_CALL_COUNT_METRIC; -use crate::metrics::names::TOOL_CALL_DURATION_METRIC; -use crate::metrics::names::WEBSOCKET_EVENT_COUNT_METRIC; -use crate::metrics::names::WEBSOCKET_EVENT_DURATION_METRIC; -use crate::metrics::names::WEBSOCKET_REQUEST_COUNT_METRIC; -use crate::metrics::names::WEBSOCKET_REQUEST_DURATION_METRIC; +use crate::metrics::SSE_EVENT_COUNT_METRIC; +use crate::metrics::SSE_EVENT_DURATION_METRIC; +use crate::metrics::SessionMetricTagValues; +use crate::metrics::TOOL_CALL_COUNT_METRIC; +use crate::metrics::TOOL_CALL_DURATION_METRIC; +use crate::metrics::WEBSOCKET_EVENT_COUNT_METRIC; +use crate::metrics::WEBSOCKET_EVENT_DURATION_METRIC; +use crate::metrics::WEBSOCKET_REQUEST_COUNT_METRIC; +use crate::metrics::WEBSOCKET_REQUEST_DURATION_METRIC; use crate::metrics::runtime_metrics::RuntimeMetricsSummary; -use crate::metrics::tags::SessionMetricTagValues; use crate::metrics::timer::Timer; use crate::provider::OtelProvider; use crate::sanitize_metric_tag_value; diff --git a/codex-rs/otel/src/lib.rs b/codex-rs/otel/src/lib.rs index ea13ad9b9..c7d0b7c41 100644 --- a/codex-rs/otel/src/lib.rs +++ b/codex-rs/otel/src/lib.rs @@ -1,23 +1,27 @@ -pub mod config; +pub(crate) mod config; mod events; -pub mod metrics; -pub mod provider; -pub mod trace_context; +pub(crate) mod metrics; +pub(crate) mod provider; +pub(crate) mod trace_context; mod otlp; mod targets; -use crate::metrics::MetricsError; use crate::metrics::Result as MetricsResult; use serde::Serialize; use strum_macros::Display; +pub use crate::config::OtelExporter; +pub use crate::config::OtelHttpProtocol; +pub use crate::config::OtelSettings; +pub use crate::config::OtelTlsConfig; pub use crate::events::session_telemetry::AuthEnvTelemetryMetadata; pub use crate::events::session_telemetry::SessionTelemetry; pub use crate::events::session_telemetry::SessionTelemetryMetadata; pub use crate::metrics::runtime_metrics::RuntimeMetricTotals; pub use crate::metrics::runtime_metrics::RuntimeMetricsSummary; pub use crate::metrics::timer::Timer; +pub use crate::metrics::*; pub use crate::provider::OtelProvider; pub use crate::trace_context::context_from_w3c_trace_context; pub use crate::trace_context::current_span_trace_id; diff --git a/codex-rs/otel/src/metrics/mod.rs b/codex-rs/otel/src/metrics/mod.rs index 1d1195e5f..bcbb85d35 100644 --- a/codex-rs/otel/src/metrics/mod.rs +++ b/codex-rs/otel/src/metrics/mod.rs @@ -1,9 +1,9 @@ mod client; mod config; mod error; -pub mod names; +pub(crate) mod names; pub(crate) mod runtime_metrics; -pub mod tags; +pub(crate) mod tags; pub(crate) mod timer; pub(crate) mod validation; @@ -12,7 +12,9 @@ pub use crate::metrics::config::MetricsConfig; pub use crate::metrics::config::MetricsExporter; pub use crate::metrics::error::MetricsError; pub use crate::metrics::error::Result; +pub use names::*; use std::sync::OnceLock; +pub use tags::SessionMetricTagValues; static GLOBAL_METRICS: OnceLock = OnceLock::new(); diff --git a/codex-rs/otel/tests/harness/mod.rs b/codex-rs/otel/tests/harness/mod.rs index acdba0b7e..fbba56411 100644 --- a/codex-rs/otel/tests/harness/mod.rs +++ b/codex-rs/otel/tests/harness/mod.rs @@ -1,6 +1,6 @@ -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::Result; +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; +use codex_otel::Result; use opentelemetry::KeyValue; use opentelemetry_sdk::metrics::InMemoryMetricExporter; use opentelemetry_sdk::metrics::data::AggregatedMetrics; diff --git a/codex-rs/otel/tests/suite/manager_metrics.rs b/codex-rs/otel/tests/suite/manager_metrics.rs index 8a61403c7..d95f42dfc 100644 --- a/codex-rs/otel/tests/suite/manager_metrics.rs +++ b/codex-rs/otel/tests/suite/manager_metrics.rs @@ -2,9 +2,9 @@ use crate::harness::attributes_to_map; use crate::harness::build_metrics_with_defaults; use crate::harness::find_metric; use crate::harness::latest_metrics; +use codex_otel::Result; use codex_otel::SessionTelemetry; use codex_otel::TelemetryAuthMode; -use codex_otel::metrics::Result; use codex_protocol::ThreadId; use codex_protocol::protocol::SessionSource; use opentelemetry_sdk::metrics::data::AggregatedMetrics; diff --git a/codex-rs/otel/tests/suite/otlp_http_loopback.rs b/codex-rs/otel/tests/suite/otlp_http_loopback.rs index eb84dfdf5..fd4e3531d 100644 --- a/codex-rs/otel/tests/suite/otlp_http_loopback.rs +++ b/codex-rs/otel/tests/suite/otlp_http_loopback.rs @@ -1,10 +1,10 @@ +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; +use codex_otel::OtelExporter; +use codex_otel::OtelHttpProtocol; use codex_otel::OtelProvider; -use codex_otel::config::OtelExporter; -use codex_otel::config::OtelHttpProtocol; -use codex_otel::config::OtelSettings; -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::Result; +use codex_otel::OtelSettings; +use codex_otel::Result; use std::collections::HashMap; use std::io::Read as _; use std::io::Write as _; diff --git a/codex-rs/otel/tests/suite/runtime_summary.rs b/codex-rs/otel/tests/suite/runtime_summary.rs index 7ffa03e02..21fc7bf76 100644 --- a/codex-rs/otel/tests/suite/runtime_summary.rs +++ b/codex-rs/otel/tests/suite/runtime_summary.rs @@ -1,10 +1,10 @@ +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; +use codex_otel::Result; use codex_otel::RuntimeMetricTotals; use codex_otel::RuntimeMetricsSummary; use codex_otel::SessionTelemetry; use codex_otel::TelemetryAuthMode; -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::Result; use codex_protocol::ThreadId; use codex_protocol::protocol::SessionSource; use eventsource_stream::Event as StreamEvent; diff --git a/codex-rs/otel/tests/suite/send.rs b/codex-rs/otel/tests/suite/send.rs index a50c57908..fc382bf88 100644 --- a/codex-rs/otel/tests/suite/send.rs +++ b/codex-rs/otel/tests/suite/send.rs @@ -3,7 +3,7 @@ use crate::harness::build_metrics_with_defaults; use crate::harness::find_metric; use crate::harness::histogram_data; use crate::harness::latest_metrics; -use codex_otel::metrics::Result; +use codex_otel::Result; use pretty_assertions::assert_eq; use std::collections::BTreeMap; diff --git a/codex-rs/otel/tests/suite/snapshot.rs b/codex-rs/otel/tests/suite/snapshot.rs index 4686e79d3..e63110000 100644 --- a/codex-rs/otel/tests/suite/snapshot.rs +++ b/codex-rs/otel/tests/suite/snapshot.rs @@ -1,10 +1,10 @@ use crate::harness::attributes_to_map; use crate::harness::find_metric; +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; +use codex_otel::Result; use codex_otel::SessionTelemetry; use codex_otel::TelemetryAuthMode; -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::Result; use codex_protocol::ThreadId; use codex_protocol::protocol::SessionSource; use opentelemetry_sdk::metrics::InMemoryMetricExporter; diff --git a/codex-rs/otel/tests/suite/timing.rs b/codex-rs/otel/tests/suite/timing.rs index 8398e1a0d..0cf73b9a5 100644 --- a/codex-rs/otel/tests/suite/timing.rs +++ b/codex-rs/otel/tests/suite/timing.rs @@ -2,7 +2,7 @@ use crate::harness::attributes_to_map; use crate::harness::build_metrics_with_defaults; use crate::harness::histogram_data; use crate::harness::latest_metrics; -use codex_otel::metrics::Result; +use codex_otel::Result; use pretty_assertions::assert_eq; use std::time::Duration; diff --git a/codex-rs/otel/tests/suite/validation.rs b/codex-rs/otel/tests/suite/validation.rs index 81f07ed14..630850611 100644 --- a/codex-rs/otel/tests/suite/validation.rs +++ b/codex-rs/otel/tests/suite/validation.rs @@ -1,7 +1,7 @@ -use codex_otel::metrics::MetricsClient; -use codex_otel::metrics::MetricsConfig; -use codex_otel::metrics::MetricsError; -use codex_otel::metrics::Result; +use codex_otel::MetricsClient; +use codex_otel::MetricsConfig; +use codex_otel::MetricsError; +use codex_otel::Result; use opentelemetry_sdk::metrics::InMemoryMetricExporter; fn build_in_memory_client() -> Result { diff --git a/codex-rs/protocol/src/models.rs b/codex-rs/protocol/src/models.rs index d4e568fea..0f18b6839 100644 --- a/codex-rs/protocol/src/models.rs +++ b/codex-rs/protocol/src/models.rs @@ -27,7 +27,7 @@ use crate::user_input::UserInput; use codex_execpolicy::Policy; use codex_git_utils::GhostCommit; use codex_utils_absolute_path::AbsolutePathBuf; -use codex_utils_image::error::ImageProcessingError; +use codex_utils_image::ImageProcessingError; use schemars::JsonSchema; use crate::mcp::CallToolResult; diff --git a/codex-rs/response-debug-context/src/lib.rs b/codex-rs/response-debug-context/src/lib.rs index ed5a6bdc6..f7c90b753 100644 --- a/codex-rs/response-debug-context/src/lib.rs +++ b/codex-rs/response-debug-context/src/lib.rs @@ -1,6 +1,6 @@ use base64::Engine; +use codex_api::ApiError; use codex_api::TransportError; -use codex_api::error::ApiError; const REQUEST_ID_HEADER: &str = "x-request-id"; const OAI_REQUEST_ID_HEADER: &str = "x-oai-request-id"; @@ -91,8 +91,8 @@ mod tests { use super::extract_response_debug_context; use super::telemetry_api_error_message; use super::telemetry_transport_error_message; + use codex_api::ApiError; use codex_api::TransportError; - use codex_api::error::ApiError; use http::HeaderMap; use http::HeaderValue; use http::StatusCode; diff --git a/codex-rs/rollout/src/lib.rs b/codex-rs/rollout/src/lib.rs index 160792a39..6acf2c3be 100644 --- a/codex-rs/rollout/src/lib.rs +++ b/codex-rs/rollout/src/lib.rs @@ -4,12 +4,12 @@ use std::sync::LazyLock; use codex_protocol::protocol::SessionSource; -pub mod config; -pub mod list; -pub mod metadata; -pub mod policy; -pub mod recorder; -pub mod session_index; +pub(crate) mod config; +pub(crate) mod list; +pub(crate) mod metadata; +pub(crate) mod policy; +pub(crate) mod recorder; +pub(crate) mod session_index; pub mod state_db; pub(crate) mod default_client { @@ -30,14 +30,28 @@ pub static INTERACTIVE_SESSION_SOURCES: LazyLock> = LazyLock: }); pub use codex_protocol::protocol::SessionMeta; +pub use config::Config; pub use config::RolloutConfig; pub use config::RolloutConfigView; +pub use list::Cursor; +pub use list::ThreadItem; +pub use list::ThreadListConfig; +pub use list::ThreadListLayout; +pub use list::ThreadSortKey; +pub use list::ThreadsPage; pub use list::find_archived_thread_path_by_id_str; pub use list::find_thread_path_by_id_str; #[deprecated(note = "use find_thread_path_by_id_str")] pub use list::find_thread_path_by_id_str as find_conversation_path_by_id_str; +pub use list::get_threads; +pub use list::get_threads_in_root; +pub use list::parse_cursor; +pub use list::read_head_for_summary; +pub use list::read_session_meta_line; pub use list::rollout_date_parts; +pub use metadata::builder_from_items; pub use policy::EventPersistenceMode; +pub use policy::should_persist_response_item_for_memories; pub use recorder::RolloutRecorder; pub use recorder::RolloutRecorderParams; pub use session_index::append_thread_name; diff --git a/codex-rs/rollout/src/metadata.rs b/codex-rs/rollout/src/metadata.rs index 51ebb5ef1..e8a95839d 100644 --- a/codex-rs/rollout/src/metadata.rs +++ b/codex-rs/rollout/src/metadata.rs @@ -137,7 +137,7 @@ pub(crate) async fn backfill_sessions( runtime: &codex_state::StateRuntime, config: &impl RolloutConfigView, ) { - let metric_client = codex_otel::metrics::global(); + let metric_client = codex_otel::global(); let timer = metric_client .as_ref() .and_then(|otel| otel.start_timer(DB_METRIC_BACKFILL_DURATION_MS, &[]).ok()); diff --git a/codex-rs/shell-command/src/command_safety/mod.rs b/codex-rs/shell-command/src/command_safety/mod.rs index 12e467bdb..31fa64f8a 100644 --- a/codex-rs/shell-command/src/command_safety/mod.rs +++ b/codex-rs/shell-command/src/command_safety/mod.rs @@ -2,4 +2,4 @@ mod powershell_parser; pub mod is_dangerous_command; pub mod is_safe_command; -pub mod windows_safe_commands; +pub(crate) mod windows_safe_commands; diff --git a/codex-rs/shell-command/src/lib.rs b/codex-rs/shell-command/src/lib.rs index 215c30fd7..1d9e302a4 100644 --- a/codex-rs/shell-command/src/lib.rs +++ b/codex-rs/shell-command/src/lib.rs @@ -3,7 +3,7 @@ mod shell_detect; pub mod bash; -pub mod command_safety; +pub(crate) mod command_safety; pub mod parse_command; pub mod powershell; diff --git a/codex-rs/shell-escalation/src/lib.rs b/codex-rs/shell-escalation/src/lib.rs index edad193af..6c7e1ec60 100644 --- a/codex-rs/shell-escalation/src/lib.rs +++ b/codex-rs/shell-escalation/src/lib.rs @@ -1,6 +1,8 @@ #[cfg(unix)] mod unix; +#[cfg(unix)] +pub use unix::ESCALATE_SOCKET_ENV_VAR; #[cfg(unix)] pub use unix::EscalateAction; #[cfg(unix)] @@ -28,8 +30,6 @@ pub use unix::ShellCommandExecutor; #[cfg(unix)] pub use unix::Stopwatch; #[cfg(unix)] -pub use unix::escalate_protocol::ESCALATE_SOCKET_ENV_VAR; -#[cfg(unix)] pub use unix::main_execve_wrapper; #[cfg(unix)] pub use unix::run_shell_escalation_execve_wrapper; diff --git a/codex-rs/shell-escalation/src/unix/mod.rs b/codex-rs/shell-escalation/src/unix/mod.rs index 13b7146ab..b5d999411 100644 --- a/codex-rs/shell-escalation/src/unix/mod.rs +++ b/codex-rs/shell-escalation/src/unix/mod.rs @@ -53,15 +53,16 @@ //! | | //! o<-----x //! -pub mod escalate_client; -pub mod escalate_protocol; -pub mod escalate_server; -pub mod escalation_policy; -pub mod execve_wrapper; -pub mod socket; -pub mod stopwatch; +pub(crate) mod escalate_client; +pub(crate) mod escalate_protocol; +pub(crate) mod escalate_server; +pub(crate) mod escalation_policy; +pub(crate) mod execve_wrapper; +pub(crate) mod socket; +pub(crate) mod stopwatch; pub use self::escalate_client::run_shell_escalation_execve_wrapper; +pub use self::escalate_protocol::ESCALATE_SOCKET_ENV_VAR; pub use self::escalate_protocol::EscalateAction; pub use self::escalate_protocol::EscalationDecision; pub use self::escalate_protocol::EscalationExecution; diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index cf42e8516..5bd7bb7ef 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -85,13 +85,14 @@ use codex_app_server_protocol::TurnError as AppServerTurnError; use codex_app_server_protocol::TurnStatus; use codex_config::types::ApprovalsReviewer; use codex_config::types::ModelAvailabilityNuxConfig; +use codex_core::append_message_history_entry; use codex_core::config::Config; use codex_core::config::ConfigBuilder; use codex_core::config::ConfigOverrides; use codex_core::config::edit::ConfigEdit; use codex_core::config::edit::ConfigEditsBuilder; use codex_core::config_loader::ConfigLayerStackOrdering; -use codex_core::message_history; +use codex_core::lookup_message_history_entry; #[cfg(target_os = "windows")] use codex_core::windows_sandbox::WindowsSandboxLevelExt; use codex_features::Feature; @@ -2159,8 +2160,7 @@ impl App { let text = text.clone(); let config = self.chat_widget.config_ref().clone(); tokio::spawn(async move { - if let Err(err) = - message_history::append_entry(&text, &thread_id, &config).await + if let Err(err) = append_message_history_entry(&text, &thread_id, &config).await { tracing::warn!( thread_id = %thread_id, @@ -2178,7 +2178,7 @@ impl App { let app_event_tx = self.app_event_tx.clone(); tokio::spawn(async move { let entry_opt = tokio::task::spawn_blocking(move || { - message_history::lookup(log_id, offset, &config) + lookup_message_history_entry(log_id, offset, &config) }) .await .unwrap_or_else(|err| { @@ -4693,7 +4693,7 @@ impl App { tokio::task::spawn_blocking(move || { let requested_path = PathBuf::from(path); - let event = match codex_core::windows_sandbox_read_grants::grant_read_root_non_elevated( + let event = match codex_core::grant_read_root_non_elevated( &policy, policy_cwd.as_path(), command_cwd.as_path(), diff --git a/codex-rs/tui/src/app_server_session.rs b/codex-rs/tui/src/app_server_session.rs index d152e99f6..03072632b 100644 --- a/codex-rs/tui/src/app_server_session.rs +++ b/codex-rs/tui/src/app_server_session.rs @@ -63,8 +63,10 @@ use codex_app_server_protocol::TurnStartParams; use codex_app_server_protocol::TurnStartResponse; use codex_app_server_protocol::TurnSteerParams; use codex_app_server_protocol::TurnSteerResponse; +#[cfg(test)] +use codex_core::append_message_history_entry; use codex_core::config::Config; -use codex_core::message_history; +use codex_core::message_history_metadata; use codex_otel::TelemetryAuthMode; use codex_protocol::ThreadId; use codex_protocol::openai_models::ModelAvailabilityNux; @@ -1076,7 +1078,7 @@ async fn thread_session_state_from_thread_response( .map(ThreadId::from_string) .transpose() .map_err(|err| format!("forked_from_id is invalid: {err}"))?; - let (history_log_id, history_entry_count) = message_history::history_metadata(config).await; + let (history_log_id, history_entry_count) = message_history_metadata(config).await; let history_entry_count = u64::try_from(history_entry_count).unwrap_or(u64::MAX); Ok(ThreadSessionState { @@ -1316,10 +1318,10 @@ mod tests { let config = build_config(&temp_dir).await; let thread_id = ThreadId::new(); - message_history::append_entry("older", &thread_id, &config) + append_message_history_entry("older", &thread_id, &config) .await .expect("history append should succeed"); - message_history::append_entry("newer", &thread_id, &config) + append_message_history_entry("newer", &thread_id, &config) .await .expect("history append should succeed"); diff --git a/codex-rs/tui/src/bottom_pane/feedback_view.rs b/codex-rs/tui/src/bottom_pane/feedback_view.rs index f4f641c5d..b1889abca 100644 --- a/codex-rs/tui/src/bottom_pane/feedback_view.rs +++ b/codex-rs/tui/src/bottom_pane/feedback_view.rs @@ -1,5 +1,5 @@ -use codex_feedback::feedback_diagnostics::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME; -use codex_feedback::feedback_diagnostics::FeedbackDiagnostics; +use codex_feedback::FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME; +use codex_feedback::FeedbackDiagnostics; use crossterm::event::KeyCode; use crossterm::event::KeyEvent; use crossterm::event::KeyModifiers; @@ -556,7 +556,7 @@ mod tests { use super::*; use crate::app_event::AppEvent; use crate::app_event_sender::AppEventSender; - use codex_feedback::feedback_diagnostics::FeedbackDiagnostic; + use codex_feedback::FeedbackDiagnostic; use pretty_assertions::assert_eq; fn render(view: &FeedbackNoteView, width: u16) -> String { diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index da5e2421f..cbb698e3a 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -76,7 +76,7 @@ pub(crate) struct MentionBinding { mod chat_composer; mod chat_composer_history; mod command_popup; -pub mod custom_prompt_view; +pub(crate) mod custom_prompt_view; mod experimental_features_view; mod file_search_popup; mod footer; @@ -108,7 +108,7 @@ pub(crate) use title_setup::TerminalTitleSetupView; mod paste_burst; mod pending_input_preview; mod pending_thread_approvals; -pub mod popup_consts; +pub(crate) mod popup_consts; mod scroll_state; mod selection_popup_common; mod textarea; diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index f942308aa..e8713704d 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -95,13 +95,13 @@ use codex_chatgpt::connectors; use codex_config::types::ApprovalsReviewer; use codex_config::types::Notifications; use codex_config::types::WindowsSandboxModeToml; +use codex_core::DEFAULT_PROJECT_DOC_FILENAME; use codex_core::config::Config; use codex_core::config::Constrained; use codex_core::config::ConstraintResult; use codex_core::config_loader::ConfigLayerStackOrdering; use codex_core::find_thread_name_by_id; use codex_core::plugins::PluginsManager; -use codex_core::project_doc::DEFAULT_PROJECT_DOC_FILENAME; use codex_core::skills::model::SkillMetadata; #[cfg(target_os = "windows")] use codex_core::windows_sandbox::WindowsSandboxLevelExt; diff --git a/codex-rs/tui/src/chatwidget/skills.rs b/codex-rs/tui/src/chatwidget/skills.rs index 53dd7e8b8..b5794f6c4 100644 --- a/codex-rs/tui/src/chatwidget/skills.rs +++ b/codex-rs/tui/src/chatwidget/skills.rs @@ -13,8 +13,8 @@ use crate::bottom_pane::popup_consts::standard_popup_hint_line; use crate::skills_helpers::skill_description; use crate::skills_helpers::skill_display_name; use codex_chatgpt::connectors::AppInfo; +use codex_core::TOOL_MENTION_SIGIL; use codex_core::connectors::connector_mention_slug; -use codex_core::mention_syntax::TOOL_MENTION_SIGIL; use codex_core::skills::model::SkillDependencies; use codex_core::skills::model::SkillInterface; use codex_core::skills::model::SkillMetadata; diff --git a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs index f89926785..8d14d4dda 100644 --- a/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs +++ b/codex-rs/tui/src/chatwidget/tests/popups_and_settings.rs @@ -1761,13 +1761,11 @@ async fn feedback_upload_consent_popup_snapshot() { chat.app_event_tx.clone(), crate::app_event::FeedbackCategory::Bug, chat.current_rollout_path.clone(), - &codex_feedback::feedback_diagnostics::FeedbackDiagnostics::new(vec![ - codex_feedback::feedback_diagnostics::FeedbackDiagnostic { - headline: "Proxy environment variables are set and may affect connectivity." - .to_string(), - details: vec!["HTTPS_PROXY = hello".to_string()], - }, - ]), + &codex_feedback::FeedbackDiagnostics::new(vec![codex_feedback::FeedbackDiagnostic { + headline: "Proxy environment variables are set and may affect connectivity." + .to_string(), + details: vec!["HTTPS_PROXY = hello".to_string()], + }]), )); let popup = render_bottom_popup(&chat, /*width*/ 80); @@ -1782,13 +1780,11 @@ async fn feedback_good_result_consent_popup_includes_connectivity_diagnostics_fi chat.app_event_tx.clone(), crate::app_event::FeedbackCategory::GoodResult, chat.current_rollout_path.clone(), - &codex_feedback::feedback_diagnostics::FeedbackDiagnostics::new(vec![ - codex_feedback::feedback_diagnostics::FeedbackDiagnostic { - headline: "Proxy environment variables are set and may affect connectivity." - .to_string(), - details: vec!["HTTPS_PROXY = hello".to_string()], - }, - ]), + &codex_feedback::FeedbackDiagnostics::new(vec![codex_feedback::FeedbackDiagnostic { + headline: "Proxy environment variables are set and may affect connectivity." + .to_string(), + details: vec!["HTTPS_PROXY = hello".to_string()], + }]), )); let popup = render_bottom_popup(&chat, /*width*/ 80); diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 6821adb5a..67c7e9f98 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -42,14 +42,14 @@ use base64::Engine; use codex_app_server_protocol::McpServerStatus; use codex_app_server_protocol::McpServerStatusDetail; use codex_config::types::McpServerTransportConfig; +#[cfg(test)] +use codex_core::McpManager; use codex_core::config::Config; #[cfg(test)] -use codex_core::mcp::McpManager; -#[cfg(test)] use codex_core::plugins::PluginsManager; -use codex_core::web_search::web_search_detail; +use codex_core::web_search_detail; #[cfg(test)] -use codex_mcp::mcp::qualified_mcp_tool_name_prefix; +use codex_mcp::qualified_mcp_tool_name_prefix; use codex_otel::RuntimeMetricsSummary; use codex_protocol::account::PlanType; use codex_protocol::config_types::ServiceTier; @@ -70,7 +70,7 @@ use codex_protocol::protocol::SessionConfiguredEvent; use codex_protocol::request_user_input::RequestUserInputAnswer; use codex_protocol::request_user_input::RequestUserInputQuestion; use codex_protocol::user_input::TextElement; -use codex_utils_cli::format_env_display::format_env_display; +use codex_utils_cli::format_env_display; use image::DynamicImage; use image::ImageReader; use ratatui::prelude::*; diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 4e90c909e..7cd4c6494 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -102,7 +102,8 @@ mod clipboard_paste; mod clipboard_text; mod collaboration_modes; mod color; -pub mod custom_terminal; +pub(crate) mod custom_terminal; +pub use custom_terminal::Terminal; mod cwd_prompt; mod debug_config; mod diff_render; @@ -113,10 +114,12 @@ mod file_search; mod frames; mod get_git_diff; mod history_cell; -pub mod insert_history; +pub(crate) mod insert_history; +pub use insert_history::insert_history_lines; mod key_hint; mod line_truncation; -pub mod live_wrap; +pub(crate) mod live_wrap; +pub use live_wrap::RowBuilder; mod local_chatgpt_auth; mod markdown; mod markdown_render; @@ -126,10 +129,10 @@ mod model_catalog; mod model_migration; mod multi_agents; mod notifications; -pub mod onboarding; +pub(crate) mod onboarding; mod oss_selection; mod pager_overlay; -pub mod public_widgets; +pub(crate) mod public_widgets; mod render; mod resume_picker; mod selection_list; @@ -148,7 +151,8 @@ mod theme_picker; mod tooltips; mod tui; mod ui_consts; -pub mod update_action; +pub(crate) mod update_action; +pub use update_action::UpdateAction; mod update_prompt; mod updates; mod version; @@ -212,7 +216,7 @@ mod voice { mod wrapping; #[cfg(test)] -pub mod test_backend; +pub(crate) mod test_backend; #[cfg(test)] pub(crate) mod test_support; diff --git a/codex-rs/tui/src/mention_codec.rs b/codex-rs/tui/src/mention_codec.rs index 6e95067ba..d3d1ead4d 100644 --- a/codex-rs/tui/src/mention_codec.rs +++ b/codex-rs/tui/src/mention_codec.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::collections::VecDeque; -use codex_core::mention_syntax::PLUGIN_TEXT_MENTION_SIGIL; -use codex_core::mention_syntax::TOOL_MENTION_SIGIL; +use codex_core::PLUGIN_TEXT_MENTION_SIGIL; +use codex_core::TOOL_MENTION_SIGIL; #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) struct LinkedMention { diff --git a/codex-rs/tui/src/onboarding/mod.rs b/codex-rs/tui/src/onboarding/mod.rs index 8a4dc760f..0db5204d3 100644 --- a/codex-rs/tui/src/onboarding/mod.rs +++ b/codex-rs/tui/src/onboarding/mod.rs @@ -1,6 +1,5 @@ mod auth; -pub mod onboarding_screen; +pub(crate) mod onboarding_screen; mod trust_directory; pub(crate) use auth::mark_url_hyperlink; -pub use trust_directory::TrustDirectorySelection; mod welcome; diff --git a/codex-rs/tui/src/public_widgets/mod.rs b/codex-rs/tui/src/public_widgets/mod.rs index c752189f3..b8db1c6bf 100644 --- a/codex-rs/tui/src/public_widgets/mod.rs +++ b/codex-rs/tui/src/public_widgets/mod.rs @@ -1 +1 @@ -pub mod composer_input; +pub(crate) mod composer_input; diff --git a/codex-rs/tui/src/render/mod.rs b/codex-rs/tui/src/render/mod.rs index a2e492058..02c19fc9f 100644 --- a/codex-rs/tui/src/render/mod.rs +++ b/codex-rs/tui/src/render/mod.rs @@ -1,8 +1,8 @@ use ratatui::layout::Rect; -pub mod highlight; -pub mod line_utils; -pub mod renderable; +pub(crate) mod highlight; +pub(crate) mod line_utils; +pub(crate) mod renderable; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Insets { diff --git a/codex-rs/tui/src/status/helpers.rs b/codex-rs/tui/src/status/helpers.rs index 9f4c8f793..76aaa3da1 100644 --- a/codex-rs/tui/src/status/helpers.rs +++ b/codex-rs/tui/src/status/helpers.rs @@ -4,7 +4,7 @@ use crate::text_formatting; use chrono::DateTime; use chrono::Local; use codex_core::config::Config; -use codex_core::project_doc::discover_project_doc_paths; +use codex_core::discover_project_doc_paths; use codex_exec_server::LOCAL_FS; use codex_protocol::account::PlanType; use codex_utils_absolute_path::AbsolutePathBuf; diff --git a/codex-rs/tui/tests/suite/vt100_history.rs b/codex-rs/tui/tests/suite/vt100_history.rs index 2b89363e6..609671cc3 100644 --- a/codex-rs/tui/tests/suite/vt100_history.rs +++ b/codex-rs/tui/tests/suite/vt100_history.rs @@ -22,20 +22,20 @@ macro_rules! assert_contains { } struct TestScenario { - term: codex_tui::custom_terminal::Terminal, + term: codex_tui::Terminal, } impl TestScenario { fn new(width: u16, height: u16, viewport: Rect) -> Self { let backend = VT100Backend::new(width, height); - let mut term = codex_tui::custom_terminal::Terminal::with_options(backend) - .expect("failed to construct terminal"); + let mut term = + codex_tui::Terminal::with_options(backend).expect("failed to construct terminal"); term.set_viewport_area(viewport); Self { term } } fn run_insert(&mut self, lines: Vec>) { - codex_tui::insert_history::insert_history_lines(&mut self.term, lines) + codex_tui::insert_history_lines(&mut self.term, lines) .expect("Failed to insert history lines in test"); } } diff --git a/codex-rs/tui/tests/suite/vt100_live_commit.rs b/codex-rs/tui/tests/suite/vt100_live_commit.rs index 4c13bb402..01b3f7257 100644 --- a/codex-rs/tui/tests/suite/vt100_live_commit.rs +++ b/codex-rs/tui/tests/suite/vt100_live_commit.rs @@ -5,7 +5,7 @@ use ratatui::text::Line; #[test] fn live_001_commit_on_overflow() { let backend = VT100Backend::new(/*width*/ 20, /*height*/ 6); - let mut term = match codex_tui::custom_terminal::Terminal::with_options(backend) { + let mut term = match codex_tui::Terminal::with_options(backend) { Ok(t) => t, Err(e) => panic!("failed to construct terminal: {e}"), }; @@ -15,7 +15,7 @@ fn live_001_commit_on_overflow() { term.set_viewport_area(area); // Build 5 explicit rows at width 20. - let mut rb = codex_tui::live_wrap::RowBuilder::new(/*target_width*/ 20); + let mut rb = codex_tui::RowBuilder::new(/*target_width*/ 20); rb.push_fragment("one\n"); rb.push_fragment("two\n"); rb.push_fragment("three\n"); @@ -26,7 +26,7 @@ fn live_001_commit_on_overflow() { let commit_rows = rb.drain_commit_ready(/*max_keep*/ 3); let lines: Vec> = commit_rows.into_iter().map(|r| r.text.into()).collect(); - codex_tui::insert_history::insert_history_lines(&mut term, lines) + codex_tui::insert_history_lines(&mut term, lines) .expect("Failed to insert history lines in test"); let screen = term.backend().vt100().screen(); diff --git a/codex-rs/utils/cli/src/lib.rs b/codex-rs/utils/cli/src/lib.rs index b3ce23b90..ed00d683f 100644 --- a/codex-rs/utils/cli/src/lib.rs +++ b/codex-rs/utils/cli/src/lib.rs @@ -1,8 +1,9 @@ mod approval_mode_cli_arg; mod config_override; -pub mod format_env_display; +pub(crate) mod format_env_display; mod sandbox_mode_cli_arg; pub use approval_mode_cli_arg::ApprovalModeCliArg; pub use config_override::CliConfigOverrides; +pub use format_env_display::format_env_display; pub use sandbox_mode_cli_arg::SandboxModeCliArg; diff --git a/codex-rs/utils/image/src/lib.rs b/codex-rs/utils/image/src/lib.rs index b150f76a1..9d491bc10 100644 --- a/codex-rs/utils/image/src/lib.rs +++ b/codex-rs/utils/image/src/lib.rs @@ -2,7 +2,6 @@ use std::num::NonZeroUsize; use std::path::Path; use std::sync::LazyLock; -use crate::error::ImageProcessingError; use base64::Engine; use base64::engine::general_purpose::STANDARD as BASE64_STANDARD; use codex_utils_cache::BlockingLruCache; @@ -21,7 +20,9 @@ pub const MAX_WIDTH: u32 = 2048; /// Maximum height used when resizing images before uploading. pub const MAX_HEIGHT: u32 = 768; -pub mod error; +pub(crate) mod error; + +pub use crate::error::ImageProcessingError; #[derive(Debug, Clone)] pub struct EncodedImage { diff --git a/codex-rs/utils/path-utils/src/lib.rs b/codex-rs/utils/path-utils/src/lib.rs index a6dc6f8b3..4e053c039 100644 --- a/codex-rs/utils/path-utils/src/lib.rs +++ b/codex-rs/utils/path-utils/src/lib.rs @@ -1,6 +1,8 @@ //! Path normalization, symlink resolution, and atomic writes shared across Codex crates. -pub mod env; +pub(crate) mod env; +pub use env::is_headless_environment; +pub use env::is_wsl; use codex_utils_absolute_path::AbsolutePathBuf; use std::collections::HashSet; diff --git a/codex-rs/utils/pty/src/win/mod.rs b/codex-rs/utils/pty/src/win/mod.rs index 78f5af2ce..33b6e52fb 100644 --- a/codex-rs/utils/pty/src/win/mod.rs +++ b/codex-rs/utils/pty/src/win/mod.rs @@ -44,7 +44,7 @@ use winapi::um::processthreadsapi::*; use winapi::um::synchapi::WaitForSingleObject; use winapi::um::winbase::INFINITE; -pub mod conpty; +pub(crate) mod conpty; mod procthreadattr; mod psuedocon; diff --git a/codex-rs/windows-sandbox-rs/src/elevated/command_runner_win.rs b/codex-rs/windows-sandbox-rs/src/elevated/command_runner_win.rs index 7777055e2..9cb59e18d 100644 --- a/codex-rs/windows-sandbox-rs/src/elevated/command_runner_win.rs +++ b/codex-rs/windows-sandbox-rs/src/elevated/command_runner_win.rs @@ -12,31 +12,33 @@ use anyhow::Context; use anyhow::Result; +use codex_windows_sandbox::ErrorPayload; +use codex_windows_sandbox::ExitPayload; +use codex_windows_sandbox::FramedMessage; +use codex_windows_sandbox::Message; +use codex_windows_sandbox::OutputPayload; +use codex_windows_sandbox::OutputStream; use codex_windows_sandbox::PipeSpawnHandles; use codex_windows_sandbox::SandboxPolicy; +use codex_windows_sandbox::SpawnReady; +use codex_windows_sandbox::SpawnRequest; use codex_windows_sandbox::StderrMode; use codex_windows_sandbox::StdinMode; use codex_windows_sandbox::allow_null_device; use codex_windows_sandbox::convert_string_sid_to_sid; use codex_windows_sandbox::create_readonly_token_with_caps_from; use codex_windows_sandbox::create_workspace_write_token_with_caps_from; +use codex_windows_sandbox::decode_bytes; +use codex_windows_sandbox::encode_bytes; use codex_windows_sandbox::get_current_token_for_restriction; use codex_windows_sandbox::hide_current_user_profile_dir; -use codex_windows_sandbox::ipc_framed::ErrorPayload; -use codex_windows_sandbox::ipc_framed::ExitPayload; -use codex_windows_sandbox::ipc_framed::FramedMessage; -use codex_windows_sandbox::ipc_framed::Message; -use codex_windows_sandbox::ipc_framed::OutputPayload; -use codex_windows_sandbox::ipc_framed::OutputStream; -use codex_windows_sandbox::ipc_framed::decode_bytes; -use codex_windows_sandbox::ipc_framed::encode_bytes; -use codex_windows_sandbox::ipc_framed::read_frame; -use codex_windows_sandbox::ipc_framed::write_frame; use codex_windows_sandbox::log_note; use codex_windows_sandbox::parse_policy; +use codex_windows_sandbox::read_frame; use codex_windows_sandbox::read_handle_loop; use codex_windows_sandbox::spawn_process_with_pipes; use codex_windows_sandbox::to_wide; +use codex_windows_sandbox::write_frame; use std::ffi::c_void; use std::fs::File; use std::os::windows::io::FromRawHandle; @@ -144,9 +146,7 @@ fn send_error(writer: &Arc>, code: &str, message: String) -> Resu } /// Read and validate the initial spawn request frame. -fn read_spawn_request( - reader: &mut File, -) -> Result { +fn read_spawn_request(reader: &mut File) -> Result { let Some(msg) = read_frame(reader)? else { anyhow::bail!("runner: pipe closed before spawn_request"); }; @@ -184,9 +184,7 @@ fn effective_cwd(req_cwd: &Path, log_dir: Option<&Path>) -> PathBuf { } } -fn spawn_ipc_process( - req: &codex_windows_sandbox::ipc_framed::SpawnRequest, -) -> Result { +fn spawn_ipc_process(req: &SpawnRequest) -> Result { let log_dir = req.codex_home.clone(); hide_current_user_profile_dir(req.codex_home.as_path()); log_note( @@ -466,7 +464,7 @@ pub fn main() -> Result<()> { let msg = FramedMessage { version: 1, message: Message::SpawnReady { - payload: codex_windows_sandbox::ipc_framed::SpawnReady { + payload: SpawnReady { process_id: unsafe { GetProcessId(pi.hProcess) }, }, }, diff --git a/codex-rs/windows-sandbox-rs/src/lib.rs b/codex-rs/windows-sandbox-rs/src/lib.rs index 9dea9414b..dd8f23d00 100644 --- a/codex-rs/windows-sandbox-rs/src/lib.rs +++ b/codex-rs/windows-sandbox-rs/src/lib.rs @@ -34,7 +34,7 @@ mod conpty; #[cfg(target_os = "windows")] #[path = "elevated/ipc_framed.rs"] -pub mod ipc_framed; +pub(crate) mod ipc_framed; #[cfg(target_os = "windows")] #[path = "setup_orchestrator.rs"] @@ -88,6 +88,30 @@ pub use identity::require_logon_sandbox_creds; #[cfg(target_os = "windows")] pub use identity::sandbox_setup_is_complete; #[cfg(target_os = "windows")] +pub use ipc_framed::ErrorPayload; +#[cfg(target_os = "windows")] +pub use ipc_framed::ExitPayload; +#[cfg(target_os = "windows")] +pub use ipc_framed::FramedMessage; +#[cfg(target_os = "windows")] +pub use ipc_framed::Message; +#[cfg(target_os = "windows")] +pub use ipc_framed::OutputPayload; +#[cfg(target_os = "windows")] +pub use ipc_framed::OutputStream; +#[cfg(target_os = "windows")] +pub use ipc_framed::SpawnReady; +#[cfg(target_os = "windows")] +pub use ipc_framed::SpawnRequest; +#[cfg(target_os = "windows")] +pub use ipc_framed::decode_bytes; +#[cfg(target_os = "windows")] +pub use ipc_framed::encode_bytes; +#[cfg(target_os = "windows")] +pub use ipc_framed::read_frame; +#[cfg(target_os = "windows")] +pub use ipc_framed::write_frame; +#[cfg(target_os = "windows")] pub use logging::LOG_FILE_NAME; #[cfg(target_os = "windows")] pub use logging::log_note;