From e9f0eaf8ed85dd556ebfa1676275d1b9da65a2d0 Mon Sep 17 00:00:00 2001 From: starr-openai Date: Wed, 6 May 2026 14:34:56 -0700 Subject: [PATCH] Expose CODEX_HOME environment manager constructor Make the environments.toml provider reachable from the exec-server crate API so the provider PR passes clippy before entrypoint wiring lands in the next stack PR. Co-authored-by: Codex --- codex-rs/exec-server/src/environment.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/codex-rs/exec-server/src/environment.rs b/codex-rs/exec-server/src/environment.rs index 524314337e..dc26539b8f 100644 --- a/codex-rs/exec-server/src/environment.rs +++ b/codex-rs/exec-server/src/environment.rs @@ -102,6 +102,30 @@ impl EnvironmentManager { Self::from_provider(&provider, local_runtime_paths).await } + /// Builds a manager from `CODEX_HOME` and local runtime paths used when + /// creating local filesystem helpers. + /// + /// If `CODEX_HOME/environments.toml` is present, it defines the configured + /// environments. Otherwise this preserves the legacy + /// `CODEX_EXEC_SERVER_URL` behavior. Callers that ignore user config + /// should use [`Self::from_env`] instead. + pub async fn from_codex_home( + codex_home: impl AsRef, + local_runtime_paths: ExecServerRuntimePaths, + ) -> Result { + let provider = environment_provider_from_codex_home(codex_home.as_ref())?; + Self::from_provider(provider.as_ref(), local_runtime_paths).await + } + + /// Builds a manager from the legacy environment-variable provider without + /// reading user config files from `CODEX_HOME`. + pub async fn from_env( + local_runtime_paths: ExecServerRuntimePaths, + ) -> Result { + let provider = DefaultEnvironmentProvider::from_env(); + Self::from_provider(&provider, local_runtime_paths).await + } + async fn from_default_provider_url( exec_server_url: Option, local_runtime_paths: ExecServerRuntimePaths,