Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
148
akode-rs/app-server-protocol/src/protocol/v2/model_provider.rs
Normal file
148
akode-rs/app-server-protocol/src/protocol/v2/model_provider.rs
Normal file
@@ -0,0 +1,148 @@
|
||||
//! Safe provider discovery and field patches for custom provider configuration.
|
||||
|
||||
use crate::JsonSchema;
|
||||
use crate::TS;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ModelProviderListParams {}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ModelProviderListResponse {
|
||||
pub data: Vec<ModelProviderSummary>,
|
||||
pub default_provider_id: String,
|
||||
pub can_change_default: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ModelProviderSummary {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
/// Whether a supported configuration field can be edited in the active user layer.
|
||||
pub can_edit: bool,
|
||||
/// Null when the endpoint is absent or cannot be safely displayed.
|
||||
pub base_url: Option<String>,
|
||||
pub settings: ProviderSettings,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for ModelProviderSummary {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("ModelProviderSummary")
|
||||
.field("id", &self.id)
|
||||
.field("name", &self.name)
|
||||
.field("can_edit", &self.can_edit)
|
||||
.field("base_url", &"[REDACTED]")
|
||||
.field("settings", &self.settings)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(tag = "type", rename_all = "camelCase")]
|
||||
#[ts(tag = "type", rename_all = "camelCase", export_to = "v2/")]
|
||||
pub enum ProviderSettings {
|
||||
CustomGateway { auth: GatewayAuth },
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(tag = "mode", rename_all = "camelCase")]
|
||||
#[ts(tag = "mode", rename_all = "camelCase", export_to = "v2/")]
|
||||
pub enum GatewayAuth {
|
||||
None,
|
||||
EnvironmentVariable {
|
||||
#[serde(rename = "envKey")]
|
||||
#[ts(rename = "envKey")]
|
||||
env_key: String,
|
||||
},
|
||||
/// Authentication is configured outside the gateway form. Preserve it on edits.
|
||||
ExternallyConfigured {
|
||||
#[serde(rename = "envKey")]
|
||||
#[ts(rename = "envKey")]
|
||||
env_key: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Omitted patch fields preserve their values. Explicit null clears a nullable field.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(tag = "type", rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(tag = "type", rename_all = "camelCase", export_to = "v2/")]
|
||||
pub enum ProviderSettingsPatch {
|
||||
CustomGateway(CustomGatewaySettingsParams),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct CustomGatewaySettingsParams {
|
||||
/// Omit or pass null to allocate a new custom provider ID.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub provider_id: Option<String>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_patch_name",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[schemars(with = "String", skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub name: Option<String>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "crate::protocol::serde_helpers::deserialize_double_option",
|
||||
serialize_with = "crate::protocol::serde_helpers::serialize_double_option",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[schemars(with = "Option<String>", skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
#[ts(optional = nullable)]
|
||||
pub base_url: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "crate::protocol::serde_helpers::deserialize_double_option",
|
||||
serialize_with = "crate::protocol::serde_helpers::serialize_double_option",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
#[schemars(with = "Option<String>", skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "string | null")]
|
||||
#[ts(optional = nullable)]
|
||||
pub env_key: Option<Option<String>>,
|
||||
}
|
||||
|
||||
// A missing name preserves it, but an explicitly supplied name must be a string.
|
||||
fn deserialize_patch_name<'de, D: serde::Deserializer<'de>>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<String>, D::Error> {
|
||||
String::deserialize(deserializer).map(Some)
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for CustomGatewaySettingsParams {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("CustomGatewaySettingsParams")
|
||||
.field("name", &self.name)
|
||||
.field("base_url", &"[REDACTED]")
|
||||
.field("env_key", &self.env_key)
|
||||
.field("provider_id", &self.provider_id)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ModelProviderConfigWriteParams {
|
||||
pub settings: ProviderSettingsPatch,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ModelProviderConfigWriteResponse {
|
||||
pub provider: ModelProviderSummary,
|
||||
}
|
||||
Reference in New Issue
Block a user