mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-27 03:07:57 +01:00
feat(antigravity): allow plugin Runner-task and remote Google sign-in targets once released (#22940)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The native Runner executes Google Antigravity on local hosts, Core managed sandboxes, and plugin Runner-task environments such as Paperclip Computer. > - Before this change, Paperclip refused Google sign-in on all remote targets even after release, returned an unavailable error when testing Antigravity on plugin Runner-task environments, and did not wire remote refresh-token write-back on Core sandboxes or released Antigravity profile resolution. > - Paperclip Cloud needs Google Antigravity to run with both Gemini API keys and Google sign-in on both plugin Runner-task environments and Core managed sandboxes once the profile flips from pending to qualified. > - This pull request lifts the released-state remote sign-in refusal, wires plugin Runner-task probing and released profile resolution for Antigravity, adds Core sandbox remote sign-in write-back and checkpoint exclusion, and keeps pending-release candidate grants restricted to API-key non-plugin targets. > - The benefit is that flipping the Antigravity profile from pending to qualified immediately enables picker selection, agent creation/save, Test probing, and execution with either Gemini API keys or Google sign-in on both plugin Runner-task environments and Core sandboxes. ## Linked Issues or Issue Description - Refs #22923 (Item 6 of `doc/plans/2026-11-25-antigravity-cloud-rollout.md`, gaps G6 and G7) - Pairs with #22933 (Item 2: Antigravity sign-in task credential and plugin write-back) and #22935 (Item 3: keep per-turn-only harnesses per-turn on warm environments) - Refs #22930 (Item 1: Gemini API key task credential for plugin Runners) ## What Changed - **Remote Google sign-in policy & credential preparation (`antigravity-connection-policy.ts`, `antigravity-runner-credentials.ts`)**: - Allow both Gemini API key and Google sign-in on remote targets in `antigravityConnectionRefusal` once `releasePending` is `false`, while keeping `lifecycleMode: "warm"` refused and keeping pending-release candidate grants API-key-only on non-plugin remote targets. - Strip all `GOOGLE_*` and non-selected `GEMINI_*` variables (plus `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET`) in `prepareAntigravityRunnerCredentials`, enforce `antigravityConnectionRefusal` using `antigravityReleasePending()`, and pass pure sanitized sign-in JSON on remote runs (without local `/swarm` metadata). - **Core sandbox remote sign-in write-back & checkpoint safety (`native-credential-store.ts`, `native-session-executor.ts`, `antigravity-runner-credentials.ts`)**: - Extend `createNativeCredentialStore` to support `provider: "antigravity"` (`acp_token.json` and `auth-refresh.json`) over local and remote command runners. - Add optional `runtimeStore` support to `antigravityCredentialTurn` and wire it in `native-session-executor.ts` for Core remote sandboxes so rotated Google refresh tokens copy back after process retirement and remote credential files are scrubbed. - Exclude `antigravity-home/antigravity-acp/{acp_token.json,auth-refresh.json,auth-refresh.json.tmp,logs}` from remote ACPX session checkpoints. - Enforce `antigravityConnectionRefusal` in `preparePluginTaskOwner` and reject pending `pluginTask` execution in `assertAntigravityExecutionAdmissible` (defense in depth). - **Plugin Runner-task probing, released profile resolution & agent save/setup (`provider-profile.ts`, `plugin-runner-probe.ts`, `antigravity-connection-probe.ts`, `agent-environment-test.ts`, `agents.ts`, `NewAgentSetup.tsx`)**: - Add `antigravity` to `DEFAULT_ACPX_RUNNER_MODELS` and the qualified ACPX agent allowlist in `provider-profile.ts`, requiring an explicit non-placeholder model ID and checking `antigravityReleasePending()`. - Wire `testAntigravityConnection` to delegate plugin Runner-task targets to `probePluginRunnerEnvironment` instead of returning `"Google Antigravity is unavailable in this hosting environment."`, and update `probePluginRunnerEnvironment` to run `admissionOnly: true` for Antigravity with either Gemini API key or Google sign-in once released, returning `antigravity_metadata_verified`. - Allow Core sandbox/SSH `probeAntigravityExecutionTarget` for Google sign-in once released, preserve `antigravity_remote_runtime_ready` warn status in `agent-environment-test.ts` and `NewAgentSetup.tsx`. - Allow released Antigravity creation without `enableNativeRunner`, allow released remote sign-in account model discovery on the tenant host, and refuse pending plugin targets even when a `linux-x64` candidate grant exists. - Note on existing >1,000-line files: edits to `server/src/routes/agents.ts` and `server/src/services/native-runtime/native-session-executor.ts` are minimal wiring at existing Antigravity call sites (+12 and +26 net lines). - **Tests**: - Updated `antigravity-runner-credentials.test.ts`, `native-credential-store.test.ts`, `antigravity-save-refusal.test.ts`, `antigravity-connection-probe.test.ts`, `antigravity-release.test.ts`, `adapter-routes.test.ts`, `agent-runner-selection.test.ts`, `agent-environment-test-status.test.ts`, `native-session-executor.test.ts`, and `ui/src/lib/cloud-harness-policy.test.ts`. - Added `server/src/services/native-runtime/plugin-runner-probe-antigravity.test.ts`. ## Verification - Local Vitest (all passed against a released-profile fixture as well as the real pending profile): - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/antigravity-runner-credentials.test.ts src/services/native-runtime/native-credential-store.test.ts src/services/native-runtime/antigravity-release.test.ts src/services/native-runtime/plugin-runner-probe-antigravity.test.ts src/services/native-runtime/plugin-runner-probe-runner-mismatch.test.ts src/services/native-runtime/plugin-runner-credentials.test.ts src/__tests__/antigravity-connection-probe.test.ts src/__tests__/antigravity-save-refusal.test.ts src/__tests__/antigravity-managed-subscription.test.ts src/__tests__/antigravity-plugin-task-credential-writeback.test.ts src/services/agent-runner-selection.test.ts src/services/agent-environment-test-status.test.ts` (12 files, 425 tests passed) - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/adapter-routes.test.ts --hookTimeout=60000` (36 passed) - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/agent-test-environment-routes.test.ts --hookTimeout=60000 -t "passes the selected Antigravity"` (1 passed) - `pnpm --filter @paperclipai/server exec vitest run src/services/native-runtime/native-session-executor.test.ts -t "projects the selected Antigravity subscription"` (2 passed) - `pnpm --filter @paperclipai/ui exec vitest run src/lib/cloud-harness-policy.test.ts` (36 passed) - Typechecks: - `pnpm --filter @paperclipai/server exec tsc --noEmit` (passed) - `pnpm --filter @paperclipai/ui typecheck` (passed) - Not run live: the real Antigravity profile remains `pending` until Item 8; live staging verification on Paperclip Computer and Core managed sandboxes is covered by Item 12. ## Risks - Low risk while the Antigravity profile remains `pending`: all new remote sign-in and plugin Runner-task paths stay gated behind `!antigravityReleasePending()`, and pending-release candidate behavior remains unchanged (and tighter on plugin environments). - Once Item 8 flips the profile to qualified, released Antigravity agents on Core sandboxes and plugin Runner-task environments will use the paths tested here; live acceptance on staging is gated by Items 9–12. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - Google Gemini (Antigravity agent with tool use and code execution) ## 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 - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
aa85bcb518
commit
e04efb9734
22 files changed
+737
-76
No files matched your search
@@ -140,6 +140,8 @@ import * as providerArtifactStorage from "./native-provider-artifacts.js";
|
||||
import * as providerArtifactCapture from "./native-provider-artifact-capture.js";
|
||||
import * as nativeCredentialEvents from "./native-credential-updates.js";
|
||||
import * as nativeCredentialStores from "./native-credential-store.js";
|
||||
import * as antigravityRelease from "./antigravity-release.js";
|
||||
import { ANTIGRAVITY_PATCHED_CLOSURE_SHA256 } from "./remote-provider-pack.js";
|
||||
import * as managedCredentialWriteback from "../managed-ai-credential-writeback.js";
|
||||
import { completeManagedNativeCredentialTurn } from "./managed-native-credentials.js";
|
||||
import * as nativeExecutionDriver from "./native-runner-execution-driver.js";
|
||||
@@ -5308,18 +5310,21 @@ describe("split durable provider checkpoint identity", () => {
|
||||
});
|
||||
|
||||
describe("remote provider checkpoint snapshots", () => {
|
||||
it.each(["codex", "grok"] as const)("excludes %s credentials and handoffs from real checkpoint copies while retaining sessions", async provider => {
|
||||
it.each(["codex", "grok", "antigravity"] as const)("excludes %s credentials and handoffs from real checkpoint copies while retaining sessions", async provider => {
|
||||
const root = await mkdtemp(join(tmpdir(), `${provider}-checkpoint-`));
|
||||
try {
|
||||
const source = join(root, "source");
|
||||
const target = join(root, "backup");
|
||||
const sessionDirectory = acpxRuntimeSessionDirectoryName("session");
|
||||
const relativeHome = join("acpx", sessionDirectory, `${provider}-home`);
|
||||
const relativeHome = provider === "antigravity"
|
||||
? join("acpx", sessionDirectory, "antigravity-home", "antigravity-acp")
|
||||
: join("acpx", sessionDirectory, `${provider}-home`);
|
||||
const primaryToken = provider === "antigravity" ? "acp_token.json" : "auth.json";
|
||||
const home = join(source, relativeHome);
|
||||
await mkdir(join(home, "logs"), { recursive: true });
|
||||
await mkdir(join(home, "sessions"));
|
||||
await writeFile(join(home, "logs", "unified.jsonl"), "AUTH_SENTINEL");
|
||||
await writeFile(join(home, "auth.json"), "AUTH_SENTINEL");
|
||||
await writeFile(join(home, primaryToken), "AUTH_SENTINEL");
|
||||
await writeFile(join(home, "auth-refresh.json"), "AUTH_SENTINEL");
|
||||
await writeFile(join(home, "auth-refresh.json.tmp"), "AUTH_SENTINEL");
|
||||
await writeFile(join(home, "sessions", "session.json"), "resume-state");
|
||||
@@ -5337,7 +5342,7 @@ describe("remote provider checkpoint snapshots", () => {
|
||||
await syncRemoteRunnerDirectoryOut({ runner: { execute, syncOut } as never,
|
||||
sourcePath: source, targetPath: target, mode: 0o700,
|
||||
excludeEntries: profile.directories.find(directory => directory.name === "acpx")!.excludeEntries });
|
||||
for (const entry of ["auth.json", "auth-refresh.json", "auth-refresh.json.tmp", ...(provider === "grok" ? ["logs"] : [])])
|
||||
for (const entry of [primaryToken, "auth-refresh.json", "auth-refresh.json.tmp", ...(provider === "grok" || provider === "antigravity" ? ["logs"] : [])])
|
||||
await expect(access(join(target, relativeHome, entry))).rejects.toMatchObject({ code: "ENOENT" });
|
||||
expect(await readFile(join(target, relativeHome, "sessions", "session.json"), "utf8")).toBe("resume-state");
|
||||
expect(await readFile(join(home, "logs", "unified.jsonl"), "utf8")).toBe("AUTH_SENTINEL");
|
||||
@@ -18605,6 +18610,110 @@ describe("runnerd provider runtime wiring", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("projects the selected Antigravity subscription onto a Core remote sandbox and writes back rotated refreshes over the remote store", async () => {
|
||||
const priorHome = process.env.PAPERCLIP_HOME;
|
||||
const privateRoot = await realpath(isolatedStateDirectory);
|
||||
process.env.PAPERCLIP_HOME = privateRoot;
|
||||
const managedHome = join(privateRoot, "antigravity-remote-managed-home");
|
||||
await mkdir(join(managedHome, "antigravity-acp"), { recursive: true, mode: 0o700 });
|
||||
const credential = (project?: string) => JSON.stringify({
|
||||
client_id: "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com", client_secret: "fixture-client-secret",
|
||||
refresh_token: "fixture-google-refresh", token_uri: "https://oauth2.googleapis.com/token", scopes: ["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/aicode"],
|
||||
...(project ? { project_id: project } : {}),
|
||||
});
|
||||
const managedToken = join(managedHome, "antigravity-acp", "acp_token.json");
|
||||
await writeFile(managedToken, credential(), { mode: 0o600 });
|
||||
const current = { ...execution,
|
||||
provider: { kind: "acpx", agent: "antigravity", model: "caller-selected-model", permissionMode: "deny-all" },
|
||||
session: { ...execution.session, driverKind: "acpx_runtime" },
|
||||
} as unknown as NativeExecutionInputV1;
|
||||
const order: string[] = [];
|
||||
const transportClose = vi.fn(async () => { order.push("transport-close"); });
|
||||
const nativeTransport = { close: transportClose };
|
||||
state.createTransport.mockReturnValueOnce({ transport: nativeTransport } as never);
|
||||
const close = vi.fn(async () => { order.push("session-close"); await nativeTransport.close(); });
|
||||
state.createBackend.mockReturnValueOnce({ kind: "test", openSession: async () => ({ close }) } as never);
|
||||
const remoteStore = {
|
||||
read: vi.fn(async () => { order.push("remote-read"); return credential("rotated-remote-project"); }),
|
||||
remove: vi.fn(async () => { order.push("remote-remove"); }),
|
||||
};
|
||||
const releaseSpy = vi.spyOn(antigravityRelease, "antigravityReleasePending").mockReturnValue(false);
|
||||
const storeSpy = vi.spyOn(nativeCredentialStores, "createNativeCredentialStore").mockReturnValueOnce(remoteStore);
|
||||
const prepareRemoteSpy = vi.spyOn(nativeExecutionDriver, "prepareNativeRemoteRunner").mockResolvedValueOnce(undefined);
|
||||
const execute = vi.fn(async () => ({ exitCode: 0, timedOut: false, stdout: "", stderr: "", signal: null, pid: null, startedAt: null }));
|
||||
const packRoot = join(privateRoot, "antigravity-remote-pack");
|
||||
await mkdir(packRoot, { recursive: true, mode: 0o700 });
|
||||
const digest = "sha256:" + "a".repeat(64);
|
||||
const canonical = (value: unknown): string => Array.isArray(value)
|
||||
? `[${value.map(canonical).join(",")}]`
|
||||
: value && typeof value === "object"
|
||||
? `{${Object.entries(value as Record<string, unknown>).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`
|
||||
: JSON.stringify(value);
|
||||
const artifacts = Object.fromEntries(Object.entries({
|
||||
grokLauncher: "dist/providers/grok/launcher.cjs", nodeCommand: "node_modules/node/bin/node",
|
||||
productionLock: "pnpm-lock.yaml", opencodeCommand: "node_modules/.bin/opencode",
|
||||
opencodeExecutable: "node_modules/opencode-ai/bin/opencode.exe",
|
||||
opencodeProxy: "dist/cli/opencode-app-server-proxy.cjs", acpxSidecar: "dist/cli/acpx-runtime-sidecar.cjs",
|
||||
}).map(([key, path]) => [key, { path, sha256: digest }]));
|
||||
const payload = {
|
||||
compatibility: { opencode: 1, acpx: 1 }, contractDigest: digest,
|
||||
target: { platform: "linux", architecture: "x64" }, runnerSourceRevision: "a".repeat(40),
|
||||
pins: { nodeMinimum: "24.11.0", codex: QUALIFIED_ACPX_PROFILES.codex.agentRuntimeVersion,
|
||||
opencode: "1.18.34", acpx: "0.22.0", grok: QUALIFIED_ACPX_PROFILES.grok.agentRuntimeVersion,
|
||||
claudeAcp: QUALIFIED_ACPX_PROFILES.claude.agentServerVersion, codexAcp: QUALIFIED_ACPX_PROFILES.codex.agentServerVersion },
|
||||
acpxProfileDigests: Object.fromEntries(["grok", "claude", "codex"].map(agent =>
|
||||
[agent, QUALIFIED_ACPX_PROFILES[agent as "grok" | "claude" | "codex"].commandDigest])),
|
||||
distDigest: digest, artifacts,
|
||||
bridgeDigest: "sha256:" + createHash("sha256").update(digest + "\n" + digest + "\n" + digest).digest("hex"),
|
||||
providers: {
|
||||
antigravity: {
|
||||
version: QUALIFIED_ACPX_PROFILES.antigravity.agentServerVersion,
|
||||
profileDigest: QUALIFIED_ACPX_PROFILES.antigravity.commandDigest,
|
||||
closureDigest: `sha256:${ANTIGRAVITY_PATCHED_CLOSURE_SHA256["linux-x64"]}`,
|
||||
qualification: "qualified",
|
||||
path: "provider-assets/antigravity/linux-x64",
|
||||
sha256: digest,
|
||||
},
|
||||
},
|
||||
};
|
||||
const manifest = { schema: "paperclip-runner/remote-provider-pack/v1", payload,
|
||||
digest: "sha256:" + createHash("sha256").update(canonical(payload)).digest("hex") };
|
||||
const previousPackPath = state.bundledPackManifestPath;
|
||||
const previousRunnerBinary = state.bundledRunnerBinary;
|
||||
state.bundledPackManifestPath = join(packRoot, "provider-pack.json");
|
||||
state.bundledRunnerBinary = join(packRoot, "linux-paperclip-runnerd");
|
||||
await writeFile(state.bundledPackManifestPath, JSON.stringify(manifest));
|
||||
const daemon = Buffer.alloc(64); daemon.set([0x7f, 0x45, 0x4c, 0x46, 2, 1]); daemon.writeUInt16LE(62, 18);
|
||||
await writeFile(state.bundledRunnerBinary, daemon);
|
||||
try {
|
||||
const backend = await createRunnerdBackend({ db: leaseDb(current), execution: current,
|
||||
runnerInstanceId: "antigravity-remote-credential-close", managedAiCredentialHome: managedHome,
|
||||
runnerExecutionTarget: { kind: "remote", transport: "sandbox", remoteCwd: "/workspace", runner: { execute } },
|
||||
runnerEnvironment: { GEMINI_HOME: "/ambient", GOOGLE_API_KEY: "ambient-key", PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: "spoofed" } });
|
||||
state.createBackend.mock.calls.at(-1)![1].codexTransportFactory!();
|
||||
const transport = state.createTransport.mock.calls.at(-1)![0];
|
||||
expect(transport.environment!.PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET).toBe(credential());
|
||||
expect(transport.environment?.GEMINI_HOME).toBeUndefined();
|
||||
expect(transport.environment?.GOOGLE_API_KEY).toBeUndefined();
|
||||
const session = await backend.openSession({} as never);
|
||||
expect(storeSpy).toHaveBeenCalledWith(expect.objectContaining({
|
||||
provider: "antigravity",
|
||||
remoteHome: expect.stringMatching(/\/acpx\/acpx\/[^/]+\/antigravity-home\/antigravity-acp$/),
|
||||
}));
|
||||
await session.close({ reason: "completed" });
|
||||
expect(order).toEqual(["session-close", "transport-close", "remote-read", "remote-remove"]);
|
||||
expect(await readFile(managedToken, "utf8")).toBe(credential("rotated-remote-project"));
|
||||
} finally {
|
||||
state.bundledPackManifestPath = previousPackPath;
|
||||
state.bundledRunnerBinary = previousRunnerBinary;
|
||||
releaseSpy.mockRestore();
|
||||
storeSpy.mockRestore();
|
||||
prepareRemoteSpy.mockRestore();
|
||||
if (priorHome === undefined) delete process.env.PAPERCLIP_HOME;
|
||||
else process.env.PAPERCLIP_HOME = priorHome;
|
||||
}
|
||||
});
|
||||
|
||||
it("still cleans up managed Codex credentials after an owned session closes", async () => {
|
||||
const close = vi.fn(async () => undefined);
|
||||
state.copyBackCodexAuth.mockClear();
|
||||
|
||||
Reference in new issue
Block a user