exec 命令仅限于沙箱环境。提升模式允许代理突破沙箱,并在其外部运行命令,同时支持可配置的审批门控。
提升模式仅在代理处于沙箱化状态时才会改变行为。对于未沙箱化的代理,exec 已经在宿主机上运行。
指令
通过斜杠命令按会话控制提升模式:
也可使用
/elev on|off|ask|full。
发送不带参数的 /elevated 可查看当前级别。
工作原理
1
检查可用性
必须在配置中启用 elevated,且发送者必须在允许列表中:
2
设置级别
发送仅包含指令的消息以设置会话默认值:或以内联方式使用(仅适用于该消息):
3
在沙箱外运行命令
启用 elevated 后,
exec 调用会离开沙箱。默认情况下,有效主机是
gateway;当配置/会话的 exec 目标为
node 时,有效主机为 node。在 full 模式下,如果解析后的 exec
模式/主机审批策略已经是完全宽松(安全级别 full,ask 为 off),则会跳过 exec 审批;否则仍适用正常的审批策略。在
on/ask 模式下,始终适用已配置的审批规则。解析顺序
- 消息中的内联指令(仅适用于该消息)
- 会话覆盖(通过发送仅包含指令的消息设置)
- 全局默认值(配置中的
agents.defaults.elevatedDefault)
可用性和允许列表
- Global gate:
tools.elevated.enabled(必须为true) - Sender allowlist:
tools.elevated.allowFrom,按频道分别配置列表 - Per-agent gate:
agents.entries.*.tools.elevated.enabled(只能进一步限制;全局和 per-agent gate 都必须为true) - Per-agent allowlist:
agents.entries.*.tools.elevated.allowFrom(发送者必须同时匹配全局 + per-agent) - Channel-provided fallback allowlist: 频道插件可以通过 SDK adapter hook 选择性提供一个回退允许列表,当未配置
tools.elevated.allowFrom.<provider>时使用。目前没有任何内置频道实现这个 hook,因此实际上现在每个 provider 都需要显式配置一个tools.elevated.allowFrom.<provider>条目。 - All gates must pass;否则 elevated 会被视为不可用
elevated does not control
- Tool policy: If the tool policy denies
exec, elevated cannot override it either. - Host selection policy: elevated does not turn
autointo a freely cross-host override. It uses the configured/session exec target rules, and only choosesnodewhen the target is alreadynode. - Separated from
/exec: The/execcommand adjusts the exec defaults for each session for authorized senders (host, security, ask, node), and does not require elevated mode.
The bash chat command (
! prefix; /bash alias) is a separate gate. In addition to its own tools.bash.enabled flag, it also requires tools.elevated to be enabled. Disabling elevated also locks the ! shell command.相关内容
Exec 工具
来自代理的 Shell 命令执行。
Exec 审批
exec 的审批和允许列表系统。沙箱
Gateway 级别的沙箱配置。
沙箱 vs 工具策略 vs 提升模式
工具调用期间这三个门控如何组合。