Skip to main content

vtcode_core/tool_policy/
alternative.rs

1use indexmap::IndexMap;
2use serde::{Deserialize, Serialize};
3
4use super::ToolConstraints;
5
6/// Alternative tool policy configuration format (user's format)
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct AlternativeToolPolicyConfig {
9    /// Configuration version for future compatibility
10    pub version: u32,
11    /// Default policy settings
12    pub default: AlternativeDefaultPolicy,
13    /// Tool-specific policies
14    pub tools: IndexMap<String, AlternativeToolPolicy>,
15    /// Optional per-tool constraints (ignored if absent)
16    #[serde(default)]
17    pub constraints: IndexMap<String, ToolConstraints>,
18}
19
20/// Default policy in alternative format
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct AlternativeDefaultPolicy {
23    /// Whether to allow by default
24    pub allow: bool,
25    /// Rate limit per run
26    pub rate_limit_per_run: u32,
27    /// Max concurrent executions
28    pub max_concurrent: u32,
29    /// Allow filesystem writes
30    pub fs_write: bool,
31    /// Allow network access
32    pub network: bool,
33}
34
35/// Tool policy in alternative format
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct AlternativeToolPolicy {
38    /// Whether to allow this tool
39    pub allow: bool,
40    /// Allow filesystem writes (optional)
41    #[serde(default)]
42    pub fs_write: bool,
43    /// Allow network access (optional)
44    #[serde(default)]
45    pub network: bool,
46    /// Arguments policy (optional)
47    #[serde(default)]
48    pub args_policy: Option<AlternativeArgsPolicy>,
49}
50
51/// Arguments policy in alternative format
52#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct AlternativeArgsPolicy {
54    /// Substrings to deny
55    pub deny_substrings: Vec<String>,
56}