import { Effect } from "effect"
import { define } from "@opencode-ai/plugin/v2/effect/plugin"

export const AlibabaPlugin = define({
  id: "opencode.provider.alibaba",
  effect: Effect.fn(function* (ctx) {
    yield* ctx.aisdk.sdk(
      Effect.fn(function* (evt) {
        if (evt.package !== "@ai-sdk/alibaba") return
        const mod = yield* Effect.promise(() => import("@ai-sdk/alibaba"))
        evt.sdk = mod.createAlibaba(evt.options)
      }),
    )
  }),
})
