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