Rimossi i provider integrati OpenAI, Bedrock e GCP e ogni fallback a OpenAI (B)

Parte "sicurezza" della fase 3 di aKode (e39aae00), senza le funzioni di imeAI:

- via i provider integrati openai, amazon-bedrock, amazon-bedrock-runtime e gcp
  (crate model-provider: moduli amazon_bedrock, gcp, chatgpt_base_url; login Bedrock;
  onboarding Bedrock/GCP; richieste app-server di setup cloud);
- nessun URL predefinito verso api.openai.com / chatgpt.com: un provider senza
  base_url non viene mai contattato; senza model_provider configurato exec e TUI
  mostrano come scriverne uno in config.toml (NO_MODEL_PROVIDER_CONFIGURED_ERROR);
- via la skill openai-docs, la sample skill-installer (scaricava da github.com/openai/skills),
  request_plugin_install, AppsInstructions, URL predefiniti di realtime e updater;
- test di sicurezza adattati (provider "mock" al posto di quello integrato), non cancellati.

Restano fuori da questo commit (categoria F/D/E, non portate): chiave per provider nel
portachiavi, modelli da /models, unione dei messaggi di sistema, crate web-tools e
SearXNG, header @@ in apply_patch, modello ausiliario, tool function per apply_patch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-17 12:31:29 +01:00
parent 22a79feba1
commit 2f8b6a3e16
481 changed files with 4319 additions and 25142 deletions

View File

@@ -1,16 +1,8 @@
#![allow(clippy::unwrap_used)]
use codex_config::test_support::ManagedConfigFixture;
use codex_features::Feature;
use codex_login::CodexAuth;
use codex_login::auth::BedrockApiKeyAuth;
use codex_model_provider_info::AMAZON_BEDROCK_GPT_5_5_MODEL_ID;
use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID;
use codex_model_provider_info::AMAZON_BEDROCK_RUNTIME_PROVIDER_ID;
use codex_model_provider_info::ModelProviderInfo;
use codex_protocol::config_types::WebSearchMode;
use codex_protocol::models::PermissionProfile;
use codex_protocol::openai_models::WebSearchToolType;
use core_test_support::responses;
use core_test_support::responses::start_mock_server;
use core_test_support::skip_if_no_network;
@@ -67,213 +59,6 @@ async fn web_search_mode_cached_sets_external_web_access_false() {
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn amazon_bedrock_web_search_uses_text_only_hosted_tools() {
skip_if_no_network!();
enum ModelCatalog {
BuiltIn,
Configured,
}
for (case, configured_web_search_mode, model_catalog) in [
("cached by default", None, ModelCatalog::BuiltIn),
(
"unsupported explicit live search falls back to cached",
Some(WebSearchMode::Live),
ModelCatalog::BuiltIn,
),
(
"unsupported explicit indexed search falls back to cached",
Some(WebSearchMode::Indexed),
ModelCatalog::BuiltIn,
),
("configured model catalog", None, ModelCatalog::Configured),
] {
let server = start_mock_server().await;
let resp_mock = responses::mount_sse_once(
&server,
responses::sse(vec![
responses::ev_response_created("resp-1"),
responses::ev_completed("resp-1"),
]),
)
.await;
let auth = CodexAuth::BedrockApiKey(BedrockApiKeyAuth {
api_key: "dummy".to_string(),
region: "us-east-1".to_string(),
});
let mut builder = test_codex().with_auth(auth);
builder = match model_catalog {
ModelCatalog::BuiltIn => builder.with_model(AMAZON_BEDROCK_GPT_5_5_MODEL_ID),
ModelCatalog::Configured => builder.with_model_info_override("gpt-5.5", |model_info| {
model_info.web_search_tool_type = WebSearchToolType::TextAndImage;
}),
};
builder = builder.with_config(move |config| {
let base_url = config.model_provider.base_url.clone();
config.model_provider_id = AMAZON_BEDROCK_PROVIDER_ID.to_string();
config.model_provider =
ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None);
config.model_provider.base_url = base_url;
if let Some(mode) = configured_web_search_mode {
config
.web_search_mode
.set(mode)
.expect("test web search mode should satisfy constraints");
}
});
let test = builder
.build_with_auto_env(&server)
.await
.expect("create test Bedrock conversation");
test.submit_turn_with_permission_profile(
"hello Bedrock web search",
PermissionProfile::Disabled,
)
.await
.expect("submit Bedrock turn");
let body = resp_mock.single_request().body_json();
assert_eq!(
find_web_search_tool(&body),
&json!({
"type": "web_search",
"external_web_access": false,
}),
"unexpected Bedrock search tool for {case}"
);
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn amazon_bedrock_runtime_preserves_cross_region_models_without_web_search() {
skip_if_no_network!();
for model in ["us.openai.gpt-5.6-sol", "global.openai.gpt-5.6-sol"] {
let server = start_mock_server().await;
let response = responses::mount_sse_once(
&server,
responses::sse(vec![
responses::ev_response_created("resp-1"),
responses::ev_completed("resp-1"),
]),
)
.await;
let auth = CodexAuth::BedrockApiKey(BedrockApiKeyAuth {
api_key: "dummy".to_string(),
region: "us-east-1".to_string(),
});
let mut builder = test_codex()
.with_auth(auth)
.with_model(model)
.with_config(|config| {
let base_url = config.model_provider.base_url.clone();
config.model_provider_id = AMAZON_BEDROCK_RUNTIME_PROVIDER_ID.to_string();
config.model_provider =
ModelProviderInfo::create_amazon_bedrock_runtime_provider(/*aws*/ None);
config.model_provider.base_url = base_url;
config
.web_search_mode
.set(WebSearchMode::Cached)
.expect("test web search mode should satisfy constraints");
});
let test = builder
.build_with_auto_env(&server)
.await
.expect("create test Bedrock Runtime conversation");
test.submit_turn_with_permission_profile(
"hello Bedrock Runtime",
PermissionProfile::Disabled,
)
.await
.expect("submit Bedrock Runtime turn");
let body = response.single_request().body_json();
let web_search_tool = body
.get("tools")
.and_then(Value::as_array)
.and_then(|tools| {
tools
.iter()
.find(|tool| tool.get("type").and_then(Value::as_str) == Some("web_search"))
});
assert_eq!(
(body["model"].as_str(), web_search_tool),
(Some(model), None)
);
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn amazon_bedrock_web_search_is_disabled_when_managed_requirements_prohibit_cached_search() {
skip_if_no_network!();
for (allowed_mode, requested_mode) in [
("live", WebSearchMode::Live),
("indexed", WebSearchMode::Indexed),
] {
let server = start_mock_server().await;
let resp_mock = responses::mount_sse_once(
&server,
responses::sse(vec![
responses::ev_response_created("resp-1"),
responses::ev_completed("resp-1"),
]),
)
.await;
let auth = CodexAuth::BedrockApiKey(BedrockApiKeyAuth {
api_key: "dummy".to_string(),
region: "us-east-1".to_string(),
});
let mut builder = test_codex()
.with_auth(auth)
.with_model(AMAZON_BEDROCK_GPT_5_5_MODEL_ID)
.with_managed_config(
ManagedConfigFixture::requirements(format!(
r#"allowed_web_search_modes = ["{allowed_mode}"]"#
)),
)
.with_config(move |config| {
assert_eq!(config.web_search_mode.value(), requested_mode);
let base_url = config.model_provider.base_url.clone();
config.model_provider_id = AMAZON_BEDROCK_PROVIDER_ID.to_string();
config.model_provider =
ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None);
config.model_provider.base_url = base_url;
});
let test = builder
.build_with_auto_env(&server)
.await
.expect("create managed Bedrock conversation");
test.submit_turn_with_permission_profile(
"hello managed Bedrock web search",
PermissionProfile::Disabled,
)
.await
.expect("submit managed Bedrock turn");
let body = resp_mock.single_request().body_json();
let web_search_tool = body
.get("tools")
.and_then(Value::as_array)
.and_then(|tools| {
tools
.iter()
.find(|tool| tool.get("type").and_then(Value::as_str) == Some("web_search"))
});
assert_eq!(
web_search_tool, None,
"Bedrock search should be disabled when managed requirements only allow {allowed_mode}"
);
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn web_search_mode_takes_precedence_over_legacy_flags() {
skip_if_no_network!();