1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Tools façade
//!
//! 此模块由两部分组成:
//! - `echo_execution::tools` 提供共享的 `ToolManager` 与核心工具抽象
//! - 根 crate 下的 `builtin` / `files` / `shell` / `web` / `media` 提供产品层工具
//!
//! 如需直接依赖拆分后的 crate,可使用 [`crate::workspace::execution::tools`]。
//!
//! # 核心类型
//!
//! - [`Tool`]: 工具接口 trait,所有工具必须实现
//! - [`ToolManager`][]: 工具管理器,负责注册和执行
//! - [`ToolResult`][]: 工具执行结果
//! - [`ToolExecutionConfig`][]: 执行配置(超时、重试、并发)
//!
//! # 快速开始
//!
//! ```rust
//! use echo_agent::tools::ToolManager;
//!
//! // 创建工具管理器
//! let manager = ToolManager::new();
//!
//! // 列出已注册工具
//! println!("已注册工具: {:?}", manager.list_tools());
//! ```
//!
//! # 自定义工具
//!
//! ```rust
//! use echo_agent::prelude::*;
//! use futures::future::BoxFuture;
//!
//! /// 简单的计算器工具
//! struct Calculator;
//!
//! impl Tool for Calculator {
//! fn name(&self) -> &str {
//! "calculator"
//! }
//!
//! fn description(&self) -> &str {
//! "执行简单的数学计算"
//! }
//!
//! fn parameters(&self) -> serde_json::Value {
//! serde_json::json!({
//! "type": "object",
//! "properties": {
//! "expression": {
//! "type": "string",
//! "description": "数学表达式,如 '1+2*3'"
//! }
//! },
//! "required": ["expression"]
//! })
//! }
//!
//! fn execute(&self, params: ToolParameters) -> BoxFuture<'_, Result<ToolResult>> {
//! Box::pin(async move {
//! let expr = params.get("expression")
//! .and_then(|v| v.as_str())
//! .unwrap_or("");
//!
//! // 简化示例:只处理加法
//! let result = if expr.contains('+') {
//! let parts: Vec<&str> = expr.split('+').collect();
//! if parts.len() == 2 {
//! let a: i64 = parts[0].trim().parse().unwrap_or(0);
//! let b: i64 = parts[1].trim().parse().unwrap_or(0);
//! Some(a + b)
//! } else {
//! None
//! }
//! } else {
//! None
//! };
//!
//! match result {
//! Some(n) => Ok(ToolResult::success(format!("计算结果: {}", n))),
//! None => Ok(ToolResult::error("不支持的表达式")),
//! }
//! })
//! }
//! }
//!
//! # fn main() {
//! let tool = Calculator;
//! assert_eq!(tool.name(), "calculator");
//! # }
//! ```
/// Built-in tools (security, think, etc.)
/// File manipulation tools
/// Direct re-exports from `echo_execution::tools`.
pub use ;