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:
@@ -24,8 +24,6 @@ const FOCUS_PROBE_INPUT: &str = "focus-palette-24527";
|
||||
|
||||
#[path = "external_editor_tests.rs"]
|
||||
mod external_editor;
|
||||
#[path = "gov_cloud_guidance_tests.rs"]
|
||||
mod gov_cloud_guidance;
|
||||
#[path = "tui_mode_picker_tests.rs"]
|
||||
mod tui_mode_picker;
|
||||
|
||||
@@ -569,11 +567,23 @@ fn contains_bytes(buffer: &[u8], needle: &[u8]) -> bool {
|
||||
|
||||
pub(super) fn write_test_config(codex_home: &Path, repo_root: &Path) -> Result<()> {
|
||||
let repo_root = repo_root.display();
|
||||
// aKode has no built-in catalog provider: give the mock provider the bundled catalog.
|
||||
let catalog_path = codex_home.join("test-models.json");
|
||||
std::fs::write(
|
||||
&catalog_path,
|
||||
serde_json::to_vec(&codex_models_manager::bundled_models_response()?)?,
|
||||
)
|
||||
.context("write focus-test model catalog")?;
|
||||
let catalog_path = catalog_path.display().to_string();
|
||||
let config = format!(
|
||||
"model = \"gpt-5.6-terra\"\nmodel_provider = \"openai\"\n\
|
||||
"model = \"gpt-5.6-terra\"\nmodel_provider = \"mock\"\n\
|
||||
model_catalog_json = {catalog_path:?}\n\
|
||||
suppress_unstable_features_warning = true\n\
|
||||
features.daemon_auto_start = false\n\
|
||||
notice.model_migrations.\"gpt-5.6-terra\" = \"gpt-6-sol\"\n\n\
|
||||
[model_providers.mock]\nname = \"Mock\"\nbase_url = \"http://127.0.0.1:9/v1\"\n\
|
||||
wire_api = \"responses\"\nrequires_openai_auth = true\n\
|
||||
merge_system_messages = false\n\n\
|
||||
[projects.\"{repo_root}\"]\ntrust_level = \"trusted\"\n"
|
||||
);
|
||||
std::fs::write(codex_home.join("config.toml"), config)
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
//! Verify startup acknowledgment, quit without saving, and restart suppression.
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn gov_cloud_startup_persists_only_acknowledgment() -> Result<()> {
|
||||
let cwd = codex_utils_cargo_bin::repo_root()?;
|
||||
let args = [
|
||||
"--no-daemon",
|
||||
"-c",
|
||||
"features.api_key_model_discovery=false",
|
||||
];
|
||||
for action in ["quit", "acknowledge"] {
|
||||
let home = tempfile::tempdir()?;
|
||||
write_test_config(home.path(), &cwd)?;
|
||||
let path = home.path().join("config.toml");
|
||||
let config = std::fs::read_to_string(&path)?.replace(
|
||||
"model_provider = \"openai\"",
|
||||
"model_provider = \"amazon-bedrock\"",
|
||||
);
|
||||
let config = format!(
|
||||
"{config}\n[model_providers.amazon-bedrock]\nbase_url = 'https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1'\n"
|
||||
);
|
||||
std::fs::write(&path, &config)?;
|
||||
let mut terminal = PtyCodex::start(&cwd, home, &args)?;
|
||||
terminal.wait_for_screen("Using aKode with AWS GovCloud")?;
|
||||
let original = std::fs::read_to_string(&path)?;
|
||||
let deadline = Instant::now() + STARTUP_TIMEOUT;
|
||||
loop {
|
||||
// Startup drains pending keys after drawing the guidance; retry until it handles one.
|
||||
terminal.write_input(if action == "quit" { b"q" } else { b"\r" })?;
|
||||
terminal.read_output(Duration::from_millis(/*millis*/ 50))?;
|
||||
if action == "quit" {
|
||||
if let Some(status) = terminal.child.try_wait()? {
|
||||
ensure!(status.success(), "quit exited with {status}");
|
||||
break;
|
||||
}
|
||||
} else if terminal.screen_contains("aKode v") {
|
||||
break;
|
||||
}
|
||||
ensure!(Instant::now() < deadline, "{action} did not complete");
|
||||
}
|
||||
let saved = std::fs::read_to_string(&path)?;
|
||||
if action == "acknowledge" {
|
||||
let config: toml::Value = toml::from_str(&saved)?;
|
||||
assert_eq!(
|
||||
config["notice"]["hide_gov_cloud_guidance"].as_bool(),
|
||||
Some(true)
|
||||
);
|
||||
let home = std::mem::replace(&mut terminal._codex_home, tempfile::tempdir()?);
|
||||
drop(terminal);
|
||||
let mut restarted = PtyCodex::start(&cwd, home, &args)?;
|
||||
// The startup draft says "loading"; the actual model appears after guidance.
|
||||
restarted.wait_for_screen("gpt-5.6-terra")?;
|
||||
assert!(!restarted.screen_contains("Using aKode with AWS GovCloud"));
|
||||
} else {
|
||||
assert_eq!(saved, original);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -33,7 +33,7 @@ async fn resume_lists_all_providers_and_fork_keeps_provider_filter() -> Result<(
|
||||
),
|
||||
)?;
|
||||
for (hour, provider, preview) in [
|
||||
("10", "openai", "Client provider history"),
|
||||
("10", "mock", "Client provider history"),
|
||||
("11", "server-provider", "Server provider history"),
|
||||
] {
|
||||
create_fake_rollout(
|
||||
@@ -89,14 +89,14 @@ async fn resume_lists_all_providers_and_fork_keeps_provider_filter() -> Result<(
|
||||
"--remote",
|
||||
remote_endpoint.as_str(),
|
||||
"-c",
|
||||
"model_provider=\"openai\"",
|
||||
"model_provider=\"mock\"",
|
||||
]);
|
||||
}
|
||||
let case = format!("{action}: embedded={embedded}, last={last}, explicit={explicit}");
|
||||
let mut terminal = PtyCodex::start_cli(&cwd, home, &args)?;
|
||||
if action == "resume" && last && explicit {
|
||||
// --last finds the newest thread across providers. An explicit override
|
||||
// cannot switch that thread from server-provider to openai.
|
||||
// cannot switch that thread from server-provider to mock.
|
||||
terminal
|
||||
.wait_for_screen("Cannot change this thread's model provider")
|
||||
.with_context(|| format!("{case}; screen:\n{}", terminal.screen_contents()))?;
|
||||
@@ -158,15 +158,12 @@ async fn selected_gateway_authenticates_before_its_first_chat() -> Result<()> {
|
||||
&profile,
|
||||
format!(
|
||||
r#"
|
||||
model_provider = "openai"
|
||||
model_provider = "office"
|
||||
model = "gpt-5.1"
|
||||
forced_login_method = "api"
|
||||
cli_auth_credentials_store = "file"
|
||||
suppress_unstable_features_warning = true
|
||||
[features]
|
||||
gateway_setup_wizard = true
|
||||
bedrock_setup_wizard = false
|
||||
gcp_setup_wizard = false
|
||||
api_key_model_discovery = false
|
||||
[projects.{trusted}]
|
||||
trust_level = "trusted"
|
||||
@@ -184,23 +181,23 @@ requires_openai_auth = true
|
||||
home,
|
||||
&["--profile", "work", "--no-daemon", "verify the gateway"],
|
||||
)?;
|
||||
// aKode has no default provider, so the gateway is already selected; its sign-in must
|
||||
// finish before the first chat request.
|
||||
terminal
|
||||
.wait_for_screen("Use a custom provider or gateway")
|
||||
.wait_for_screen("Connect an API key to use aKode")
|
||||
.with_context(|| terminal.screen_contents())?;
|
||||
// Startup drains input after its first draw. Retry the navigation until it is accepted.
|
||||
// Startup drains input after its first draw. Retry until the API key entry opens. Pick the
|
||||
// option by number: Enter would arm the activation guard and swallow the save below.
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(/*secs*/ 30);
|
||||
while !terminal.screen_contains("> 2. Use a custom provider or gateway") {
|
||||
while !terminal.screen_contains("Paste or type your API key") {
|
||||
ensure!(
|
||||
std::time::Instant::now() < deadline,
|
||||
"gateway option was not highlighted: {}",
|
||||
"API key entry did not open: {}",
|
||||
terminal.screen_contents()
|
||||
);
|
||||
terminal.write_input(b"\x1b[B")?;
|
||||
terminal.write_input(b"1")?;
|
||||
terminal.read_output(Duration::from_millis(/*millis*/ 50))?;
|
||||
}
|
||||
terminal.write_input(b"\r")?;
|
||||
terminal.wait_for_screen("Office gateway")?;
|
||||
terminal.write_input(b"\x1b[H\r")?;
|
||||
terminal.wait_for_screen("Paste or type your API key")?;
|
||||
let deadline = std::time::Instant::now() + Duration::from_secs(/*secs*/ 30);
|
||||
while !auth.is_file() && terminal.screen_contains("Paste or type your API key") {
|
||||
|
||||
@@ -62,7 +62,7 @@ async fn picker_side_worktree_fork_and_cd_run_on_the_production_stack() -> Resul
|
||||
let server = responses::start_mock_server().await;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
let config = fs::read_to_string(&config_path)?
|
||||
.replace("model_provider = \"openai\"", "model_provider = \"test\"");
|
||||
.replace("model_provider = \"mock\"", "model_provider = \"test\"");
|
||||
fs::write(
|
||||
&config_path,
|
||||
format!(
|
||||
|
||||
Reference in New Issue
Block a user