mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 18:35:33 +01:00
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:
1 parent
4ade8a9e63
commit
07d444a717
9 files changed
+94
-14
No files matched your search
@@ -40,6 +40,36 @@ describe("plugin Runner selected credentials", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("plugin Runner Google Antigravity credentials", () => {
|
||||
const signIn = "{\"refresh_token\":\"fixture-refresh\"}";
|
||||
it("transfers only the selected Gemini API key", async () => {
|
||||
const transfer = await preparePluginRunnerCredentials({ provider: "antigravity", identity: "revision", accountIdentity: "account",
|
||||
environment: { GEMINI_API_KEY: "fixture-gemini", GOOGLE_API_KEY: "fixture-google", GOOGLE_APPLICATION_CREDENTIALS: "/controller/private/adc.json",
|
||||
GOOGLE_GEMINI_BASE_URL: "https://router.example.test", GEMINI_HOME: "/controller/private/gemini", XAI_API_KEY: "fixture-xai",
|
||||
HOME: "/controller/private", OTHER_SECRET: "fixture-unrelated" } });
|
||||
expect(transfer).toEqual({ accountIdentity: "account", credential: { type: "provider-env", provider: "antigravity", environment: { GEMINI_API_KEY: "fixture-gemini" } } });
|
||||
expect(transfer.needsWriteback).toBeUndefined();
|
||||
expect(transfer.onCredentials).toBeUndefined();
|
||||
});
|
||||
it.each([
|
||||
["a Google sign-in", { PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: signIn }],
|
||||
["a Google sign-in beside a Gemini API key", { GEMINI_API_KEY: "fixture-gemini", PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: signIn }],
|
||||
["no key", {}],
|
||||
["an empty key", { GEMINI_API_KEY: "" }],
|
||||
["a blank key", { GEMINI_API_KEY: " " }],
|
||||
["only a Google API key", { GOOGLE_API_KEY: "fixture-google" }],
|
||||
] as const)("refuses %s because only a Gemini API key can be transferred", async (_name, environment) => {
|
||||
const result = preparePluginRunnerCredentials({ provider: "antigravity", identity: "revision", environment });
|
||||
await expect(result).rejects.toThrow("Google Antigravity only with a Gemini API key");
|
||||
await result.catch((error: Error) => expect(error.message).not.toContain("fixture"));
|
||||
});
|
||||
it("fails closed for an invalid Gemini API key without echoing it", async () => {
|
||||
const result = preparePluginRunnerCredentials({ provider: "antigravity", identity: "revision", environment: { GEMINI_API_KEY: "fixture\0gemini" } });
|
||||
await expect(result).rejects.toThrow("Plugin Runner selected credential unavailable");
|
||||
await result.catch((error: Error) => expect(error.message).not.toContain("fixture"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("plugin Runner provider environment credentials", () => {
|
||||
const blanks = { XAI_API_KEY: "", COPILOT_GITHUB_TOKEN: "", OPENROUTER_API_KEY: "", PAPERCLIP_AI_PROVIDER_URL: "", PAPERCLIP_AI_PROVIDER_KEY: "",
|
||||
ANTHROPIC_API_KEY: "", HOME: "/controller/private", GROK_HOME: "/controller/private/provider", OTHER_SECRET: "fixture-unrelated" };
|
||||
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
} from "@paperclipai/plugin-sdk";
|
||||
import { readLocalAiCredentialFile } from "../local-ai-credential-file.js";
|
||||
|
||||
const ANTIGRAVITY_SIGN_IN_ENV = "PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET";
|
||||
|
||||
interface PreparedPluginRunnerCredentials {
|
||||
githubBroker?: { url: string; token: string };
|
||||
accountIdentity?: string;
|
||||
@@ -51,12 +53,15 @@ export async function preparePluginRunnerCredentials(input: {
|
||||
.flatMap(key => input.environment[key] ? [[key, input.environment[key]]] : []));
|
||||
return { ...github, accountIdentity, credential: environmentTaskCredentialSchema.parse({ type: "claude-env", environment }) };
|
||||
}
|
||||
if (input.provider === "grok" || input.provider === "copilot" || input.provider === "opencode") {
|
||||
if (input.provider === "grok" || input.provider === "copilot" || input.provider === "opencode" || input.provider === "antigravity") {
|
||||
const provider: PluginEnvironmentTaskCredentialProvider = input.provider;
|
||||
if (provider === "grok") {
|
||||
if (input.environment.XAI_BASE_URL) throw new Error("Plugin Runner does not support the selected provider routing");
|
||||
if (!input.environment.XAI_API_KEY) throw new Error("Plugin Runner supports Grok only with an xAI API key. Grok subscription login is not supported.");
|
||||
}
|
||||
if (provider === "antigravity" && (input.environment[ANTIGRAVITY_SIGN_IN_ENV] || !input.environment.GEMINI_API_KEY?.trim())) {
|
||||
throw new Error("Plugin Runner supports Google Antigravity only with a Gemini API key. Google sign-in is not supported.");
|
||||
}
|
||||
const names = new Set(ENVIRONMENT_TASK_PROVIDER_CREDENTIAL_KEY_SETS[provider].flat());
|
||||
const environment = Object.fromEntries([...names]
|
||||
.flatMap(key => input.environment[key] ? [[key, input.environment[key]]] : []));
|
||||
|
||||
Reference in new issue
Block a user