ditto_os/browser/
types.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4pub enum BrowserType {
5 Chrome,
6 Firefox,
7 Safari,
8 Edge,
9}
10
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
12pub enum SessionStatus {
13 Starting,
14 Running,
15 Idle,
16 Error,
17 Closed,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct BrowserCommand {
22 pub action: BrowserAction,
23 pub parameters: std::collections::HashMap<String, serde_json::Value>,
24 pub timeout_ms: u32,
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub enum BrowserAction {
29 Navigate { url: String },
30 Click { selector: String },
31 Type { selector: String, text: String },
32 Screenshot { path: Option<String> },
33 ExecuteScript { script: String },
34 WaitForElement { selector: String, timeout_ms: u32 },
35 GetTitle {},
36 GetUrl {},
37 Refresh {},
38 Back {},
39 Forward {},
40 GetText { selector: String },
41 GetAttribute { selector: String, attribute: String },
42 ScrollTo { selector: Option<String> },
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct CommandResult {
47 pub success: bool,
48 pub data: serde_json::Value,
49 pub error: Option<String>,
50 pub execution_time_ms: u64,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct SessionStats {
55 pub total_sessions: usize,
56 pub running_sessions: usize,
57 pub idle_sessions: usize,
58 pub error_sessions: usize,
59 pub browser_type_counts: std::collections::HashMap<String, usize>,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct BrowserSession {
64 pub id: String,
65 pub browser_type: BrowserType,
66 pub agent_id: String,
67 pub status: SessionStatus,
68 pub created_at: chrono::DateTime<chrono::Utc>,
69 pub last_activity: chrono::DateTime<chrono::Utc>,
70 pub url: Option<String>,
71 pub title: Option<String>,
72 pub chromiumoxide_handle: Option<String>,
73}