Bỏ qua để đến nội dung

Trình đơn

Antigravity

Quyền và sandbox: cấu hình đặt sẵn, quy tắc và sandbox kiểm soát những gì

Trang cơ sở về quyền Antigravity và sandbox terminal: cấu hình quyền của ứng dụng, chế độ thực thi CLI với toolPermission, quy tắc action(target), Deny > Ask > Allow, vị trí quy tắc, phạm vi bảo vệ của sandbox và cách nới quyền tối thiểu.

phút đọc
14
Cấp độ
Trung cấp
Xác minh lần cuối

This page covers both the Antigravity App and the Antigravity CLI (command agy), and each section says which one it applies to; the two use different names, so do not mix them. It is this site’s baseline page for permissions and the terminal sandbox: preset names, mode names, toolPermission values, rule syntax, and sandbox scope are defined here, and other pages link to it. After reading it, you should be able to say who decides whether an operation is denied, asked about, or allowed, write a narrow rule set, and know what the sandbox blocks and what it does not.

This is an independent, unofficial guide and is not affiliated with Google. Where the official pages say nothing, this page says “not documented on the official page” and does not guess. It only says “newer versions” for versions and gives no quota numbers. The example rules and commands were not run; they were only checked against the official pages for structure. Try them in the synthetic repository demo-notes before using them on a real project.

Whether an operation runs is decided by three layers, each answering a different question:

Layer Question it answers In the App In the CLI
Overall autonomy For operations no rule covers, ask or not by default Permission preset Execution mode (agentMode / --mode) plus toolPermission
Specific rules Deny, ask, or allow a particular command, path, domain, or MCP tool allow, deny, and ask rules allow, deny, ask under permissions
Command isolation Once a command is allowed, which files and network it can reach Terminal sandbox, switched on or off by the preset Terminal sandbox: automatic in auto, otherwise enableTerminalSandbox or --sandbox

Rules take priority over presets and modes. The sandbox then wraps an allowed command in system-level isolation. The layers are independent: loosening rules also loosens the sandbox boundary (see “How permissions change the sandbox boundary” below), and a sandbox being on does not make loose rules safe.

Newer versions of the App use a permission preset to decide how terminal commands, file access, MCP tools, and web page reads get approved. The official page lists four:

Preset Terminal sandbox Terminal commands File access MCP and web
Request Review Off Always ask Workspace only Ask
Default (the default) On Run in the sandbox; ask outside it Workspace and temp directories Ask
Auto On Run in the sandbox; outside it Antigravity evaluates automatically: safe, reversible commands run, risky or irreversible ones still ask Workspace and temp directories Ask
Turbo Off All commands run, unrestricted Full filesystem Allowed

Points to note:

  • Default is the default, and it falls back to Request Review when the sandbox is unavailable. The official page says so, so “I am on the default preset” does not guarantee the sandbox is on.
  • Auto has prerequisites. Newer versions offer it on macOS, Linux, and Windows when the sandbox is available. The official page says it is currently not offered to business or enterprise accounts (including Antigravity in Gemini Enterprise). Earlier versions labeled it Auto (Preview); defer to the official page for version numbers.
  • Rules sit on top of the preset and always win. For example, under Request Review your command(git diff) allow rule still lets that command run directly; under Default, an command(rm) ask rule makes even a sandboxed rm ask first.
  • There are three places to switch: globally (Settings > General > Global Permissions, shown as Permissions > This Computer when remote agents are available), per project (Settings > Projects, overriding the global setting; new projects default to Inherit Global), and the permissions picker in the message box (newer versions). The picker changes the global preset, or the project’s preset if the project overrides it; choose Use Global Settings to remove a project override.
  • Under Turbo, every file upload by the browser subagent still needs one-time approval; the official page calls this out. It is the only Turbo exception the page documents, so do not infer others.

For projects and artifacts in the App, see Create a project in the Antigravity App and review artifacts.

The CLI splits “how much autonomy” into two settings, plus two related switches:

Setting Key and flag Values and default
Execution mode agentMode, --mode, /config, Shift + Tab "" (that is, default), accept-edits, auto, plan; newer versions start in auto when it is available, otherwise default
Tool permission toolPermission request-review (default), proceed-in-sandbox, strict, always-proceed
Terminal sandbox enableTerminalSandbox, --sandbox Default false; turned on automatically by auto mode
Non-workspace access allowNonWorkspaceAccess Default false: the agent cannot read or write files outside the active workspace

The four toolPermission values:

Value Meaning (official page)
request-review Ask before running write, shell, or web tools
proceed-in-sandbox Sandboxed commands run automatically; ask when a command needs to run outside the sandbox; behaves like request-review if the sandbox is unavailable
strict Ask before every non-read tool call; overrides auto mode
always-proceed Run all tools without asking; overrides auto mode; --dangerously-skip-permissions also activates it

The four execution modes themselves (default, accept-edits, auto, plan), the Shift + Tab cycle, and the diff review flow are walked through task by task in Your first agent task and are not repeated here. The permission-related relationships:

  • Priority: explicit allow, ask, and deny rules, plus global overrides such as strict and always-proceed, take effect ahead of the mode in every mode. The mode and toolPermission apply only when no rule matches.
  • default and accept-edits both follow toolPermission for commands: by default request-review means every command asks; with proceed-in-sandbox and a working sandbox, sandboxed commands stop interrupting you.
  • auto runs commands in the sandbox and evaluates commands that need to run outside it automatically. It requires a working sandbox and is currently not available for business or enterprise accounts. When unavailable, it does not appear in the Shift + Tab cycle or /config, and setting it runs default; non-interactive agy -p prints a warning and continues in default (see Using agy -p in scripts and CI).
  • The sandbox is not an execution mode and is not in the Shift + Tab cycle.
  • Command-line flags override the settings file: when a flag such as --sandbox or --dangerously-skip-permissions is in effect, /config marks the setting as overridden by the flag, and the session follows the flag until restart.

A minimal CLI setup for “interactive use, sandboxed commands automatic, everything else still asks” (an example; not run):

{
"agentMode": "accept-edits",
"enableTerminalSandbox": true,
"toolPermission": "proceed-in-sandbox",
"permissions": {
"deny": ["command(sudo)", "write_file(.git/)"],
"ask": ["command(git push)"]
}
}

Đối chiếu cùng một ý định trong ứng dụng và CLI

Phần tiêu đề “Đối chiếu cùng một ý định trong ứng dụng và CLI”
What you want App CLI
Ask for every command, sandbox off Request Review toolPermission: request-review, sandbox not enabled
Sandboxed commands run quietly, ask outside Default proceed-in-sandbox plus enableTerminalSandbox (it degrades to ask-for-everything if the sandbox is unavailable)
Automatic judgment outside the sandbox too Auto agentMode: auto
All commands run, no isolation Turbo always-proceed or --dangerously-skip-permissions; see Risks of permissive modes
Ask before all writes and shell operations No equivalent preset documented strict (ask before every non-read call)
Always allow one command command(...) allow rule Same, in permissions.allow
Separate project and global settings Settings > Projects overrides the global setting The Project, Shared, and Global scopes in /permissions

The two sides have no one-to-one names. Do not search the CLI for a preset name, or the App settings for toolPermission.

Every sensitive operation is expressed as action(target). Rules go into three lists, deny, ask, and allow, with Deny > Ask > Allow: when several conflicting rules match one operation, deny is checked first, then ask, and allow last. For example, with command(*) in ask and command(git) in allow, every command still asks. Defaults apply only when no rule matches.

Action Target format Default with no rule Applies to
read_file Path, directory, or * Ask; allowed inside the workspace App, CLI
write_file Path, directory, or * Ask; allowed inside the workspace App, CLI
read_url Domain or * Ask App, CLI
execute_url Domain or * Ask App, CLI
download_url Domain or * Ask Listed on the official page only in the App tab
command Prefix, regex:pattern, or * Ask; allowed in the sandbox under the Default and Auto presets App, CLI
unsandboxed Prefix, regex:pattern, or * Ask Business and enterprise accounts only; other accounts ignore it with a warning and use command
mcp server/tool, server/*, or * Ask App, CLI

How each action matches (official pages):

  • read_file: absolute paths or paths relative to the workspace roots; grants recursive read access to everything beneath; read_file(*) matches all files on the system.
  • write_file: same as read_file, and it implicitly grants read_file on the same path. Conversely, denying read denies write.
  • read_url: matches hostnames and their subdomains (google.com covers mail.google.com) and ignores URL paths; read_url(*) matches any domain.
  • execute_url: covers the browser subagent opening or redirecting to a page on a domain; a read_url grant does not cover it. The App tab says it separates localhost by port and requires explicit rules for sensitive Google subdomains such as mail.google.com, docs.google.com, drive.google.com, and console.cloud.google.com.
  • download_url: covers the App’s built-in browser agent downloading files from a domain; data: and blob: downloads always ask once, and executable or active-markup file types are blocked.
  • command: by default matches word-by-word literal prefixes; to use a regular expression, start the target with regex:, and each whitespace-separated token is evaluated as an anchored ^(?:pattern)$, for example command(regex:npm run (build|lint|test)). It covers execution both inside and outside the sandbox.
  • mcp: matches a specific MCP tool or all tools on a server; local and remote servers are treated alike.
  • Wildcard *: in any action, * matches every target in that action’s namespace. Putting command(*), read_file(*), or mcp(*) into allow opens that whole class of operations; putting it into ask means “ask every time”.

Some shell constructs can hide arbitrary command execution behind an innocent-looking prefix: command and process substitution ($(...), backticks, <(...)), arithmetic contexts, brace expansion, non-literal command names, network or file-descriptor redirections, and developer-tool flags that run subcommands (the official page cites git -c core.pager=<cmd> and tar --to-command). When Antigravity detects any of these, or cannot parse the command cleanly, it turns off prefix matching for the whole command line: the command runs without asking only if a rule matches the full line character for character (for regex: rules, against the full raw line); otherwise it falls back to ask.

Ordinary composition still prefix-matches: pipelines, &&, ||, and ; chains, quoted literals, plain $VAR arguments, simple file redirects, and transparent wrappers such as timeout, nohup, nice, and env (the inner command is judged on its own). The official example: with command(git) in allow, git status && git log runs without asking, while git log $(whoami) asks. In Windows PowerShell and Command Prompt, commands that cannot be cleanly split into words likewise need a whole-line match; to match a command and its subcommands, use regex:, for example command(regex:git .*).

What this means for you: an allow rule is a narrow match, not a contains-match. Do not expect command(git) to allow every form that includes git, and do not use regex:.*-style patterns to get around it.

macOS and Linux use forward slashes. On Windows, Antigravity strips drive letters (such as C:) and converts backslashes to forward slashes before evaluating rules, so write rules with forward slashes and no drive letter.

Location Applies to Notes
App: Settings > General > Global Permissions App The global preset; rules layered on the preset are also managed in App settings, and the exact place in the UI is whatever you see
App: Settings > Projects App A project overrides the global preset; new projects default to Inherit Global
CLI: permissions in ~/.gemini/antigravity-cli/settings.json CLI The official page puts the three lists in this global settings file; /config (alias /settings) also edits settings
CLI: the /permissions panel CLI View, add, and delete rules in the TUI by scope: Project (the active project only; disabled when no project is open), Shared (shared across all Antigravity products), Global (all your sessions)
“Always allow” in a permission prompt CLI (the App’s prompt card can also widen scope) See below
Remote agent sessions CLI and App Permissions use a separate set of remote agent settings and rules that do not inherit local ones; see Should you turn on Remote Control, SSH, or remote agents: risks first

In /permissions, in the rule viewer press A to add, E (or Ctrl + G) to edit, D (or Backspace) to delete; rules must be in action(target) form and are validated on save; ←/→ (or Tab) switch among the allow, deny, and ask tabs. The official pages do not say how rules from the Project, Shared, and Global scopes are merged when they conflict, nor which file paths the Project and Shared scopes correspond to: precedence between scopes is not documented on the official page. Do not base security decisions on it; check the rules in whichever scope you wrote them.

A CLI command prompt offers three ways to approve (official page): this once; always for commands starting with that prefix in this conversation; always for commands starting with that prefix and persist to settings.json. The third creates a lasting rule, so look at /permissions afterwards. Also, before confirming a file, URL, or MCP permission, you can edit the target string in the prompt card to widen the grant (for example, from one file to its directory); the system checks that your edit still covers the current operation and applies it for the rest of the turn. Terminal commands do not support scope editing.

Antigravity also has hooks, which can deny tool calls in PreToolUse, but they are automation added inside the permission system, not the permission system itself; see Run checks before and after tool calls with hooks. For where rules, skills, and MCP must live to be loaded, see Where customization files go.

Sandbox bảo vệ và không bảo vệ những gì

Phần tiêu đề “Sandbox bảo vệ và không bảo vệ những gì”

The terminal sandbox runs the agent’s shell commands inside system-level isolation. According to the official pages:

Aspect Commands inside the sandbox
Write Project folders (the workspace), temp directories, and common build caches
Read System directories (such as /usr and /etc on macOS and Linux), the workspace, and paths you granted with read_file
Blocked Sensitive files such as ~/.ssh and .env are blocked; anything not explicitly mounted is invisible on macOS and Linux
Network No network by default; only domains granted with read_url go on the outbound allowlist
Implementation Kernel namespaces on Linux, sandbox-exec (Seatbelt) on macOS, no virtual machines or Docker images, no startup delay; Windows uses an AppContainer, and the CLI tab says it requires a recent Windows 11

Things the sandbox does not protect, taken from the converse of the official description or from explicit exceptions:

  1. Commands outside the sandbox. A command that needs network access or talks to system services can be requested to run outside the sandbox, where it runs on your host with full privileges and the sandbox no longer applies. Under the Default preset (or CLI modes other than auto) such requests always ask you first, unless a command allow or deny rule covers the command; under Auto, or the CLI’s auto mode, an automatic evaluation decides and safe, reversible ones run without asking.
  2. Commands allowed by an allow rule. A rule such as command(git push) lets the matching command run without asking “inside or outside the sandbox”, as the official page puts it. Allowing command(docker compose .*) allows it to reach things the sandbox cannot manage.
  3. Everything that does not go through the shell. The official page says the sandbox isolates “shell commands”. File reads and writes, web page reads, and MCP tool calls go through permission rules, not the sandbox. From this the page infers: a workspace .env is invisible to sandboxed commands, but the agent’s own file-read tool treats it as “inside the workspace, allowed by default”, so protect it with a read_file deny rule. The official page does not address this point separately, so verify it yourself.
  4. The workspace itself. Project folders are mounted read-write, so the sandbox does not stop an agent from damaging files there; guard against that with Git and diff review, as in Your first agent task.
  5. The complete list of blocked paths. The official pages name only ~/.ssh and .env (with “such as”) and do not give a full list, nor say whether variants such as .env.local or a .env in a nested directory are also blocked: not documented on the official page. Treat them as examples, not a list.
  6. Availability. The sandbox may be unavailable on Windows 10, earlier Windows 11 builds, and Linux hosts or containers that block unprivileged user namespaces. When unavailable, the CLI’s enableTerminalSandbox and --sandbox have no effect, proceed-in-sandbox behaves like request-review, auto is not offered, and /config hides the related options; values saved in your settings file are not rewritten and take effect again once the sandbox is available.

The sandbox boundary is not fixed; it is derived from your permission configuration:

Rule you write Effect inside the sandbox
Workspace folders Mounted read-write
read_file(path) allow The path is mounted read-only
write_file(path) allow The path is mounted read-write
read_url(domain) allow Added to the outbound network allowlist, so commands like curl and npm can reach those hosts
CLI: denied paths Blocked inside the sandbox
Everything else Inaccessible (on Windows, folders outside the user profile stay readable, not writable)

So a read_url(registry.npmjs.org) you add to make npm install work also lets every sandboxed command reach that domain, and read_file(*) makes the whole filesystem visible read-only in the sandbox, removing protection beyond the blocked paths. The wider the grant, the looser the sandbox.

The official permissions and sandbox pages separate “updated permission settings” (the preset system) from “previous permission settings”, and note that business and enterprise accounts use the previous system. Known differences (official pages):

Item Personal accounts (newer versions) Business and enterprise accounts
App permission entry Four permission presets Terminal command auto execution (Require Review, Proceed in Sandbox, Always Proceed), non-workspace file access, and sandbox mode are set separately, with a Security Preset that bundles terminal and file policies
Auto preset and CLI auto mode Offered when the sandbox is available Not offered, including Antigravity in Gemini Enterprise
unsandboxed action Ignored with a warning; use command unsandboxed(...) allows commands to run outside the sandbox; the prompt explicitly labels it a sandbox bypass
Turning the sandbox on On by default under Default Marked as a preview feature and not on by default; none of the Security Presets turns it on, and enabling it switches the preset to Custom
Rule created by “always allow” command(...) unsandboxed(...) for sandbox bypass requests
Always Proceed exception See presets The official page says commands on the Deny list are excluded; all others run without asking

The takeaway: on enterprise or business accounts, do not expect the Auto preset or preset names from the personal-account docs. For telling account types apart, plans, and quotas, see Accounts, plans, and quotas. How administrator policy layers on top of these settings is not described on the official permissions or sandbox pages (they only note that Gemini Enterprise has its own page): not documented on the official page. In managed environments, follow administrator policy and do not try to bypass it.

Khi nào cần nới quyền và cách nới tối thiểu

Phần tiêu đề “Khi nào cần nới quyền và cách nới tối thiểu”

The sandbox and default prompts will make some legitimate tasks fail or interrupt you often. First work out which situation you are in, then choose the narrowest fix:

Symptom Cause Minimal loosening Do not
npm install or pip install cannot connect The sandbox has no network by default Add read_url(domain) only for domains actually needed read_url(*), or jump to Turbo or always-proceed
git push or docker fails in the sandbox Needs network or system services the sandbox cannot provide A precise command(git push) or command(regex:docker compose .*) allow A command(*) allow
Need to read logs or docs outside the workspace Outside the workspace asks by default A specific path such as read_file(/var/log/app); in the CLI you can also edit the prompt card’s target to its directory read_file(*), or turning on allowNonWorkspaceAccess and forgetting about it
Need to write outside the workspace Same write_file(specific directory) (it also implies read) write_file(*)
Build and test commands ask every time toolPermission is request-review With a working sandbox, proceed-in-sandbox; or allow only `command(regex:npm run (build lint
Want fewer prompts That is already the default In the CLI, accept-edits keeps command prompts; in the App, stay on Default Turbo

Order of loosening: loosen one precise rule first and observe; only if that is not enough, loosen the next; consider changing the preset or mode last. Every loosening should come with a written undo method; see Risks of permissive modes. For credentials and .env, see API key safety; examples always use YOUR_API_KEY.

Ví dụ tối thiểu: bộ quy tắc hẹp cho demo-notes

Phần tiêu đề “Ví dụ tối thiểu: bộ quy tắc hẹp cho demo-notes”

Starting material: the synthetic repository demo-notes (README.md, notes/, scripts/check.sh, and a placeholder .env at the repository root containing only API_KEY=YOUR_API_KEY). Allowed changes: only your own CLI settings (back up settings.json first); do not try this on a real project.

Goal: agy can read and write the repository, sandboxed commands run automatically, git diff and the check script run without asking, and git push, .env, and .git/ are protected. In ~/.gemini/antigravity-cli/settings.json (an example; not run):

{
"agentMode": "accept-edits",
"enableTerminalSandbox": true,
"toolPermission": "proceed-in-sandbox",
"permissions": {
"allow": ["command(git diff)", "command(sh scripts/check.sh)"],
"deny": ["command(sudo)", "command(rm -rf)", "write_file(.git/)", "read_file(.env)"],
"ask": ["command(git push)"]
}
}

Verify step by step (check state and /permissions first, then give tasks):

  1. Start agy, run /permissions, and confirm the rules appear in the three tabs of the Global scope; run /config and confirm the sandbox and toolPermission values.
  2. Expected to pass: ask the agent to “run sh scripts/check.sh and report the result”; it should run without a prompt.
  3. Expected to be blocked (verifies deny): ask the agent to “read .env and tell me the contents”; it should be refused (the file has only a placeholder; if the agent got the content, the rule is not working, so check the rule’s scope and spelling).
  4. Expected to ask (verifies ask): ask the agent to “commit and git push”; a command prompt should appear.
  5. Expected to ask (verifies the default): ask the agent to “read a file under /tmp”; outside the workspace it should ask.
  6. When all of that checks out, give a small task using the flow in Your first agent task.

Note that step 3 relies on the inference in point 3 above: read_file(.env) is written relative to the workspace root and covers only the .env at the repository root; a .env in subdirectories, .env.local, and similar need their own rules, and the official page gives no wildcard form, so verify each one.

Counterexample 1: “Commands keep asking, so I will put command(*) in allow.”

That opens the whole command class, so every later command, including rm, curl, and git push, stops asking; sandboxed commands are still confined by the sandbox, but anything outside it has no checkpoint at all. Rewrite: run through a task interactively in a synthetic repository, note which commands were asked about, write only the ones you are sure about as precise rules (command(git diff), command(regex:npm run (build|lint|test))), and put the dangerous ones in deny.

Counterexample 2: “The agent reports a network error, so I will write read_url(*) once and for all.”

No network by default is part of the sandbox’s value; read_url(*) widens the outbound allowlist to every domain, so any sandboxed command can reach any host. Rewrite: write only the domains the task needs, for example one entry for the package registry.

Counterexample 3: “The sandbox is on, so .env is safe.”

The sandbox hides files from sandboxed commands; the agent’s own file-read tool follows permission rules, and the workspace is allowed by default. Rewrite: write a deny rule for .env with read_file(.env), and keep real secrets out of the repository, using only placeholders such as YOUR_API_KEY; see API key safety.

Counterexample 4: “I wrote unsandboxed(git push) and nothing happened.”

The official page says only business and enterprise accounts use unsandboxed; other accounts ignore it with a warning. Rewrite: on a personal account use command(git push).

Counterexample 5: “I added an allow rule in the App, so the CLI has it too.”

The App and CLI store rules in different places, and remote agents have yet another set. Rewrite: check each entry point on its own: use the CLI’s /permissions for the three scopes there, and App settings for presets and project overrides.

  • I can state the preset, or the mode plus toolPermission, for the entry point I am using, without mixing names between the two sides;
  • The sandbox is really on: in the App check the preset (Request Review and Turbo are off), in the CLI check /config or the status; if it is unavailable, I know what it degrades to;
  • Every allow rule is down to a command prefix, a specific path, or a specific domain, with no command(*), read_file(*), write_file(*), read_url(*), or mcp(*);
  • Each path that needs protection (.git/, ~/.ssh, the repository-root .env) has a deny rule that I verified with an “expected to be blocked” task;
  • I checked the rule scopes with /permissions (or App settings) and no lasting rules from “always allow” remain;
  • On enterprise or business accounts, I use the previous settings’ names and do not expect Auto or anything beyond what unsandboxed provides;
  • No real secrets appear in examples, logs, or the repository.
  • A rule has no effect: first check whether a deny or ask rule with higher priority matches the same operation (Deny > Ask > Allow); then check whether the command contains command substitution, redirection, or another construct that triggers a whole-line match; finally check that the rule is in the place your current entry point reads.
  • A command fails in the sandbox: first see whether it is a network or system-service problem; if a domain or precise command rule will do, do not change the mode. When the agent asks to run outside the sandbox, read the command before approving.
  • auto or the sandbox options disappeared: usually the account type or an unavailable sandbox; check the platform notes on the official page and do not loosen permissions to make it reappear.
  • Loosened too far: delete the extra rules in /permissions (CLI) or App settings, set the preset or toolPermission back to Default or request-review, and handle side effects already caused using Git and the checklist in Risks of permissive modes.
  • Points the official page does not document: precedence between scopes, the full list of blocked paths, and how administrator policy layers in managed environments. Do not assume any of them in scripts or team standards; rely on the official pages and your own testing.

Next: to walk through modes and permissions task by task, see Your first agent task; to create a project in the App, see Create a project in the Antigravity App and review artifacts; before turning on auto, Turbo, or always-proceed, read Risks of permissive modes; for allowing things in terminal-less environments, see Using agy -p in scripts and CI; for entry-point differences, see Which Antigravity entry point to choose.