# @ycodium-ai/agent-antigravity

Google Antigravity executor plugin. It runs the official Antigravity agent program
(`agy acp`) over Agent Client Protocol stdio, one process per conversation, and runs the
shared `ycodium-acp-executor` state machine.

This plugin is part of the pre-installed set: the Antigravity card appears in the add-provider
list right after install. Add a provider with it, then open the provider: its page has
a section for the downloaded runtime and the Google sign-in (see "The settings
section" below). That section exists on Web and Desktop only; Mobile has no screen for adding or
editing a provider.

## Setting it up

- **Program.** The plugin picks the program in this order: the **program path** field, then the
  runtime the plugin downloaded itself (see below), then the provider's `PATH`. The program is
  the CLI executable. Legacy standalone programs require the companion harness. A path in the field that does not exist is
  reported as an error; it never falls back to the downloaded runtime or `PATH`.
- **Account directory.** Optional. Each provider gets its own private account profile under the
  plugin's data directory, so two providers never share a Google sign-in by accident. Set a
  directory here to share one profile between providers on purpose.
- A session started without a Google sign-in fails with a message that says so.

## The settings section

The provider's page shows two blocks, both for that provider's own instance and on the machine the
provider runs on. Buttons are disabled for read-only viewers.

- **Antigravity runtime.** The state (not installed, the installed version, an update is
  available, the install phase with the downloaded bytes of the total, or why the last attempt
  failed). Before you install or update it states the download size, the installed
  size and the free disk space the install needs. **Remove runtime** asks for confirmation first
  and, when something holds the runtime, stays focusable with a tooltip explaining why.
- **Google sign-in.** The state (not signed in, signed in, or the step in progress). **Sign in with
  Google** starts the flow; while it waits the block shows the sign-in link with **Open** (system
  browser) and **Copy link**, a box to paste the address the browser ended up on with **Finish**,
  the deadline, and **Cancel sign-in**. The CLI accepts the Google sign-in code or redirect URL. **Sign out** asks first because it stops the provider's
  conversations.

Refreshing the model list uses the host's **Refresh model list** action (`refreshModelCatalog`),
which opens a short-lived session and updates the model cache. Sign-in, sign-out and model refresh
all start the program, so while it cannot be found (no runtime installed, no usable program path,
nothing on `PATH`) sign-in and sign-out are disabled and the sign-in block says to install the
runtime or set the program path. `auth.state` carries the reason as `programUnavailable`; the
plugin resolves the program again when the state is subscribed, when the instance is created, and
when the runtime is installed, updated or removed.

Failures arrive with a stable `code`; the section has hand-written English and Simplified Chinese
text for every code it knows and shows the backend's English message for a code it does not.
The add dialog has no instance yet, so there the section is a single hint line.

## The downloaded runtime

The plugin can download Google's official runtime for you, but **only when you ask**: nothing is
downloaded when the plugin loads, when a provider is added, or on a health check. The download
is large, so the state the plugin reports before you start includes the sizes and the free disk
space it needs. The managed release supports Windows x64/arm64, Linux x64/arm64 and macOS arm64.
Opening runtime settings or choosing **Check for updates** reads Google's platform manifest. Install and Update check it again and verify the archive against its SHA-512 before activation. Windows ships an
executable and Unix a single executable in a compressed tar. The installer verifies the file and
checks the staged program's ACP identity before switching versions.

- Files go under `<plugin data>/runtime/<platform>-<arch>/versions/<release id>/`, and
  `active.json` switches to a new version atomically. An update comes from the official release manifest; it installs next to the old version and never touches files a running session uses.
- **Old versions are cleaned up after a successful update.** Once the new version is read back as
  the active one, every other version directory nobody holds is deleted. A version a running
  session still holds is remembered and deleted when its last lease is returned, unless it has
  become the active version again by then. A version a provider's program path points into is left
  alone. A failed update deletes nothing, and a deletion that fails (a locked file, say) is only
  logged: the runtime state is unaffected and the next successful update tries again.
- Each running agent process holds a lease on the version it started with. Removing the runtime is
  refused while a lease is held, while an install is running, and while a provider's program path
  points into the downloaded files.
- Settings uses host maintenance to install and update the managed runtime. The plugin provides download progress, release sizes, checks and removal.

## Signing in

The CLI runs with a private Gemini directory. The settings block starts `acp --login`,
shows the Google link and sends the user's code to that process via stdin. It verifies the sign-in
over ACP and refreshes the model catalog. Legacy standalone programs use the loopback callback.
After upgrading, sign in once in the provider settings.

## Subscription limits and token records

The provider answers the usage page's two reads (ADR-0034 shape; both run only when the user
asks, over the instance's own egress):

- **Remaining allowance (`readQuota`).** Reads `<profile>/antigravity-acp/acp_token.json` — the
  file Google's program wrote at sign-in — and exchanges its refresh token for an access token
  **in memory only**, never writing back (Google does not rotate that token, so the agent's own
  login is untouched). With it the plugin asks both `daily-cloudcode-pa.googleapis.com` and
  `cloudcode-pa.googleapis.com` for `v1internal:retrieveUserQuotaSummary` and keeps each bucket's
  fullest reading; accounts without the summary fall back to `v1internal:fetchAvailableModels`.
  Buckets group as Gemini, Gemini Argon and the shared Claude & GPT allowance, each with a 5-hour
  and a weekly window. A bucket nobody has used reports a rolling full-window "reset"; that is
  suppressed so it does not masquerade as a real reset time. The account key is the hashed Google
  account id, so providers sharing a sign-in collapse into one row.
- **Token records (`readTokenUsage`).** Reads the conversation databases the program keeps in
  `<profile>/antigravity-acp/conversations/*.db` (SQLite, protobuf rows, opened read-only).
  One usage line can appear in the step and the generation table, in a retry, and in copied
  databases; records are merged transitively by the response, request and message ids the agent
  records with each usage. A database file is re-parsed only when it or its `-wal` changed.
  Records outside the requested time window are dropped. Model names follow the agent's own
  spelling, normalized only for pricing (`Gemini 3 Pro` →
  `gemini-3-pro`, `Claude Opus 4.6` → `claude-opus-4-6`); effort-suffixed model ids
  (`gemini-4-argon-high`) are kept as reported, so a rate table without that exact id prices the
  record as unpriced rather than folding it onto the base model.

Both reads report data, not throw, when they cannot complete: no token file is `missingCredentials`,
a refused refresh token is `authRejected`, and unreadable or empty answers are `unreachable`.
The conversation records cover turns run outside Ycodium too, so the usage page counts the whole
account history on that machine; the orchestration ledger never double-counts an Antigravity turn
while a provider on this machine reports records.

### Backend entry points

Plugin commands (all need operate access; payloads carry `instanceId`):
`auth.complete` (`callbackUrl`), `auth.logout`. Stream: `auth.state`.

`auth.complete`, `auth.logout` and every `auth.state` item return
`{ instanceId, phase, operation, authorizationUrl, expiresAt, error, signedIn, programUnavailable }`:

- `phase`: `idle`, `starting`, `waiting` (the link is in `authorizationUrl`), `verifying`,
  `succeeded`, `failed`, `cancelled`.
- `operation`: `sign-in`, `sign-out`, `refresh-models`, or `null` when nothing runs.
- `error`: `null` or `{ code, message }`. Failures also reach command callers as errors carrying
  the same `code`. Codes: `program-unavailable`, `too-many-processes`, `process-exited`,
  `agent-timeout`, `invalid-url`, `multiple-urls`, `expired`, `denied`,
  `subscription-required`, `sign-in-unsupported`, `session-init-failed`, `sign-in-required`,
  `callback-too-long`, `callback-malformed`, `callback-mismatch`, `callback-no-response`,
  `callback-bad-issuer`, `callback-already-sent`, `callback-delivery-failed`,
  `no-active-sign-in`, `sign-in-not-ready`, `logout-unsupported`, `logout-failed`,
  `refresh-failed`, `busy`, `instance-unavailable`, `instance-disposed`, `sign-in-failed`.

## Behaviour worth knowing

- **Uninstalling the plugin keeps what it stored**, including the downloaded runtime (up to
  about 2 GB). Press **Remove runtime** first if you want the disk space back.
- **The health check never starts the agent.** The program is a single-file bundle that unpacks
  about 1 GB on every launch, so the plugin only checks that the files exist on disk and that its
  own signed-in marker is there. The model list and version are cached from the last sign-in,
  model refresh or real session; a provider that has done none of these shows no models.
- **Each process unpacks into its own short temp folder** under the plugin's data directory, which
  is removed when the process ends. Leftovers from a crash are swept the next time the provider is
  created.
- **Permission levels.** The CLI runs in its advertised auto mode for Auto when available, or
  in default mode. The plugin applies the current thread policy to CLI permission requests.
  The standalone program applies its native default, auto_edit and yolo modes.
- **Workspace file reads and writes** go through the client, limited to the conversation's working
  directory (and the attachment folder for reads).
- Choices the agent asks for (`interaction_…` requests) are shown as questions.
- Image attachments are sent as native image blocks (BMP, JPEG, PNG, WebP; 10 MiB each, 50 MiB
  total, declared on the card as `capabilities.inlineImages`). The host passes any image outside
  those facts, such as a GIF or an oversized one, by its file path only instead of failing the turn.
- **Background commands, timers and workflows that outlive a turn are tracked and can be stopped.**
  A `run_command`, `schedule` timer/cron or `run_workflow` run that is still running when a turn
  ends — or that the agent starts during a reactive wakeup with no turn running — is reported as a
  background task (`local_bash`, `monitor` or `local_workflow`) so idle reclamation keeps the
  session alive while it waits. With no turn running, Stop closes that conversation's agent process
  (ending its in-process background work), marks those tasks stopped, and the next message resumes
  the same conversation. Stop during a running turn only cancels that turn, and other conversations
  are never touched.
- **Short generated text.** Conversation titles, branch names, commit messages, pull request
  descriptions and hand-over summaries can be written by Antigravity. Each one runs in its own
  agent process in an empty temporary folder; the agent may only answer, so any tool call, permission
  request, question or file access fails the generation. The folder, the process's temp directory and
  the conversation files the temporary session left in the account directory are removed afterwards.
  It is not available for an account whose `config/hooks.json` or `config/mcp_config.json` (in the
  account directory) is anything but empty, because those run when the agent starts. These processes
  count against the provider's limit of two; when it is reached the generation fails with a message
  saying so. Signing out or removing the provider stops them first.

## Skills

Antigravity looks for personal skills under `GEMINI_HOME`, which the plugin points at the
provider's private account directory. So when a session starts the plugin links that directory's
`config/skills` and `antigravity-cli/skills` back to the same folders under the real
`~/.gemini` (a symlink on macOS and Linux, a junction on Windows, which needs no administrator
rights). MCP configuration, hooks and credentials stay private. A real directory already at a link
path is the user's own and is never replaced; a stale link is repointed; a link that cannot be
made is logged and the session starts without personal skills. The home is resolved from the
program's launch environment (`USERPROFILE` on Windows, `HOME` elsewhere; the provider's
environment variables override the server's).

The health check reports machine-level skills by reading those two roots on disk (no process): a
skill is a folder with a `SKILL.md` whose YAML header has `name` and `description`, a root may
itself hold one `SKILL.md`, the first root wins a duplicate name, and the scan is bounded at 8 MB
of skill text, 10,000 directory entries and 1 MB per file. A scan that runs over budget or cannot
read a folder leaves `skills` out of the result instead of reporting a partial list. Project skills
(`.gemini/skills`, `.agents/skills`, `.agent/skills` under the working directory) are a known gap:
the health check has no working directory, so it does not report them, although the agent itself
loads them. `verifiedSkills` stays `false` on the card.

## Subagents

ACP 1.1.1 presents a subagent launch as an ordinary tool whose title is `Running start_subagent`
(or `Run start_subagent?` while it waits for approval) with kind `other` or none. The plugin
turns it into `task.*` events with `taskType: "subagent"` and the tool call id as `taskId`
instead of drawing a tool row, and does not split the reply around it. A same-named MCP tool
(`_meta.is_mcp_tool_call` true on its first update) is left as an ordinary tool; the plugin decides
that on the first update it sees, because later updates omit `_meta`.

The launch call returns a description of the batch, not a result, so the entry is titled
"Antigravity subagent batch" and stays `running` while the turn runs; only a failed call completes
it. When the turn ends the plugin settles every open batch as `idle` with `timelineBypass` (the
agent panel keeps it, the parent timeline does not) and never as interrupted; a cancelled turn or a
stopped session settles it as `cancelled`, and a turn that fails because the process died as
`failed`. A replayed history sends a completed launch before its result: the plugin waits for the
result and then settles it as `idle` (or `completed` with the error for a failure).

## MCP tool listing

Antigravity CLI enforces an approximately 64 KiB budget on eager MCP tools and packs smaller tools first, which can drop larger core tools on servers such as Ycodium. `agent-antigravity` declares `hostMcpToolListing: "compact"` on its executor card so the Ycodium MCP server lists only the core eager host tools plus `ycodium_tools` and `ycodium_call` on `tools/list`, letting the session discover and invoke remaining host and plugin tools on demand without a local loopback bridge.

## Large tool payloads

Every tool call update is truncated before the shared executor sees it, so event raw payloads are
bounded: strings keep their last 8,000 characters behind a truncation marker; `rawInput`,
`rawOutput` and `_meta` each keep at most 512 nodes and 64,000 characters, `content` 512 nodes and
32,000 characters, nesting stops at twelve levels, image bytes and `data:image` strings are
dropped, and a formatted copy identical to the combined output is not kept twice.

## Runtime checks

CLI 1.5 or later accepts a second prompt in the active turn. The standalone runtime only queues
follow-ups. CLI quota reads use the access token in the provider's own `antigravity-oauth-token`;
the CLI owns refreshing it.

## License

UNLICENSED.
