walrus_daemon/config/
mod.rs1use anyhow::Result;
4pub use model::{ProviderConfig, ProviderManager};
5pub use router::ChannelConfig;
6use serde::{Deserialize, Serialize};
7use std::path::PathBuf;
8
9pub use default::{DEFAULT_AGENT_MD, scaffold_config_dir};
10pub use loader::{load_agents_dir, load_cron_dir};
11
12mod default;
13mod loader;
14
15pub const AGENTS_DIR: &str = "agents";
17pub const SKILLS_DIR: &str = "skills";
19pub const CRON_DIR: &str = "cron";
21pub const DATA_DIR: &str = "data";
23pub const MEMORY_DB: &str = "memory.db";
25
26pub fn global_config_dir() -> PathBuf {
28 dirs::home_dir().expect("no home directory").join(".walrus")
29}
30
31pub fn socket_path() -> PathBuf {
33 global_config_dir().join("walrus.sock")
34}
35
36#[derive(Debug, Serialize, Deserialize)]
38pub struct DaemonConfig {
39 pub models: Vec<ProviderConfig>,
41 #[serde(default)]
43 pub channels: Vec<ChannelConfig>,
44 #[serde(default)]
46 pub mcp_servers: Vec<mcp::McpServerConfig>,
47}
48
49impl DaemonConfig {
50 pub fn from_toml(toml_str: &str) -> Result<Self> {
52 let config: Self = toml::from_str(toml_str)?;
53 Ok(config)
54 }
55
56 pub fn load(path: &std::path::Path) -> Result<Self> {
58 let content = std::fs::read_to_string(path)?;
59 Self::from_toml(&content)
60 }
61}