use super::IntegrationResult;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommandResult {
pub command: String,
pub stdout: String,
pub stderr: String,
pub exit_code: i32,
pub duration_ms: u64,
pub started_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ShellEnvironment {
pub shell: String,
pub cwd: PathBuf,
pub env_vars: HashMap<String, String>,
}
#[async_trait::async_trait]
pub trait ShellProvider: Send + Sync {
async fn run_command(&self, command: &str, cwd: Option<&str>) -> IntegrationResult;
async fn run_with_env(&self, command: &str, env: HashMap<String, String>) -> IntegrationResult;
async fn run_background(&self, command: &str) -> IntegrationResult;
async fn kill_process(&self, pid: u32) -> IntegrationResult;
async fn get_environment(&self) -> IntegrationResult;
async fn set_env_var(&self, name: &str, value: &str) -> IntegrationResult;
async fn source_script(&self, path: &str) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ClipboardContent {
Text(String),
Html(String),
Image(Vec<u8>),
Files(Vec<PathBuf>),
RichText { text: String, rtf: String },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClipboardEntry {
pub content: ClipboardContent,
pub timestamp: String,
pub source_app: Option<String>,
}
#[async_trait::async_trait]
pub trait ClipboardProvider: Send + Sync {
async fn get(&self) -> IntegrationResult;
async fn set_text(&self, text: &str) -> IntegrationResult;
async fn set_html(&self, html: &str) -> IntegrationResult;
async fn set_image(&self, image_data: Vec<u8>) -> IntegrationResult;
async fn get_history(&self, limit: u32) -> IntegrationResult;
async fn clear(&self) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FileInfo {
pub path: PathBuf,
pub name: String,
pub is_dir: bool,
pub is_file: bool,
pub is_symlink: bool,
pub size_bytes: u64,
pub created: Option<String>,
pub modified: Option<String>,
pub accessed: Option<String>,
pub permissions: Option<u32>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SearchOptions {
pub pattern: String,
pub recursive: bool,
pub include_hidden: bool,
pub file_types: Option<Vec<String>>,
pub max_depth: Option<u32>,
pub max_results: Option<u32>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WatchEvent {
Created,
Modified,
Deleted,
Renamed,
Accessed,
}
#[async_trait::async_trait]
pub trait FilesystemProvider: Send + Sync {
async fn read_file(&self, path: &str) -> IntegrationResult;
async fn read_file_bytes(&self, path: &str) -> IntegrationResult;
async fn read_json(&self, path: &str) -> IntegrationResult;
async fn list_dir(&self, path: &str) -> IntegrationResult;
async fn get_file_info(&self, path: &str) -> IntegrationResult;
async fn write_file(&self, path: &str, content: &str) -> IntegrationResult;
async fn write_file_bytes(&self, path: &str, content: Vec<u8>) -> IntegrationResult;
async fn append_file(&self, path: &str, content: &str) -> IntegrationResult;
async fn create_dir(&self, path: &str, recursive: bool) -> IntegrationResult;
async fn copy(&self, src: &str, dst: &str) -> IntegrationResult;
async fn move_path(&self, src: &str, dst: &str) -> IntegrationResult;
async fn delete(&self, path: &str, recursive: bool) -> IntegrationResult;
async fn exists(&self, path: &str) -> IntegrationResult;
async fn search(&self, base_path: &str, options: SearchOptions) -> IntegrationResult;
async fn glob(&self, pattern: &str) -> IntegrationResult;
async fn watch(&self, path: &str, events: Vec<WatchEvent>) -> IntegrationResult;
async fn unwatch(&self, watch_id: &str) -> IntegrationResult;
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum NotificationPriority {
Low,
Normal,
High,
Urgent,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NotificationAction {
pub id: String,
pub label: String,
pub is_destructive: bool,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct NotificationOptions {
pub title: String,
pub body: String,
pub subtitle: Option<String>,
pub icon: Option<String>,
pub image: Option<String>,
pub sound: Option<String>,
pub priority: Option<NotificationPriority>,
pub actions: Vec<NotificationAction>,
pub timeout_ms: Option<u32>,
pub silent: bool,
}
#[async_trait::async_trait]
pub trait SystemNotificationProvider: Send + Sync {
async fn notify(&self, options: NotificationOptions) -> IntegrationResult;
async fn schedule(&self, options: NotificationOptions, at: &str) -> IntegrationResult;
async fn cancel(&self, notification_id: &str) -> IntegrationResult;
async fn list_pending(&self) -> IntegrationResult;
async fn request_permission(&self) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CpuInfo {
pub model: String,
pub cores: u32,
pub threads: u32,
pub usage_percent: f32,
pub frequency_mhz: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryInfo {
pub total_bytes: u64,
pub used_bytes: u64,
pub free_bytes: u64,
pub available_bytes: u64,
pub usage_percent: f32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DiskInfo {
pub name: String,
pub mount_point: String,
pub fs_type: String,
pub total_bytes: u64,
pub used_bytes: u64,
pub free_bytes: u64,
pub usage_percent: f32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NetworkInfo {
pub name: String,
pub ip_address: Option<String>,
pub mac_address: Option<String>,
pub is_up: bool,
pub bytes_sent: u64,
pub bytes_received: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatteryInfo {
pub charge_percent: u8,
pub is_charging: bool,
pub is_plugged_in: bool,
pub time_to_full_mins: Option<u32>,
pub time_to_empty_mins: Option<u32>,
pub health_percent: Option<u8>,
}
#[async_trait::async_trait]
pub trait SystemInfoProvider: Send + Sync {
async fn get_os_info(&self) -> IntegrationResult;
async fn get_cpu_info(&self) -> IntegrationResult;
async fn get_memory_info(&self) -> IntegrationResult;
async fn get_disk_info(&self) -> IntegrationResult;
async fn get_network_info(&self) -> IntegrationResult;
async fn get_battery_info(&self) -> IntegrationResult;
async fn get_uptime(&self) -> IntegrationResult;
async fn get_load_average(&self) -> IntegrationResult;
async fn get_processes(&self, limit: Option<u32>) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppInfo {
pub name: String,
pub bundle_id: Option<String>,
pub path: PathBuf,
pub version: Option<String>,
pub is_running: bool,
pub pid: Option<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WindowInfo {
pub id: u64,
pub title: String,
pub app_name: String,
pub is_focused: bool,
pub is_visible: bool,
pub position: (i32, i32),
pub size: (u32, u32),
}
#[async_trait::async_trait]
pub trait AppControlProvider: Send + Sync {
async fn list_installed_apps(&self) -> IntegrationResult;
async fn list_running_apps(&self) -> IntegrationResult;
async fn launch_app(&self, app_id: &str) -> IntegrationResult;
async fn quit_app(&self, app_id: &str) -> IntegrationResult;
async fn focus_app(&self, app_id: &str) -> IntegrationResult;
async fn list_windows(&self) -> IntegrationResult;
async fn focus_window(&self, window_id: u64) -> IntegrationResult;
async fn close_window(&self, window_id: u64) -> IntegrationResult;
async fn minimize_window(&self, window_id: u64) -> IntegrationResult;
async fn maximize_window(&self, window_id: u64) -> IntegrationResult;
async fn move_window(&self, window_id: u64, x: i32, y: i32) -> IntegrationResult;
async fn resize_window(&self, window_id: u64, width: u32, height: u32) -> IntegrationResult;
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum KeyModifier {
Shift,
Ctrl,
Alt,
Meta,
Cmd,
}
#[async_trait::async_trait]
pub trait InputProvider: Send + Sync {
async fn type_text(&self, text: &str, delay_ms: Option<u32>) -> IntegrationResult;
async fn press_key(&self, key: &str, modifiers: Vec<KeyModifier>) -> IntegrationResult;
async fn key_combo(&self, keys: Vec<&str>) -> IntegrationResult;
async fn move_mouse(&self, x: i32, y: i32) -> IntegrationResult;
async fn click(&self, button: &str) -> IntegrationResult;
async fn double_click(&self) -> IntegrationResult;
async fn scroll(&self, dx: i32, dy: i32) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AudioDevice {
pub id: String,
pub name: String,
pub device_type: AudioDeviceType,
pub is_default: bool,
pub volume: u8,
pub is_muted: bool,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AudioDeviceType {
Output,
Input,
}
#[async_trait::async_trait]
pub trait AudioProvider: Send + Sync {
async fn list_devices(&self) -> IntegrationResult;
async fn get_volume(&self) -> IntegrationResult;
async fn set_volume(&self, volume: u8) -> IntegrationResult;
async fn mute(&self) -> IntegrationResult;
async fn unmute(&self) -> IntegrationResult;
async fn set_default_device(&self, device_id: &str) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DisplayInfo {
pub id: String,
pub name: String,
pub width: u32,
pub height: u32,
pub refresh_rate: u32,
pub is_primary: bool,
pub brightness: Option<u8>,
pub scale_factor: f32,
}
#[async_trait::async_trait]
pub trait DisplayProvider: Send + Sync {
async fn list_displays(&self) -> IntegrationResult;
async fn get_brightness(&self, display_id: &str) -> IntegrationResult;
async fn set_brightness(&self, display_id: &str, brightness: u8) -> IntegrationResult;
async fn take_screenshot(&self, display_id: Option<&str>) -> IntegrationResult;
async fn take_screenshot_region(
&self,
x: i32,
y: i32,
width: u32,
height: u32,
) -> IntegrationResult;
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PowerAction {
Shutdown,
Restart,
Sleep,
Hibernate,
Lock,
LogOut,
}
#[async_trait::async_trait]
pub trait PowerProvider: Send + Sync {
async fn perform_action(&self, action: PowerAction) -> IntegrationResult;
async fn schedule_action(&self, action: PowerAction, at: &str) -> IntegrationResult;
async fn cancel_scheduled(&self) -> IntegrationResult;
async fn prevent_sleep(&self, reason: &str) -> IntegrationResult;
async fn allow_sleep(&self) -> IntegrationResult;
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScheduledTask {
pub id: String,
pub name: String,
pub command: String,
pub schedule: String, pub enabled: bool,
pub last_run: Option<String>,
pub next_run: Option<String>,
}
#[async_trait::async_trait]
pub trait SchedulerProvider: Send + Sync {
async fn list_tasks(&self) -> IntegrationResult;
async fn create_task(&self, name: &str, command: &str, schedule: &str) -> IntegrationResult;
async fn update_task(
&self,
task_id: &str,
command: Option<&str>,
schedule: Option<&str>,
) -> IntegrationResult;
async fn delete_task(&self, task_id: &str) -> IntegrationResult;
async fn enable_task(&self, task_id: &str) -> IntegrationResult;
async fn disable_task(&self, task_id: &str) -> IntegrationResult;
async fn run_task_now(&self, task_id: &str) -> IntegrationResult;
}