feat(plugin): add namespaced hook API (#33416)

This commit is contained in:
Dax 2026-06-22 19:06:57 -04:00 committed by GitHub
commit 909a1a6d78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
150 changed files with 3276 additions and 3906 deletions

View file

@ -1,6 +1,6 @@
import { Effect } from "effect"
import { ModelV2 } from "../../model"
import { define } from "@opencode-ai/plugin/v2/effect"
import { define } from "../internal"
import { ProviderV2 } from "../../provider"
function shouldUseResponses(modelID: string) {
@ -25,16 +25,14 @@ export const GithubCopilotPlugin = define({
})
}),
)
yield* ctx.aisdk.hook(
"sdk",
yield* ctx.aisdk.sdk(
Effect.fn(function* (evt) {
if (evt.package !== "@ai-sdk/github-copilot") return
const mod = yield* Effect.promise(() => import("../../github-copilot/copilot-provider"))
evt.sdk = mod.createOpenaiCompatible(evt.options)
}),
)
yield* ctx.aisdk.hook(
"language",
yield* ctx.aisdk.language(
Effect.fn(function* (evt) {
if (evt.model.providerID !== ProviderV2.ID.githubCopilot) return
if (evt.sdk.responses === undefined && evt.sdk.chat === undefined) {