终端沙箱

本页目录

终端沙箱将 Agent shell 命令隔离在操作系统级容器边界内,以保护您的工作站和敏感文件。

Antigravity App

更新后的权限设置

概览

Antigravity includes a terminal sandbox, enabled by default, that isolates shell commands executed by agents. Sandboxed commands can write to your project folders, temporary directories, and common build caches, and read system directories such as /usr and /etc so your tools keep working. Sensitive files such as ~/.ssh and .env are blocked, anything not explicitly mounted is invisible inside the sandbox, and network access is limited to domains you’ve approved.

沙箱是基于本机操作系统原语构建的,因此无需管理虚拟机或 Docker 映像,也没有启动延迟:

操作系统技术详情
Linux命名空间内核命名空间隔离文件系统、隐藏主机进程并切断网络。
macOSsandbox-execmacOS Seatbelt 配置文件 (SBPL) 会限制文件系统访问与套接字连接。

配置

Your permission preset controls whether the sandbox is used:

预设沙箱 (Sandbox)命令
请求审查关闭总是问
Default (default)开启允许在沙箱中使用;到外面去问
自动开启Allowed in sandbox; safe, reversible commands allowed outside
Turbo关闭无需提示即可允许,不受限制

You can change your preset in three places:

  • 所有项目:打开 Settings > General > Global Permissions > Permission Preset(如果您可以使用远程 Agent,则为 Permissions > This Computer)。
  • For a single project: Override the global preset under Settings > Projects. Projects default to Inherit Global upon creation, which follows your global preset.
  • From the message box (v2.23.0+): Choose a preset from the permissions picker. The picker changes your global preset, or the project’s preset if the project overrides it. To remove a project override, choose Use Global Settings.

请参阅 Agent 权限 了解完整的预设行为,包括文件访问、MCP 工具和网页读取。

非沙箱命令

Some commands cannot work inside the sandbox—for example, those needing network access or talking to system services. The agent can request to run such commands outside the sandbox, where they run on your host with full privileges:

  • Default: Requests to run outside the sandbox always pause for your approval, unless the command is already covered by a command allow or deny rule.
  • Auto(macOS 和 Linux 需 v2.23.0+,Windows 需 v2.26.0+):Antigravity 会自动检查需要在沙箱外运行的命令,使安全、可逆的命令无需提示即可运行,而存在风险或不可逆的命令仍会暂停并等待您的批准(除非已匹配 command 允许或拒绝规则)。

要让特定命令在没有提示的情况下运行(在沙箱内部或外部),请添加 command 允许规则:

command(git push)
command(regex:docker compose .*)

权限集成

沙箱从您的 权限 配置中获取其访问边界:

  • 文件系统:您的项目文件夹以读写方式安装。在默认系统安装之上,read_file 下允许的路径以只读方式安装,write_file 下允许的路径以读写方式安装。其他一切都无法访问。
  • 网络:默认情况下,沙箱命令无需网络访问即可运行。 read_url 下允许的域将添加到沙箱的出站白名单中。

旧版权限设置

概览

Antigravity includes a terminal sandbox that isolates shell commands executed by agents. Sandboxed commands can write to your project folders, temporary directories, and common build caches, and read system directories so your tools keep working. Sensitive files such as .env are blocked, and network access is limited to domains you’ve approved. On macOS and Linux, anything not explicitly mounted is invisible inside the sandbox. On Windows, the sandbox requires Windows 11 24H2 or later with the August 2026 update or later, and folders outside your user profile are readable but not writable inside it.

配置

您可以全局或每个项目配置沙箱。

全局设置

在 设置 > 一般的 中的 Agent 设置 下,配置以下选项:

  • 启用沙箱模式(预览):在沙箱内运行 Agent 终端命令。
  • 终端命令自动执行:设置为在沙箱中继续,让沙箱命令无需批准即可运行;需要在沙箱外运行的命令仍然首先询问。其他选项是 需要审核 和 始终继续。
项目设置

Select a project under Settings > Projects to override these settings for that project. Each setting gains an Inherit Global option, and Enable Sandbox Mode becomes a dropdown: Inherit Global, Enabled, or Disabled.

安全预设方案

同一设置部分中的 安全预设 下拉列表捆绑了终端和文件访问策略:

预设终端命令自动执行文件夹外文件访问
默认值需要审核总是问
整机需要审核允许
涡轮增压模式始终继续允许

所有预设均不会打开沙箱。启用 启用沙箱模式 会将预设切换为 风俗,您可以自己设置每个选项 - 常见的组合是沙箱与 在沙箱中继续。

非沙箱命令

当命令需要在沙箱外部运行时(因为它与 unsandboxed(...) 规则匹配、Agent 请求它或沙箱被禁用),该命令会在您的主机上以完全权限运行。根据您的执行策略,Agent 会首先暂停以等待您的批准。

权限集成

沙箱从您的 权限 配置中获取其访问边界:

  • Filesystem: Your project folders are mounted read-write. Paths allowed under read_file are mounted read-only, and paths allowed under write_file are mounted read-write, on top of the default system mounts. Everything else is inaccessible, except that on Windows, folders outside your user profile stay readable.
  • 网络:启用网络访问时,read_url 下允许的域将添加到沙箱的出站白名单中。
  • Escape hatches (unsandboxed): To let specific commands run outside the sandbox without disabling it entirely, add an unsandboxed allow rule:
    unsandboxed(git push)
    unsandboxed(docker compose .*)

探索相关文档和指南: