Skip to main content

aidens_tool_kit/
exposure.rs

1use aidens_contracts::{CanonicalToolSideEffectClass, ProviderRouteReportV1};
2use aidens_permit_kit::PermitPolicyV1;
3use std::collections::BTreeSet;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct ToolExposurePolicyV1 {
7    pub allowed_tool_ids: Option<BTreeSet<String>>,
8    pub allowed_risk_classes: BTreeSet<CanonicalToolSideEffectClass>,
9    pub max_tools: Option<usize>,
10    pub native_tool_loop_available: bool,
11    pub permit_policy: PermitPolicyV1,
12    pub sandbox_root: Option<String>,
13}
14
15impl ToolExposurePolicyV1 {
16    pub fn read_only_default() -> Self {
17        Self {
18            allowed_tool_ids: None,
19            allowed_risk_classes: BTreeSet::from([CanonicalToolSideEffectClass::ReadOnly]),
20            max_tools: Some(64),
21            native_tool_loop_available: false,
22            permit_policy: PermitPolicyV1::default(),
23            sandbox_root: None,
24        }
25    }
26
27    pub fn coding_agent_default() -> Self {
28        Self {
29            allowed_tool_ids: None,
30            allowed_risk_classes: BTreeSet::from([
31                CanonicalToolSideEffectClass::ReadOnly,
32                CanonicalToolSideEffectClass::Write,
33                CanonicalToolSideEffectClass::Admin,
34            ]),
35            max_tools: Some(64),
36            native_tool_loop_available: false,
37            permit_policy: PermitPolicyV1::default(),
38            sandbox_root: None,
39        }
40    }
41
42    pub fn for_provider_route(mut self, route: &ProviderRouteReportV1) -> Self {
43        self.native_tool_loop_available = route.native_tool_loop;
44        self
45    }
46
47    pub fn with_permit_policy(mut self, permit_policy: PermitPolicyV1) -> Self {
48        self.permit_policy = permit_policy;
49        self
50    }
51
52    pub fn with_sandbox_root(mut self, sandbox_root: impl Into<String>) -> Self {
53        self.sandbox_root = Some(sandbox_root.into());
54        self
55    }
56}