mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 17:45:53 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - Apps gives agents governed access to external resources. > - Operators need to inspect Railway services, read logs, deploy code, and run container commands. > - Railway offers hosted MCP with OAuth, but broad remote actions hide their internal operations. > - This PR adds a branded connection and fixed direct operations through the existing gateway. > - Separate SSH keys enable container commands under the same grants and policies. > - Operators can require approval for an action and inspect the resulting audit record. ## Linked Issues or Issue Description **Subsystem affected** Apps catalog, connection setup, gateway execution, and connection documentation. **Problem or motivation** Agents need Railway access through Paperclip. Operators need to grant and revoke that access, inspect available actions, and govern deployment and container operations without giving agents provider credentials. **Proposed solution** Reuse hosted MCP OAuth, vault storage, catalog discovery, grants, and the gateway. Probe the actual credential before enabling fixed GraphQL operations. Use a dedicated grant-owned SSH key for bounded container commands. **Alternatives considered** A catalog entry alone cannot execute the missing operations. The hosted general agent has opaque internal effects. An unrestricted CLI runtime can bypass action policy and inherit ambient credentials. **Roadmap alignment** This extends the existing MCP Tool Gateway & Apps path and the Connected Apps direction in ROADMAP.md. It does not add a plugin or parallel connection service. Related PRs #311, #939, and #7861 concern hosting Paperclip on Railway. They do not add this outbound Apps connection. The separate shared agent-picker fix is #13414 and is not included here. ## What Changed - Add the generated Railway catalog entry, official marks, provenance, and OAuth setup guidance. - Add fixed service/deployment status, bounded logs, and redeploy/restart/rollback tools. Block source deployment until the provider can atomically bind the approved repository and commit. - Verify API access with an explicit workspace before exposing direct tools. - Add grant-owned SSH key setup and a bounded runner with host verification, target checks, isolated state, and cleanup. - Block the opaque hosted railway-agent and accept-deploy actions. Preserve normal Allowed defaults and Ask-first policies for other actions. - Quarantine new or changed Railway schemas after initial discovery, including reconnect. - Add provider, lifecycle, gateway, SSH, UI, and browser fixtures. Document setup, limitations, and the release checklist. ## Verification - Security follow-up: removed the unsafe source-deployment mutation. Direct calls and old active catalog entries are denied before any upstream request, including normalized aliases. Refresh marks retired entries disabled. All 386 focused Railway, catalog and gateway tests passed, and server TypeScript checking passed. Full [GitHub CI](https://github.com/paperclipai/paperclip/actions/runs/35139421144) passed ond86530ab9, including typecheck, build, all tests, runner checks, and browser tests. Superagent passed and confirmed the P2 fix. Greptile reviewed the same commit at 5/5 with no findings. - CI follow-up: fixed the missing Railway SSH operation in the OpenAPI document, including its request schema, operator-only authentication, and error responses. The failure reproduced locally before the fix; all 403 selected API, Railway, catalog, and artwork tests passed after it. Synced current master and resolved the catalog/artwork conflicts. - After rebase: 440 focused provider, lifecycle, gateway, catalog, and container-panel tests passed. AppDetail and AppsConnect passed another 196 tests. - Full typecheck, build, token gates, and the gallery browser check passed after rebase. - During implementation, full build and the gallery browser check passed. Shared generic-MCP fixtures covered OAuth callback/state/issuer binding and failure paths. - Local live consent and tools/list succeeded. There were 44 active hosted actions and two blocked actions. A workspace-bound API probe and direct project/service/environment reads succeeded. The inspected project had no deployed services. No provider mutation ran. - Full GitHub CI passed on commit303340f19, including all server/workspace test groups, typecheck, build, runtime verification, release dry run, and browser tests. The original local full-run attempt was incomplete; the complete automated suite is now verified in CI. Manual review: connect Railway, review the actual actions, install for an agent, and run a resource read through the gateway. Choose Ask first before testing a deployment mutation. Configure a dedicated key only when container access is needed. **Release qualification is still open.** Live agent gateway reads/logs, rejected and approved deployment calls, refresh/revoke, public HTTPS consent, and SSH enrollment/commands/cleanup need an authorized disposable service. The passing API diagnostic does not replace those tests. See doc/connections/RAILWAY.md and RAILWAY-REVIEW.md. ## Risks Overall risk is medium. New runtime behavior is gated to Railway connections, but the PR changes shared catalog, credential lifecycle, and gateway code. A regression in those paths can affect other Apps connections. The highest-impact operations are Railway deployments and container commands. - Provider consent can authorize an entire workspace. Catalog labels are not local resource allowlists. Direct tools check target membership, and provider permissions still apply. - Shell commands have broad internal authority. Action policy cannot approve each internal shell step. Timeouts close the local connection but cannot guarantee remote child-process termination. - Log and command output may contain application secrets that pattern redaction cannot recognize. - Source deployment is unavailable until the provider supports atomic repository/commit binding. Existing deployments can still be redeployed, restarted or rolled back. - No database migration is required. Rollback can remove promotion and direct dispatch while preserving connection data and the generic MCP path. - Live Railway qualification must still pass before release acceptance. ## Model Used OpenAI Codex, based on GPT-6, with code execution and browser testing. An independent read-only security agent reviewed the local implementation. The exact serving model ID and context window were 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>
170 lines
5.5 KiB
TypeScript
170 lines
5.5 KiB
TypeScript
/**
|
|
* Prosumer copy for the Apps surface (PAP-10856).
|
|
*
|
|
* The P1a gallery manifest carries developer-flavoured taglines and credential
|
|
* labels (e.g. "Connect Zapier-hosted MCP actions", "Zapier MCP token"). Those
|
|
* strings would fail the vocabulary gate from PAP-10827 — no "MCP", "server",
|
|
* "profile", "policy", "gateway", or "transport" anywhere on this surface. So
|
|
* the UI never renders the raw manifest copy directly: it looks up plain copy
|
|
* here, and `sanitizeProsumerCopy` is a final backstop for any free-text we do
|
|
* surface (app names, fallback taglines).
|
|
*/
|
|
|
|
/** Words that must never appear in prosumer-facing copy on the Apps surface. */
|
|
const BANNED_WORDS = [
|
|
"mcp",
|
|
"server",
|
|
"profile",
|
|
"policy",
|
|
"gateway",
|
|
"transport",
|
|
"stdio",
|
|
"endpoint",
|
|
];
|
|
|
|
const BANNED_RE = new RegExp(`\\b(${BANNED_WORDS.join("|")})s?\\b`, "gi");
|
|
|
|
/**
|
|
* Strip banned vocabulary from a free-text string as a last-resort backstop.
|
|
* Prefer curated copy below; this only protects against manifest text we can't
|
|
* fully control (e.g. a newly added gallery app with no curated entry yet).
|
|
*/
|
|
export function sanitizeProsumerCopy(text: string): string {
|
|
return text
|
|
.replace(BANNED_RE, "")
|
|
.replace(/\s{2,}/g, " ")
|
|
.replace(/\s+([.,])/g, "$1")
|
|
.trim();
|
|
}
|
|
|
|
export interface AppCopy {
|
|
/** Two short lines for the gallery card (M2). */
|
|
tagline: string;
|
|
/** Single line for the connect step header (M3b). */
|
|
short: string;
|
|
}
|
|
|
|
/**
|
|
* Curated prosumer copy keyed by gallery key. Taken from the M-series wires
|
|
* (https://happy-grove-jzyc.here.now/). Apps without an entry fall back to a
|
|
* generic, gate-safe line.
|
|
*/
|
|
const APP_COPY: Record<string, AppCopy> = {
|
|
zapier: {
|
|
tagline: "Reach 9,000+ apps your team already uses.",
|
|
short: "Reach 9,000+ apps from your agents.",
|
|
},
|
|
github: {
|
|
tagline: "Read code and pull requests, comment on issues.",
|
|
short: "Read code and pull requests, comment on issues.",
|
|
},
|
|
slack: {
|
|
tagline: "Send and read messages in your team's channels.",
|
|
short: "Send and read messages in your channels.",
|
|
},
|
|
notion: {
|
|
tagline: "Read and update pages in your workspace.",
|
|
short: "Read and update pages in your workspace.",
|
|
},
|
|
railway: {
|
|
tagline: "Inspect services, read logs, and manage deployments.",
|
|
short: "Connect Railway for deployments, logs, and container access.",
|
|
},
|
|
posthog: {
|
|
tagline: "Explore product usage, errors, flags, and experiments.",
|
|
short: "Sign in with PostHog. Project pinning and access controls are optional.",
|
|
},
|
|
linear: {
|
|
tagline: "Create, update and read tickets.",
|
|
short: "Create, update and read tickets.",
|
|
},
|
|
"google-sheets": {
|
|
tagline: "Read and update selected spreadsheets.",
|
|
short: "Read spreadsheets or update the files you choose.",
|
|
},
|
|
gmail: {
|
|
tagline: "Read mail and create drafts for your review.",
|
|
short: "Read mail and create drafts for your review.",
|
|
},
|
|
"google-drive": {
|
|
tagline: "Find, read, and create files in Drive.",
|
|
short: "Find, read, and create files in Drive.",
|
|
},
|
|
"google-docs": {
|
|
tagline: "Read and update documents.",
|
|
short: "Read and update documents.",
|
|
},
|
|
"google-slides": {
|
|
tagline: "Read and update presentations.",
|
|
short: "Read and update presentations.",
|
|
},
|
|
"google-calendar": {
|
|
tagline: "Review calendars and manage events.",
|
|
short: "Review calendars and manage events.",
|
|
},
|
|
"google-chat": {
|
|
tagline: "Read conversations and send messages.",
|
|
short: "Read conversations and send messages.",
|
|
},
|
|
"google-people": {
|
|
tagline: "Look up contacts and people in your directory.",
|
|
short: "Look up contacts and people in your directory.",
|
|
},
|
|
"google-workspace-search": {
|
|
tagline: "Search across your Google workspace.",
|
|
short: "Search across your Google workspace.",
|
|
},
|
|
hubspot: {
|
|
tagline: "Look up contacts and update deal stages.",
|
|
short: "Look up contacts and update deal stages.",
|
|
},
|
|
intercom: {
|
|
tagline: "Read and reply to customer conversations.",
|
|
short: "Read and reply to customer conversations.",
|
|
},
|
|
figma: {
|
|
tagline: "Read files and post comments on frames.",
|
|
short: "Read files and post comments on frames.",
|
|
},
|
|
stripe: {
|
|
tagline: "Read customers, invoices, and payouts.",
|
|
short: "Read customers, invoices, and payouts.",
|
|
},
|
|
context7: {
|
|
tagline: "Look up up-to-date docs for your libraries.",
|
|
short: "Look up up-to-date docs for your libraries.",
|
|
},
|
|
};
|
|
|
|
const GENERIC: AppCopy = {
|
|
tagline: "Give your agents access to this app.",
|
|
short: "Give your agents access to this app.",
|
|
};
|
|
|
|
/** Curated, gate-safe copy for a gallery app. */
|
|
export function appCopyFor(key: string, fallbackTagline?: string | null): AppCopy {
|
|
const curated = APP_COPY[key];
|
|
if (curated) return curated;
|
|
if (fallbackTagline) {
|
|
const cleaned = sanitizeProsumerCopy(fallbackTagline);
|
|
if (cleaned) return { tagline: cleaned, short: cleaned };
|
|
}
|
|
return GENERIC;
|
|
}
|
|
|
|
/**
|
|
* Label for a single credential field on the key-paste step (M3b). The raw
|
|
* manifest label can contain banned vocab ("Zapier MCP token"), so for the
|
|
* common single-field case we present "Your {App} key" per the wires; multi-
|
|
* field apps fall back to a sanitized version of the manifest label.
|
|
*/
|
|
export function credentialFieldLabel(
|
|
appName: string,
|
|
rawLabel: string,
|
|
fieldCount: number,
|
|
): string {
|
|
if (fieldCount <= 1) return `Your ${appName} key`;
|
|
const cleaned = sanitizeProsumerCopy(rawLabel);
|
|
return cleaned || `Your ${appName} key`;
|
|
}
|