1use std::sync::Arc;
4
5use adk_core::{ReadonlyContext, Result, Tool, Toolset};
6use async_trait::async_trait;
7
8use crate::tools::{
9 ApplyPatchTool, BashTool, EditFileTool, GlobTool, GrepTool, ReadFileTool, WriteFileTool,
10};
11use crate::workspace::Workspace;
12
13pub struct DevToolset {
20 workspace: Workspace,
21 include_bash: bool,
22}
23
24impl DevToolset {
25 pub fn new(workspace: Workspace) -> Self {
27 Self { workspace, include_bash: true }
28 }
29
30 pub fn with_bash(mut self, include: bool) -> Self {
33 self.include_bash = include;
34 self
35 }
36}
37
38#[async_trait]
39impl Toolset for DevToolset {
40 fn name(&self) -> &str {
41 "devtools"
42 }
43
44 async fn tools(&self, _ctx: Arc<dyn ReadonlyContext>) -> Result<Vec<Arc<dyn Tool>>> {
45 let ws = self.workspace.clone();
46 let mut tools: Vec<Arc<dyn Tool>> = vec![
47 Arc::new(ReadFileTool::new(ws.clone())),
48 Arc::new(GlobTool::new(ws.clone())),
49 Arc::new(GrepTool::new(ws.clone())),
50 ];
51 if ws.is_writable() {
52 tools.push(Arc::new(WriteFileTool::new(ws.clone())));
53 tools.push(Arc::new(EditFileTool::new(ws.clone())));
54 tools.push(Arc::new(ApplyPatchTool::new(ws.clone())));
55 }
56 if self.include_bash && ws.bash_allowed() {
57 tools.push(Arc::new(BashTool::new(ws.clone())));
58 }
59 Ok(tools)
60 }
61}