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.
53 lines
988 B
Rust
53 lines
988 B
Rust
use serde::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Config {
|
|
#[serde(default = "default_name")]
|
|
pub name: String,
|
|
pub tg: TgConfig,
|
|
pub auth: AuthConfig,
|
|
pub session: SessionConfig,
|
|
#[serde(default)]
|
|
pub backend: BackendConfig,
|
|
#[serde(default)]
|
|
pub whisper_url: Option<String>,
|
|
}
|
|
|
|
fn default_name() -> String {
|
|
"noc".to_string()
|
|
}
|
|
|
|
#[derive(Deserialize, Clone, Default)]
|
|
#[serde(tag = "type")]
|
|
pub enum BackendConfig {
|
|
#[serde(rename = "claude")]
|
|
#[default]
|
|
Claude,
|
|
#[serde(rename = "openai")]
|
|
OpenAI {
|
|
endpoint: String,
|
|
model: String,
|
|
#[serde(default = "default_api_key")]
|
|
api_key: String,
|
|
},
|
|
}
|
|
|
|
fn default_api_key() -> String {
|
|
"unused".to_string()
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct TgConfig {
|
|
pub key: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct AuthConfig {
|
|
pub passphrase: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct SessionConfig {
|
|
pub refresh_hour: u32,
|
|
}
|