pub struct ShellTool { /* private fields */ }Expand description
Shell 工具:执行系统命令。
支持超时和输出限制,防止命令执行时间过长或输出过大。
§安全机制
- 命令黑名单检查
- 危险操作符检测
- 路径遍历防护
- 安全的环境变量(清除敏感变量)
- 超时和输出大小限制
适用场景:
- 执行系统命令
- 运行脚本
输入格式:
{
"command": "要执行的命令",
"args": ["命令参数"],
"timeout": 60, // 可选,超时时间(秒)
"working_dir": "/path/to/dir" // 可选,工作目录
}Implementations§
Trait Implementations§
Source§impl Tool for ShellTool
impl Tool for ShellTool
Source§fn categories(&self) -> &'static [ToolCategory]
fn categories(&self) -> &'static [ToolCategory]
工具分类 Read more
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
工具输入参数的 schema Read more
Source§fn call<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call<'life0, 'async_trait>(
&'life0 self,
input: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
执行工具 Read more
Source§fn definition(&self) -> ToolDefinition
fn definition(&self) -> ToolDefinition
获取工具定义 (ToolDefinition) Read more
Auto Trait Implementations§
impl Freeze for ShellTool
impl RefUnwindSafe for ShellTool
impl Send for ShellTool
impl Sync for ShellTool
impl Unpin for ShellTool
impl UnsafeUnpin for ShellTool
impl UnwindSafe for ShellTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more