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