vtcode_core/tools/registry/
registration_facade.rs1use anyhow::Result;
4
5use super::{ToolRegistration, ToolRegistry};
6
7impl ToolRegistry {
8 pub fn tool_network_access(&self, name: &str) -> super::ToolNetworkAccess {
10 self.inventory
11 .registration_for(name)
12 .map(|registration| registration.metadata().network_access())
13 .unwrap_or_default()
14 }
15 pub async fn register_tool(&self, registration: ToolRegistration) -> Result<()> {
24 let registration = if let Some(mode) = self.current_cgp_mode() {
25 if registration.is_cgp_wrapped() {
26 registration
27 } else if let Some(handler) = self.cgp_handler_for_registration(®istration, mode) {
28 registration.with_handler(handler).with_cgp_wrapped(true)
29 } else {
30 registration
31 }
32 } else {
33 registration
34 };
35 self.inventory.register_tool(registration)?;
36 *self.cached_available_tools.write() = None;
38 self.rebuild_tool_assembly().await;
39 self.tool_catalog_state.note_explicit_refresh("tool_registration");
40 self.sync_policy_catalog().await;
41 Ok(())
42 }
43
44 pub async fn unregister_tool(&self, name: &str) -> Result<bool> {
46 let removed = self.inventory.remove_tool(name)?.is_some();
47 if removed {
48 *self.cached_available_tools.write() = None;
49 self.rebuild_tool_assembly().await;
50 self.tool_catalog_state.note_explicit_refresh("tool_unregistration");
51 self.sync_policy_catalog().await;
52 }
53 Ok(removed)
54 }
55}