diff --git a/doc/connections/AI-CONNECTIONS.md b/doc/connections/AI-CONNECTIONS.md index 8c24a3d06de..02f947a7f23 100644 --- a/doc/connections/AI-CONNECTIONS.md +++ b/doc/connections/AI-CONNECTIONS.md @@ -535,7 +535,7 @@ credentials belong to the connection; the model belongs to the agent. | Harness | Implemented managed routes | | --- | --- | | Codex legacy and Codex New Runner (app-server) | OpenRouter; custom/local OpenAI Responses endpoints | -| Claude legacy and Claude New Runner (ACPX) | OpenRouter; custom/local Anthropic Messages; Bedrock API key or AWS access keys with optional session token | +| Claude legacy and Claude New Runner (ACPX) | OpenRouter; custom/local Anthropic Messages; Bedrock API key | | OpenCode legacy and New Runner | OpenRouter; custom/local Chat Completions | | Hermes local | OpenRouter; custom/local Chat Completions | | Gemini CLI, Grok | Their native API connections; custom routes are not advertised | @@ -593,5 +593,10 @@ the task, then resumed from a new user message and completed a second shell calculation with the prior context. Reconnect coverage round-trips routing through PostgreSQL JSONB and verifies that credential rotation retains identity and agent access. +General AWS access keys are not accepted or forwarded to Claude; use a Bedrock +API key. Support for AWS roles requires a credential broker before it can ship. +A subsequent OpenCode tool-use check reached OpenRouter but was denied terminal +access; its follow-up ended with `process_lost`. Treat OpenCode tool-use acceptance +as unresolved rather than inferring it from a completed task status. Bedrock and private gateway credentials were not available for live verification; their mapping and validation are covered by deterministic tests. diff --git a/packages/paperclip-runner/runner/crates/runner-core/src/acpx_sidecar_transport.rs b/packages/paperclip-runner/runner/crates/runner-core/src/acpx_sidecar_transport.rs index 611b5b19583..61d66307dcf 100644 --- a/packages/paperclip-runner/runner/crates/runner-core/src/acpx_sidecar_transport.rs +++ b/packages/paperclip-runner/runner/crates/runner-core/src/acpx_sidecar_transport.rs @@ -100,9 +100,6 @@ impl AcpxSidecarTransport { "ANTHROPIC_API_KEY", "CLAUDE_CODE_OAUTH_TOKEN", "ANTHROPIC_AUTH_TOKEN", - "AWS_ACCESS_KEY_ID", - "AWS_SECRET_ACCESS_KEY", - "AWS_SESSION_TOKEN", "AWS_BEARER_TOKEN_BEDROCK", ], "codex" => &[ diff --git a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts index 54230d42455..b357089afc1 100644 --- a/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts +++ b/packages/paperclip-runner/src/control-plane/durable-prp-control-plane.ts @@ -3400,7 +3400,7 @@ function runnerEnvironment( if (value !== undefined) environment[key] = value; } if (explicitSource.CLAUDE_CODE_USE_BEDROCK === "1") { - for (const key of ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "AWS_BEARER_TOKEN_BEDROCK"] as const) { + for (const key of ["AWS_BEARER_TOKEN_BEDROCK"] as const) { if (explicitSource[key] !== undefined) environment[key] = explicitSource[key]; } } diff --git a/packages/paperclip-runner/src/drivers/acpx/environment.test.ts b/packages/paperclip-runner/src/drivers/acpx/environment.test.ts index 4585bc4c9d0..5449b7791fa 100644 --- a/packages/paperclip-runner/src/drivers/acpx/environment.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/environment.test.ts @@ -11,6 +11,7 @@ describe("ACPX launch environment", () => { ANTHROPIC_AUTH_TOKEN: "selected-key", CLAUDE_CODE_USE_BEDROCK: "1", AWS_REGION: "us-east-1", AWS_BEARER_TOKEN_BEDROCK: "bedrock-key", + AWS_ACCESS_KEY_ID: "general-aws-key", AWS_SECRET_ACCESS_KEY: "general-aws-secret", AWS_SESSION_TOKEN: "general-aws-session", PAPERCLIP_AI_PROVIDER_KEY: "codex-key", UNRELATED_SECRET: "private", }; expect(createSanitizedAcpxSpawnInput(source, "claude").env).toEqual({ diff --git a/packages/paperclip-runner/src/drivers/acpx/environment.ts b/packages/paperclip-runner/src/drivers/acpx/environment.ts index 697c565454b..3ce0790542a 100644 --- a/packages/paperclip-runner/src/drivers/acpx/environment.ts +++ b/packages/paperclip-runner/src/drivers/acpx/environment.ts @@ -6,7 +6,7 @@ export const ACPX_CREDENTIAL_NAMES: Readonly; -export const aiAwsCredentialsSchema = z - .object({ - accessKeyId: z.string().trim().min(1).max(256), - secretAccessKey: z.string().min(1).max(4096), - sessionToken: z.string().max(16384).optional(), - }) - .strict(); - export function aiRoutingHarness( adapter: string, provider?: unknown, diff --git a/server/src/__tests__/ai-provider-routing.test.ts b/server/src/__tests__/ai-provider-routing.test.ts index da86ca4457f..d67dcd8e1ea 100644 --- a/server/src/__tests__/ai-provider-routing.test.ts +++ b/server/src/__tests__/ai-provider-routing.test.ts @@ -118,30 +118,26 @@ describe("provider routing", () => { "openrouter/anthropic/claude-sonnet-4.6", ); }); - it("projects AWS credentials and disables ambient instance metadata", () => { + it("projects only a Bedrock API key and rejects general AWS access keys", () => { const routing = aiProviderRoutingSchema.parse({ kind: "bedrock", protocol: "bedrock", - auth: "aws_credentials", + auth: "bearer", region: "us-east-1", }); const projected = managedProviderRouting( routing, "claude_local", - JSON.stringify({ - accessKeyId: "fixture-id", - secretAccessKey: "fixture-secret", - sessionToken: "fixture-token", - }), + "fixture-bedrock-key", "bedrock-model", ); expect(projected.env).toMatchObject({ CLAUDE_CODE_USE_BEDROCK: "1", AWS_REGION: "us-east-1", - AWS_ACCESS_KEY_ID: "fixture-id", - AWS_SECRET_ACCESS_KEY: "fixture-secret", - AWS_SESSION_TOKEN: "fixture-token", + AWS_BEARER_TOKEN_BEDROCK: "fixture-bedrock-key", AWS_EC2_METADATA_DISABLED: "true", }); + expect(aiProviderRoutingSchema.safeParse({ ...routing, auth: "aws_credentials" }).success).toBe(false); + for (const key of ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]) expect(projected.env).not.toHaveProperty(key); }); }); diff --git a/server/src/routes/ai-connections.ts b/server/src/routes/ai-connections.ts index 59a44b52ba5..749562669cf 100644 --- a/server/src/routes/ai-connections.ts +++ b/server/src/routes/ai-connections.ts @@ -303,7 +303,7 @@ export function aiConnectionRoutes(db: Db, options: Parameters ({ // model/harness picker internals are out of scope here, so stub the adapter // layer entirely and drive it through this knob. const mockAdapterRegistry = vi.hoisted(() => ({ - list: [] as Array<{ type: string }>, + list: [] as Array<{ type: string; recommended?: boolean }>, disabled: new Set(), })); @@ -198,7 +198,7 @@ vi.mock("../adapters/adapter-display-registry", () => ({ // then sat in the "Advanced settings" disclosure and was reachable anyway; // with the step down to a tile row built from this flag, it made that row // empty in every test and hid the surface under it. - recommended: type === "claude_local" || type === "codex_local", + recommended: type === "claude_local" || type === "codex_local" || mockAdapterRegistry.list.some(entry => entry.type === type && entry.recommended), label: type, description: "", icon: () => null, @@ -3336,6 +3336,21 @@ describe("OnboardingWizard restore-gate (stale localStorage across accounts)", ( }); }); + it("keeps Gemini local login out of managed Claude subscription setup", async () => { + localHealth.get.mockResolvedValue({ deploymentMode: "local_trusted" }); + mockEnvironmentsApi.list.mockResolvedValue([LOCAL_ENVIRONMENT]); + mockInstanceSettingsApi.get.mockResolvedValue({ defaultEnvironmentId: null }); + mockAdapterRegistry.list.push({ type: "gemini_local", recommended: true }); + const { root } = await openStep4({ adapterType: "gemini_local" }); + try { + await pickSource(/Gemini|Google|gemini_local/); + expect(managedApi.startLocalLogin).not.toHaveBeenCalled(); + expect(managedApi.connectLocal).not.toHaveBeenCalled(); + expect(document.body.textContent).not.toContain("claude auth login"); + expect(mockAgentsApi.startClaudeSetupTokenLogin).not.toHaveBeenCalled(); + } finally { await act(async () => root.unmount()); } + }); + it("shows local Claude instructions and saves its connection before hiring", async () => { localHealth.get.mockResolvedValue({ deploymentMode: "local_trusted" }); mockEnvironmentsApi.list.mockResolvedValue([LOCAL_ENVIRONMENT]); diff --git a/ui/src/components/OnboardingWizard.tsx b/ui/src/components/OnboardingWizard.tsx index f9caf79d0f5..5b254215828 100644 --- a/ui/src/components/OnboardingWizard.tsx +++ b/ui/src/components/OnboardingWizard.tsx @@ -762,6 +762,7 @@ function OnboardingWizardInner({ const apiKeySecretRef = useRef<{ key: string; companyId: string; envKey: string; binding?: Awaited>["binding"]; aiConnection?: AiConnectionBinding } | null>(null); const managedSubscriptionRef = useRef<{ companyId: string; binding: AiConnectionBinding } | null>(null); const managedProvider = aiProviderForAdapter(adapterType); + const managedSubscriptionProvider = managedProvider === "anthropic" || managedProvider === "openai" || managedProvider === "xai" ? managedProvider : undefined; function managedBindingForStep(): AiConnectionBinding | undefined { if (credentialMode === "api") return selectedApiKey?.aiConnection ?? ( !selectedApiKey && apiKeySecretRef.current?.companyId === createdCompanyId && apiKeySecretRef.current.envKey === apiKeyEnvKeyFor(adapterType) @@ -1014,9 +1015,9 @@ function OnboardingWizardInner({ // input here, so this gate alone only decides whether the login mechanism // could ever apply to the current adapter and environment. const localLoginHealth = useQuery({ queryKey: queryKeys.health, queryFn: healthApi.get }); - const canUseLocalLogin = resolvedLoginEnvironment?.driver === "local" && (localLoginHealth.data?.localAiLoginSupported ?? localLoginHealth.data?.deploymentMode === "local_trusted"); + const canUseLocalLogin = Boolean(managedSubscriptionProvider) && resolvedLoginEnvironment?.driver === "local" && (localLoginHealth.data?.localAiLoginSupported ?? localLoginHealth.data?.deploymentMode === "local_trusted"); const localLogin = useLocalAiLogin(createdCompanyId, { - provider: managedProvider === "openai" || managedProvider === "xai" ? managedProvider : "anthropic", method: "subscription", + provider: managedSubscriptionProvider ?? "anthropic", method: "subscription", name: `My ${CONNECT_SOURCE_NAMES[adapterType] ?? managedProvider} subscription`, ownership: "personal", agentIds: [], allAgents: true, }, effectiveOnboardingOpen && step === 4 && canUseLocalLogin && credentialMode !== "api" && @@ -2850,7 +2851,7 @@ function OnboardingWizardInner({ ); }} onConnected={() => { - if (managedProvider) managedSubscriptionRef.current = { companyId: createdCompanyId, binding: { provider: managedProvider, method: "subscription", mode: "responsible_user" } }; + if (managedSubscriptionProvider) managedSubscriptionRef.current = { companyId: createdCompanyId, binding: { provider: managedSubscriptionProvider, method: "subscription", mode: "responsible_user" } }; setConnectAuthUrl(null); // Not into a card the customer has left. The panel is // still mounted through Back's exit, and a login that diff --git a/ui/src/components/ai-connections/AiConnectionField.test.tsx b/ui/src/components/ai-connections/AiConnectionField.test.tsx index d223009f054..f68283bbaac 100644 --- a/ui/src/components/ai-connections/AiConnectionField.test.tsx +++ b/ui/src/components/ai-connections/AiConnectionField.test.tsx @@ -127,7 +127,9 @@ it("does not offer reconnection for a healthy default or another owner's account it("keeps an ordinary member's new connection scoped to the current agent by default", async () => { await mount([], false); + expect(document.body.textContent).toContain("You have no default account"); await click("Connect another account"); + expect(document.querySelector('[role="checkbox"]')!.disabled).toBe(true); expect(credentialProps).toMatchObject({ allAgents: false, agentIds: ["agent"] }); }); diff --git a/ui/src/components/ai-connections/AiConnectionField.tsx b/ui/src/components/ai-connections/AiConnectionField.tsx index 7835b2bc4a6..902cd7884e0 100644 --- a/ui/src/components/ai-connections/AiConnectionField.tsx +++ b/ui/src/components/ai-connections/AiConnectionField.tsx @@ -196,7 +196,7 @@ export function AiConnectionField({ }} /> : <> {!reconnecting && !savedAccount && } {savedAccount ?
diff --git a/ui/src/components/ai-connections/AiConnectionSelect.tsx b/ui/src/components/ai-connections/AiConnectionSelect.tsx index 8bbfc080949..3726eefc0fe 100644 --- a/ui/src/components/ai-connections/AiConnectionSelect.tsx +++ b/ui/src/components/ai-connections/AiConnectionSelect.tsx @@ -162,7 +162,11 @@ export function AiConnectionSelect({
)} - {unavailable ? ( + {value?.mode === "responsible_user" && !personal && !loading && !error ? ( +

+ You have no default account for this provider. Connect an account or choose another connection. +

+ ) : unavailable ? (

This connection is unavailable. Choose another connection.

diff --git a/ui/src/components/ai-connections/AiProviderSetup.test.tsx b/ui/src/components/ai-connections/AiProviderSetup.test.tsx new file mode 100644 index 00000000000..7d8666efef2 --- /dev/null +++ b/ui/src/components/ai-connections/AiProviderSetup.test.tsx @@ -0,0 +1,30 @@ +// @vitest-environment jsdom +import { act, type ComponentProps } from "react"; +import { createRoot } from "react-dom/client"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { expect, it, vi } from "vitest"; +import { AiProviderSetup } from "./AiProviderSetup"; +import type { AiConnectionCredentialStep } from "./AiConnectionCredentialStep"; + +let credentialProps: ComponentProps | undefined; +vi.mock("@/api/ai-connections", () => ({ aiConnectionsApi: { list: vi.fn(async () => ({ currentUserId: "owner", connections: [], canManageConnections: true })) } })); +vi.mock("@/api/agents", () => ({ agentsApi: { list: vi.fn(async () => []) } })); +vi.mock("./AiConnectionCredentialStep", () => ({ AiConnectionCredentialStep: (props: ComponentProps) => { credentialProps = props; return
Existing credential flow
; } })); + +it("reconnects an older OpenRouter account without adding routing metadata", async () => { + const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); + const container = document.createElement("div"); + const root = createRoot(container); + const onComplete = vi.fn(); + const account = { id: "connection", grantId: "grant", companyId: "company", provider: "openrouter", method: "api_key", name: "Existing OpenRouter", ownership: "personal", ownerUserId: "owner", isDefault: true, status: "needs_attention" } as const; + try { + await act(async () => root.render( {}} onComplete={onComplete} />)); + expect(container.textContent).toContain("Existing credential flow"); + expect(credentialProps).toMatchObject({ connectionId: account.id, provider: "openrouter", initialMethod: "api_key", fixedMethod: true }); + credentialProps!.onComplete({ connectionId: account.id, grantId: account.grantId, method: "api_key" }); + expect(onComplete).toHaveBeenCalledWith({ provider: "openrouter", method: "api_key", mode: "delegated", connectionId: account.id, grantId: account.grantId }); + } finally { + await act(async () => root.unmount()); + client.clear(); + } +}); diff --git a/ui/src/components/ai-connections/AiProviderSetup.tsx b/ui/src/components/ai-connections/AiProviderSetup.tsx index e925d46e95f..868cdcf80f8 100644 --- a/ui/src/components/ai-connections/AiProviderSetup.tsx +++ b/ui/src/components/ai-connections/AiProviderSetup.tsx @@ -47,7 +47,7 @@ const providers = [ { id: "bedrock", name: "Amazon Bedrock", - description: "AWS credentials or Bedrock API key", + description: "Bedrock API key and AWS region", advanced: true, }, { @@ -115,9 +115,6 @@ export function AiProviderSetup({ reconnect?.routing?.models.map((m) => m.id).join(", ") ?? "", ); const [apiKey, setApiKey] = useState(""); - const [accessKeyId, setAccessKeyId] = useState(""); - const [secretAccessKey, setSecretAccessKey] = useState(""); - const [sessionToken, setSessionToken] = useState(""); const client = useQueryClient(); const accounts = useQuery({ queryKey: ["ai-connections", companyId, agentId], @@ -130,9 +127,7 @@ export function AiProviderSetup({ queryFn: () => agentsApi.list(companyId), }); const label = providers.find((p) => p.id === provider)?.name ?? "provider"; - const advanced = ["openrouter", "bedrock", "gateway", "local"].includes( - provider ?? "", - ); + const advanced = reconnect ? Boolean(reconnect.routing) : ["openrouter", "bedrock", "gateway", "local"].includes(provider ?? ""); const nativeProvider: AiProvider = provider === "bedrock" ? "anthropic" @@ -198,25 +193,13 @@ export function AiProviderSetup({ agentIds: [...agentIds], connectionId: reconnect?.id, routing, - ...(auth === "aws_credentials" - ? { - awsCredentials: { - accessKeyId, - secretAccessKey, - ...(sessionToken ? { sessionToken } : {}), - }, - } - : auth !== "none" - ? { apiKey } - : {}), + ...(auth !== "none" ? { apiKey } : {}), }), ); }, onSuccess: complete, onSettled: () => { setApiKey(""); - setSecretAccessKey(""); - setSessionToken(""); }, }); const choices = (advancedOnly: boolean) => ( @@ -308,6 +291,7 @@ export function AiProviderSetup({ provider={nativeProvider} connectionId={reconnect?.id} initialMethod={reconnect?.method} + fixedMethod={Boolean(reconnect)} name={name} hideName ownership={ownership} @@ -398,11 +382,7 @@ export function AiProviderSetup({ ? "Bedrock API key" : "Bearer token"} - {provider === "bedrock" ? ( - - AWS access keys - - ) : ( + {provider !== "bedrock" && ( <> {protocol === "messages" && ( @@ -416,39 +396,7 @@ export function AiProviderSetup({ )} - {auth === "aws_credentials" ? ( - <> - - - - - ) : ( + { auth !== "none" && ( ) - )} + }
Advanced model settings @@ -504,9 +452,7 @@ export function AiProviderSetup({ type="submit" disabled={ save.isPending || - (auth === "aws_credentials" - ? !accessKeyId || !secretAccessKey - : auth !== "none" && !apiKey.trim()) + (auth !== "none" && !apiKey.trim()) } > {save.isPending diff --git a/ui/storybook/prototypes/provider-routing/ConnectionSetup.tsx b/ui/storybook/prototypes/provider-routing/ConnectionSetup.tsx index fe9aafa0cb6..a34a2f4d241 100644 --- a/ui/storybook/prototypes/provider-routing/ConnectionSetup.tsx +++ b/ui/storybook/prototypes/provider-routing/ConnectionSetup.tsx @@ -305,9 +305,6 @@ export function ConnectionSetup({ }, ] : []), - ...(isAws - ? [{ value: "aws-keys", label: "AWS access keys" }] - : []), ...(provider === "custom" ? [ { value: "header", label: "Custom authentication header" }, diff --git a/ui/storybook/prototypes/provider-routing/README.md b/ui/storybook/prototypes/provider-routing/README.md index 86e05121e14..218da84cc81 100644 --- a/ui/storybook/prototypes/provider-routing/README.md +++ b/ui/storybook/prototypes/provider-routing/README.md @@ -73,7 +73,7 @@ explicitly opening advanced setup, and preserving a custom selection on collapse 1. **01 Onboarding:** current default sign-in shape, saved reuse, and optional “Use another provider or gateway” entry under Advanced. Walk through setup into an agent. 2. **02 Connect:** provider → Access → Connect; OpenRouter API key, Bedrock region - with API key/AWS credentials/environment identity, Google Vertex identity, + with a Bedrock API key; exploratory environment identity, Google Vertex identity, custom Responses/Messages endpoints, custom auth header, and local endpoint. 3. **03 Agent:** harness/connection/model ownership, new and legacy runners, model discovery and manual alias, incompatibility, loading/empty/denied states, @@ -111,3 +111,8 @@ pnpm build-storybook The walkthrough stories include interaction assertions. Review all story renders, walkthrough results, internal links, and representative light/dark mobile layouts in the browser. + +Production Bedrock setup accepts only a Bedrock API key. General AWS access keys +are excluded until a credential broker can contain them. Environment identity, +Vertex, and arbitrary-header stories remain design explorations, not shipped +provider options. diff --git a/ui/storybook/stories/provider-routing-02-connect.stories.tsx b/ui/storybook/stories/provider-routing-02-connect.stories.tsx index b503818cac0..b331dee6697 100644 --- a/ui/storybook/stories/provider-routing-02-connect.stories.tsx +++ b/ui/storybook/stories/provider-routing-02-connect.stories.tsx @@ -68,13 +68,6 @@ export const BedrockEnvironmentIdentity: Story = { initialMethod: "identity", }, }; -export const BedrockAccessKeys: Story = { - args: { - initialStep: "connect", - initialProvider: "bedrock", - initialMethod: "aws-keys", - }, -}; export const GoogleVertexIdentity: Story = { args: { initialStep: "connect", @@ -111,7 +104,7 @@ export const InvalidCredential: Story = { args: { initialStep: "connect", initialError: "credential" }, }; export const MobileBedrock: Story = { - ...BedrockAccessKeys, + ...BedrockApiKey, globals: { viewport: { value: "mobile", isRotated: false } }, }; export const CustomEndpointWalkthrough: Story = { diff --git a/ui/storybook/stories/provider-routing-06-production.stories.tsx b/ui/storybook/stories/provider-routing-06-production.stories.tsx index 72c1cf1fcc4..b56f55fd4d0 100644 --- a/ui/storybook/stories/provider-routing-06-production.stories.tsx +++ b/ui/storybook/stories/provider-routing-06-production.stories.tsx @@ -160,6 +160,6 @@ export const MemberProviderAccess: Story = { const canvas = within(canvasElement); await userEvent.click(canvas.getByRole("button", { name: "OpenAI" })); await expect(canvas.getByText("Which agents can use this connection?", { exact: true })).toBeVisible(); - await expect(canvas.getByRole("button", { name: "Continue", exact: true })).toBeEnabled(); + await expect(canvas.getByRole("button", { name: /^Continue$/ })).toBeEnabled(); }, };