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        if let Ok(mut guard) = self.runtime_sandbox_config.write() {
13            *guard = sandbox_config.clone();
14        }
15    }
16
17    pub fn sandbox_config(&self) -> vtcode_config::SandboxConfig {
18        self.runtime_sandbox_config
19            .read()
20            .map(|guard| guard.clone())
21            .unwrap_or_else(|_| runtime_sandbox_config_default())
22    }
23}