WIP fase 2b-3: rimozione sottosistemi solo-ChatGPT (plugin remoti, image gen, daybreak, cyber, attestation, cloud config, app/connettori) - test in corso

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-10 16:07:22 +01:00
parent 231e8cd136
commit 5afc7e9f7f
1223 changed files with 6225 additions and 113722 deletions

View File

@@ -7,7 +7,6 @@ use std::path::PathBuf;
use std::process::Stdio;
use anyhow::Context as _;
use codex_config::CloudConfigBundleLoader;
use codex_config::LoaderOverrides;
use codex_core::config::Config;
use codex_core::config::ConfigBuilder;
@@ -666,7 +665,6 @@ async fn load_debug_sandbox_config(
codex_linux_sandbox_exe,
options,
/*codex_home*/ None,
CloudConfigBundleLoader::default(),
strict_config,
)
.await
@@ -677,7 +675,6 @@ async fn load_debug_sandbox_config_with_codex_home(
codex_linux_sandbox_exe: Option<PathBuf>,
options: DebugSandboxConfigOptions,
codex_home: Option<PathBuf>,
cloud_config_bundle: CloudConfigBundleLoader,
strict_config: bool,
) -> anyhow::Result<Config> {
let DebugSandboxConfigOptions {
@@ -711,7 +708,6 @@ async fn load_debug_sandbox_config_with_codex_home(
codex_home.clone(),
managed_requirements_mode,
loader_overrides.clone(),
cloud_config_bundle.clone(),
strict_config,
)
.await?;
@@ -731,7 +727,6 @@ async fn load_debug_sandbox_config_with_codex_home(
codex_home,
managed_requirements_mode,
loader_overrides,
cloud_config_bundle,
strict_config,
)
.await
@@ -744,13 +739,11 @@ async fn build_debug_sandbox_config_with_loader_overrides(
codex_home: Option<PathBuf>,
managed_requirements_mode: ManagedRequirementsMode,
mut loader_overrides: LoaderOverrides,
cloud_config_bundle: CloudConfigBundleLoader,
strict_config: bool,
) -> std::io::Result<Config> {
let mut builder = ConfigBuilder::default()
.cli_overrides(cli_overrides)
.harness_overrides(harness_overrides)
.cloud_config_bundle(cloud_config_bundle)
.strict_config(strict_config);
if matches!(managed_requirements_mode, ManagedRequirementsMode::Ignore) {
loader_overrides.ignore_managed_requirements = true;
@@ -782,20 +775,20 @@ fn cli_overrides_use_legacy_sandbox_mode(cli_overrides: &[(String, TomlValue)])
mod tests {
use super::*;
use codex_config::ConfigRequirementsToml;
use codex_config::test_support::CloudConfigBundleFixture;
use codex_config::test_support::ManagedConfigFixture;
use pretty_assertions::assert_eq;
use tempfile::TempDir;
const CLOUD_MANAGED_PERMISSION_PROFILE_REQUIREMENTS: &str = r#"
default_permissions = "managed-cloud"
const MANAGED_PERMISSION_PROFILE_REQUIREMENTS: &str = r#"
default_permissions = "managed-profile"
[allowed_permission_profiles]
managed-cloud = true
managed-profile = true
[permissions.managed-cloud]
[permissions.managed-profile]
extends = ":workspace"
[permissions.managed-cloud.network]
[permissions.managed-profile.network]
enabled = true
"#;
@@ -812,7 +805,6 @@ enabled = true
codex_home,
managed_requirements_mode,
LoaderOverrides::default(),
CloudConfigBundleLoader::default(),
strict_config,
)
.await
@@ -896,7 +888,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home_path),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -940,7 +931,6 @@ enabled = true
Some(codex_home_path.clone()),
ManagedRequirementsMode::Include,
loader_overrides.clone(),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -967,7 +957,6 @@ enabled = true
loader_overrides,
},
Some(codex_home_path),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -1026,7 +1015,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home_path),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -1086,7 +1074,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home_path),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -1115,7 +1102,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home.path().to_path_buf()),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -1138,7 +1124,7 @@ enabled = true
}
#[tokio::test]
async fn debug_sandbox_honors_explicit_cloud_managed_permission_profile() -> anyhow::Result<()>
async fn debug_sandbox_honors_explicit_managed_permission_profile() -> anyhow::Result<()>
{
let codex_home = TempDir::new()?;
@@ -1147,15 +1133,15 @@ enabled = true
/*codex_linux_sandbox_exe*/ None,
DebugSandboxConfigOptions {
sandbox_state: Default::default(),
permissions_profile: Some("managed-cloud".to_string()),
permissions_profile: Some("managed-profile".to_string()),
cwd: None,
managed_requirements_mode: ManagedRequirementsMode::Include,
loader_overrides: LoaderOverrides::without_managed_config_for_tests(),
loader_overrides: ManagedConfigFixture::requirements(
MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
)
.loader_overrides_for_tests(codex_home.path())?,
},
Some(codex_home.path().to_path_buf()),
CloudConfigBundleFixture::loader_with_enterprise_requirement(
CLOUD_MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
),
/*strict_config*/ false,
)
.await?;
@@ -1165,7 +1151,7 @@ enabled = true
.permissions
.active_permission_profile()
.map(|profile| profile.id),
Some("managed-cloud".to_string()),
Some("managed-profile".to_string()),
);
assert_eq!(
config.permissions.network_sandbox_policy(),
@@ -1174,7 +1160,7 @@ enabled = true
assert_eq!(
config.config_layer_stack.requirements_toml(),
&toml::from_str::<ConfigRequirementsToml>(
CLOUD_MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
)?,
);
@@ -1182,7 +1168,7 @@ enabled = true
}
#[tokio::test]
async fn debug_sandbox_ignores_cloud_managed_permission_profiles_by_default()
async fn debug_sandbox_ignores_managed_permission_profiles_by_default()
-> anyhow::Result<()> {
let codex_home = TempDir::new()?;
@@ -1194,12 +1180,12 @@ enabled = true
permissions_profile: Some(":workspace".to_string()),
cwd: None,
managed_requirements_mode: ManagedRequirementsMode::Ignore,
loader_overrides: LoaderOverrides::without_managed_config_for_tests(),
loader_overrides: ManagedConfigFixture::requirements(
MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
)
.loader_overrides_for_tests(codex_home.path())?,
},
Some(codex_home.path().to_path_buf()),
CloudConfigBundleFixture::loader_with_enterprise_requirement(
CLOUD_MANAGED_PERMISSION_PROFILE_REQUIREMENTS,
),
/*strict_config*/ false,
)
.await?;
@@ -1242,7 +1228,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home.path().to_path_buf()),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;
@@ -1283,7 +1268,6 @@ enabled = true
loader_overrides: LoaderOverrides::default(),
},
Some(codex_home.path().to_path_buf()),
CloudConfigBundleLoader::default(),
/*strict_config*/ false,
)
.await?;

View File

@@ -640,7 +640,7 @@ async fn load_config(
..config_overrides_from_interactive(interactive, arg0_paths)
};
let config = crate::cloud_config::config_builder(
let config = crate::local_config::config_builder(
&root_config_overrides,
LoaderOverrides::default(),
overrides,
@@ -1117,7 +1117,7 @@ fn codex_path_entries() -> Vec<String> {
fn config_check(config: &Config) -> DoctorCheck {
let mut details = Vec::new();
details
.push("configuration scope: invocation config, including cloud-managed policy".to_string());
.push("configuration scope: invocation config, including managed policy".to_string());
details.push("active thread overrides: not inspected".to_string());
details.push(format!("CODEX_HOME: {}", config.codex_home.display()));
details.push(format!("cwd: {}", config.cwd.display()));
@@ -1230,13 +1230,10 @@ fn auth_check(config: &Config) -> DoctorCheck {
));
details.push(format!("auth file: {}", auth_path.display()));
let env_auth_vars = [
OPENAI_API_KEY_ENV_VAR,
CODEX_API_KEY_ENV_VAR,
]
.into_iter()
.filter(|name| env_var_present(name))
.collect::<Vec<_>>();
let env_auth_vars = [OPENAI_API_KEY_ENV_VAR, CODEX_API_KEY_ENV_VAR]
.into_iter()
.filter(|name| env_var_present(name))
.collect::<Vec<_>>();
if !env_auth_vars.is_empty() {
details.push(format!(
"auth env vars present: {}",
@@ -2723,7 +2720,7 @@ async fn provider_reachability_check(plan: ReachabilityPlan) -> DoctorCheck {
.details(details);
}
let client = RouteAwareClientPool::with_chatgpt_cloudflare_cookies_without_request_logging(
let client = RouteAwareClientPool::new_without_request_logging(
plan.http_client_factory,
ClientRouteClass::Api,
)

View File

@@ -83,7 +83,6 @@ pub(super) fn sandbox_check(config: &Config, arg0_paths: &Arg0DispatchPaths) ->
{
None => "none",
Some(RequirementSource::Unknown) => "unknown",
Some(RequirementSource::EnterpriseManaged { .. }) => "cloud",
Some(RequirementSource::Composite { .. }) => "multiple layers",
Some(RequirementSource::MdmManagedPreferences { .. }) => "MDM",
Some(RequirementSource::SystemRequirementsToml { .. }) => "system",

View File

@@ -142,7 +142,6 @@ fn terminal_title_item_id(item: &str) -> Option<&'static str> {
"total-output-tokens" => Some("total-output-tokens"),
"thread-id" | "session-id" => Some("thread-id"),
"fast-mode" => Some("fast-mode"),
"daybreak" => Some("daybreak"),
"model" | "model-name" => Some("model"),
"model-with-reasoning" => Some("model-with-reasoning"),
"reasoning" => Some("reasoning"),
@@ -315,7 +314,7 @@ mod tests {
configured_items: Some(vec![
"thread-credits".to_string(),
"estimated-thread-cost".to_string(),
"daybreak".to_string(),
"fast-mode".to_string(),
]),
cwd: PathBuf::from("/workspace/project"),
project_root: None,
@@ -324,7 +323,7 @@ mod tests {
assert_eq!(check.status, CheckStatus::Ok);
assert_eq!(check.summary, "terminal title configured");
assert!(check.details.contains(
&"terminal title items: thread-credits, estimated-thread-cost, daybreak".to_string()
&"terminal title items: thread-credits, estimated-thread-cost, fast-mode".to_string()
));
assert!(check.issues.is_empty());
}

View File

@@ -1,30 +0,0 @@
//! Snapshot coverage for the public exec command's argument help.
use super::MultitoolCli;
use clap::CommandFactory;
use pretty_assertions::assert_eq;
#[test]
fn exec_help_documents_cyber_access_program() {
let help = MultitoolCli::command()
.term_width(80)
.try_get_matches_from(["codex", "exec", "--help"])
.expect_err("help should short-circuit");
assert_eq!(help.kind(), clap::error::ErrorKind::DisplayHelp);
let program_help = help
.to_string()
.lines()
.skip_while(|line| !line.contains("--cyber-access-program"))
.take_while(|line| !line.is_empty())
.map(str::trim_end)
.collect::<Vec<_>>()
.join("\n");
insta::assert_snapshot!(program_help.trim(), @r"
--cyber-access-program <PROGRAM>
Request an experimental Cyber access program for this turn (OpenAI
provider only). Omit to use server defaults. Not supported with
review; fork requires a prompt
[possible values: standard, daybreak_blue, daybreak_red]
");
}

View File

@@ -1,4 +1,4 @@
pub mod cloud_config;
pub mod local_config;
pub(crate) mod debug_sandbox;
mod exit_status;
pub(crate) mod login;

View File

@@ -7,7 +7,7 @@ use codex_app_server_daemon::BootstrapOptions as AppServerBootstrapOptions;
use codex_app_server_daemon::LifecycleCommand as AppServerLifecycleCommand;
use codex_arg0::Arg0DispatchPaths;
use codex_arg0::arg0_dispatch_or_else;
use codex_cli::cloud_config;
use codex_cli::local_config;
use codex_cli::read_api_key_from_stdin;
use codex_cli::run_login_status;
use codex_cli::run_login_with_api_key;
@@ -46,9 +46,6 @@ mod config_override_args;
mod daemon_install;
mod doctor;
#[cfg(test)]
#[path = "exec_args_tests.rs"]
mod exec_args_tests;
#[cfg(test)]
#[path = "exec_server_args_tests.rs"]
mod exec_server_args_tests;
mod marketplace_cmd;
@@ -525,9 +522,6 @@ struct AppServerCommand {
#[command(flatten)]
startup_config: codex_app_server::StartupConfigArgs,
/// Load frozen cloud skills from a JSON snapshot instead of a live skill service.
#[arg(long, value_name = "PATH")]
cloud_skills_snapshot: Option<PathBuf>,
/// Omit to run the app server; specify a subcommand for tooling.
#[command(subcommand)]
subcommand: Option<AppServerSubcommand>,
@@ -1163,7 +1157,6 @@ async fn dispatch_cli(
Some(Subcommand::AppServer(app_server_cli)) => {
let AppServerCommand {
startup_config,
cloud_skills_snapshot,
subcommand,
code_mode_host,
strict_config: app_server_strict_config,
@@ -1212,7 +1205,6 @@ async fn dispatch_cli(
let _ = codex_app_server_daemon::maintain_stderr_log();
}
let runtime_options = codex_app_server::AppServerRuntimeOptions {
cloud_skills_snapshot,
code_mode_host_transport: code_mode_host.into(),
managed_daemon,
// aKode: remote control (chatgpt.com relay) is never started.
@@ -1734,7 +1726,7 @@ async fn dispatch_cli(
}
let config =
cloud_config::load_config(&root_config_overrides, LoaderOverrides::default())
local_config::load_config(&root_config_overrides, LoaderOverrides::default())
.await?;
let mut rows = Vec::with_capacity(FEATURES.len());
let mut name_width = 0;
@@ -1969,7 +1961,6 @@ async fn run_debug_prompt_input_command(
.enabled(codex_features::Feature::OmitSkillDescriptions),
max_context_tokens: config.skill_max_context_tokens,
bundled_skills_enabled: config.bundled_skills_enabled(),
cloud_skill_enabled: config.cloud_skill_enabled,
shadow_selection_enabled: config
.features
.enabled(codex_features::Feature::SkillSearch),

View File

@@ -24,7 +24,7 @@ use std::collections::HashSet;
use std::path::Path;
use std::path::PathBuf;
use crate::cloud_config;
use crate::local_config;
use crate::plugin_cmd::JsonMarketplaceSource;
use crate::plugin_cmd::configured_marketplace_snapshot_issues;
use crate::plugin_cmd::configured_marketplace_sources;
@@ -129,7 +129,7 @@ impl MarketplaceCli {
subcommand,
} = self;
let builder = cloud_config::config_builder(
let builder = local_config::config_builder(
&config_overrides,
LoaderOverrides::default(),
ConfigOverrides::default(),

View File

@@ -29,7 +29,6 @@ use codex_mcp::McpRuntimeContext;
use codex_mcp::apply_http_headers_helper;
use codex_mcp::compute_auth_statuses;
use codex_mcp::discover_supported_scopes;
use codex_mcp::ema_auth_scope;
use codex_mcp::oauth_login_support;
use codex_mcp::resolve_oauth_callback;
use codex_mcp::resolve_oauth_scopes;
@@ -38,14 +37,13 @@ use codex_rmcp_client::McpOAuthCallbackMode;
use codex_rmcp_client::McpOAuthClientRegistration;
use codex_rmcp_client::OAuthDiscoveryTimeout;
use codex_rmcp_client::StreamableHttpRedirectMode;
use codex_rmcp_client::delete_enterprise_oauth_tokens;
use codex_rmcp_client::delete_oauth_tokens;
use codex_rmcp_client::resolve_mcp_oauth_callback_url;
use codex_utils_cli::CliConfigOverrides;
use codex_utils_cli::format_env_display;
use codex_utils_redacted_string::RedactedString;
use crate::cloud_config;
use crate::local_config;
use crate::mcp_login::McpLoginMode;
use crate::mcp_login::perform_oauth_login_retry_without_scopes;
@@ -249,26 +247,26 @@ impl McpCli {
match subcommand {
McpSubcommand::List(args) => {
let config = cloud_config::load_config(&config_overrides, loader_overrides).await?;
let config = local_config::load_config(&config_overrides, loader_overrides).await?;
run_list(&config, args).await?;
}
McpSubcommand::Get(args) => {
let config = cloud_config::load_config(&config_overrides, loader_overrides).await?;
let config = local_config::load_config(&config_overrides, loader_overrides).await?;
run_get(&config, args).await?;
}
McpSubcommand::Add(args) => {
let config = cloud_config::load_config(&config_overrides, loader_overrides).await?;
let config = local_config::load_config(&config_overrides, loader_overrides).await?;
run_add(&config, args).await?;
}
McpSubcommand::Remove(args) => {
run_remove(&config_overrides, args).await?;
}
McpSubcommand::Login(args) => {
let config = cloud_config::load_config(&config_overrides, loader_overrides).await?;
let config = local_config::load_config(&config_overrides, loader_overrides).await?;
run_login(&config, args).await?;
}
McpSubcommand::Logout(args) => {
let config = cloud_config::load_config(&config_overrides, loader_overrides).await?;
let config = local_config::load_config(&config_overrides, loader_overrides).await?;
run_logout(&config, args).await?;
}
}
@@ -558,9 +556,7 @@ async fn run_login(config: &Config, login_args: LoginArgs) -> Result<()> {
};
if matches!(server.auth, codex_config::types::McpServerAuth::EmaAuth) {
bail!(
"Enterprise MCP authorization is managed by Codex account sign-in. Open Codex to sign in."
);
bail!("Enterprise-managed MCP authorization (`auth = \"ema_auth\"`) is not supported.");
}
let (url, http_headers, env_http_headers) = match &server.transport {
@@ -635,34 +631,7 @@ async fn run_logout(config: &Config, logout_args: LogoutArgs) -> Result<()> {
.ok_or_else(|| anyhow!("No MCP server named '{name}' found in configuration."))?;
if matches!(server.auth, McpServerAuth::EmaAuth) {
let auth_manager =
AuthManager::shared_from_config(config, /*enable_codex_api_key_env*/ true).await?;
let auth = auth_manager.auth().await;
let scope = ema_auth_scope(auth.as_ref()).context(
"Enterprise MCP authorization requires an account sign-in, which this build does not support",
)?;
// Cleanup must remain available even when this server is no longer eligible
// for EMA (for example, after disabling the feature or changing its transport).
let profile = config
.mcp_enterprise_managed_auth
.as_ref()
.context("EMA logout requires a trusted enterprise IdP profile")?;
let idp = &profile.idp;
let credential_name = idp.credential_name(&scope);
match delete_enterprise_oauth_tokens(
&credential_name,
&idp.issuer,
config.auth_keyring_backend_kind(),
)
.await
{
Ok(true) => println!(
"Removed the shared enterprise authorization used by EMA MCP servers (selected via '{name}')."
),
Ok(false) => println!("No shared enterprise authorization is stored."),
Err(_) => return Err(anyhow!("failed to delete enterprise authorization")),
}
return Ok(());
bail!("Enterprise-managed MCP authorization (`auth = \"ema_auth\"`) is not supported.");
}
let url = match &server.transport {

View File

@@ -120,7 +120,7 @@ async fn config_with_application_network(
)?;
let requirements_path = home.join("requirements.toml");
std::fs::write(&requirements_path, requirements)?;
crate::cloud_config::load_config(
crate::local_config::load_config(
&codex_utils_cli::CliConfigOverrides::default(),
codex_core::config::LoaderOverrides {
system_config_path: Some(home.join("absent-system-config.toml")),

View File

@@ -1,10 +1,7 @@
use anyhow::Context;
use anyhow::Result;
use anyhow::bail;
use anyhow::ensure;
use clap::Parser;
use codex_app_server_protocol::PluginAuthPolicy;
use codex_app_server_protocol::PluginInstallPolicy;
use codex_core::config::Config;
use codex_core::config::find_codex_home;
use codex_core::plugins_manager_for_config;
@@ -14,7 +11,6 @@ use codex_core_plugins::PluginInstallOutcome;
use codex_core_plugins::PluginInstallRequest;
use codex_core_plugins::PluginsConfigInput;
use codex_core_plugins::PluginsManager;
use codex_core_plugins::RemotePluginInstallRequest;
use codex_core_plugins::allowed_configured_marketplace_names;
use codex_core_plugins::installed_marketplaces::marketplace_install_root;
use codex_core_plugins::installed_marketplaces::resolve_configured_marketplace_root;
@@ -23,14 +19,7 @@ use codex_core_plugins::marketplace::MarketplacePluginAuthPolicy;
use codex_core_plugins::marketplace::MarketplacePluginInstallPolicy;
use codex_core_plugins::marketplace::MarketplacePluginSource;
use codex_core_plugins::marketplace::find_marketplace_manifest_path;
use codex_core_plugins::remote;
use codex_core_plugins::remote::REMOTE_GLOBAL_MARKETPLACE_NAME;
use codex_core_plugins::remote::RemoteMarketplace;
use codex_core_plugins::remote::RemoteMarketplaceSource;
use codex_core_plugins::remote::RemotePluginCatalogCacheMode;
use codex_core_plugins::remote::RemotePluginSummary;
use codex_login::AuthManager;
use codex_login::CodexAuth;
use codex_plugin::PluginId;
use codex_plugin::validate_plugin_segment;
use codex_utils_absolute_path::AbsolutePathBuf;
@@ -60,13 +49,13 @@ pub struct PluginCli {
#[derive(Debug, clap::Subcommand)]
pub enum PluginSubcommand {
/// Install a plugin from a configured or remote marketplace.
/// Install a plugin from a configured marketplace.
///
/// Pass either `PLUGIN@MARKETPLACE` or pass `PLUGIN` with
/// `--marketplace MARKETPLACE`.
Add(AddPluginArgs),
/// List plugins available from configured and remote marketplaces.
/// List plugins available from configured marketplaces.
List(ListPluginsArgs),
/// Add, list, upgrade, or remove configured plugin marketplaces.
@@ -147,62 +136,23 @@ pub async fn run_plugin_add(
} = args;
let selection = parse_plugin_selection(plugin, marketplace_name)?;
let context = load_plugin_command_context(overrides).await?;
let outcome = if selection.marketplace_name == REMOTE_GLOBAL_MARKETPLACE_NAME {
let mut listing = fetch_remote_marketplaces(
&context,
Some(&selection.marketplace_name),
RemotePluginCatalogCacheMode::PreferFreshCache,
let marketplace = find_marketplace_for_plugin(
&context.manager,
context.codex_home.as_path(),
&context.plugins_input,
&selection.marketplace_name,
&selection.plugin_name,
)?;
let outcome = context
.manager
.install_plugin(
&context.plugins_input.config_layer_stack,
PluginInstallRequest {
plugin_name: selection.plugin_name,
marketplace_path: marketplace.path,
},
)
.await?;
// A newly published plugin may be missing from an otherwise fresh catalog cache.
if listing.catalog_cache_used
&& !listing
.marketplaces
.iter()
.flat_map(|marketplace| &marketplace.plugins)
.any(|plugin| plugin.name == selection.plugin_name)
{
listing = fetch_remote_marketplaces(
&context,
Some(&selection.marketplace_name),
RemotePluginCatalogCacheMode::ForceRefetch,
)
.await?;
}
let plugin = resolve_remote_plugin(listing.marketplaces, &selection)?;
context
.manager
.install_remote_plugin(
&context.plugins_input,
context.auth.as_ref(),
RemotePluginInstallRequest {
marketplace_name: selection.marketplace_name,
remote_plugin_id: plugin.remote_plugin_id,
install_attempt_id: None,
},
/*on_effective_plugins_changed*/ None,
)
.await?
.installed
} else {
let marketplace = find_marketplace_for_plugin(
&context.manager,
context.codex_home.as_path(),
&context.plugins_input,
&selection.marketplace_name,
&selection.plugin_name,
)?;
context
.manager
.install_plugin(
&context.plugins_input.config_layer_stack,
PluginInstallRequest {
plugin_name: selection.plugin_name,
marketplace_path: marketplace.path,
},
)
.await?
};
let output = JsonPluginAddOutput::from_outcome(outcome);
if json {
@@ -248,12 +198,6 @@ pub async fn run_plugin_list(
args: ListPluginsArgs,
) -> Result<()> {
let context = load_plugin_command_context(overrides).await?;
let remote_listing = fetch_remote_marketplaces(
&context,
args.marketplace_name.as_deref(),
RemotePluginCatalogCacheMode::PreferFreshCache,
)
.await?;
let PluginCommandContext {
codex_home,
plugins_input,
@@ -261,11 +205,7 @@ pub async fn run_plugin_list(
..
} = context;
let outcome = manager
.list_marketplaces_for_config(
&plugins_input,
&[],
/*include_openai_curated*/ !remote_listing.uses_global_catalog,
)
.list_marketplaces_for_config(&plugins_input, &[], /*include_openai_curated*/ true)
.context("failed to list marketplace plugins")?;
ensure_configured_marketplace_snapshots_loaded(
codex_home.as_path(),
@@ -293,15 +233,9 @@ pub async fn run_plugin_list(
})
.collect(),
name: marketplace.name,
path: Some(marketplace.path),
path: marketplace.path,
}
})
.chain(
remote_listing
.marketplaces
.into_iter()
.map(PluginListMarketplace::from),
)
.filter(|marketplace| {
args.marketplace_name
.as_ref()
@@ -370,7 +304,6 @@ fn render_plugin_list(
};
let installed_version = plugin.display_version.clone().unwrap_or_default();
let path = match &plugin.source {
JsonPluginSource::Remote { id } => id.clone(),
JsonPluginSource::Local { path } => path.clone(),
JsonPluginSource::Git { url, ref_name, sha }
| JsonPluginSource::GitSubdir {
@@ -413,11 +346,7 @@ fn render_plugin_list(
writeln!(writer)?;
}
writeln!(writer, "Marketplace `{}`", marketplace.name)?;
if let Some(path) = &marketplace.path {
writeln!(writer, "{}", path.display())?;
} else {
writeln!(writer, "Remote catalog")?;
}
writeln!(writer, "{}", marketplace.path.display())?;
writeln!(writer)?;
writeln!(
writer,
@@ -438,48 +367,10 @@ fn render_plugin_list(
struct PluginListMarketplace {
name: String,
path: Option<AbsolutePathBuf>,
path: AbsolutePathBuf,
plugins: Vec<PluginListEntry>,
}
impl From<RemoteMarketplace> for PluginListMarketplace {
fn from(marketplace: RemoteMarketplace) -> Self {
Self {
plugins: marketplace
.plugins
.into_iter()
.map(|plugin| {
let version = plugin.local_version.or(plugin.version);
PluginListEntry {
plugin_id: plugin.id,
name: plugin.name,
marketplace_name: marketplace.name.clone(),
display_version: version.clone(),
version,
installed: plugin.installed,
enabled: plugin.enabled,
source: JsonPluginSource::Remote {
id: plugin.remote_plugin_id,
},
marketplace_source: None,
install_policy: match plugin.install_policy {
PluginInstallPolicy::NotAvailable => "NOT_AVAILABLE",
PluginInstallPolicy::Available => "AVAILABLE",
PluginInstallPolicy::InstalledByDefault => "INSTALLED_BY_DEFAULT",
},
auth_policy: match plugin.auth_policy {
PluginAuthPolicy::OnInstall => "ON_INSTALL",
PluginAuthPolicy::OnUse => "ON_USE",
},
}
})
.collect(),
name: marketplace.name,
path: None,
}
}
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct JsonPluginListOutput {
@@ -557,9 +448,6 @@ impl PluginListEntry {
#[derive(Debug, Serialize)]
#[serde(tag = "source", rename_all = "kebab-case")]
enum JsonPluginSource {
Remote {
id: String,
},
Local {
path: String,
},
@@ -690,41 +578,10 @@ pub async fn run_plugin_remove(
let selection = parse_plugin_selection(plugin, marketplace_name)?;
let context = load_plugin_command_context(overrides).await?;
if selection.marketplace_name == REMOTE_GLOBAL_MARKETPLACE_NAME {
ensure!(
context.plugins_input.plugins_enabled,
"remote plugins are not enabled"
);
let auth = context.auth.as_ref();
// Installed plugins may no longer appear in the directory or curated collection.
let marketplaces = context
.manager
.build_and_cache_remote_installed_plugin_marketplaces(
&context.plugins_input,
auth,
&[REMOTE_GLOBAL_MARKETPLACE_NAME],
/*on_effective_plugins_changed*/ None,
)
.await?;
let plugin = resolve_remote_plugin(marketplaces, &selection)?;
let outcome = context
.manager
.uninstall_remote_plugin(
&context.plugins_input,
auth,
&plugin.remote_plugin_id,
/*on_effective_plugins_changed*/ None,
)
.await?;
if let Some(err) = outcome.cache_removal_error {
return Err(err.into());
}
} else {
context
.manager
.uninstall_plugin(selection.plugin_key.clone())
.await?;
}
context
.manager
.uninstall_plugin(selection.plugin_key.clone())
.await?;
if json {
let output = JsonPluginRemoveOutput::from_selection(selection);
println!("{}", serde_json::to_string_pretty(&output)?);
@@ -761,7 +618,6 @@ struct PluginCommandContext {
codex_home: PathBuf,
plugins_input: PluginsConfigInput,
manager: Arc<PluginsManager>,
auth: Option<CodexAuth>,
}
async fn load_plugin_command_context(
@@ -773,13 +629,11 @@ async fn load_plugin_command_context(
.context("failed to load configuration")?;
let plugins_input = config.plugins_config_input();
let auth_manager = load_cli_auth_manager(&config).await?;
let auth = auth_manager.auth().await;
let manager = Arc::new(plugins_manager_for_config(&config, Arc::clone(&auth_manager)));
let manager = Arc::new(plugins_manager_for_config(&config, auth_manager));
Ok(PluginCommandContext {
codex_home: codex_home.to_path_buf(),
plugins_input,
manager,
auth,
})
}
@@ -831,98 +685,6 @@ fn parse_plugin_selection(
}
}
#[derive(Default)]
struct RemoteMarketplaceListing {
marketplaces: Vec<RemoteMarketplace>,
// A successful global catalog replaces the local curated catalog even when it is empty.
uses_global_catalog: bool,
catalog_cache_used: bool,
}
async fn fetch_remote_marketplaces(
context: &PluginCommandContext,
marketplace_name: Option<&str>,
cache_mode: RemotePluginCatalogCacheMode,
) -> Result<RemoteMarketplaceListing> {
if marketplace_name.is_some_and(|name| name != REMOTE_GLOBAL_MARKETPLACE_NAME) {
return Ok(RemoteMarketplaceListing::default());
}
if !context.plugins_input.plugins_enabled {
ensure!(marketplace_name.is_none(), "remote plugins are not enabled");
return Ok(RemoteMarketplaceListing::default());
}
let auth = context.auth.as_ref();
if !codex_core_plugins::apps_route_available(auth.map(CodexAuth::auth_mode)) {
ensure!(
marketplace_name.is_none(),
"remote plugin catalogs are not available"
);
return Ok(RemoteMarketplaceListing::default());
}
let service = context
.manager
.remote_plugin_service_config(&context.plugins_input);
let result = if context.plugins_input.remote_plugin_enabled {
remote::fetch_remote_marketplaces(
&service,
auth,
&[RemoteMarketplaceSource::Global],
/*catalog_cache_root*/ Some(context.codex_home.as_path()),
cache_mode,
)
.await
.map(|outcome| RemoteMarketplaceListing {
marketplaces: outcome.marketplaces,
uses_global_catalog: true,
catalog_cache_used: outcome.catalog_cache_used,
})
} else {
remote::fetch_openai_curated_remote_collection_marketplace(
&service,
auth,
/*catalog_cache_root*/ Some(context.codex_home.as_path()),
cache_mode,
)
.await
.map(|outcome| RemoteMarketplaceListing {
marketplaces: outcome.marketplace.into_iter().collect(),
uses_global_catalog: false,
catalog_cache_used: outcome.catalog_cache_used,
})
};
match result {
Ok(listing) => Ok(listing),
Err(err) if marketplace_name.is_none() => {
eprintln!("Warning: failed to list remote marketplace plugins: {err}");
Ok(RemoteMarketplaceListing::default())
}
Err(err) => Err(err).context("failed to list remote marketplace plugins"),
}
}
fn resolve_remote_plugin(
marketplaces: Vec<RemoteMarketplace>,
selection: &PluginSelection,
) -> Result<RemotePluginSummary> {
let matches = marketplaces
.into_iter()
.flat_map(|marketplace| marketplace.plugins)
.filter(|plugin| plugin.name == selection.plugin_name)
.collect::<Vec<_>>();
match matches.as_slice() {
[plugin] => Ok(plugin.clone()),
[] => bail!(
"plugin `{}` was not found in remote marketplace `{}`",
selection.plugin_name,
selection.marketplace_name
),
_ => bail!(
"plugin `{}` matched multiple remote plugins",
selection.plugin_key
),
}
}
fn find_marketplace_for_plugin(
manager: &PluginsManager,
codex_home: &std::path::Path,

View File

@@ -167,7 +167,7 @@ async fn network_only_reports_recoverable_config_warnings_and_effective_config()
},
"config": {
"summary": "config loaded",
"scope": "invocation config, including cloud-managed policy",
"scope": "invocation config, including managed policy",
"provider": "local",
"startupWarnings": baseline_warning_count + 1,
"startupWarning": "Ignoring invalid `otel.span_attributes` config: configured span attribute key must not be empty",