interplane.Get Omega
Read in your language

aegis-runtime-mv

Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha.

Brought by drakestapleton

branch main Branches Tags History

aegis-runtime-mv / src / events / event.rs

171 lines · 5171 bytes Raw Blame History
1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4#[serde(tag = "type", content = "data")]
5pub enum AegisEvent {
6 SessionCreated {
7 session_id: String,
8 objective: Option<String>,
9 },
10 SessionBranched {
11 session_id: String,
12 parent_session_id: String,
13 },
14 SessionClosed {
15 session_id: String,
16 },
17
18 RunStarted {
19 run_id: String,
20 session_id: String,
21 trigger: String,
22 },
23 RunCompleted {
24 run_id: String,
25 steps: u32,
26 duration_ms: u64,
27 },
28 RunFailed {
29 run_id: String,
30 error: String,
31 },
32
33 /// A tool call failed. Carries the structured provenance record; never
34 /// carries raw tool arguments. Does not map to a canonical agent event.
35 StepFailed {
36 failure: crate::failure::FailureRecord,
37 },
38
39 /// Workflow (task DAG) transitions. `workflow_seq` is assigned under one
40 /// lock at transition time, so sorting by it replays the exact order.
41 WorkflowTaskReady {
42 run_id: String,
43 workflow_seq: u64,
44 task_id: String,
45 },
46 WorkflowTaskStarted {
47 run_id: String,
48 workflow_seq: u64,
49 task_id: String,
50 },
51 WorkflowTaskCompleted {
52 run_id: String,
53 workflow_seq: u64,
54 task_id: String,
55 result_digest: String,
56 },
57 WorkflowTaskWaiting {
58 run_id: String,
59 workflow_seq: u64,
60 task_id: String,
61 },
62 WorkflowTaskFailed {
63 run_id: String,
64 workflow_seq: u64,
65 task_id: String,
66 failure: crate::failure::FailureRecord,
67 },
68 WorkflowTaskCancelled {
69 run_id: String,
70 workflow_seq: u64,
71 task_id: String,
72 },
73 WorkflowTaskSkipped {
74 run_id: String,
75 workflow_seq: u64,
76 task_id: String,
77 prerequisite: String,
78 },
79 WorkflowFinished {
80 run_id: String,
81 workflow_seq: u64,
82 status: String,
83 },
84
85 AssistantDelta {
86 text: String,
87 },
88
89 ActionRequested {
90 action_id: String,
91 capability: String,
92 },
93 ActionAuthorized {
94 action_id: String,
95 decision: String,
96 },
97 ActionDenied {
98 action_id: String,
99 reason: String,
100 },
101 ActionCompleted {
102 action_id: String,
103 success: bool,
104 duration_ms: u64,
105 },
106
107 ApprovalRequired {
108 approval_id: String,
109 action_id: String,
110 capability: String,
111 },
112 ApprovalResolved {
113 approval_id: String,
114 approved: bool,
115 },
116
117 ContainmentActivated {
118 level: String,
119 reason: String,
120 },
121}
122
123impl AegisEvent {
124 pub fn to_canonical_agent_event(&self) -> Option<aien_agent_state_abi::AgentEvent> {
125 use crate::sessions::id::{ActionId, ApprovalId, RunId, SessionId};
126 use aien_agent_state_abi::AgentEvent;
127
128 match self {
129 AegisEvent::SessionCreated { .. } => Some(AgentEvent::SessionCreated),
130 AegisEvent::SessionClosed { .. } => Some(AgentEvent::SessionClosed),
131 AegisEvent::SessionBranched { session_id, .. } => {
132 let sid: aien_protocol_types::SessionId = SessionId::from_string(session_id).into();
133 Some(AgentEvent::ContextBranched(sid.0))
134 }
135 AegisEvent::RunStarted { run_id, .. } => {
136 let rid: aien_protocol_types::RunId = RunId::from_string(run_id).into();
137 Some(AgentEvent::RunStarted(rid))
138 }
139 AegisEvent::RunCompleted { run_id, .. } => {
140 Some(AgentEvent::RunCompleted(run_id.clone()))
141 }
142 AegisEvent::ActionRequested { action_id, .. } => {
143 let aid: aien_protocol_types::ActionId = ActionId::from_string(action_id).into();
144 Some(AgentEvent::ActionRequested(aid))
145 }
146 AegisEvent::ActionAuthorized { action_id, .. } => {
147 let aid: aien_protocol_types::ActionId = ActionId::from_string(action_id).into();
148 Some(AgentEvent::ActionAuthorized(aid))
149 }
150 AegisEvent::ActionDenied { action_id, .. } => {
151 let aid: aien_protocol_types::ActionId = ActionId::from_string(action_id).into();
152 Some(AgentEvent::ActionDenied(aid))
153 }
154 AegisEvent::ActionCompleted { action_id, .. } => {
155 let aid: aien_protocol_types::ActionId = ActionId::from_string(action_id).into();
156 Some(AgentEvent::ActionCompleted(aid))
157 }
158 AegisEvent::ApprovalRequired { approval_id, .. } => {
159 let apid: aien_protocol_types::ApprovalId =
160 ApprovalId::from_string(approval_id).into();
161 Some(AgentEvent::ApprovalRequested(apid))
162 }
163 AegisEvent::ApprovalResolved { approval_id, .. } => {
164 let apid: aien_protocol_types::ApprovalId =
165 ApprovalId::from_string(approval_id).into();
166 Some(AgentEvent::ApprovalResolved(apid))
167 }
168 _ => None,
169 }
170 }
171}