mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
Initial scaffold for ECC 2.0, a terminal-native agentic IDE built with Ratatui. Compiles to a 3.4MB single binary. Core modules: - Session manager with SQLite-backed state store - TUI dashboard with split-pane layout (sessions, output, metrics) - Worktree orchestration (auto-create per agent session) - Observability with tool call risk scoring - Inter-agent communication via SQLite mailbox - Background daemon with heartbeat monitoring - CLI with start/stop/sessions/status/daemon subcommands Tech stack: Rust + Ratatui + Crossterm + Tokio + rusqlite + git2 + clap
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use anyhow::Result;
|
|
use std::time::Duration;
|
|
use tokio::time;
|
|
|
|
use super::store::StateStore;
|
|
use super::SessionState;
|
|
use crate::config::Config;
|
|
|
|
/// Background daemon that monitors sessions, handles heartbeats,
|
|
/// and cleans up stale resources.
|
|
pub async fn run(db: StateStore, cfg: Config) -> Result<()> {
|
|
tracing::info!("ECC daemon started");
|
|
|
|
let heartbeat_interval = Duration::from_secs(cfg.heartbeat_interval_secs);
|
|
let timeout = Duration::from_secs(cfg.session_timeout_secs);
|
|
|
|
loop {
|
|
if let Err(e) = check_sessions(&db, timeout) {
|
|
tracing::error!("Session check failed: {e}");
|
|
}
|
|
|
|
time::sleep(heartbeat_interval).await;
|
|
}
|
|
}
|
|
|
|
fn check_sessions(db: &StateStore, timeout: Duration) -> Result<()> {
|
|
let sessions = db.list_sessions()?;
|
|
|
|
for session in sessions {
|
|
if session.state != SessionState::Running {
|
|
continue;
|
|
}
|
|
|
|
let elapsed = chrono::Utc::now()
|
|
.signed_duration_since(session.updated_at)
|
|
.to_std()
|
|
.unwrap_or(Duration::ZERO);
|
|
|
|
if elapsed > timeout {
|
|
tracing::warn!("Session {} timed out after {:?}", session.id, elapsed);
|
|
db.update_state(&session.id, &SessionState::Failed)?;
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|