From 79d9a0372ea0bf8c33c7fce2054bb14658d5c085 Mon Sep 17 00:00:00 2001 From: Meng Bo Date: Sat, 12 Sep 2026 06:57:03 +0800 Subject: [PATCH] fix(opencode): add default plugin export wrapper for opencode2 --- .../assets/opencode/herdr-agent-state.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/integration/assets/opencode/herdr-agent-state.js b/src/integration/assets/opencode/herdr-agent-state.js index 73a7053400..6633ac8021 100644 --- a/src/integration/assets/opencode/herdr-agent-state.js +++ b/src/integration/assets/opencode/herdr-agent-state.js @@ -208,3 +208,33 @@ export default { server: HerdrAgentStatePlugin, setup() {}, }; + +// opencode2 compatibility: plugin loader expects a default export definition +// with an id and setup/effect function. +export default { + id: "herdr-agent-state", + async setup(ctx) { + const handlers = await HerdrAgentStatePlugin(); + + if (!ctx || typeof ctx.on !== "function") { + // Fail softly if host API shape differs. + return; + } + + const disposers = []; + + if (typeof handlers?.["chat.message"] === "function") { + disposers.push(ctx.on("chat.message", handlers["chat.message"])); + } + + if (typeof handlers?.event === "function") { + disposers.push(ctx.on("event", handlers.event)); + } + + return () => { + for (const dispose of disposers) { + if (typeof dispose === "function") dispose(); + } + }; + }, +};