diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs new file mode 100644 index 0000000..758f49f --- /dev/null +++ b/src-tauri/src/commands.rs @@ -0,0 +1,66 @@ +use crate::models::{Config, ProfileSummary}; + +#[tauri::command] +pub fn load_config_command() -> Config { + Config { + default_model: None, + providers: indexmap::IndexMap::new(), + models: indexmap::IndexMap::new(), + raw_other: toml_edit::Table::new(), + } +} + +#[tauri::command] +pub fn save_config_command(_config: Config) -> Result<(), String> { + Ok(()) +} + +#[tauri::command] +pub fn list_profiles() -> Vec { + Vec::new() +} + +#[tauri::command] +pub fn load_profile(_filename: String) -> Config { + Config { + default_model: None, + providers: indexmap::IndexMap::new(), + models: indexmap::IndexMap::new(), + raw_other: toml_edit::Table::new(), + } +} + +#[tauri::command] +pub fn save_profile(_filename: String, _config: Config) -> Result<(), String> { + Ok(()) +} + +#[tauri::command] +pub fn switch_profile(_filename: String) -> Result { + Ok(Config { + default_model: None, + providers: indexmap::IndexMap::new(), + models: indexmap::IndexMap::new(), + raw_other: toml_edit::Table::new(), + }) +} + +#[tauri::command] +pub fn rename_profile(_old_filename: String, _new_name: String) -> Result { + Ok(String::new()) +} + +#[tauri::command] +pub fn delete_profile(_filename: String) -> Result<(), String> { + Ok(()) +} + +#[tauri::command] +pub fn open_config_dir() -> Result<(), String> { + Ok(()) +} + +#[tauri::command] +pub fn get_app_version() -> String { + env!("CARGO_PKG_VERSION").to_string() +} diff --git a/src-tauri/src/config_io.rs b/src-tauri/src/config_io.rs new file mode 100644 index 0000000..e69de29 diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index adad12a..eb36fa9 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,6 +1,24 @@ +pub mod commands; +pub mod config_io; +pub mod models; +pub mod profile_manager; +pub mod validators; + pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_shell::init()) + .invoke_handler(tauri::generate_handler![ + commands::load_config_command, + commands::save_config_command, + commands::list_profiles, + commands::load_profile, + commands::save_profile, + commands::switch_profile, + commands::rename_profile, + commands::delete_profile, + commands::open_config_dir, + commands::get_app_version, + ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/src-tauri/src/models.rs b/src-tauri/src/models.rs new file mode 100644 index 0000000..bcadabe --- /dev/null +++ b/src-tauri/src/models.rs @@ -0,0 +1,75 @@ +use indexmap::IndexMap; +use serde::{Deserialize, Serialize}; +pub use toml_edit::Table; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ProviderType { + Kimi, + Anthropic, + Openai, + #[serde(rename = "openai_responses")] + OpenaiResponses, + #[serde(rename = "google-genai")] + GoogleGenai, + Vertexai, +} + +impl ProviderType { + pub fn as_str(&self) -> &'static str { + match self { + ProviderType::Kimi => "kimi", + ProviderType::Anthropic => "anthropic", + ProviderType::Openai => "openai", + ProviderType::OpenaiResponses => "openai_responses", + ProviderType::GoogleGenai => "google-genai", + ProviderType::Vertexai => "vertexai", + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Provider { + pub name: String, + pub provider_type: ProviderType, + pub base_url: Option, + pub api_key: Option, + pub env: IndexMap, + #[serde(skip)] + pub raw_other: Table, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Model { + pub alias: String, + pub provider: String, + pub model: String, + pub max_context_size: u64, + pub display_name: Option, + #[serde(skip)] + pub raw_other: Table, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct Config { + pub default_model: Option, + pub providers: IndexMap, + pub models: IndexMap, + #[serde(skip)] + pub raw_other: Table, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ProfileSummary { + pub name: String, + pub filename: String, + pub is_active: bool, +} + +#[derive(Debug, Clone)] +pub struct Profile { + pub name: String, + pub filename: String, + pub config: Config, + pub is_active: bool, +} diff --git a/src-tauri/src/profile_manager.rs b/src-tauri/src/profile_manager.rs new file mode 100644 index 0000000..e69de29 diff --git a/src-tauri/src/validators.rs b/src-tauri/src/validators.rs new file mode 100644 index 0000000..e69de29