Skip to main content

vtcode_core/tools/registry/
commands_facade.rs

1//! Command configuration accessors for ToolRegistry.
2
3use crate::config::CommandsConfig;
4
5use super::ToolRegistry;
6
7impl ToolRegistry {
8    pub fn apply_commands_config(&self, commands_config: &CommandsConfig) {
9        self.inventory.update_commands_config(commands_config);
10        self.pty_sessions
11            .manager()
12            .apply_commands_config(commands_config);
13        match self.shell_policy.write() {
14            Ok(mut shell_policy) => shell_policy.set_commands_config(commands_config),
15            Err(poisoned) => poisoned.into_inner().set_commands_config(commands_config),
16        }
17    }
18
19    pub fn commands_config(&self) -> CommandsConfig {
20        match self.shell_policy.read() {
21            Ok(shell_policy) => shell_policy.commands_config().cloned().unwrap_or_default(),
22            Err(poisoned) => poisoned
23                .into_inner()
24                .commands_config()
25                .cloned()
26                .unwrap_or_default(),
27        }
28    }
29}