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 ValidationReport {
43 pub const fn new() -> Self {
44 Self {
45 valid: true,
46 issues: Vec::new(),
47 }
48 }
49
50 pub fn with_issue(issue: String) -> Self {
51 Self {
52 valid: false,
53 issues: vec![issue],
54 }
55 }
56
57 pub fn add_issue(&mut self, issue: String) {
58 self.valid = false;
59 self.issues.push(issue);
60 }
61}
62
63use anyhow::Result;
64use thiserror::Error;
65
66#[derive(Error, Debug)]
67pub enum OrchestrationError {
68 #[error("Agent {0} not found")]
69 AgentNotFound(String),
70
71 #[error("Agent {0} already running")]
72 AgentAlreadyRunning(String),
73
74 #[error("Process spawn failed: {0}")]
75 ProcessSpawnFailed(String),
76
77 #[error("Database error: {0}")]
78 DatabaseError(#[from] sqlx::Error),
79
80 #[error("Database error: {0}")]
81 Database(String),
82
83 #[error("IO error: {0}")]
84 IoError(#[from] std::io::Error),
85
86 #[error("Health check timeout for agent {0}")]
87 HealthCheckTimeout(String),
88
89 #[error("Generic error: {0}")]
90 Generic(#[from] anyhow::Error),
91}
92
93pub type OrchestrationResult<T> = Result<T, OrchestrationError>;