Skip to content

Commit 956716b

Browse files
committed
feat: add copilot provider
1 parent fd3535c commit 956716b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2793
-16
lines changed

packages/types/src/provider-settings.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const providerNames = [
4747
"zai",
4848
"fireworks",
4949
"io-intelligence",
50+
"copilot",
5051
"roo",
5152
] as const
5253

@@ -289,6 +290,10 @@ const ioIntelligenceSchema = apiModelIdProviderModelSchema.extend({
289290
ioIntelligenceApiKey: z.string().optional(),
290291
})
291292

293+
const copilotSchema = baseProviderSettingsSchema.extend({
294+
copilotModelId: z.string().optional(),
295+
})
296+
292297
const rooSchema = apiModelIdProviderModelSchema.extend({
293298
// No additional fields needed - uses cloud authentication
294299
})
@@ -329,6 +334,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
329334
zaiSchema.merge(z.object({ apiProvider: z.literal("zai") })),
330335
fireworksSchema.merge(z.object({ apiProvider: z.literal("fireworks") })),
331336
ioIntelligenceSchema.merge(z.object({ apiProvider: z.literal("io-intelligence") })),
337+
copilotSchema.merge(z.object({ apiProvider: z.literal("copilot") })),
332338
rooSchema.merge(z.object({ apiProvider: z.literal("roo") })),
333339
defaultSchema,
334340
])
@@ -366,6 +372,7 @@ export const providerSettingsSchema = z.object({
366372
...zaiSchema.shape,
367373
...fireworksSchema.shape,
368374
...ioIntelligenceSchema.shape,
375+
...copilotSchema.shape,
369376
...rooSchema.shape,
370377
...codebaseIndexProviderSchema.shape,
371378
})
@@ -393,6 +400,7 @@ export const MODEL_ID_KEYS: Partial<keyof ProviderSettings>[] = [
393400
"litellmModelId",
394401
"huggingFaceModelId",
395402
"ioIntelligenceModelId",
403+
"copilotModelId",
396404
]
397405

398406
export const getModelId = (settings: ProviderSettings): string | undefined => {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const copilotDefaultModelId = "gpt-4.1"
2+
3+
export const GITHUB_CLIENT_ID = "Iv1.b507a08c87ecfe98"
4+
export const GITHUB_DEVICE_CODE_URL = "https://github.com/login/device/code"
5+
export const GITHUB_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"
6+
export const GITHUB_API_KEY_URL = "https://api.github.com/copilot_internal/v2/token"
7+
export const GITHUB_COPILOT_API_BASE = "https://api.githubcopilot.com/"
8+
9+
export const COPILOT_DEFAULT_HEADER = {
10+
accept: "application/json",
11+
"content-type": "application/json",
12+
"editor-version": "vscode/1.85.1",
13+
"editor-plugin-version": "copilot/1.155.0",
14+
"user-agent": "GithubCopilot/1.155.0",
15+
"accept-encoding": "gzip,deflate,br",
16+
}

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ export * from "./xai.js"
2525
export * from "./doubao.js"
2626
export * from "./zai.js"
2727
export * from "./fireworks.js"
28+
export * from "./copilot.js"
2829
export * from "./roo.js"

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
DoubaoHandler,
3636
ZAiHandler,
3737
FireworksHandler,
38+
CopilotHandler,
3839
RooHandler,
3940
} from "./providers"
4041
import { NativeOllamaHandler } from "./providers/native-ollama"
@@ -141,6 +142,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
141142
return new FireworksHandler(options)
142143
case "io-intelligence":
143144
return new IOIntelligenceHandler(options)
145+
case "copilot":
146+
return new CopilotHandler(options)
144147
case "roo":
145148
return new RooHandler(options)
146149
default:

0 commit comments

Comments
 (0)