diff --git a/packages/opencode/src/session/processor.ts b/packages/opencode/src/session/processor.ts index bf994755c1f..f1f7dd0964f 100644 --- a/packages/opencode/src/session/processor.ts +++ b/packages/opencode/src/session/processor.ts @@ -10,6 +10,7 @@ import { SessionSummary } from "./summary" import { Bus } from "@/bus" import { SessionRetry } from "./retry" import { SessionStatus } from "./status" +import { Plugin } from "@/plugin" import type { Provider } from "@/provider/provider" export namespace SessionProcessor { @@ -316,6 +317,16 @@ export namespace SessionProcessor { case "text-end": if (currentText) { currentText.text = currentText.text.trimEnd() + const textOutput = await Plugin.trigger( + "experimental.text.complete", + { + sessionID: input.sessionID, + messageID: input.assistantMessage.id, + partID: currentText.id, + }, + { text: currentText.text }, + ) + currentText.text = textOutput.text currentText.time = { start: Date.now(), end: Date.now(), diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts index 291d68b794d..f00e90482d6 100644 --- a/packages/plugin/src/index.ts +++ b/packages/plugin/src/index.ts @@ -175,4 +175,8 @@ export interface Hooks { metadata: any }, ) => Promise + "experimental.text.complete"?: ( + input: { sessionID: string; messageID: string; partID: string }, + output: { text: string }, + ) => Promise }