refactor: split main.rs into 7 modules, add life loop with timer system

Structure:
  main.rs (534)   — entry, handler, prompt building
  config.rs (52)  — config structs
  state.rs (358)  — AppState, SQLite, persistence
  tools.rs (665)  — tool definitions, execution, subagent management
  stream.rs (776) — OpenAI/Claude streaming, system prompt
  display.rs (220)— markdown rendering, message formatting
  life.rs (87)    — life loop heartbeat, timer firing

New features:
- Life Loop: background tokio task, 30s heartbeat, scans timers table
- Timer tools: set_timer (relative/absolute/cron), list_timers, cancel_timer
- inner_state table for life loop's own context
- cron crate for recurring schedule parsing

Zero logic changes in the refactor — pure structural split.
This commit is contained in:
Fam Zheng
2026-04-09 20:28:54 +01:00
parent ec1bd7cb25
commit c3eb13dad3
9 changed files with 2266 additions and 1796 deletions

View File

@@ -7,6 +7,7 @@ edition = "2021"
anyhow = "1"
base64 = "0.22"
chrono = { version = "0.4", features = ["serde"] }
cron = "0.16"
dptree = "0.3"
libc = "0.2"
serde = { version = "1", features = ["derive"] }