mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-09 19:09:49 -04:00
fix(core): route Copilot Claude through plugin
This commit is contained in:
@@ -202,7 +202,12 @@ export const GithubCopilotPlugin = define({
|
||||
if (!loaded.models.has(Model.ID.make(id))) evt.model.remove(item.provider.id, id)
|
||||
}
|
||||
for (const [id, model] of loaded.models) {
|
||||
evt.model.update(item.provider.id, id, (draft) => Object.assign(draft, structuredClone(model)))
|
||||
evt.model.update(item.provider.id, id, (draft) => {
|
||||
Object.assign(draft, structuredClone(model))
|
||||
if (Provider.packageName(draft.package) === "@ai-sdk/anthropic") {
|
||||
draft.package = Provider.aisdk("@ai-sdk/github-copilot")
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (loaded.baseURL) {
|
||||
for (const id of item.models.keys()) {
|
||||
@@ -230,14 +235,15 @@ export const GithubCopilotPlugin = define({
|
||||
"sdk",
|
||||
Effect.fn(function* (evt) {
|
||||
if (evt.model.providerID !== Provider.ID.githubCopilot) return
|
||||
if (evt.package !== "@ai-sdk/github-copilot" && evt.package !== "@ai-sdk/anthropic") return
|
||||
if (evt.package !== "@ai-sdk/github-copilot") return
|
||||
const anthropic = evt.options.endpoint === "messages"
|
||||
evt.options.fetch = copilotFetch(
|
||||
typeof evt.options.apiKey === "string" ? evt.options.apiKey : undefined,
|
||||
evt.options.fetch,
|
||||
evt.package === "@ai-sdk/anthropic",
|
||||
anthropic,
|
||||
ctx.app,
|
||||
)
|
||||
if (evt.package === "@ai-sdk/anthropic") {
|
||||
if (anthropic) {
|
||||
evt.options.headers = {
|
||||
...evt.options.headers,
|
||||
"anthropic-beta": "interleaved-thinking-2025-05-14",
|
||||
|
||||
@@ -118,7 +118,7 @@ describe("GithubCopilotPlugin", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("creates the bundled Copilot SDK for the GitHub Copilot package", () =>
|
||||
it.effect("creates the Copilot SDK for OpenAI and Anthropic endpoints", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugin = yield* Plugin.Service
|
||||
const aisdk = yield* AISDK.Service
|
||||
@@ -141,8 +141,18 @@ describe("GithubCopilotPlugin", () => {
|
||||
package: "@ai-sdk/github-copilot",
|
||||
options: { name: "github-copilot" },
|
||||
})
|
||||
const messages = yield* aisdk.runSDK({
|
||||
model: Model.Info.make({
|
||||
...Model.Info.default(Provider.ID.make("github-copilot"), Model.ID.make("claude-haiku-4.5")),
|
||||
modelID: Model.ID.make("claude-haiku-4.5"),
|
||||
package: Provider.aisdk("@ai-sdk/github-copilot"),
|
||||
}),
|
||||
package: "@ai-sdk/github-copilot",
|
||||
options: { name: "github-copilot", endpoint: "messages" },
|
||||
})
|
||||
expect(ignored.sdk).toBeUndefined()
|
||||
expect(result.sdk).toBeDefined()
|
||||
expect(messages.sdk).toBeDefined()
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user