feat(plugin): restore ai request hook
This commit is contained in:
parent
b95a5dc259
commit
f2f5eb6f16
19 changed files with 261 additions and 10 deletions
|
|
@ -1,5 +1,6 @@
|
|||
export * as PluginHooks from "./hooks"
|
||||
|
||||
import type { AIHooks } from "@opencode-ai/plugin/v2/effect/ai"
|
||||
import type { AISDKHooks } from "@opencode-ai/plugin/v2/effect/aisdk"
|
||||
import type { ToolHooks } from "@opencode-ai/plugin/v2/effect/tool"
|
||||
import { Context, Effect, Layer, Scope } from "effect"
|
||||
|
|
@ -7,6 +8,7 @@ import { makeLocationNode } from "../effect/app-node"
|
|||
import { State } from "../state"
|
||||
|
||||
export interface Domains {
|
||||
readonly ai: AIHooks
|
||||
readonly aisdk: AISDKHooks
|
||||
readonly tool: ToolHooks
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ export const make = Effect.fn("PluginHost.make")(function* (plugin: PluginV2.Int
|
|||
})
|
||||
}),
|
||||
},
|
||||
ai: {
|
||||
hook: (name, callback) => hooks.register("ai", name, callback),
|
||||
},
|
||||
aisdk: {
|
||||
hook: (name, callback) => {
|
||||
if (name === "sdk") {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ export function fromPromise(plugin: Plugin) {
|
|||
transform: transform(host.agent),
|
||||
reload: () => run(host.agent.reload()),
|
||||
},
|
||||
ai: {
|
||||
hook: (name, callback) =>
|
||||
register(host.ai.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
|
||||
},
|
||||
aisdk: {
|
||||
hook: (name, callback) =>
|
||||
register(host.aisdk.hook(name, (event) => Effect.promise(() => Promise.resolve(callback(event))))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue