Shell 工具
代码模式可在工作区内执行命令。办公模式不提供 Shell。
主要工具
| 工具 | 行为 |
|---|---|
exec_shell |
执行命令(前台或后台) |
exec_shell_wait / exec_wait |
等待后台任务 |
exec_shell_interact / exec_interact |
向运行中进程发送 stdin |
exec_shell_cancel |
取消后台 shell |
task_shell_start / task_shell_wait |
长任务辅助 |
输出进入工具结果,并常同步到内嵌终端。
审批
多数非常规命令会弹出审批对话框。安全前缀字典可在策略允许时自动放行常见开发命令(cargo test、npm run 等)。
安全(Windows v0.7.4+)
在 Windows 上,exec_shell 默认走 Windows 原生沙箱,而非以你的完整用户权限裸跑:
| 模式 | 行为摘要 |
|---|---|
| Elevated(推荐) | 工作区外不可写;profile 敏感目录不可读;默认 WFP 阻断出站;支持 ConPTY 交互终端 |
| Unelevated | 工作区写隔离 + 尽力网络限制;无 profile 读隔离 |
工具结果含 sandbox_enforced、windows_sandbox_mode 等元数据;未强制时 stderr 会有警告。
- 破坏性命令(删系统目录等)仍应被策略拒绝。
- 可选 OpenSandbox 外部后端见执行策略。
- Linux 当前为 degraded(策略声明、OS 未强制)。
建议
- 首次使用代码模式前完成沙箱向导。
- 优先用
run_tests、cargo check等专用工具。 - 起服务(
npm run dev)用后台exec_shell+exec_shell_wait。
相关:Windows 沙箱 · 文件工具 · CRAFT