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