Skip to content

Commit 2e7972d

Browse files
fix(hooks): correct resolveHookSource mapping and restore error logging
- Change "openclaw-plugin" → "workspace" in resolveHookSource so plugin-discovered hooks are properly cleared on hot-reload - Replace silent .catch(() => {}) with logVerbose in dispatch-unified to preserve debug observability for plugin hook failures
1 parent d7d638f commit 2e7972d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/hooks/dispatch-unified.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* co-locates the dual dispatch so each call site only needs one function.
77
*/
88

9+
import { logVerbose } from "../globals.js";
910
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
1011
import { createInternalHookEvent, triggerInternalHook } from "./internal-hooks.js";
1112

@@ -42,7 +43,9 @@ export function emitMessageReceived(params: {
4243
conversationId: params.conversationId,
4344
},
4445
)
45-
.catch(() => {});
46+
.catch((err) => {
47+
logVerbose(`dispatch-unified: message_received plugin hook failed: ${String(err)}`);
48+
});
4649
}
4750

4851
if (params.sessionKey) {
@@ -91,7 +94,9 @@ export function emitMessageSent(params: {
9194
conversationId: params.conversationId ?? params.to,
9295
},
9396
)
94-
.catch(() => {});
97+
.catch((err) => {
98+
logVerbose(`dispatch-unified: message_sent plugin hook failed: ${String(err)}`);
99+
});
95100
}
96101

97102
if (params.sessionKey) {
@@ -126,7 +131,11 @@ export function emitGatewayStartup(params: {
126131
// Plugin hook
127132
const hookRunner = getGlobalHookRunner();
128133
if (hookRunner?.hasHooks("gateway_start")) {
129-
void hookRunner.runGatewayStart({ port: params.port }, { port: params.port }).catch(() => {});
134+
void hookRunner
135+
.runGatewayStart({ port: params.port }, { port: params.port })
136+
.catch((err) => {
137+
logVerbose(`dispatch-unified: gateway_start plugin hook failed: ${String(err)}`);
138+
});
130139
}
131140

132141
// Internal hook — no setTimeout, fire immediately after hooks are loaded

src/hooks/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function resolveHookSource(source: string): HookSource {
2525
case "openclaw-bundled": return "bundled";
2626
case "openclaw-managed": return "managed";
2727
case "openclaw-workspace": return "workspace";
28-
case "openclaw-plugin": return "plugin";
28+
case "openclaw-plugin": return "workspace";
2929
default: return "config";
3030
}
3131
}

0 commit comments

Comments
 (0)