Skip to main content

scv_core/
approval.rs

1//! The [`ApprovalGate`] that decides whether a tool call may run.
2
3use std::path::PathBuf;
4
5use async_trait::async_trait;
6use tokio_util::sync::CancellationToken;
7
8use crate::{AgentError, ToolRisk};
9
10#[derive(Debug, Clone)]
11pub struct ApprovalRequest {
12    pub call_id: String,
13    pub name: String,
14    pub risk: ToolRisk,
15    pub cwd: PathBuf,
16    /// What the call will do, for the person deciding: display text only.
17    pub summary: String,
18    /// The exact command the call runs, such as a `bash` call's script or a
19    /// relayed agent's shell command, which the policy's command gates match.
20    pub command: Option<String>,
21}
22
23#[async_trait]
24pub trait ApprovalGate: Send + Sync {
25    async fn approve(
26        &self,
27        request: ApprovalRequest,
28        cancellation: CancellationToken,
29    ) -> Result<bool, AgentError>;
30}