a3s_code_core/tools/builtin/
mod.rs1pub(crate) mod agentic_parse;
10pub(crate) mod agentic_search;
11mod bash;
12pub mod batch;
13mod edit;
14mod git_worktree;
15mod glob_tool;
16mod grep;
17mod ls;
18mod patch;
19mod read;
20mod web_fetch;
21mod web_search;
22mod write;
23
24use super::registry::ToolRegistry;
25use std::sync::Arc;
26
27pub fn register_builtins(registry: &ToolRegistry) {
32 registry.register_builtin(Arc::new(read::ReadTool));
33 registry.register_builtin(Arc::new(write::WriteTool));
34 registry.register_builtin(Arc::new(edit::EditTool));
35 registry.register_builtin(Arc::new(patch::PatchTool));
36 registry.register_builtin(Arc::new(bash::BashTool));
37 registry.register_builtin(Arc::new(grep::GrepTool));
38 registry.register_builtin(Arc::new(glob_tool::GlobTool));
39 registry.register_builtin(Arc::new(ls::LsTool));
40 registry.register_builtin(Arc::new(web_fetch::WebFetchTool));
41 registry.register_builtin(Arc::new(web_search::WebSearchTool));
42 registry.register_builtin(Arc::new(git_worktree::GitWorktreeTool));
43}
44
45pub fn register_batch(registry: &Arc<ToolRegistry>) {
47 registry.register_builtin(Arc::new(batch::BatchTool::new(Arc::clone(registry))));
48}
49
50pub fn register_agentic_tools(
55 registry: &Arc<ToolRegistry>,
56 llm: Option<Arc<dyn crate::llm::LlmClient>>,
57 search_enabled: bool,
58 parse_enabled: bool,
59) {
60 if search_enabled {
61 registry.register_builtin(Arc::new(agentic_search::AgenticSearchTool::new()));
62 }
63 if parse_enabled {
64 let llm_client =
65 llm.expect("agentic_parse requires an LLM client when registered as a built-in tool");
66 registry.register_builtin(Arc::new(agentic_parse::AgenticParseTool::new(llm_client)));
67 }
68}
69
70pub fn register_task(
76 registry: &Arc<ToolRegistry>,
77 llm_client: Arc<dyn crate::llm::LlmClient>,
78 agent_registry: Arc<crate::subagent::AgentRegistry>,
79 workspace: String,
80) {
81 register_task_with_mcp(registry, llm_client, agent_registry, workspace, None);
82}
83
84pub fn register_task_with_mcp(
89 registry: &Arc<ToolRegistry>,
90 llm_client: Arc<dyn crate::llm::LlmClient>,
91 agent_registry: Arc<crate::subagent::AgentRegistry>,
92 workspace: String,
93 mcp_manager: Option<Arc<crate::mcp::manager::McpManager>>,
94) {
95 use crate::tools::task::{ParallelTaskTool, RunTeamTool, TaskExecutor, TaskTool};
96 let executor = Arc::new(match mcp_manager {
97 Some(mcp) => TaskExecutor::with_mcp(agent_registry, llm_client, workspace, mcp),
98 None => TaskExecutor::new(agent_registry, llm_client, workspace),
99 });
100 registry.register_builtin(Arc::new(TaskTool::new(Arc::clone(&executor))));
101 registry.register_builtin(Arc::new(ParallelTaskTool::new(Arc::clone(&executor))));
102 registry.register_builtin(Arc::new(RunTeamTool::new(executor)));
103}
104
105pub fn register_skill(
107 registry: &Arc<ToolRegistry>,
108 llm_client: Arc<dyn crate::llm::LlmClient>,
109 skill_registry: Arc<crate::skills::SkillRegistry>,
110 tool_executor: Arc<crate::tools::ToolExecutor>,
111 base_config: crate::agent::AgentConfig,
112) {
113 use crate::tools::skill::SkillTool;
114 registry.register_builtin(Arc::new(SkillTool::new(
115 skill_registry,
116 llm_client,
117 tool_executor,
118 base_config,
119 )));
120}