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:
@@ -312,7 +312,8 @@ trust_level = "trusted"
|
||||
if auth_failure {
|
||||
fs::write(
|
||||
source.join(".codex/config.toml"),
|
||||
"forced_login_method = \"api\"\n",
|
||||
// The stored API key satisfies `api`; require a login method it cannot satisfy.
|
||||
"forced_login_method = \"chatgpt\"\n",
|
||||
)?;
|
||||
git(
|
||||
&source,
|
||||
@@ -330,16 +331,6 @@ trust_level = "trusted"
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
Mock::given(wiremock::matchers::method("GET"))
|
||||
.and(wiremock::matchers::path(
|
||||
"/source/backend-api/wham/config/bundle",
|
||||
))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": { "enterprise_managed": [{ "id": "test", "name": "test",
|
||||
"contents": "developer_instructions = \"managed cloud instructions\"" }] }
|
||||
})))
|
||||
.mount(&server)
|
||||
.await;
|
||||
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
|
||||
let response = app_test_support::create_final_assistant_message_sse_response("done")?;
|
||||
let observed_source = source.clone();
|
||||
@@ -456,7 +447,7 @@ trust_level = "trusted"
|
||||
let bytes = bytes.context("TUI exited before model request")?;
|
||||
let text = String::from_utf8_lossy(&bytes);
|
||||
output.push_str(&text);
|
||||
if auth_failure && output.contains("API key login is required") && output.contains("Do not use --force.") {
|
||||
if auth_failure && output.contains("API key login is not permitted") && output.contains("Do not use --force.") {
|
||||
anyhow::bail!("observed required API login rejection");
|
||||
}
|
||||
let replies = queries.feed(&bytes);
|
||||
@@ -470,7 +461,10 @@ trust_level = "trusted"
|
||||
let exit =
|
||||
tokio::time::timeout(Duration::from_secs(/*secs*/ 10), spawned.exit_rx).await??;
|
||||
assert_ne!(exit, 0);
|
||||
assert!(output.contains("API key login is required"), "{output}");
|
||||
assert!(
|
||||
output.contains("API key login is not permitted"),
|
||||
"{output}"
|
||||
);
|
||||
assert!(!home.join("auth.json").exists());
|
||||
assert!(output.contains("The checkout was kept"), "{output}");
|
||||
continue;
|
||||
@@ -646,7 +640,7 @@ trust_level = "trusted"
|
||||
);
|
||||
}
|
||||
assert_eq!(body["model"], "destination-model");
|
||||
assert!(context.contains("managed cloud instructions"), "{context}");
|
||||
// Managed cloud configuration (ChatGPT config bundles) was removed in aKode.
|
||||
if previous.is_empty() {
|
||||
// A legacy summary still says launcher A, but persisted turns use checkout B.
|
||||
let sqlite = codex_state::SqliteConfig::new_for_testing(
|
||||
@@ -659,26 +653,9 @@ trust_level = "trusted"
|
||||
.execute(&db)
|
||||
.await?;
|
||||
db.close().await;
|
||||
// B inherits trust from its primary repository; no exact trusted entry masks cloud distrust.
|
||||
let home_config = home.join("config.toml");
|
||||
let launcher_config = fs::read_to_string(&home_config)?;
|
||||
fs::write(
|
||||
&home_config,
|
||||
launcher_config.replace(
|
||||
"cli_auth_credentials_store = \"file\"",
|
||||
"cli_auth_credentials_store = \"ephemeral\"",
|
||||
),
|
||||
)?;
|
||||
let cache = home.join("cloud-config-bundle-cache.json");
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
let request_count = server.received_requests().await.context("requests")?.len();
|
||||
Mock::given(wiremock::matchers::path("/source/backend-api/wham/config/bundle"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": {"enterprise_managed": [{"id":"distrust", "name":"distrust",
|
||||
"contents": format!("[projects.{}]\ntrust_level = \"untrusted\"\n", serde_json::to_string(&codex_config::loader::project_trust_key(Path::new(&checkout)))?)}]}
|
||||
}))).with_priority(/*priority*/ 1).mount(&server).await;
|
||||
// B inherits trust from its primary repository; an explicit distrust entry for B
|
||||
// (formerly delivered by a managed cloud bundle, now a config override) still
|
||||
// rejects the fork before any checkout is created.
|
||||
let before = git(&source, &["worktree", "list", "--porcelain"])?;
|
||||
rejected_start(
|
||||
&program,
|
||||
@@ -687,6 +664,13 @@ trust_level = "trusted"
|
||||
"--enable".into(),
|
||||
"worktrees".into(),
|
||||
"--no-alt-screen".into(),
|
||||
"-c".into(),
|
||||
format!(
|
||||
"projects={{{}={{trust_level=\"untrusted\"}}}}",
|
||||
serde_json::to_string(&codex_config::loader::project_trust_key(
|
||||
Path::new(&checkout)
|
||||
))?
|
||||
),
|
||||
"fork".into(),
|
||||
next_owner.clone(),
|
||||
],
|
||||
@@ -695,70 +679,7 @@ trust_level = "trusted"
|
||||
"cannot create a checkout from an explicitly untrusted source",
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
server
|
||||
.received_requests()
|
||||
.await
|
||||
.context("requests")?
|
||||
.iter()
|
||||
.skip(request_count)
|
||||
.any(|request| request.url.path() == "/source/backend-api/wham/config/bundle")
|
||||
);
|
||||
assert_eq!(git(&source, &["worktree", "list", "--porcelain"])?, before);
|
||||
server.reset().await;
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
let count = server.received_requests().await.context("requests")?.len();
|
||||
Mock::given(wiremock::matchers::path("/source/backend-api/wham/config/bundle"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
|
||||
"config_toml": {"enterprise_managed": [{"id":"distrust-source", "name":"distrust-source",
|
||||
"contents": format!("[projects.{}]\ntrust_level = \"untrusted\"\n", serde_json::to_string(&codex_config::loader::project_trust_key(&source.join(".codex")))?)}]}
|
||||
}))).mount(&server).await;
|
||||
let output = rejected_start(
|
||||
&program,
|
||||
&[
|
||||
"--worktree".into(),
|
||||
"--enable".into(),
|
||||
"worktrees".into(),
|
||||
"--no-alt-screen".into(),
|
||||
"--cd".into(),
|
||||
source.join(".codex").display().to_string(),
|
||||
],
|
||||
&launcher,
|
||||
&env,
|
||||
"cannot create a checkout from an explicitly untrusted source",
|
||||
)
|
||||
.await?;
|
||||
let requests = server.received_requests().await.context("requests")?;
|
||||
let paths = requests
|
||||
.iter()
|
||||
.skip(count)
|
||||
.map(|r| r.url.path())
|
||||
.collect::<Vec<_>>();
|
||||
assert!(paths.contains(&"/source/backend-api/wham/config/bundle"));
|
||||
assert!(!paths.contains(&"/v1/responses"));
|
||||
let after = git(&source, &["worktree", "list", "--porcelain"])?;
|
||||
let retained = after
|
||||
.lines()
|
||||
.filter_map(|line| line.strip_prefix("worktree "))
|
||||
.find(|path| {
|
||||
!before
|
||||
.lines()
|
||||
.any(|line| line.strip_prefix("worktree ") == Some(*path))
|
||||
})
|
||||
.context("retained untrusted checkout")?;
|
||||
assert!(output.contains("The checkout was kept"), "{output}");
|
||||
let metadata = git(
|
||||
Path::new(retained),
|
||||
&["rev-parse", "--git-path", "codex-thread.json"],
|
||||
)?;
|
||||
assert!(!Path::new(retained).join(metadata).exists());
|
||||
previous.push(retained.to_owned());
|
||||
fs::write(&home_config, launcher_config)?;
|
||||
if cache.exists() {
|
||||
fs::remove_file(&cache)?;
|
||||
}
|
||||
}
|
||||
previous.push(checkout);
|
||||
owner = Some(next_owner);
|
||||
|
||||
Reference in New Issue
Block a user