execute_command
Destructive
Execute shell commands with support for pipes, redirection, and configurable options like working directory, timeouts, and output formats.
Instructions
命令执行:在系统中执行shell命令。支持管道、重定向,集成命令策略评估和sudo配置。
示例:列出文件 { "command": "ls -la", "output_format": "json" } 示例:带工作目录执行 { "command": "npm test", "working_directory": "/project", "timeout_ms": 120000 }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | 要执行的系统命令,支持管道和重定向 | |
| working_directory | No | 工作目录路径,所有相对路径以此为基础解析 | |
| confirm | No | 确认执行高风险命令,需要在 warn 策略下设为 true | |
| timeout_ms | No | 超时时间(毫秒),防止命令长时间阻塞,默认60000 | |
| stdout_max | No | stdout最大输出长度,超出会被截断,默认4000 | |
| stderr_max | No | stderr最大输出长度,超出会被截断,默认2000 | |
| output_format | No | 输出格式:text(纯文本)、json(结构化JSON)、both(两者兼有) |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | 工作目录 | |
| status | No | 执行状态:ok/error/need_confirm | |
| stderr | No | 错误输出 | |
| stdout | No | 标准输出 | |
| command | No | 执行的命令 | |
| exit_code | No | 进程退出码 | |
| truncated | No | 输出是否被截断 | |
| duration_ms | No | 执行耗时(毫秒) |