mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 01:24:30 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - Paperclip Runner executes native ACPX providers using release-verified profiles, capability declarations, and provider packs > - Google Antigravity is wired across Runner, server routes, UI pickers, and remote provider packs, but its ACPX profile remained `qualificationStatus: "pending"` behind operator candidate grants > - The owner waived the paid-key `runner-e2e-paid` gate on 2026-11-25 so Google Antigravity can ship to staging and be tested there live > - This pull request flips the Google Antigravity ACPX profile from `pending` to `qualified` (profile revision 2), updates its capability declaration while keeping `recovery: "unverified"`, enables ordinary server/UI/pack admission without candidate grants, and updates tests and qualification docs honestly > - The benefit is that Google Antigravity enters the default `linux-x64` remote provider pack and ordinary board setup/execution flows on staging, while candidate-era v1 saved sessions are cleanly rejected and unverified recovery/paid-key evidence remains honestly labeled ## Linked Issues or Issue Description Refs #22923 Refs #22935 (merge after #22935 `fix/per-turn-harness-on-warm-environment`) **What existing behavior does this improve?** Google Antigravity native ACPX profile qualification, remote provider-pack assembly, and Paperclip Runner agent setup/admission across `packages/paperclip-runner`, `packages/adapter-utils`, `packages/adapters/codex-local`, `server`, `ui`, and `tests/runner-e2e`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** `packages/paperclip-runner/acpx-profiles.json` declares `antigravity` at `agentProfileVersion: 1` with `qualificationStatus: "pending"`. `PAPERCLIP_RUNNER_ACPX_PROFILES` marks `antigravity.qualified = false`, remote `linux-x64` provider packs exclude Antigravity unless built with `--candidate-providers=antigravity`, and server/Runner admission requires a short-lived operator candidate grant. **Proposed behavior** Remove `qualificationStatus: "pending"` from `antigravity` and bump `agentProfileVersion` from `1` to `2` so candidate-era v1 saved state is refused permanently as `provider_state_incompatible`. Flip `PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`, mark `ACPX_CAPABILITY_PROFILES.antigravity` as `qualified` with `models: "explicit-provider-verified"` while keeping `recovery: "unverified"`, require an explicit provider model in config builders and server validation, and admit qualified Antigravity through the ordinary ACPX path without candidate grants. **Reason and benefit** Unblocks staging deployment and live testing of Google Antigravity under the 2026-11-25 owner waiver of `runner-e2e-paid`, including default `linux-x64` provider pack inclusion (local `darwin-arm64` continues to use `paperclipai runtime setup antigravity`). **Breaking changes** Any candidate-era v1 Google Antigravity saved session state is intentionally refused as `provider_state_incompatible` due to the `agentProfileVersion` bump (`1` -> `2`). ## What Changed - **Runner profile & generated contracts**: - `packages/paperclip-runner/acpx-profiles.json`: removed `qualificationStatus: "pending"` on `antigravity` and bumped `agentProfileVersion` from `1` to `2`. - Regenerated `packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts` and `packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs` (`qualification_pending: false`). - `packages/paperclip-runner/src/drivers/acpx/capability-profiles.ts`: set `antigravity.qualification` to `"qualified"` and `models` to `"explicit-provider-verified"` when released; kept `recovery: "unverified"` (never claiming `session-load` without live proof). - **Adapter utils & config builder**: - `packages/adapter-utils/src/paperclip-runner-permissions.ts`: flipped `PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`. - `packages/adapters/codex-local/src/ui/build-config.ts`: added `"antigravity"` to the explicit-provider-model validation check. - **Server admission & routes**: - `server/src/services/native-runtime/provider-profile.ts`: added `antigravity: null` to `DEFAULT_ACPX_RUNNER_MODELS`, included `antigravity` in explicit-model-required and qualified ACPX checks. - `server/src/services/native-runtime/acpx-qualification.ts`: short-circuited `resolveAntigravityCandidateAdmission` to return `undefined` once `qualificationStatus !== "pending"`. - `server/src/routes/agents.ts`: allowed qualified `antigravity` without `experimental.enableNativeRunner` (matching Copilot and UI rules), preserved empty model on provisional setup draft transitions, and allowed `setupOnly` draft creation before model selection. - **Tests**: - Updated Runner TS/Rust tests (`profile-compatibility.test.ts`, `candidate-provider-pack.test.mjs`, `release-provider-pack.test.mjs`, `antigravity-provider-pack-smoke.test.mjs`, `candidate-admission*.test.ts`, `antigravity-models.test.ts`, `acpx-runtime-sidecar.test.ts`, `runner-core` Rust unit/integration tests). - Updated `@paperclipai/adapter-utils`, `@paperclipai/adapter-codex-local`, `@paperclipai/server`, `@paperclipai/ui`, and `tests/runner-e2e` (`catalog.test.ts`, `controller-rolling-deployment.test.ts`) tests for qualified Antigravity behavior. - **Documentation & maps**: - `doc/plans/2026-11-22-antigravity-qualification.md`, `doc/plans/2026-11-25-antigravity-cloud-rollout.md`, and `packages/paperclip-runner/README.md`: recorded the 2026-11-25 owner waiver of `runner-e2e-paid` for staging verification while keeping all `NOT RUN` paid-key rows honestly marked `NOT RUN` / deferred. - Minimal in-place accuracy updates in `maps/feature-map/instance-operations.md` and `maps/agent-access-map/instance-operations.md` (`node scripts/check-maps.mjs` passing). ## Verification - `pnpm --filter @paperclipai/paperclip-runner build` (TS + Rust release binary + `check:acpx-profiles`, `generate-antigravity-models --check`, `check:protocol-types`, capability/attestation/traceability/replay-golden checks) — passed. - `pnpm --filter @paperclipai/paperclip-runner test:typescript:prep` (468 tests) and focused Runner Vitest suites (`acpx-runtime-sidecar.test.ts` 127/127, `antigravity-models.test.ts` 22/22, `candidate-admission*.test.ts`, `profile-compatibility.test.ts`, `runnerd-codex-transport-antigravity-release.test.ts`, pack script tests) — passed. - Rust tests in `packages/paperclip-runner/runner`: `cargo fmt --all -- --check`, `paperclip_process_table` (3/3), `paperclip_runner_core --lib` (670/670, skipping macOS-incompatible `task_memory::tests::monitor_*`), `paperclip-runnerd` bin tests (11/11), and `acpx_provider_resolutions` (12/12) — passed. - `packages/adapter-utils` (`paperclip-runner-permissions.test.ts` 50/50) and `packages/adapters/codex-local` (`build-config.test.ts` 64/64) — passed. - `scripts/__tests__/prepare-runner-release-image.test.mjs`, `node scripts/check-maps.mjs`, and `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` — passed. - Server suites: `adapter-routes.test.ts` (36/36), `registry.test.ts` (67/67), `agent-adapter-validation-routes.test.ts` (`Antigravity|YAML`), `antigravity-connection-probe.test.ts`, `antigravity-save-refusal.test.ts`, `antigravity-release.test.ts` (10/10), `acpx-qualification.test.ts` (39/39), `antigravity-candidate-admission.test.ts`, `remote-provider-pack.test.ts` (60/60), `native-session-executor.test.ts` (`Antigravity|provider pack`), `plugin-runner-credentials.test.ts`, `plugin-runner-credential-names.test.ts`, `antigravity-plugin-task-credential-writeback.test.ts` — passed. - CLI (`runtime.test.ts`, `runtime-setup.test.ts` 15/15), UI (6 Antigravity/setup suites 58/58 + `AgentConfigForm.render.test.tsx`), and `tests/runner-e2e` (`catalog.test.ts`, `controller-rolling-deployment.test.ts`, `antigravity-qualification.test.ts`, `eval-gateway-drain.test.ts`, and 690+ unit files) — passed. - Typechecks: `@paperclipai/adapter-utils`, `@paperclipai/adapter-codex-local`, `@paperclipai/paperclip-runner`, `@paperclipai/server` (all 7 layers), `@paperclipai/ui`, and `pnpm test:e2e:runner:typecheck` — all passed. - **Not run locally**: Live paid-key `runner-e2e` suites (`antigravity-qualification`, `antigravity-model-lineup`, `antigravity-agent-journey`) were waived by the owner on 2026-11-25 to enable staging testing and remain marked `NOT RUN` / deferred in the qualification docs. Rust `task_memory::tests::monitor_*` cgroup tests require Linux CI. ## Risks - **Merge sequencing**: Merge after #22935 (`fix/per-turn-harness-on-warm-environment`) so warm environments keep Antigravity on its per-turn lifecycle. - **Deferred live qualification**: Paid-key `antigravity-qualification` cells have not run in CI; `ACPX_CAPABILITY_PROFILES.antigravity.recovery` remains `"unverified"` until live multi-turn and restart continuity are verified on staging. - **Profile version reset**: Bumping `agentProfileVersion` from `1` to `2` intentionally rejects any candidate-era v1 saved sessions as `provider_state_incompatible`; new runs start a clean replacement conversation in the same workspace. - **Remote provider pack targets**: Remote provider packs intentionally target `linux-x64` (Core Docker images and Linux sandboxes); local `darwin-arm64` hosts continue to provision via `paperclipai runtime setup antigravity`. > 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>
290 lines
21 KiB
TypeScript
290 lines
21 KiB
TypeScript
import { access, mkdir, rm, stat } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import type { AdapterEnvironmentTestContext } from "@paperclipai/adapter-utils";
|
|
|
|
const mocks = vi.hoisted(() => ({ probe: vi.fn(), pluginProbe: vi.fn(), admission: vi.fn(), remoteAdmitted: vi.fn(() => false), credentials: vi.fn(), copyBack: vi.fn(), remove: vi.fn(), turn: vi.fn(), warn: vi.fn(),
|
|
shell: vi.fn(), released: false }));
|
|
vi.mock("../middleware/logger.js", () => ({ logger: { warn: mocks.warn } }));
|
|
vi.mock("../vendor/paperclip-runner/index.js", async importOriginal => {
|
|
const original = await importOriginal<typeof import("../vendor/paperclip-runner/index.js")>();
|
|
// Tests keep mocks.released = false for the pending-candidate suite and flip mocks.released = true for the qualified release suite.
|
|
const pending = { ...original.QUALIFIED_ACPX_PROFILES.antigravity, qualificationStatus: "pending" as const };
|
|
const profiles = { ...original.QUALIFIED_ACPX_PROFILES };
|
|
Object.defineProperty(profiles, "antigravity", { enumerable: true,
|
|
get: () => mocks.released ? original.QUALIFIED_ACPX_PROFILES.antigravity : pending });
|
|
return { ...original, QUALIFIED_ACPX_PROFILES: profiles, probeNativeRunnerEnvironment: mocks.probe };
|
|
});
|
|
vi.mock("@paperclipai/adapter-utils/execution-target", async importOriginal => ({
|
|
...await importOriginal<object>(), runAdapterExecutionTargetShellCommand: mocks.shell,
|
|
}));
|
|
vi.mock("../services/native-runtime/remote-provider-pack.js", async importOriginal => ({
|
|
...await importOriginal<object>(), ANTIGRAVITY_PATCHED_CLOSURE_SHA256: { "linux-x64": "b".repeat(64) },
|
|
}));
|
|
vi.mock("../services/native-runtime/acpx-qualification.js", () => ({ resolveAntigravityCandidateAdmission: mocks.admission,
|
|
antigravityRemoteCandidateAdmitted: mocks.remoteAdmitted }));
|
|
vi.mock("../services/native-runtime/antigravity-runner-credentials.js", () => ({
|
|
prepareAntigravityRunnerCredentials: mocks.credentials, antigravityCredentialTurn: mocks.turn,
|
|
}));
|
|
vi.mock("../services/native-runtime/native-codex-runner.js", () => ({
|
|
resolvePaperclipRunnerBinary: () => "/owned/runnerd",
|
|
resolvePaperclipRunnerBinaryAsync: async () => "/owned/runnerd",
|
|
}));
|
|
vi.mock("../services/native-runtime/plugin-runner-probe.js", () => ({
|
|
probePluginRunnerEnvironment: mocks.pluginProbe,
|
|
}));
|
|
import { antigravityConnectionProbeFailure, testAntigravityConnection } from "../services/antigravity-connection-probe.js";
|
|
import { NativeEnvironmentProbeCleanupError, QUALIFIED_ACPX_PROFILES, resolveAcpxRuntimeRoot } from "../vendor/paperclip-runner/index.js";
|
|
|
|
const model = "exact-google-model";
|
|
const admission = { agent: "antigravity", model, companyId: "company-1" };
|
|
const roots: string[] = [];
|
|
const context: AdapterEnvironmentTestContext = { companyId: "company-1", adapterType: "paperclip_runner",
|
|
config: { provider: "acpx", acpxAgent: "antigravity", model, env: { GEMINI_HOME: "/selected/provider", PATH: "/selected/bin" } },
|
|
managedAiCredentialHome: "/selected/provider", executionTarget: null,
|
|
};
|
|
const receipt = { provider: "acpx", providerDriver: "acpx_runtime", effectiveModel: model,
|
|
sessionAdmissionPassed: true, admissionOnly: true, helloProbePassed: false };
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
mocks.admission.mockReturnValue(admission);
|
|
mocks.credentials.mockImplementation(async input => ({ environment: { ...input.environment, PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: "fixture-managed-credential" }, home: "/selected/provider", credential: "fixture-managed-credential" }));
|
|
mocks.turn.mockImplementation(() => ({ copyBack: mocks.copyBack, remove: mocks.remove }));
|
|
mocks.probe.mockImplementation(async options => {
|
|
roots.push(options.runtimeDirectory);
|
|
await options.onCleanupConfirmed();
|
|
return receipt;
|
|
});
|
|
});
|
|
afterEach(async () => {
|
|
mocks.released = false;
|
|
vi.unstubAllEnvs();
|
|
await Promise.all(roots.splice(0).map(root => rm(root, { recursive: true, force: true })));
|
|
});
|
|
|
|
describe("Google Antigravity setup admission", () => {
|
|
it("reports the observed installation failure with a repair action and only closed server diagnostics", () => {
|
|
const privateValue = "fixture-private-token /private/selected-google-home";
|
|
const error = new Error(privateValue);
|
|
Object.defineProperty(error, "runnerCommandResult", { value: { commandType: "session.open", status: "failed", request: privateValue,
|
|
result: { code: "command_execution_failed", message: "failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=admission_installation)" } } });
|
|
const result = antigravityConnectionProbeFailure("company-1", error);
|
|
expect(result).toMatchObject({ status: "fail", checks: [{ code: "antigravity_installation_check_failed",
|
|
message: "Paperclip could not complete the local Google Antigravity installation check.", hint: expect.stringContaining("instance operator") }] });
|
|
expect(mocks.warn).toHaveBeenCalledExactlyOnceWith({ companyId: "company-1", code: "antigravity_installation_check_failed",
|
|
errorClass: "Error", commandCode: "command_execution_failed", classification: "admission_installation", retryable: false },
|
|
"Antigravity installation check failed before account verification");
|
|
expect(JSON.stringify([result, mocks.warn.mock.calls])).not.toMatch(/fixture-private-token|\/private\/selected-google-home/);
|
|
expect(JSON.stringify(result)).not.toMatch(/reconnect|sign in/i);
|
|
});
|
|
|
|
it("logs the closed instructions admission classification without treating it as an installation failure", () => {
|
|
const error = new Error("fixture-private-token");
|
|
Object.defineProperty(error, "runnerCommandResult", { value: { commandType: "session.open", status: "failed",
|
|
result: { code: "command_execution_failed", message: "failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=admission_instructions)" } } });
|
|
expect(antigravityConnectionProbeFailure("company-1", error).checks[0].code).toBe("antigravity_admission_failed");
|
|
expect(mocks.warn).toHaveBeenCalledExactlyOnceWith(expect.objectContaining({ commandCode: "command_execution_failed",
|
|
classification: "admission_instructions", retryable: false }), "Antigravity runtime admission check failed");
|
|
});
|
|
|
|
it("does not parse outer serialized errors or copy unknown codes, classes or native output", () => {
|
|
const privateValue = "fixture-private-token /private/selected-google-home";
|
|
for (const native of [{ code: privateValue, message: privateValue }, { code: "command_execution_failed",
|
|
message: "failed to start ACPX provider: ACPX sidecar command session.open was rejected (retryable=false, classification=admission_installation)" + privateValue }]) {
|
|
const nativeMessage = native.message;
|
|
const error = new Error(`PRP command session.open failed: ${nativeMessage}`);
|
|
error.name = privateValue;
|
|
Object.defineProperty(error, "runnerCommandResult", { value: { commandType: "session.open", status: "failed",
|
|
result: native } });
|
|
const result = antigravityConnectionProbeFailure("company-1", error);
|
|
expect(result.checks[0].code).toBe("antigravity_admission_failed");
|
|
expect(JSON.stringify([result, mocks.warn.mock.calls])).not.toMatch(/fixture-private-token|\/private\/selected-google-home/);
|
|
}
|
|
const rawOnly = new Error('PRP command session.open failed: {"code":"command_execution_failed","classification":"admission_installation"}');
|
|
expect(antigravityConnectionProbeFailure("company-1", rawOnly).checks[0].code).toBe("antigravity_admission_failed");
|
|
});
|
|
|
|
it("preserves physical cleanup ownership instead of converting its typed error into a connection result", () => {
|
|
const retired = Promise.resolve();
|
|
const error = new NativeEnvironmentProbeCleanupError(retired, new Error("fixture-private-token"), [new Error("fixture private path")]);
|
|
expect(() => antigravityConnectionProbeFailure("company-1", error)).toThrow(error);
|
|
expect(mocks.warn).not.toHaveBeenCalled();
|
|
expect(error.retired).toBe(retired);
|
|
});
|
|
|
|
it("uses the selected managed account, exact candidate and a private runtime without a model turn", async () => {
|
|
vi.stubEnv("GEMINI_API_KEY", "ambient-key-must-not-enter");
|
|
vi.stubEnv("GOOGLE_APPLICATION_CREDENTIALS", "/ambient-google-credential");
|
|
const order: string[] = [];
|
|
mocks.copyBack.mockImplementation(async () => { order.push("copy-back"); });
|
|
mocks.remove.mockImplementation(async () => { order.push("scrub"); });
|
|
let root = "";
|
|
mocks.probe.mockImplementation(async options => {
|
|
root = options.runtimeDirectory; roots.push(root);
|
|
expect((await stat(root)).mode & 0o777).toBe(0o700);
|
|
expect((await stat(options.transportOptions.acpxRuntimeDirectory)).mode & 0o777).toBe(0o700);
|
|
expect(options).toMatchObject({ provider: "acpx", model, admissionOnly: true,
|
|
environment: { PATH: "/selected/bin", PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: "fixture-managed-credential" },
|
|
transportOptions: { runnerBinary: "/owned/runnerd", acpxAgent: "antigravity", acpxCandidateAdmission: admission,
|
|
acpxPermissionMode: "approve-reads", acpxPermissionModePinned: true } });
|
|
expect(options.environment.GEMINI_API_KEY).toBeUndefined();
|
|
expect(options.environment.GOOGLE_APPLICATION_CREDENTIALS).toBeUndefined();
|
|
const identity = options.transportOptions.prpIdentity;
|
|
const nativeHome = join(await resolveAcpxRuntimeRoot(options.transportOptions.acpxRuntimeDirectory, identity.normalizedSessionId), "antigravity-home");
|
|
expect(mocks.turn).toHaveBeenCalledWith({ managedHome: "/selected/provider", runtimeHome: nativeHome, credential: "fixture-managed-credential" });
|
|
await mkdir(nativeHome, { recursive: true });
|
|
order.push("retired");
|
|
await options.onCleanupConfirmed();
|
|
await expect(access(root)).rejects.toMatchObject({ code: "ENOENT" });
|
|
return receipt;
|
|
});
|
|
const result = await testAntigravityConnection(context, model);
|
|
expect(result.status).toBe("pass");
|
|
expect(result.checks).toContainEqual(expect.objectContaining({ code: "antigravity_metadata_verified" }));
|
|
expect(mocks.admission).toHaveBeenCalledExactlyOnceWith({ companyId: "company-1", model, target: { platform: process.platform, architecture: process.arch } });
|
|
expect(mocks.credentials).toHaveBeenCalledWith(expect.objectContaining({ managedHome: "/selected/provider", remote: false, lifecycleMode: "per_turn" }));
|
|
expect(order).toEqual(["retired", "copy-back", "scrub"]);
|
|
});
|
|
|
|
it.each(["effectiveModel", "providerDriver", "sessionAdmissionPassed", "admissionOnly", "helloProbePassed"] as const)("rejects a mismatched %s receipt after cleanup", async field => {
|
|
mocks.probe.mockImplementation(async options => {
|
|
roots.push(options.runtimeDirectory);
|
|
await options.onCleanupConfirmed();
|
|
return { ...receipt, [field]: typeof receipt[field] === "string" ? "different" : !receipt[field] };
|
|
});
|
|
await expect(testAntigravityConnection(context, model)).rejects.toThrow("no matching account and model admission receipt");
|
|
expect(mocks.copyBack).toHaveBeenCalledOnce();
|
|
expect(mocks.remove).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("rejects an unavailable company or remote target before reading credentials or launching native code", async () => {
|
|
mocks.admission.mockReturnValue(undefined);
|
|
await expect(testAntigravityConnection(context, model)).rejects.toThrow("not available for this company");
|
|
const remote = await testAntigravityConnection({ ...context, executionTarget: { kind: "remote" } as AdapterEnvironmentTestContext["executionTarget"] }, model);
|
|
expect(remote).toMatchObject({ status: "fail", checks: [{ code: "antigravity_remote_unavailable", message: expect.stringMatching(/only on the Paperclip host/) }] });
|
|
expect(mocks.credentials).not.toHaveBeenCalled();
|
|
expect(mocks.probe).not.toHaveBeenCalled();
|
|
expect(mocks.shell).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe("Google Antigravity cloud candidate while pending", () => {
|
|
const remoteTarget = { kind: "remote", transport: "ssh", remoteCwd: "/workspace" } as unknown as AdapterEnvironmentTestContext["executionTarget"];
|
|
const apiKeyContext = { ...context, managedAiCredentialHome: undefined,
|
|
config: { ...context.config, env: { GEMINI_API_KEY: "fixture-google-key" } }, executionTarget: remoteTarget };
|
|
const pendingEntry = () => ({ version: QUALIFIED_ACPX_PROFILES.antigravity.agentServerVersion, profileDigest: QUALIFIED_ACPX_PROFILES.antigravity.commandDigest,
|
|
closureDigest: `sha256:${"b".repeat(64)}`, qualification: "pending", path: "provider-assets/antigravity/linux-x64", sha256: `sha256:${"c".repeat(64)}` });
|
|
const pendingManifest = (providers: Record<string, unknown>) => ["Linux", "x86_64", JSON.stringify({
|
|
schema: "paperclip-runner/remote-provider-pack/v1", payload: { target: { platform: "linux", architecture: "x64" }, ...providers } })].join("\n");
|
|
afterEach(() => { mocks.remoteAdmitted.mockReset(); mocks.remoteAdmitted.mockReturnValue(false); });
|
|
|
|
it("checks the cloud candidate pack for an API key the operator granted this company and model", async () => {
|
|
mocks.remoteAdmitted.mockReturnValue(true);
|
|
mocks.shell.mockResolvedValue({ exitCode: 0, timedOut: false, stdout: pendingManifest({ candidateProviders: { antigravity: pendingEntry() } }), stderr: "" });
|
|
expect(await testAntigravityConnection(apiKeyContext, model)).toMatchObject({ status: "warn", checks: [{ code: "antigravity_remote_runtime_ready" }] });
|
|
expect(mocks.remoteAdmitted).toHaveBeenCalledWith({ companyId: "company-1", model });
|
|
mocks.shell.mockResolvedValue({ exitCode: 0, timedOut: false, stdout: pendingManifest({ providers: { antigravity: { ...pendingEntry(), qualification: "qualified" } } }), stderr: "" });
|
|
expect((await testAntigravityConnection(apiKeyContext, model)).status).toBe("fail");
|
|
expect(mocks.credentials).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("refuses Google sign-in in the cloud even with a grant, refuses plugin Runner-task targets while pending, and refuses any cloud run without a grant", async () => {
|
|
mocks.remoteAdmitted.mockReturnValue(true);
|
|
expect(await testAntigravityConnection({ ...context, executionTarget: remoteTarget }, model))
|
|
.toMatchObject({ status: "fail", checks: [{ code: "antigravity_remote_sign_in_unsupported" }] });
|
|
const pluginTarget = { kind: "remote", transport: "sandbox", remoteCwd: ".", leaseId: "lease-1",
|
|
runnerTaskProbe: { runId: "run-1", sessionId: "session-1" }, runnerTask: vi.fn() } as unknown as AdapterEnvironmentTestContext["executionTarget"];
|
|
expect(await testAntigravityConnection({ ...apiKeyContext, executionTarget: pluginTarget }, model))
|
|
.toMatchObject({ status: "fail", checks: [{ code: "antigravity_remote_unavailable" }] });
|
|
expect(mocks.pluginProbe).not.toHaveBeenCalled();
|
|
mocks.remoteAdmitted.mockReturnValue(false);
|
|
expect(await testAntigravityConnection(apiKeyContext, model))
|
|
.toMatchObject({ status: "fail", checks: [{ code: "antigravity_remote_unavailable" }] });
|
|
expect(mocks.shell).not.toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe("Google Antigravity setup admission after the release flip", () => {
|
|
const remoteTarget = { kind: "remote", transport: "ssh", remoteCwd: "/workspace" } as unknown as AdapterEnvironmentTestContext["executionTarget"];
|
|
const apiKeyContext = { ...context, managedAiCredentialHome: undefined,
|
|
config: { ...context.config, env: { GEMINI_API_KEY: "fixture-google-key" } }, executionTarget: remoteTarget };
|
|
const manifest = (antigravity: Record<string, unknown>, extra: Record<string, unknown> = {}) => ["Linux", "x86_64", JSON.stringify({
|
|
schema: "paperclip-runner/remote-provider-pack/v1", payload: { target: { platform: "linux", architecture: "x64" }, providers: { antigravity }, ...extra } })].join("\n");
|
|
const entry = () => ({ version: QUALIFIED_ACPX_PROFILES.antigravity.agentServerVersion, profileDigest: QUALIFIED_ACPX_PROFILES.antigravity.commandDigest,
|
|
closureDigest: `sha256:${"b".repeat(64)}`, qualification: "qualified", path: "provider-assets/antigravity/linux-x64", sha256: `sha256:${"c".repeat(64)}` });
|
|
beforeEach(() => { mocks.released = true; });
|
|
|
|
it("verifies the local connection without a candidate grant", async () => {
|
|
mocks.admission.mockReturnValue(undefined);
|
|
const result = await testAntigravityConnection(context, model);
|
|
expect(result.status).toBe("pass");
|
|
expect(mocks.admission).not.toHaveBeenCalled();
|
|
expect(mocks.probe.mock.calls[0][0].transportOptions.acpxCandidateAdmission).toBeUndefined();
|
|
});
|
|
|
|
it("checks the cloud image's patched Antigravity runtime for Google sign-in once released without sending credentials or a prompt", async () => {
|
|
mocks.shell.mockResolvedValue({ exitCode: 0, timedOut: false, stdout: manifest(entry()), stderr: "" });
|
|
const result = await testAntigravityConnection({ ...context, executionTarget: remoteTarget }, model);
|
|
expect(result).toMatchObject({ status: "warn", checks: [{ code: "antigravity_remote_runtime_ready",
|
|
message: expect.stringContaining("Google sign-in") }] });
|
|
const [, , command, options] = mocks.shell.mock.calls[0];
|
|
expect(options.env).toEqual({});
|
|
expect(command).not.toContain("/selected/provider");
|
|
expect(mocks.probe).not.toHaveBeenCalled();
|
|
expect(mocks.credentials).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("delegates plugin Runner-task targets to probePluginRunnerEnvironment for both Gemini API key and Google sign-in once released", async () => {
|
|
const pluginTarget = { kind: "remote", transport: "sandbox", remoteCwd: ".", leaseId: "lease-1",
|
|
runnerTaskProbe: { runId: "run-1", sessionId: "session-1" }, runnerTask: vi.fn() } as unknown as AdapterEnvironmentTestContext["executionTarget"];
|
|
const verified = { adapterType: "paperclip_runner", status: "pass" as const, testedAt: new Date(0).toISOString(),
|
|
checks: [{ code: "antigravity_metadata_verified", level: "info" as const, message: "Verified." }] };
|
|
mocks.pluginProbe.mockResolvedValue(verified);
|
|
|
|
const apiKeyPluginContext: AdapterEnvironmentTestContext = {
|
|
...apiKeyContext,
|
|
config: { ...apiKeyContext.config, managedAiConnection: { identity: "key-id", sessionIdentity: "key-session" } },
|
|
executionTarget: pluginTarget,
|
|
};
|
|
expect(await testAntigravityConnection(apiKeyPluginContext, model)).toEqual(verified);
|
|
expect(mocks.pluginProbe).toHaveBeenCalledWith(apiKeyPluginContext, { identity: "key-id", accountIdentity: "key-session", home: undefined });
|
|
|
|
const signInPluginContext: AdapterEnvironmentTestContext = {
|
|
...context,
|
|
config: { ...context.config, managedAiConnection: { identity: "google-id", sessionIdentity: "google-session" } },
|
|
executionTarget: pluginTarget,
|
|
};
|
|
expect(await testAntigravityConnection(signInPluginContext, model)).toEqual(verified);
|
|
expect(mocks.pluginProbe).toHaveBeenLastCalledWith(signInPluginContext, { identity: "google-id", accountIdentity: "google-session", home: "/selected/provider" });
|
|
expect(mocks.shell).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("checks the cloud image's patched Antigravity runtime for an API key without sending the key or a prompt", async () => {
|
|
mocks.shell.mockResolvedValue({ exitCode: 0, timedOut: false, stdout: manifest(entry()), stderr: "" });
|
|
const result = await testAntigravityConnection(apiKeyContext, model);
|
|
expect(result).toMatchObject({ status: "warn", checks: [{ code: "antigravity_remote_runtime_ready" }] });
|
|
const [, , command, options] = mocks.shell.mock.calls[0];
|
|
expect(options.env).toEqual({});
|
|
expect(command).not.toContain("fixture-google-key");
|
|
expect(mocks.probe).not.toHaveBeenCalled();
|
|
expect(mocks.credentials).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.each([
|
|
["the vendor closure", manifest({ ...entry(), closureDigest: `sha256:${"e".repeat(64)}` })],
|
|
["a pending entry", manifest({ ...entry(), qualification: "pending" })],
|
|
["an entry in both inventories", manifest(entry(), { candidateProviders: { antigravity: entry() } })],
|
|
["an older profile", manifest({ ...entry(), profileDigest: `sha256:${"f".repeat(64)}` })],
|
|
["an ARM host", manifest(entry()).replace("x86_64", "aarch64")],
|
|
])("refuses %s", async (_name, stdout) => {
|
|
mocks.shell.mockResolvedValue({ exitCode: 0, timedOut: false, stdout, stderr: "" });
|
|
expect((await testAntigravityConnection(apiKeyContext, model)).status).toBe("fail");
|
|
});
|
|
|
|
it("reports a missing pack in plain language", async () => {
|
|
mocks.shell.mockResolvedValue({ exitCode: 127, timedOut: false, stdout: "", stderr: "" });
|
|
expect(await testAntigravityConnection(apiKeyContext, model)).toMatchObject({ status: "fail",
|
|
checks: [{ code: "antigravity_remote_runtime_missing" }] });
|
|
});
|
|
});
|