use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AgentStatus {
Registered,
Active,
Paused,
Deactivated,
Archived,
}
impl AgentStatus {
pub fn can_accept_tasks(&self) -> bool {
matches!(self, Self::Active)
}
pub fn validate_transition(&self, next: &AgentStatus) -> Result<(), String> {
let valid = matches!(
(self, next),
(Self::Registered, Self::Active)
| (Self::Active, Self::Paused)
| (Self::Active, Self::Deactivated)
| (Self::Paused, Self::Active)
| (Self::Paused, Self::Deactivated)
| (Self::Deactivated, Self::Archived)
);
if valid {
Ok(())
} else {
Err(format!(
"invalid agent status transition: {self:?} → {next:?}"
))
}
}
}