oxicode_sdk/
tool_factory.rs1use std::path::Path;
4use std::sync::Arc;
5
6use oxicode_agent::{
7 ToolRegistry,
8 tools::{EditTool, LsTool, ReadTool, WriteTool},
9};
10
11pub fn coding_tools(cwd: &Path) -> Arc<ToolRegistry> {
13 let registry = ToolRegistry::new();
14 registry.register(ReadTool::with_cwd(cwd.to_path_buf()));
15 registry.register(WriteTool::with_cwd(cwd.to_path_buf()));
16 registry.register(EditTool::with_cwd(cwd.to_path_buf()));
17 registry.register(LsTool::with_cwd(cwd.to_path_buf()));
18 Arc::new(registry)
19}
20
21pub fn readonly_tools(cwd: &Path) -> Arc<ToolRegistry> {
23 let registry = ToolRegistry::new();
24 registry.register(ReadTool::with_cwd(cwd.to_path_buf()));
25 registry.register(LsTool::with_cwd(cwd.to_path_buf()));
26 Arc::new(registry)
27}
28
29pub fn mcp_tools(
39 cwd: &std::path::Path,
40 config: Option<oxicode_agent::mcp::McpConfig>,
41) -> std::sync::Arc<ToolRegistry> {
42 use oxicode_agent::mcp::{McpDirectTool, McpManager, McpTool};
43
44 let manager = match config {
45 Some(cfg) => McpManager::spawn_with_config(cfg),
46 None => {
47 let _ = cwd; McpManager::spawn()
51 }
52 };
53
54 let registry = ToolRegistry::new();
55
56 for def in manager.direct_tools_from_cache() {
58 registry.register(McpDirectTool::new(manager.clone(), def));
59 }
60
61 if !manager.should_disable_proxy() {
63 registry.register(McpTool::new(manager.clone()));
64 }
65
66 registry.set_mcp_manager(manager);
68
69 std::sync::Arc::new(registry)
70}