mirror of
https://github.com/openai/codex.git
synced 2026-10-25 07:55:34 +00:00
## What changed - Load doctor configuration through the cloud-aware CLI configuration path while preserving invocation overrides such as `--cd`. - Report configuration load time and clarify that diagnostics cover invocation configuration, including cloud-managed policy, but not active thread overrides. - Add redacted filesystem sandbox diagnostics for denied-read rule counts, glob rule counts, glob scan depth, and the managed policy source. ## Testing Add an integration test that verifies valid cloud-managed filesystem requirements are reported without exposing denied paths, and invalid requirements fail the configuration check. GitOrigin-RevId: 65c3c9ad3fd42c1579ca0c9d8e209066f98e5407
73 lines
2.5 KiB
Rust
73 lines
2.5 KiB
Rust
use anyhow::Context;
|
|
use anyhow::Result;
|
|
use codex_cloud_config::cloud_config_bundle_loader_for_storage;
|
|
use codex_config::CloudConfigBundleLoader;
|
|
use codex_config::ConfigLoadOptions;
|
|
use codex_core::config::Config;
|
|
use codex_core::config::ConfigBuilder;
|
|
use codex_core::config::ConfigOverrides;
|
|
use codex_core::config::LoaderOverrides;
|
|
use codex_core::config::bootstrap_auth_config;
|
|
use codex_core::config::find_codex_home;
|
|
use codex_core::config::load_config_toml_with_layer_stack;
|
|
use codex_utils_absolute_path::AbsolutePathBuf;
|
|
use codex_utils_cli::CliConfigOverrides;
|
|
|
|
pub(crate) async fn load_config(
|
|
config_overrides: &CliConfigOverrides,
|
|
loader_overrides: LoaderOverrides,
|
|
) -> Result<Config> {
|
|
config_builder(
|
|
config_overrides,
|
|
loader_overrides,
|
|
ConfigOverrides::default(),
|
|
)
|
|
.await?
|
|
.build()
|
|
.await
|
|
.context("failed to load configuration")
|
|
}
|
|
|
|
pub(crate) async fn config_builder(
|
|
config_overrides: &CliConfigOverrides,
|
|
loader_overrides: LoaderOverrides,
|
|
harness_overrides: ConfigOverrides,
|
|
) -> Result<ConfigBuilder> {
|
|
let cli_overrides = config_overrides
|
|
.parse_overrides()
|
|
.map_err(anyhow::Error::msg)?;
|
|
let codex_home = find_codex_home().context("failed to resolve CODEX_HOME")?;
|
|
let cwd = match harness_overrides.cwd.as_deref() {
|
|
Some(cwd) => AbsolutePathBuf::relative_to_current_dir(cwd),
|
|
None => AbsolutePathBuf::current_dir(),
|
|
}
|
|
.context("failed to resolve current directory")?;
|
|
let bootstrap_config = load_config_toml_with_layer_stack(
|
|
codex_home.as_path(),
|
|
Some(&cwd),
|
|
cli_overrides.clone(),
|
|
ConfigLoadOptions {
|
|
loader_overrides: loader_overrides.clone(),
|
|
strict_config: false,
|
|
cloud_config_bundle: CloudConfigBundleLoader::default(),
|
|
},
|
|
)
|
|
.await
|
|
.context("failed to load bootstrap configuration")?;
|
|
let cloud_config_bundle = cloud_config_bundle_loader_for_storage(
|
|
bootstrap_auth_config(codex_home.as_path(), &bootstrap_config)
|
|
.context("failed to resolve cloud configuration authentication")?,
|
|
/*enable_codex_api_key_env*/ false,
|
|
)
|
|
.await
|
|
.context("failed to initialize cloud configuration authentication")?;
|
|
|
|
Ok(ConfigBuilder::default()
|
|
.codex_home(codex_home.to_path_buf())
|
|
.cli_overrides(cli_overrides)
|
|
.loader_overrides(loader_overrides)
|
|
.harness_overrides(harness_overrides)
|
|
.cloud_config_bundle(cloud_config_bundle)
|
|
.fallback_cwd(Some(cwd.to_path_buf())))
|
|
}
|