Skip to content

Commit 882bd0b

Browse files
committed
fix(core): route Copilot Claude through plugin
1 parent 28eea85 commit 882bd0b

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎packages/core/src/plugin/provider/github-copilot.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ export const GithubCopilotPlugin = define({
202202
if (!loaded.models.has(Model.ID.make(id))) evt.model.remove(item.provider.id, id)
203203
}
204204
for (const [id, model] of loaded.models) {
205-
evt.model.update(item.provider.id, id, (draft) => Object.assign(draft, structuredClone(model)))
205+
evt.model.update(item.provider.id, id, (draft) => {
206+
Object.assign(draft, structuredClone(model))
207+
if (Provider.packageName(draft.package) === "@ai-sdk/anthropic") {
208+
draft.package = Provider.aisdk("@ai-sdk/github-copilot")
209+
}
210+
})
206211
}
207212
} else if (loaded.baseURL) {
208213
for (const id of item.models.keys()) {
@@ -230,14 +235,15 @@ export const GithubCopilotPlugin = define({
230235
"sdk",
231236
Effect.fn(function* (evt) {
232237
if (evt.model.providerID !== Provider.ID.githubCopilot) return
233-
if (evt.package !== "@ai-sdk/github-copilot" && evt.package !== "@ai-sdk/anthropic") return
238+
if (evt.package !== "@ai-sdk/github-copilot") return
239+
const anthropic = evt.options.endpoint === "messages"
234240
evt.options.fetch = copilotFetch(
235241
typeof evt.options.apiKey === "string" ? evt.options.apiKey : undefined,
236242
evt.options.fetch,
237-
evt.package === "@ai-sdk/anthropic",
243+
anthropic,
238244
ctx.app,
239245
)
240-
if (evt.package === "@ai-sdk/anthropic") {
246+
if (anthropic) {
241247
evt.options.headers = {
242248
...evt.options.headers,
243249
"anthropic-beta": "interleaved-thinking-2025-05-14",

‎packages/core/test/plugin/provider-github-copilot.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe("GithubCopilotPlugin", () => {
118118
}),
119119
)
120120

121-
it.effect("creates the bundled Copilot SDK for the GitHub Copilot package", () =>
121+
it.effect("creates the Copilot SDK for OpenAI and Anthropic endpoints", () =>
122122
Effect.gen(function* () {
123123
const plugin = yield* Plugin.Service
124124
const aisdk = yield* AISDK.Service
@@ -141,8 +141,18 @@ describe("GithubCopilotPlugin", () => {
141141
package: "@ai-sdk/github-copilot",
142142
options: { name: "github-copilot" },
143143
})
144+
const messages = yield* aisdk.runSDK({
145+
model: Model.Info.make({
146+
...Model.Info.default(Provider.ID.make("github-copilot"), Model.ID.make("claude-haiku-4.5")),
147+
modelID: Model.ID.make("claude-haiku-4.5"),
148+
package: Provider.aisdk("@ai-sdk/github-copilot"),
149+
}),
150+
package: "@ai-sdk/github-copilot",
151+
options: { name: "github-copilot", endpoint: "messages" },
152+
})
144153
expect(ignored.sdk).toBeUndefined()
145154
expect(result.sdk).toBeDefined()
155+
expect(messages.sdk).toBeDefined()
146156
}),
147157
)
148158

0 commit comments

Comments
 (0)