feat(plugins): carry a Gemini API key to plugin Runners for Google Antigravity (#22930)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Plugin environments (for example, an agent computer) run agents as
plugin Runner tasks. Core sends each task one typed credential.
> - The typed `provider-env` credential carries API keys for Grok,
Copilot and OpenCode. It has no entry for Google Antigravity.
> - So an Antigravity agent cannot get its Gemini API key on a plugin
Runner task. This is gap G3 and work item 1 in the Antigravity Cloud
rollout plan (#22923).
> - This pull request adds `antigravity` to `provider-env`, with the
single variable set `GEMINI_API_KEY`. It follows the Copilot pattern
from #22359.
> - The benefit is that a plugin (for example, the Paperclip Cloud agent
computer) can now accept a Gemini API key for an Antigravity task.
Google sign-in, the plugin-target refusal and the qualification flip
stay out of scope.

## Linked Issues or Issue Description

Refs #22923
Refs #22359

**What problem does this solve?**
A plugin Runner task cannot carry a Gemini API key. `provider-env`
accepts only `grok`, `copilot` and `opencode`, and Core throws "Plugin
Runner does not support the selected credential provider" for
Antigravity.

**Proposed solution**
Add `antigravity: [["GEMINI_API_KEY"]]` to the published key sets and to
the `provider-env` provider enum. Core transfers only that key. Core
refuses a Google sign-in or a missing key with a plain message.

**Alternatives considered**
A new credential type only for Gemini. The generic `provider-env` type
already has the exact-set check, the binding contract and the
cross-check against the Runner's allowlists, so a new type adds no
value.

## What Changed

- `packages/plugins/sdk/src/environment-tasks.ts`:
`ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS` has `antigravity:
[["GEMINI_API_KEY"]]`. The `provider-env` provider enum accepts
`antigravity`. Mixed, partial and extra variable sets stay rejected.
- `server/src/services/native-runtime/plugin-runner-credentials.ts`: for
provider `antigravity`, Core sends only `GEMINI_API_KEY`. Core refuses a
Google sign-in document (`PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`)
or a missing or blank key with "Plugin Runner supports Google
Antigravity only with a Gemini API key. Google sign-in is not
supported." No key value is in any error message.
- Tests: SDK schema cases (accept the key; reject a sign-in document, a
key mixed with a sign-in document, `GOOGLE_API_KEY`, extra routing
variables, empty values, and the key under another provider). Core
transfer and refusal cases. Dispatch only for the matching `antigravity`
harness, with no key in persisted lease metadata or in a worker error. A
Runner check that the Antigravity process gets the key and no `GOOGLE_*`
or other `GEMINI_*` variable.
- Docs: `doc/plugins/PLUGIN_ENVIRONMENT_TASKS.md` and
`doc/plugins/PLUGIN_RUNNER_EXECUTION.md` list the new set, the binding
requirement and the sign-in refusal.
- `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed for the
changed SDK source.

## Verification

- Red first: the new tests failed before the change (the schema rejected
`antigravity`, and Core threw "does not support the selected credential
provider").
- Green after the change:
  - `cd packages/plugins/sdk && npx vitest run tests/` (322 passed)
- `cd server && npx vitest run
src/__tests__/plugin-runner-credential-names.test.ts
src/services/native-runtime/plugin-runner-credentials.test.ts
src/__tests__/environment-task-runtime.test.ts` (94 passed)
- `cd packages/plugins/sdk && npx tsc --noEmit -p .` and `cd server &&
npx tsc --noEmit -p .` (clean)
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`
(no change)
- `pnpm verify` asks for broad CI coverage (exit 2) because an SDK test
file changed. Required CI supplies that coverage.
- No live run. Antigravity on a plugin target stays refused by Core
until a later change lifts that refusal, so this change is not reachable
in a run yet.

## Risks

- Low risk. The change adds one enum value and one key set. Existing
providers keep the same behavior.
- Plugins that validate with an older SDK reject an `antigravity`
credential. This is the expected fail-closed result.
- The key reaches the Runner only through the typed credential. The
Runner still requires a matching `PAPERCLIP_ACPX_CREDENTIAL_BINDING` and
still removes other `GOOGLE_*` and `GEMINI_*` variables.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, file edits) and extended thinking.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 authored and GitHub committed 2026-11-25 07:03:49 -06:00
1 parent 4ade8a9e63
commit 07d444a717
9 files changed
+94 -14

No files matched your search

+12 -6
View File
@@ -77,7 +77,7 @@ The `credential` field has one of these types:
| --- | --- | --- |
| `codex-auth-json` | `authJson`: the selected Codex `auth.json` | `codex` |
| `claude-env` | `environment`: exactly one of `CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY` | `claude` |
| `provider-env` | `provider` and `environment`: one complete variable set for that provider | `grok`, `copilot` or `opencode` |
| `provider-env` | `provider` and `environment`: one complete variable set for that provider | `grok`, `copilot`, `opencode` or `antigravity` |
A `provider-env` credential contains exactly one of these variable sets and no
other variable:
@@ -87,6 +87,7 @@ other variable:
| `grok` | `XAI_API_KEY` |
| `copilot` | `COPILOT_GITHUB_TOKEN` |
| `opencode` | `OPENROUTER_API_KEY`, or `PAPERCLIP_AI_PROVIDER_URL` with `PAPERCLIP_AI_PROVIDER_KEY` |
| `antigravity` | `GEMINI_API_KEY` |
`ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS` exports this list. A server test
checks every set against the names that the Runner forwards to each provider. Every value
@@ -94,17 +95,22 @@ is non-empty and contains no NUL byte. The `provider` always matches the
Runner harness of the task. Set the variables in the environment of the Runner
process. The Runner gives each variable only to its provider.
For `copilot`, also set `PAPERCLIP_ACPX_CREDENTIAL_BINDING` in the Runner
environment. Its value is this JSON object, with the normalized session ID of
the task's PRP identity:
For `copilot` and `antigravity`, also set `PAPERCLIP_ACPX_CREDENTIAL_BINDING`
in the Runner environment. Its value is this JSON object, with the provider as
`agent`, its variable names as `names`, and the normalized session ID of the
task's PRP identity:
```json
{"schema":"paperclip.acpx_credential_binding.v1","agent":"copilot","sessionId":"<normalizedSessionId>","names":["COPILOT_GITHUB_TOKEN"]}
```
The Runner refuses a Copilot token without a matching binding.
The Runner refuses a Copilot token or a Gemini API key without a matching
binding. For `antigravity`, the Runner also removes every other `GOOGLE_*` and
`GEMINI_*` variable before it starts the provider, so a configured variable
cannot redirect the key.
Core does not send a Grok subscription login. A Grok agent must use an xAI API
key in a plugin environment.
key in a plugin environment. Core does not send a Google sign-in yet. A Google
Antigravity agent must use a Gemini API key in a plugin environment.
## Configured environment
+3 -3
View File
@@ -103,11 +103,11 @@ reconciliation for the same task.
## Credentials and tools
Core can transfer a selected Codex account, a direct Claude credential, or the
API credential of a Grok, Copilot or OpenCode connection. See
API credential of a Grok, Copilot, OpenCode or Google Antigravity connection. See
[typed credentials](PLUGIN_ENVIRONMENT_TASKS.md#typed-credentials).
Other managed routes fail closed until they have a typed credential contract.
A Grok subscription login, Claude provider routing, and an OpenCode gateway
without a key also fail closed.
A Grok subscription login, a Google sign-in, Claude provider routing, and an
OpenCode gateway without a key also fail closed.
Do not put credentials in task metadata, journals, logs, or errors.
Assigned MCP tools run through the Core gateway over PRP.