pub fn check_approval_policy() -> Option<(bool, bool)> {
match crate::config::Config::load() {
Ok(cfg) => match cfg.agent.approval_policy.as_str() {
"auto-always" | "auto-session" => {
tracing::debug!(
"Approval policy is '{}' — auto-approving",
cfg.agent.approval_policy
);
Some((true, true))
}
_ => None,
},
Err(e) => {
tracing::warn!("Failed to load config for approval check: {}", e);
None
}
}
}
pub fn persist_auto_session_policy() {
match crate::config::Config::write_key("agent", "approval_policy", "auto-session") {
Ok(_) => tracing::info!("Persisted approval_policy = auto-session to config.toml"),
Err(e) => tracing::error!("Failed to persist approval_policy to config.toml: {}", e),
}
}
pub fn persist_auto_always_policy() {
match crate::config::Config::write_key("agent", "approval_policy", "auto-always") {
Ok(_) => tracing::info!("Persisted approval_policy = auto-always to config.toml"),
Err(e) => tracing::error!("Failed to persist approval_policy to config.toml: {}", e),
}
}