aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT
- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
use anyhow::Context;
|
||||
use codex_config::AppToolApproval;
|
||||
use codex_config::McpServerToolConfig;
|
||||
use codex_config::test_support::CloudConfigBundleFixture;
|
||||
use codex_config::test_support::ManagedConfigFixture;
|
||||
use codex_core::EnvironmentConfig;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigBuilder;
|
||||
use codex_core::windows_sandbox::WindowsSandboxLevelExt;
|
||||
use codex_core_plugins::ExecutorPluginProvider;
|
||||
use codex_core_plugins::PluginCatalog;
|
||||
use codex_core_plugins::PluginCatalogEntry;
|
||||
use codex_core_plugins::PluginIdentity;
|
||||
use codex_core_plugins::PluginListQuery;
|
||||
use codex_core_plugins::PluginProvider;
|
||||
use codex_core_plugins::PluginProviderError;
|
||||
use codex_core_plugins::PluginProviderFuture;
|
||||
use codex_core_plugins::PluginSourceLocation;
|
||||
use codex_exec_server::CapabilityRootDiscovery;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server::ExecutorCapabilityDiscoveryCache;
|
||||
@@ -29,15 +21,14 @@ use codex_extension_api::SelectedPluginContribution;
|
||||
use codex_features::Feature;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_mcp_extension::PluginProviders;
|
||||
use codex_mcp_extension::PluginsThreadState;
|
||||
use codex_mcp_extension::install_plugin_providers;
|
||||
use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
use codex_protocol::capabilities::SelectedCapabilityRoot;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use codex_protocol::models::PermissionProfileSnapshot;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use core_test_support::apps_test_server::AppsTestServer;
|
||||
use core_test_support::apps_test_server::recorded_apps_tool_calls;
|
||||
use core_test_support::mcp_test_server::McpTestServer;
|
||||
use core_test_support::mcp_test_server::recorded_mcp_tool_calls;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
use core_test_support::responses::ev_completed;
|
||||
use core_test_support::responses::ev_function_call_with_namespace;
|
||||
@@ -53,8 +44,6 @@ use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
type TestResult = Result<(), Box<dyn std::error::Error>>;
|
||||
|
||||
@@ -73,7 +62,6 @@ struct PackageSummary {
|
||||
plugin_id: String,
|
||||
plugin_display_name: String,
|
||||
source_environment_id: String,
|
||||
connector_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -102,8 +90,8 @@ async fn selected_plugin_servers_use_managed_requirements_for_the_selected_root_
|
||||
let config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.fallback_cwd(Some(codex_home.path().to_path_buf()))
|
||||
.cloud_config_bundle(
|
||||
CloudConfigBundleFixture::loader_with_enterprise_requirement(
|
||||
.loader_overrides(
|
||||
(ManagedConfigFixture::requirements(
|
||||
r#"
|
||||
[plugins."selected-root".mcp_servers.allowed.identity]
|
||||
command = "allowed-command"
|
||||
@@ -111,7 +99,9 @@ command = "allowed-command"
|
||||
[plugins."selected-root".mcp_servers.mismatched.identity]
|
||||
command = "expected-command"
|
||||
"#,
|
||||
),
|
||||
))
|
||||
.loader_overrides_for_tests(codex_home.path())
|
||||
.expect("write managed config fixture"),
|
||||
)
|
||||
.build()
|
||||
.await?;
|
||||
@@ -151,7 +141,7 @@ command = "expected-command"
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn selected_plugin_package_is_contributed_without_servers_or_connectors() -> TestResult {
|
||||
async fn selected_plugin_package_is_contributed_without_servers() -> TestResult {
|
||||
let codex_home = tempfile::tempdir()?;
|
||||
let plugin_root = tempfile::tempdir()?;
|
||||
std::fs::create_dir_all(plugin_root.path().join(".codex-plugin"))?;
|
||||
@@ -178,7 +168,6 @@ async fn selected_plugin_package_is_contributed_without_servers_or_connectors()
|
||||
plugin_id,
|
||||
plugin_display_name: contribution.plugin_display_name,
|
||||
source_environment_id: contribution.source_environment_id,
|
||||
connector_ids: contribution.connector_ids,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
@@ -187,7 +176,6 @@ async fn selected_plugin_package_is_contributed_without_servers_or_connectors()
|
||||
plugin_id: "selected-root".to_string(),
|
||||
plugin_display_name: "Skill Only".to_string(),
|
||||
source_environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
connector_ids: Vec::new(),
|
||||
})
|
||||
);
|
||||
Ok(())
|
||||
@@ -235,7 +223,6 @@ async fn denied_malformed_plugin_retains_identity_without_capabilities() -> Test
|
||||
vec![(
|
||||
("selected-root".to_string(), "selected-root".to_string()),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
)]
|
||||
} else {
|
||||
Vec::new()
|
||||
@@ -248,7 +235,6 @@ async fn denied_malformed_plugin_retains_identity_without_capabilities() -> Test
|
||||
.map(|(root_id, plugin_id, contribution)| (
|
||||
(root_id, plugin_id),
|
||||
contribution.servers,
|
||||
contribution.connector_ids,
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
expected
|
||||
@@ -395,7 +381,6 @@ async fn selected_root_ownership_retries_errors_and_caches_success() -> TestResu
|
||||
.into_iter()
|
||||
.map(|(name, _)| name)
|
||||
.collect::<Vec<_>>(),
|
||||
contribution.connector_ids,
|
||||
));
|
||||
}
|
||||
assert_eq!(
|
||||
@@ -405,7 +390,6 @@ async fn selected_root_ownership_retries_errors_and_caches_success() -> TestResu
|
||||
.map(|(id, servers)| (
|
||||
id.to_string(),
|
||||
servers.into_iter().map(str::to_string).collect::<Vec<_>>(),
|
||||
Vec::new(),
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
"phase {phase}",
|
||||
@@ -430,13 +414,15 @@ async fn managed_plugins_requirement_disables_selected_plugin_capabilities() ->
|
||||
let mut config = ConfigBuilder::default()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.fallback_cwd(Some(codex_home.path().to_path_buf()))
|
||||
.cloud_config_bundle(
|
||||
CloudConfigBundleFixture::loader_with_enterprise_requirement(
|
||||
.loader_overrides(
|
||||
(ManagedConfigFixture::requirements(
|
||||
r#"
|
||||
[features]
|
||||
plugins = false
|
||||
"#,
|
||||
),
|
||||
))
|
||||
.loader_overrides_for_tests(codex_home.path())
|
||||
.expect("write managed config fixture"),
|
||||
)
|
||||
.build()
|
||||
.await?;
|
||||
@@ -692,43 +678,22 @@ async fn raw_selected_plugin_contributions(
|
||||
Ok(contributions)
|
||||
}
|
||||
|
||||
struct CloudCatalogFixture {
|
||||
reply: Result<PluginCatalog, String>,
|
||||
calls: AtomicUsize,
|
||||
}
|
||||
|
||||
impl PluginProvider for CloudCatalogFixture {
|
||||
fn list(&self, _query: PluginListQuery) -> PluginProviderFuture<'_, PluginCatalog> {
|
||||
Box::pin(async {
|
||||
self.calls.fetch_add(1, Ordering::SeqCst);
|
||||
self.reply.clone().map_err(PluginProviderError::Message)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cloud_plugins_append_apps_without_changing_executor_tools() -> anyhow::Result<()> {
|
||||
fn installed_executor_plugin_exposes_and_calls_its_mcp_tools() -> anyhow::Result<()> {
|
||||
run_test_with_large_stack(
|
||||
"cloud-plugin-projection",
|
||||
run_cloud_plugin_projection_scenarios,
|
||||
"executor-plugin-projection",
|
||||
run_executor_plugin_projection_scenarios,
|
||||
)
|
||||
}
|
||||
|
||||
async fn run_cloud_plugin_projection_scenarios() -> anyhow::Result<()> {
|
||||
async fn run_executor_plugin_projection_scenarios() -> anyhow::Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
core_test_support::skip_if_remote!(Ok(()), "V1 plugin fixtures use host-local files");
|
||||
// Fresh sessions keep unavailable-cloud fallback independent of a previously cached catalog.
|
||||
for (case, installed, cloud_enabled, cloud_available, cloud_empty) in [
|
||||
("cloud_only", false, true, true, false),
|
||||
("cloud_and_executor", true, true, true, false),
|
||||
("unavailable_cloud", true, true, false, false),
|
||||
("rollout_disabled", true, false, true, false),
|
||||
("empty_cloud", true, true, true, true),
|
||||
] {
|
||||
// Uninstalled plugins must not start MCPs; installed ones expose and run their tools.
|
||||
for (case, installed) in [("not_installed", false), ("installed", true)] {
|
||||
let server = start_mock_server().await;
|
||||
let apps = AppsTestServer::mount(&server).await?;
|
||||
let plugin_server = start_mock_server().await;
|
||||
let plugin_mcp = AppsTestServer::mount_with_tools(
|
||||
let plugin_mcp = McpTestServer::mount_with_tools(
|
||||
&plugin_server,
|
||||
Arc::new(std::sync::Mutex::new(vec![json!({
|
||||
"name": "echo", "description": "Echo a note.",
|
||||
@@ -749,56 +714,24 @@ async fn run_cloud_plugin_projection_scenarios() -> anyhow::Result<()> {
|
||||
})
|
||||
.with_priority(1)
|
||||
.mount(&plugin_server).await;
|
||||
let declaration =
|
||||
json!({"url": format!("{}/api/codex/ps/mcp", plugin_mcp.chatgpt_base_url)});
|
||||
let cloud = Arc::new(CloudCatalogFixture {
|
||||
reply: if cloud_empty {
|
||||
Ok(PluginCatalog::default())
|
||||
} else if cloud_available {
|
||||
Ok(PluginCatalog {
|
||||
entries: vec![PluginCatalogEntry {
|
||||
enabled: true,
|
||||
id: PluginIdentity::Remote {
|
||||
remote_plugin_id: "plugin_notes".into(),
|
||||
},
|
||||
display_name: "Cloud Notes".into(),
|
||||
version: "1".into(),
|
||||
mcp_servers: [("notes".into(), declaration.clone())].into(),
|
||||
connector_ids: vec!["calendar".into()],
|
||||
locations: vec![PluginSourceLocation::Cloud {
|
||||
resource_uri: "plugin://plugin_notes".into(),
|
||||
bundle_uri: None,
|
||||
}],
|
||||
}],
|
||||
..Default::default()
|
||||
})
|
||||
} else {
|
||||
Err("plugin-service unavailable".into())
|
||||
},
|
||||
calls: AtomicUsize::new(0),
|
||||
});
|
||||
let declaration = json!({"url": plugin_mcp.mcp_url()});
|
||||
let mut extensions = ExtensionRegistryBuilder::new();
|
||||
let mut providers = PluginProviders::new(Arc::new(ExecutorPluginProvider::new(Arc::new(
|
||||
let providers = PluginProviders::new(Arc::new(ExecutorPluginProvider::new(Arc::new(
|
||||
EnvironmentManager::default_for_tests(),
|
||||
))));
|
||||
if cloud_enabled {
|
||||
providers = providers.with_cloud_provider(cloud.clone());
|
||||
}
|
||||
install_plugin_providers(&mut extensions, providers);
|
||||
let mut builder = test_codex()
|
||||
.with_extensions(Arc::new(extensions.build()))
|
||||
.with_auth(CodexAuth::create_dummy_chatgpt_auth_for_testing())
|
||||
.with_auth(CodexAuth::from_api_key("Test API Key"))
|
||||
.with_model_info_override("gpt-5.5", |model| model.supports_search_tool = false)
|
||||
.with_config(move |config| {
|
||||
assert!(config.features.enable(Feature::Plugins).is_ok());
|
||||
assert!(config.features.enable(Feature::Apps).is_ok());
|
||||
assert!(
|
||||
config
|
||||
.features
|
||||
.enable(Feature::ExecutorCapabilityDiscovery)
|
||||
.is_ok()
|
||||
);
|
||||
config.chatgpt_base_url = apps.chatgpt_base_url;
|
||||
});
|
||||
let test = builder.build(&server).await?;
|
||||
if installed {
|
||||
@@ -887,7 +820,7 @@ async fn run_cloud_plugin_projection_scenarios() -> anyhow::Result<()> {
|
||||
"{case}: {output}"
|
||||
);
|
||||
}
|
||||
let calls = recorded_apps_tool_calls(&plugin_server).await;
|
||||
let calls = recorded_mcp_tool_calls(&plugin_server).await;
|
||||
assert_eq!(calls.len(), usize::from(installed), "{case}");
|
||||
if installed {
|
||||
assert_eq!(calls[0]["params"]["name"], "echo");
|
||||
@@ -907,34 +840,7 @@ async fn run_cloud_plugin_projection_scenarios() -> anyhow::Result<()> {
|
||||
});
|
||||
assert_eq!(
|
||||
initialized, installed,
|
||||
"{case}: cloud-only declarations must not start MCPs"
|
||||
);
|
||||
// Failed discovery stays in cooldown across both model steps.
|
||||
assert_eq!(
|
||||
cloud.calls.load(Ordering::SeqCst),
|
||||
usize::from(cloud_enabled),
|
||||
"{case}"
|
||||
);
|
||||
let state = test
|
||||
.codex
|
||||
.thread_extension_data()
|
||||
.get::<PluginsThreadState>()
|
||||
.context("plugin state missing")?;
|
||||
assert_eq!(
|
||||
state.cloud_catalog().is_some(),
|
||||
cloud_enabled && cloud_available,
|
||||
"{case}"
|
||||
);
|
||||
let calendar = requests[0]
|
||||
.tool_by_name("mcp__codex_apps__calendar", "_list_events")
|
||||
.context("Calendar tool missing")?;
|
||||
assert_eq!(
|
||||
calendar["description"]
|
||||
.as_str()
|
||||
.context("Apps description missing")?
|
||||
.contains("Cloud Notes"),
|
||||
cloud_enabled && cloud_available && !cloud_empty,
|
||||
"{case}"
|
||||
"{case}: uninstalled declarations must not start MCPs"
|
||||
);
|
||||
test.codex.shutdown_and_wait().await?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user