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 / orchestration / run.rs

76 lines · 2143 bytes Raw Blame History
1use super::budget::RunBudget;
2use super::termination::TerminationReason;
3use super::trigger::Trigger;
4use crate::sessions::id::{RunId, SessionId};
5use chrono::Utc;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "snake_case")]
10pub enum RunState {
11 Running,
12 WaitingForApproval,
13 WaitingForTool,
14 Completed,
15 Failed,
16 Cancelled,
17}
18
19impl RunState {
20 pub fn as_str(&self) -> &'static str {
21 match self {
22 Self::Running => "running",
23 Self::WaitingForApproval => "waiting_for_approval",
24 Self::WaitingForTool => "waiting_for_tool",
25 Self::Completed => "completed",
26 Self::Failed => "failed",
27 Self::Cancelled => "cancelled",
28 }
29 }
30
31 #[allow(clippy::should_implement_trait)]
32 pub fn from_str(s: &str) -> Option<Self> {
33 match s {
34 "running" => Some(Self::Running),
35 "waiting_for_approval" => Some(Self::WaitingForApproval),
36 "waiting_for_tool" => Some(Self::WaitingForTool),
37 "completed" => Some(Self::Completed),
38 "failed" => Some(Self::Failed),
39 "cancelled" => Some(Self::Cancelled),
40 _ => None,
41 }
42 }
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct Run {
47 pub id: RunId,
48 pub session_id: SessionId,
49 pub state: RunState,
50 pub trigger: Trigger,
51 pub steps_used: u32,
52 pub inference_calls_used: u32,
53 pub actions_used: u32,
54 pub budget: RunBudget,
55 pub started_at: i64,
56 pub completed_at: Option<i64>,
57 pub termination: Option<TerminationReason>,
58}
59
60impl Run {
61 pub fn new(session_id: SessionId, trigger: Trigger, budget: RunBudget) -> Self {
62 Self {
63 id: RunId::new(),
64 session_id,
65 state: RunState::Running,
66 trigger,
67 steps_used: 0,
68 inference_calls_used: 0,
69 actions_used: 0,
70 budget,
71 started_at: Utc::now().timestamp(),
72 completed_at: None,
73 termination: None,
74 }
75 }
76}