mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-28 21:46:15 +01:00
feat(connections): add self-serve intent runtime (#12345)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Agents need a governed way to request app connections during issue work. > - The catalog now describes the available providers and setup methods. > - A request must become a durable, company-scoped intent before an operator acts on it. > - This pull request adds that intent runtime across server, agent, CLI, and shared contracts. > - The benefit is a safe bridge from agent need to operator-approved setup. ## Linked Issues or Issue Description Refs #11965 This is stack 7 of 11. It depends on stack 6 and replaces another reviewable part of #11965. ## What Changed - Add connection intent types, validation, service logic, and routes. - Add agent runtime tools and CLI support for connection requests. - Add issue-thread interaction support for connection intents. - Add runtime, route, adapter, and contract tests. - Hold the final resolved-continuation row lock through asynchronous adapter preparation until an actual process spawn, so parking or reassignment cannot cross that boundary. - Report Hermes Gateway's first remote run request through the shared dispatch hook so the resolved-intent lock is released at the true dispatch boundary. - Revalidate the addressed user's live non-viewer membership and connection-management authority for every intent mutation, including OAuth completion. ## Verification - `pnpm --filter @paperclipai/server typecheck` - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/tool-access-service.test.ts` - Result: 176 tests passed. - `pnpm build` - `pnpm --filter @paperclipai/server exec vitest run src/__tests__/heartbeat-stale-queue-invalidation.test.ts` (32 passed; includes non-process dispatch lock-release coverage) - `pnpm exec vitest run --project @paperclipai/server server/src/__tests__/connection-intents-service.test.ts -t "addressed-user mutation"` (1 passed) - `pnpm exec vitest run --project @paperclipai/server server/src/__tests__/tool-access-service.test.ts -t "binds OAuth callback completion to the initiating board session"` (1 passed) - `pnpm --filter @paperclipai/hermes-paperclip-adapter test -- src/gateway/server/execute.test.ts` (23 passed; includes dispatch-hook ordering and exactly-once coverage) - `pnpm --filter @paperclipai/hermes-paperclip-adapter typecheck` ## Risks - A malformed intent could create an unusable operator request. - Validators and company checks reject invalid or cross-company requests. - The final continuation gate holds the issue row lock through adapter preparation until process or remote dispatch; later operator changes use the normal active-run interruption path. - The change does not add a database migration. > I checked `ROADMAP.md`. This stack continues the existing app connection work from #11965 and does not duplicate another planned item. ## Model Used OpenAI Codex, GPT-5. The runtime model ID and context window were not exposed. The model used reasoning, 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 linked the public source pull request with `Refs #` - [x] I have not referenced internal or instance-local Paperclip issues or links - [x] My branch name describes the change 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
fcb2e99e8f
commit
b3343dbd64
96 files changed
+8695
-971
No files matched your search
@@ -0,0 +1,44 @@
|
||||
# Connection intents
|
||||
|
||||
Connection intents let an agent ask the responsible user for a known service connection without leaving the task thread. The user can reuse an eligible connection or run the normal provider setup in a dialog. A successful resolution grants and installs the connection for the requesting agent, then wakes the task assignee in a fresh run.
|
||||
|
||||
## Shared setup flow
|
||||
|
||||
`ui/src/features/connections/ConnectionSetupFlow.tsx` is the only connection setup implementation. It owns provider selection, method and identity choices, provider fields, validation, OAuth, access, catalog setup, installs, retry states, and completion. It has two presentation hosts:
|
||||
|
||||
- `ui/src/pages/apps/AppsConnect.tsx` supplies full-page routing and breadcrumbs.
|
||||
- `ui/src/features/connections/ConnectionIntentInteractionBody.tsx` supplies the task dialog, intent resolution, query invalidation, and focus return.
|
||||
|
||||
Provider-specific setup must stay in the shared feature and `AppDefinition` metadata. Do not add provider forms or connection mutations to either host.
|
||||
|
||||
## Agent tools
|
||||
|
||||
Every active heartbeat with a responsible user receives two run-bound tools:
|
||||
|
||||
- `connections_search({ query })` searches first-party connectable definitions and returns `ready`, `needs_user_action`, `available`, or `unavailable` from the requesting agent's perspective.
|
||||
- `connection_request({ service })` returns immediately when the service is already usable. Otherwise it creates or reuses a `connection_intent` and instructs the agent to end the run pending continuation.
|
||||
|
||||
Claude and Codex receive the tools through a native managed MCP server. Local/process adapters receive `PAPERCLIP_RUNTIME_TOOLS_*` environment variables and CLI guidance. Cloud, HTTP, gateway, and external adapters receive the typed runtime descriptor in their invocation context; compatible adapters may also project it into their remote environment.
|
||||
|
||||
The equivalent CLI helpers are:
|
||||
|
||||
```sh
|
||||
paperclipai connections search notion
|
||||
paperclipai connections request notion
|
||||
```
|
||||
|
||||
The manually configured Paperclip MCP server also advertises `connections_search` and `connection_request`. Both helper surfaces require the narrow runtime token and fail outside an active heartbeat.
|
||||
|
||||
## Security and lifecycle
|
||||
|
||||
- Company, agent, run, task, and responsible user come only from the signed runtime token and stored heartbeat context.
|
||||
- Tokens are scoped to connection intents, expire after one hour, and are rejected when the heartbeat is no longer running.
|
||||
- The thread payload contains only service identity, requesting-agent identity, and a safe phase. It never contains credentials or authorization URLs.
|
||||
- OAuth state is linked to the interaction. The same-origin callback finalizes the existing connection pipeline, posts only interaction ID/outcome to its opener, and redirects back to the task if there is no opener.
|
||||
- Personal OAuth defaults to the addressed user and creates an explicit delegation to the requesting agent. Reuse and installs are additive.
|
||||
- Task-hosted setup locks install reach to the requesting agent; the store host retains its normal broader access choices.
|
||||
- The intent resolves only after the connection, grant/delegation, profile access, and install succeed. Failures remain pending with `needs_retry`.
|
||||
- Closing the task, a newer run requesting the same service, or a newer human task comment expires the intent and deletes linked OAuth state.
|
||||
- Success and decline wake the assignee once using an interaction-and-status idempotency key and force a fresh continuation session.
|
||||
|
||||
Legacy `request_confirmation.payload.connectionAuthorization` interactions remain readable and resolvable. New agent requests use `connection_intent` exclusively.
|
||||
@@ -0,0 +1,120 @@
|
||||
# Self-Serve MCP Connections Program
|
||||
|
||||
Date: 2026-08-26
|
||||
|
||||
## Outcome
|
||||
|
||||
Paperclip treats a connection method as the capability boundary. A curated MCP method may declare automatic OAuth registration (`dcr`, including CIMD), a customer-owned OAuth client (`customer`), an API key, or a provider-generated MCP URL. Provider tokens and client secrets remain in the instance's encrypted vault. Paperclip ID remains the future broker for `platform_shared` registrations; the self-serve catalog does not depend on it.
|
||||
|
||||
The machine-readable evidence ledger is [`packages/shared/src/self-serve-mcp-research.json`](../../packages/shared/src/self-serve-mcp-research.json). It is the source for the generated app definitions and records the documentation URL, current endpoint, authentication mode, prerequisite, risk tier, and verification date for all 46 researched providers.
|
||||
|
||||
## Platform checklist
|
||||
|
||||
- [x] Replace the Notion-only OAuth allowlist with app-definition capability checks.
|
||||
- [x] Support DCR/CIMD browser sign-in for curated remote MCP methods.
|
||||
- [x] Accept customer-owned OAuth client IDs and secrets only when a method declares `customer` ownership.
|
||||
- [x] Store customer OAuth secrets and provider tokens as encrypted secret references, never inline in connection configuration or API responses.
|
||||
- [x] Keep Paperclip ID limited to explicitly brokered `platform_shared` methods such as Gmail.
|
||||
- [x] Contain curated OAuth scopes to the method's reviewed `scopesHint`; omit scope when the method has no hint and reject caller widening.
|
||||
- [x] Reuse the existing connection setup flow for browser sign-in, customer OAuth apps, API keys, tenant fields, and generated URLs.
|
||||
- [x] Correct the Jira, Cloudinary, Kernel, Resend, ClickHouse, Postman, PagerDuty, Supabase, PlanetScale, and Zapier connection shapes.
|
||||
- [x] Keep G2, Vercel, and Zomato out of the connectable catalog while retaining their evidence and reconsideration criteria.
|
||||
|
||||
## Catalog delivery and branding checklist
|
||||
|
||||
- [x] Derive Browse, setup, reconnect, and additional-account routes from method capabilities instead of a slug switch.
|
||||
- [x] Route automatic OAuth, customer OAuth, API-key, and no-auth methods through `/apps/connect?source=<slug>`; retain Zapier's provider-generated URL path.
|
||||
- [x] Show the instance-provided `availability.reason` for Gmail, Google Sheets, and any future instance-disabled app; remove “Coming soon” from the connectable catalog.
|
||||
- [x] Ship 50 unique local provider marks under `ui/public/brands/apps/`, with no favicon proxy or generated provider imitation.
|
||||
- [x] Record provider, local asset, official source, upstream asset, format, visibility, and dark-variant requirements in `ui/public/brands/apps/manifest.json`.
|
||||
- [x] Preserve local light/dark branding paths through definition regeneration and validate every SVG/PNG during manifest tests.
|
||||
- [x] Reuse `AppLogo` across Browse, setup, success, Connections, details, sidebars, and connection-intent cards; retain its deterministic letter tile only for runtime image failure.
|
||||
- [x] Replace the compact method segment with full-row radio choices that name authentication, mode/region, and when to use each method.
|
||||
- [x] Present warnings, prerequisites, and provider documentation before credentials or consent.
|
||||
- [x] Prevent automatic OAuth from bypassing tenant/extension fields or the customer-owned OAuth alternative; ClickHouse must collect `serviceId`.
|
||||
- [x] Default S4 write and destructive actions to ask-first while retaining Supabase's project-scoped read-only default.
|
||||
- [x] Add an opt-in credential-free metadata preflight. It performs guarded GET requests only and never creates a connection or invokes OAuth registration.
|
||||
|
||||
## Provider rollout checklist
|
||||
|
||||
“Definition” means the reviewed manifest and UI/server setup contract are implemented. “Live proof” requires a provider account and must be completed before production enablement: authorize in a browser, list tools, run one safe read, refresh/reconnect, revoke, and inspect API responses and logs for secret leakage.
|
||||
|
||||
| Provider | Wave | Definition | Live proof | Notes |
|
||||
|---|---:|:---:|:---:|---|
|
||||
| Jira | 1 | [x] | [ ] | Reference DCR/CIMD flow; `https://mcp.atlassian.com/v1/mcp/authv2`. |
|
||||
| Airtable | 1 | [x] | [ ] | Enterprise client allowlisting may apply. |
|
||||
| beehiiv | 1 | [x] | [ ] | Plan controls write capabilities. |
|
||||
| Bitly | 1 | [x] | [ ] | Browser sign-in and API-token methods. |
|
||||
| Candid | 1 | [x] | [ ] | DCR. |
|
||||
| Cloudflare | 1 | [x] | [ ] | Browser sign-in and API-token methods. |
|
||||
| Cloudinary | 1 | [x] | [ ] | Current `/mcp` endpoint, not the captured SSE endpoint. |
|
||||
| Coda | 1 | [x] | [ ] | Browser sign-in and personal token; beta warning. |
|
||||
| Hugging Face | 1 | [x] | [ ] | DCR/CIMD. |
|
||||
| Kernel | 1 | [x] | [ ] | Current `/mcp` endpoint; API-key alternative. |
|
||||
| Local Falcon | 1 | [x] | [ ] | DCR. |
|
||||
| Make | 1 | [x] | [ ] | DCR. |
|
||||
| Manufact | 1 | [x] | [ ] | DCR. |
|
||||
| Miro | 1 | [x] | [ ] | Enterprise client restrictions may apply. |
|
||||
| Netlify | 1 | [x] | [ ] | DCR. |
|
||||
| Notion | 1 | [x] | [ ] | Existing DCR definition hardened by scope containment. |
|
||||
| O'Reilly | 1 | [x] | [ ] | Browser sign-in and token methods. |
|
||||
| PlanetScale | 1 | [x] | [ ] | Database and insights-only methods; optional intended project/branch metadata. |
|
||||
| PostHog | 1 | [x] | [ ] | OAuth and API-key methods retain project pinning. |
|
||||
| Resend | 1 | [x] | [ ] | Current `/mcp` endpoint. |
|
||||
| Sentry | 1 | [x] | [ ] | Existing DCR/CIMD definition enabled. |
|
||||
| TickTick | 1 | [x] | [ ] | DCR. |
|
||||
| Todoist | 1 | [x] | [ ] | DCR. |
|
||||
| Webflow | 1 | [x] | [ ] | Tenant roles constrain site access. |
|
||||
| Wix | 1 | [x] | [ ] | DCR. |
|
||||
| Brex | 2 | [x] | [ ] | Early access/admin prerequisite; S4 warning. |
|
||||
| ClickHouse | 2 | [x] | [ ] | `/clickstack`; required `x-service-id` header. |
|
||||
| Egnyte | 2 | [x] | [ ] | Plan and external-LLM admin prerequisites. |
|
||||
| Embat | 2 | [x] | [ ] | WorkOS DCR/CIMD; pilot because documentation is sparse. |
|
||||
| Mixpanel | 2 | [x] | [ ] | Beta warning. |
|
||||
| Postman | 2 | [x] | [ ] | US OAuth and EU API-key methods for minimal/code/full endpoints. |
|
||||
| Razorpay | 2 | [x] | [ ] | OAuth and key method; S4 financial warning. |
|
||||
| Sanity | 2 | [x] | [ ] | Browser sign-in and token methods. |
|
||||
| Stripe | 2 | [x] | [ ] | OAuth and key method; public-preview/S4 warning. |
|
||||
| Supabase | 2 | [x] | [ ] | Project required, read-only default, optional feature groups, production-data warning. |
|
||||
| Ticket Tailor | 2 | [x] | [ ] | Provider-hosted authorization may request an API key. |
|
||||
| Asana | 3 | [x] | [ ] | Customer-owned OAuth app; DCR intentionally disabled. |
|
||||
| Box | 3 | [x] | [ ] | Customer-owned OAuth app and Box admin prerequisite. |
|
||||
| Mem0 | 3 | [x] | [ ] | Bearer API key. |
|
||||
| PagerDuty | 3 | [x] | [ ] | API token; separate US and EU methods. |
|
||||
| Similarweb | 3 | [x] | [ ] | `api-key` header and API-enabled subscription. |
|
||||
| Xero | 3 | [x] | [ ] | Customer-owned OAuth app; confirm remote endpoint and data-use terms during live proof. |
|
||||
| Zapier | 3 | [x] | [ ] | Existing generated-URL flow; never substitutes a static shared endpoint. |
|
||||
| G2 | Blocked | [x] | n/a | Reconsider after a customer-created client works without G2 coordination. |
|
||||
| Vercel | Blocked | [x] | n/a | Reconsider when reviewed-client approval is removed or Paperclip is approved. |
|
||||
| Zomato | Blocked | [x] | n/a | Reconsider when third-party clients and unallowlisted redirect URIs are supported. |
|
||||
|
||||
## Automated acceptance
|
||||
|
||||
- [x] Manifest tests assert 46 researched entries, 43 self-serve candidates, three blocked providers, unique slugs, HTTPS documentation/endpoints, authentication mode, prerequisite, risk tier, and verification date.
|
||||
- [x] Definition tests cover corrected endpoints, ClickHouse's service header, Postman's six modes, Supabase's read-only default, and customer-owned OAuth ownership.
|
||||
- [x] Server tests cover DCR reuse, CIMD/DCR fixtures, customer OAuth secret storage, scope containment, token refresh/revocation, SSRF rejection, company isolation, and failed-setup cleanup.
|
||||
- [x] UI tests cover automatic OAuth, customer-owned OAuth credentials, API keys, generated URLs, tenant fields, prerequisites, and unavailable-provider policy.
|
||||
- [x] Branding tests require exactly 50 visible, unique, local, decodable marks and verify dark variants and the failed-image fallback.
|
||||
- [x] Routing tests prove all 43 researched self-serve candidates are actionable and all three blocked providers remain absent.
|
||||
- [x] Metadata preflight tests prove Jira discovery sends no credential, makes no registration request, and treats an authentication challenge as endpoint reachability.
|
||||
- [x] `pnpm check:token-gates` is required for the UI change.
|
||||
- [ ] Complete the account-bound live proof column above before declaring each provider production-verified.
|
||||
|
||||
## Remaining external verification
|
||||
|
||||
The code paths and catalog definitions are complete. The unchecked work is deliberately account-bound and cannot be inferred from public metadata alone:
|
||||
|
||||
1. Start with Jira, then complete Wave 1 automatic OAuth providers. For each provider: authorize, list tools, run one safe read, reconnect/refresh, revoke, and inspect API responses and server logs for secrets.
|
||||
2. Validate customer-created OAuth applications end to end for Asana, Box, and Xero, including redirect URI configuration and tenant-admin prerequisites.
|
||||
3. Validate restricted-key flows for Mem0, PagerDuty, Similarweb, and every API-key alternative; confirm the manifest's exact header/query placement.
|
||||
4. Exercise all six Postman modes, both PagerDuty regions, PlanetScale database/insights modes, and Supabase's project-scoped read-only default against real accounts.
|
||||
5. Confirm Xero's endpoint and applicable AI/data-use terms before marking it verified. Pilot Embat before removing its sparse-documentation warning.
|
||||
6. Keep preview, paid-plan, early-access, and tenant-admin-gated providers connectable with their current warnings. These prerequisites do not change self-serve status.
|
||||
7. Reconsider G2, Vercel, and Zomato only when their provider-approval constraints change; until then they remain absent from the catalog.
|
||||
|
||||
## Operating rules
|
||||
|
||||
- “Self-serve” allows normal accounts, subscriptions, tenant-admin policies, and OAuth consent, but excludes a Paperclip/provider partnership.
|
||||
- Provider documentation and working live OAuth metadata are both required for production verification.
|
||||
- Preview and early-access providers retain warnings until their live proof passes.
|
||||
- This program covers hosted remote MCP connections and credential custody. Generic REST execution and Paperclip-ID-managed shared OAuth registrations remain separate follow-up programs.
|
||||
Reference in new issue
Block a user