Skip to main content

vtcode_core/tools/registry/
sandbox_facade.rs

1//! Sandbox configuration accessors for ToolRegistry.
2
3use super::ToolRegistry;
4
5pub(super) fn runtime_sandbox_config_default() -> vtcode_config::SandboxConfig {
6    // Keep legacy behavior for registry instances that never receive workspace config.
7    vtcode_config::SandboxConfig {
8        enabled: false,
9        ..Default::default()
10    }
11}
12
13impl ToolRegistry {
14    pub fn apply_sandbox_config(&self, sandbox_config: &vtcode_config::SandboxConfig) {
15        if let Ok(mut guard) = self.runtime_sandbox_config.write() {
16            *guard = sandbox_config.clone();
17        }
18    }
19
20    pub fn sandbox_config(&self) -> vtcode_config::SandboxConfig {
21        self.runtime_sandbox_config
22            .read()
23            .map(|guard| guard.clone())
24            .unwrap_or_else(|_| runtime_sandbox_config_default())
25    }
26}