use crate::config::AgentConfig; use anyhow::{Context, Result}; use std::fs; use std::path::Path; pub fn load_config>(path: P) -> Result { let path = path.as_ref(); let content = fs::read_to_string(path) .with_context(|| format!("Failed to read config file: {}", path.display()))?; let config: AgentConfig = toml::from_str(&content) .with_context(|| format!("Failed to parse config file: {}", path.display()))?; config .validate() .with_context(|| format!("Invalid configuration in file: {}", path.display()))?; Ok(config) }