use crate::env_helpers::default_true;
use serde::{Deserialize, Serialize};
use vtcode_commons::VtCodePaths;
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct GatekeeperConfig {
#[serde(default = "default_true")]
pub warn_on_quarantine: bool,
#[serde(default)]
pub auto_clear_quarantine: bool,
#[serde(default = "default_gatekeeper_auto_clear_paths")]
pub auto_clear_paths: Vec<String>,
}
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SecurityConfig {
#[serde(default = "default_true")]
pub human_in_the_loop: bool,
#[serde(default = "default_true")]
require_write_tool_for_claims: bool,
#[serde(default)]
auto_apply_detected_patches: bool,
#[serde(default)]
pub zero_trust_mode: bool,
#[serde(default)]
encrypt_payloads: bool,
#[serde(default = "default_true")]
pub integrity_checks: bool,
#[serde(default = "default_true")]
pub hitl_notification_bell: bool,
#[serde(default)]
pub gatekeeper: GatekeeperConfig,
}
impl Default for SecurityConfig {
fn default() -> Self {
Self {
human_in_the_loop: default_true(),
require_write_tool_for_claims: default_true(),
auto_apply_detected_patches: false,
zero_trust_mode: true,
encrypt_payloads: true,
integrity_checks: default_true(),
hitl_notification_bell: default_true(),
gatekeeper: GatekeeperConfig::default(),
}
}
}
fn default_gatekeeper_auto_clear_paths() -> Vec<String> {
let mut paths = vec![".vtcode/bin".to_string()];
if let Ok(resolver) = VtCodePaths::resolve() {
paths.push(resolver.executable_dir().display().to_string());
paths.push(resolver.legacy_dir().join("bin").display().to_string());
} else {
paths.push(".local/bin".to_string());
}
paths.sort();
paths.dedup();
paths
}
impl Default for GatekeeperConfig {
fn default() -> Self {
Self {
warn_on_quarantine: default_true(),
auto_clear_quarantine: false,
auto_clear_paths: default_gatekeeper_auto_clear_paths(),
}
}
}