Files
PaperClipAI/packages
DottaandClaude Opus 5.5 304854ee99 fix(antigravity): resolve the hosted runtime in one place and report sign-in failures plainly (#22990)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Google Antigravity agents can sign in with a Google subscription. On
hosted public deployments the server starts the pinned Antigravity
runtime and relays the pasted loopback redirect (#22932).
> - The server looked for that runtime only in the server package's
vendored assets and the OS-account cache. The Docker image keeps the
verified closure in the build-owned provider pack
(`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`).
> - So every hosted attempt failed before the runtime started, and the
page showed "Google sign-in did not complete. Start sign-in again." with
no sign-in link. Every failure reason became that one message, and
nothing was logged.
> - #22983 added the pack lookup as an option that each caller had to
pass. That leaves several search paths that can drift: installation
verification still used none.
> - This pull request moves the pack lookup into the one canonical
resolver, gives sign-in failures a typed reason with one plain-language
message each, and logs a secret-free reason code.
> - The benefit is that sign-in, model discovery and installation
verification always find the same verified runtime, and a server without
the runtime says why.

## Linked Issues or Issue Description

Refs #22932, Refs #22983

**Describe the bug**
On a hosted authenticated public deployment, the user chooses Google
Antigravity and then "Google Subscription". The page immediately shows
"Google sign-in did not complete. Start sign-in again." `POST
.../ai-connections/local/attempts` returns 201, and every `POST
.../ai-connections/local/check` returns `sign_in_required` with the same
message and no `authorizationUrl`.

**Steps to reproduce**
1. Run the standard image as an authenticated public deployment. Do not
create an Antigravity runtime cache in the server account.
2. Create an agent with Google Antigravity and choose Google
Subscription.
3. See the error before any sign-in step runs.

**Expected behavior**
The server starts the pinned runtime from the image's provider pack and
shows the Google sign-in link. If the server has no runtime, the message
says so in plain language and does not tell the user to start again.

**Root cause**
`antigravityNativeDistributionSpec()` resolved
`<server>/dist/vendor/paperclip-runner/provider-assets/antigravity/<target>`
and then `$HOME/.paperclip/runtimes/antigravity/<target>/<closure>`. The
image ships the closure at
`$PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH/provider-assets/antigravity/linux-x64`.
`startAntigravityBrowserLogin` caught every failure with a bare `catch`
and showed the generic message. The #22932 tests mocked both the runtime
resolution and the installation check.

## What Changed

- Runner: `antigravityNativeDistributionSpec` is the one resolver for
every caller. The search order is: the runner package's own assets
(runnerd binds Runner children to the selected pack with
`PAPERCLIP_ACPX_PROVIDER_PACKAGE_ROOT`), then the deployment provider
pack from `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`, then the
OS-account cache. The pack root must be a normalized absolute path. The
pack goes through the manifest and link checks of
`resolveRunnerProviderAssetsRoot` from #22983. The pinned closure digest
check is unchanged.
- Runner: the `providerPackageRoot` option on
`startAntigravityBrowserLogin`, `discoverAntigravityModels` and
`antigravityNativeDistributionSpec` is removed. The server no longer
reads the pack path.
- Runner: sign-in failures have a typed reason (`runtime_unavailable`,
`start_failed`, `login_incomplete`, `aborted`). One table maps each
reason to its message. A missing runtime reports "This server does not
have the current Google Antigravity runtime, so Google sign-in cannot
start. Use a Google API key instead, or update Paperclip on this
server."
- Runner: model discovery throws `AntigravityRuntimeUnavailableError`
when the runtime is missing. The server shows a plain-language message
for it instead of "Could not load models for this Google account".
- Server: sign-in failures, except cancelled attempts, are logged with a
secret-free code such as `ANTIGRAVITY_SIGN_IN_RUNTIME_UNAVAILABLE`. A
missing runtime during model discovery is logged as
`ANTIGRAVITY_RUNTIME_UNAVAILABLE`.

## Verification

- Red on master, green on this branch:
- `antigravity-installation.test.ts`: pack resolution, precedence, cache
fallback, link and path refusal, and one test that binds sign-in, model
discovery and `verifyAntigravityInstallation` to the same pack with no
vendored assets.
- `antigravity-auth.test.ts`: one test for each failure reason and its
message.
- `antigravity-models.test.ts`: a missing runtime gives
`AntigravityRuntimeUnavailableError` without a launch.
- `pnpm --filter @paperclipai/paperclip-runner exec vitest run` on the
antigravity auth, stream-order, installation, models and
provider-assets-root suites: 76 of 76 pass.
- `server/src/__tests__/local-ai-browser-login-google.test.ts`,
`antigravity-connection-models.test.ts` and
`antigravity-local-ai-login.test.ts`: 33 of 33 pass.
- The runner `tsc --noEmit` and the server `tsc --noEmit` pass.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`
reports no registry change.
- `pnpm verify` returned exit 2 (runner test files are outside the
resolved test graphs). Required CI supplies the broad coverage.
- Not run: a live Google sign-in against the real closure in a hosted
image. That needs a deploy and a real Google account.

## Risks

- Low risk. The pack is used only when the packaged assets are absent
and the pack contains the target. A modified pack still fails the pinned
closure check.
- A pack root that is relative or contains `..` now fails as "runtime
unavailable" instead of being ignored silently.
- Error text changes only for failures before the runtime initializes.

> 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

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

## 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>
2026-11-25 14:30:43 -06:00
..