paperclip/doc/plans
Dotta a7e6b818e9
feat(apps): add Paperclip Cloud managed OAuth connector (#12600)
## Thinking Path

> - Paperclip lets operators give governed tools to AI agents.
> - Connected Apps already support provider OAuth and personal
connection grants.
> - Some providers require one stable callback and do not support
dynamic client registration.
> - Self-hosted Paperclip instances can run at private or changeable
origins.
> - Paperclip Cloud can provide the stable callback while each instance
keeps its durable provider credentials.
> - This pull request adds the instance side of that managed OAuth
protocol and keeps customer-created clients available.
> - The benefit is a safe path to one-click Workspace connections for
hosted and enrolled self-hosted instances.

## Linked Issues or Issue Description

**Subsystem affected**

Cross-cutting. This change updates the server, Apps UI, shared app
definitions, and connection documentation.

**Problem or motivation**

Some OAuth providers require a pre-registered callback and
provider-owned client. An arbitrary self-hosted Paperclip origin cannot
use that client callback directly. Paperclip ID must also stay limited
to product identity instead of resource authorization.

**Proposed solution**

Use the existing Paperclip Cloud application as the fixed callback
broker. Enroll each instance to an exact origin and separate Ed25519 and
X25519 keys. Bind every request and sealed envelope to the instance,
environment, user, company, provider, profile, and exact scope set.
Store durable provider credentials only in the originating instance
vault.

**Alternatives considered**

Customer-created OAuth clients remain available as the independent
fallback. A generic redirect relay was rejected because it would allow
caller-selected destinations and scopes. Paperclip ID was rejected as
the broker because it is the identity boundary. A new service was
rejected because the existing Cloud application already owns customer
login and the public callback origin.

**Roadmap alignment**

This work extends the shipped MCP Tool Gateway and Apps milestone. It
also supports the Connected Apps and Cloud deployments roadmap items.

Companion Cloud implementation:
https://github.com/paperclipai/paperclip-cloud/pull/312

The duplicate search found no related open Paperclip PR or issue.

## What Changed

- Add a `paperclip_cloud_connector` client with signed requests, exact
profile and scope bindings, and X25519-sealed credential handling.
- Add explicit self-hosted enrollment with owner-only instance key
storage and exact HTTPS origins.
- Route managed Google Workspace setup through Paperclip Cloud and
preserve customer-created OAuth clients.
- Keep broker claims retryable until the local vault transaction
commits.
- Keep managed Google per-profile removal local-only to avoid
client-wide provider revocation.
- Add setup status to the Connections page and retain the Paperclip ID
names as compatibility aliases.
- Document the trust boundaries, enrollment, callback, refresh, removal,
and rollout flows.

## Verification

- `pnpm -r typecheck`
- `pnpm --filter @paperclipai/shared exec vitest run
src/app-definitions.test.ts`
- `pnpm --filter @paperclipai/server exec vitest run
src/services/paperclip-cloud-connector.test.ts
src/services/paperclip-cloud-connector-enrollment.test.ts`
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/tool-access-service.test.ts -t 'brokered Gmail
OAuth|brokered OAuth state'`
- `pnpm --filter @paperclipai/ui exec vitest run
src/pages/apps/Connections.test.tsx`
- `pnpm check:token-gates`
- `pnpm build`
- The full stable test runner also reproduced existing macOS workspace,
skill-discovery, and listener fixture failures outside the changed
paths. GitHub Linux CI is the authoritative full-suite result.

## Risks

- The managed flow depends on
https://github.com/paperclipai/paperclip-cloud/pull/312. Real provider
profiles stay disabled until Cloud deploys that protocol and the
provider approves the managed client.
- A Cloud outage blocks new authorization and refresh. Existing access
tokens continue to work until expiry.
- Managed Google profile removal only deletes the local grant. This
avoids invalidating the user's other profiles that share the managed
Google client.
- Legacy `paperclip_id_connector` records require a reconnect after
their current access tokens expire. Old Paperclip ID keys and refresh
tokens are not sent to Paperclip Cloud.

> 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

OpenAI GPT-5.6 (Codex). Agentic coding, tool use, code execution, and
subagents were enabled. The context-window size is not exposed in this
session.

## 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-08-31 14:34:46 -05:00
..
2026-02-16-module-system.md
2026-02-18-agent-authentication-implementation.md
2026-02-18-agent-authentication.md
2026-02-19-agent-mgmt-followup-plan.md
2026-02-19-ceo-agent-creation-and-hiring.md
2026-02-20-issue-run-orchestration-plan.md
2026-02-20-storage-system-implementation.md
2026-02-21-humans-and-permissions-implementation.md
2026-02-21-humans-and-permissions.md
2026-02-23-cursor-cloud-adapter.md
2026-02-23-deployment-auth-mode-consolidation.md
2026-03-10-workspace-strategy-and-git-worktrees.md
2026-03-11-agent-chat-ui-and-issue-backed-conversations.md
2026-03-13-TOKEN-OPTIMIZATION-PLAN.md
2026-03-13-agent-evals-framework.md
2026-03-13-company-import-export-v2.md
2026-03-13-features.md
2026-03-13-paperclip-skill-tightening-plan.md
2026-03-13-plugin-kitchen-sink-example.md
2026-03-13-workspace-product-model-and-work-product.md
2026-03-14-adapter-skill-sync-rollout.md
2026-03-14-billing-ledger-and-reporting.md
2026-03-14-budget-policies-and-enforcement.md
2026-03-14-skills-ui-product-plan.md
2026-03-17-docker-release-browser-e2e.md
2026-03-17-memory-service-surface-api.md
2026-03-17-release-automation-and-versioning.md
2026-04-06-smart-model-routing.md
2026-04-06-subissue-creation-on-issue-detail.md
2026-04-07-issue-detail-speed-and-optimistic-inventory.md
2026-04-07-pi-hooks-survey.md
2026-04-08-agent-browser-process-cleanup-plan.md
2026-04-08-agent-os-follow-up-plan.md
2026-04-08-agent-os-technical-report.md
2026-04-12-vscode-task-interoperability-plan.md
2026-04-24-external-object-reference-backfill.md
2026-04-26-plugin-secret-ref-company-scope.md
2026-05-05-scaled-kanban-board-design.md
2026-05-05-scaled-kanban-board.md
2026-05-06-llm-wiki-paperclip-asset-security-gate.md
2026-05-23-cli-api-parity-openapi-reference.ts
2026-05-23-cli-api-parity.md
2026-05-26-skills-cli-catalog-contract.md
2026-06-03-low-trust-review-contract.md
2026-06-05-agent-access-mcp-runtime-slots-adr.md
2026-08-26-self-serve-mcp-connections.md feat(apps): add Paperclip Cloud managed OAuth connector (#12600) 2026-08-31 14:34:46 -05:00
workspace-product-model-and-work-product.md
workspace-technical-implementation.md