Download codex-rs/exec-server/src/environment_bootstrap.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 2.38 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/exec-server/src/environment_bootstrap.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/exec-server/src/environment_bootstrap.rs
-
curl -L -o environment_bootstrap.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/exec-server/src/environment_bootstrap.rs
2.38 kB
| use codex_http_client::HttpClientFactory; | |
| use crate::EnvironmentManager; | |
| use crate::ExecServerError; | |
| use crate::ExecServerRuntimePaths; | |
| use crate::environment_provider::EnvironmentDefault; | |
| use crate::environment_provider::EnvironmentProviderSnapshot; | |
| use crate::remote::NoiseRendezvousEnvironmentConfig; | |
| pub(crate) enum PreparedEnvironmentSource { | |
| Noise(NoiseRendezvousEnvironmentConfig), | |
| Snapshot(EnvironmentProviderSnapshot), | |
| } | |
| /// Holds discovered execution environments before their HTTP policy is resolved. | |
| /// | |
| /// Preparing environments does not start remote connections. Callers can inspect | |
| /// the default environment to choose config-loading behavior and then build the | |
| /// manager with the effective outbound HTTP policy. | |
| pub struct PreparedEnvironmentManager { | |
| pub(crate) source: PreparedEnvironmentSource, | |
| } | |
| impl PreparedEnvironmentManager { | |
| /// Returns whether the discovered default environment is remote. | |
| pub fn default_environment_is_remote(&self) -> bool { | |
| match &self.source { | |
| PreparedEnvironmentSource::Noise(_) => true, | |
| PreparedEnvironmentSource::Snapshot(snapshot) => match &snapshot.default { | |
| EnvironmentDefault::Disabled => false, | |
| EnvironmentDefault::EnvironmentId(default_id) => snapshot | |
| .environments | |
| .iter() | |
| .any(|(environment_id, _)| environment_id == default_id), | |
| }, | |
| } | |
| } | |
| /// Builds the manager and starts remote connections using the supplied policy. | |
| pub fn build( | |
| self, | |
| local_runtime_paths: Option<ExecServerRuntimePaths>, | |
| http_client_factory: HttpClientFactory, | |
| ) -> Result<EnvironmentManager, ExecServerError> { | |
| match self.source { | |
| PreparedEnvironmentSource::Noise(config) => { | |
| EnvironmentManager::from_noise_environment_config( | |
| config, | |
| local_runtime_paths, | |
| http_client_factory, | |
| ) | |
| } | |
| PreparedEnvironmentSource::Snapshot(snapshot) => EnvironmentManager::from_snapshot( | |
| snapshot, | |
| local_runtime_paths, | |
| http_client_factory, | |
| ), | |
| } | |
| } | |
| } | |
| mod tests; | |