Marchio: allineamento fine della rinomina (A)
Le righe che differivano dalla rinomina di aKode solo per codex/akode (header e user agent codex_cli_rs -> akode_cli_rs, nomi di file, testi di test) sono riportate come in aKode 0.9.2; dove la mappa automatica aveva rinominato troppo (stringhe di protocollo, residenza) e' ripristinato il testo originale. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,7 @@ pub use gateway_oauth::GatewayOAuthSettings;
|
||||
pub use oauth_session::OAuthCredentialsStore;
|
||||
pub use oauth_session::OAuthSessionConfig;
|
||||
|
||||
pub const RESIDENCY_HEADER_NAME: &str = "x-openai-internal-akode-residency";
|
||||
pub const RESIDENCY_HEADER_NAME: &str = "x-openai-internal-codex-residency";
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
@@ -97,9 +97,9 @@ pub const NO_MODEL_PROVIDER_CONFIGURED_ERROR: &str = concat!(
|
||||
"Built-in local providers: model_provider = \"ollama\" (http://localhost:11434/v1) ",
|
||||
"or model_provider = \"lmstudio\" (http://localhost:1234/v1).",
|
||||
);
|
||||
const CHAT_WIRE_API_REMOVED_ERROR: &str = "`wire_api = \"chat\"` is no longer supported.\nHow to fix: set `wire_api = \"responses\"` in your provider config.\nMore info: https://github.com/openai/akode/discussions/7782";
|
||||
const CHAT_WIRE_API_REMOVED_ERROR: &str = "`wire_api = \"chat\"` is no longer supported.\nHow to fix: set `wire_api = \"responses\"` in your provider config.\nMore info: https://github.com/openai/codex/discussions/7782";
|
||||
pub const LEGACY_OLLAMA_CHAT_PROVIDER_ID: &str = "ollama-chat";
|
||||
pub const OLLAMA_CHAT_PROVIDER_REMOVED_ERROR: &str = "`ollama-chat` is no longer supported.\nHow to fix: replace `ollama-chat` with `ollama` in `model_provider`, `oss_provider`, or `--local-provider`.\nMore info: https://github.com/openai/akode/discussions/7782";
|
||||
pub const OLLAMA_CHAT_PROVIDER_REMOVED_ERROR: &str = "`ollama-chat` is no longer supported.\nHow to fix: replace `ollama-chat` with `ollama` in `model_provider`, `oss_provider`, or `--local-provider`.\nMore info: https://github.com/openai/codex/discussions/7782";
|
||||
|
||||
/// Wire protocol that the provider speaks.
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, JsonSchema)]
|
||||
|
||||
@@ -87,7 +87,6 @@ base_url = "http://localhost:11434/v1"
|
||||
experimental_bearer_token: None,
|
||||
auth: None,
|
||||
gateway_oauth: None,
|
||||
api_key: None,
|
||||
wire_api: WireApi::Responses,
|
||||
query_params: None,
|
||||
http_headers: None,
|
||||
@@ -100,8 +99,6 @@ base_url = "http://localhost:11434/v1"
|
||||
supports_websockets: false,
|
||||
supports_standalone_web_search: false,
|
||||
capabilities: None,
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
};
|
||||
|
||||
@@ -126,7 +123,6 @@ query_params = { api-version = "2025-04-01-preview" }
|
||||
experimental_bearer_token: None,
|
||||
auth: None,
|
||||
gateway_oauth: None,
|
||||
api_key: None,
|
||||
wire_api: WireApi::Responses,
|
||||
query_params: Some(maplit::hashmap! {
|
||||
"api-version".to_string() => "2025-04-01-preview".into(),
|
||||
@@ -141,8 +137,6 @@ query_params = { api-version = "2025-04-01-preview" }
|
||||
supports_websockets: false,
|
||||
supports_standalone_web_search: false,
|
||||
capabilities: None,
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
};
|
||||
|
||||
@@ -169,7 +163,6 @@ supports_standalone_web_search = true
|
||||
experimental_bearer_token: None,
|
||||
auth: None,
|
||||
gateway_oauth: None,
|
||||
api_key: None,
|
||||
wire_api: WireApi::Responses,
|
||||
query_params: None,
|
||||
http_headers: Some(maplit::hashmap! {
|
||||
@@ -186,8 +179,6 @@ supports_standalone_web_search = true
|
||||
supports_websockets: false,
|
||||
supports_standalone_web_search: true,
|
||||
capabilities: None,
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
};
|
||||
|
||||
@@ -263,7 +254,6 @@ fn test_merge_configured_model_providers_adds_custom_provider() {
|
||||
expected.insert(
|
||||
"custom".to_string(),
|
||||
ModelProviderInfo {
|
||||
keyring_account: Some("model-provider:custom".to_string()),
|
||||
..custom_provider
|
||||
},
|
||||
);
|
||||
@@ -377,100 +367,6 @@ fn no_provider_targets_openai_without_explicit_configuration() {
|
||||
assert!(!error.contains("api.openai.com"), "{error}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_provider_learns_keyring_account_and_default_name() {
|
||||
let configured: ModelProviderInfo = toml::from_str(
|
||||
r#"
|
||||
base_url = "http://192.0.2.10:8080/v1"
|
||||
api_key = "keyring"
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(configured.api_key, Some(ProviderApiKeySource::Keyring));
|
||||
let providers = merge_configured_model_providers(
|
||||
built_in_model_providers(),
|
||||
HashMap::from([("imeai".to_string(), configured)]),
|
||||
)
|
||||
.unwrap();
|
||||
let provider = &providers["imeai"];
|
||||
assert_eq!(provider.name, "imeai");
|
||||
assert_eq!(
|
||||
provider.keyring_account.as_deref(),
|
||||
Some("model-provider:imeai")
|
||||
);
|
||||
// The runtime-only keyring account is never serialized.
|
||||
assert!(
|
||||
!toml::to_string(provider)
|
||||
.unwrap()
|
||||
.contains("model-provider:")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn literal_api_key_is_rejected_without_echoing_it() {
|
||||
// The TOML parser quotes the offending source line in its own errors; the
|
||||
// deserializer message itself must never repeat the value.
|
||||
let error = toml::from_str::<ModelProviderInfo>(
|
||||
r#"
|
||||
base_url = "http://192.0.2.10:8080/v1"
|
||||
api_key = "sk-literal-secret-do-not-log"
|
||||
"#,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(error.message().contains("must be \"keyring\""), "{error}");
|
||||
assert!(
|
||||
!error.message().contains("sk-literal-secret-do-not-log"),
|
||||
"{error}"
|
||||
);
|
||||
let error = ProviderApiKeySource::deserialize(serde::de::value::StrDeserializer::<
|
||||
serde::de::value::Error,
|
||||
>::new("sk-literal-secret-do-not-log"))
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(!error.contains("sk-literal-secret-do-not-log"), "{error}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keyring_api_key_conflicts_with_other_credential_sources() {
|
||||
for extra in [
|
||||
"env_key = \"KEY\"",
|
||||
"experimental_bearer_token = \"token\"",
|
||||
"requires_openai_auth = true",
|
||||
] {
|
||||
let provider: ModelProviderInfo = toml::from_str(&format!(
|
||||
"base_url = \"http://192.0.2.10/v1\"\napi_key = \"keyring\"\n{extra}\n"
|
||||
))
|
||||
.unwrap();
|
||||
let error = provider.validate().unwrap_err();
|
||||
assert!(error.contains("api_key cannot be combined"), "{error}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn use_stored_api_key_is_an_alias_for_requires_openai_auth() {
|
||||
let provider: ModelProviderInfo =
|
||||
toml::from_str("base_url = \"http://192.0.2.10/v1\"\nuse_stored_api_key = true\n").unwrap();
|
||||
assert!(provider.requires_openai_auth);
|
||||
let legacy: ModelProviderInfo =
|
||||
toml::from_str("base_url = \"http://192.0.2.10/v1\"\nrequires_openai_auth = true\n")
|
||||
.unwrap();
|
||||
assert_eq!(provider, legacy);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merge_system_messages_defaults_on() {
|
||||
let provider: ModelProviderInfo =
|
||||
toml::from_str("base_url = \"http://192.0.2.10/v1\"").unwrap();
|
||||
assert!(provider.merge_system_messages());
|
||||
let disabled: ModelProviderInfo =
|
||||
toml::from_str("base_url = \"http://192.0.2.10/v1\"\nmerge_system_messages = false")
|
||||
.unwrap();
|
||||
assert!(!disabled.merge_system_messages());
|
||||
for provider in built_in_model_providers().values() {
|
||||
assert!(provider.merge_system_messages());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_providers_get_a_generous_idle_timeout() {
|
||||
let provider = |base_url: &str| -> ModelProviderInfo {
|
||||
|
||||
Reference in New Issue
Block a user