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:
@@ -1116,8 +1116,7 @@ fn codex_path_entries() -> Vec<String> {
|
||||
|
||||
fn config_check(config: &Config) -> DoctorCheck {
|
||||
let mut details = Vec::new();
|
||||
details
|
||||
.push("configuration scope: invocation config, including managed policy".to_string());
|
||||
details.push("configuration scope: invocation config, including managed policy".to_string());
|
||||
details.push("active thread overrides: not inspected".to_string());
|
||||
details.push(format!("CODEX_HOME: {}", config.codex_home.display()));
|
||||
details.push(format!("cwd: {}", config.cwd.display()));
|
||||
@@ -1240,6 +1239,9 @@ fn auth_check(config: &Config) -> DoctorCheck {
|
||||
env_auth_vars.join(", ")
|
||||
));
|
||||
}
|
||||
if let Some(check) = provider_keyring_auth_check(config, details.clone()) {
|
||||
return check;
|
||||
}
|
||||
if let Some(check) = provider_specific_auth_check(
|
||||
config.model_provider.requires_openai_auth,
|
||||
config.model_provider.env_key.as_deref(),
|
||||
@@ -1319,6 +1321,55 @@ fn auth_check(config: &Config) -> DoctorCheck {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reports where an `api_key = "keyring"` provider key is stored, never the key itself.
|
||||
fn provider_keyring_auth_check(config: &Config, mut details: Vec<String>) -> Option<DoctorCheck> {
|
||||
if config.model_provider.api_key
|
||||
!= Some(codex_model_provider_info::ProviderApiKeySource::Keyring)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let id = config.model_provider_id.as_str();
|
||||
details.push(format!(
|
||||
"provider API key store: {:?}",
|
||||
config.provider_api_key_store_mode
|
||||
));
|
||||
Some(
|
||||
match codex_model_provider_info::locate_provider_api_key(id) {
|
||||
Ok(Some(location)) => {
|
||||
details.push(format!("provider API key: stored in {location}"));
|
||||
DoctorCheck::new(
|
||||
"auth.credentials",
|
||||
"auth",
|
||||
CheckStatus::Ok,
|
||||
"the active model provider's API key is stored",
|
||||
)
|
||||
.details(details)
|
||||
}
|
||||
Ok(None) => DoctorCheck::new(
|
||||
"auth.credentials",
|
||||
"auth",
|
||||
CheckStatus::Fail,
|
||||
"no API key is stored for the active model provider",
|
||||
)
|
||||
.details(details)
|
||||
.remediation(format!(
|
||||
"Run: codex login --provider {id} --with-api-key (reads the key from stdin)."
|
||||
)),
|
||||
Err(error) => DoctorCheck::new(
|
||||
"auth.credentials",
|
||||
"auth",
|
||||
CheckStatus::Fail,
|
||||
"the provider API key store cannot be read",
|
||||
)
|
||||
.details({
|
||||
details.push(format!("error: {error}"));
|
||||
details
|
||||
})
|
||||
.remediation("Unlock the system keyring or set provider_api_key_store = \"file\"."),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn provider_specific_auth_check(
|
||||
requires_openai_auth: bool,
|
||||
provider_env_key: Option<&str>,
|
||||
@@ -1327,7 +1378,7 @@ fn provider_specific_auth_check(
|
||||
env_var_present: impl Fn(&str) -> bool,
|
||||
) -> Option<DoctorCheck> {
|
||||
details.push(format!(
|
||||
"model provider requires OpenAI auth: {requires_openai_auth}"
|
||||
"model provider uses the stored API key: {requires_openai_auth}"
|
||||
));
|
||||
if requires_openai_auth {
|
||||
return None;
|
||||
@@ -1367,7 +1418,7 @@ fn provider_specific_auth_check(
|
||||
"auth.credentials",
|
||||
"auth",
|
||||
CheckStatus::Ok,
|
||||
"OpenAI auth is not required for the active model provider",
|
||||
"the stored API key is not used by the active model provider",
|
||||
)
|
||||
.details(details),
|
||||
),
|
||||
@@ -1378,8 +1429,6 @@ fn stored_auth_mode(auth: &codex_login::AuthDotJson) -> &'static str {
|
||||
match stored_auth_mode_value(auth) {
|
||||
Some(AuthMode::ApiKey) => "api_key",
|
||||
Some(AuthMode::Headers) => "headers",
|
||||
Some(AuthMode::BedrockApiKey) => "bedrock_api_key",
|
||||
Some(AuthMode::BedrockAccessKeys) => "bedrock_access_keys",
|
||||
None => "unsupported",
|
||||
}
|
||||
}
|
||||
@@ -1389,11 +1438,7 @@ fn stored_auth_mode_value(auth: &AuthDotJson) -> Option<AuthMode> {
|
||||
if let Some(mode) = auth.auth_mode {
|
||||
return Some(mode);
|
||||
}
|
||||
if auth.bedrock_api_key.is_some() {
|
||||
Some(AuthMode::BedrockApiKey)
|
||||
} else if auth.bedrock_access_keys.is_some() {
|
||||
Some(AuthMode::BedrockAccessKeys)
|
||||
} else if auth.openai_api_key.is_some() {
|
||||
if auth.openai_api_key.is_some() {
|
||||
Some(AuthMode::ApiKey)
|
||||
} else {
|
||||
None
|
||||
@@ -1426,22 +1471,6 @@ fn stored_auth_issues(
|
||||
AuthMode::Headers => {
|
||||
issues.push("header auth cannot be loaded from auth storage");
|
||||
}
|
||||
AuthMode::BedrockApiKey => {
|
||||
if auth.bedrock_api_key.is_none() {
|
||||
issues.push("Bedrock API key auth is missing a Bedrock API key");
|
||||
}
|
||||
}
|
||||
AuthMode::BedrockAccessKeys => match auth.bedrock_access_keys.as_ref() {
|
||||
Some(access_keys) => {
|
||||
if access_keys.access_key_id.trim().is_empty() {
|
||||
issues.push("Bedrock access key auth is missing an access key ID");
|
||||
}
|
||||
if access_keys.secret_access_key.trim().is_empty() {
|
||||
issues.push("Bedrock access key auth is missing a secret access key");
|
||||
}
|
||||
}
|
||||
None => issues.push("Bedrock access key auth is missing AWS access keys"),
|
||||
},
|
||||
}
|
||||
issues
|
||||
}
|
||||
@@ -2493,8 +2522,6 @@ fn auth_mode_name(auth: &CodexAuth) -> &'static str {
|
||||
match auth.auth_mode() {
|
||||
AuthMode::ApiKey => "api_key",
|
||||
AuthMode::Headers => "headers",
|
||||
AuthMode::BedrockApiKey => "bedrock_api_key",
|
||||
AuthMode::BedrockAccessKeys => "bedrock_access_keys",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2602,7 +2629,6 @@ fn provider_reachability_plan(config: &Config) -> ReachabilityPlan {
|
||||
&config.model_provider.name,
|
||||
config.model_provider.base_url.as_deref(),
|
||||
query_params.as_ref(),
|
||||
config.model_provider.is_amazon_bedrock(),
|
||||
);
|
||||
plan.http_client_factory = config.http_client_factory();
|
||||
plan
|
||||
@@ -2616,7 +2642,6 @@ fn default_reachability_plan() -> ReachabilityPlan {
|
||||
"unknown",
|
||||
/*provider_base_url*/ None,
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2638,9 +2663,7 @@ fn provider_auth_reachability_mode_from_auth(
|
||||
return ProviderAuthReachabilityMode::ApiKey;
|
||||
}
|
||||
match stored_auth.and_then(stored_auth_mode_value) {
|
||||
Some(AuthMode::ApiKey | AuthMode::BedrockApiKey | AuthMode::BedrockAccessKeys) => {
|
||||
ProviderAuthReachabilityMode::ApiKey
|
||||
}
|
||||
Some(AuthMode::ApiKey) => ProviderAuthReachabilityMode::ApiKey,
|
||||
Some(AuthMode::Headers) | None => ProviderAuthReachabilityMode::NotRequired,
|
||||
}
|
||||
}
|
||||
@@ -2651,7 +2674,6 @@ fn provider_reachability_plan_from_parts(
|
||||
provider_name: &str,
|
||||
provider_base_url: Option<&str>,
|
||||
provider_query_params: Option<&HashMap<String, String>>,
|
||||
is_amazon_bedrock: bool,
|
||||
) -> ReachabilityPlan {
|
||||
// aKode: only an explicitly configured base URL outside OpenAI/ChatGPT is probed. The
|
||||
// implicit chatgpt.com and api.openai.com endpoints are never contacted.
|
||||
@@ -2661,7 +2683,7 @@ fn provider_reachability_plan_from_parts(
|
||||
label: format!("{provider_id} API"),
|
||||
url: provider_url_for_path(base_url, "responses", provider_query_params),
|
||||
required: true,
|
||||
route_probe_url: should_probe_models_route(provider_name, base_url, is_amazon_bedrock)
|
||||
route_probe_url: should_probe_models_route(provider_name, base_url)
|
||||
.then(|| provider_url_for_path(base_url, "models", provider_query_params)),
|
||||
})
|
||||
.into_iter()
|
||||
@@ -2673,8 +2695,8 @@ fn provider_reachability_plan_from_parts(
|
||||
}
|
||||
}
|
||||
|
||||
fn should_probe_models_route(provider_name: &str, base_url: &str, is_amazon_bedrock: bool) -> bool {
|
||||
!is_amazon_bedrock && !is_azure_responses_provider(provider_name, Some(base_url))
|
||||
fn should_probe_models_route(provider_name: &str, base_url: &str) -> bool {
|
||||
!is_azure_responses_provider(provider_name, Some(base_url))
|
||||
}
|
||||
|
||||
fn provider_url_for_path(
|
||||
@@ -3656,7 +3678,7 @@ mod tests {
|
||||
assert_eq!(check.status, CheckStatus::Ok);
|
||||
assert_eq!(
|
||||
check.summary,
|
||||
"OpenAI auth is not required for the active model provider"
|
||||
"the stored API key is not used by the active model provider"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3687,8 +3709,6 @@ mod tests {
|
||||
let auth = AuthDotJson {
|
||||
auth_mode: Some(AuthMode::ApiKey),
|
||||
openai_api_key: None,
|
||||
bedrock_api_key: None,
|
||||
bedrock_access_keys: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
@@ -3721,8 +3741,6 @@ mod tests {
|
||||
let api_key_auth = AuthDotJson {
|
||||
auth_mode: Some(AuthMode::ApiKey),
|
||||
openai_api_key: Some("sk-test".to_string()),
|
||||
bedrock_api_key: None,
|
||||
bedrock_access_keys: None,
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
@@ -3792,7 +3810,6 @@ mod tests {
|
||||
"azure",
|
||||
Some("https://example.openai.azure.com/openai/v1"),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
),
|
||||
ReachabilityPlan {
|
||||
description: "provider auth".to_string(),
|
||||
@@ -3822,7 +3839,6 @@ mod tests {
|
||||
"Custom",
|
||||
Some("https://example.com/openai/v1/"),
|
||||
Some(&query_params),
|
||||
/*is_amazon_bedrock*/ false,
|
||||
),
|
||||
ReachabilityPlan {
|
||||
description: description.to_string(),
|
||||
@@ -3844,20 +3860,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_reachability_skips_route_probe_for_bedrock() {
|
||||
let plan = provider_reachability_plan_from_parts(
|
||||
ProviderAuthReachabilityMode::NotRequired,
|
||||
"amazon-bedrock",
|
||||
"Amazon Bedrock",
|
||||
Some("https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1"),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ true,
|
||||
);
|
||||
|
||||
assert_eq!(plan.endpoints[0].route_probe_url, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_reachability_never_infers_openai_endpoints() {
|
||||
let plan = provider_reachability_plan_from_parts(
|
||||
@@ -3866,7 +3868,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
/*provider_base_url*/ None,
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
assert_eq!(plan.endpoints, Vec::new());
|
||||
|
||||
@@ -3880,7 +3881,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(base_url),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
assert_eq!(plan.endpoints, Vec::new(), "{base_url}");
|
||||
}
|
||||
@@ -3929,7 +3929,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(&format!("http://{addr}/xxxx")),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
|
||||
let check = provider_reachability_check(plan).await;
|
||||
@@ -3969,7 +3968,6 @@ mod tests {
|
||||
"OpenAI",
|
||||
Some(&format!("http://{addr}/v1")),
|
||||
/*provider_query_params*/ None,
|
||||
/*is_amazon_bedrock*/ false,
|
||||
);
|
||||
|
||||
let check = provider_reachability_check(plan).await;
|
||||
|
||||
Reference in New Issue
Block a user