From cb273931f84276dbe71fe4a8fd81a199ddf89982 Mon Sep 17 00:00:00 2001 From: starr-openai Date: Thu, 16 Apr 2026 13:58:05 -0700 Subject: [PATCH] Remove environment provider trait Co-authored-by: Codex --- codex-rs/exec-server/src/environment.rs | 42 +++---------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/codex-rs/exec-server/src/environment.rs b/codex-rs/exec-server/src/environment.rs index bcf1fb5f8c..79be61fad6 100644 --- a/codex-rs/exec-server/src/environment.rs +++ b/codex-rs/exec-server/src/environment.rs @@ -33,19 +33,6 @@ struct EnvironmentConfig { default_cwd: Option, } -/// Resolves the current or explicitly selected execution environment for a -/// session. -pub trait EnvironmentProvider: Send + Sync + std::fmt::Debug { - async fn current(&self) -> Result>, ExecServerError>; - - async fn environment( - &self, - environment_id: Option<&str>, - ) -> Result>, ExecServerError>; - - fn default_cwd(&self, environment_id: Option<&str>) -> Result, ExecServerError>; -} - /// Lazily creates and caches the active environment for a session. /// /// The manager keeps the session's environment selection stable so subagents @@ -221,11 +208,9 @@ impl EnvironmentManager { } } } -} -impl EnvironmentProvider for EnvironmentManager { /// Returns the cached environment, creating it on first access. - async fn current(&self) -> Result>, ExecServerError> { + pub async fn current(&self) -> Result>, ExecServerError> { self.current_environment .get_or_try_init(|| async { if self.disabled { @@ -248,7 +233,7 @@ impl EnvironmentProvider for EnvironmentManager { .map(std::option::Option::<&Arc>::cloned) } - async fn environment( + pub async fn environment( &self, environment_id: Option<&str>, ) -> Result>, ExecServerError> { @@ -259,30 +244,13 @@ impl EnvironmentProvider for EnvironmentManager { } } - fn default_cwd(&self, environment_id: Option<&str>) -> Result, ExecServerError> { - Ok(self - .environment_config(environment_id)? - .and_then(|environment_config| environment_config.default_cwd.as_deref())) - } -} - -impl EnvironmentManager { - pub async fn current(&self) -> Result>, ExecServerError> { - ::current(self).await - } - - pub async fn environment( - &self, - environment_id: Option<&str>, - ) -> Result>, ExecServerError> { - ::environment(self, environment_id).await - } - pub fn default_cwd( &self, environment_id: Option<&str>, ) -> Result, ExecServerError> { - ::default_cwd(self, environment_id) + Ok(self + .environment_config(environment_id)? + .and_then(|environment_config| environment_config.default_cwd.as_deref())) } async fn local_environment(&self) -> Result, ExecServerError> {