chore: unify config crates (#5958)

This commit is contained in:
jif-oai
2025-10-30 10:28:32 +00:00
committed by GitHub
parent fac548e430
commit aa76003e28
25 changed files with 74 additions and 73 deletions

View File

@@ -767,7 +767,7 @@ pub struct Tools {
pub view_image: Option<bool>, pub view_image: Option<bool>,
} }
/// MCP representation of a [`codex_core::config_types::SandboxWorkspaceWrite`]. /// MCP representation of a [`codex_core::config::types::SandboxWorkspaceWrite`].
#[derive(Deserialize, Debug, Clone, PartialEq, Serialize, JsonSchema, TS)] #[derive(Deserialize, Debug, Clone, PartialEq, Serialize, JsonSchema, TS)]
#[ts(optional_fields = nullable)] #[ts(optional_fields = nullable)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]

View File

@@ -73,8 +73,8 @@ use codex_core::auth::login_with_api_key;
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config::ConfigOverrides; use codex_core::config::ConfigOverrides;
use codex_core::config::ConfigToml; use codex_core::config::ConfigToml;
use codex_core::config::load_config_as_toml; use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::config_edit::ConfigEditsBuilder; use codex_core::config_loader::load_config_as_toml;
use codex_core::default_client::get_codex_user_agent; use codex_core::default_client::get_codex_user_agent;
use codex_core::exec::ExecParams; use codex_core::exec::ExecParams;
use codex_core::exec_env::create_env; use codex_core::exec_env::create_env;

View File

@@ -9,11 +9,11 @@ use codex_common::CliConfigOverrides;
use codex_common::format_env_display::format_env_display; use codex_common::format_env_display::format_env_display;
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config::ConfigOverrides; use codex_core::config::ConfigOverrides;
use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::config::find_codex_home; use codex_core::config::find_codex_home;
use codex_core::config::load_global_mcp_servers; use codex_core::config::load_global_mcp_servers;
use codex_core::config_edit::ConfigEditsBuilder; use codex_core::config::types::McpServerConfig;
use codex_core::config_types::McpServerConfig; use codex_core::config::types::McpServerTransportConfig;
use codex_core::config_types::McpServerTransportConfig;
use codex_core::features::Feature; use codex_core::features::Feature;
use codex_core::mcp::auth::compute_auth_statuses; use codex_core::mcp::auth::compute_auth_statuses;
use codex_core::protocol::McpAuthStatus; use codex_core::protocol::McpAuthStatus;

View File

@@ -2,7 +2,7 @@ use std::path::Path;
use anyhow::Result; use anyhow::Result;
use codex_core::config::load_global_mcp_servers; use codex_core::config::load_global_mcp_servers;
use codex_core::config_types::McpServerTransportConfig; use codex_core::config::types::McpServerTransportConfig;
use predicates::str::contains; use predicates::str::contains;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use tempfile::TempDir; use tempfile::TempDir;

View File

@@ -1,9 +1,9 @@
use std::path::Path; use std::path::Path;
use anyhow::Result; use anyhow::Result;
use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::config::load_global_mcp_servers; use codex_core::config::load_global_mcp_servers;
use codex_core::config_edit::ConfigEditsBuilder; use codex_core::config::types::McpServerTransportConfig;
use codex_core::config_types::McpServerTransportConfig;
use predicates::prelude::PredicateBooleanExt; use predicates::prelude::PredicateBooleanExt;
use predicates::str::contains; use predicates::str::contains;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;

View File

@@ -56,8 +56,8 @@ use crate::client::ModelClient;
use crate::client_common::Prompt; use crate::client_common::Prompt;
use crate::client_common::ResponseEvent; use crate::client_common::ResponseEvent;
use crate::config::Config; use crate::config::Config;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
use crate::config_types::ShellEnvironmentPolicy; use crate::config::types::ShellEnvironmentPolicy;
use crate::conversation_history::ConversationHistory; use crate::conversation_history::ConversationHistory;
use crate::environment_context::EnvironmentContext; use crate::environment_context::EnvironmentContext;
use crate::error::CodexErr; use crate::error::CodexErr;
@@ -2277,8 +2277,8 @@ mod tests {
use super::*; use super::*;
use crate::config::ConfigOverrides; use crate::config::ConfigOverrides;
use crate::config::ConfigToml; use crate::config::ConfigToml;
use crate::config_types::McpServerConfig; use crate::config::types::McpServerConfig;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
use crate::exec::ExecToolCallOutput; use crate::exec::ExecToolCallOutput;
use crate::mcp::auth::McpAuthStatusEntry; use crate::mcp::auth::McpAuthStatusEntry;
use crate::tools::format_exec_output_str; use crate::tools::format_exec_output_str;

View File

@@ -1,6 +1,6 @@
use crate::config::CONFIG_TOML_FILE; use crate::config::CONFIG_TOML_FILE;
use crate::config_types::McpServerConfig; use crate::config::types::McpServerConfig;
use crate::config_types::Notice; use crate::config::types::Notice;
use anyhow::Context; use anyhow::Context;
use codex_protocol::config_types::ReasoningEffort; use codex_protocol::config_types::ReasoningEffort;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@@ -41,8 +41,8 @@ pub enum ConfigEdit {
// TODO(jif) move to a dedicated file // TODO(jif) move to a dedicated file
mod document_helpers { mod document_helpers {
use crate::config_types::McpServerConfig; use crate::config::types::McpServerConfig;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
use toml_edit::Array as TomlArray; use toml_edit::Array as TomlArray;
use toml_edit::InlineTable; use toml_edit::InlineTable;
use toml_edit::Item as TomlItem; use toml_edit::Item as TomlItem;
@@ -509,7 +509,7 @@ impl ConfigEditsBuilder {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
use codex_protocol::config_types::ReasoningEffort; use codex_protocol::config_types::ReasoningEffort;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use tempfile::tempdir; use tempfile::tempdir;

View File

@@ -1,23 +1,22 @@
use crate::auth::AuthCredentialsStoreMode; use crate::auth::AuthCredentialsStoreMode;
use crate::config::types::DEFAULT_OTEL_ENVIRONMENT;
use crate::config::types::History;
use crate::config::types::McpServerConfig;
use crate::config::types::Notice;
use crate::config::types::Notifications;
use crate::config::types::OtelConfig;
use crate::config::types::OtelConfigToml;
use crate::config::types::OtelExporterKind;
use crate::config::types::ReasoningSummaryFormat;
use crate::config::types::SandboxWorkspaceWrite;
use crate::config::types::ShellEnvironmentPolicy;
use crate::config::types::ShellEnvironmentPolicyToml;
use crate::config::types::Tui;
use crate::config::types::UriBasedFileOpener;
use crate::config_loader::LoadedConfigLayers; use crate::config_loader::LoadedConfigLayers;
pub use crate::config_loader::load_config_as_toml; use crate::config_loader::load_config_as_toml;
use crate::config_loader::load_config_layers_with_overrides; use crate::config_loader::load_config_layers_with_overrides;
use crate::config_loader::merge_toml_values; use crate::config_loader::merge_toml_values;
use crate::config_profile::ConfigProfile;
use crate::config_types::DEFAULT_OTEL_ENVIRONMENT;
use crate::config_types::History;
use crate::config_types::McpServerConfig;
use crate::config_types::Notice;
use crate::config_types::Notifications;
use crate::config_types::OtelConfig;
use crate::config_types::OtelConfigToml;
use crate::config_types::OtelExporterKind;
use crate::config_types::ReasoningSummaryFormat;
use crate::config_types::SandboxWorkspaceWrite;
use crate::config_types::ShellEnvironmentPolicy;
use crate::config_types::ShellEnvironmentPolicyToml;
use crate::config_types::Tui;
use crate::config_types::UriBasedFileOpener;
use crate::features::Feature; use crate::features::Feature;
use crate::features::FeatureOverrides; use crate::features::FeatureOverrides;
use crate::features::Features; use crate::features::Features;
@@ -51,9 +50,14 @@ use std::io::ErrorKind;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use crate::config::profile::ConfigProfile;
use toml::Value as TomlValue; use toml::Value as TomlValue;
use toml_edit::DocumentMut; use toml_edit::DocumentMut;
pub mod edit;
pub mod profile;
pub mod types;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub const OPENAI_DEFAULT_MODEL: &str = "gpt-5"; pub const OPENAI_DEFAULT_MODEL: &str = "gpt-5";
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
@@ -265,7 +269,7 @@ pub struct Config {
pub disable_paste_burst: bool, pub disable_paste_burst: bool,
/// OTEL configuration (exporter type, endpoint, headers, etc.). /// OTEL configuration (exporter type, endpoint, headers, etc.).
pub otel: crate::config_types::OtelConfig, pub otel: crate::config::types::OtelConfig,
} }
impl Config { impl Config {
@@ -448,7 +452,7 @@ pub(crate) fn set_project_trusted_inner(
/// Patch `CODEX_HOME/config.toml` project state. /// Patch `CODEX_HOME/config.toml` project state.
/// Use with caution. /// Use with caution.
pub fn set_project_trusted(codex_home: &Path, project_path: &Path) -> anyhow::Result<()> { pub fn set_project_trusted(codex_home: &Path, project_path: &Path) -> anyhow::Result<()> {
use crate::config_edit::ConfigEditsBuilder; use crate::config::edit::ConfigEditsBuilder;
ConfigEditsBuilder::new(codex_home) ConfigEditsBuilder::new(codex_home)
.set_project_trusted(project_path) .set_project_trusted(project_path)
@@ -629,13 +633,13 @@ pub struct ConfigToml {
pub disable_paste_burst: Option<bool>, pub disable_paste_burst: Option<bool>,
/// OTEL configuration. /// OTEL configuration.
pub otel: Option<crate::config_types::OtelConfigToml>, pub otel: Option<crate::config::types::OtelConfigToml>,
/// Tracks whether the Windows onboarding screen has been acknowledged. /// Tracks whether the Windows onboarding screen has been acknowledged.
pub windows_wsl_setup_acknowledged: Option<bool>, pub windows_wsl_setup_acknowledged: Option<bool>,
/// Collection of in-product notices (different from notifications) /// Collection of in-product notices (different from notifications)
/// See [`crate::config_types::Notices`] for more details /// See [`crate::config::types::Notices`] for more details
pub notice: Option<Notice>, pub notice: Option<Notice>,
/// Legacy, now use features /// Legacy, now use features
@@ -1244,12 +1248,12 @@ pub fn log_dir(cfg: &Config) -> std::io::Result<PathBuf> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::config_edit::ConfigEdit; use crate::config::edit::ConfigEdit;
use crate::config_edit::ConfigEditsBuilder; use crate::config::edit::ConfigEditsBuilder;
use crate::config_edit::apply_blocking; use crate::config::edit::apply_blocking;
use crate::config_types::HistoryPersistence; use crate::config::types::HistoryPersistence;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
use crate::config_types::Notifications; use crate::config::types::Notifications;
use crate::features::Feature; use crate::features::Feature;
use super::*; use super::*;
@@ -3174,7 +3178,7 @@ trust_level = "trusted"
#[cfg(test)] #[cfg(test)]
mod notifications_tests { mod notifications_tests {
use crate::config_types::Notifications; use crate::config::types::Notifications;
use assert_matches::assert_matches; use assert_matches::assert_matches;
use serde::Deserialize; use serde::Deserialize;

View File

@@ -1,6 +1,6 @@
use crate::config_types::EnvironmentVariablePattern; use crate::config::types::EnvironmentVariablePattern;
use crate::config_types::ShellEnvironmentPolicy; use crate::config::types::ShellEnvironmentPolicy;
use crate::config_types::ShellEnvironmentPolicyInherit; use crate::config::types::ShellEnvironmentPolicyInherit;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::HashSet; use std::collections::HashSet;
@@ -71,7 +71,7 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::config_types::ShellEnvironmentPolicyInherit; use crate::config::types::ShellEnvironmentPolicyInherit;
use maplit::hashmap; use maplit::hashmap;
fn make_vars(pairs: &[(&str, &str)]) -> Vec<(String, String)> { fn make_vars(pairs: &[(&str, &str)]) -> Vec<(String, String)> {

View File

@@ -6,7 +6,7 @@
//! container attached to `Config`. //! container attached to `Config`.
use crate::config::ConfigToml; use crate::config::ConfigToml;
use crate::config_profile::ConfigProfile; use crate::config::profile::ConfigProfile;
use serde::Deserialize; use serde::Deserialize;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::BTreeSet; use std::collections::BTreeSet;

View File

@@ -17,10 +17,7 @@ pub use codex_conversation::CodexConversation;
mod codex_delegate; mod codex_delegate;
mod command_safety; mod command_safety;
pub mod config; pub mod config;
pub mod config_edit;
pub mod config_loader; pub mod config_loader;
pub mod config_profile;
pub mod config_types;
mod conversation_history; mod conversation_history;
pub mod custom_prompts; pub mod custom_prompts;
mod environment_context; mod environment_context;

View File

@@ -7,8 +7,8 @@ use codex_rmcp_client::determine_streamable_http_auth_status;
use futures::future::join_all; use futures::future::join_all;
use tracing::warn; use tracing::warn;
use crate::config_types::McpServerConfig; use crate::config::types::McpServerConfig;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct McpAuthStatusEntry { pub struct McpAuthStatusEntry {

View File

@@ -37,8 +37,8 @@ use tokio::task::JoinSet;
use tracing::info; use tracing::info;
use tracing::warn; use tracing::warn;
use crate::config_types::McpServerConfig; use crate::config::types::McpServerConfig;
use crate::config_types::McpServerTransportConfig; use crate::config::types::McpServerTransportConfig;
/// Delimiter used to separate the server name from the tool name in a fully /// Delimiter used to separate the server name from the tool name in a fully
/// qualified tool name. /// qualified tool name.

View File

@@ -28,7 +28,7 @@ use tokio::fs;
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
use crate::config::Config; use crate::config::Config;
use crate::config_types::HistoryPersistence; use crate::config::types::HistoryPersistence;
use codex_protocol::ConversationId; use codex_protocol::ConversationId;
#[cfg(unix)] #[cfg(unix)]

View File

@@ -1,4 +1,4 @@
use crate::config_types::ReasoningSummaryFormat; use crate::config::types::ReasoningSummaryFormat;
use crate::tools::handlers::apply_patch::ApplyPatchToolType; use crate::tools::handlers::apply_patch::ApplyPatchToolType;
/// The `instructions` field in the payload sent to a model should always start /// The `instructions` field in the payload sent to a model should always start

View File

@@ -1,6 +1,6 @@
use crate::config::Config; use crate::config::Config;
use crate::config_types::OtelExporterKind as Kind; use crate::config::types::OtelExporterKind as Kind;
use crate::config_types::OtelHttpProtocol as Protocol; use crate::config::types::OtelHttpProtocol as Protocol;
use crate::default_client::originator; use crate::default_client::originator;
use codex_otel::config::OtelExporter; use codex_otel::config::OtelExporter;
use codex_otel::config::OtelHttpProtocol; use codex_otel::config::OtelHttpProtocol;

View File

@@ -8,8 +8,8 @@ use std::time::Duration;
use std::time::SystemTime; use std::time::SystemTime;
use std::time::UNIX_EPOCH; use std::time::UNIX_EPOCH;
use codex_core::config_types::McpServerConfig; use codex_core::config::types::McpServerConfig;
use codex_core::config_types::McpServerTransportConfig; use codex_core::config::types::McpServerTransportConfig;
use codex_core::features::Feature; use codex_core::features::Feature;
use codex_core::protocol::AskForApproval; use codex_core::protocol::AskForApproval;

View File

@@ -219,8 +219,8 @@ async fn mcp_tool_call_output_exceeds_limit_truncated_for_model() -> Result<()>
config.features.enable(Feature::RmcpClient); config.features.enable(Feature::RmcpClient);
config.mcp_servers.insert( config.mcp_servers.insert(
server_name.to_string(), server_name.to_string(),
codex_core::config_types::McpServerConfig { codex_core::config::types::McpServerConfig {
transport: codex_core::config_types::McpServerTransportConfig::Stdio { transport: codex_core::config::types::McpServerTransportConfig::Stdio {
command: rmcp_test_server_bin, command: rmcp_test_server_bin,
args: Vec::new(), args: Vec::new(),
env: None, env: None,

View File

@@ -1,5 +1,5 @@
#![cfg(target_os = "linux")] #![cfg(target_os = "linux")]
use codex_core::config_types::ShellEnvironmentPolicy; use codex_core::config::types::ShellEnvironmentPolicy;
use codex_core::error::CodexErr; use codex_core::error::CodexErr;
use codex_core::error::SandboxErr; use codex_core::error::SandboxErr;
use codex_core::exec::ExecParams; use codex_core::exec::ExecParams;

View File

@@ -17,7 +17,7 @@ use codex_ansi_escape::ansi_escape_line;
use codex_core::AuthManager; use codex_core::AuthManager;
use codex_core::ConversationManager; use codex_core::ConversationManager;
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config_edit::ConfigEditsBuilder; use codex_core::config::edit::ConfigEditsBuilder;
use codex_core::model_family::find_family_for_model; use codex_core::model_family::find_family_for_model;
use codex_core::protocol::SessionSource; use codex_core::protocol::SessionSource;
use codex_core::protocol::TokenUsage; use codex_core::protocol::TokenUsage;

View File

@@ -4,7 +4,7 @@ use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config_types::Notifications; use codex_core::config::types::Notifications;
use codex_core::git_info::current_branch_name; use codex_core::git_info::current_branch_name;
use codex_core::git_info::local_git_branches; use codex_core::git_info::local_git_branches;
use codex_core::project_doc::DEFAULT_PROJECT_DOC_FILENAME; use codex_core::project_doc::DEFAULT_PROJECT_DOC_FILENAME;

View File

@@ -23,8 +23,8 @@ use crate::wrapping::word_wrap_lines;
use base64::Engine; use base64::Engine;
use codex_common::format_env_display::format_env_display; use codex_common::format_env_display::format_env_display;
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config_types::McpServerTransportConfig; use codex_core::config::types::McpServerTransportConfig;
use codex_core::config_types::ReasoningSummaryFormat; use codex_core::config::types::ReasoningSummaryFormat;
use codex_core::protocol::FileChange; use codex_core::protocol::FileChange;
use codex_core::protocol::McpAuthStatus; use codex_core::protocol::McpAuthStatus;
use codex_core::protocol::McpInvocation; use codex_core::protocol::McpInvocation;
@@ -1450,8 +1450,8 @@ mod tests {
use codex_core::config::Config; use codex_core::config::Config;
use codex_core::config::ConfigOverrides; use codex_core::config::ConfigOverrides;
use codex_core::config::ConfigToml; use codex_core::config::ConfigToml;
use codex_core::config_types::McpServerConfig; use codex_core::config::types::McpServerConfig;
use codex_core::config_types::McpServerTransportConfig; use codex_core::config::types::McpServerTransportConfig;
use codex_core::protocol::McpAuthStatus; use codex_core::protocol::McpAuthStatus;
use codex_protocol::parse_command::ParsedCommand; use codex_protocol::parse_command::ParsedCommand;
use dirs::home_dir; use dirs::home_dir;

View File

@@ -1,6 +1,6 @@
use std::path::PathBuf; use std::path::PathBuf;
use codex_core::config_edit::ConfigEditsBuilder; use codex_core::config::edit::ConfigEditsBuilder;
use crossterm::event::KeyCode; use crossterm::event::KeyCode;
use crossterm::event::KeyEvent; use crossterm::event::KeyEvent;
use crossterm::event::KeyEventKind; use crossterm::event::KeyEventKind;