Skip to main content

codetether_agent/a2a/worker_tool_registry/
safe.rs

1use crate::tool::{ToolRegistry, codesearch, file, lsp, search, skill, todo, webfetch, websearch};
2use std::path::{Path, PathBuf};
3use std::sync::Arc;
4
5/// Register the worker's read-only tools against the current workspace root.
6///
7/// # Examples
8///
9/// ```rust
10/// use codetether_agent::a2a::worker_tool_registry::register_safe_tools;
11/// use codetether_agent::tool::ToolRegistry;
12/// use std::path::PathBuf;
13///
14/// let mut registry = ToolRegistry::new();
15/// let root = PathBuf::from(".");
16/// register_safe_tools(&mut registry, root.as_path(), &root);
17///
18/// assert!(registry.contains("read"));
19/// assert!(registry.contains("todoread"));
20/// ```
21pub fn register_safe_tools(registry: &mut ToolRegistry, workspace_dir: &Path, root_path: &PathBuf) {
22    registry.register(Arc::new(file::ReadTool::new()));
23    registry.register(Arc::new(file::ListTool::new()));
24    registry.register(Arc::new(file::GlobTool::with_root(root_path.clone())));
25    registry.register(Arc::new(search::GrepTool::new()));
26    registry.register(Arc::new(lsp::LspTool::with_root(format!(
27        "file://{}",
28        workspace_dir.display()
29    ))));
30    registry.register(Arc::new(webfetch::WebFetchTool::new()));
31    registry.register(Arc::new(websearch::WebSearchTool::new()));
32    registry.register(Arc::new(codesearch::CodeSearchTool::with_root(
33        root_path.clone(),
34    )));
35    registry.register(Arc::new(todo::TodoReadTool::with_root(root_path.clone())));
36    registry.register(Arc::new(skill::SkillTool::new()));
37}