@moltnet/guard 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +12 -10
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -343,22 +343,24 @@ const register: PluginRegisterFn = (api: PluginAPI) => {
|
|
|
343
343
|
})();
|
|
344
344
|
|
|
345
345
|
// Hook: Intercept tool results before persistence
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
|
|
346
|
+
// Clawdbot passes { message, toolName, toolInput, ... }
|
|
347
|
+
api.on('tool_result_persist', (event: any) => {
|
|
348
|
+
const toolName = event.toolName || event.name;
|
|
349
|
+
const toolInput = event.toolInput || event.input || {};
|
|
350
|
+
|
|
351
|
+
if (!toolName) return;
|
|
351
352
|
|
|
352
|
-
const risk = getToolRisk(
|
|
353
|
+
const risk = getToolRisk(toolName, toolInput);
|
|
353
354
|
const shouldGate = cfg.gateHighRisk &&
|
|
354
355
|
(risk === 'high' || risk === 'critical') &&
|
|
355
|
-
cfg.gateTools?.includes(
|
|
356
|
+
cfg.gateTools?.includes(toolName);
|
|
356
357
|
|
|
357
|
-
// Log the action (
|
|
358
|
-
logAction(cfg, agentName, state.sessionId,
|
|
358
|
+
// Log the action (fire and forget - this hook must be sync)
|
|
359
|
+
logAction(cfg, agentName, state.sessionId, toolName, toolInput, risk, shouldGate ? 'pending' : 'executed')
|
|
359
360
|
.catch(err => console.error('[moltguard] Failed to log action:', err));
|
|
360
361
|
|
|
361
|
-
|
|
362
|
+
// Don't modify the message
|
|
363
|
+
return undefined;
|
|
362
364
|
});
|
|
363
365
|
|
|
364
366
|
// Hook: Log agent bootstrap (session start)
|