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