|
|
@@ -10,7 +10,7 @@ import { SessionV2 } from "@opencode-ai/core/session"
|
|
|
import { SessionMessage } from "@opencode-ai/core/session/message"
|
|
|
import { ToolRegistry } from "@opencode-ai/core/tool/registry"
|
|
|
import { Plugin } from "@opencode-ai/plugin/v2"
|
|
|
-import type { AIHooks } from "@opencode-ai/plugin/v2/effect/ai"
|
|
|
+import type { SessionHooks } from "@opencode-ai/plugin/v2/effect/session"
|
|
|
import { Model } from "@opencode-ai/schema/model"
|
|
|
import { Provider } from "@opencode-ai/schema/provider"
|
|
|
import { testEffect } from "../lib/effect"
|
|
|
@@ -77,24 +77,24 @@ describe("fromPromise", () => {
|
|
|
}),
|
|
|
)
|
|
|
|
|
|
- it.effect("forwards AI request hooks", () =>
|
|
|
+ it.effect("forwards session context hooks", () =>
|
|
|
Effect.gen(function* () {
|
|
|
const plugin = yield* PluginV2.Service
|
|
|
const hooks = yield* PluginHooks.Service
|
|
|
const host = yield* PluginHost.make(plugin)
|
|
|
yield* PluginPromise.fromPromise(
|
|
|
Plugin.define({
|
|
|
- id: "promise-ai-request",
|
|
|
+ id: "promise-session-context",
|
|
|
setup: async (ctx) => {
|
|
|
- await ctx.ai.hook("request", (event) => {
|
|
|
+ await ctx.session.hook("context", (event) => {
|
|
|
event.system.push(SystemPart.make("Promise hook"))
|
|
|
delete event.tools.echo
|
|
|
})
|
|
|
},
|
|
|
}),
|
|
|
).effect(host)
|
|
|
- const event: AIHooks["request"] = {
|
|
|
- sessionID: SessionV2.ID.make("ses_promise_ai_request"),
|
|
|
+ const event: SessionHooks["context"] = {
|
|
|
+ sessionID: SessionV2.ID.make("ses_promise_session_context"),
|
|
|
agent: AgentV2.ID.make("build"),
|
|
|
model: Model.Ref.make({ providerID: Provider.ID.make("test"), id: Model.ID.make("model") }),
|
|
|
system: [SystemPart.make("Initial")],
|
|
|
@@ -102,7 +102,7 @@ describe("fromPromise", () => {
|
|
|
tools: { echo: { description: "Echo", input: { type: "object" } } },
|
|
|
}
|
|
|
|
|
|
- yield* hooks.trigger("ai", "request", event)
|
|
|
+ yield* hooks.trigger("session", "context", event)
|
|
|
|
|
|
expect(event.system.map((part) => part.text)).toEqual(["Initial", "Promise hook"])
|
|
|
expect(event.tools).toEqual({})
|