diff --git a/doc/connections/github-copilot.md b/doc/connections/github-copilot.md index 8031ec85233..6980b69b77b 100644 --- a/doc/connections/github-copilot.md +++ b/doc/connections/github-copilot.md @@ -6,14 +6,18 @@ The [qualification record](../plans/2026-10-20-copilot-qualification-v47.json) identifies the tested build, retained failures, and remaining release gates. On first setup, choose **GitHub Copilot** when creating your first agent. In an -existing organization, open **Connectors → GitHub → Connect Copilot**. Create a -fine-grained personal access token owned by your personal GitHub account and -add the **Copilot Requests** account permission. Organization-owned tokens and -classic personal tokens are unsupported for this setup. Follow +existing organization, open **Connectors → GitHub Copilot → Connect**. GitHub +Copilot is its own connector, separate from the **GitHub** connector for +repository and MCP access. Create a fine-grained personal access token owned +by your personal GitHub account and add the **Copilot Requests** account +permission. Organization-owned tokens and classic personal tokens are +unsupported for this setup. Follow [GitHub's authentication instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli). Save the token as a personal or shared AI connection and select the execution -environment. Paperclip uses its encrypted credential store, grants, access +environment. Copilot accounts saved before the split are listed under GitHub +Copilot as well, and older `source=github&method=copilot-token` setup links +redirect there. Paperclip uses its encrypted credential store, grants, access checks, reconnect/revocation, and activity logging. GitHub repository/MCP access uses its separate connection and grants. Copilot execution receives only the selected runtime token as `COPILOT_GITHUB_TOKEN`; ambient GitHub credentials diff --git a/packages/shared/src/ai-connections.ts b/packages/shared/src/ai-connections.ts index 6aba41f15e8..4192761de2d 100644 --- a/packages/shared/src/ai-connections.ts +++ b/packages/shared/src/ai-connections.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { aiProviderRoutingSchema, aiRoutingHarness, isAiRoutingCompatible, type AiProviderRouting } from "./ai-provider-routing.js"; +import { aiConnectionCatalogSlug, aiProviderRoutingSchema, aiRoutingHarness, isAiRoutingCompatible, type AiProviderRouting } from "./ai-provider-routing.js"; /** Runtime authentication is a separate transport, never a tool or channel. */ export const connectionPurposeTransportSchema = z.discriminatedUnion( @@ -70,6 +70,18 @@ export type AiConnectionBinding = z.infer; export const aiConnectionMetadataSchema = z.object({ ...requirement, routing: aiProviderRoutingSchema.optional() }).strict(); export type AiConnectionMetadata = z.infer; +/** + * Catalog source of a saved AI connection. It reads the AI metadata, not the + * application, so accounts saved under an earlier catalog entry still resolve. + */ +export function aiConnectionSourceSlug( + connection: { connectionPurpose?: string | null; config?: Record | null } | null | undefined, +): string | null { + if (connection?.connectionPurpose !== "ai") return null; + const metadata = aiConnectionMetadataSchema.safeParse(connection.config?.ai); + return metadata.success ? aiConnectionCatalogSlug(metadata.data.provider, metadata.data.routing) : null; +} + /** Existing integrations only. This table describes compatibility, never routing. */ export const AI_CONNECTION_CAPABILITIES: Record< AiProvider, diff --git a/packages/shared/src/ai-provider-routing.ts b/packages/shared/src/ai-provider-routing.ts index 519c93bd489..8149629b707 100644 --- a/packages/shared/src/ai-provider-routing.ts +++ b/packages/shared/src/ai-provider-routing.ts @@ -141,6 +141,7 @@ export function aiConnectionCatalogSlug(provider: string, routing?: Pick @@ -257,7 +258,7 @@ describe("AppDefinition catalog", () => { it("validates all Wave 1 definitions", () => expect(() => appDefinitionsSchema.parse(APP_DEFINITIONS)).not.toThrow()); it("lists model providers as regular tagged catalog entries", () => { - const slugs = ["openai", "anthropic", "openrouter", "xai", "google", "bedrock", "responses-api", "messages-api", "chat-completions-api", "local"]; + const slugs = ["openai", "anthropic", "openrouter", "xai", "google", "github-copilot", "bedrock", "responses-api", "messages-api", "chat-completions-api", "local"]; expect(APP_STORE_DEFINITIONS.filter(app => app.tags?.includes("model-provider")).map(app => app.slug).sort()).toEqual(slugs.sort()); for (const slug of slugs) { const app = APP_STORE_DEFINITIONS.find(app => app.slug === slug)!; @@ -322,15 +323,32 @@ describe("AppDefinition catalog", () => { it("separates GitHub tools from the review bot without changing the provider identity", () => { const github = getConnectableAppDefinition("github")!; const bot = getConnectableAppDefinition("github-code-review-bot")!; - expect(github.methods.map((method) => method.key)).toEqual(["managed", "mcp-key", "copilot-token"]); - expect(github.methods.filter((method) => method.purpose === "tool").map((method) => method.key)).toEqual(["managed", "mcp-key"]); - expect(github.methods.find((method) => method.key === "copilot-token")).toMatchObject({ purpose: "ai", transport: "runtime_auth" }); + expect(github.methods.map((method) => method.key)).toEqual(["managed", "mcp-key"]); + expect(github.methods.every((method) => method.purpose === "tool")).toBe(true); expect(bot.name).toBe("GitHub Code Review Bot"); expect(bot.methods).toHaveLength(1); expect(bot.methods[0]).toMatchObject({ provider: "github", purpose: "channel", transport: "chat_sdk" }); expect(bot.branding).toEqual(github.branding); expect(bot.urlPatterns).toEqual([]); }); + it("offers GitHub Copilot authentication as its own connector, separate from GitHub tools", () => { + const github = getAppStoreDefinition("github")!; + const copilot = getAppStoreDefinition("github-copilot")!; + expect(copilot.name).toBe("GitHub Copilot"); + expect(copilot.categories).toEqual(["ai"]); + expect(copilot.methods.map((method) => method.key)).toEqual(["copilot-token"]); + expect(copilot.methods[0]).toMatchObject({ + purpose: "ai", + transport: "runtime_auth", + ai: { provider: "github", method: "api_key" }, + keyPlacement: { location: "env", name: "COPILOT_GITHUB_TOKEN" }, + }); + expect(copilot.branding.logoUrl).not.toBe(github.branding.logoUrl); + expect(copilot.urlPatterns).toEqual([]); + expect(github.categories).not.toContain("ai"); + expect(github.description).not.toContain("Copilot"); + expect(aiConnectionCatalogSlug("github")).toBe("github-copilot"); + }); it("registers the five native chat providers with only required setup credentials", () => { const expected = { slack: { @@ -906,7 +924,7 @@ describe("AppDefinition catalog", () => { "ticktick", "xero", ]); - expect(APP_STORE_DEFINITIONS).toHaveLength(90); + expect(APP_STORE_DEFINITIONS).toHaveLength(91); const connectableSlugs = new Set( CONNECTABLE_APP_DEFINITIONS.map((entry) => entry.slug), ); diff --git a/packages/shared/src/app-definitions.ts b/packages/shared/src/app-definitions.ts index de39d817de0..f8c9c3aa66e 100644 --- a/packages/shared/src/app-definitions.ts +++ b/packages/shared/src/app-definitions.ts @@ -41,6 +41,7 @@ export const CONNECTABLE_APP_SLUGS = new Set([ "google-workspace", "github", "github-code-review-bot", + "github-copilot", "discord", "speko", "microsoft-teams", diff --git a/packages/shared/src/app-definitions/github-copilot.json b/packages/shared/src/app-definitions/github-copilot.json new file mode 100644 index 00000000000..c98ddd4f362 --- /dev/null +++ b/packages/shared/src/app-definitions/github-copilot.json @@ -0,0 +1,56 @@ +{ + "schemaVersion": 1, + "slug": "github-copilot", + "name": "GitHub Copilot", + "description": "Run GitHub Copilot agents with your Copilot account.", + "categories": [ + "ai" + ], + "featured": false, + "urlPatterns": [], + "methods": [ + { + "key": "copilot-token", + "label": "GitHub Copilot personal access token", + "purpose": "ai", + "transport": "runtime_auth", + "auth": "api_key", + "ai": { + "provider": "github", + "method": "api_key" + }, + "grantKinds": [ + "user", + "organization" + ], + "ownershipModes": [ + "customer" + ], + "whenToUse": "Authenticate the GitHub Copilot agent runtime with a personal or explicitly shared account.", + "guidanceMd": "Create a personal fine-grained token with the Copilot Requests permission. Copilot authentication is separate from GitHub repository and MCP access. [GitHub authentication instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli).", + "riskTier": "S3", + "credentialFields": [ + { + "key": "apiKey", + "label": "Personal access token", + "type": "password", + "required": true, + "placeholder": "github_pat_...", + "secret": true, + "helperMd": "Use a personal fine-grained token with Copilot Requests permission." + } + ], + "keyPlacement": { + "location": "env", + "name": "COPILOT_GITHUB_TOKEN" + } + } + ], + "tags": [ + "model-provider" + ], + "branding": { + "logoUrl": "/brands/apps/github-copilot.svg", + "darkLogoUrl": "/brands/apps/github-copilot-dark.svg" + } +} diff --git a/packages/shared/src/app-definitions/github.json b/packages/shared/src/app-definitions/github.json index 9eb13cfb65c..18b30f1ba83 100644 --- a/packages/shared/src/app-definitions/github.json +++ b/packages/shared/src/app-definitions/github.json @@ -2,10 +2,9 @@ "schemaVersion": 1, "slug": "github", "name": "GitHub", - "description": "Connect GitHub repository access or authenticate GitHub Copilot agents.", + "description": "Give agents access to GitHub repositories, issues, and pull requests.", "categories": [ - "developer", - "ai" + "developer" ], "featured": true, "branding": { @@ -81,42 +80,6 @@ "organization", "repository" ] - }, - { - "key": "copilot-token", - "label": "GitHub Copilot personal access token", - "purpose": "ai", - "transport": "runtime_auth", - "auth": "api_key", - "ai": { - "provider": "github", - "method": "api_key" - }, - "grantKinds": [ - "user", - "organization" - ], - "ownershipModes": [ - "customer" - ], - "whenToUse": "Authenticate the GitHub Copilot agent runtime with a personal or explicitly shared account.", - "guidanceMd": "Create a personal fine-grained token with the Copilot Requests permission. Copilot authentication is separate from repository and MCP access. [GitHub authentication instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli).", - "riskTier": "S3", - "credentialFields": [ - { - "key": "apiKey", - "label": "Personal access token", - "type": "password", - "required": true, - "placeholder": "github_pat_...", - "secret": true, - "helperMd": "Use a personal fine-grained token with Copilot Requests permission." - } - ], - "keyPlacement": { - "location": "env", - "name": "COPILOT_GITHUB_TOKEN" - } } ] } diff --git a/scripts/app-definition-overrides/github-copilot.json b/scripts/app-definition-overrides/github-copilot.json new file mode 100644 index 00000000000..dcffeb8fb1f --- /dev/null +++ b/scripts/app-definition-overrides/github-copilot.json @@ -0,0 +1,52 @@ +{ + "schemaVersion": 1, + "slug": "github-copilot", + "name": "GitHub Copilot", + "description": "Run GitHub Copilot agents with your Copilot account.", + "categories": [ + "ai" + ], + "featured": false, + "urlPatterns": [], + "methods": [ + { + "key": "copilot-token", + "label": "GitHub Copilot personal access token", + "purpose": "ai", + "transport": "runtime_auth", + "auth": "api_key", + "ai": { + "provider": "github", + "method": "api_key" + }, + "grantKinds": [ + "user", + "organization" + ], + "ownershipModes": [ + "customer" + ], + "whenToUse": "Authenticate the GitHub Copilot agent runtime with a personal or explicitly shared account.", + "guidanceMd": "Create a personal fine-grained token with the Copilot Requests permission. Copilot authentication is separate from GitHub repository and MCP access. [GitHub authentication instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli).", + "riskTier": "S3", + "credentialFields": [ + { + "key": "apiKey", + "label": "Personal access token", + "type": "password", + "required": true, + "placeholder": "github_pat_...", + "secret": true, + "helperMd": "Use a personal fine-grained token with Copilot Requests permission." + } + ], + "keyPlacement": { + "location": "env", + "name": "COPILOT_GITHUB_TOKEN" + } + } + ], + "tags": [ + "model-provider" + ] +} diff --git a/scripts/app-definition-overrides/github.json b/scripts/app-definition-overrides/github.json index 69ca1d712db..14863db3fe5 100644 --- a/scripts/app-definition-overrides/github.json +++ b/scripts/app-definition-overrides/github.json @@ -2,10 +2,9 @@ "schemaVersion": 1, "slug": "github", "name": "GitHub", - "description": "Connect GitHub repository access or authenticate GitHub Copilot agents.", + "description": "Give agents access to GitHub repositories, issues, and pull requests.", "categories": [ - "developer", - "ai" + "developer" ], "featured": true, "urlPatterns": [ @@ -77,42 +76,6 @@ "organization", "repository" ] - }, - { - "key": "copilot-token", - "label": "GitHub Copilot personal access token", - "purpose": "ai", - "transport": "runtime_auth", - "auth": "api_key", - "ai": { - "provider": "github", - "method": "api_key" - }, - "grantKinds": [ - "user", - "organization" - ], - "ownershipModes": [ - "customer" - ], - "whenToUse": "Authenticate the GitHub Copilot agent runtime with a personal or explicitly shared account.", - "guidanceMd": "Create a personal fine-grained token with the Copilot Requests permission. Copilot authentication is separate from repository and MCP access. [GitHub authentication instructions](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli).", - "riskTier": "S3", - "credentialFields": [ - { - "key": "apiKey", - "label": "Personal access token", - "type": "password", - "required": true, - "placeholder": "github_pat_...", - "secret": true, - "helperMd": "Use a personal fine-grained token with Copilot Requests permission." - } - ], - "keyPlacement": { - "location": "env", - "name": "COPILOT_GITHUB_TOKEN" - } } ] } diff --git a/server/src/__tests__/ai-connections.test.ts b/server/src/__tests__/ai-connections.test.ts index 8e12493de88..9ca870ca3d9 100644 --- a/server/src/__tests__/ai-connections.test.ts +++ b/server/src/__tests__/ai-connections.test.ts @@ -1676,6 +1676,14 @@ console.log(JSON.stringify({ type: "result", subtype: "success", result: "hello" } }); + it("files Copilot accounts under the GitHub Copilot connector, not GitHub", async () => { + const saved = await service.save(companyId, "alice", { provider: "github", method: "api_key", ownership: "personal", name: "Copilot catalog", apiKey: "github_pat_fixture_catalog", agentIds: [], allAgents: false }, "github_pat_fixture_catalog"); + const [stored] = await db.select().from(toolConnections).where(eq(toolConnections.id, saved.connectionId)); + expect(stored!.config.sourceTemplateKey).toBe("github-copilot"); + const [application] = await db.select().from(toolApplications).where(eq(toolApplications.id, stored!.applicationId)); + expect(application).toMatchObject({ applicationKey: "app-gallery:github-copilot", name: "GitHub Copilot", metadata: { sourceTemplateKey: "github-copilot" } }); + }); + it("reconnects JSONB routing without changing its identity or access", async () => { const routing = { kind: "gateway", protocol: "responses", auth: "bearer", baseUrl: "https://gateway.example/v1", models: [{ id: "gateway-model" }] } as const; const input = { provider: "openai", method: "api_key", name: "Reconnect gateway", ownership: "personal", allAgents: false, agentIds: [agentId], routing: { ...routing, models: [...routing.models] } } as const; diff --git a/server/src/__tests__/connection-intents-service.test.ts b/server/src/__tests__/connection-intents-service.test.ts index 22a67d78a28..299e63cf943 100644 --- a/server/src/__tests__/connection-intents-service.test.ts +++ b/server/src/__tests__/connection-intents-service.test.ts @@ -458,6 +458,7 @@ describeEmbeddedPostgres("connectionIntentService", () => { .rejects.toThrow("was not found"); expect((await service.search(claims, "github")).results).toEqual([ expect.objectContaining({ service: "github", state: "available" }), + expect.objectContaining({ service: "github-copilot", state: "available" }), ]); await expect(service.request(claims, "github")).resolves.toMatchObject({ state: "needs_user_action", @@ -478,10 +479,17 @@ describeEmbeddedPostgres("connectionIntentService", () => { auth: "api_key", purpose: "tool", }), + ], + }), + ); + const copilot = search.results.find((result) => result.service === "github-copilot"); + expect(copilot).toEqual( + expect.objectContaining({ + methods: [ expect.objectContaining({ key: "copilot-token", purpose: "ai", - setupPath: expect.stringContaining("/apps/connect?source=github"), + setupPath: expect.stringMatching(/\/apps\/connect\?source=github-copilot$/), }), ], }), @@ -1022,6 +1030,96 @@ describeEmbeddedPostgres("connectionIntentService", () => { }); + it("requests Copilot authentication through the GitHub Copilot connector", async () => { + const companyId = claims.company_id; + const agentId = randomUUID(); + const issueId = randomUUID(); + const aiRunId = randomUUID(); + await db.insert(agents).values({ id: agentId, companyId, name: "Copilot Agent", adapterType: "paperclip_runner", + adapterConfig: { provider: "acpx", acpxAgent: "copilot", model: "gpt-5.6-luna" }, + runtimeConfig: { aiConnection: { provider: "github", method: "api_key", mode: "responsible_user" } } }); + await db.insert(issues).values({ id: issueId, companyId, title: "Copilot authentication", status: "in_progress", assigneeAgentId: agentId }); + await db.insert(heartbeatRuns).values({ id: aiRunId, companyId, agentId, status: "running", responsibleUserId: claims.responsible_user_id, contextSnapshot: { issueId } }); + const service = connectionIntentService(db); + const aiRequest = await service.request({ ...claims, sub: agentId, run_id: aiRunId }, "github", { purpose: "ai" }); + expect(aiRequest).toMatchObject({ service: "github-copilot", state: "needs_user_action" }); + const setup = await service.setupOptions(aiRequest.interactionId!); + expect(setup.service).toMatchObject({ service: "github-copilot", name: "GitHub Copilot" }); + expect(setup.service.methods.map((method) => method.key)).toEqual(["copilot-token"]); + expect(setup.aiConnection).toMatchObject({ provider: "github", method: "api_key" }); + }); + + async function copilotAccountFixture(agentRuntimeConfig: Record, run: { status: "running" | "failed"; errorCode?: string }) { + const companyId = claims.company_id; + const userId = claims.responsible_user_id!; + const agentId = randomUUID(); + const issueId = randomUUID(); + const runId = randomUUID(); + const [agent] = await db.insert(agents).values({ id: agentId, companyId, name: "Copilot Agent", adapterType: "paperclip_runner", + adapterConfig: { provider: "acpx", acpxAgent: "copilot", model: "gpt-5.6-luna" }, runtimeConfig: agentRuntimeConfig }).returning(); + await db.insert(issues).values({ id: issueId, companyId, title: "Copilot authentication", status: "in_progress", assigneeAgentId: agentId }); + await db.insert(heartbeatRuns).values({ id: runId, companyId, agentId, status: run.status, errorCode: run.errorCode ?? null, responsibleUserId: userId, contextSnapshot: { issueId } }); + const [application] = await db.insert(toolApplications).values({ companyId, applicationKey: `app-gallery:github:${randomUUID()}`, name: `GitHub ${randomUUID()}`, type: "mcp_http", metadata: { sourceTemplateKey: "github" } }).returning(); + const [connection] = await db.insert(toolConnections).values({ companyId, applicationId: application!.id, name: "Older Copilot account", uid: `ai-${randomUUID()}`, connectionPurpose: "ai", transport: "runtime_auth", authKind: "api_key", credentialPolicy: "per_user", healthStatus: "ok", status: "active", enabled: true, config: { sourceTemplateKey: "github", ai: { provider: "github", method: "api_key" } } }).returning(); + const [grant] = await db.insert(connectionGrants).values({ companyId, connectionId: connection!.id, kind: "user", subjectUserId: userId, createdByUserId: userId }).returning(); + await db.delete(aiProviderDefaults).where(and(eq(aiProviderDefaults.companyId, companyId), eq(aiProviderDefaults.userId, userId), eq(aiProviderDefaults.provider, "github"))); + await db.insert(aiProviderDefaults).values({ companyId, userId, provider: "github", grantId: grant!.id }); + return { companyId, userId, agent: agent!, issueId, runId, connection: connection! }; + } + + it("completes a Copilot request saved before the connector split with an older Copilot account", async () => { + const f = await copilotAccountFixture({ aiConnection: { provider: "github", method: "api_key", mode: "responsible_user" } }, { status: "running" }); + const card = await issueThreadInteractionService(db).createConnectionIntent({ id: f.issueId, companyId: f.companyId }, { + payload: { version: 1, serviceSlug: "github", serviceName: "GitHub", serviceLogoUrl: null, requestingAgentId: f.agent.id, + requestingAgentName: f.agent.name, phase: "requested", purpose: "ai" }, + sourceRunId: f.runId, + addresseeUserId: f.userId, + idempotencyKey: `connection-intent:${f.runId}:${f.userId}:github:ai`, + }); + expect((await connectionIntentService(db).setupOptions(card.id)).service).toMatchObject({ service: "github-copilot" }); + await expect(connectionIntentService(db).complete(card.id, f.connection.id, f.userId)).resolves.toMatchObject({ status: "accepted" }); + }); + + it("keeps a Copilot request declined before the connector split declined in its continuation", async () => { + const companyId = claims.company_id; + const userId = claims.responsible_user_id!; + const agentId = randomUUID(); + const issueId = randomUUID(); + const runId = randomUUID(); + const continuationRunId = randomUUID(); + await db.insert(agents).values({ id: agentId, companyId, name: "Copilot Agent", adapterType: "paperclip_runner", + adapterConfig: { provider: "acpx", acpxAgent: "copilot", model: "gpt-5.6-luna" }, + runtimeConfig: { aiConnection: { provider: "github", method: "api_key", mode: "responsible_user" } } }); + await db.insert(issues).values({ id: issueId, companyId, title: "Copilot authentication", status: "in_progress", assigneeAgentId: agentId }); + await db.insert(heartbeatRuns).values({ id: runId, companyId, agentId, status: "running", responsibleUserId: userId, contextSnapshot: { issueId } }); + const intents = connectionIntentService(db); + const card = await issueThreadInteractionService(db).createConnectionIntent({ id: issueId, companyId }, { + payload: { version: 1, serviceSlug: "github", serviceName: "GitHub", serviceLogoUrl: null, requestingAgentId: agentId, + requestingAgentName: "Copilot Agent", phase: "requested", purpose: "ai" }, + sourceRunId: runId, + addresseeUserId: userId, + idempotencyKey: `connection-intent:${runId}:${userId}:github:ai`, + }); + await intents.decline(card.id, userId); + await db.insert(heartbeatRuns).values({ id: continuationRunId, companyId, agentId, status: "running", responsibleUserId: userId, + contextSnapshot: { issueId, interactionId: card.id } }); + await expect(intents.request({ ...claims, sub: agentId, run_id: continuationRunId }, "github", { purpose: "ai" })) + .rejects.toThrow("The user declined this connection"); + }); + + it("adopts a Copilot account for an agent without a saved AI connection", async () => { + const f = await copilotAccountFixture({}, { status: "failed", errorCode: "copilot_auth_required" }); + const intents = connectionIntentService(db); + const card = await intents.requestForRunAuthFailure(f.runId); + expect(card).toMatchObject({ service: "github-copilot", state: "needs_user_action" }); + const setup = await intents.setupOptions(card!.interactionId!); + expect(setup).toMatchObject({ aiConnectionRequiresAdoption: true, aiConnection: { provider: "github", mode: "responsible_user" } }); + await expect(intents.complete(card!.interactionId!, f.connection.id, f.userId, { + validatedAdoption: { agentUpdatedAt: f.agent.updatedAt, binding: setup.aiConnection! }, + })).resolves.toMatchObject({ status: "accepted" }); + expect((await db.select().from(agents).where(eq(agents.id, f.agent.id)))[0]!.runtimeConfig.aiConnection).toMatchObject({ provider: "github", mode: "responsible_user" }); + }); + async function accessFixture(source = "composio") { const [company] = await db.insert(companies).values({ name: "Grant fixture", issuePrefix: `G${randomUUID().slice(0, 7)}` }).returning(); const [agent] = await db.insert(agents).values({ companyId: company.id, name: "Default agent", role: "general", adapterType: "process" }).returning(); diff --git a/server/src/services/connection-intents.ts b/server/src/services/connection-intents.ts index ad59e88414b..f008af33efc 100644 --- a/server/src/services/connection-intents.ts +++ b/server/src/services/connection-intents.ts @@ -12,7 +12,7 @@ import { createHash } from "node:crypto"; import { isDeepStrictEqual } from "node:util"; import { logActivity } from "./activity-log.js"; import { aiConnectionService } from "./ai-connections.js"; -import { aiConnectionBindingSchema, aiConnectionRouterBindingSchema } from "@paperclipai/shared"; +import { aiConnectionBindingSchema, aiConnectionCatalogSlug, aiConnectionRouterBindingSchema, aiConnectionSourceSlug } from "@paperclipai/shared"; import { aiBindingForAuthRecovery, isAiAuthenticationFailure, isAiAuthenticationRepairable } from "./ai-auth-failure.js"; import { and, eq, desc, isNull, notInArray, sql } from "drizzle-orm"; import type { Db } from "@paperclipai/db"; @@ -111,11 +111,21 @@ function sourceSlugForApplication(application: ToolApplication | undefined) { return text(application?.metadata?.sourceTemplateKey) ?? text(application?.metadata?.galleryKey); } +function aiBindingMatchesService(provider: string, serviceSlug: string) { + return provider === serviceSlug || aiConnectionCatalogSlug(provider) === serviceSlug; +} + +/** AI intents saved before a provider had its own catalog entry still name the provider. */ +function intentCatalogSlug(payload: { serviceSlug: string; purpose?: string }) { + return payload.purpose === "ai" ? aiConnectionCatalogSlug(payload.serviceSlug) : payload.serviceSlug; +} + function sourceSlugForConnection( connection: ToolConnection, applications: ReadonlyMap, ) { - const source = text(connection.config?.sourceTemplateKey) + const source = aiConnectionSourceSlug(connection) + ?? text(connection.config?.sourceTemplateKey) ?? text(connection.transportConfig?.sourceTemplateKey) ?? sourceSlugForApplication(applications.get(connection.applicationId)); return source && getAppStoreDefinition(source) ? source : `connection:${connection.id}`; @@ -323,7 +333,7 @@ export function connectionIntentService(db: Db) { // account. Legacy direct-account cards remain readable across upgrades. if (!options.agentSetupOperationId && aiConnectionRouterBindingSchema.safeParse(agent.runtimeConfig.aiConnection).success) return null; const managed = await queuedSetupManagedAgent(agent, client); - return managed?.binding.provider === serviceSlug ? managed : null; + return managed && aiBindingMatchesService(managed.binding.provider, serviceSlug) ? managed : null; } const router = aiConnectionRouterBindingSchema.safeParse(agent.runtimeConfig.aiConnection).data; if (router) { @@ -336,12 +346,12 @@ export function connectionIntentService(db: Db) { if (!source || !isAiAuthenticationFailure(source.errorCode) || source.status !== "failed" || evidence?.poolId !== router.connectionId || !taskKey) return null; const [pin] = await client.select().from(aiConnectionTaskPins).where(and(eq(aiConnectionTaskPins.companyId, companyId), eq(aiConnectionTaskPins.poolId, router.connectionId), eq(aiConnectionTaskPins.agentId, agentId), eq(aiConnectionTaskPins.taskKey, taskKey))); const binding = pin?.selection.binding; - if (!pin || binding?.provider !== serviceSlug || JSON.stringify(evidence.binding) !== JSON.stringify(binding)) return null; + if (!pin || !binding || !aiBindingMatchesService(binding.provider, serviceSlug) || JSON.stringify(evidence.binding) !== JSON.stringify(binding)) return null; return { agent, binding, adapterConfig: { ...agent.adapterConfig, ...pin.selection.runtimeConfig }, requiresAdoption: false }; } const saved = aiConnectionBindingSchema.safeParse(agent.runtimeConfig.aiConnection).data; const binding = saved ?? options.fallback; - return binding?.provider === serviceSlug ? { agent, binding, adapterConfig: agent.adapterConfig, requiresAdoption: !saved } : null; + return binding && aiBindingMatchesService(binding.provider, serviceSlug) ? { agent, binding, adapterConfig: agent.adapterConfig, requiresAdoption: !saved } : null; } async function usableConnectionForAgent(input: { @@ -448,7 +458,7 @@ export function connectionIntentService(db: Db) { async function resolveService(service: string, companyId: string, userId: string, agentId: string, purpose?: "ai" | "channel") { if (!service.startsWith("connection:")) { - const app = getAppStoreDefinition(service); + const app = getAppStoreDefinition(purpose === "ai" ? aiConnectionCatalogSlug(service) : service); if (!app) throw notFound("Connection service was not found"); if (app.experimentalFeatureKey && !isConnectorFeatureEnabled(app, await instanceSettingsService(db).getExperimental())) { throw notFound("Connection service was not found"); @@ -984,7 +994,8 @@ export function connectionIntentService(db: Db) { const outcomeId = context.run.contextSnapshot?.interactionId; if (typeof outcomeId === "string") { const [outcome] = await db.select().from(issueThreadInteractions).where(and(eq(issueThreadInteractions.id, outcomeId), eq(issueThreadInteractions.companyId, context.run.companyId), eq(issueThreadInteractions.issueId, context.issue.id))); - if (outcome?.kind === "connection_intent" && outcome.status === "rejected" && connectionIntentPayloadSchema.parse(outcome.payload).serviceSlug === app.slug && connectionIntentPayloadSchema.parse(outcome.payload).purpose === options.purpose) { + const declined = outcome?.kind === "connection_intent" && outcome.status === "rejected" ? connectionIntentPayloadSchema.parse(outcome.payload) : null; + if (declined && intentCatalogSlug(declined) === app.slug && declined.purpose === options.purpose) { throw conflict("The user declined this connection. Pursue alternatives; do not request it again in this continuation."); } } @@ -1260,7 +1271,7 @@ export function connectionIntentService(db: Db) { if (sourceSlugForConnection( selectedConnection, new Map([[selectedApplication.id, selectedApplication]]), - ) !== payload.serviceSlug) { + ) !== intentCatalogSlug(payload)) { throw notFound("Connection does not match this intent"); } if (selectedConnection.status !== "active" || !selectedConnection.enabled || isToolConnectionAttentionHealth(selectedConnection.healthStatus)) { @@ -1296,7 +1307,7 @@ export function connectionIntentService(db: Db) { throw conflict("The agent changed during validation. Reload the task and try again."); } const binding = options.validatedAdoption.binding; - if (binding.provider !== payload.serviceSlug || binding.mode !== "responsible_user") throw conflict("Invalid legacy adoption binding"); + if (!aiBindingMatchesService(binding.provider, payload.serviceSlug) || binding.mode !== "responsible_user") throw conflict("Invalid legacy adoption binding"); const updated = await updateAgentConfigurationInTransaction(txDb, agent.id, { runtimeConfig: { ...agent.runtimeConfig, aiConnection: binding }, }, { recordRevision: { createdByUserId: userId, source: "patch" } }); @@ -1475,7 +1486,7 @@ export function connectionIntentService(db: Db) { eq(issueThreadInteractions.sourceRunId, run.id), operationId ? sql`${issueThreadInteractions.payload}->>'agentSetupOperationId' = ${operationId}` : undefined, sql`${issueThreadInteractions.payload}->>'agentSetup' = 'true'`, - sql`${issueThreadInteractions.payload}->>'serviceSlug' = ${binding.provider}`, + sql`${issueThreadInteractions.payload}->>'serviceSlug' in (${binding.provider}, ${aiConnectionCatalogSlug(binding.provider)})`, )).limit(1); if (pending) continue; if (!await canActorReadIssuePrivacy(db, { type: "board", userId: verificationUserId, ignoreInstanceAdmin: true }, issue)) continue; diff --git a/tests/runner-e2e/source-sdk-public-inputs.json b/tests/runner-e2e/source-sdk-public-inputs.json index cc160f2ffb3..ec9b7c3a5ef 100644 --- a/tests/runner-e2e/source-sdk-public-inputs.json +++ b/tests/runner-e2e/source-sdk-public-inputs.json @@ -63,8 +63,8 @@ "packages/shared/src/aggregator-apps.ts": "2a69a54ee0cb305170275b6f4e97689c107defb1", "packages/shared/src/ai-connection-router.ts": "9fbd89c385a4d5827bc68e1c7f6a66e00453d413", "packages/shared/src/ai-connection-usage.ts": "4b51573ee92f8a2ae0f80dd15288a0e59b4dddc7", - "packages/shared/src/ai-connections.ts": "6aba41f15e8879fed5d9e3d9199e9a9983647a4e", - "packages/shared/src/ai-provider-routing.ts": "519c93bd489100125e9a4ad096611f25fd60af4e", + "packages/shared/src/ai-connections.ts": "4192761de2dfc02c2e93342077f03c577e862590", + "packages/shared/src/ai-provider-routing.ts": "8149629b707981f0c90118c019eb9c9a88aa435f", "packages/shared/src/analytics-consent.test.ts": "0c69d867d4f108cb57c07b4e71633e058cb7506b", "packages/shared/src/analytics-consent.ts": "00c4bfbd24ac3a288a68caae52468dfcd26df3e7", "packages/shared/src/announcements.test.ts": "121ed97b560e0dd271fe6602c97e2415ee4e4bf7", @@ -72,10 +72,10 @@ "packages/shared/src/antigravity-runtime.test.ts": "f9ebcc9430be51c342b42644b735f1434b405ec7", "packages/shared/src/api.ts": "1d61cdff51433c4136368d52ee7cf2f16aa820ed", "packages/shared/src/app-definitions-url.test.ts": "56792d6745a5bc7eafc36e7403f4c9bbd671ae99", - "packages/shared/src/app-definitions.generated.ts": "854539d487e1eb12bbef36f96889dc032ed56c41", + "packages/shared/src/app-definitions.generated.ts": "b162e9621fab029951d77a6b4605ab7893904a3a", "packages/shared/src/app-definitions.ingestion-report.json": "a7b60c7c16a484a411989315e9f08d48258fa647", - "packages/shared/src/app-definitions.test.ts": "20b31d44848f415076431f03e829365c6ae19467", - "packages/shared/src/app-definitions.ts": "de39d817de0aa90ff1cc218d62bcc886bb5608d6", + "packages/shared/src/app-definitions.test.ts": "c66ab693bd49ddcc8acc2c2c5049c3dacd034d36", + "packages/shared/src/app-definitions.ts": "f8c9c3aa66ea3bbe38c3a2eff7abca9a25911c83", "packages/shared/src/app-definitions/1password.json": "c11a4777de2c78805b2d391da5eb075a9511e0f8", "packages/shared/src/app-definitions/agentmail.json": "edd0799b1980d0f5f43b89c8f7a1173dc623f7fa", "packages/shared/src/app-definitions/airtable.json": "c9b216a2bbe693bc6167413255d41c33512d418d", @@ -115,7 +115,8 @@ "packages/shared/src/app-definitions/fireflies.json": "2c4605a6044ccdd4e6cd66d2763f80a2fc5c88c0", "packages/shared/src/app-definitions/gauge.json": "da9d1f2bd1592689f7363462c7c432d6f20a156f", "packages/shared/src/app-definitions/github-code-review-bot.json": "c5897ebcbbbf4f0c2d243574748d4e682f14e57e", - "packages/shared/src/app-definitions/github.json": "9eb13cfb65c54ffc6a9b1fb6d32085d4f0a32cbf", + "packages/shared/src/app-definitions/github-copilot.json": "c98ddd4f362dafe803b991c186f524a3c39e47d1", + "packages/shared/src/app-definitions/github.json": "18b30f1ba83712780889d9063608bee93848d98e", "packages/shared/src/app-definitions/gmail.json": "a0f2dcfaaeca5bf54318d8cad82a0cb188e72bea", "packages/shared/src/app-definitions/google-calendar.json": "ab9e93999dd69a5d432ae66195e517c66aad2b74", "packages/shared/src/app-definitions/google-chat.json": "f3cf1f37b4b9f0e937b2af2e8d86ebf5df83ac7c", diff --git a/ui/public/brands/apps/github-copilot-dark.svg b/ui/public/brands/apps/github-copilot-dark.svg new file mode 100644 index 00000000000..d3b97b39108 --- /dev/null +++ b/ui/public/brands/apps/github-copilot-dark.svg @@ -0,0 +1 @@ + diff --git a/ui/public/brands/apps/github-copilot.svg b/ui/public/brands/apps/github-copilot.svg new file mode 100644 index 00000000000..6860a0c7aef --- /dev/null +++ b/ui/public/brands/apps/github-copilot.svg @@ -0,0 +1 @@ + diff --git a/ui/public/brands/apps/manifest.json b/ui/public/brands/apps/manifest.json index e6260708456..4d3e6451cd7 100644 --- a/ui/public/brands/apps/manifest.json +++ b/ui/public/brands/apps/manifest.json @@ -193,6 +193,13 @@ "localAsset": "/brands/apps/github.svg", "darkAsset": "/brands/apps/github-dark.svg" }, + { + "slug": "github-copilot", + "provider": "GitHub Copilot", + "catalogVisible": true, + "localAsset": "/brands/apps/github-copilot.svg", + "darkAsset": "/brands/apps/github-copilot-dark.svg" + }, { "slug": "gmail", "provider": "Gmail", diff --git a/ui/src/components/ai-connections/AiConnectionIdentity.tsx b/ui/src/components/ai-connections/AiConnectionIdentity.tsx index 23d71aead47..f34c54e230e 100644 --- a/ui/src/components/ai-connections/AiConnectionIdentity.tsx +++ b/ui/src/components/ai-connections/AiConnectionIdentity.tsx @@ -1,4 +1,5 @@ import { Building2, UserRound } from "lucide-react"; +import { aiConnectionCatalogSlug } from "@paperclipai/shared"; import { AppLogo } from "@/pages/apps/AppLogo"; import { AI_PROVIDERS, @@ -17,7 +18,7 @@ export function AiConnectionIdentity({ const Icon = connection.ownership === "shared" ? Building2 : UserRound; return (
- +
{connection.name} diff --git a/ui/src/components/ai-connections/AiConnectionPicker.tsx b/ui/src/components/ai-connections/AiConnectionPicker.tsx index b3738bab67d..4cfc15f5c98 100644 --- a/ui/src/components/ai-connections/AiConnectionPicker.tsx +++ b/ui/src/components/ai-connections/AiConnectionPicker.tsx @@ -1,3 +1,4 @@ +import { aiConnectionCatalogSlug } from "@paperclipai/shared"; import { AppLogo } from "@/pages/apps/AppLogo"; import { ConnectionChoiceList } from "@/features/connections/ConnectionChoiceList"; import { Button } from "@/components/ui/button"; @@ -76,7 +77,7 @@ export function AiConnectionPicker({
navigate( - `/apps/connect?source=${account.provider}&reconnect=${connection.id}&method=ai-${account.method}`, + `/apps/connect?source=${aiConnectionCatalogSlug(account.provider)}&reconnect=${connection.id}&method=ai-${account.method}`, ) } /> diff --git a/ui/src/components/ai-connections/model.ts b/ui/src/components/ai-connections/model.ts index f309219b395..a19d44b41f6 100644 --- a/ui/src/components/ai-connections/model.ts +++ b/ui/src/components/ai-connections/model.ts @@ -7,7 +7,7 @@ export const AI_PROVIDERS: Record< AiProvider, { name: string; subscriptionName?: string; logo?: string } > = { - github: { name: "GitHub Copilot", logo: "/brands/apps/github.svg" }, + github: { name: "GitHub Copilot", logo: "/brands/apps/github-copilot.svg" }, google: { name: "Google", subscriptionName: "Google Antigravity account", logo: "/brands/apps/google.svg" }, anthropic: { name: "Claude", diff --git a/ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts b/ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts index ba2526c13d7..dd5a3a9b7c2 100644 --- a/ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts +++ b/ui/src/features/connections/ConnectionSetupFlow.oauth.test.ts @@ -196,6 +196,41 @@ describe("retained reconnect definition lookup", () => { })).toBe(expected); }); + it("resumes an older Copilot draft saved under the GitHub application through GitHub Copilot", () => { + const github = { + id: "app-github", + companyId: "company-1", + applicationKey: "app-gallery:github", + metadata: { sourceTemplateKey: "github" }, + } as unknown as ToolApplication; + const copilotDraft = { + id: "connection-1", + companyId: "company-1", + applicationId: "app-github", + status: "draft", + connectionPurpose: "ai", + config: { sourceTemplateKey: "github", ai: { provider: "github", method: "api_key" } }, + } as unknown as ToolConnection; + const githubDraft = { + id: "connection-2", + companyId: "company-1", + applicationId: "app-github", + status: "draft", + config: { sourceTemplateKey: "github" }, + } as unknown as ToolConnection; + const resume = (requestedAppKey: string, resumeConnection: ToolConnection) => retainedResumeMatches({ + requestedAppKey, + resumeConnection, + resumeApplication: github, + completedResumeConnectionId: null, + }); + + expect(resume("github-copilot", copilotDraft)).toBe(true); + expect(resume("github", copilotDraft)).toBe(false); + expect(resume("github-copilot", githubDraft)).toBe(false); + expect(resume("github", githubDraft)).toBe(true); + }); + it("does not apply fresh-setup availability to an exact retained reconnect", () => { expect(isVercelConnectUnavailable({ credentialSource: "vercel_connect", @@ -267,6 +302,33 @@ describe("retained reconnect target matching", () => { reconnectApplication: curated, })).toBe(false); }); + + it("reconnects older Copilot accounts saved under the GitHub application through GitHub Copilot", () => { + const github = { + id: "app-1", + applicationKey: "app-gallery:github", + metadata: { sourceTemplateKey: "github" }, + } as unknown as ToolApplication; + const copilot = { + applicationId: "app-1", + connectionPurpose: "ai", + config: { sourceTemplateKey: "github", ai: { provider: "github", method: "api_key" } }, + } as unknown as ToolConnection; + expect(retainedReconnectMatches({ + requestedAppKey: "github-copilot", + byo: false, + applicationId: undefined, + reconnectConnection: copilot, + reconnectApplication: github, + })).toBe(true); + expect(retainedReconnectMatches({ + requestedAppKey: "github-copilot", + byo: false, + applicationId: undefined, + reconnectConnection: connection, + reconnectApplication: github, + })).toBe(false); + }); }); describe("connection intent OAuth failure reasons", () => { diff --git a/ui/src/features/connections/ConnectionSetupFlow.tsx b/ui/src/features/connections/ConnectionSetupFlow.tsx index 5fcb64c8d26..a624b81594a 100644 --- a/ui/src/features/connections/ConnectionSetupFlow.tsx +++ b/ui/src/features/connections/ConnectionSetupFlow.tsx @@ -89,7 +89,7 @@ import { resolveAuthorizationTarget } from "@/lib/authorizationUrl"; import { prepareOAuthNavigation, savePendingCloudHandoff } from "@/lib/oauthHandoff"; import { askFirstCatalogEntryIdsFor } from "./connection-defaults"; import { AppLogo } from "@/pages/apps/AppLogo"; -import { appApplicationSourceSlug, appConnectionSourceSlug } from "@/pages/apps/app-definition-display"; +import { aiConnectionSourceSlug, appApplicationSourceSlug, appConnectionSourceSlug } from "@/pages/apps/app-definition-display"; import { UnverifiedServerBadge } from "@/pages/apps/UnverifiedServerBadge"; import { appSourceConnectHref, @@ -235,6 +235,13 @@ export function requestedConnectionEntry(input: { return getConnectableAppDefinition(input.requestedAppKey); } +// AI accounts saved before their provider had its own catalog entry stay on +// the earlier application, so their AI metadata also identifies the source. +function retainedApplicationMatches(application: ToolApplication, connection: ToolConnection, requestedAppKey: string) { + return appApplicationSourceSlug(application) === requestedAppKey + || aiConnectionSourceSlug(connection) === requestedAppKey; +} + export function retainedResumeMatches(input: { requestedAppKey: string; resumeConnection: ToolConnection | null; @@ -251,7 +258,7 @@ export function retainedResumeMatches(input: { && resumeApplication && resumeConnection.applicationId === resumeApplication.id && resumeConnection.companyId === resumeApplication.companyId - && appApplicationSourceSlug(resumeApplication) === requestedAppKey + && retainedApplicationMatches(resumeApplication, resumeConnection, requestedAppKey) && appConnectionSourceSlug(resumeConnection) === requestedAppKey, ); } @@ -269,7 +276,7 @@ export function retainedReconnectMatches(input: { || input.reconnectConnection.applicationId !== input.reconnectApplication.id ) return false; if (input.requestedAppKey) { - return appApplicationSourceSlug(input.reconnectApplication) === input.requestedAppKey; + return retainedApplicationMatches(input.reconnectApplication, input.reconnectConnection, input.requestedAppKey); } // Generic MCP applications intentionally have no provider slug. Their // reconnect URL instead carries the exact retained application identity. @@ -2333,7 +2340,7 @@ function StandardConnectionSetupFlow({ setInstallAgentIds={setInstallAgentIds} lockedAgentId={requestedAgentId} capabilities={galleryQuery.data?.capabilities} - githubIdentity={entry?.slug === "github"} + githubIdentity={entry?.slug === "github" || entry?.slug === "github-copilot"} identityLoading={Boolean(automaticOAuthEntry) && directOAuthLookupPending} preserveAgentAccess={preservesAgentAccess} disabled={connectMutation.isPending || oauthStartMutation.isPending} diff --git a/ui/src/pages/apps/AppDetail.tsx b/ui/src/pages/apps/AppDetail.tsx index ecb3753dc5a..de5fe154e3c 100644 --- a/ui/src/pages/apps/AppDetail.tsx +++ b/ui/src/pages/apps/AppDetail.tsx @@ -47,6 +47,7 @@ import { cn } from "@/lib/utils"; import { AppLogo } from "./AppLogo"; import { UnverifiedServerBadge } from "./UnverifiedServerBadge"; import { + aiConnectionSourceSlug, appApplicationSourceSlug, appConnectionSourceSlug, appDefinitionDarkLogoUrl, @@ -241,7 +242,8 @@ function StandardAppDetail({ renderActions, renderAgentSettings, renderConnectio const peer = paperclipPeerFromMcpUrl(typeof connection?.config?.url === "string" ? connection.config.url : null); return peer ? { provider: peer.host, template: paperclipPeerInstructionTemplate(peer) } : null; }, [logoEntry, connection]); - const brandKey = appApplicationSourceSlug(application) + const brandKey = aiConnectionSourceSlug(connection) + ?? appApplicationSourceSlug(application) ?? appConnectionSourceSlug(connection) ?? (logoEntry ? appDefinitionSlug(logoEntry) : null); const userProfileById = useMemo( @@ -628,7 +630,7 @@ function StandardAppDetail({ renderActions, renderAgentSettings, renderConnectio galleryEntry={logoEntry} canReconnect={canReconnect} reconnectUnavailableMessage={reconnectUnavailableMessage} - onReconnect={onReconnect ? () => onReconnect(connection) : (connection.connectionPurpose === "ai" || isRemoteMcpConnectorMethod(connection.config?.sourceTemplateKey, connection.config?.connectionMethodKey)) ? () => navigate(`/apps/connect?source=${connection.config?.sourceTemplateKey}&reconnect=${connection.id}`) : undefined} + onReconnect={onReconnect ? () => onReconnect(connection) : (connection.connectionPurpose === "ai" || isRemoteMcpConnectorMethod(connection.config?.sourceTemplateKey, connection.config?.connectionMethodKey)) ? () => navigate(`/apps/connect?source=${aiConnectionSourceSlug(connection) ?? connection.config?.sourceTemplateKey}&reconnect=${connection.id}`) : undefined} onReconnected={() => { queryClient.invalidateQueries({ queryKey: queryKeys.tools.connection(connectionId) }); queryClient.invalidateQueries({ queryKey: queryKeys.tools.connections(selectedCompanyId) }); diff --git a/ui/src/pages/apps/AppsConnect.test.tsx b/ui/src/pages/apps/AppsConnect.test.tsx index d0800e4c4ff..626f1744188 100644 --- a/ui/src/pages/apps/AppsConnect.test.tsx +++ b/ui/src/pages/apps/AppsConnect.test.tsx @@ -54,6 +54,7 @@ const mockCompany = vi.hoisted(() => ({ const ZAPIER = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "zapier")!; const GITHUB = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "github")!; +const GITHUB_COPILOT = CONNECTABLE_APP_DEFINITIONS.find((app) => app.slug === "github-copilot")!; const GITHUB_MANAGED = { ...GITHUB, ownershipAvailability: { @@ -1230,8 +1231,8 @@ describe("AppsConnect — Connect with a link (M4 frame)", () => { }); it.each([false, true])("opens Copilot with visible personal defaults and shares only by explicit choice (%s)", async (share) => { - mockSearch.value = "source=github&method=copilot-token"; - listGalleryMock.mockResolvedValue({ apps: [GITHUB] }); + mockSearch.value = "source=github-copilot"; + listGalleryMock.mockResolvedValue({ apps: [GITHUB, GITHUB_COPILOT] }); const client = new QueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity } } }); client.setQueryData(queryKeys.environments.list("company-1"), [ { id: "local-env", name: "Local", driver: "local", status: "active", config: {} }, @@ -1272,6 +1273,16 @@ describe("AppsConnect — Connect with a link (M4 frame)", () => { expect(mockNavigate).toHaveBeenCalledWith("/apps/copilot-ai-account/permissions"); }); + it("redirects older GitHub Copilot setup links to the GitHub Copilot connector", async () => { + mockSearch.value = "source=github&method=copilot-token&agentId=agent-1"; + listGalleryMock.mockResolvedValue({ apps: [GITHUB, GITHUB_COPILOT] }); + await render(); + expect(mockNavigate).toHaveBeenCalledWith( + "/apps/connect?source=github-copilot&method=copilot-token&agentId=agent-1", + { replace: true }, + ); + }); + it("states the GitHub identity default and keeps its controls one click away", async () => { mockParams.appKey = "github"; listGalleryMock.mockResolvedValue({ apps: [GITHUB_MANAGED] }); diff --git a/ui/src/pages/apps/AppsConnect.tsx b/ui/src/pages/apps/AppsConnect.tsx index 4ca07a1ddab..4e447159d66 100644 --- a/ui/src/pages/apps/AppsConnect.tsx +++ b/ui/src/pages/apps/AppsConnect.tsx @@ -56,6 +56,15 @@ export function AppsConnect({ byoOnly = false, credentialSource = "paperclip_vau useEffect(() => { if (hasSavedComposio) navigate(`/apps?source=composio&targetToolkit=${encodeURIComponent(toolkit!)}`, { replace: true }); }, [hasSavedComposio, toolkit, navigate]); + const legacyCopilotLink = source === "github" && searchParams.get("method") === "copilot-token"; + useEffect(() => { + if (!legacyCopilotLink) return; + const params = new URLSearchParams(searchParams); + params.delete("appKey"); + params.set("source", "github-copilot"); + navigate(`/apps/connect?${params.toString()}`, { replace: true }); + }, [legacyCopilotLink, searchParams, navigate]); + if (legacyCopilotLink) return null; if (reuseComposio && selectedCompanyId && (saved.isPending || savedView.kind === "reconnecting" || hasSavedComposio)) return

Checking saved Composio accounts…

; if (reuseComposio && savedView.kind === "error") return
diff --git a/ui/src/pages/apps/Browse.test.tsx b/ui/src/pages/apps/Browse.test.tsx index 1292e9762fd..1c6d21308e6 100644 --- a/ui/src/pages/apps/Browse.test.tsx +++ b/ui/src/pages/apps/Browse.test.tsx @@ -1314,10 +1314,38 @@ describe("Connectors landing page", () => { expect(container.textContent).not.toContain("Chat with agents"); await act(() => void container.querySelector('button[aria-label="Add key GitHub"]')!.click()); expect(navigateMock).toHaveBeenLastCalledWith("/apps/connect?source=github"); - const copilot = [...container.querySelectorAll("button")].find(button => button.textContent === "Connect Copilot")!; - expect(copilot).toBeTruthy(); - await act(() => void copilot.click()); - expect(navigateMock).toHaveBeenLastCalledWith("/apps/connect?source=github&method=copilot-token"); + }); + + it("lists GitHub Copilot as its own connector and keeps saved Copilot accounts off the GitHub card", async () => { + listGalleryMock.mockResolvedValue({ apps: ["github", "github-copilot"].map(getAppStoreDefinition) }); + listApplicationsMock.mockResolvedValue({ applications: [application({ + id: "github-app", name: "GitHub", applicationKey: "app-gallery:github", metadata: { sourceTemplateKey: "github" }, + })] }); + listConnectionsMock.mockResolvedValue({ connections: [ + connection({ id: "github-tools", applicationId: "github-app", name: "octocat", config: { sourceTemplateKey: "github" } }), + connection({ + id: "copilot-account", applicationId: "github-app", name: "My Copilot", connectionPurpose: "ai", transport: "runtime_auth", authKind: "api_key", + config: { sourceTemplateKey: "github", ai: { provider: "github", method: "api_key" } }, + }), + ] }); + await renderBrowse(); + const github = container.querySelector('[data-app-slug="github"]')!; + const copilot = container.querySelector('[data-app-slug="github-copilot"]')!; + expect(github.querySelector("h2")?.textContent).toBe("GitHub"); + expect(copilot.querySelector("h2")?.textContent).toBe("GitHub Copilot"); + expect(github.textContent).toContain("octocat"); + expect(github.textContent).not.toContain("My Copilot"); + expect(github.textContent).not.toContain("Copilot"); + expect(copilot.textContent).toContain("My Copilot"); + expect(copilot.textContent).not.toContain("octocat"); + expect([...container.querySelectorAll("button")].some(button => button.textContent === "Connect Copilot")).toBe(false); + }); + + it("opens Copilot setup from the GitHub Copilot card", async () => { + listGalleryMock.mockResolvedValue({ apps: ["github", "github-copilot"].map(getAppStoreDefinition) }); + await renderBrowse(); + await act(() => void container.querySelector('button[aria-label="Connect GitHub Copilot"]')!.click()); + expect(navigateMock).toHaveBeenLastCalledWith("/apps/connect?source=github-copilot"); }); it("names what the card will actually ask for", async () => { diff --git a/ui/src/pages/apps/Browse.tsx b/ui/src/pages/apps/Browse.tsx index 8cd94ced3de..4ee152e2bb7 100644 --- a/ui/src/pages/apps/Browse.tsx +++ b/ui/src/pages/apps/Browse.tsx @@ -1239,9 +1239,6 @@ export function ConnectorCard({ chatProviderVisible(row.slug, chatConnectorsEnabled, githubReviewBotsEnabled), preselectedAgentId, ); - const copilotMethod = row.slug === "github" - ? getAppStoreDefinition(row.slug)?.methods.find(method => method.purpose === "ai" && method.ai?.provider === "github") - : undefined; const upstreamAccounts = (row.upstreamApps ?? []).flatMap(snapshot => { const connection = connectionById?.get(snapshot.connectionId); return connection ? snapshot.accounts.map((account, index) => ({ connection, account, snapshot, @@ -1295,14 +1292,6 @@ export function ConnectorCard({ {row.aggregatorApp && row.upstreamApps?.some(app => app.accounts.length > 0) ? `Accounts managed in ${[...new Set(row.upstreamApps?.map(app => AGGREGATOR_NAMES[app.provider ?? "composio"]))].join(" and ")}.` : row.description}

- {copilotMethod && } {setupEnabled &&