From 68809365dfe32dd13ad9b3a8c2f555b2e8fa049b Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:05:14 -0500 Subject: [PATCH] fix: github copilot enterprise integration (#17847) --- packages/opencode/src/plugin/copilot.ts | 5 +- packages/opencode/src/provider/provider.ts | 56 +--------------------- packages/opencode/src/provider/schema.ts | 1 - 3 files changed, 2 insertions(+), 60 deletions(-) diff --git a/packages/opencode/src/plugin/copilot.ts b/packages/opencode/src/plugin/copilot.ts index ddb4d9046..31d84532c 100644 --- a/packages/opencode/src/plugin/copilot.ts +++ b/packages/opencode/src/plugin/copilot.ts @@ -185,12 +185,10 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise { const deploymentType = inputs.deploymentType || "github.com" let domain = "github.com" - let actualProvider = "github-copilot" if (deploymentType === "enterprise") { const enterpriseUrl = inputs.enterpriseUrl domain = normalizeDomain(enterpriseUrl!) - actualProvider = "github-copilot-enterprise" } const urls = getUrls(domain) @@ -262,8 +260,7 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise { expires: 0, } - if (actualProvider === "github-copilot-enterprise") { - result.provider = "github-copilot-enterprise" + if (deploymentType === "enterprise") { result.enterpriseUrl = domain } diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 349073197..2537f8949 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -197,16 +197,6 @@ export namespace Provider { options: {}, } }, - "github-copilot-enterprise": async () => { - return { - autoload: false, - async getModel(sdk: any, modelID: string, _options?: Record) { - if (useLanguageModel(sdk)) return sdk.languageModel(modelID) - return shouldUseCopilotResponsesApi(modelID) ? sdk.responses(modelID) : sdk.chat(modelID) - }, - options: {}, - } - }, azure: async (provider) => { const resource = iife(() => { const name = provider.options?.resourceName @@ -863,20 +853,6 @@ export namespace Provider { const configProviders = Object.entries(config.provider ?? {}) - // Add GitHub Copilot Enterprise provider that inherits from GitHub Copilot - if (database["github-copilot"]) { - const githubCopilot = database["github-copilot"] - database["github-copilot-enterprise"] = { - ...githubCopilot, - id: ProviderID.githubCopilotEnterprise, - name: "GitHub Copilot Enterprise", - models: mapValues(githubCopilot.models, (model) => ({ - ...model, - providerID: ProviderID.githubCopilotEnterprise, - })), - } - } - function mergeProvider(providerID: ProviderID, provider: Partial) { const existing = providers[providerID] if (existing) { @@ -1003,46 +979,16 @@ export namespace Provider { const providerID = ProviderID.make(plugin.auth.provider) if (disabled.has(providerID)) continue - // For github-copilot plugin, check if auth exists for either github-copilot or github-copilot-enterprise - let hasAuth = false const auth = await Auth.get(providerID) - if (auth) hasAuth = true - - // Special handling for github-copilot: also check for enterprise auth - if (providerID === ProviderID.githubCopilot && !hasAuth) { - const enterpriseAuth = await Auth.get("github-copilot-enterprise") - if (enterpriseAuth) hasAuth = true - } - - if (!hasAuth) continue + if (!auth) continue if (!plugin.auth.loader) continue - // Load for the main provider if auth exists if (auth) { const options = await plugin.auth.loader(() => Auth.get(providerID) as any, database[plugin.auth.provider]) const opts = options ?? {} const patch: Partial = providers[providerID] ? { options: opts } : { source: "custom", options: opts } mergeProvider(providerID, patch) } - - // If this is github-copilot plugin, also register for github-copilot-enterprise if auth exists - if (providerID === ProviderID.githubCopilot) { - const enterpriseProviderID = ProviderID.githubCopilotEnterprise - if (!disabled.has(enterpriseProviderID)) { - const enterpriseAuth = await Auth.get(enterpriseProviderID) - if (enterpriseAuth) { - const enterpriseOptions = await plugin.auth.loader( - () => Auth.get(enterpriseProviderID) as any, - database[enterpriseProviderID], - ) - const opts = enterpriseOptions ?? {} - const patch: Partial = providers[enterpriseProviderID] - ? { options: opts } - : { source: "custom", options: opts } - mergeProvider(enterpriseProviderID, patch) - } - } - } } for (const [id, fn] of Object.entries(CUSTOM_LOADERS)) { diff --git a/packages/opencode/src/provider/schema.ts b/packages/opencode/src/provider/schema.ts index 9eac235ce..15a919d8e 100644 --- a/packages/opencode/src/provider/schema.ts +++ b/packages/opencode/src/provider/schema.ts @@ -18,7 +18,6 @@ export const ProviderID = providerIdSchema.pipe( google: schema.makeUnsafe("google"), googleVertex: schema.makeUnsafe("google-vertex"), githubCopilot: schema.makeUnsafe("github-copilot"), - githubCopilotEnterprise: schema.makeUnsafe("github-copilot-enterprise"), amazonBedrock: schema.makeUnsafe("amazon-bedrock"), azure: schema.makeUnsafe("azure"), openrouter: schema.makeUnsafe("openrouter"),