功能
Sandbox
Sandbox 限制 Agent process 及其 child process 可以读取、写入的内容和可访问的 network(Linux 使用 Landlock,macOS 使用 Seatbelt)。默认关闭。权限决定工具调用是否运行;sandbox 限制已批准调用可以执行的操作,请参阅权限。
Profiles
| Profile | Filesystem 读取 | Filesystem 写入 | Child network | 使用场景 |
|---|---|---|---|---|
off | 无限制 | 无限制 | 允许 | 无 sandbox(默认) |
workspace | 所有位置 | CWD、~/.grok/、temp | 允许 | 常规开发 |
devbox | 所有位置 | 除 /data 外的顶级目录 | 允许 | Cloud devbox 环境 |
read-only | 所有位置 | 仅 ~/.grok/ 和 temp | 阻止 | Code review、审计 |
strict | CWD 和 system paths | CWD、~/.grok/、temp | 阻止 | 不受信任的 repository |
| 限制 | 详情 |
|---|---|
| Child network | 仅在 Linux 上执行;macOS 对 read-only / strict 无操作 |
| Credentials | 内置配置不会永久保护 ~/.ssh 等路径;请使用自定义 deny list |
~/.grok/ | 在 sandbox profile 下保持可写,以便 session 持久化 |
| In-process network | Model API 和 web tools 不受 child-network 设置阻止 |
启用 Profile
| 机制 | 示例 |
|---|---|
| CLI | grok --sandbox workspace |
| Config | [sandbox] profile = "workspace",位于 ~/.grok/config.toml 中 |
| Env | GROK_SANDBOX=workspace |
| Managed pin | requirements.toml(可以覆盖 CLI),请参阅 Enterprise |
自定义 Profiles
在 ~/.grok/sandbox.toml 或项目 .grok/sandbox.toml 中定义命名 profile:
[profiles.my-profile]
extends = "workspace"
restrict_network = true
deny = ["/secrets", "**/.env", "**/*.pem"]使用 --sandbox my-profile 或 [sandbox] profile 选择。内置名称不能重新定义后用于选择。Field 详情请参阅 Settings Reference。
对于不受信任的目录树,将 strict profile 与范围较窄的 permission allow(或 headless dontAsk)配合使用。