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

@@ -24,8 +24,6 @@ const FOCUS_PROBE_INPUT: &str = "focus-palette-24527";
#[path = "external_editor_tests.rs"]
mod external_editor;
#[path = "gov_cloud_guidance_tests.rs"]
mod gov_cloud_guidance;
#[path = "tui_mode_picker_tests.rs"]
mod tui_mode_picker;
@@ -570,11 +568,23 @@ fn contains_bytes(buffer: &[u8], needle: &[u8]) -> bool {
pub(super) fn write_test_config(codex_home: &Path, repo_root: &Path) -> Result<()> {
let repo_root = repo_root.display();
// aKode has no built-in catalog provider: give the mock provider the bundled catalog.
let catalog_path = codex_home.join("test-models.json");
std::fs::write(
&catalog_path,
serde_json::to_vec(&codex_models_manager::bundled_models_response()?)?,
)
.context("write focus-test model catalog")?;
let catalog_path = catalog_path.display().to_string();
let config = format!(
"model = \"gpt-5.6-terra\"\nmodel_provider = \"openai\"\n\
"model = \"gpt-5.6-terra\"\nmodel_provider = \"mock\"\n\
model_catalog_json = {catalog_path:?}\n\
suppress_unstable_features_warning = true\n\
features.daemon_auto_start = false\n\
notice.model_migrations.\"gpt-5.6-terra\" = \"gpt-6-sol\"\n\n\
[model_providers.mock]\nname = \"Mock\"\nbase_url = \"http://127.0.0.1:9/v1\"\n\
wire_api = \"responses\"\nrequires_openai_auth = true\n\
merge_system_messages = false\n\n\
[projects.\"{repo_root}\"]\ntrust_level = \"trusted\"\n"
);
std::fs::write(codex_home.join("config.toml"), config)

View File

@@ -1,62 +0,0 @@
//! Verify startup acknowledgment, quit without saving, and restart suppression.
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn gov_cloud_startup_persists_only_acknowledgment() -> Result<()> {
let cwd = codex_utils_cargo_bin::repo_root()?;
let args = [
"--no-daemon",
"-c",
"features.api_key_model_discovery=false",
];
for action in ["quit", "acknowledge"] {
let home = tempfile::tempdir()?;
write_test_config(home.path(), &cwd)?;
let path = home.path().join("config.toml");
let config = std::fs::read_to_string(&path)?.replace(
"model_provider = \"openai\"",
"model_provider = \"amazon-bedrock\"",
);
let config = format!(
"{config}\n[model_providers.amazon-bedrock]\nbase_url = 'https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1'\n"
);
std::fs::write(&path, &config)?;
let mut terminal = PtyCodex::start(&cwd, home, &args)?;
terminal.wait_for_screen("Using Codex with AWS GovCloud")?;
let original = std::fs::read_to_string(&path)?;
let deadline = Instant::now() + STARTUP_TIMEOUT;
loop {
// Startup drains pending keys after drawing the guidance; retry until it handles one.
terminal.write_input(if action == "quit" { b"q" } else { b"\r" })?;
terminal.read_output(Duration::from_millis(/*millis*/ 50))?;
if action == "quit" {
if let Some(status) = terminal.child.try_wait()? {
ensure!(status.success(), "quit exited with {status}");
break;
}
} else if terminal.screen_contains("OpenAI Codex") {
break;
}
ensure!(Instant::now() < deadline, "{action} did not complete");
}
let saved = std::fs::read_to_string(&path)?;
if action == "acknowledge" {
let config: toml::Value = toml::from_str(&saved)?;
assert_eq!(
config["notice"]["hide_gov_cloud_guidance"].as_bool(),
Some(true)
);
let home = std::mem::replace(&mut terminal._codex_home, tempfile::tempdir()?);
drop(terminal);
let mut restarted = PtyCodex::start(&cwd, home, &args)?;
// The startup draft says "loading"; the actual model appears after guidance.
restarted.wait_for_screen("gpt-5.6-terra")?;
assert!(!restarted.screen_contains("Using Codex with AWS GovCloud"));
} else {
assert_eq!(saved, original);
}
}
Ok(())
}

View File

@@ -33,7 +33,7 @@ async fn resume_lists_all_providers_and_fork_keeps_provider_filter() -> Result<(
),
)?;
for (hour, provider, preview) in [
("10", "openai", "Client provider history"),
("10", "mock", "Client provider history"),
("11", "server-provider", "Server provider history"),
] {
create_fake_rollout(
@@ -89,14 +89,14 @@ async fn resume_lists_all_providers_and_fork_keeps_provider_filter() -> Result<(
"--remote",
remote_endpoint.as_str(),
"-c",
"model_provider=\"openai\"",
"model_provider=\"mock\"",
]);
}
let case = format!("{action}: embedded={embedded}, last={last}, explicit={explicit}");
let mut terminal = PtyCodex::start_cli(&cwd, home, &args)?;
if action == "resume" && last && explicit {
// --last finds the newest thread across providers. An explicit override
// cannot switch that thread from server-provider to openai.
// cannot switch that thread from server-provider to mock.
terminal
.wait_for_screen("Cannot change this thread's model provider")
.with_context(|| format!("{case}; screen:\n{}", terminal.screen_contents()))?;
@@ -158,15 +158,12 @@ async fn selected_gateway_authenticates_before_its_first_chat() -> Result<()> {
&profile,
format!(
r#"
model_provider = "openai"
model_provider = "office"
model = "gpt-5.1"
forced_login_method = "api"
cli_auth_credentials_store = "file"
suppress_unstable_features_warning = true
[features]
gateway_setup_wizard = true
bedrock_setup_wizard = false
gcp_setup_wizard = false
api_key_model_discovery = false
[projects.{trusted}]
trust_level = "trusted"
@@ -184,23 +181,23 @@ requires_openai_auth = true
home,
&["--profile", "work", "--no-daemon", "verify the gateway"],
)?;
// aKode has no default provider, so the gateway is already selected; its sign-in must
// finish before the first chat request.
terminal
.wait_for_screen("Use a custom provider or gateway")
.wait_for_screen("Connect an API key to use aKode")
.with_context(|| terminal.screen_contents())?;
// Startup drains input after its first draw. Retry the navigation until it is accepted.
// Startup drains input after its first draw. Retry until the API key entry opens. Pick the
// option by number: Enter would arm the activation guard and swallow the save below.
let deadline = std::time::Instant::now() + Duration::from_secs(/*secs*/ 30);
while !terminal.screen_contains("> 2. Use a custom provider or gateway") {
while !terminal.screen_contains("Paste or type your API key") {
ensure!(
std::time::Instant::now() < deadline,
"gateway option was not highlighted: {}",
"API key entry did not open: {}",
terminal.screen_contents()
);
terminal.write_input(b"\x1b[B")?;
terminal.write_input(b"1")?;
terminal.read_output(Duration::from_millis(/*millis*/ 50))?;
}
terminal.write_input(b"\r")?;
terminal.wait_for_screen("Office gateway")?;
terminal.write_input(b"\x1b[H\r")?;
terminal.wait_for_screen("Paste or type your API key")?;
let deadline = std::time::Instant::now() + Duration::from_secs(/*secs*/ 30);
while !auth.is_file() && terminal.screen_contains("Paste or type your API key") {

View File

@@ -62,7 +62,7 @@ async fn picker_side_worktree_fork_and_cd_run_on_the_production_stack() -> Resul
let server = responses::start_mock_server().await;
let config_path = codex_home.path().join("config.toml");
let config = fs::read_to_string(&config_path)?
.replace("model_provider = \"openai\"", "model_provider = \"test\"");
.replace("model_provider = \"mock\"", "model_provider = \"test\"");
fs::write(
&config_path,
format!(