权限

本页目录

Antigravity 使用统一的细粒度权限引擎,对照拒绝 (Deny)、询问 (Ask) 和允许 (Allow) 访问列表来评估敏感的工具操作。如果您在 Gemini Enterprise 中使用 Antigravity,请参阅 Gemini Enterprise 中的 Antigravity。

Antigravity App

更新后的权限设置

Antigravity 使用强大、统一的权限引擎来保护您的环境,同时支持自主工作流程。Agent 执行的每个敏感操作都表示为格式为 action(target) 的 权限资源。

权限通过三个不同的访问列表评估:

  • 否定:该动作立即被阻止。
  • Ask(询问):Agent 会暂停并提示您明确批准,然后再继续。
  • 允许:允许该操作而不提示。

权限预设方案

权限预设 控制 Agent 操作的批准方式。您配置的允许、拒绝和询问规则位于预设之上,并且始终优先:

预设终端沙箱终端命令文件访问MCP 和网络
请求审查已禁用总是问仅工作区问
Default (default)已启用允许在沙箱中使用;到外面去问工作区+临时目录问
自动已启用Allowed in sandbox; checked automatically outside工作区+临时目录问
Turbo已禁用允许(无限制)完整的文件系统允许

The two presets that use the sandbox work as follows:

  • Default(“在执行敏感操作前询问。”;默认):终端命令在隔离的终端沙箱内运行,访问权限仅限于您的工作区和临时目录,且无网络访问权限。当命令需要网络连接或主机资源时,Agent 会请求在沙箱外运行该命令——除非已被某条 command(...) 允许规则覆盖,否则会弹出提示请求您的批准。
  • Auto(“自动决定是否运行命令。”):命令默认同样在终端沙箱内运行。当命令需要在沙箱外运行时,Antigravity 会自动评估该命令,使安全、可逆的命令无需提示即可运行,而存在风险或不可逆的命令仍会请求您的批准。

Refer to Agent settings for more detail on each preset.

更改权限预设

You can set a preset for all projects, override it for a single project, or switch presets from the message box.

For all projects

若要更改所有项目的预设,请打开 Settings > General > Global Permissions > Permission Preset(如果您可以使用远程 Agent,则为 Permissions > This Computer):

The Permission Preset list open under Global Permissions in Settings > General, with Default checked and the options Request Review, Default, Auto, and Turbo

The checkmark marks your current global preset.

For a single project

To override the global preset for a single project, change the project’s preset under Settings > Projects. New projects default to Inherit Global, which follows your global preset.

From the message box

In v2.23.0+, you can also choose a preset from the permissions picker in the message box:

The permissions picker open above the message box, with Default checked and the options Request Review, Default, Auto, and Turbo

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.

支持的操作与匹配规则

The following table lists the supported permission actions, their target formats, and their default behavior:

操作目标格式默认回退
read_fileread_file(/path)、read_file(dir) 或 read_file(*)Ask(询问)(工作区允许)
write_filewrite_file(/path) 或 write_file(*)Ask(询问)(工作区允许)
read_urlread_url(domain) 或 read_url(*)Ask(询问)
execute_urlexecute_url(domain) 或 execute_url(*)Ask(询问)
download_urldownload_url(domain) or download_url(*)Ask(询问)
commandcommand(prefix)、command(regex:pattern) 或 command(*)Ask (Allowed in sandbox under the Default and Auto presets)
mcpmcp(server/tool)、mcp(server/*) 或 mcp(*)Ask(询问)

Each action matches its target as follows:

  • read_file: Matches absolute paths or paths relative to project workspace roots. Grants recursive read access to all contained files and folders. Using read_file(*) matches all files on the system.
  • write_file: Same as read_file. Implicitly grants read_file for the exact same target path.
  • read_url: Matches hostnames and subdomains (for example, google.com covers mail.google.com). Ignores URL path segments. Using read_url(*) matches any domain.
  • execute_url:涵盖浏览器子 Agent 打开或重定向到某个网域上的页面。匹配主机名和常规子网域并忽略 URL 路径片段,同时按 localhost 隔离 :port(例如,localhost:3000 与 localhost:8080 相互独立),并要求为敏感的 Google 子网域(如 mail.google.com、docs.google.com、drive.google.com 和 console.cloud.google.com)配置显式规则。read_url 授权不包含此权限。
  • download_url:涵盖 Antigravity App 中的内置浏览器 Agent 从某个网域下载文件(在 v2.30.0+ 中可在浏览器操控规则下配置,在 v2.31.0+ 中支持交互式下载提示)。使用与 localhost:port 相同的网域、execute_url 和敏感 Google 子网域匹配规则(data: 和 blob: 下载始终每次询问,且可执行文件或活动标记文件类型会被拦截)。请参阅浏览器使用权限与安全护栏。
  • command: Matches by exact word or token prefix literally by default. To match by regular expression, start the target with the regex: prefix (each whitespace-separated token is evaluated as an anchored regular expression ^(?:pattern)$, for example, command(regex:npm run (build.*))). Covers execution both inside and outside the sandbox.
  • mcp: Matches exact MCP tools or all tools on a specified server (applies equally to local and remote MCP servers). Using mcp(*) matches any tool.
何时需要命令精确匹配

某些 Shell 语法结构可能会在看似无害的前缀背后隐藏任意命令执行——例如命令或进程替换($(...)、反引号、<(...))、算术展开($((...)))、大括号展开({a,b})、非字面量命令名称、网络或文件描述符重定向,以及会执行子命令的开发者工具标志(例如 git -c core.pager=<cmd> 或 tar --to-command)。当 Antigravity 检测到上述任何结构(或无法完整解析该命令)时,会对整行命令行禁用前缀匹配:仅当规则与整行命令逐字符完全匹配(或针对 regex: 规则匹配完整原始命令行)时,命令才会在不提示的情况下运行,否则将回退到 Ask(询问)模式。

标准 shell 组合仍然正常前缀匹配:管道、&&/||/; 链、带引号的文字、纯 $VAR 参数、简单文件重定向和透明包装器(timeout、nohup、nice、 env,其内部命令自行评估)。例如,如果 command(git) 位于允许列表中,则 git status && git log 运行时不会出现提示,而 git log $(whoami) 则会提示批准。

理解跨平台的 read_url 与 execute_url

Antigravity 会在以下三个方面检查 read_url 和 execute_url:

  1. Web page reading: When the agent fetches web page Markdown for research, it checks your read_url grants.
  2. 浏览器子 Agent:当浏览器子 Agent 打开页面或触发文件下载时,它会检查您针对该网域的 execute_url 和 download_url 授权,而非 read_url(并且每次文件上传都需要一次性批准,即使在 Turbo 模式下也是如此)。有关详情,请参阅浏览器使用以及允许列表与拒绝列表。
  3. 终端沙箱:在 read_url 下授予的任何域都会直接编译到沙箱的出站网络白名单中,允许 curl 或 npm 等命令连接到授权主机。
跨平台命令与路径匹配

无论您是在 macOS、Linux 还是 Windows 上开发,Antigravity 都能确保您的权限规则始终如一地发挥作用。在 macOS 和 Linux 上,路径使用标准正斜杠 (/)。在 Windows 上,Antigravity 在规则评估之前自动规范化路径,方法是剥离驱动器号(例如 C:)并将所有反斜杠 (\) 转换为正斜杠 (/)。

隐式权限规则

Antigravity applies the following implicit permission rules:

  • 写意味着读:在路径上允许 write_file 会自动在该路径上授予 read_file。
  • 拒绝读取意味着拒绝写入:拒绝路径上的 read_file 会立即阻止该路径上的 write_file。

交互式权限提示

当 Agent 遇到需要批准的操作(Ask(询问)模式)时,编辑器中会出现一张交互式卡。在单击文件、URL或MCP权限的允许之前,您可以直接编辑提示卡中的目标字符串以扩大授予范围(例如将/project/file.txt这样的单个文件请求扩大到父目录/project)。Antigravity 验证您编辑的目标是否安全地覆盖该操作,并在该回合的剩余时间内应用扩展的授权,从而防止重复提示相关操作。 (注意:终端命令不支持范围编辑)。

终端命令与沙箱机制

在 Auto 和 Default 预设下,Agent 会在隔离的终端沙箱内运行终端命令,默认情况下该沙箱仅能访问您的工作区和系统临时目录,且没有网络访问权限。命令可在沙箱内无需手动批准直接运行,而您的权限授权可进一步调整沙箱的访问范围:

  • read_file 下授予的路径动态填充沙箱的只读文件系统白名单。
  • write_file 下授予的路径动态填充沙箱的读写文件系统白名单。
  • 在 read_url 下授予的域定义出站网络访问策略。

Because some commands cannot run in the sandbox—for example, those requiring network access—the agent can still choose to run commands outside the sandbox:

  • Default(默认):沙箱外的命令会弹出提示请求您的批准,除非已被某条 command 规则允许或拒绝。
  • Auto:Antigravity 会自动评估需要在沙箱外运行的命令,使安全、可逆的命令无需提示即可继续执行,而存在风险或不可逆的命令仍需获得批准。

默认系统行为与安全护栏

当您的“允许”、“拒绝”或“询问”列表中未明确列出某个操作时,Antigravity 将回退到安全系统默认值:

  1. 命令:在 Default 预设下,命令在沙箱内运行时无需提示,在沙箱外运行则需要获得批准。在 Auto 预设下,沙箱外的安全命令无需提示即可运行,而敏感或不可逆的命令则会暂停以等待批准。
  2. 工作区文件:允许在不提示的情况下读取和写入活动项目目录中的文件,而非工作空间文件需要批准。
  3. 网页浏览默认设为询问(Ask):read_url 和 execute_url 的操作默认设为询问(Ask)。除非已配置允许规则,否则 Agent 在读取或打开网页之前会暂停并提示您明确批准。
  4. MCP 工具默认为“询问”:未配置的 MCP 工具调用提示确认批准。

配置示例

以下示例显示了 允许列表 的规则,它定义了在没有提示的情况下运行的操作:

command(git)                             # Standard git commands
command(regex:npm run (build|lint|test)) # Allow safe npm scripts using regex
command(git push)                        # Allow git push, inside or outside the sandbox
read_file(/var/log/app)                  # Read external log paths
write_file(src/)                         # Edit relative src/ folder
read_url(google.com)                     # Fetch Google subdomains
mcp(linter/*)                            # Run linter MCP tools

以下示例显示了 拒绝名单 的规则,它定义了永久阻止的操作:

command(rm -rf)                    # Block destructive deletions
command(regex:curl .*)             # Block unvetted curl downloads
command(sudo)                      # Block sudo privileges
write_file(.git/)                  # Safeguard Git history
write_file(/home/user/.ssh)        # Safeguard SSH keys

以下示例显示了 询问清单 的规则,它定义了暂停以手动确认的操作:

command(*)                         # Prompt all commands
execute_url(aws.amazon.com)        # Prompt before opening AWS pages
mcp(sql/execute_mutation)          # Prompt modifying SQL queries

旧版权限设置

Antigravity 使用强大、统一的权限引擎来保护您的环境,同时支持自主工作流程。Agent 执行的每个敏感操作都表示为格式为 action(target) 的 权限资源。

权限通过三个不同的访问列表评估:

  • 否定:该动作立即被阻止。
  • Ask(询问):Agent 会暂停并提示您明确批准,然后再继续。
  • 允许:允许该操作而不提示。

支持的操作与匹配规则

The following table lists the supported permission actions in the previous permission settings, their target formats, and their default behavior:

操作目标格式默认回退
read_fileread_file(/path)、read_file(dir) 或 read_file(*)Ask(询问)(工作区允许)
write_filewrite_file(/path) 或 write_file(*)Ask(询问)(工作区允许)
read_urlread_url(domain) 或 read_url(*)Ask(询问)
execute_urlexecute_url(domain) 或 execute_url(*)Ask(询问)
download_urldownload_url(domain) or download_url(*)Ask(询问)
commandcommand(prefix)、command(regex:pattern) 或 command(*)Ask(询问)
unsandboxedunsandboxed(prefix)、unsandboxed(regex:pattern) 或 unsandboxed(*)Ask(询问)
mcpmcp(server/tool)、mcp(server/*) 或 mcp(*)Ask(询问)

Each action matches its target as follows:

  • read_file: Matches absolute paths or paths relative to project workspace roots. Grants recursive read access to all contained files and folders. Using read_file(*) matches all files on the system.
  • write_file: Same as read_file. Implicitly grants read_file for the exact same target path.
  • read_url: Matches hostnames and subdomains (for example, google.com covers mail.google.com). Ignores URL path segments. Using read_url(*) matches any domain.
  • execute_url:涵盖浏览器子 Agent 打开或重定向到某个网域上的页面。匹配主机名和常规子网域并忽略 URL 路径片段,同时按 localhost 隔离 :port(例如,localhost:3000 与 localhost:8080 相互独立),并要求为敏感的 Google 子网域(如 mail.google.com、docs.google.com、drive.google.com 和 console.cloud.google.com)配置显式规则。read_url 授权不包含此权限。
  • download_url:涵盖 Antigravity App 中的内置浏览器 Agent 从某个网域下载文件(在 v2.30.0+ 中可在浏览器操控规则下配置,在 v2.31.0+ 中支持交互式下载提示)。使用与 localhost:port 相同的网域、execute_url 和敏感 Google 子网域匹配规则(data: 和 blob: 下载始终每次询问,且可执行文件或活动标记文件类型会被拦截)。请参阅浏览器使用权限与安全护栏。
  • command: Matches by exact word or token prefix literally by default. To match by regular expression, start the target with the regex: prefix (each whitespace-separated token is evaluated as an anchored regular expression ^(?:pattern)$, for example, command(regex:npm run (build.*))).
  • unsandboxed: Matches command prefixes word-by-word literally by default (or with regex:). Commands matching this grant execute outside container isolation when terminal sandboxing is enabled.
  • mcp: Matches exact MCP tools or all tools on a specified server (applies equally to local and remote MCP servers). Using mcp(*) matches any tool.
何时需要命令精确匹配

某些 Shell 语法结构可能会在看似无害的前缀背后隐藏任意命令执行——例如命令或进程替换($(...)、反引号、<(...))、算术展开($((...)))、大括号展开({a,b})、非字面量命令名称、网络或文件描述符重定向,以及会执行子命令的开发者工具标志(例如 git -c core.pager=<cmd> 或 tar --to-command)。在 PowerShell 或命令提示符等 Windows Shell 中,语法无法干净拆分为独立词元的命令也属于此类。当 Antigravity 检测到上述任何结构时,会对整行命令行禁用前缀匹配:仅当规则与整行命令逐字符完全匹配(或针对 regex: 规则匹配完整原始命令行,例如 command(regex:git .*))时,命令才会在不提示的情况下运行,否则将回退到 Ask(询问)模式。

标准 shell 组合仍然正常前缀匹配:管道、&&/||/; 链、带引号的文字、纯 $VAR 参数、简单文件重定向和透明包装器(timeout、nohup、nice、 env,其内部命令自行评估)。例如,如果 command(git) 位于允许列表中,则 git status && git log 运行时不会出现提示,而 git log $(whoami) 则会提示批准。

理解跨平台的 read_url 与 execute_url

Antigravity 会在以下三个方面检查 read_url 和 execute_url:

  1. Web page reading: When the agent fetches web page Markdown for research, it checks your read_url grants.
  2. 浏览器子 Agent:当浏览器子 Agent 打开页面或触发文件下载时,它会检查您针对该网域的 execute_url 和 download_url 授权,而非 read_url(并且每次文件上传都需要一次性批准,即使在 Turbo 模式下也是如此)。有关详情,请参阅浏览器使用以及允许列表与拒绝列表。
  3. 终端沙箱:在沙箱模式下,read_url 下授予的任何域都会直接编译到容器的出站网络白名单 (AllowedDomains) 中,允许 curl 或 npm 等命令连接到授权主机。
跨平台命令与路径匹配

无论您是在 macOS、Linux 还是 Windows 上开发,Antigravity 都能确保您的权限规则始终如一地发挥作用。在 macOS 和 Linux 上,路径使用标准正斜杠 (/)。在 Windows 上,Antigravity 在规则评估之前自动规范化路径,方法是剥离驱动器号(例如 C:)并将所有反斜杠 (\) 转换为正斜杠 (/)。

隐式权限规则

Antigravity applies the following implicit permission rules:

  • 写意味着读:在路径上允许 write_file 会自动在该路径上授予 read_file。
  • 拒绝读取意味着拒绝写入:拒绝路径上的 read_file 会立即阻止该路径上的 write_file。

交互式权限提示

当 Agent 遇到需要批准的操作(Ask(询问)模式)时,编辑器中会出现一张交互式卡。在单击文件、URL或MCP权限的允许之前,您可以直接编辑提示卡中的目标字符串以扩大授予范围(例如将/project/file.txt这样的单个文件请求扩大到父目录/project)。Antigravity 验证您编辑的目标是否安全地覆盖该操作,并在该回合的剩余时间内应用扩展的授权,从而防止重复提示相关操作。 (注意:终端命令不支持范围编辑)。

终端沙箱隔离(预览版)

启用沙箱后,权限授予也适用于命令:

  • read_file 下授予的路径动态填充沙箱的只读文件系统白名单。
  • write_file 下授予的路径动态填充沙箱的读写文件系统白名单。
  • 在 read_url 下授予的域定义出站网络访问策略。

默认系统行为与安全护栏

当您的“允许”、“拒绝”或“询问”列表中未明确列出某个操作时,Antigravity 将回退到安全系统默认值:

  1. 命令默认为询问:未配置的终端命令(command 和 unsandboxed)需要手动批准,除非配置为在设置中不提示的情况下运行。
  2. 工作区文件:允许在不提示的情况下读取和写入活动项目目录中的文件,而非工作空间文件需要批准。
  3. 网页浏览默认设为询问(Ask):read_url 和 execute_url 的操作默认设为询问(Ask)。除非已配置允许规则,否则 Agent 在读取或打开网页之前会暂停并提示您明确批准。
  4. MCP 工具默认为“询问”:未配置的 MCP 工具调用提示确认批准。

配置示例

以下示例显示了 允许列表 的规则,它定义了在没有提示的情况下运行的操作:

command(git)                             # Standard git commands
command(regex:npm run (build|lint|test)) # Allow safe npm scripts using regex
unsandboxed(git push)                    # Allow git push outside sandbox
read_file(/var/log/app)                  # Read external log paths
write_file(src/)                         # Edit relative src/ folder
read_url(google.com)                     # Fetch Google subdomains
mcp(linter/*)                            # Run linter MCP tools

以下示例显示了 拒绝名单 的规则,它定义了永久阻止的操作:

command(rm -rf)                    # Block destructive deletions
command(regex:curl .*)             # Block unvetted curl downloads
command(sudo)                      # Block sudo privileges
write_file(.git/)                  # Safeguard Git history
write_file(/home/user/.ssh)        # Safeguard SSH keys

以下示例显示了 询问清单 的规则,它定义了暂停以手动确认的操作:

command(*)                         # Prompt all commands
execute_url(aws.amazon.com)        # Prompt before opening AWS pages
mcp(sql/execute_mutation)          # Prompt modifying SQL queries

探索相关文档和指南: