UNPKG

@openguardrails/moltguard

Version:

AI agent security plugin for OpenClaw: prompt injection detection, PII sanitization, and monitoring dashboard

51 lines 2.38 kB
/** * Type definitions for all 24 OpenClaw plugin hooks. * * These types define the event data structure for each hook, * enabling complete context reporting to Core for intent-action mismatch detection. */ // ============================================================================= // Blocking vs Non-Blocking Hook Classification // ============================================================================= /** Hooks that require synchronous response from Core (can block execution) */ export const BLOCKING_HOOKS = new Set([ "before_tool_call", "subagent_spawning", "message_sending", "before_message_write", ]); /** Check if a hook type requires synchronous (blocking) reporting */ export function isBlockingHook(hookType) { return BLOCKING_HOOKS.has(hookType); } // ============================================================================= // Type Guard Helpers // ============================================================================= /** Map of hook types to their expected data types (for runtime validation) */ export const HOOK_DATA_FIELDS = { before_agent_start: ["prompt"], agent_end: ["reason"], session_start: ["sessionId", "isNew"], session_end: ["sessionId"], message_received: ["from", "content", "contentLength"], message_sending: ["to", "content", "contentLength"], message_sent: ["to", "success"], before_message_write: ["filePath", "content", "contentLength"], before_model_resolve: ["requestedModel"], before_prompt_build: ["messageCount"], llm_input: ["model", "content", "contentLength", "messageCount"], llm_output: ["model", "content", "contentLength", "streamed", "latencyMs"], before_tool_call: ["toolName", "params"], after_tool_call: ["toolName", "params", "success", "resultSizeBytes", "durationMs"], tool_result_persist: ["modified"], before_compaction: ["messageCount", "reason"], after_compaction: ["messageCount", "removedCount"], before_reset: ["reason", "messageCount"], subagent_spawning: ["subagentId", "subagentType", "task", "taskLength"], subagent_delivery_target: ["subagentId", "targetType"], subagent_spawned: ["subagentId", "subagentType", "success"], subagent_ended: ["subagentId", "reason"], gateway_start: ["port", "url"], gateway_stop: ["reason"], }; //# sourceMappingURL=hook-types.js.map