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 { enabled: false, ..Default::default() }
8}
9
10impl ToolRegistry {
11    pub fn apply_sandbox_config(&self, sandbox_config: &vtcode_config::SandboxConfig) {
12        // Recover the guard on poisoning: a poisoned lock must not silently
13        // leave the previous (possibly disabled) sandbox in force.
14        let mut guard = self
15            .runtime_sandbox_config
16            .write()
17            .unwrap_or_else(|poisoned| poisoned.into_inner());
18        *guard = sandbox_config.clone();
19    }
20
21    pub fn sandbox_config(&self) -> vtcode_config::SandboxConfig {
22        self.runtime_sandbox_config
23            .read()
24            .map(|guard| guard.clone())
25            .unwrap_or_else(|_| runtime_sandbox_config_default())
26    }
27}