capo-agent 0.1.0

Coding-agent library built on motosan-agent-loop. Composable, embeddable.
Documentation
use async_trait::async_trait;
use serde_json::Value;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Decision {
    Allowed,
    Denied(String),
}

#[derive(Debug, Clone)]
pub struct PermissionRequest {
    pub tool: String,
    pub args: Value,
}

impl PermissionRequest {
    pub fn new(tool: impl Into<String>, args: Value) -> Self {
        Self {
            tool: tool.into(),
            args,
        }
    }
}

#[async_trait]
pub trait PermissionGate: Send + Sync {
    async fn check(&self, request: PermissionRequest) -> Decision;
}

pub struct NoOpPermissionGate;

#[async_trait]
impl PermissionGate for NoOpPermissionGate {
    async fn check(&self, _request: PermissionRequest) -> Decision {
        Decision::Allowed
    }
}