feat(plugin): add v2 effect host (#33111)

This commit is contained in:
Dax
2026-06-21 08:05:49 -04:00
committed by GitHub
parent 7a9337da8a
commit c780d7cee7
139 changed files with 3749 additions and 1952 deletions
+10 -11
View File
@@ -1,19 +1,18 @@
import { Npm } from "../../npm"
import { Effect, Option } from "effect"
import { Effect } from "effect"
import { pathToFileURL } from "url"
import { PluginV2 } from "../../plugin"
import { define } from "@opencode-ai/plugin/v2/effect"
export const DynamicProviderPlugin = PluginV2.define({
id: PluginV2.ID.make("dynamic-provider"),
effect: Effect.gen(function* () {
const npm = yield* Npm.Service
return {
"aisdk.sdk": Effect.fn(function* (evt) {
export const DynamicProviderPlugin = define({
id: "dynamic-provider",
effect: Effect.fn(function* (ctx) {
yield* ctx.aisdk.hook(
"sdk",
Effect.fn(function* (evt) {
if (evt.sdk) return
const installedPath = evt.package.startsWith("file://")
? evt.package
: Option.getOrUndefined((yield* npm.add(evt.package).pipe(Effect.orDie)).entrypoint)
: (yield* ctx.npm.add(evt.package).pipe(Effect.orDie)).entrypoint
if (!installedPath) throw new Error(`Package ${evt.package} has no import entrypoint`)
const mod = yield* Effect.promise(async () => {
@@ -26,6 +25,6 @@ export const DynamicProviderPlugin = PluginV2.define({
evt.sdk = mod[match](evt.options)
}),
}
)
}),
})