agent_status.rs (2221B)
1 /// Represents the current status of an agent in the RTS scene 2 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] 3 pub enum AgentStatus { 4 /// Agent is idle, no active work 5 #[default] 6 Idle, 7 /// Agent is actively processing (receiving tokens, executing tools) 8 Working, 9 /// Agent needs user input (permission request pending) 10 NeedsInput, 11 /// Agent encountered an error 12 Error, 13 /// Agent completed its task successfully 14 Done, 15 } 16 17 impl AgentStatus { 18 /// Get the color associated with this status 19 pub fn color(&self) -> egui::Color32 { 20 match self { 21 AgentStatus::Idle => egui::Color32::from_rgb(128, 128, 128), // Gray 22 AgentStatus::Working => egui::Color32::from_rgb(50, 205, 50), // Green 23 AgentStatus::NeedsInput => egui::Color32::from_rgb(255, 200, 0), // Yellow/amber 24 AgentStatus::Error => egui::Color32::from_rgb(220, 60, 60), // Red 25 AgentStatus::Done => egui::Color32::from_rgb(70, 130, 220), // Blue 26 } 27 } 28 29 /// Get a human-readable label for this status 30 pub fn label(&self) -> &'static str { 31 match self { 32 AgentStatus::Idle => "Idle", 33 AgentStatus::Working => "Working", 34 AgentStatus::NeedsInput => "Needs Input", 35 AgentStatus::Error => "Error", 36 AgentStatus::Done => "Done", 37 } 38 } 39 40 /// Get the status as a lowercase string for serialization (nostr events). 41 pub fn as_str(&self) -> &'static str { 42 match self { 43 AgentStatus::Idle => "idle", 44 AgentStatus::Working => "working", 45 AgentStatus::NeedsInput => "needs_input", 46 AgentStatus::Error => "error", 47 AgentStatus::Done => "done", 48 } 49 } 50 51 /// Parse a status string from a nostr event (kind-31988 content). 52 pub fn from_status_str(s: &str) -> Option<Self> { 53 match s { 54 "idle" => Some(AgentStatus::Idle), 55 "working" => Some(AgentStatus::Working), 56 "needs_input" => Some(AgentStatus::NeedsInput), 57 "error" => Some(AgentStatus::Error), 58 "done" => Some(AgentStatus::Done), 59 _ => None, 60 } 61 } 62 }