mirror of
https://github.com/openai/codex.git
synced 2026-11-03 00:21:31 +00:00
Use AbsolutePathBuf in skill loading and codex_home (#17407)
Helps with FS migration later
This commit is contained in:
1 parent
d25a9822a7
commit
ac82443d07
86 files changed
+850
-625
No files matched your search
@@ -125,7 +125,7 @@ fn load_config_normalizes_relative_cwd_override() -> std::io::Result<()> {
|
||||
cwd: Some(PathBuf::from("nested")),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.abs().into_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.cwd, expected_cwd);
|
||||
@@ -141,7 +141,7 @@ fn load_config_records_global_agents_path() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
ConfigOverrides::default(),
|
||||
codex_home.abs().into_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -168,7 +168,7 @@ fn load_config_records_preferred_global_agents_override_path() -> std::io::Resul
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
ConfigOverrides::default(),
|
||||
codex_home.abs().into_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -247,7 +247,7 @@ consolidation_model = "gpt-5"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
memories_cfg,
|
||||
ConfigOverrides::default(),
|
||||
tempdir().expect("tempdir").path().to_path_buf(),
|
||||
tempdir().expect("tempdir").abs(),
|
||||
)
|
||||
.expect("load config from memories settings");
|
||||
assert_eq!(
|
||||
@@ -379,7 +379,7 @@ fn runtime_config_defaults_model_availability_nux() {
|
||||
let cfg = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
ConfigOverrides::default(),
|
||||
tempdir().expect("tempdir").path().to_path_buf(),
|
||||
tempdir().expect("tempdir").abs(),
|
||||
)
|
||||
.expect("load config");
|
||||
|
||||
@@ -494,7 +494,7 @@ fn permissions_profiles_network_populates_runtime_network_proxy_spec() -> std::i
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
let network = config
|
||||
.permissions
|
||||
@@ -544,7 +544,7 @@ fn permissions_profiles_network_disabled_by_default_does_not_start_proxy() -> st
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(config.permissions.network.is_none());
|
||||
@@ -592,7 +592,7 @@ fn default_permissions_profile_populates_runtime_sandbox_policy() -> std::io::Re
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
let memories_root = codex_home.path().join("memories").abs();
|
||||
@@ -673,7 +673,7 @@ fn permissions_profiles_require_default_permissions() -> std::io::Result<()> {
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.expect_err("missing default_permissions should be rejected");
|
||||
|
||||
@@ -715,7 +715,7 @@ fn permissions_profiles_reject_writes_outside_workspace_root() -> std::io::Resul
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.expect_err("writes outside the workspace root should be rejected");
|
||||
|
||||
@@ -760,7 +760,7 @@ fn permissions_profiles_reject_nested_entries_for_non_project_roots() -> std::io
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.expect_err("nested entries outside :project_roots should be rejected");
|
||||
|
||||
@@ -789,7 +789,7 @@ fn load_workspace_permission_profile(profile: PermissionProfileToml) -> std::io:
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -957,7 +957,7 @@ fn permissions_profiles_reject_project_root_parent_traversal() -> std::io::Resul
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.expect_err("parent traversal should be rejected for project root subpaths");
|
||||
|
||||
@@ -1001,7 +1001,7 @@ fn permissions_profiles_allow_network_enablement() -> std::io::Result<()> {
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(
|
||||
@@ -1229,7 +1229,7 @@ exclude_slash_tmp = true
|
||||
cwd: Some(cwd.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
let sandbox_policy = config.permissions.sandbox_policy.get();
|
||||
@@ -1409,7 +1409,7 @@ fn add_dir_override_extends_workspace_writable_roots() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
overrides,
|
||||
temp_dir.path().to_path_buf(),
|
||||
temp_dir.path().abs(),
|
||||
)?;
|
||||
|
||||
let expected_backend = backend.abs();
|
||||
@@ -1447,7 +1447,7 @@ fn sqlite_home_defaults_to_codex_home_for_workspace_write() -> std::io::Result<(
|
||||
sandbox_mode: Some(SandboxMode::WorkspaceWrite),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.sqlite_home, codex_home.path().to_path_buf());
|
||||
@@ -1471,7 +1471,7 @@ fn workspace_write_always_includes_memories_root_once() -> std::io::Result<()> {
|
||||
sandbox_mode: Some(SandboxMode::WorkspaceWrite),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
@@ -1513,7 +1513,7 @@ fn config_defaults_to_file_cli_auth_store_mode() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -1535,7 +1535,7 @@ fn config_resolves_explicit_keyring_auth_store_mode() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -1557,7 +1557,7 @@ fn config_resolves_default_oauth_store_mode() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -1633,7 +1633,7 @@ fn feedback_enabled_defaults_to_true() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.feedback_enabled, true);
|
||||
@@ -1795,7 +1795,7 @@ fn profile_sandbox_mode_overrides_base() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(matches!(
|
||||
@@ -1828,11 +1828,7 @@ fn cli_override_takes_precedence_over_profile_sandbox_mode() -> std::io::Result<
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
overrides,
|
||||
codex_home.path().to_path_buf(),
|
||||
)?;
|
||||
let config = Config::load_from_base_config_with_overrides(cfg, overrides, codex_home.abs())?;
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
assert!(matches!(
|
||||
@@ -1862,7 +1858,7 @@ fn feature_table_overrides_legacy_flags() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(!config.features.enabled(Feature::ApplyPatchFreeform));
|
||||
@@ -1883,7 +1879,7 @@ fn legacy_toggles_map_to_features() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(config.features.enabled(Feature::ApplyPatchFreeform));
|
||||
@@ -1910,7 +1906,7 @@ fn responses_websocket_features_do_not_change_wire_api() -> std::io::Result<()>
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.model_provider.wire_api, WireApi::Responses);
|
||||
@@ -1930,7 +1926,7 @@ fn config_honors_explicit_file_oauth_store_mode() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -1975,7 +1971,7 @@ async fn managed_config_overrides_oauth_store_mode() -> anyhow::Result<()> {
|
||||
let final_config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
assert_eq!(
|
||||
final_config.mcp_oauth_credentials_store_mode,
|
||||
@@ -2199,7 +2195,7 @@ fn to_mcp_config_preserves_apps_feature_from_config() -> std::io::Result<()> {
|
||||
let mut config = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
let plugins_manager = PluginsManager::new(codex_home.path().to_path_buf());
|
||||
|
||||
@@ -3231,8 +3227,8 @@ impl PrecedenceTestFixture {
|
||||
self.cwd.path().to_path_buf()
|
||||
}
|
||||
|
||||
fn codex_home(&self) -> PathBuf {
|
||||
self.codex_home.path().to_path_buf()
|
||||
fn codex_home(&self) -> AbsolutePathBuf {
|
||||
self.codex_home.abs()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3247,7 +3243,7 @@ fn cli_override_sets_compact_prompt() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
overrides,
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -3277,11 +3273,7 @@ fn loads_compact_prompt_from_file() -> std::io::Result<()> {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
overrides,
|
||||
codex_home.path().to_path_buf(),
|
||||
)?;
|
||||
let config = Config::load_from_base_config_with_overrides(cfg, overrides, codex_home.abs())?;
|
||||
|
||||
assert_eq!(
|
||||
config.compact_prompt.as_deref(),
|
||||
@@ -3312,7 +3304,7 @@ fn load_config_uses_requirements_guardian_policy_config() -> std::io::Result<()>
|
||||
cwd: Some(codex_home.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
config_layer_stack,
|
||||
)?;
|
||||
|
||||
@@ -3343,7 +3335,7 @@ fn load_config_ignores_empty_requirements_guardian_policy_config() -> std::io::R
|
||||
cwd: Some(codex_home.path().to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
config_layer_stack,
|
||||
)?;
|
||||
|
||||
@@ -3376,7 +3368,7 @@ fn load_config_rejects_missing_agent_role_config_file() -> std::io::Result<()> {
|
||||
let result = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
);
|
||||
let err = result.expect_err("missing role config file should be rejected");
|
||||
assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput);
|
||||
@@ -4244,7 +4236,7 @@ fn load_config_normalizes_agent_role_nickname_candidates() -> std::io::Result<()
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -4282,7 +4274,7 @@ fn load_config_rejects_empty_agent_role_nickname_candidates() -> std::io::Result
|
||||
let result = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
);
|
||||
let err = result.expect_err("empty nickname candidates should be rejected");
|
||||
assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput);
|
||||
@@ -4317,7 +4309,7 @@ fn load_config_rejects_duplicate_agent_role_nickname_candidates() -> std::io::Re
|
||||
let result = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
);
|
||||
let err = result.expect_err("duplicate nickname candidates should be rejected");
|
||||
assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput);
|
||||
@@ -4352,7 +4344,7 @@ fn load_config_rejects_unsafe_agent_role_nickname_candidates() -> std::io::Resul
|
||||
let result = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
);
|
||||
let err = result.expect_err("unsafe nickname candidates should be rejected");
|
||||
assert_eq!(err.kind(), std::io::ErrorKind::InvalidInput);
|
||||
@@ -4383,7 +4375,7 @@ fn model_catalog_json_loads_from_path() -> std::io::Result<()> {
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.model_catalog, Some(catalog));
|
||||
@@ -4404,7 +4396,7 @@ fn model_catalog_json_rejects_empty_catalog() -> std::io::Result<()> {
|
||||
let err = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)
|
||||
.expect_err("empty custom catalog should fail config load");
|
||||
|
||||
@@ -4590,8 +4582,8 @@ fn test_precedence_fixture_with_o3_profile() -> std::io::Result<()> {
|
||||
memories: MemoriesConfig::default(),
|
||||
agent_job_max_runtime_seconds: DEFAULT_AGENT_JOB_MAX_RUNTIME_SECONDS,
|
||||
codex_home: fixture.codex_home(),
|
||||
sqlite_home: fixture.codex_home(),
|
||||
log_dir: fixture.codex_home().join("log"),
|
||||
sqlite_home: fixture.codex_home().to_path_buf(),
|
||||
log_dir: fixture.codex_home().join("log").to_path_buf(),
|
||||
config_layer_stack: Default::default(),
|
||||
startup_warnings: Vec::new(),
|
||||
history: History::default(),
|
||||
@@ -4739,8 +4731,8 @@ fn test_precedence_fixture_with_gpt3_profile() -> std::io::Result<()> {
|
||||
memories: MemoriesConfig::default(),
|
||||
agent_job_max_runtime_seconds: DEFAULT_AGENT_JOB_MAX_RUNTIME_SECONDS,
|
||||
codex_home: fixture.codex_home(),
|
||||
sqlite_home: fixture.codex_home(),
|
||||
log_dir: fixture.codex_home().join("log"),
|
||||
sqlite_home: fixture.codex_home().to_path_buf(),
|
||||
log_dir: fixture.codex_home().join("log").to_path_buf(),
|
||||
config_layer_stack: Default::default(),
|
||||
startup_warnings: Vec::new(),
|
||||
history: History::default(),
|
||||
@@ -4886,8 +4878,8 @@ fn test_precedence_fixture_with_zdr_profile() -> std::io::Result<()> {
|
||||
memories: MemoriesConfig::default(),
|
||||
agent_job_max_runtime_seconds: DEFAULT_AGENT_JOB_MAX_RUNTIME_SECONDS,
|
||||
codex_home: fixture.codex_home(),
|
||||
sqlite_home: fixture.codex_home(),
|
||||
log_dir: fixture.codex_home().join("log"),
|
||||
sqlite_home: fixture.codex_home().to_path_buf(),
|
||||
log_dir: fixture.codex_home().join("log").to_path_buf(),
|
||||
config_layer_stack: Default::default(),
|
||||
startup_warnings: Vec::new(),
|
||||
history: History::default(),
|
||||
@@ -5019,8 +5011,8 @@ fn test_precedence_fixture_with_gpt5_profile() -> std::io::Result<()> {
|
||||
memories: MemoriesConfig::default(),
|
||||
agent_job_max_runtime_seconds: DEFAULT_AGENT_JOB_MAX_RUNTIME_SECONDS,
|
||||
codex_home: fixture.codex_home(),
|
||||
sqlite_home: fixture.codex_home(),
|
||||
log_dir: fixture.codex_home().join("log"),
|
||||
sqlite_home: fixture.codex_home().to_path_buf(),
|
||||
log_dir: fixture.codex_home().join("log").to_path_buf(),
|
||||
config_layer_stack: Default::default(),
|
||||
startup_warnings: Vec::new(),
|
||||
history: History::default(),
|
||||
@@ -5321,7 +5313,7 @@ fn test_load_config_rejects_legacy_ollama_chat_provider_with_helpful_error() ->
|
||||
let result = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
);
|
||||
assert!(result.is_err());
|
||||
let error = result.unwrap_err();
|
||||
@@ -5584,7 +5576,7 @@ mcp_oauth_callback_port = 5678
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.mcp_oauth_callback_port, Some(5678));
|
||||
@@ -5605,7 +5597,7 @@ allow_login_shell = false
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert!(!config.permissions.allow_login_shell);
|
||||
@@ -5625,7 +5617,7 @@ mcp_oauth_callback_url = "https://example.com/callback"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -5655,7 +5647,7 @@ fn test_untrusted_project_gets_unless_trusted_approval_policy() -> anyhow::Resul
|
||||
cwd: Some(test_path.to_path_buf()),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
// Verify that untrusted projects get UnlessTrusted approval policy
|
||||
@@ -6389,7 +6381,7 @@ discoverables = [
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6428,7 +6420,7 @@ experimental_realtime_start_instructions = "start instructions from config"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6456,7 +6448,7 @@ experimental_realtime_ws_base_url = "http://127.0.0.1:8011"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6484,7 +6476,7 @@ experimental_realtime_ws_backend_prompt = "prompt from config"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6512,7 +6504,7 @@ experimental_realtime_ws_startup_context = "startup context from config"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6540,7 +6532,7 @@ experimental_realtime_ws_model = "realtime-test-model"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6564,7 +6556,7 @@ voice = "marin"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6604,7 +6596,7 @@ voice = "cedar"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
@@ -6641,7 +6633,7 @@ speaker = "Desk Speakers"
|
||||
let config = Config::load_from_base_config_with_overrides(
|
||||
cfg,
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
codex_home.abs(),
|
||||
)?;
|
||||
|
||||
assert_eq!(config.realtime_audio.microphone.as_deref(), Some("USB Mic"));
|
||||
|
||||
@@ -174,7 +174,7 @@ pub(crate) fn test_config() -> Config {
|
||||
Config::load_from_base_config_with_overrides(
|
||||
ConfigToml::default(),
|
||||
ConfigOverrides::default(),
|
||||
codex_home.path().to_path_buf(),
|
||||
AbsolutePathBuf::from_absolute_path(codex_home.path()).expect("temp dir should resolve"),
|
||||
)
|
||||
.expect("load default test config")
|
||||
}
|
||||
@@ -425,7 +425,7 @@ pub struct Config {
|
||||
|
||||
/// Directory containing all Codex state (defaults to `~/.codex` but can be
|
||||
/// overridden by the `CODEX_HOME` environment variable).
|
||||
pub codex_home: PathBuf,
|
||||
pub codex_home: AbsolutePathBuf,
|
||||
|
||||
/// Directory where Codex stores the SQLite state DB.
|
||||
pub sqlite_home: PathBuf,
|
||||
@@ -616,7 +616,7 @@ impl Default for MultiAgentV2Config {
|
||||
|
||||
impl AuthManagerConfig for Config {
|
||||
fn codex_home(&self) -> PathBuf {
|
||||
self.codex_home.clone()
|
||||
self.codex_home.to_path_buf()
|
||||
}
|
||||
|
||||
fn cli_auth_credentials_store_mode(&self) -> AuthCredentialsStoreMode {
|
||||
@@ -678,7 +678,10 @@ impl ConfigBuilder {
|
||||
cloud_requirements,
|
||||
fallback_cwd,
|
||||
} = self;
|
||||
let codex_home = codex_home.map_or_else(find_codex_home, std::io::Result::Ok)?;
|
||||
let codex_home = match codex_home {
|
||||
Some(codex_home) => AbsolutePathBuf::from_absolute_path(codex_home)?,
|
||||
None => find_codex_home()?,
|
||||
};
|
||||
let cli_overrides = cli_overrides.unwrap_or_default();
|
||||
let mut harness_overrides = harness_overrides.unwrap_or_default();
|
||||
let loader_overrides = loader_overrides.unwrap_or_default();
|
||||
@@ -753,7 +756,7 @@ impl Config {
|
||||
|
||||
McpConfig {
|
||||
chatgpt_base_url: self.chatgpt_base_url.clone(),
|
||||
codex_home: self.codex_home.clone(),
|
||||
codex_home: self.codex_home.to_path_buf(),
|
||||
mcp_oauth_credentials_store_mode: self.mcp_oauth_credentials_store_mode,
|
||||
mcp_oauth_callback_port: self.mcp_oauth_callback_port,
|
||||
mcp_oauth_callback_url: self.mcp_oauth_callback_url.clone(),
|
||||
@@ -784,7 +787,10 @@ impl Config {
|
||||
cli_overrides: Vec<(String, TomlValue)>,
|
||||
) -> std::io::Result<Self> {
|
||||
let codex_home = find_codex_home()?;
|
||||
Self::load_default_with_cli_overrides_for_codex_home(codex_home, cli_overrides)
|
||||
Self::load_default_with_cli_overrides_for_codex_home(
|
||||
codex_home.to_path_buf(),
|
||||
cli_overrides,
|
||||
)
|
||||
}
|
||||
|
||||
/// Load a default configuration for a specific Codex home without reading
|
||||
@@ -801,6 +807,7 @@ impl Config {
|
||||
})?;
|
||||
let cli_layer = crate::config_loader::build_cli_overrides_layer(&cli_overrides);
|
||||
crate::config_loader::merge_toml_values(&mut merged, &cli_layer);
|
||||
let codex_home = AbsolutePathBuf::from_absolute_path_checked(codex_home)?;
|
||||
let config_toml = deserialize_config_toml_with_base(merged, &codex_home)?;
|
||||
Self::load_config_with_layer_stack(
|
||||
config_toml,
|
||||
@@ -1406,7 +1413,7 @@ impl Config {
|
||||
fn load_from_base_config_with_overrides(
|
||||
cfg: ConfigToml,
|
||||
overrides: ConfigOverrides,
|
||||
codex_home: PathBuf,
|
||||
codex_home: AbsolutePathBuf,
|
||||
) -> std::io::Result<Self> {
|
||||
// Note this ignores requirements.toml enforcement for tests.
|
||||
let config_layer_stack = ConfigLayerStack::default();
|
||||
@@ -1416,7 +1423,7 @@ impl Config {
|
||||
pub(crate) fn load_config_with_layer_stack(
|
||||
cfg: ConfigToml,
|
||||
overrides: ConfigOverrides,
|
||||
codex_home: PathBuf,
|
||||
codex_home: AbsolutePathBuf,
|
||||
config_layer_stack: ConfigLayerStack,
|
||||
) -> std::io::Result<Self> {
|
||||
validate_model_providers(&cfg.model_providers)
|
||||
@@ -1916,11 +1923,7 @@ impl Config {
|
||||
.log_dir
|
||||
.as_ref()
|
||||
.map(AbsolutePathBuf::to_path_buf)
|
||||
.unwrap_or_else(|| {
|
||||
let mut p = codex_home.clone();
|
||||
p.push("log");
|
||||
p
|
||||
});
|
||||
.unwrap_or_else(|| codex_home.join("log").to_path_buf());
|
||||
let sqlite_home = cfg
|
||||
.sqlite_home
|
||||
.as_ref()
|
||||
@@ -2338,7 +2341,7 @@ fn toml_uses_deprecated_instructions_file(value: &TomlValue) -> bool {
|
||||
/// value will be canonicalized and this function will Err otherwise.
|
||||
/// - If `CODEX_HOME` is not set, this function does not verify that the
|
||||
/// directory exists.
|
||||
pub fn find_codex_home() -> std::io::Result<PathBuf> {
|
||||
pub fn find_codex_home() -> std::io::Result<AbsolutePathBuf> {
|
||||
codex_utils_home_dir::find_codex_home()
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ fn restricted_read_implicitly_allows_helper_executables() -> std::io::Result<()>
|
||||
main_execve_wrapper_exe: Some(execve_wrapper),
|
||||
..Default::default()
|
||||
},
|
||||
codex_home,
|
||||
AbsolutePathBuf::from_absolute_path(&codex_home)?,
|
||||
)?;
|
||||
|
||||
let expected_zsh = AbsolutePathBuf::try_from(zsh_path)?;
|
||||
|
||||
Reference in new issue
Block a user