#![cfg_attr(coverage_nightly, coverage(off))]
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
use super::super::mcp_server::AgentConfig;
use super::super::quality_monitor::QualityMonitorConfig;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DaemonConfig {
pub agent: AgentConfig,
pub quality_monitor: QualityMonitorConfig,
pub daemon: DaemonSettings,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonSettings {
pub pid_file: Option<PathBuf>,
pub log_file: Option<PathBuf>,
pub working_directory: PathBuf,
pub health_check_interval: Duration,
pub max_memory_mb: u64,
pub auto_restart: bool,
pub shutdown_timeout: Duration,
}
impl Default for DaemonSettings {
fn default() -> Self {
Self {
pid_file: None,
log_file: None,
working_directory: std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
health_check_interval: Duration::from_secs(30),
max_memory_mb: 500,
auto_restart: true,
shutdown_timeout: Duration::from_secs(10),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaemonState {
pub status: DaemonStatus,
pub started_at: SystemTime,
pub last_health_check: SystemTime,
pub active_projects: usize,
pub events_processed: u64,
pub memory_usage_mb: u64,
pub restart_count: u32,
pub last_error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum DaemonStatus {
Starting,
Running,
Stopping,
Stopped,
Error,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DaemonCommand {
GetStatus,
StartMonitoring { project_path: String },
StopMonitoring { project_id: String },
ReloadConfig,
HealthCheck,
Shutdown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QualityGateResult {
pub violations: Option<u32>,
pub passed: bool,
}