openclaw-guardian-plugin
v2026.4.10
Published
OpenClaw plugin that reports hook payloads to the security_plugin detect service with remote hook toggles.
Maintainers
Readme
OpenClaw Guardian Plugin
This plugin uses the new OpenClaw SDK entry style and reports trust-layer payloads for the active hook points below:
logs the payload to the official plugin logger
pulls runtime toggles from
http://localhost:8001/open-apis/security_plugin/v1/openclaw_plugin/configforwards detect requests to
http://localhost:8001/open-apis/security_plugin/v1/openclaw_plugin/detectllm_inputllm_outputbefore_tool_callafter_tool_call
The runtime config polling is managed by api.registerService(...). The service initializes remote config on startup, keeps an in-memory snapshot for hook handlers, and disposes the refresh timer on shutdown.
Files
openclaw.plugin.json: native plugin manifestsrc/index.ts: plugin entry registered withdefinePluginEntry, hook registration, andapi.registerService(...)wiringsrc/runtime-config.ts: remote config store plus polling service, typed againstOpenClawPluginApi/api.registerService(...)src/hook-payloads.ts: hook-specific payload builders required by the trust-layer APIsrc/logger.ts: safe payload formatter and logger helpersrc/http-client.ts: request body builder and detect/config service clientsrc/fetch-interceptor.ts: optionalbefore_llm_fetch/after_llm_fetchrequest-response interceptor, currently not enabled insrc/index.tssrc/tool-effects.ts: effect parser and hook-specific deny/rewrite handling
Install
Link-install the plugin from this directory:
openclaw plugins install -l .Then enable it in your OpenClaw config if needed:
{
plugins: {
entries: {
"openclaw-guardian-plugin": {
enabled: true
}
}
}
}Restart the Gateway after config changes.
Notes
- The plugin logs via
api.logger.info(...). - The plugin registers a background service via
api.registerService(...); the service typing is derived fromOpenClawPluginApi, GETs remote runtime config on startup, retries up to 3 times, defaults to all hooks disabled on first-start failure, and refreshes the config every 60 seconds. - The plugin POSTs
{ hook_name, payload }tohttp://localhost:8001/open-apis/security_plugin/v1/openclaw_plugin/detect. - Hook handlers read the latest in-memory runtime-config snapshot instead of fetching
/configinline on every hook invocation. - Hook payloads are sent as the trust-layer contract requires, such as tool/session fields for tool hooks and
domain/path/origin_reqororigin_respfor LLM fetch hooks. llm_inputandllm_outputare report-only hooks; deny/rewrite responses are logged but not applied.after_tool_callis also observe-only in runtime; detect decisions are logged but do not rewrite the actual hook return value.- Payloads are serialized defensively so circular references and
Errorobjects do not break logging. before_llm_fetch/after_llm_fetchsupport remains insrc/fetch-interceptor.ts, but those hooks are not active untilinstallFetchInterceptor(api, configStore)is enabled insrc/index.ts.
