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:
@@ -1,4 +1,3 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_api::AuthError;
|
||||
@@ -9,14 +8,10 @@ use codex_login::AuthHeaders;
|
||||
use codex_login::AuthManager;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_model_provider_info::ModelProviderInfo;
|
||||
use codex_protocol::error::CodexErr;
|
||||
use http::HeaderMap;
|
||||
|
||||
use crate::bearer_auth_provider::BearerAuthProvider;
|
||||
|
||||
const BEDROCK_API_KEY_UNSUPPORTED_MESSAGE: &str =
|
||||
"Bedrock API key auth is only supported by the Amazon Bedrock model provider";
|
||||
|
||||
/// Credential ownership for one harness/thread context.
|
||||
/// Publish this so auxiliary clients cannot select another thread's credentials.
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -170,24 +165,11 @@ pub(crate) fn auth_manager_for_provider(
|
||||
provider: &ModelProviderInfo,
|
||||
) -> Option<Arc<AuthManager>> {
|
||||
match provider.auth.clone() {
|
||||
Some(config) => {
|
||||
if provider.is_gcp() {
|
||||
let mut env = HashMap::new();
|
||||
if let Some(credential_file) = &provider.credential_file {
|
||||
env.insert(
|
||||
"GOOGLE_APPLICATION_CREDENTIALS".to_string(),
|
||||
credential_file.as_os_str().to_os_string(),
|
||||
);
|
||||
}
|
||||
Some(AuthManager::external_bearer_only_with_env(config, env))
|
||||
} else {
|
||||
Some(match auth_manager {
|
||||
Some(manager) => crate::shared_state::process_shared_state()
|
||||
.command_credentials(&config, &manager.runtime_config()),
|
||||
None => AuthManager::external_bearer_only(config),
|
||||
})
|
||||
}
|
||||
}
|
||||
Some(config) => Some(match auth_manager {
|
||||
Some(manager) => crate::shared_state::process_shared_state()
|
||||
.command_credentials(&config, &manager.runtime_config()),
|
||||
None => AuthManager::external_bearer_only(config),
|
||||
}),
|
||||
None => auth_manager,
|
||||
}
|
||||
}
|
||||
@@ -204,15 +186,6 @@ pub(crate) fn resolve_provider_auth(
|
||||
return Ok(unauthenticated_auth_provider());
|
||||
}
|
||||
|
||||
if matches!(
|
||||
auth,
|
||||
Some(CodexAuth::BedrockApiKey(_) | CodexAuth::BedrockAccessKeys(_))
|
||||
) {
|
||||
return Err(CodexErr::UnsupportedOperation(
|
||||
BEDROCK_API_KEY_UNSUPPORTED_MESSAGE.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(match auth {
|
||||
Some(auth) => auth_provider_from_auth(auth),
|
||||
None => unauthenticated_auth_provider(),
|
||||
@@ -233,23 +206,6 @@ pub(crate) fn bearer_auth_for_provider(
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
/// Whether the selected API key enables OpenAI's default FedRAMP endpoints.
|
||||
/// Command-backed providers retain their configured routing across token refreshes.
|
||||
pub(crate) fn uses_fedramp_api_key(
|
||||
auth: Option<&CodexAuth>,
|
||||
provider: &ModelProviderInfo,
|
||||
) -> codex_protocol::error::Result<bool> {
|
||||
if !provider.is_openai() || provider.has_command_auth() {
|
||||
return Ok(false);
|
||||
}
|
||||
if let Some(auth) = bearer_auth_for_provider(provider)? {
|
||||
return Ok(auth.is_fedramp_account);
|
||||
}
|
||||
Ok(provider.requires_openai_auth
|
||||
&& matches!(auth, Some(CodexAuth::ApiKey(_)))
|
||||
&& auth.is_some_and(CodexAuth::is_fedramp_account))
|
||||
}
|
||||
|
||||
/// Builds request auth for an already selected credential.
|
||||
pub fn auth_provider_for_request(auth: &CodexAuth) -> ResolvedProviderAuth {
|
||||
let mut resolved = ResolvedProviderAuth::new(auth_provider_from_auth(auth));
|
||||
@@ -261,12 +217,8 @@ pub fn auth_provider_for_request(auth: &CodexAuth) -> ResolvedProviderAuth {
|
||||
pub fn auth_provider_from_auth(auth: &CodexAuth) -> SharedAuthProvider {
|
||||
match auth {
|
||||
CodexAuth::Headers(auth) => Arc::new(HeaderAuthProvider { auth: auth.clone() }),
|
||||
CodexAuth::BedrockApiKey(_) | CodexAuth::BedrockAccessKeys(_) => {
|
||||
unreachable!("{BEDROCK_API_KEY_UNSUPPORTED_MESSAGE}")
|
||||
}
|
||||
CodexAuth::ApiKey(_) => Arc::new(BearerAuthProvider {
|
||||
token: auth.get_token().ok(),
|
||||
is_fedramp_account: auth.is_fedramp_account(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user