Skip to main content

vtcode_config/core/
automation.rs

1use crate::constants::{defaults, tools};
2use serde::{Deserialize, Serialize};
3use std::path::PathBuf;
4
5/// Automation-specific configuration toggles.
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7#[derive(Debug, Clone, Deserialize, Serialize, Default)]
8pub struct AutomationConfig {
9    /// Full-auto execution safeguards.
10    #[serde(default)]
11    pub full_auto: FullAutoConfig,
12    /// Session and durable scheduled task controls.
13    #[serde(default)]
14    pub scheduled_tasks: ScheduledTasksConfig,
15}
16
17/// Controls for the built-in scheduled task subsystem.
18#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
19#[derive(Debug, Clone, Deserialize, Serialize)]
20pub struct ScheduledTasksConfig {
21    /// Enable session-scoped `/loop` tasks and durable `vtcode schedule` jobs.
22    #[serde(default = "default_scheduled_tasks_enabled")]
23    pub enabled: bool,
24}
25
26impl Default for ScheduledTasksConfig {
27    fn default() -> Self {
28        Self {
29            enabled: default_scheduled_tasks_enabled(),
30        }
31    }
32}
33
34/// Controls for running the agent without interactive approvals.
35#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
36#[derive(Debug, Clone, Deserialize, Serialize)]
37pub struct FullAutoConfig {
38    /// Enable the runtime flag once the workspace is configured for autonomous runs.
39    #[serde(default = "default_full_auto_enabled")]
40    pub enabled: bool,
41
42    /// Maximum number of autonomous agent turns before the exec runner pauses.
43    #[serde(default = "default_full_auto_max_turns")]
44    pub max_turns: usize,
45
46    /// Allow-list of tools that may execute automatically.
47    #[serde(default = "default_full_auto_allowed_tools")]
48    pub allowed_tools: Vec<String>,
49
50    /// Require presence of a profile/acknowledgement file before activation.
51    #[serde(default = "default_require_profile_ack")]
52    pub require_profile_ack: bool,
53
54    /// Optional path to a profile describing acceptable behaviors.
55    #[serde(default)]
56    pub profile_path: Option<PathBuf>,
57}
58
59impl Default for FullAutoConfig {
60    fn default() -> Self {
61        Self {
62            enabled: default_full_auto_enabled(),
63            max_turns: default_full_auto_max_turns(),
64            allowed_tools: default_full_auto_allowed_tools(),
65            require_profile_ack: default_require_profile_ack(),
66            profile_path: None,
67        }
68    }
69}
70
71fn default_full_auto_enabled() -> bool {
72    false
73}
74
75fn default_scheduled_tasks_enabled() -> bool {
76    false
77}
78
79fn default_full_auto_allowed_tools() -> Vec<String> {
80    vec![
81        tools::READ_FILE.to_string(),
82        tools::UNIFIED_SEARCH.to_string(),
83    ]
84}
85
86fn default_require_profile_ack() -> bool {
87    true
88}
89
90fn default_full_auto_max_turns() -> usize {
91    defaults::DEFAULT_FULL_AUTO_MAX_TURNS
92}