The open source coding agent.
TypeScript
fix: github copilot enterprise integration (#17847)
Aiden Cline68809365dfe3
diff --git a/packages/opencode/src/plugin/copilot.ts b/packages/opencode/src/plugin/copilot.tsindex ddb4d9046a6..31d84532c4e 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<Hooks> {const deploymentType = inputs.deploymentType || "github.com"let domain = "github.com"- let actualProvider = "github-copilot"if (deploymentType === "enterprise") {const enterpriseUrl = inputs.enterpriseUrldomain = normalizeDomain(enterpriseUrl!)- actualProvider = "github-copilot-enterprise"}const urls = getUrls(domain)@@ -262,8 +260,7 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {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.tsindex 349073197d7..2537f894933 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<string, any>) {- 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<Info>) {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 = falseconst 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) continueif (!plugin.auth.loader) continue- // Load for the main provider if auth existsif (auth) {const options = await plugin.auth.loader(() => Auth.get(providerID) as any, database[plugin.auth.provider])const opts = options ?? {}const patch: Partial<Info> = 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<Info> = 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.tsindex 9eac235ceb9..15a919d8eae 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"),