use async_trait::async_trait;
use crate::tools::ToolInvocation;
#[async_trait]
pub trait ApprovalGate: Send + Sync {
async fn approve(&self, inv: &ToolInvocation) -> bool;
fn advertise_mutating_tools(&self) -> bool {
true
}
}
#[derive(Debug, Clone, Default)]
pub struct YoloApproval;
#[async_trait]
impl ApprovalGate for YoloApproval {
async fn approve(&self, _inv: &ToolInvocation) -> bool {
true
}
}
#[derive(Debug, Clone, Default)]
pub struct PlanApproval;
#[async_trait]
impl ApprovalGate for PlanApproval {
async fn approve(&self, inv: &ToolInvocation) -> bool {
is_read_only(&inv.name)
}
fn advertise_mutating_tools(&self) -> bool {
false
}
}
pub(crate) fn is_read_only(name: &str) -> bool {
matches!(name, "read" | "glob" | "grep")
}