Files
PaperClipAI/server
DottaandPaperclip 362bdc1117 fix(antigravity): resolve hosted login and model discovery from configured provider pack (#22983)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip supports Google Antigravity through Paperclip Runner,
including server-hosted Google sign-in and account-bound model
discovery.
> - In Docker and hosted deployments, the server ships Antigravity's
verified Linux runtime closure inside the build-owned provider pack at
`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH`, not under
`server/dist/vendor/paperclip-runner/`.
> - Because `startAntigravityBrowserLogin` and
`discoverAntigravityModels` only checked `import.meta.url` and
`PAPERCLIP_ACPX_PROVIDER_PACKAGE_ROOT`, hosted Google sign-in and
subscription model discovery failed immediately on container
deployments.
> - This pull request adds an explicit `providerPackageRoot` option to
the Runner asset-root and Antigravity helpers and forwards the
normalized `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` from the server
without mutating `process.env`.
> - The benefit is that hosted Google Antigravity sign-in and model
discovery resolve the verified build-owned closure cleanly on Docker and
Cloud deployments while keeping all manifest, symlink, and
closure-integrity checks intact.

## Linked Issues or Issue Description

Refs #22932

**What happened?**
On a Docker/hosted server where `hostedGoogleAiLoginSupported` is `true`
and
`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH=/opt/paperclip-runner/provider-pack`,
starting Google Subscription sign-in returned `HTTP 201` on `POST
/ai-connections/local/attempts` and then immediately failed on
`/ai-connections/local/check` with `Google sign-in did not complete.
Start sign-in again.` and no OAuth URL. `discoverAntigravityModels` hit
the same missing asset lookup in container deployments.

**Expected behavior**
Hosted Google Antigravity sign-in and account-bound model discovery
resolve the verified `provider-assets/antigravity/linux-x64` closure
from the server's configured
`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` provider pack, return the
PKCE loopback authorization URL for hosted redirect relay, and load the
account's model catalog.

**Steps to reproduce**
1. Run the Paperclip Docker image (`node server/dist-runtime/index.mjs`)
with
`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH=/opt/paperclip-runner/provider-pack`.
2. Open the Google Antigravity and Gemini connector and start a `Google
Subscription` sign-in attempt.
3. Observe `/ai-connections/local/check` immediately returning `Google
sign-in did not complete. Start sign-in again.` without an authorization
URL.

**Paperclip version or commit**
`1fca3a6d8c5a2be455f1240e96ff8d12387ad688` (on `master`)

**Deployment mode**
Docker

## What Changed

- Added an optional `RunnerProviderAssetsRootOptions` (`{
providerPackageRoot?, providerPackageManifest? }`) parameter to
`resolveRunnerProviderAssetsRoot` in
`packages/paperclip-runner/src/drivers/acpx/provider-assets-root.ts` so
callers can pass an explicit package root without mutating
`process.env`, reusing the same manifest, symlink, containment, and
TOCTOU verification checks and failing closed on invalid roots.
- Threaded optional `{ providerPackageRoot }` through
`antigravityNativeDistributionSpec`, `startAntigravityBrowserLogin`, and
`discoverAntigravityModels`.
- Updated `server/src/services/local-ai-browser-login.ts` and
`server/src/services/antigravity-connection-models.ts` to normalize
`PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` (stripping trailing slashes
and rejecting non-normalized or relative paths) and pass `{
providerPackageRoot }` when configured.
- Added unit tests covering explicit `providerPackageRoot` resolution
for bundled server paths, fail-closed validation on invalid roots, and
server forwarding in `provider-assets-root.test.ts`,
`antigravity-connection-models.test.ts`, and
`local-ai-browser-login-google.test.ts`.

## Verification

- `pnpm --filter @paperclipai/paperclip-runner build:typescript` —
passed.
- `pnpm --filter @paperclipai/server typecheck` — passed.
- `pnpm --filter @paperclipai/paperclip-runner exec vitest run
src/drivers/acpx/provider-assets-root.test.ts
src/drivers/acpx/antigravity-auth.test.ts
src/drivers/acpx/antigravity-models.test.ts` — passed (52/52 tests
across 3 files).
- `pnpm exec vitest run
server/src/__tests__/antigravity-connection-models.test.ts
server/src/services/local-ai-browser-login-google.test.ts
server/src/__tests__/antigravity-local-ai-login.test.ts` — passed (31/31
tests across 3 files).
- `node --test
packages/paperclip-runner/scripts/contracts/contract-fingerprints.test.mjs`
— passed (11/11 tests).

## Risks

- Low risk. When `PAPERCLIP_RUNNER_REMOTE_PROVIDER_PACK_PATH` is unset
(ordinary local development), all call sites keep their existing
single-argument behavior. When set, the path must be normalized and
absolute and still passes `resolveRunnerProviderAssetsRoot`'s full
`package.json` and symlink-containment checks plus
`verifyNativeAcpxInstallation`'s pinned SHA-256 closure verification. No
contract fingerprints or database schemas change.

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