mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-26 01:39:51 +01:00
feat(connections): AWS connector out of experimental; role ARN comes back from the agent (#22994)
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The AWS connector lets agents work in an AWS account through AWS's hosted MCP server, with a per-connection role and short-lived credentials (#22083, #22195, #22233, #22626) > - It has been behind the `enableAwsConnector` experimental setting. It is now proven on paperclip.staging: a connection was set up end to end, and the daily QA routine's agent uses it to read private test evidence from S3 > - On the role step, the person still had to paste the role ARN back, even when their own agent created the role and reported the ARN in its live checklist > - This pull request takes the connector out of experimental and has the page pick up the role ARN from the agent, keeping the field for people who set the role up by hand > - The benefit is AWS available to everyone, with a setup that is "paste a prompt, press Test connection" ## Linked Issues or Issue Description Refs #22233 (role setup), #22626 (live agent checklist). **Subsystem affected** Connections (AWS app definition, role setup UI), instance experimental settings. **Problem or motivation** - The AWS connector works, but is hidden unless an operator turns on an experimental flag. - The setup page always showed a Role ARN field, and the person had to copy the ARN from the agent's summary into it. **Proposed solution** - Remove `experimentalFeatureKey` from the AWS app definition. `enableAwsConnector` becomes a compatibility key: stored and Cloud-managed values are ignored, and old clients' writes are accepted (same pattern as `enableMcpAggregators` and `enablePublicMcp`). - Move the Role ARN field into "Or do it by hand". When the agent finishes, take the ARN from its finish summary, accepting only an IAM role ARN for this connection's own role name (`paperclip-<connectionId>`), so a summary cannot point the connection at another role. "Test connection" then works with nothing to paste. The by-hand section opens on its own when a test fails or the agent finished without a usable ARN. **Alternatives considered** - Letting the agent save the ARN through the checklist API: more surface on a token-only route. Reading it from the finish summary needs no new API, and the test still proves the role trusts only this connection. - Removing the field entirely: people who use CloudFormation or IAM by hand still need it. ## What Changed - `packages/shared/src/app-definitions/aws.json`, `scripts/app-definition-overrides/aws.json`: no `experimentalFeatureKey`. - `packages/shared/src/feature-catalog.ts`, `validators/instance.ts`: `enableAwsConnector` is "(compatibility)", default on. - `server/src/services/instance-settings.ts`: always on; Cloud-managed values skipped; old clients' writes accepted. - `ui/src/pages/InstanceExperimentalSettings.tsx`: the AWS toggle is removed. - `ui/src/features/connections/aws-role-arn.ts` (new): the role ARN rule and `roleArnFromAgentSummary`. - `ui/src/features/connections/AwsRoleSetup.tsx`: Role ARN under "Or do it by hand", auto-filled from the agent's summary, with copy updated ("hands back the role when it finishes", "the Role ARN field below"). - `doc/connections/AWS.md`: no longer described as experimental. ## Verification - Server: `aws-mcp-connector.test.ts` (connects even with a stored `enableAwsConnector: false`), `instance-settings-managed-overlay.test.ts` (stays on with stored and Cloud-managed false; an old client's false write is accepted), `instance-settings-service.test.ts`: 68 passed. The 4 new flag tests fail against master's source (red/green). - Shared: `app-definitions.test.ts` 43 passed; `scripts/app-definition-overrides.test.mjs` 3 passed. - UI: `aws-role-arn.test.ts` 3 passed (this connection's ARN from a summary, including role paths and a trailing period; another role, a longer name, a short account and no ARN are rejected). UI typecheck clean. - Storybook (headless Playwright, current branch): the default view has no Role ARN field; "agent done" shows "Your agent's role is ready. Test the connection to finish." with Test connection enabled; "test failed" opens "Or do it by hand" with the field at its end. No page errors. - Live: the connector was set up end to end on paperclip.staging (Test connection passed) and is in daily use by the QA routine. To re-check after deploy without the flag. ## Risks - Every instance now shows the AWS connector. It was already proven on staging; access is per connection and read-only connections are capped by AWS's `ReadOnlyAccess`. - The ARN auto-fill trusts only an ARN naming this connection's own role, and Test connection still verifies AWS accepts it, so a wrong or foreign ARN cannot be saved silently. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use (shell, file edits, Storybook with headless Playwright, the live staging instance). ## 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 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e8c1b9f4d
commit
73369c5d46
15 files changed
+164
-78
No files matched your search
+15
-10
@@ -6,7 +6,8 @@ AWS key for the role method. For each connection, the control plane mints a
|
||||
one-hour bearer token at call time. Agents see the AWS tools like any other
|
||||
connector's tools and never receive AWS credentials.
|
||||
|
||||
It is behind the `enableAwsConnector` experimental setting (off by default).
|
||||
It is available on every instance. The former `enableAwsConnector` experimental
|
||||
setting is a compatibility key whose value is ignored.
|
||||
The design and the spike that proved it are in
|
||||
[the AWS connector plan](../plans/2026-11-17-aws-connector-and-minted-credentials.md)
|
||||
and [the workload identity issuer](../plans/2026-11-17-workload-identity-issuer.md).
|
||||
@@ -90,11 +91,10 @@ sequenceDiagram
|
||||
The role method takes two steps, because the role must trust a connection that
|
||||
already exists. The setup screen walks through them:
|
||||
|
||||
1. Turn on **AWS connector** in Instance Settings, Experimental.
|
||||
2. In Connectors, open AWS. Choose the endpoint region and the access level,
|
||||
1. In Connectors, open AWS. Choose the endpoint region and the access level,
|
||||
then click **Connect**. There is no role ARN to enter yet: the role does not
|
||||
exist until the next step creates it.
|
||||
3. Paperclip saves a draft without contacting AWS and publishes the company's
|
||||
2. Paperclip saves a draft without contacting AWS and publishes the company's
|
||||
issuer. The role is named after the connection (`paperclip-<connection id>`),
|
||||
and CloudFormation fills in the account, so nothing is typed by hand. The
|
||||
screen shows one thing by default:
|
||||
@@ -110,25 +110,30 @@ already exists. The setup screen walks through them:
|
||||
- While the agent works, the step shows its live checklist (it sets and
|
||||
ticks off its steps with the URLs and token in the prompt; see
|
||||
`docs/api/agent-setup-progress.md`), and its finish summary carries the
|
||||
role ARN.
|
||||
- Paste that role ARN into the Role ARN field.
|
||||
role ARN. When the agent finishes, the screen fills in that ARN itself. It
|
||||
accepts only an ARN naming this connection's own role, and keeps any ARN
|
||||
you typed yourself.
|
||||
|
||||
**Or do it by hand** shows the same setup without an agent:
|
||||
**Or do it by hand** shows the same setup without an agent, and holds the
|
||||
Role ARN field. It opens on its own when a test fails or the agent finished
|
||||
without a usable ARN:
|
||||
- **With CloudFormation.** Download the template, create a stack from it in
|
||||
the AWS account, set `CreateIdentityProvider` to `false` if the account
|
||||
already has an identity provider for this issuer, choose `AccessPolicyArn`
|
||||
for full access, and acknowledge that the stack creates IAM resources
|
||||
(`CAPABILITY_NAMED_IAM`). Copy `RoleArn` from the stack's outputs.
|
||||
(`CAPABILITY_NAMED_IAM`). Copy `RoleArn` from the stack's outputs into the
|
||||
Role ARN field.
|
||||
- **In the IAM console or AWS CLI.** Add an OpenID Connect provider with the
|
||||
shown provider URL and audience, then create the role with the shown trust
|
||||
policy (replace `ACCOUNT_ID`), which trusts only `connection:<id>`. Attach
|
||||
`AWSMCPSignInOAuthAccessPolicy` and the agents' permissions. The CLI
|
||||
commands read the account ID themselves and print the role ARN.
|
||||
commands read the account ID themselves and print the role ARN to paste
|
||||
into the Role ARN field.
|
||||
|
||||
If the instance's address changed after the draft was saved, the screen
|
||||
shows no steps and asks you to go back and click **Connect** again, which
|
||||
saves the draft with the current address.
|
||||
4. Click **Test connection**. Paperclip saves the role ARN, mints a token, lists the tools and
|
||||
3. Click **Test connection**. Paperclip saves the role ARN, mints a token, lists the tools and
|
||||
finishes setup. If AWS refuses, the screen shows why, in place.
|
||||
|
||||
The screen reads `GET /api/tool-connections/{connectionId}/aws-setup`, which
|
||||
|
||||
@@ -1492,7 +1492,7 @@ describe("AppDefinition catalog", () => {
|
||||
});
|
||||
it("mints AWS credentials instead of placing stored keys in headers", () => {
|
||||
const aws = APP_DEFINITIONS.find((app) => app.slug === "aws")!;
|
||||
expect(aws.experimentalFeatureKey).toBe("enableAwsConnector");
|
||||
expect(aws.experimentalFeatureKey).toBeUndefined();
|
||||
for (const method of aws.methods) {
|
||||
expect(method).toMatchObject({ transport: "mcp_remote", auth: "api_key", credentialMinter: "aws_mcp" });
|
||||
expect(method.keyPlacement).toBeUndefined();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"experimentalFeatureKey": "enableAwsConnector",
|
||||
"schemaVersion": 1,
|
||||
"slug": "aws",
|
||||
"name": "AWS",
|
||||
|
||||
@@ -184,11 +184,11 @@ export const INSTANCE_FEATURE_CATALOG: Record<InstanceFeatureKey, FeatureCatalog
|
||||
selfHostedDefault: false,
|
||||
},
|
||||
enableAwsConnector: {
|
||||
title: "AWS connector",
|
||||
description: "Show and allow the AWS connector, which reaches AWS's hosted MCP server with short-lived credentials minted for each connection.",
|
||||
title: "AWS connector (compatibility)",
|
||||
description: "Deprecated compatibility key. The AWS connector is always available; stored and managed values are ignored.",
|
||||
tier: "managed",
|
||||
cloudDefault: false,
|
||||
selfHostedDefault: false,
|
||||
cloudDefault: true,
|
||||
selfHostedDefault: true,
|
||||
},
|
||||
enableMcpAggregators: {
|
||||
title: "MCP aggregators (compatibility)",
|
||||
|
||||
@@ -66,7 +66,7 @@ export const instanceExperimentalSettingsSchema = z.object({
|
||||
enableMemoryConnectors: z.boolean().default(false),
|
||||
enablePaperclipNotebook: z.boolean().default(false),
|
||||
enableGoogleWorkspaceConnector: z.boolean().default(false),
|
||||
enableAwsConnector: z.boolean().default(false),
|
||||
enableAwsConnector: z.boolean().default(true),
|
||||
enableCases: z.boolean().default(false),
|
||||
enableAgentChat: z.boolean().default(true),
|
||||
enableCombinedInboxTasks: z.boolean().default(false),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"experimentalFeatureKey": "enableAwsConnector",
|
||||
"schemaVersion": 1,
|
||||
"slug": "aws",
|
||||
"name": "AWS",
|
||||
|
||||
@@ -158,15 +158,16 @@ describe("AWS connector with minted credentials", () => {
|
||||
await request(app).get(`/api/tool-connections/${keyDraft.body.connectionId}/aws-setup`).expect(422);
|
||||
});
|
||||
|
||||
it("stays unavailable until the experimental setting is on", async () => {
|
||||
it("is available even where an old setting turned the former experimental flag off", async () => {
|
||||
const { org } = await company();
|
||||
const { service } = harness();
|
||||
await instanceSettingsService(db).updateExperimental({ enableAwsConnector: false });
|
||||
expect((await instanceSettingsService(db).getExperimental()).enableAwsConnector).toBe(true);
|
||||
await expect(service.connectGalleryApp(org.id, {
|
||||
galleryKey: "aws", connectionMethodKey: "aws-access-key",
|
||||
configValues: { endpointRegion: "us-east-1", accessLevel: "read_only" },
|
||||
credentialValues: { "credentials.accessKeyId": ACCESS_KEY_ID, "credentials.secretAccessKey": SECRET_ACCESS_KEY },
|
||||
}, actor)).rejects.toThrow();
|
||||
}, actor)).resolves.toBeTruthy();
|
||||
});
|
||||
|
||||
it("access key: lists and calls tools with a minted token, never sending the stored key", async () => {
|
||||
|
||||
@@ -142,10 +142,10 @@ describe("instanceSettingsService managed overlay", () => {
|
||||
expect((await service.get()).experimental).toMatchObject(features);
|
||||
expect((await service.getExperimental()).managedKeys).toMatchObject(
|
||||
Object.fromEntries(Object.keys(features)
|
||||
.filter((key) => key !== "enableApps" && key !== "enableMcpAggregators" && key !== "enablePublicMcp")
|
||||
.filter((key) => key !== "enableApps" && key !== "enableMcpAggregators" && key !== "enablePublicMcp" && key !== "enableAwsConnector")
|
||||
.map((key) => [key, { managed: true, managedBy: "paperclip-cloud" }])),
|
||||
);
|
||||
for (const key of Object.keys(features).filter((key) => key !== "enablePublicMcp")) {
|
||||
for (const key of Object.keys(features).filter((key) => key !== "enablePublicMcp" && key !== "enableAwsConnector")) {
|
||||
await expect(service.updateExperimental({ [key]: false })).rejects.toMatchObject({
|
||||
status: 403,
|
||||
details: { code: "settings_operator_managed" },
|
||||
@@ -273,6 +273,25 @@ describe("instanceSettingsService managed overlay", () => {
|
||||
expect(await service.updateExperimental({ enableMcpAggregators: false })).toMatchObject({ experimental: { enableMcpAggregators: true, enableChatConnectors: true } });
|
||||
});
|
||||
|
||||
it.each([{}, { enableAwsConnector: false }])("keeps the AWS connector on with legacy stored and managed values: %j", async (stored) => {
|
||||
const { db } = stubDb(settingsRow(stored));
|
||||
const service = instanceSettingsService(db, { runtimeEnv: managedEnv(JSON.stringify({
|
||||
v: 1, mode: "cloud", catalogVersion: "legacy", features: { enableAwsConnector: false }, plugins: { autoInstall: [] },
|
||||
})) });
|
||||
const experimental = await service.getExperimental();
|
||||
expect(experimental.enableAwsConnector).toBe(true);
|
||||
expect(experimental.managedKeys).not.toHaveProperty("enableAwsConnector");
|
||||
expect(await service.updateExperimental({ enableAwsConnector: false })).toMatchObject({ experimental: { enableAwsConnector: true } });
|
||||
});
|
||||
|
||||
it("accepts an old client's write of the retired AWS connector key while Cloud lists it as on", async () => {
|
||||
const { db } = stubDb(settingsRow({}));
|
||||
const service = instanceSettingsService(db, { runtimeEnv: managedEnv(JSON.stringify({
|
||||
v: 1, mode: "cloud", catalogVersion: "test", features: { enableAwsConnector: true }, plugins: { autoInstall: [] },
|
||||
})) });
|
||||
expect(await service.updateExperimental({ enableAwsConnector: false })).toMatchObject({ experimental: { enableAwsConnector: true } });
|
||||
});
|
||||
|
||||
it("persists chat connector opt-in and reads it back after service reconstruction", async () => {
|
||||
const row = settingsRow({});
|
||||
const { db, persistedSets } = stubDb(row);
|
||||
|
||||
@@ -140,7 +140,7 @@ describe("instance settings service", () => {
|
||||
enableMemoryConnectors: false,
|
||||
enablePaperclipNotebook: false,
|
||||
enableGoogleWorkspaceConnector: false,
|
||||
enableAwsConnector: false,
|
||||
enableAwsConnector: true,
|
||||
enableConferenceRoomChat: false,
|
||||
enableClassicTaskInterface: false,
|
||||
enableLegacyComposerSubmit: false,
|
||||
|
||||
@@ -261,6 +261,8 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
|
||||
enableMcpAggregators: true,
|
||||
// Assistant connections (MCP) graduated from Experimental; ignore historical off values.
|
||||
enablePublicMcp: true,
|
||||
// The AWS connector graduated from Experimental; ignore historical off values.
|
||||
enableAwsConnector: true,
|
||||
enableOpenAiDot: parsed.data.enableOpenAiDot ?? false,
|
||||
enableMuse: parsed.data.enableMuse ?? false,
|
||||
enableGrokBot: parsed.data.enableGrokBot ?? false,
|
||||
@@ -269,7 +271,6 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
|
||||
enableMemoryConnectors: parsed.data.enableMemoryConnectors ?? false,
|
||||
enablePaperclipNotebook: parsed.data.enablePaperclipNotebook ?? false,
|
||||
enableGoogleWorkspaceConnector: parsed.data.enableGoogleWorkspaceConnector ?? false,
|
||||
enableAwsConnector: parsed.data.enableAwsConnector ?? false,
|
||||
enableCases: parsed.data.enableCases ?? false,
|
||||
enableAgentChat: true,
|
||||
enableCombinedInboxTasks: parsed.data.enableCombinedInboxTasks ?? false,
|
||||
@@ -333,7 +334,7 @@ export function normalizeExperimentalSettings(raw: unknown): InstanceExperimenta
|
||||
enableMemoryConnectors: false,
|
||||
enablePaperclipNotebook: false,
|
||||
enableGoogleWorkspaceConnector: false,
|
||||
enableAwsConnector: false,
|
||||
enableAwsConnector: true,
|
||||
enableCases: false,
|
||||
enableAgentChat: true,
|
||||
enableCombinedInboxTasks: false,
|
||||
@@ -397,9 +398,10 @@ export function applyManagedExperimentalOverlay(
|
||||
[ManagedExperimentalFeatureKey, boolean]
|
||||
>) {
|
||||
// Existing Cloud stack configs may still carry retired flags. Accept the
|
||||
// document during rollout, but never let retired flags disable Apps, Agent Chat, MCP aggregators
|
||||
// or Assistant connections (MCP).
|
||||
if (key === "enableApps" || key === "enableAgentChat" || key === "enableMcpAggregators" || key === "enablePublicMcp") continue;
|
||||
// document during rollout, but never let retired flags disable Apps, Agent Chat, MCP aggregators,
|
||||
// Assistant connections (MCP) or the AWS connector.
|
||||
if (key === "enableApps" || key === "enableAgentChat" || key === "enableMcpAggregators" || key === "enablePublicMcp"
|
||||
|| key === "enableAwsConnector") continue;
|
||||
next[key] = value;
|
||||
managedKeys[key] = { managed: true, managedBy: PAPERCLIP_CLOUD_MANAGED_BY };
|
||||
}
|
||||
@@ -643,7 +645,7 @@ export function instanceSettingsService(db: Db, options: InstanceSettingsService
|
||||
updateExperimental: async (patch: PatchInstanceExperimentalSettings): Promise<InstanceSettings> => {
|
||||
for (const [key, enabled] of Object.entries(managedConfig?.features ?? {})) {
|
||||
// Retired always-on keys are ignored on read, so an old client's write must not be rejected.
|
||||
if (key === "enablePublicMcp") continue;
|
||||
if (key === "enablePublicMcp" || key === "enableAwsConnector") continue;
|
||||
if (enabled && patch[key as ManagedExperimentalFeatureKey] === false) {
|
||||
throw forbidden(`${key} is enabled by Paperclip Cloud and cannot be disabled on this instance`, {
|
||||
code: "settings_operator_managed",
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
"packages/shared/src/app-definitions-url.test.ts": "56792d6745a5bc7eafc36e7403f4c9bbd671ae99",
|
||||
"packages/shared/src/app-definitions.generated.ts": "b162e9621fab029951d77a6b4605ab7893904a3a",
|
||||
"packages/shared/src/app-definitions.ingestion-report.json": "a7b60c7c16a484a411989315e9f08d48258fa647",
|
||||
"packages/shared/src/app-definitions.test.ts": "269e1c82f377bab004c00765ba51543922315172",
|
||||
"packages/shared/src/app-definitions.test.ts": "591727cee240c7b1f9a2e2c726d8656d539129e2",
|
||||
"packages/shared/src/app-definitions.ts": "f8c9c3aa66ea3bbe38c3a2eff7abca9a25911c83",
|
||||
"packages/shared/src/app-definitions/1password.json": "c11a4777de2c78805b2d391da5eb075a9511e0f8",
|
||||
"packages/shared/src/app-definitions/agentmail.json": "edd0799b1980d0f5f43b89c8f7a1173dc623f7fa",
|
||||
@@ -87,7 +87,7 @@
|
||||
"packages/shared/src/app-definitions/api-key-generic.json": "09e6d4295513ac9f1002eaf37c34e7c2d00a3c05",
|
||||
"packages/shared/src/app-definitions/arcade.json": "c8379450055d4ea226d229b1cbf99c7ed2e52beb",
|
||||
"packages/shared/src/app-definitions/asana.json": "42d051d84a576509d75a73fe49b23443d34759f8",
|
||||
"packages/shared/src/app-definitions/aws.json": "f6413552f37f06e3b003486324c7d892d8f3e5f3",
|
||||
"packages/shared/src/app-definitions/aws.json": "33762ad62b4e45b6c04cce52a0fab67c83a30caa",
|
||||
"packages/shared/src/app-definitions/bedrock.json": "962d8a722ac6e2e4db00abc34f71947a3fdb733a",
|
||||
"packages/shared/src/app-definitions/beehiiv.json": "47aec8fdfbf5aed0919b6ac9bddb435de4988db3",
|
||||
"packages/shared/src/app-definitions/bitly.json": "81f4937e92f2971f2011acb50929adf5287315e4",
|
||||
@@ -261,7 +261,7 @@
|
||||
"packages/shared/src/external-objects.ts": "a9953c4e3f77f2bad03cb7832914ffc0b1a1266a",
|
||||
"packages/shared/src/fast-response.ts": "a81332a2b46b59c1f6953cfc4da659eae2326beb",
|
||||
"packages/shared/src/feature-catalog.test.ts": "d3e000c039492daad1fe0b7302b34e7c3816a8ce",
|
||||
"packages/shared/src/feature-catalog.ts": "f30fed662ad1a7dec4c3012b7653af2f777f0a0d",
|
||||
"packages/shared/src/feature-catalog.ts": "468dbae9dba45b45f1a993de9307c5b6409f513c",
|
||||
"packages/shared/src/frontmatter-runner-contract.test.ts": "cd121330e10aaa9da36c16293bcd9760561b6b41",
|
||||
"packages/shared/src/frontmatter.test.ts": "56635e331c8abca8868da76f23a08e98f20ff07f",
|
||||
"packages/shared/src/frontmatter.ts": "a86e046ce588d2f92d4996122cc2068ec275e89c",
|
||||
@@ -519,7 +519,7 @@
|
||||
"packages/shared/src/validators/inbox-agent-policy.ts": "29cef157f4d9b564fd813868038aa8c813df4a7b",
|
||||
"packages/shared/src/validators/index.ts": "25a142aeffc3b395993347c2d7bb0538738fefc3",
|
||||
"packages/shared/src/validators/instance.test.ts": "3faa9593a9a05f74429d9b1d2251906a03e9a903",
|
||||
"packages/shared/src/validators/instance.ts": "edde733b1d1b91023321c6c59b17b65aadf5dfa1",
|
||||
"packages/shared/src/validators/instance.ts": "1c151c58a13a8aedc8ed04b9c07d31f23fd41d40",
|
||||
"packages/shared/src/validators/issue-chat-bootstrap.test.ts": "e1ebb9aa94da22c825bc3ddd32ce2cfc98bfe645",
|
||||
"packages/shared/src/validators/issue-tree-control.ts": "7144ef86a83e008ac0626e1d62a1d6164c46f438",
|
||||
"packages/shared/src/validators/issue.test.ts": "7584bcce33a933ebcb02695b439767163e5ef61a",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { ArrowUpRight, ChevronRight, Download, Loader2 } from "lucide-react";
|
||||
import { getAppStoreDefinition, type AwsConnectionSetup } from "@paperclipai/shared";
|
||||
import type { AwsConnectionSetup } from "@paperclipai/shared";
|
||||
import { ROLE_ARN_PATTERN, roleArnFromAgentSummary } from "./aws-role-arn";
|
||||
import { ApiError } from "@/api/client";
|
||||
import { toolsApi } from "@/api/tools";
|
||||
import { describeError } from "@/api/errors";
|
||||
@@ -78,20 +79,12 @@ export const AWS_AGENT_SETUP_STEPS: AgentSetupStep[] = [
|
||||
{ key: "report-role", title: "Report the role ARN" },
|
||||
];
|
||||
|
||||
/**
|
||||
* The app definition's role ARN rule (a server test keeps it equal to the server's), so this
|
||||
* check matches what the server accepts. Without a definition the server alone decides.
|
||||
*/
|
||||
const ROLE_ARN_PATTERN = new RegExp(
|
||||
getAppStoreDefinition("aws")?.methods.find((method) => method.key === "aws-role")
|
||||
?.tenantFields?.find((field) => field.key === "roleArn")?.validation?.pattern ?? "^arn:",
|
||||
);
|
||||
|
||||
/**
|
||||
* The middle of AWS role setup: the connection is saved as a draft, so AWS can
|
||||
* now trust exactly this connection. By default the customer hands a prompt to
|
||||
* their own agent, which creates the role, then pastes back the role ARN; the
|
||||
* CloudFormation and by-hand steps are there for anyone who prefers them.
|
||||
* their own agent, which creates the role and reports its ARN back through the
|
||||
* live checklist; the CloudFormation and by-hand steps, and the Role ARN field,
|
||||
* are there for anyone who prefers them.
|
||||
*/
|
||||
export function AwsRoleSetup({
|
||||
connectionId,
|
||||
@@ -118,6 +111,9 @@ export function AwsRoleSetup({
|
||||
const promptReady = !companyId || Boolean(agentProgress.handoff) || Boolean(agentProgress.error);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
const [roleArn, setRoleArn] = useState("");
|
||||
// Set once the person types in the field: the agent's ARN then never replaces their value.
|
||||
const [roleArnEdited, setRoleArnEdited] = useState(false);
|
||||
const [byHandOpen, setByHandOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
@@ -137,6 +133,16 @@ export function AwsRoleSetup({
|
||||
const ready = setup?.available === true ? setup : null;
|
||||
const trimmedArn = roleArn.trim();
|
||||
const arnInvalid = trimmedArn.length > 0 && !ROLE_ARN_PATTERN.test(trimmedArn);
|
||||
const agentFinished = agentProgress.progress?.status === "done";
|
||||
const reportedArn = ready && agentFinished ? roleArnFromAgentSummary(agentProgress.progress?.summary, ready.roleName) : null;
|
||||
useEffect(() => {
|
||||
if (reportedArn && !roleArnEdited) setRoleArn(reportedArn);
|
||||
}, [reportedArn, roleArnEdited]);
|
||||
// The field is under "Or do it by hand"; open it whenever the person has to see or fix the ARN.
|
||||
const needsArnByHand = Boolean(error) || arnInvalid || (agentFinished && !reportedArn);
|
||||
useEffect(() => {
|
||||
if (needsArnByHand) setByHandOpen(true);
|
||||
}, [needsArnByHand]);
|
||||
|
||||
return (
|
||||
<div className="space-y-5" data-testid="aws-role-setup">
|
||||
@@ -171,7 +177,9 @@ export function AwsRoleSetup({
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<span className="text-foreground">Give this prompt to an agent on a computer signed in to your AWS account.</span>{" "}
|
||||
{ready.savedRoleArn ? "It updates the existing role" : "It creates the role"} with the AWS CLI
|
||||
{agentProgress.handoff ? ", shows its progress here," : ""} and tells you the role ARN to paste below.
|
||||
{agentProgress.handoff
|
||||
? ", shows its progress here, and hands back the role when it finishes."
|
||||
: " and tells you the role ARN to paste under Or do it by hand."}
|
||||
</p>
|
||||
{agentProgress.error ? (
|
||||
<InlineBanner tone="warning" title="Live progress isn’t available">
|
||||
@@ -202,25 +210,17 @@ export function AwsRoleSetup({
|
||||
onRetryRefresh={agentProgress.retryRefresh}
|
||||
/>
|
||||
) : null}
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="aws-role-arn" className="text-sm font-medium text-foreground">Role ARN</label>
|
||||
<Input
|
||||
id="aws-role-arn"
|
||||
value={roleArn}
|
||||
onChange={(event) => setRoleArn(event.target.value)}
|
||||
placeholder={`arn:aws:iam::<account ID>:role/${ready.roleName}`}
|
||||
aria-invalid={arnInvalid || undefined}
|
||||
className="font-mono text-base md:text-xs"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
{arnInvalid ? (
|
||||
<p className="text-xs text-destructive">Use the full role ARN, like arn:aws:iam::123456789012:role/{ready.roleName}.</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Collapsible>
|
||||
{reportedArn && trimmedArn === reportedArn ? (
|
||||
<p className="text-sm text-muted-foreground">Your agent’s role is ready. Test the connection to finish.</p>
|
||||
) : agentFinished && !reportedArn ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Your agent finished without a role ARN Paperclip could use. Paste it under Or do it by hand.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<Collapsible open={byHandOpen} onOpenChange={setByHandOpen}>
|
||||
<CollapsibleTrigger className="group flex items-center gap-1 text-sm font-medium text-foreground">
|
||||
<ChevronRight className="h-4 w-4 transition-transform group-data-[state=open]:rotate-90" />
|
||||
Or do it by hand
|
||||
@@ -260,7 +260,7 @@ export function AwsRoleSetup({
|
||||
resources.
|
||||
</li>
|
||||
<li>
|
||||
When the stack finishes, copy RoleArn from its Outputs tab into the field above. If this role came from
|
||||
When the stack finishes, copy RoleArn from its Outputs tab into the Role ARN field below. If this role came from
|
||||
this template before, update that stack (<span className="font-mono text-foreground">{ready.roleName}</span>)
|
||||
with the new template instead of creating another.
|
||||
</li>
|
||||
@@ -277,7 +277,7 @@ export function AwsRoleSetup({
|
||||
{ready.savedRoleArn ? "so its trust policy is the one below" : "with the trust policy below"}, replacing
|
||||
ACCOUNT_ID with your AWS account ID. The CLI commands do either.
|
||||
</li>
|
||||
<li>Attach AWSMCPSignInOAuthAccessPolicy and the permissions agents should have, then paste the role ARN above.</li>
|
||||
<li>Attach AWSMCPSignInOAuthAccessPolicy and the permissions agents should have, then paste the role ARN below.</li>
|
||||
</ol>
|
||||
<CopyRow label="Provider URL" value={ready.issuer} />
|
||||
<CopyRow label="Audience" value={ready.audience} />
|
||||
@@ -286,6 +286,23 @@ export function AwsRoleSetup({
|
||||
<CopyBlock label="Trust policy" value={JSON.stringify(ready.trustPolicy, null, 2)} />
|
||||
<CopyBlock label="AWS CLI commands" value={awsCliCommands(ready)} />
|
||||
</section>
|
||||
|
||||
<section className="space-y-2" aria-label="Role ARN">
|
||||
<label htmlFor="aws-role-arn" className="text-sm font-medium text-foreground">Role ARN</label>
|
||||
<Input
|
||||
id="aws-role-arn"
|
||||
value={roleArn}
|
||||
onChange={(event) => { setRoleArnEdited(true); setRoleArn(event.target.value); }}
|
||||
placeholder={`arn:aws:iam::<account ID>:role/${ready.roleName}`}
|
||||
aria-invalid={arnInvalid || undefined}
|
||||
className="font-mono text-base md:text-xs"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
{arnInvalid ? (
|
||||
<p className="text-xs text-destructive">Use the full role ARN, like arn:aws:iam::123456789012:role/{ready.roleName}.</p>
|
||||
) : null}
|
||||
</section>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
</>
|
||||
@@ -359,7 +376,9 @@ export function awsAgentSetupPrompt(setup: Extract<AwsConnectionSetup, { availab
|
||||
"4. Save the CloudFormation template below to a file and deploy it. This creates the stack, or updates it if it already exists:",
|
||||
` aws cloudformation deploy --stack-name ${stack} --template-file <file> --capabilities CAPABILITY_NAMED_IAM --parameter-overrides CreateIdentityProvider=<true|false>${setup.accessLevel === "full" ? " AccessPolicyArn=<policy ARN>" : ""}`,
|
||||
` If it fails because the role ${setup.roleName} already exists outside this stack, do not delete it. Instead update its trust policy with \`aws iam update-assume-role-policy\` to the trust policy in the template (with this account's ID and the identity provider's ARN), make sure AWSMCPSignInOAuthAccessPolicy and the access policy are attached, and use that role's ARN in step 5.`,
|
||||
`5. Give me the role's ARN (the stack's RoleArn output, or \`aws iam get-role --role-name ${setup.roleName} --query Role.Arn --output text\`), so I can paste it into Paperclip and press Test connection.${progressInstructions ? " Also put it in your finish summary, as \"Role ARN: <arn>\"." : ""}`,
|
||||
progressInstructions
|
||||
? `5. Put the role's ARN (the stack's RoleArn output, or \`aws iam get-role --role-name ${setup.roleName} --query Role.Arn --output text\`) in your finish summary, as "Role ARN: <arn>". Paperclip fills it in from there; then I press Test connection.`
|
||||
: `5. Give me the role's ARN (the stack's RoleArn output, or \`aws iam get-role --role-name ${setup.roleName} --query Role.Arn --output text\`), so I can paste it into Paperclip under Or do it by hand and press Test connection.`,
|
||||
"",
|
||||
"The role trusts only this one Paperclip connection, and no AWS keys are created or shared:",
|
||||
`- Identity provider: ${setup.issuer} (audience ${setup.audience})`,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ROLE_ARN_PATTERN, roleArnFromAgentSummary } from "./aws-role-arn";
|
||||
|
||||
const roleName = "paperclip-c41a8e57-0f3b-4b6e-9d22-7a1e5c3f8b90";
|
||||
const arn = `arn:aws:iam::123456789012:role/${roleName}`;
|
||||
|
||||
describe("roleArnFromAgentSummary", () => {
|
||||
it("reads this connection's role ARN from the agent's finish summary", () => {
|
||||
expect(roleArnFromAgentSummary(`Role ARN: ${arn}`, roleName)).toBe(arn);
|
||||
expect(roleArnFromAgentSummary(`Done. The role is ${arn}.`, roleName)).toBe(arn);
|
||||
expect(roleArnFromAgentSummary(`Role ARN: arn:aws:iam::123456789012:role/team/${roleName}`, roleName))
|
||||
.toBe(`arn:aws:iam::123456789012:role/team/${roleName}`);
|
||||
});
|
||||
|
||||
it("never accepts another role, a longer name, or a malformed account", () => {
|
||||
expect(roleArnFromAgentSummary("Role ARN: arn:aws:iam::123456789012:role/admin", roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary(`Role ARN: ${arn}-copy`, roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary(`Role ARN: ${arn}/other`, roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary(`Role ARN: ${arn}./other`, roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary(`Role ARN: arn:aws:iam::12345:role/${roleName}`, roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary("Stopped: no permission to create the role.", roleName)).toBeNull();
|
||||
expect(roleArnFromAgentSummary(null, roleName)).toBeNull();
|
||||
});
|
||||
|
||||
it("only returns ARNs the connection's own validation accepts", () => {
|
||||
expect(ROLE_ARN_PATTERN.test(roleArnFromAgentSummary(`Role ARN: ${arn}`, roleName)!)).toBe(true);
|
||||
expect(ROLE_ARN_PATTERN.test("arn:aws:s3:::some-bucket")).toBe(false);
|
||||
expect(ROLE_ARN_PATTERN.test(`arn:aws:iam::123456789012:user/${roleName}`)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { getAppStoreDefinition } from "@paperclipai/shared";
|
||||
|
||||
/** An IAM role ARN, the same shape the AWS app definition requires. */
|
||||
const IAM_ROLE_ARN_SHAPE = "^arn:aws[a-z-]*:iam::[0-9]{12}:role/(?:[A-Za-z0-9+=,.@_-]+/)*[A-Za-z0-9+=,.@_-]{1,64}$";
|
||||
|
||||
/**
|
||||
* The app definition's role ARN rule (a server test keeps it equal to the server's), so this
|
||||
* check matches what the server accepts. Without a definition it still requires an IAM role ARN.
|
||||
*/
|
||||
export const ROLE_ARN_PATTERN = new RegExp(
|
||||
getAppStoreDefinition("aws")?.methods.find((method) => method.key === "aws-role")
|
||||
?.tenantFields?.find((field) => field.key === "roleArn")?.validation?.pattern ?? IAM_ROLE_ARN_SHAPE,
|
||||
);
|
||||
|
||||
/**
|
||||
* The role ARN an agent reported in its finish summary, accepted only when it names this
|
||||
* connection's own role, so a summary can never point the connection at another role. An ARN
|
||||
* that continues past the role name (`…/<roleName>/other`) names a different role and is rejected.
|
||||
*/
|
||||
export function roleArnFromAgentSummary(summary: string | null | undefined, roleName: string): string | null {
|
||||
const escaped = roleName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const match = summary?.match(new RegExp(`arn:aws[a-z-]*:iam::\\d{12}:role/(?:[\\w+=,.@-]+/)*${escaped}(?![\\w+=,@/-]|\\.[\\w+=,@/-])`));
|
||||
return match && ROLE_ARN_PATTERN.test(match[0]) ? match[0] : null;
|
||||
}
|
||||
@@ -322,18 +322,6 @@ export function InstanceExperimentalSettings() {
|
||||
ariaLabel="Toggle Areas & Responsibilities dashboard experimental setting"
|
||||
/>
|
||||
|
||||
<ExperimentalToggleCard
|
||||
title="AWS connector"
|
||||
description="Let agents work in AWS through AWS's hosted MCP server, with short-lived credentials made for each connection."
|
||||
footnote="Off by default. While off, the AWS connector cannot be set up or run."
|
||||
checked={experimentalQuery.data?.enableAwsConnector === true}
|
||||
onCheckedChange={(checked) => toggleMutation.mutate({ enableAwsConnector: checked })}
|
||||
disabled={toggleMutation.isPending}
|
||||
settingKey="enableAwsConnector"
|
||||
managed={managedKeys.enableAwsConnector}
|
||||
ariaLabel="Toggle AWS connector experimental setting"
|
||||
/>
|
||||
|
||||
<ExperimentalToggleCard
|
||||
title="Beta skills"
|
||||
description="Allow agents to pin beta releases of the Paperclip core skill. Disabling this returns every agent to the default live skill without removing saved pins."
|
||||
|
||||
Reference in new issue
Block a user