systemprompt_agent/services/agent_orchestration/
mod.rs1pub mod database;
2pub mod event_bus;
3pub mod events;
4pub mod lifecycle;
5pub mod monitor;
6pub mod orchestrator;
7pub mod port_manager;
8pub mod process;
9pub mod reconciler;
10
11pub use event_bus::AgentEventBus;
12pub use events::AgentEvent;
13pub use orchestrator::{AgentInfo, AgentOrchestrator};
14pub use port_manager::PortManager;
15
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub enum AgentStatus {
18 Running {
19 pid: u32,
20 port: u16,
21 },
22 Failed {
23 reason: String,
24 last_attempt: Option<String>,
25 retry_count: u32,
26 },
27}
28
29#[derive(Debug, Clone)]
30pub struct AgentRuntimeConfig {
31 pub id: String,
32 pub name: String,
33 pub port: u16,
34}
35
36#[derive(Debug, Clone)]
37pub struct ValidationReport {
38 pub valid: bool,
39 pub issues: Vec<String>,
40}
41
42impl Default for ValidationReport {
43 fn default() -> Self {
44 Self::new()
45 }
46}
47
48impl ValidationReport {
49 pub const fn new() -> Self {
50 Self {
51 valid: true,
52 issues: Vec::new(),
53 }
54 }
55
56 pub fn with_issue(issue: String) -> Self {
57 Self {
58 valid: false,
59 issues: vec![issue],
60 }
61 }
62
63 pub fn add_issue(&mut self, issue: String) {
64 self.valid = false;
65 self.issues.push(issue);
66 }
67}
68
69use anyhow::Result;
70use thiserror::Error;
71
72#[derive(Error, Debug)]
73pub enum OrchestrationError {
74 #[error("Agent {0} not found")]
75 AgentNotFound(String),
76
77 #[error("Agent {0} already running")]
78 AgentAlreadyRunning(String),
79
80 #[error("Process spawn failed: {0}")]
81 ProcessSpawnFailed(String),
82
83 #[error("Database error: {0}")]
84 DatabaseError(#[from] sqlx::Error),
85
86 #[error("Database error: {0}")]
87 Database(String),
88
89 #[error("IO error: {0}")]
90 IoError(#[from] std::io::Error),
91
92 #[error("Health check timeout for agent {0}")]
93 HealthCheckTimeout(String),
94
95 #[error("Generic error: {0}")]
96 Generic(#[from] anyhow::Error),
97}
98
99pub type OrchestrationResult<T> = Result<T, OrchestrationError>;