@silmaril-security/firewall-plugin 1.2.3

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/README.md ADDED
@@ -0,0 +1,320 @@
1
+ # Silmaril Firewall Plugin for OpenClaw
2
+
3
+ Silmaril classification and native blocked-decision visibility for OpenClaw
4
+ plugin hooks.
5
+
6
+ The plugin observes OpenClaw agent, tool, message, delivery, and subagent
7
+ lifecycle payloads and sends them to Silmaril Firewall. Shadow is silent. Warn
8
+ adds one bounded content-free warning at `before_prompt_build`. Block uses
9
+ OpenClaw-native block or cancel responses at enforceable boundaries and never
10
+ replaces content or delivery payloads. Unsupported boundaries remain unchanged
11
+ and record `block_unavailable`. Classifier failures fail open without adding
12
+ agent-visible context.
13
+
14
+ The plugin requires OpenClaw plugin API `2026.5.28` or newer and is tested with
15
+ OpenClaw `2026.7.1-2`. Its manifest declares startup activation for hook
16
+ capability loading, and the runtime entry registers typed Gateway hooks with
17
+ `api.on(...)`.
18
+
19
+ ## Runtime Hooks
20
+
21
+ | OpenClaw hook | Silmaril label | Classified content |
22
+ |---|---|---|
23
+ | `gateway_start` | n/a | Logs plugin installation when the Gateway starts |
24
+ | `before_agent_run` | `USER_INPUT` | Final agent prompt/message payload before model submission; can return OpenClaw's native block shape with a readable message |
25
+ | `before_tool_call` | `TOOL_CALL` | Tool parameters; can return `{ "block": true, "blockReason": "..." }` when enforcement is explicitly enabled |
26
+ | `after_tool_call` | `TOOL_RESPONSE` | Tool result text immediately after execution, including child-agent tool calls |
27
+ | `tool_result_persist` | `TOOL_RESPONSE` | Tool result text being persisted into context; observe-only because external OpenClaw plugins cannot replace tool results |
28
+ | `message_sending` | `LLM_OUTPUT` | Final outbound assistant message text; Block can return `{ "cancel": true }` without replacement content |
29
+ | `reply_payload_sending` | `LLM_OUTPUT` | Normalized delivery payload; Block can cancel it without replacement content |
30
+ | `message_sent` | n/a | Logs content-free delivery telemetry; does not reclassify delivered content |
31
+ | `subagent_delivery_target` | `USER_INPUT` | Subagent delivery routing payload; observe-only compatibility hook |
32
+ | `subagent_spawned` | `USER_INPUT` | Subagent spawn lifecycle payload; observe-only in OpenClaw |
33
+ | `subagent_ended` | `LLM_OUTPUT` | Subagent completion payload; observe-only in OpenClaw |
34
+
35
+ Hook registration is unconditional, so OpenClaw can discover and invoke the
36
+ Gateway hooks even before classifier settings are validated. Classifier config
37
+ is resolved inside each hook call.
38
+
39
+ Enforceable hooks await Silmaril SDK 0.6.0 with a plugin-owned timeout.
40
+ `after_tool_call`, `tool_result_persist`, and subagent lifecycle hooks classify
41
+ for visibility but do not claim to block because OpenClaw exposes asynchronous
42
+ observation separately from its synchronous result-transform hook. Malicious
43
+ Block-mode events at these boundaries record native action `unavailable` and
44
+ `block_unavailable=true`. `message_sending` and `reply_payload_sending` share a short-lived,
45
+ content-sensitive result so duplicate callbacks make one SDK request; changed
46
+ content is classified separately. Image-only and other empty payloads are
47
+ skipped. Only `prediction === "MALICIOUS"` is enforceable. User-visible and
48
+ model-visible feedback never includes raw classifier JSON, numeric scores or
49
+ thresholds, detector maps, metadata dumps, or the original sensitive payload.
50
+
51
+ ## Files
52
+
53
+ | Path | Purpose |
54
+ |---|---|
55
+ | `index.ts` | OpenClaw plugin entrypoint and hook registration |
56
+ | `openclaw.plugin.json` | Plugin metadata and config schema |
57
+ | `package.json` | Package metadata, dependency list, and OpenClaw extension metadata |
58
+ | `scripts/build.mjs` | Builds `dist/index.js` for CLI plugin installation |
59
+ | `scripts/mock-silmaril-classifier.mjs` | Local classifier stub for manual smoke testing |
60
+ | `scripts/open-playground.mjs` | Opens or prints the public Silmaril Firewall demo URL |
61
+ | `dist/index.js` | Built plugin entrypoint used by OpenClaw's CLI install path |
62
+
63
+ ## Source Checkout Configuration
64
+
65
+ Register this source checkout directly in `~/.openclaw/openclaw.json`. Preserve
66
+ the rest of the user's OpenClaw config and add the absolute repository path to
67
+ `plugins.load.paths`:
68
+
69
+ ```json
70
+ {
71
+ "plugins": {
72
+ "load": {
73
+ "paths": [
74
+ "/absolute/path/to/FirewallPlugin"
75
+ ]
76
+ },
77
+ "entries": {
78
+ "firewall-plugin": {
79
+ "enabled": true,
80
+ "hooks": {
81
+ "allowConversationAccess": true
82
+ },
83
+ "config": {
84
+ "apiKey": "your-plugin-or-legacy-silmaril-api-key",
85
+ "silmarilApiKey": "your-silmaril-api-key",
86
+ "apiUrl": "https://your-endpoint.execute-api.us-west-2.amazonaws.com/alpha/classify",
87
+ "endpointId": "2b64e603-f82a-4aec-9524-9736472dc80a",
88
+ "timeoutMs": 2500,
89
+ "shadowMode": true,
90
+ "blockMalicious": false
91
+ }
92
+ }
93
+ },
94
+ "allow": [
95
+ "firewall-plugin"
96
+ ]
97
+ }
98
+ }
99
+ ```
100
+
101
+ `apiUrl` should be the full classify endpoint URL. The plugin reads these values
102
+ from OpenClaw plugin config during hook execution. `silmarilApiKey` is preferred
103
+ for Silmaril classification when present; `apiKey` remains supported as the
104
+ legacy fallback and may otherwise be used as a plugin or OpenClaw identity key.
105
+
106
+ OpenClaw requires `hooks.allowConversationAccess: true` for a non-bundled
107
+ plugin to receive `before_agent_run`. Without that host permission, OpenClaw
108
+ loads the remaining hooks but skips prompt classification and reports a plugin
109
+ diagnostic.
110
+
111
+ `timeoutMs` is optional. It defaults to `2500` and bounds each classifier
112
+ request.
113
+
114
+ The Silmaril endpoint app supplies `endpointId` as a canonical UUID v4. Every classifier request carries plugin-owned `metadata.silmaril.provenance`; without an endpoint ID the plugin continues with harness-only provenance.
115
+
116
+ Each native OpenClaw event produces at most one classification. The plugin classifies only current event fields and ignores transcript-like `messages` or generic history payloads; conversation state is owned by the Firewall sequence cache.
117
+
118
+ Omit `mode` to use the backend-configured mode, or set it to `shadow`, `warn`,
119
+ or `block` for a pilot override. Existing configurations keep their legacy
120
+ behavior: `shadowMode: true` is Shadow, and `shadowMode: false` blocks only when
121
+ `blockMalicious: true`; otherwise it remains observe-only. Blocking uses
122
+ OpenClaw's documented native decision shapes. During a rolling backend upgrade,
123
+ an explicit override remains authoritative and a mode-less legacy response
124
+ preserves the plugin's observe-only default instead of escalating to Block.
125
+ The external plugin cannot
126
+ retroactively block or replace persisted tool results, and OpenClaw's
127
+ `subagent_spawned`, `subagent_ended`, and
128
+ `subagent_delivery_target` hooks are observer or routing hooks. Child-agent tool
129
+ calls and tool results still pass through `before_tool_call`/`after_tool_call`
130
+ inside the child execution path and are scanned there.
131
+
132
+ By default the plugin is pass-through only. Apart from the bounded outbound
133
+ delivery deduplication window, it does not cache classifier results, add
134
+ prompt/system/developer context, or register wrapper tools.
135
+
136
+ Configuration precedence is intentionally OpenClaw-native: hook execution reads
137
+ `plugins.entries.firewall-plugin.config` from OpenClaw at runtime. The launcher
138
+ prints only the public demo URL and does not read or echo classifier
139
+ configuration values. Do not commit API keys or write them into URLs.
140
+
141
+ ## Local protection evidence
142
+
143
+ Flagged Block and Shadow decisions emit one bounded
144
+ `LocalProtectionEventV1` JSON file for the local Silmaril app. Set
145
+ `SILMARIL_LOCAL_EVENT_DIR` to override the spool directory; otherwise files go
146
+ to `~/Library/Application Support/Silmaril/Evidence/incoming`.
147
+
148
+ Publication uses a private temporary file followed by an atomic rename. The
149
+ directory is mode `0700` and event files are mode `0600`. Emission is
150
+ best-effort: filesystem failures never change the native OpenClaw decision.
151
+
152
+ Events contain hashes, bounded risk metadata, classifier diagnostics, policy,
153
+ and the action returned to OpenClaw. They never contain raw prompts, inputs,
154
+ outputs, tool arguments, or credential values. Because the plugin does not
155
+ independently observe downstream execution, it reports
156
+ `evidenceTruth: plugin_reported` and `outcome: not_observed`; a native block
157
+ response is not represented as independently verified prevention.
158
+
159
+ ## Install
160
+
161
+ Install the published package by name:
162
+
163
+ ```sh
164
+ openclaw plugins install @silmaril-security/firewall-plugin@1.2.3
165
+ openclaw plugins enable firewall-plugin
166
+ openclaw gateway restart
167
+ ```
168
+
169
+ This repository also supports direct source loading and two local CLI install styles.
170
+
171
+ OpenClaw does not automatically discover or pull this repository by plugin id.
172
+ Start by cloning the repository onto the machine where OpenClaw runs:
173
+
174
+ ```sh
175
+ git clone https://github.com/Silmaril-Security/FirewallPlugin.git
176
+ cd FirewallPlugin
177
+ ```
178
+
179
+ For the source checkout flow, use the `plugins.load.paths` configuration above.
180
+ The repository ships a built `dist/index.js`, so a fresh checkout can be loaded
181
+ directly. Install dependencies before starting OpenClaw, and rebuild after
182
+ editing `index.ts`:
183
+
184
+ ```sh
185
+ npm install
186
+ npm run build
187
+ openclaw gateway restart
188
+ ```
189
+
190
+ For OpenClaw's linked local plugin install path, build the package and install
191
+ it from the repository root:
192
+
193
+ ```sh
194
+ npm install
195
+ npm run build
196
+ openclaw plugins install -l .
197
+ openclaw plugins enable firewall-plugin
198
+ openclaw gateway restart
199
+ ```
200
+
201
+ For a clean installable archive, build and pack the plugin, then install the
202
+ generated tarball:
203
+
204
+ ```sh
205
+ npm install
206
+ npm run build
207
+ npm pack
208
+ openclaw plugins install ./silmaril-security-firewall-plugin-1.2.3.tgz
209
+ openclaw plugins enable firewall-plugin
210
+ openclaw gateway restart
211
+ ```
212
+
213
+ Use `plugins.load.paths` when you want OpenClaw to load this checkout directly.
214
+ Use `openclaw plugins install -l .` when you want OpenClaw to register this
215
+ checkout as a linked local plugin. Use the `.tgz` flow when you want the
216
+ installer to consume only the packaged files listed by `package.json`. All flows
217
+ use the same plugin id, `firewall-plugin`, and the same
218
+ `plugins.entries.firewall-plugin.config` settings.
219
+
220
+ Inspect the installed plugin:
221
+
222
+ ```sh
223
+ openclaw --no-color plugins inspect firewall-plugin --runtime
224
+ ```
225
+
226
+ Expected shape:
227
+
228
+ ```text
229
+ Status: loaded
230
+ Format: openclaw
231
+ Shape: hook-only
232
+ Typed hooks:
233
+ gateway_start
234
+ before_agent_run
235
+ before_tool_call
236
+ after_tool_call
237
+ tool_result_persist
238
+ message_sending
239
+ reply_payload_sending
240
+ message_sent
241
+ subagent_delivery_target
242
+ subagent_spawned
243
+ subagent_ended
244
+ ```
245
+
246
+ Run diagnostics:
247
+
248
+ ```sh
249
+ openclaw --no-color plugins doctor
250
+ ```
251
+
252
+ ## Public Demo
253
+
254
+ The demo launcher opens the hosted Silmaril Firewall UI at
255
+ `https://app.silmaril.dev/demo/setup-complete`. It does not serve a local UI,
256
+ start a credential proxy, or put the Silmaril API key in the URL, chat, or
257
+ launcher output.
258
+
259
+ Run it from the repository root:
260
+
261
+ ```sh
262
+ node scripts/open-playground.mjs
263
+ node scripts/open-playground.mjs --open
264
+ node scripts/open-playground.mjs --route playground --json
265
+ ```
266
+
267
+ For preview validation, override the hosted base URL:
268
+
269
+ ```sh
270
+ SILMARIL_DEMO_BASE_URL="http://localhost:3001" node scripts/open-playground.mjs
271
+ ```
272
+
273
+ For machine-readable automation output, pass `--json`:
274
+
275
+ ```sh
276
+ node scripts/open-playground.mjs --json
277
+ ```
278
+
279
+ The JSON output intentionally contains only the public demo URL and no OpenClaw
280
+ configuration status, classifier endpoint, or API key fields.
281
+
282
+ ## Manual Smoke Test
283
+
284
+ For a local smoke test, start the mock classifier:
285
+
286
+ ```sh
287
+ node scripts/mock-silmaril-classifier.mjs
288
+ ```
289
+
290
+ Set the plugin `apiUrl` to the mock classifier URL printed by the script, set
291
+ any non-empty test API key, then restart OpenClaw:
292
+
293
+ ```sh
294
+ openclaw gateway restart
295
+ ```
296
+
297
+ Send a normal OpenClaw message, then send a message that uses at least one tool.
298
+ Check the gateway logs for the install confirmation and classification entries:
299
+
300
+ ```text
301
+ firewall-plugin: installed
302
+ [firewall] before_agent_run result:
303
+ [firewall] before_tool_call result:
304
+ [firewall] after_tool_call result:
305
+ [firewall] tool_result_persist result:
306
+ [firewall] message_sending result:
307
+ [firewall] reply_payload_sending result:
308
+ [firewall] message_sent observed:
309
+ [firewall] subagent_delivery_target result:
310
+ [firewall] subagent_spawned result:
311
+ [firewall] subagent_ended result:
312
+ ```
313
+
314
+ The mock classifier writes captured requests to the path printed on startup.
315
+ Those captures should show the hook label, tool name when available, and the
316
+ classified text length.
317
+
318
+ ## License
319
+
320
+ This plugin is licensed under Apache-2.0. See `LICENSE` and `NOTICE`.