mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
feat: add experimental.text.complete plugin hook (#4962)
This commit is contained in:
parent
5b3550ab9f
commit
81ee8541ab
2 changed files with 15 additions and 0 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -175,4 +175,8 @@ export interface Hooks {
|
|||
metadata: any
|
||||
},
|
||||
) => Promise<void>
|
||||
"experimental.text.complete"?: (
|
||||
input: { sessionID: string; messageID: string; partID: string },
|
||||
output: { text: string },
|
||||
) => Promise<void>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue