Explorar el Código

fix: mcp tool not triggering hooks (#2320)

Aiden Cline hace 5 meses
padre
commit
a3f4a030b4
Se han modificado 1 ficheros con 20 adiciones y 0 borrados
  1. 20 0
      packages/opencode/src/session/index.ts

+ 20 - 0
packages/opencode/src/session/index.ts

@@ -863,11 +863,31 @@ export namespace Session {
       const execute = item.execute
       const execute = item.execute
       if (!execute) continue
       if (!execute) continue
       item.execute = async (args, opts) => {
       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 result = await execute(args, opts)
         const output = result.content
         const output = result.content
           .filter((x: any) => x.type === "text")
           .filter((x: any) => x.type === "text")
           .map((x: any) => x.text)
           .map((x: any) => x.text)
           .join("\n\n")
           .join("\n\n")
+        await Plugin.trigger(
+          "tool.execute.after",
+          {
+            tool: key,
+            sessionID: input.sessionID,
+            callID: opts.toolCallId,
+          },
+          result,
+        )
 
 
         return {
         return {
           output,
           output,