aKode fase 2b-1: rimossi plugin remoti e share, bundle download, UI usage/crediti/banner/workspace ChatGPT; fix argomenti MCP (inviati vuoti dopo e4209e2) e overlay TUI; test analytics-upload rimossi; test sicurezza MCP adattati
Some checks failed
blocking-ci / Bazel (push) Has been cancelled
blocking-ci / Blob size policy (push) Has been cancelled
blocking-ci / cargo-deny (push) Has been cancelled
blocking-ci / Codespell (push) Has been cancelled
blocking-ci / repo-checks (push) Has been cancelled
blocking-ci / rust-ci (push) Has been cancelled
blocking-ci / sdk (push) Has been cancelled
blocking-ci / CI required (push) Has been cancelled
postmerge-ci / rust-ci-full (push) Has been cancelled
postmerge-ci / v8-canary (push) Has been cancelled
postmerge-ci / Postmerge CI results (push) Has been cancelled

This commit is contained in:
Andrea
2026-11-09 16:24:36 +01:00
parent 0de669e9ce
commit 981745ccc8
190 changed files with 313 additions and 9756 deletions

View File

@@ -67,14 +67,9 @@ fn user_verification_is_projected_only_to_the_host_owned_plugin_service() {
use crate::catalog::McpServerRegistration;
use crate::catalog::ResolvedMcpCatalog;
use crate::mcp::CODEX_APPS_MCP_SERVER_NAME;
use crate::mcp::codex_apps_mcp_server_config;
use codex_rmcp_client::McpProtocolMode;
let config = codex_apps_mcp_server_config(
"https://example.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let config = crate::mcp::test_http_mcp_server_config("https://example.com");
let extensions = ClientMcpExtensions::new([
(
OPENAI_ELICITATION_EXTENSION_ID.to_string(),

View File

@@ -4718,11 +4718,7 @@ async fn list_all_tools_adds_server_metadata_to_tools() {
#[test]
fn server_metadata_preserves_tool_approval_policy() {
let mut config = crate::codex_apps_mcp_server_config(
"https://docs.example",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let mut config = crate::mcp::test_http_mcp_server_config("https://docs.example");
config.environment_id = "remote".to_string();
config.default_tools_approval_mode = Some(AppToolApproval::Prompt);
config.tools.insert(
@@ -4757,11 +4753,7 @@ fn hosted_actor_credentials_are_only_available_to_host_owned_mcp_servers() {
);
let hosted_auth = CodexAuth::Headers(AuthHeaders::new(actor_headers));
let provider = codex_model_provider::auth_provider_from_auth(&hosted_auth);
let mut local_config = crate::codex_apps_mcp_server_config(
"https://chatgpt.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let mut local_config = crate::mcp::test_http_mcp_server_config("https://chatgpt.com");
local_config.auth = McpServerAuth::ChatGpt;
let local_server = EffectiveMcpServer::from_host_config(local_config.clone());
@@ -4795,11 +4787,9 @@ fn gov_codex_apps_retain_local_chatgpt_auth_provider() -> anyhow::Result<()> {
config.chatgpt_base_url = "https://gov.chatgpt.com/backend-api/".to_string();
config.apps_enabled = true;
let local_config = crate::codex_apps_mcp_server_config(
&config.chatgpt_base_url,
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let mut local_config =
crate::mcp::test_http_mcp_server_config("https://gov.chatgpt.com/backend-api/ps/mcp");
local_config.auth = McpServerAuth::ChatGpt;
let mut remote_config = local_config.clone();
remote_config.environment_id = "customer-executor".to_string();
let mut custom_oauth = local_config.clone();
@@ -4822,14 +4812,8 @@ fn gov_codex_apps_retain_local_chatgpt_auth_provider() -> anyhow::Result<()> {
config.mcp_server_catalog = catalog.build();
let servers = crate::effective_mcp_servers(&config, Some(&auth));
let local = &servers[CODEX_APPS_MCP_SERVER_NAME];
assert_eq!(local.config().auth, McpServerAuth::ChatGpt);
let retained = chatgpt_auth_provider_for_server(local, Some(Arc::clone(&provider)))
.expect("local Gov Apps must retain ChatGPT authentication");
assert!(
Arc::ptr_eq(&provider, &retained),
"server selection must preserve the supplied provider"
);
// aKode never connects to the ChatGPT-hosted apps MCP server.
assert!(!servers.contains_key(CODEX_APPS_MCP_SERVER_NAME));
assert_eq!(servers["custom-oauth"].config().auth, McpServerAuth::OAuth);
assert_eq!(servers["remote-gov"].config().auth, McpServerAuth::ChatGpt);

View File

@@ -760,11 +760,7 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
config.apps_enabled = true;
let auth = codex_login::CodexAuth::create_dummy_chatgpt_auth_for_testing();
let hosted_server = crate::codex_apps_mcp_server_config(
"https://example.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let hosted_server = crate::mcp::test_http_mcp_server_config("https://example.com");
let mut attached_server = hosted_server.clone();
attached_server.environment_id = "attached".to_string();
let mut catalog = crate::ResolvedMcpCatalog::builder();
@@ -772,9 +768,9 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
"attached".to_string(),
attached_server,
));
catalog.register(crate::McpServerRegistration::from_hosted_apps(
"host",
/*contribution_order*/ 0,
// A user-configured server on the local environment, which is not attached below.
catalog.register(crate::McpServerRegistration::from_config(
"local".to_string(),
hosted_server,
));
config.mcp_server_catalog = catalog.build();
@@ -785,14 +781,8 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
codex_utils_path_uri::PathUri::from_host_native_path(std::env::temp_dir()).unwrap(),
);
let sandbox = Arc::new(sandbox);
// Hosted Apps must still use thread permissions when a local environment is attached.
[
("attached".to_string(), Arc::clone(&sandbox)),
(
codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(),
sandbox,
),
]
// Unattached local servers keep using thread permissions.
[("attached".to_string(), sandbox)]
};
config.set_server_permissions(&servers, attachment(PermissionProfile::read_only()));
@@ -808,7 +798,7 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
&ClientMcpExtensions::default(),
);
let hosted = manager.make_sender(
crate::CODEX_APPS_MCP_SERVER_NAME.to_string(),
"local".to_string(),
/*tx_event*/ None,
&ClientMcpExtensions::default(),
);
@@ -853,6 +843,14 @@ async fn reused_elicitation_senders_follow_each_servers_latest_permission_author
ElicitationAction::Decline
);
let mut configured_servers = config.mcp_server_catalog.configured_servers();
configured_servers
.get_mut("local")
.expect("local server should be registered")
.enabled = false;
config.mcp_server_catalog = config
.mcp_server_catalog
.with_materialized_servers(configured_servers);
let servers = crate::effective_mcp_servers(&config, /*auth*/ None);
config.set_server_permissions(&servers, std::iter::empty());
assert!(manager.update(
@@ -879,11 +877,7 @@ fn verification_fixture(
catalog.register(crate::catalog::McpServerRegistration::from_hosted_apps(
"verification-test",
/*contribution_order*/ 0,
crate::mcp::codex_apps_mcp_server_config(
"https://example.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
),
crate::mcp::test_http_mcp_server_config("https://example.com"),
));
Arc::make_mut(&mut config).mcp_server_catalog = catalog.build();
let manager = ElicitationRequestManager::new(
@@ -1072,11 +1066,7 @@ async fn user_verification_rejects_attached_servers_even_if_they_use_the_plugin_
let mut catalog = crate::catalog::ResolvedMcpCatalog::builder();
catalog.register(crate::catalog::McpServerRegistration::from_config(
name.into(),
crate::mcp::codex_apps_mcp_server_config(
"https://example.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
),
crate::mcp::test_http_mcp_server_config("https://example.com"),
));
config.mcp_server_catalog = catalog.build();
}

View File

@@ -824,3 +824,35 @@ pub(crate) async fn collect_mcp_server_status_snapshot_from_manager(
#[cfg(test)]
#[path = "mod_tests.rs"]
pub(crate) mod tests;
/// Test fixture: a generic user-configured streamable HTTP MCP server at `url`.
#[cfg(test)]
pub(crate) fn test_http_mcp_server_config(url: &str) -> McpServerConfig {
McpServerConfig {
transport: McpServerTransportConfig::StreamableHttp {
url: url.to_string(),
bearer_token_env_var: None,
http_headers: None,
env_http_headers: None,
http_headers_helper: None,
},
auth: McpServerAuth::default(),
environment_id: codex_config::DEFAULT_MCP_SERVER_ENVIRONMENT_ID.to_string(),
enabled: true,
required: false,
startup_readiness: Default::default(),
supports_parallel_tool_calls: false,
tool_input_schema_max_bytes: None,
omit_tools_from: None,
disabled_reason: None,
startup_timeout_sec: Some(Duration::from_secs(30)),
tool_timeout_sec: None,
default_tools_approval_mode: None,
enabled_tools: None,
disabled_tools: None,
scopes: None,
oauth: None,
oauth_resource: None,
tools: HashMap::new(),
}
}

View File

@@ -334,11 +334,7 @@ fn qualified_mcp_tool_name_prefix_sanitizes_server_names_without_lowercasing() {
fn mcp_server_permissions_handle_unattached_and_threadless_servers() {
let mut config = test_mcp_config(PathBuf::new());
config.permission_profile = PermissionProfile::Disabled;
let mut missing_server = codex_apps_mcp_server_config(
"https://example.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let mut missing_server = test_http_mcp_server_config("https://example.com");
missing_server.environment_id = "missing".to_string();
let mut selected_server = missing_server.clone();
selected_server.environment_id = "unattached".to_string();
@@ -445,11 +441,7 @@ fn tool_plugin_context_collects_app_and_mcp_sources() {
"alpha".to_string(),
McpPluginAttribution::new("alpha@test".to_string(), "alpha-plugin".to_string()),
/*plugin_order*/ 0,
codex_apps_mcp_server_config(
"https://alpha.example",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
),
test_http_mcp_server_config("https://alpha.example"),
));
config.mcp_server_catalog = catalog.build();
config.connector_snapshot =
@@ -520,11 +512,7 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
),
/*selection_order*/ 0,
"executor-1",
codex_apps_mcp_server_config(
"https://github.example",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
),
test_http_mcp_server_config("https://github.example"),
));
config.mcp_server_catalog = catalog.build();
config.connector_snapshot =
@@ -559,128 +547,6 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
assert!(provenance.is_selected_plugin_mcp_server("github"));
}
#[test]
fn codex_apps_mcp_url_for_base_url_uses_plugin_service_paths() {
assert_eq!(
codex_apps_mcp_url_for_base_url("https://chatgpt.com/backend-api"),
"https://chatgpt.com/backend-api/ps/mcp"
);
assert_eq!(
codex_apps_mcp_url_for_base_url("https://chat.openai.com"),
"https://chat.openai.com/backend-api/ps/mcp"
);
assert_eq!(
codex_apps_mcp_url_for_base_url("https://gov.chatgpt.com/backend-api/"),
"https://gov.chatgpt.com/backend-api/ps/mcp"
);
assert_eq!(
codex_apps_mcp_url_for_base_url("http://localhost:8080/api/codex"),
"http://localhost:8080/api/codex/ps/mcp"
);
assert_eq!(
codex_apps_mcp_url_for_base_url("http://localhost:8080"),
"http://localhost:8080/api/codex/ps/mcp"
);
}
#[test]
fn codex_apps_server_config_uses_plugin_service_path() {
let config = codex_apps_mcp_server_config(
"https://chatgpt.com",
/*apps_mcp_product_sku*/ None,
/*originator*/ None,
);
let url = match &config.transport {
McpServerTransportConfig::StreamableHttp { url, .. } => url,
_ => panic!("expected streamable http transport for codex apps"),
};
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
}
#[test]
fn codex_apps_server_config_forwards_thread_originator_header() {
let config = codex_apps_mcp_server_config(
"https://chatgpt.com",
/*apps_mcp_product_sku*/ None,
Some("thread_originator"),
);
match &config.transport {
McpServerTransportConfig::StreamableHttp {
http_headers,
env_http_headers,
..
} => {
assert_eq!(
http_headers,
&Some(HashMap::from([
("originator".to_string(), "thread_originator".to_string()),
("X-OpenAI-Product-Sku".to_string(), "codex".to_string()),
]))
);
assert!(env_http_headers.is_none());
}
other => panic!("expected streamable http transport, got {other:?}"),
}
}
#[test]
fn codex_apps_server_config_sets_product_sku_header() {
for (configured_product_sku, expected_product_sku) in [(None, "codex"), (Some("tpp"), "tpp")] {
let config = codex_apps_mcp_server_config(
"https://chatgpt.com",
configured_product_sku,
/*originator*/ None,
);
match &config.transport {
McpServerTransportConfig::StreamableHttp {
http_headers,
env_http_headers,
..
} => {
assert_eq!(
http_headers,
&Some(HashMap::from([(
"X-OpenAI-Product-Sku".to_string(),
expected_product_sku.to_string(),
)]))
);
assert!(env_http_headers.is_none());
}
other => panic!("expected streamable http transport, got {other:?}"),
}
}
}
#[test]
fn codex_apps_server_config_forwards_originator_and_configured_product_sku_headers() {
let config = codex_apps_mcp_server_config(
"https://chatgpt.com",
Some("tpp"),
Some("thread_originator"),
);
match &config.transport {
McpServerTransportConfig::StreamableHttp {
http_headers,
env_http_headers,
..
} => {
assert_eq!(
http_headers,
&Some(HashMap::from([
("originator".to_string(), "thread_originator".to_string()),
("X-OpenAI-Product-Sku".to_string(), "tpp".to_string()),
]))
);
assert!(env_http_headers.is_none());
}
other => panic!("expected streamable http transport, got {other:?}"),
}
}
#[test]
fn effective_mcp_servers_preserve_executor_credential_policy() {
let mut config = test_mcp_config(PathBuf::new());
@@ -747,9 +613,8 @@ fn effective_mcp_servers_preserve_chatgpt_auth_for_trusted_origins() {
] {
let mut config = test_mcp_config(PathBuf::new());
config.chatgpt_base_url = base_url.to_string();
let server = codex_apps_mcp_server_config(
server_url, /*apps_mcp_product_sku*/ None, /*originator*/ None,
);
let mut server = test_http_mcp_server_config(server_url);
server.auth = McpServerAuth::ChatGpt;
let mut catalog = ResolvedMcpCatalog::builder();
catalog.register(McpServerRegistration::from_config(
"trusted".to_string(),
@@ -780,9 +645,8 @@ fn effective_mcp_servers_reject_untrusted_origins_for_chatgpt_auth() {
] {
let mut config = test_mcp_config(PathBuf::new());
config.chatgpt_base_url = url.to_string();
let server = codex_apps_mcp_server_config(
url, /*apps_mcp_product_sku*/ None, /*originator*/ None,
);
let mut server = test_http_mcp_server_config(url);
server.auth = McpServerAuth::ChatGpt;
let mut catalog = ResolvedMcpCatalog::builder();
catalog.register(McpServerRegistration::from_config(
"untrusted".to_string(),
@@ -870,11 +734,7 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
));
catalog.register(McpServerRegistration::from_config(
CODEX_APPS_MCP_SERVER_NAME.to_string(),
codex_apps_mcp_server_config(
&config.chatgpt_base_url,
config.apps_mcp_product_sku.as_deref(),
/*originator*/ None,
),
test_http_mcp_server_config("https://chatgpt.com/backend-api/ps/mcp"),
));
config.mcp_server_catalog = catalog.build();
@@ -884,13 +744,11 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
let docs = effective
.get("docs")
.expect("configured server should exist");
let codex_apps = effective
.get(CODEX_APPS_MCP_SERVER_NAME)
.expect("codex apps server should exist");
// aKode never connects to the ChatGPT-hosted apps MCP server.
assert!(!effective.contains_key(CODEX_APPS_MCP_SERVER_NAME));
let sample = sample.config();
let docs = docs.config();
let codex_apps = codex_apps.config();
match &sample.transport {
McpServerTransportConfig::StreamableHttp { url, .. } => {
@@ -904,10 +762,4 @@ async fn effective_mcp_servers_preserve_runtime_servers() {
}
other => panic!("expected streamable http transport, got {other:?}"),
}
match &codex_apps.transport {
McpServerTransportConfig::StreamableHttp { url, .. } => {
assert_eq!(url, "https://chatgpt.com/backend-api/ps/mcp");
}
other => panic!("expected streamable http transport, got {other:?}"),
}
}