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

@@ -473,13 +473,11 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
.find(|item| item["type"] == "function_call_output" && item["call_id"] == "mcp-call")
.context("follow-up tool output")?;
assert!(serde_json::to_string(&output["output"])?.contains("Calendar result"));
// aKode: internal metadata passthrough is stripped from model requests unless the
// provider holds the runtime-only `include_internal_metadata` grant.
assert_eq!(
output["internal_chat_message_metadata_passthrough"]["executed_tool_calls"],
json!([{"name": DIRECT_CALENDAR_LIST_EVENTS_TOOL, "arguments": arguments}]),
);
assert_eq!(
output["internal_chat_message_metadata_passthrough"]["tool_calls_complete"],
true,
output.get("internal_chat_message_metadata_passthrough"),
None
);
let raw_output = &raw_params["item"];
@@ -488,10 +486,10 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
let public_metadata = raw_output["internal_chat_message_metadata_passthrough"]
.as_object()
.context("public passthrough metadata")?;
assert_eq!(
public_metadata.get("turn_id").context("public turn id")?,
&output["internal_chat_message_metadata_passthrough"]["turn_id"],
);
let public_turn_id = public_metadata
.get("turn_id")
.context("public turn id")?
.clone();
for field in ["executed_tool_calls", "tool_calls_complete", "cell_id"] {
assert!(
public_metadata.get(field).is_none(),
@@ -514,6 +512,14 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
.find(|item| item["type"] == "function_call_output" && item["call_id"] == "mcp-call")
.context("persisted MCP output")?;
assert_eq!(captured["output"], raw_output["output"]);
assert_eq!(
captured["internal_chat_message_metadata_passthrough"]["turn_id"],
public_turn_id
);
assert_eq!(
captured["internal_chat_message_metadata_passthrough"]["executed_tool_calls"][0]["name"],
json!(DIRECT_CALENDAR_LIST_EVENTS_TOOL),
);
// Raw MCP result metadata is never recorded, not even in the local rollout.
assert_eq!(
captured["internal_chat_message_metadata_passthrough"]["executed_tool_calls"][0]
@@ -644,7 +650,10 @@ async fn turn_start_steers_active_turn_and_returns_active_turn_id() -> Result<()
std::fs::write(
codex_home.path().join("config.toml"),
format!(
"model = \"gpt-5.5\"\napproval_policy = \"never\"\nopenai_base_url = \"{}/v1\"\ncli_auth_credentials_store = \"file\"\n[features]\nenable_request_compression = false\n",
// aKode: `openai_base_url` no longer configures a built-in provider; declare an
// equivalent `openai` provider explicitly, with an explicit model catalog.
"{}model = \"gpt-5.5\"\napproval_policy = \"never\"\nmodel_provider = \"openai\"\ncli_auth_credentials_store = \"file\"\n[features]\nenable_request_compression = false\n[model_providers.openai]\nname = \"OpenAI\"\nbase_url = \"{}/v1\"\nwire_api = \"responses\"\nrequires_openai_auth = true\nsupports_websockets = false\nmerge_system_messages = false\n",
app_test_support::bundled_model_catalog_config(codex_home.path())?,
server.uri()
),
)?;
@@ -1085,7 +1094,12 @@ async fn turn_start_emits_thread_scoped_warning_notification_for_trimmed_skills(
.expect("model slug should be present")
.to_string();
entry["context_window"] = serde_json::Value::from(100);
std::fs::write(&cache_path, serde_json::to_string_pretty(&cache)?)?;
// aKode: cached models are served through the explicit test catalog.
write_models_cache_with_models(
codex_home.path(),
serde_json::from_value(cache["models"].clone())?,
)
.await?;
let config_path = codex_home.path().join("config.toml");
let config = std::fs::read_to_string(&config_path)?;
std::fs::write(
@@ -1125,9 +1139,10 @@ async fn turn_start_emits_thread_scoped_warning_notification_for_trimmed_skills(
let warning: WarningNotification =
timeout(DEFAULT_READ_TIMEOUT, mcp.read_notification("warning")).await??;
assert_eq!(warning.thread_id.as_deref(), Some(thread.id.as_str()));
// aKode: the bundled `openai-docs` system skill was removed, so one fewer skill is trimmed.
assert_eq!(
warning.message,
"Exceeded skills context budget. All skill descriptions were removed and 5 additional skills were not included in the model-visible skills list."
"Exceeded skills context budget. All skill descriptions were removed and 4 additional skills were not included in the model-visible skills list."
);
timeout(
@@ -3270,13 +3285,14 @@ model = "mock-model"
approval_policy = "never"
default_permissions = "dev"
model_provider = "mock_provider"
{catalog}
[model_providers.mock_provider]
name = "Mock provider for test"
base_url = "{server_uri}/v1"
wire_api = "responses"
request_max_retries = 0
stream_max_retries = 0
merge_system_messages = false
# This test only exercises writable workspace roots; the Windows restricted-token
# sandbox cannot enforce a filesystem policy without root read access.
@@ -3285,7 +3301,9 @@ stream_max_retries = 0
[permissions.dev.filesystem.":workspace_roots"]
"." = "write"
"#
"#,
// aKode: explicit catalog (no bundled default) and upstream message layout.
catalog = app_test_support::bundled_model_catalog_config(&codex_home)?
),
)?;
@@ -3868,7 +3886,12 @@ async fn turn_start_streams_apply_patch_change_updates_v2() -> Result<()> {
model["slug"] = serde_json::Value::from("mock-model");
model["display_name"] = serde_json::Value::from("mock-model");
model["apply_patch_tool_type"] = serde_json::Value::from("freeform");
std::fs::write(&cache_path, serde_json::to_string_pretty(&cache)?)?;
// aKode: cached models are served through the explicit test catalog.
write_models_cache_with_models(
&codex_home,
serde_json::from_value(cache["models"].clone())?,
)
.await?;
let mut mcp = TestAppServer::builder()
.with_codex_home(&codex_home)