Skip to main content

oxicode_sdk/lifecycle/
hub.rs

1//! Display metadata for the Agent Hub overlay (advisor + subagent monitoring).
2//! Kept separate from supervisor.rs (lifecycle state machine) so display
3//! concerns don't pollute the supervisor API.
4
5use serde::{Deserialize, Serialize};
6
7/// Role of an agent in the hub view.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9pub enum HubKind {
10    /// The main session agent.
11    Main,
12    /// A subagent spawned by the `subagent` tool (in- or out-of-process).
13    Subagent,
14    /// The read-only advisor reviewer.
15    Advisor,
16}
17
18impl HubKind {
19    /// omp `kind` lower-case tag.
20    pub const fn as_str(self) -> &'static str {
21        match self {
22            HubKind::Main => "main",
23            HubKind::Subagent => "task",
24            HubKind::Advisor => "advisor",
25        }
26    }
27}
28
29/// High-level status for the hub table. Maps onto the supervisor's atomic
30/// status (Running/Suspended/Terminated/Failed) + a parked concept for
31/// agents kept alive after completion awaiting revival.
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
33pub enum HubStatus {
34    /// Currently executing a task.
35    Running,
36    /// Alive but not actively executing (e.g. waiting on the next prompt).
37    Idle,
38    /// STOPPED in supervisor terms; held in memory for later revival.
39    Parked,
40    /// FAILED or unrecoverable.
41    Aborted,
42}
43
44impl HubStatus {
45    /// Lower-case tag for the status badge column.
46    pub const fn as_str(self) -> &'static str {
47        match self {
48            HubStatus::Running => "running",
49            HubStatus::Idle => "idle",
50            HubStatus::Parked => "parked",
51            HubStatus::Aborted => "aborted",
52        }
53    }
54
55    /// Sort priority — lower comes first.
56    pub const fn sort_key(self) -> u8 {
57        match self {
58            HubStatus::Running => 0,
59            HubStatus::Idle => 1,
60            HubStatus::Parked => 2,
61            HubStatus::Aborted => 3,
62        }
63    }
64}