use std::collections::HashMap;
use std::path::Path;
use std::time::Duration;
use async_trait::async_trait;
use crate::host::{CacheLevel, HostApiError, OpenTarget};
use crate::services::app::AppInfo;
use crate::services::focus_monitor::FocusCallback;
use crate::services::hotkey::types::{HotkeyCallback, HotkeyEventFilter};
use crate::services::installation_monitor::types::InstallationCallback;
use crate::services::model::{
ModelChatRequest, ModelChatResponse, ModelEmbeddingRequest, ModelEmbeddingResponse, ModelError,
ModelInfo, ModelSimilarityRequest, ModelSimilarityResponse,
};
use crate::services::parameter::types::ParameterSnapshot;
use crate::services::path::path_resolver::KnownPath;
use crate::services::theme::Theme;
use crate::services::timer::types::{TimerCallback, TimerId};
use crate::services::IconRequest;
#[async_trait]
pub trait PluginHost: Send + Sync {
async fn get_icon(
&self,
request: &IconRequest,
level: CacheLevel,
) -> Result<Vec<u8>, HostApiError>;
async fn get_icon_or_default(&self, request: &IconRequest, level: CacheLevel) -> Vec<u8>;
async fn get_icon_and_update_cache(
&self,
request: &IconRequest,
level: CacheLevel,
) -> Result<Vec<u8>, HostApiError>;
async fn override_icon_cache(
&self,
original_request: &IconRequest,
custom_icon_path: &str,
) -> Result<(), HostApiError>;
async fn shell_open(&self, target: OpenTarget) -> Result<(), HostApiError>;
async fn shell_open_folder(&self, path: &str) -> Result<(), HostApiError>;
async fn shell_execute_elevation(&self, path: &str) -> Result<(), HostApiError>;
async fn shell_execute_command(&self, command: &str) -> Result<(), HostApiError>;
async fn activate_window_by_process(&self, process_name: &str) -> Result<bool, HostApiError>;
async fn activate_window_by_title(&self, title: &str) -> Result<bool, HostApiError>;
async fn activate_window_by_pid(&self, pid: u32) -> Result<bool, HostApiError>;
fn resolve_path(&self, path: KnownPath) -> Result<String, HostApiError>;
fn set_clipboard_text(&self, text: &str) -> Result<(), HostApiError>;
async fn enumerate_apps(&self) -> Vec<AppInfo>;
async fn launch_app(&self, app_id: &str, args: Option<&[String]>) -> Result<u32, HostApiError>;
fn get_app_icon_path(&self, name: &str) -> Option<String>;
fn resolve_lnk_target(&self, lnk_path: &str) -> Option<String>;
fn parse_localized_names_from_dir(&self, dir_path: &Path) -> HashMap<String, String>;
fn get_theme(&self) -> Result<Theme, HostApiError>;
fn get_system_theme(&self) -> Result<Theme, HostApiError>;
fn model_list(&self) -> Vec<ModelInfo>;
async fn model_chat(&self, req: ModelChatRequest) -> Result<ModelChatResponse, ModelError>;
async fn model_embedding(
&self,
req: ModelEmbeddingRequest,
) -> Result<ModelEmbeddingResponse, ModelError>;
async fn model_similarity(
&self,
req: ModelSimilarityRequest,
) -> Result<ModelSimilarityResponse, ModelError>;
async fn resolve_parameters(
&self,
template: &str,
user_args: &[String],
snapshot: &ParameterSnapshot,
) -> Result<String, HostApiError>;
fn count_user_parameters(&self, template: &str) -> usize;
fn has_system_parameters(&self, template: &str) -> bool;
async fn set_timeout(
&self,
delay: Duration,
callback: TimerCallback,
) -> Result<TimerId, HostApiError>;
async fn set_interval(
&self,
interval: Duration,
callback: TimerCallback,
) -> Result<TimerId, HostApiError>;
async fn cancel_timer(&self, id: TimerId) -> Result<(), HostApiError>;
async fn cancel_all_timers(&self) -> Result<(), HostApiError>;
async fn resource_upload(
&self,
plugin_id: &str,
resource_id: &str,
file_path: &str,
max_size: Option<u64>,
) -> Result<String, HostApiError>;
async fn resource_put(
&self,
plugin_id: &str,
resource_id: &str,
data: &[u8],
) -> Result<(), HostApiError>;
async fn resource_get(
&self,
plugin_id: &str,
resource_id: &str,
) -> Result<Vec<u8>, HostApiError>;
async fn resource_delete(&self, plugin_id: &str, resource_id: &str)
-> Result<(), HostApiError>;
async fn resource_list(&self, plugin_id: &str) -> Result<Vec<String>, HostApiError>;
async fn cache_put(
&self,
plugin_id: &str,
domain: &str,
key: &str,
data: &[u8],
) -> Result<(), HostApiError>;
async fn cache_get(
&self,
plugin_id: &str,
domain: &str,
key: &str,
) -> Result<Option<Vec<u8>>, HostApiError>;
async fn cache_delete(
&self,
plugin_id: &str,
domain: &str,
key: &str,
) -> Result<(), HostApiError>;
async fn cache_cleanup(
&self,
plugin_id: &str,
domain: &str,
max_entries: usize,
) -> Result<(), HostApiError>;
fn register_hotkey_callback(
&self,
plugin_id: &str,
id: &str,
filter: HotkeyEventFilter,
callback: HotkeyCallback,
);
fn unregister_hotkey_callback(&self, plugin_id: &str, id: &str);
fn register_installation_callback(
&self,
plugin_id: &str,
id: &str,
callback: InstallationCallback,
);
fn unregister_installation_callback(&self, plugin_id: &str, id: &str);
fn register_focus_callback(&self, plugin_id: &str, id: &str, callback: FocusCallback);
fn unregister_focus_callback(&self, plugin_id: &str, id: &str);
}