1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub enum AgentEvent {
11 TaskStatusChanged { node_id: String, status: NodeStatus },
13
14 PlanGenerated(crate::types::TaskPlan),
16
17 EnergyUpdated { node_id: String, energy: f32 },
19
20 Log(String),
22
23 NodeCompleted { node_id: String, goal: String },
25
26 ApprovalRequest {
28 request_id: String,
29 node_id: String,
30 action_type: ActionType,
31 description: String,
32 diff: Option<String>,
33 },
34
35 Complete { success: bool, message: String },
37
38 Error(String),
40}
41
42#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
44pub enum NodeStatus {
45 Pending,
46 Running,
47 Verifying,
48 Completed,
49 Failed,
50 Escalated,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55pub enum ActionType {
56 FileWrite { path: String },
58 Command { command: String },
60 SubGraph { node_count: usize },
62 ProjectInit {
64 command: String,
65 suggested_name: String,
66 },
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71pub enum AgentAction {
72 Approve { request_id: String },
74 ApproveWithEdit {
76 request_id: String,
77 edited_value: String,
78 },
79 Reject {
81 request_id: String,
82 reason: Option<String>,
83 },
84 Pause,
86 Resume,
88 Abort,
90}
91
92pub mod channel {
94 use super::{AgentAction, AgentEvent};
95 use tokio::sync::mpsc;
96
97 pub type EventSender = mpsc::UnboundedSender<AgentEvent>;
99 pub type EventReceiver = mpsc::UnboundedReceiver<AgentEvent>;
101
102 pub type ActionSender = mpsc::UnboundedSender<AgentAction>;
104 pub type ActionReceiver = mpsc::UnboundedReceiver<AgentAction>;
106
107 pub fn event_channel() -> (EventSender, EventReceiver) {
109 mpsc::unbounded_channel()
110 }
111
112 pub fn action_channel() -> (ActionSender, ActionReceiver) {
114 mpsc::unbounded_channel()
115 }
116}