Files
PaperClipAI/doc/connections/tracks/app-definition-reference.md
T
DottaandPaperclip 8403e1c4ce docs(connections): modularize connector playbook and add create-connector skill (#23384)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - App connectors let agents interact with external tools, suites, REST
APIs, and chat channels under instance governance
> - `doc/connections/CONNECTOR-PLAYBOOK.md` grew to 2,968 lines (171 KB)
and accumulated stale guidance on `rest_api` adapters and setup UX, with
no upfront research-and-interview gate to aim new connectors at user
expectations
> - An autonomous agent cannot reliably build a new connector in one
command when the playbook mixes every track together and defaults
blindly to remote MCP
> - This pull request splits the playbook into a concise router plus six
load-on-demand track guides and adds the
`.agents/skills/create-connector` skill
> - The benefit is that agents and contributors audit official vendor
docs up front, recommend the right architecture track, and load only the
guidance needed for that connector

## Linked Issues or Issue Description

**Issue type**
Outdated (no longer matches behavior)

**Where is the issue?**
`doc/connections/CONNECTOR-PLAYBOOK.md`, `doc/connections/README.md`,
`.agents/skills/create-connector/`

**What's wrong?**
`doc/connections/CONNECTOR-PLAYBOOK.md` was a 2,968-line monolith that
still claimed `rest_api` is not exposed through the gateway (despite
`rest-registry.ts`, `browser-use-cloud`, and
`google-workspace-rest-tools`), contradicted itself on one-screen setup
vs. a two-step Access → Connect flow, and jumped straight into MCP
endpoint probing without an official-docs feasibility audit or product
alignment interview.

**Suggested fix**
Refactor `CONNECTOR-PLAYBOOK.md` into a short canonical router +
universal invariants contract, move track-specific details into
`doc/connections/tracks/`, and add `.agents/skills/create-connector/`
with a mandatory Research-First → Proactive Recommendation & Interview
gate.

## What Changed

- Refactored `doc/connections/CONNECTOR-PLAYBOOK.md` from 2,968 lines to
184 lines (Phase 0 official-docs feasibility audit & interview, 6-track
selection matrix, universal invariants, canonical one-screen setup UX,
production validation matrix, preserved inbound anchors).
- Created six focused track guides and one deep reference under
`doc/connections/tracks/`:
  - `remote-mcp.md` (Track A)
  - `rest-adapter.md` (Track B)
  - `managed-oauth-suite.md` (Track C)
  - `connector-skills.md` (Track D)
  - `chat-channel.md` (Track E)
  - `local-and-aggregators.md` (Track F)
- `app-definition-reference.md` (field reference, troubleshooting,
provider attribution, proposal template)
- Added `.agents/skills/create-connector/SKILL.md` and
`.agents/skills/create-connector/brief-template.md` implementing the
one-command connector workflow with three explicit human Stop Gates.
- Updated `doc/connections/README.md` to link the modular playbook,
track guides, and `create-connector` skill.

## Verification

- Verified all relative markdown links across all 11 created/modified
files resolve to existing files with zero broken links.
- Verified `git diff --check` passes cleanly on all modified and added
files.
- Confirmed all existing inbound anchors to `CONNECTOR-PLAYBOOK.md`
(`#step-9-align-with-production-validation`, `#chat-channel-connectors`,
`#question-experience-inventory`,
`#retain-inspectable-per-format-evidence`) remain intact.

## Risks

- Low risk: documentation and agent-skill changes only; no runtime,
schema, or UI code is modified.

## Model Used

- Google Gemini (Antigravity agentic coding assistant, tool use and code
execution enabled)

## 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-01 16:33:39 +00:00

150 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AppDefinition Reference, Troubleshooting & Appendices
Deep reference extracted from [CONNECTOR-PLAYBOOK.md](../CONNECTOR-PLAYBOOK.md). Load this only when authoring or debugging `AppDefinition` fields, troubleshooting connector failures, writing a standalone connector proposal, or configuring provider app attribution.
## AppDefinition Field Reference
### App-level fields
| Field | Meaning and rule |
| --- | --- |
| `schemaVersion` | Must be `1`. Change only with a versioned migration plan. |
| `slug` | Stable lowercase kebab-case identity. Never rename after connections exist without a migration. |
| `name` | Provider/product name shown to users. |
| `description` | Plain-language outcome, not protocol marketing. |
| `categories` | One or more supported catalog categories. |
| `featured` | Optional merchandising signal, not availability. |
| `branding` | Local official `logoUrl`, optional `darkLogoUrl`; ingestion derives this from provenance. |
| `urlPatterns` | HTTPS patterns used to recognize pasted/generated provider URLs. Keep narrow enough to reject lookalikes. |
| `docsUrl` | Current official setup/protocol docs. |
| `setupPrerequisite` | Prerequisite users must understand or complete before credentials/consent. Includes CTA and optional ordered steps. |
| `redirectConstraints` | Currently `https-or-loopback-http`; fail before provider navigation when violated. |
| `methods` | Every genuinely supported connection method. At least one. |
| `availability` | Instance/provider availability and user-facing reason. Unavailable entries must not expose a dead action. |
| `ownershipAvailability` | Deployment override for ownership modes. Defaults currently enable `customer` and `dcr`, disable platform modes. |
| `experimentalFeatureKey` | Optional experimental flag key; shared availability checks enforce it before setup, discovery, and execution. |
| `agentInstructions` | Optional `{ id, version, text }` standing guidance template authored in `packages/shared/src/app-definitions/<slug>.json`. |
### Method fields
| Field | Meaning and rule |
| --- | --- |
| `key` | Stable method key stored on the connection as `connectionMethodKey`. |
| `label` | User-facing method label. Required in practice when multiple methods exist. |
| `transport` | `mcp_remote`, `local_stdio` (approved templates only), or `rest_api` (reviewed adapters only). |
| `auth` | `oauth`, `api_key`, or `none`. (Model bot/installation tokens via secret/grant architecture; do not invent a 4th auth enum.) |
| `ownershipModes` | Allowed OAuth client ownership modes (`dcr`, `customer`, `platform_shared`, `platform_provisioned`); also present for non-OAuth customer config. |
| `oauthStrategy` | Managed broker strategy. New definitions use `paperclip_cloud_connector`; `paperclip_id_connector` is legacy-migration-only. OAuth only. |
| `connectorProfile` | Managed connector capability/scope profile; required with `oauthStrategy`. |
| `oauthClientRegistration` | Optional `"dcr"` compatibility override when live evidence proves CIMD fails while DCR succeeds (requires `dcr` in `ownershipModes`). |
| `capabilityProfile` | User-facing read/write/mode grouping used for method selection. |
| `grantKinds` | Restricts identity to `organization`, `user`, and/or `agent`; omit for flexible methods. An `agent` method connects for exactly one chosen agent. |
| `whenToUse` | One sentence distinguishing this method from alternatives. |
| `defaults.serverUrl` | Exact fixed endpoint. For discovery-capable OAuth, omit fixed auth endpoints. |
| `defaults.serverUrlTemplate` | HTTPS endpoint with placeholders supplied by declared tenant/extension fields. Mutually exclusive with `serverUrl`. |
| `defaults.discoveryUrl` | Provider-specific discovery override only when reviewed metadata requires it. |
| `defaults.authorizationEndpoint` / `tokenEndpoint` | Authoritative fixed endpoints; ship only when provider lacks trustworthy discovery. |
| `defaults.metadataUrl` | Authorization metadata hint. |
| `defaults.scopesHint` | Explicit reviewed allowlist. Omit when docs do not require one; never copy every discovered scope. |
| `defaults.oauthAuthorizationParams` | Reviewed `access_type=offline` and/or `prompt=consent` behavior. |
| `defaults.toolArgumentDefaults` | Server-owned provider protocol arguments, hidden from caller schemas and authoritative on collision. |
| `tenantFields` / `extensionFields` | Account/project/region/resource and method-specific config fields. Mark optional narrowing `advanced: true`. |
| `configRequirements.atLeastOneOf` | Requires one of named tenant/extension fields. |
| `credentialFields` | Write-only secret/non-secret credential inputs (`secret: true` for write-only secrets). |
| `keyPlacement` | Provider request placement (use proven header path on `mcp_remote`). |
| `guidanceMd` | Setup and scoping guidance. No secrets or internal env-var names. |
| `consoleLinks` | Official registration, key, settings, and docs URLs. |
| `warnings` | Plan, preview, admin, financial, production-data, or destructive-action caveats. |
| `riskTier` | `S1` (low-risk reads), `S2` (business data/narrow writes), `S3` (broad content/ops), `S4` (payments, external sends, prod changes, deletion, tenant admin). |
| `requiredResourceFilters` | Reviewed resource boundaries — must be backed by server/wrapper enforcement, not only copy. |
| `credentialSources.vercelConnect` | Reviewed services, principal modes (`app`/`user`), scopes, and header placement for the Vercel Connect exception (authenticated `mcp_remote` only). |
### `FieldDef` Rules
Supports `text`, `password`, `textarea`, `datetime`, `select`, `checkbox`:
- Required non-checkbox fields need a `placeholder`.
- `select` needs at least one option; hidden fields need a `defaultValue`.
- `secret: true` only for write-only credential inputs; never smuggle secrets into tenant/extension config.
- `validation.pattern` is a JS regex string; always pair with a practical `maxLength`.
- `transport.location: "query"` modifies the normalized server URL; `"header"` creates a managed non-secret config header (distinct from `keyPlacement`).
- CSV fields deduplicate comma/newline-separated values; `omitFalse` prevents a false checkbox from projecting a query/header value.
---
## Troubleshooting & Failure Classification
| Symptom | Likely layer | What to inspect |
| --- | --- | --- |
| Store says Coming soon or Connect route is dead | Definition / availability / routing | `CONNECTABLE_APP_SLUGS`, store hidden set, method capability checks, `Browse.test.tsx`. |
| Direct `?source=<slug>` shows generic chooser | UI route state | `AppsConnect`, source slug lookup, availability. |
| Finish setup opens Edit config instead of resuming | Draft identity / resume | `resumeConnectionId`, stored `sourceTemplateKey`, `connectionMethodKey`, draft status. |
| OAuth never redirects | Method capability / client resolution | `ownershipModes`, metadata discovery, callback origin, manual-client requirement. |
| Provider rejects redirect URI | Deployment / provider rule | Actual browser origin, `PAPERCLIP_PUBLIC_URL`, `redirectConstraints`, provider app registration. |
| OAuth succeeds then immediately needs reconnect | Grant / secret sync or refresh | Org vs. user grant, token refs, default grant sync, expiry/refresh lease, `invalid_grant`. |
| Tools list but calls return 401 | Token audience / scope / placement | RFC 8707 `resource`, `scopesHint`, header prefix/name, endpoint path. |
| Health works but Test call fails | Gateway projection / policy | Selected grant, managed headers/args, effective profile/policy, catalog entry risk/status. |
| Required provider boilerplate appears in Test | Managed schema projection | `toolArgumentDefaults` and `projectedConnectionToolInputSchema`. |
| API key saves but is not sent | Placement or missing ref | `credentialFieldsFor`, `keyPlacement`, connection/grant refs, gateway header resolution. |
| New tool is classified `read` unexpectedly | Risk inference | Annotations, verb normalization, provider exception set, fixture. |
| Connection from another company is visible | Authorization bug | **Stop immediately**; add company-scope negative tests before any further testing. |
| Raw credential appears anywhere | Security incident | **Stop, revoke/rotate credential**, remove evidence, trace response/log/audit paths, add canary regression test. |
When a bug appears on one provider, reproduce it with a fixture or a second provider of the same auth/transport type. Fix the shared path when generic; keep provider workarounds narrow and documented.
---
## Provider App Attribution (AI / Router Providers)
When a provider supports application attribution (e.g., OpenRouter), credit Paperclip for managed requests using public product identity only — never company name, user ID, task, credential, or instance URL.
- OpenRouter policy lives in `packages/shared/src/openrouter-attribution.ts` (`HTTP-Referer: https://paperclip.ing`, `X-OpenRouter-Title: Paperclip`, `X-Title: Paperclip`, `X-OpenRouter-Categories: cloud-agent,programming-app`), applied only to actual OpenRouter endpoints (`openrouter.ai`, `eu.openrouter.ai`, `us.openrouter.ai`), never inferred from model names or repointed aliases.
- Verify outgoing headers from each pinned harness/SDK (Codex, Claude, OpenCode, Hermes, Pi), custom aliases, mixed-case conflicts, unrelated providers, secret safety, and a small live request. Record coverage limits explicitly.
---
## Documentation Standards for Per-Provider Connection Docs
Every provider doc under `doc/connections/<PROVIDER>.md` must include:
1. **Service involvement statement:** Explicitly state whether Paperclip ID or Paperclip Cloud broker participates (for RFC 7591 DCR, always "neither — DCR is instance-local").
2. **Sequence diagram + exact endpoints:** Mermaid diagram (no semicolons inside message text) plus exact authorize, token, registration, discovery, and callback paths.
3. **Administrator setup instructions:** What an admin must register (if anything), where, instance prerequisites, and end-to-end verification steps.
4. **Provider consent interaction guards:** Note any intentional provider UI delays (e.g., Sentry's 1-second Approve delay after pointer/keyboard interaction) so smoke tests do not misclassify them.
---
## Standalone Connector Proposal Template
```md
## Vendor
- App key / name / owner:
- Track: A (Remote MCP) / B (REST Adapter) / C (Managed OAuth Suite) / D (Skill/Instructions) / E (Chat Channel) / F (Deferred/Aggregator)
- Reason for track choice (and why a lighter path is or isn't enough):
- Security tier: S1 / S2 / S3 / S4
## User Jobs (Top 3–5)
1. ...
## Transport & Auth
- Transport & endpoint(s):
- Auth mode & OAuth client ownership:
- Scopes (exact reviewed allowlist):
- Grant identity (`user` / `organization` / `agent`):
- Secret storage (`paperclip_vault` / `vercel_connect`):
- Revocation behavior:
## Connection Flow (mandatory)
- Sequence diagram (Mermaid):
- Auth endpoints (authorize / token / registration / discovery / callback):
- Redirect constraints (probed):
- Paperclip ID / Paperclip Cloud broker involvement:
## Administrator Setup (mandatory)
- What the admin must register & where:
- Instance prerequisites (TLS, base URL, experimental flag, Cloud broker profile):
- How to verify end to end:
## Actions & Governance
| Tool | Risk | Default status | Resource filters | Negative test case |
| --- | --- | --- | --- | --- |
```