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

@@ -125,12 +125,50 @@ pub async fn write_models_cache_with_models(
let cache = codex_model_provider::test_support::models_cache_entry(
&config.model_provider,
auth.as_ref(),
models,
models.clone(),
);
let cache_path = codex_home.join("models_cache.json");
std::fs::write(cache_path, serde_json::to_string_pretty(&cache)?)
std::fs::write(cache_path, serde_json::to_string_pretty(&cache)?)?;
// aKode: providers without `model_catalog_url` never read `models_cache.json` (they
// use an explicit catalog or the provider's `/models` listing). Keep the cached
// models authoritative, as they were upstream, by serving them as the explicit
// catalog — replacing the bundled one `MockResponsesConfig` installs by default.
if config.model_provider.model_catalog_url.is_none() {
let config_path = codex_home.join("config.toml");
let config_text = std::fs::read_to_string(&config_path).unwrap_or_default();
let harness_catalog = codex_home.join(HARNESS_CATALOG_FILE);
// Upstream merged cached models over the bundled catalog by slug.
let mut catalog = serde_json::from_str::<codex_protocol::openai_models::ModelsResponse>(
include_str!("../../../models-manager/models.json"),
)?
.models;
for model in models {
match catalog
.iter()
.position(|existing| existing.slug == model.slug)
{
Some(index) => catalog[index] = model,
None => catalog.push(model),
}
}
if config_text.contains(HARNESS_CATALOG_FILE) && harness_catalog.exists() {
std::fs::write(
harness_catalog,
serde_json::to_string_pretty(&serde_json::json!({ "models": catalog }))?,
)?;
} else if !config_text.contains("model_catalog_json") {
if !config_path.exists() {
std::fs::write(&config_path, "")?;
}
write_model_catalog_json(codex_home, catalog)?;
}
}
Ok(())
}
/// Catalog file `MockResponsesConfig::write` installs unless a test configures one.
pub(crate) const HARNESS_CATALOG_FILE: &str = "test-models.json";
/// Write `models` as a `model_catalog_json` catalog and point `config.toml` at it.
///
/// API-key sessions without a provider model catalog URL never read `models_cache.json`, so
@@ -142,7 +180,12 @@ pub fn write_model_catalog_json(codex_home: &Path, models: Vec<ModelInfo>) -> st
serde_json::to_string_pretty(&serde_json::json!({ "models": models }))?,
)?;
let config_path = codex_home.join("config.toml");
let config = std::fs::read_to_string(&config_path)?;
// Replace the default catalog `MockResponsesConfig::write` may have installed.
let config = std::fs::read_to_string(&config_path)?
.lines()
.filter(|line| !line.trim_start().starts_with("model_catalog_json"))
.collect::<Vec<_>>()
.join("\n");
std::fs::write(
&config_path,
format!(