mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
fix: mcp tool not triggering hooks
This commit is contained in:
parent
9a330b4f0f
commit
b9530f346c
1 changed files with 20 additions and 0 deletions
|
|
@ -863,11 +863,31 @@ export namespace Session {
|
|||
const execute = item.execute
|
||||
if (!execute) continue
|
||||
item.execute = async (args, opts) => {
|
||||
await Plugin.trigger(
|
||||
"tool.execute.before",
|
||||
{
|
||||
tool: key,
|
||||
sessionID: input.sessionID,
|
||||
callID: opts.toolCallId,
|
||||
},
|
||||
{
|
||||
args,
|
||||
},
|
||||
)
|
||||
const result = await execute(args, opts)
|
||||
const output = result.content
|
||||
.filter((x: any) => x.type === "text")
|
||||
.map((x: any) => x.text)
|
||||
.join("\n\n")
|
||||
await Plugin.trigger(
|
||||
"tool.execute.after",
|
||||
{
|
||||
tool: key,
|
||||
sessionID: input.sessionID,
|
||||
callID: opts.toolCallId,
|
||||
},
|
||||
result,
|
||||
)
|
||||
|
||||
return {
|
||||
output,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue