1mod context_server_registry;
2mod copy_path_tool;
3mod create_directory_tool;
4mod delete_path_tool;
5mod diagnostics_tool;
6mod edit_file_tool;
7mod fetch_tool;
8mod find_path_tool;
9mod grep_tool;
10mod list_directory_tool;
11mod move_path_tool;
12mod now_tool;
13mod open_tool;
14mod read_file_tool;
15mod restore_file_from_disk_tool;
16mod save_file_tool;
17mod spawn_subagent_tool;
18
19mod terminal_tool;
20mod thinking_tool;
21mod web_search_tool;
22
23use crate::AgentTool;
24use language_model::{LanguageModelRequestTool, LanguageModelToolSchemaFormat};
25
26pub use context_server_registry::*;
27pub use copy_path_tool::*;
28pub use create_directory_tool::*;
29pub use delete_path_tool::*;
30pub use diagnostics_tool::*;
31pub use edit_file_tool::*;
32pub use fetch_tool::*;
33pub use find_path_tool::*;
34pub use grep_tool::*;
35pub use list_directory_tool::*;
36pub use move_path_tool::*;
37pub use now_tool::*;
38pub use open_tool::*;
39pub use read_file_tool::*;
40pub use restore_file_from_disk_tool::*;
41pub use save_file_tool::*;
42pub use spawn_subagent_tool::*;
43
44pub use terminal_tool::*;
45pub use thinking_tool::*;
46pub use web_search_tool::*;
47
48macro_rules! tools {
49 ($($tool:ty),* $(,)?) => {
50 /// A list of all built-in tool names
51 pub fn supported_built_in_tool_names(provider: Option<language_model::LanguageModelProviderId>) -> impl Iterator<Item = String> {
52 [
53 $(
54 (if let Some(provider) = provider.as_ref() {
55 <$tool>::supports_provider(provider)
56 } else {
57 true
58 })
59 .then(|| <$tool>::name().to_string()),
60 )*
61 ]
62 .into_iter()
63 .flatten()
64 }
65
66 /// A list of all built-in tools
67 pub fn built_in_tools() -> impl Iterator<Item = LanguageModelRequestTool> {
68 fn language_model_tool<T: AgentTool>() -> LanguageModelRequestTool {
69 LanguageModelRequestTool {
70 name: T::name().to_string(),
71 description: T::description().to_string(),
72 input_schema: T::input_schema(LanguageModelToolSchemaFormat::JsonSchema).to_value(),
73 }
74 }
75 [
76 $(
77 language_model_tool::<$tool>(),
78 )*
79 ]
80 .into_iter()
81 }
82 };
83}
84
85tools! {
86 CopyPathTool,
87 CreateDirectoryTool,
88 DeletePathTool,
89 DiagnosticsTool,
90 EditFileTool,
91 FetchTool,
92 FindPathTool,
93 GrepTool,
94 ListDirectoryTool,
95 MovePathTool,
96 NowTool,
97 OpenTool,
98 ReadFileTool,
99 RestoreFileFromDiskTool,
100 SaveFileTool,
101 SpawnSubagentTool,
102 TerminalTool,
103 ThinkingTool,
104 WebSearchTool,
105}