a3s_code_core/tools/builtin/
mod.rs1mod bash;
7pub mod batch;
8mod edit;
9mod generate_object;
10mod git;
11mod glob_tool;
12mod grep;
13mod ls;
14mod patch;
15mod read;
16mod web_fetch;
17mod web_search;
18mod write;
19
20use super::registry::ToolRegistry;
21use std::sync::Arc;
22
23pub fn register_builtins(registry: &ToolRegistry) {
28 registry.register_builtin(Arc::new(read::ReadTool));
29 registry.register_builtin(Arc::new(write::WriteTool));
30 registry.register_builtin(Arc::new(edit::EditTool));
31 registry.register_builtin(Arc::new(patch::PatchTool));
32 registry.register_builtin(Arc::new(bash::BashTool));
33 registry.register_builtin(Arc::new(grep::GrepTool));
34 registry.register_builtin(Arc::new(glob_tool::GlobTool));
35 registry.register_builtin(Arc::new(ls::LsTool));
36 registry.register_builtin(Arc::new(web_fetch::WebFetchTool));
37 registry.register_builtin(Arc::new(web_search::WebSearchTool::new()));
38 registry.register_builtin(Arc::new(git::GitTool));
39}
40
41pub fn register_batch(registry: &Arc<ToolRegistry>) {
43 registry.register_builtin(Arc::new(batch::BatchTool::new(Arc::clone(registry))));
44}
45
46pub fn register_program(registry: &Arc<ToolRegistry>) {
48 register_program_with_catalog(
49 registry,
50 crate::program::ProgramCatalog::with_builtin_programs(),
51 );
52}
53
54pub fn register_program_with_catalog(
56 registry: &Arc<ToolRegistry>,
57 catalog: crate::program::ProgramCatalog,
58) {
59 registry.register_builtin(Arc::new(crate::tools::ProgramTool::with_catalog(
60 Arc::clone(registry),
61 catalog,
62 )));
63}
64
65pub fn register_task(
71 registry: &Arc<ToolRegistry>,
72 llm_client: Arc<dyn crate::llm::LlmClient>,
73 agent_registry: Arc<crate::subagent::AgentRegistry>,
74 workspace: String,
75) {
76 register_task_with_mcp(registry, llm_client, agent_registry, workspace, None);
77}
78
79pub fn register_task_with_mcp(
84 registry: &Arc<ToolRegistry>,
85 llm_client: Arc<dyn crate::llm::LlmClient>,
86 agent_registry: Arc<crate::subagent::AgentRegistry>,
87 workspace: String,
88 mcp_manager: Option<Arc<crate::mcp::manager::McpManager>>,
89) {
90 use crate::tools::task::{ParallelTaskTool, TaskExecutor, TaskTool};
91 let executor = Arc::new(match mcp_manager {
92 Some(mcp) => TaskExecutor::with_mcp(agent_registry, llm_client, workspace, mcp),
93 None => TaskExecutor::new(agent_registry, llm_client, workspace),
94 });
95 registry.register_builtin(Arc::new(TaskTool::new(Arc::clone(&executor))));
96 registry.register_builtin(Arc::new(ParallelTaskTool::new(Arc::clone(&executor))));
97}
98
99pub(crate) fn register_skill(
101 registry: &Arc<ToolRegistry>,
102 llm_client: Arc<dyn crate::llm::LlmClient>,
103 skill_registry: Arc<crate::skills::SkillRegistry>,
104 tool_executor: Arc<crate::tools::ToolExecutor>,
105 base_config: crate::agent::AgentConfig,
106) {
107 use crate::tools::skill::{SearchSkillsTool, SkillTool};
108 registry.register_builtin(Arc::new(SearchSkillsTool::new(Arc::clone(&skill_registry))));
109 registry.register_builtin(Arc::new(SkillTool::new(
110 skill_registry,
111 llm_client,
112 tool_executor,
113 base_config,
114 )));
115}
116
117pub fn register_generate_object(
122 registry: &Arc<ToolRegistry>,
123 llm_client: Arc<dyn crate::llm::LlmClient>,
124) {
125 registry.register_builtin(Arc::new(generate_object::GenerateObjectTool::new(
126 llm_client,
127 )));
128}