From 0542cf7e6989de23540c409de444c182f5cbd8ac Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 22 Jun 2025 19:10:59 -0400 Subject: [PATCH] integrate models.dev --- opencode.json | 36 +------------------- packages/opencode/src/auth/github-copilot.ts | 8 ++--- packages/opencode/src/provider/provider.ts | 3 +- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/opencode.json b/opencode.json index cbddbd3b..720ece5c 100644 --- a/opencode.json +++ b/opencode.json @@ -1,37 +1,3 @@ { - "$schema": "https://opencode.ai/config.json", - "provider": { - "github-copilot": { - "npm": "@ai-sdk/openai-compatible", - "options": { - "baseURL": "https://api.githubcopilot.com" - }, - "models": { - "gpt-4o": { - "name": "gpt-4o" - }, - "gpt-4.1": { - "name": "gpt-4.1" - }, - "claude-sonnet-4": { - "name": "claude-sonnet-4" - }, - "claude-3.7-sonnet": { - "name": "claude-3.7-sonnet" - }, - "o1": { - "name": "o1" - }, - "o3-mini": { - "name": "o3-mini" - }, - "gemini-2.5-pro": { - "name": "gemini-2.5-pro" - }, - "gemini-2.0-flash-001": { - "name": "gemini-2.0-flash-001" - } - } - } - } + "$schema": "https://opencode.ai/config.json" } diff --git a/packages/opencode/src/auth/github-copilot.ts b/packages/opencode/src/auth/github-copilot.ts index 0b7cc54f..ebbf1c3d 100644 --- a/packages/opencode/src/auth/github-copilot.ts +++ b/packages/opencode/src/auth/github-copilot.ts @@ -94,8 +94,7 @@ export namespace AuthGithubCopilot { export async function access() { const info = await Auth.get("github-copilot") if (!info || info.type !== "oauth") return - if (info.access && info.expires > Date.now()) - return { access: info.access, api: "https://api.githubcopilot.com" } + if (info.access && info.expires > Date.now()) return info.access // Get new Copilot API token const response = await fetch(COPILOT_API_KEY_URL, { @@ -120,10 +119,7 @@ export namespace AuthGithubCopilot { expires: tokenData.expires_at * 1000, }) - return { - access: tokenData.token, - api: tokenData.endpoints.api, - } + return tokenData.token } export const DeviceCodeError = NamedError.create( diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 74577c55..dd7f3599 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -83,13 +83,12 @@ export namespace Provider { return { options: { apiKey: "", - baseURL: info.api, async fetch(input: any, init: any) { const token = await AuthGithubCopilot.access() if (!token) throw new Error("GitHub Copilot authentication expired") const headers = { ...init.headers, - Authorization: `Bearer ${token.access}`, + Authorization: `Bearer ${token}`, "User-Agent": "GithubCopilot/1.155.0", "Editor-Version": "vscode/1.85.1", "Editor-Plugin-Version": "copilot/1.155.0",