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

@@ -3,7 +3,6 @@ use std::time::Duration;
use anyhow::Error;
use anyhow::Result;
use app_test_support::TestAppServer;
use app_test_support::write_models_cache;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::ExperimentalFeatureEnablementSetParams;
use codex_app_server_protocol::ExperimentalFeatureEnablementSetResponse;
@@ -165,7 +164,9 @@ requires_openai_auth = true
// prevents bundled models from being advertised for this provider.
&[]
} else {
&bundled
// aKode: without `model_catalog_url` the provider's OpenAI-format `GET /models`
// listing is the source (no bundled catalog); this codex-format body lists nothing.
&[]
};
assert_eq!(
response,
@@ -174,8 +175,20 @@ requires_openai_auth = true
next_cursor: None,
}
);
let _ = bundled;
if !catalog_opt_in {
// aKode: providers without a catalog URL list their models from `GET /models`.
assert!(
server
.received_requests()
.await
.expect("request recording is enabled")
.iter()
.any(|request| request.url.path() == "/v1/models")
);
}
// Only startup opt-outs prevent fetches before the app sends its enablement.
if user_enablement == Some(false) || !catalog_opt_in {
if user_enablement == Some(false) {
assert!(
server
.received_requests()
@@ -235,6 +248,15 @@ fn model_from_preset(preset: &ModelPreset) -> Model {
}
}
/// aKode: providers without `model_catalog_url` no longer fall back to the bundled
/// catalog (or read `models_cache.json`), so the listing tests configure it explicitly.
fn write_bundled_model_catalog_config(codex_home: &std::path::Path) -> std::io::Result<()> {
std::fs::write(
codex_home.join("config.toml"),
app_test_support::bundled_model_catalog_config(codex_home)?,
)
}
fn expected_visible_models() -> Vec<Model> {
// Filter by supported_in_api to support testing with both ChatGPT and non-ChatGPT auth modes.
let mut presets = ModelPreset::filter_by_auth(
@@ -255,7 +277,7 @@ fn expected_visible_models() -> Vec<Model> {
#[tokio::test]
async fn list_models_returns_all_models_with_large_limit() -> Result<()> {
let codex_home = TempDir::new()?;
write_models_cache(codex_home.path()).await?;
write_bundled_model_catalog_config(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.without_auto_env()
@@ -286,7 +308,7 @@ async fn list_models_returns_all_models_with_large_limit() -> Result<()> {
#[tokio::test]
async fn list_models_includes_hidden_models() -> Result<()> {
let codex_home = TempDir::new()?;
write_models_cache(codex_home.path()).await?;
write_bundled_model_catalog_config(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.without_auto_env()
@@ -471,7 +493,7 @@ model_catalog_url = "{server_uri}/v1/models"
#[tokio::test]
async fn list_models_pagination_works() -> Result<()> {
let codex_home = TempDir::new()?;
write_models_cache(codex_home.path()).await?;
write_bundled_model_catalog_config(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.without_auto_env()
@@ -518,7 +540,7 @@ async fn list_models_pagination_works() -> Result<()> {
#[tokio::test]
async fn list_models_rejects_invalid_cursor() -> Result<()> {
let codex_home = TempDir::new()?;
write_models_cache(codex_home.path()).await?;
write_bundled_model_catalog_config(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.without_auto_env()