aKode fase 3: provider locali, chiavi per provider, modelli dal server, SearXNG

- Provider: rimossi openai, Bedrock e GCP integrati e ogni fallback a OpenAI;
  restano ollama, lmstudio e i provider personalizzati. Senza provider, exec e
  TUI mostrano come configurarlo.
- Chiave per provider: api_key = "keyring", provider_api_key_store =
  auto|keyring|file (fallback su file 0600 / ACL Windows); `codex login
  --provider <id> --with-api-key`, `logout --provider`; login status e doctor
  mostrano dove sta la chiave senza rivelarla.
- Modelli letti da GET {base_url}/models; contesto da config, poi dal server
  (/props, meta.n_ctx), poi 32768; apply_patch come tool function; niente tool
  ospitati; niente piu' avviso "metadata not found".
- Unione dei soli messaggi system/developer iniziali in un unico system;
  quelli successivi restano al loro posto come user (cache del server
  preservata: turno N prefisso esatto del turno N+1).
- Modelli ausiliari (memorie, guardian-v2) = modello di sessione se il
  preferito gpt-* non e' nel catalogo.
- Ricerca web: crate web-tools, backend SearXNG con web_search e web_fetch
  (protezione SSRF); senza backend nessuno strumento web.
- Skill: rimossa openai-docs; skill-installer punta a git.difonzo.net.
- apply_patch accetta gli header @@ -a,b +c,d @@ dei diff unificati.
- Rimossi resti: request_plugin_install, AppsInstructions, --cyber-access-program,
  URL updater/realtime predefiniti.
- Fix: importazione sessioni con provider vuoto.
- Istruzioni di sistema invariate. Test: cancellati solo quelli del codice
  rimosso, test di sicurezza adattati; restano solo fallimenti d'ambiente.
- Prova reale su imeAI + SearXNG: risposta, modifica file, web_search,
  cache riusata, connessioni solo verso .25 e .57.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 02:11:45 +01:00
parent 9e33707b8e
commit e39aae0085
545 changed files with 9742 additions and 24503 deletions

View File

@@ -79,34 +79,14 @@ async fn start_thread_with_model(
.await
}
#[tokio::test]
async fn thread_start_provider_model_fallback_applies_to_configured_model() -> Result<()> {
let codex_home = TempDir::new()?;
std::fs::write(
codex_home.path().join("config.toml"),
r#"model_provider = "amazon-bedrock"
model = "gpt-5.4-mini"
"#,
)?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.build_initialized()
.await?;
let response = mcp
.start_thread(ThreadStartParams {
allow_provider_model_fallback: true,
..Default::default()
})
.await?;
assert_eq!(response.model, "openai.gpt-6.1-sol");
Ok(())
}
#[tokio::test]
async fn thread_start_warns_for_exec_policy_parse_failure_after_initialize() -> Result<()> {
let codex_home = TempDir::new()?;
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
std::fs::write(
codex_home.path().join("config.toml"),
app_test_support::bundled_model_catalog_config(codex_home.path())?,
)?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.build_initialized()
@@ -175,6 +155,11 @@ async fn thread_start_warns_for_exec_policy_parse_failure_after_initialize() ->
#[tokio::test]
async fn thread_start_does_not_repeat_initialize_exec_policy_warning() -> Result<()> {
let codex_home = TempDir::new()?;
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
std::fs::write(
codex_home.path().join("config.toml"),
app_test_support::bundled_model_catalog_config(codex_home.path())?,
)?;
let rules_dir = codex_home.path().join("rules");
std::fs::create_dir_all(&rules_dir)?;
std::fs::write(rules_dir.join("broken.rules"), "prefix_rule(")?;
@@ -210,103 +195,6 @@ async fn thread_start_does_not_repeat_initialize_exec_policy_warning() -> Result
Ok(())
}
#[tokio::test]
async fn thread_start_provider_model_fallback_uses_bedrock_static_catalog() -> Result<()> {
let codex_home = TempDir::new()?;
std::fs::write(
codex_home.path().join("config.toml"),
r#"model_provider = "amazon-bedrock"
"#,
)?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.build_initialized()
.await?;
let unsupported_with_fallback = start_thread_with_model(
&mut mcp,
"gpt-5.4-mini",
/*allow_provider_model_fallback*/ true,
)
.await?;
for model in [
"openai.gpt-6.1-sol",
"openai.gpt-6.1-terra",
"openai.gpt-6-sol",
"openai.gpt-6-luna",
"openai.gpt-5.6-sol",
] {
let response =
start_thread_with_model(&mut mcp, model, /*allow_provider_model_fallback*/ true)
.await?;
assert_eq!(response.model, model);
}
let supported_with_fallback = start_thread_with_model(
&mut mcp,
"openai.gpt-5.5",
/*allow_provider_model_fallback*/ true,
)
.await?;
let unsupported_without_fallback = start_thread_with_model(
&mut mcp,
"gpt-5.4-mini",
/*allow_provider_model_fallback*/ false,
)
.await?;
assert_eq!(
vec![
unsupported_with_fallback.model,
supported_with_fallback.model,
unsupported_without_fallback.model,
],
vec!["openai.gpt-6.1-sol", "openai.gpt-5.5", "gpt-5.4-mini"]
);
Ok(())
}
#[tokio::test]
async fn thread_start_bedrock_runtime_prefers_global_cross_region_models() -> Result<()> {
let codex_home = TempDir::new()?;
std::fs::write(
codex_home.path().join("config.toml"),
r#"model_provider = "amazon-bedrock-runtime"
"#,
)?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.build_initialized()
.await?;
for model in [
"global.openai.gpt-6.1-sol",
"us.openai.gpt-6.1-sol",
"global.openai.gpt-6.1-terra",
"us.openai.gpt-6.1-terra",
"global.openai.gpt-6-sol",
"us.openai.gpt-6-sol",
"global.openai.gpt-6-luna",
"us.openai.gpt-6-luna",
"global.openai.gpt-5.6-sol",
"us.openai.gpt-5.6-sol",
] {
let response =
start_thread_with_model(&mut mcp, model, /*allow_provider_model_fallback*/ true)
.await?;
assert_eq!(response.model, model);
}
let response = start_thread_with_model(
&mut mcp,
"openai.gpt-5.6-sol",
/*allow_provider_model_fallback*/ true,
)
.await?;
assert_eq!(response.model, "global.openai.gpt-6.1-sol");
Ok(())
}
#[tokio::test]
async fn thread_start_provider_model_fallback_ignores_dynamic_catalog() -> Result<()> {
let server = create_mock_responses_server_repeating_assistant("Done").await;