@silmaril-security/firewall-plugin 1.2.9 → 1.2.11
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/CLAUDE.md +27 -2
- package/NOTICE +17 -0
- package/README.md +37 -13
- package/dist/index.js +105 -26
- package/package.json +6 -6
package/CLAUDE.md
CHANGED
|
@@ -44,6 +44,10 @@ Source file: `index.ts`
|
|
|
44
44
|
|
|
45
45
|
OpenClaw runtime entrypoint: `dist/index.js`
|
|
46
46
|
|
|
47
|
+
Prepared package and runtime attribution are `1.2.11` with
|
|
48
|
+
`@silmaril-security/sdk` `0.8.2`. The post-publication registry and local
|
|
49
|
+
archive examples below both use `1.2.11`.
|
|
50
|
+
|
|
47
51
|
Runtime behavior:
|
|
48
52
|
|
|
49
53
|
- the manifest declares Gateway startup activation for OpenClaw hook capability
|
|
@@ -86,6 +90,13 @@ Runtime behavior:
|
|
|
86
90
|
demo URL without serving local UI or reading or printing classifier config
|
|
87
91
|
- hook registration is unconditional; classifier config is resolved when each
|
|
88
92
|
hook runs
|
|
93
|
+
- the configured classifier timeout is also a plugin-owned end-to-end deadline
|
|
94
|
+
over all SDK attempts, retry backoff, and response-body handling. The SDK
|
|
95
|
+
receives its caller abort signal and retains the same per-attempt timeout
|
|
96
|
+
- plugin-authored hook budgets add a bounded 1000 ms cleanup margin to the
|
|
97
|
+
classifier timeout, up to 11000 ms. OpenClaw hook-specific and plugin-wide
|
|
98
|
+
operator timeout overrides retain native precedence and may intentionally be
|
|
99
|
+
shorter
|
|
89
100
|
- Shadow adds no agent-visible context. Warn can prepend the fixed
|
|
90
101
|
`before_prompt_build` warning. The plugin adds no system or developer context
|
|
91
102
|
- no wrapper tools, exporters, or queues are registered
|
|
@@ -106,7 +117,10 @@ Configuration fields:
|
|
|
106
117
|
- `timeoutMs`: optional classifier timeout in milliseconds. OpenClaw plugin
|
|
107
118
|
configuration accepts JSON integers from `250` through `10000`; omission uses
|
|
108
119
|
`2500`. The host validates the manifest schema before runtime loading and
|
|
109
|
-
rejects numeric strings, fractional numbers, and out-of-range values
|
|
120
|
+
rejects numeric strings, fractional numbers, and out-of-range values. This
|
|
121
|
+
value remains the SDK per-attempt timeout and is also the plugin's overall
|
|
122
|
+
classification deadline. The plugin-authored host hook budget is the deadline
|
|
123
|
+
plus a bounded 1000 ms cleanup margin
|
|
110
124
|
- `mode`: optional `shadow`, `warn`, or `block` override. A set value wins over
|
|
111
125
|
the legacy booleans below and over `mode` on the classifier response
|
|
112
126
|
- `shadowMode`: legacy flag. `true` forces Shadow, including when
|
|
@@ -148,6 +162,10 @@ for direct source loading or the CLI install path is unavailable.
|
|
|
148
162
|
openclaw --version
|
|
149
163
|
```
|
|
150
164
|
|
|
165
|
+
Existing OpenClaw installations older than `2026.8.2` must be upgraded
|
|
166
|
+
through their supported installation method before this plugin version is
|
|
167
|
+
enabled.
|
|
168
|
+
|
|
151
169
|
3. Initialize OpenClaw local state:
|
|
152
170
|
|
|
153
171
|
```sh
|
|
@@ -227,6 +245,13 @@ for direct source loading or the CLI install path is unavailable.
|
|
|
227
245
|
Use these only when the user explicitly asks for a different install style or
|
|
228
246
|
when `openclaw plugins install -l .` is unavailable.
|
|
229
247
|
|
|
248
|
+
Exact npm registry flow after publication:
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
openclaw plugins install npm:@silmaril-security/firewall-plugin@1.2.11
|
|
252
|
+
openclaw plugins enable firewall-plugin
|
|
253
|
+
```
|
|
254
|
+
|
|
230
255
|
Direct source checkout flow: register the checkout through
|
|
231
256
|
`plugins.load.paths` instead of using the CLI install command.
|
|
232
257
|
|
|
@@ -246,7 +271,7 @@ for direct source loading or the CLI install path is unavailable.
|
|
|
246
271
|
|
|
247
272
|
```sh
|
|
248
273
|
npm pack
|
|
249
|
-
openclaw plugins install ./silmaril-security-firewall-plugin-1.2.
|
|
274
|
+
openclaw plugins install ./silmaril-security-firewall-plugin-1.2.11.tgz
|
|
250
275
|
openclaw plugins enable firewall-plugin
|
|
251
276
|
```
|
|
252
277
|
|
package/NOTICE
CHANGED
|
@@ -2,3 +2,20 @@ Silmaril OpenClaw Firewall Plugin
|
|
|
2
2
|
Copyright 2026 Silmaril Security Inc.
|
|
3
3
|
|
|
4
4
|
This product includes software developed by Silmaril Security Inc.
|
|
5
|
+
|
|
6
|
+
The package depends on @silmaril-security/sdk 0.8.2, installed separately by
|
|
7
|
+
npm. That dependency is distributed under the following license included in
|
|
8
|
+
its published package:
|
|
9
|
+
|
|
10
|
+
PROPRIETARY AND CONFIDENTIAL
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2024-2025 Silmaril Security Inc. All rights reserved.
|
|
13
|
+
|
|
14
|
+
This software and its documentation are proprietary to Silmaril Security Inc.
|
|
15
|
+
Unauthorized copying, distribution, modification, or use of this software,
|
|
16
|
+
in whole or in part, is strictly prohibited without the express written
|
|
17
|
+
permission of Silmaril Security Inc.
|
|
18
|
+
|
|
19
|
+
This software is provided "AS IS" without warranty of any kind, express or
|
|
20
|
+
implied, including but not limited to the warranties of merchantability,
|
|
21
|
+
fitness for a particular purpose, and noninfringement.
|
package/README.md
CHANGED
|
@@ -12,11 +12,16 @@ the subagent lifecycle hooks stay unchanged and record `blockUnavailable: true`
|
|
|
12
12
|
when Block would have applied. Classifier failures fail open without adding
|
|
13
13
|
agent-visible context.
|
|
14
14
|
|
|
15
|
-
The package declares OpenClaw plugin API `>=2026.
|
|
16
|
-
version `2026.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
The package declares OpenClaw plugin API `>=2026.8.2` and minimum gateway
|
|
16
|
+
version `2026.8.2` (`package.json` `openclaw.compat`). This patched security
|
|
17
|
+
floor excludes affected core host lines identified by OpenClaw advisories. The
|
|
18
|
+
current registration and hook contract are qualified against OpenClaw
|
|
19
|
+
`2026.11.2`. The shipped classifier dependency pin in this source checkout is
|
|
20
|
+
`@silmaril-security/sdk` `0.8.2`. The manifest declares startup activation for
|
|
21
|
+
hook capability loading, and the runtime entry registers typed Gateway hooks
|
|
22
|
+
with `api.on(...)`. Upgrade an existing OpenClaw host older than `2026.8.2`
|
|
23
|
+
through its supported installation method before enabling this plugin version;
|
|
24
|
+
the host rejects it below that floor.
|
|
20
25
|
|
|
21
26
|
## Runtime Hooks
|
|
22
27
|
|
|
@@ -39,7 +44,7 @@ Hook registration is unconditional, so OpenClaw can discover and invoke the
|
|
|
39
44
|
Gateway hooks even before classifier settings are validated. Classifier config
|
|
40
45
|
is resolved inside each hook call.
|
|
41
46
|
|
|
42
|
-
Enforceable hooks await `@silmaril-security/sdk` `0.
|
|
47
|
+
Enforceable hooks await `@silmaril-security/sdk` `0.8.2` with a plugin-owned
|
|
43
48
|
timeout. `before_prompt_build` and `before_agent_run` share one prompt
|
|
44
49
|
classification for five seconds when both callbacks provide the same stable
|
|
45
50
|
event ID and unchanged content. ID-less callbacks classify independently. Warn
|
|
@@ -126,10 +131,30 @@ diagnostic.
|
|
|
126
131
|
from `250` through `10000`; for example, `"timeoutMs": 2500`. Omit it to use
|
|
127
132
|
`2500`. The host validates configuration against the plugin manifest before
|
|
128
133
|
loading the runtime and rejects numeric strings, fractional numbers, and values
|
|
129
|
-
outside that range. That value
|
|
134
|
+
outside that range. That value remains the SDK's per-attempt timeout and is also
|
|
135
|
+
the plugin-owned end-to-end deadline over all SDK attempts, retry backoff, and
|
|
136
|
+
response-body handling. Deadline settlement aborts the SDK call and remains
|
|
137
|
+
bounded even if underlying cleanup ignores cancellation. The plugin authors each
|
|
138
|
+
OpenClaw hook budget as that classifier deadline plus a bounded `1000` ms
|
|
139
|
+
cleanup margin, up to `11000` ms. This lets a classifier timeout settle through
|
|
140
|
+
the plugin's fail-open catch before the host gate budget expires. OpenClaw
|
|
141
|
+
operator settings retain native precedence:
|
|
142
|
+
`hooks.timeouts.<hookName>` overrides `hooks.timeoutMs`, which overrides this
|
|
143
|
+
plugin-authored budget. An operator can intentionally configure a shorter
|
|
144
|
+
budget; OpenClaw's native timeout/error policy then applies, including
|
|
145
|
+
fail-closed behavior for `before_agent_run` and `before_tool_call`.
|
|
130
146
|
|
|
131
147
|
The Silmaril endpoint app supplies `endpointId` as a canonical UUID v4. Every classifier request carries plugin-owned `metadata.silmaril.provenance` with `schema_version` `1` and harness `openclaw`. An omitted or invalid endpoint ID omits `endpoint_id`. On macOS, provenance can also include the local computer name. Classification does not wait for that lookup, and other platforms omit it.
|
|
132
148
|
|
|
149
|
+
Classifier calls identify the fixed OpenClaw agent through the SDK's typed
|
|
150
|
+
governance context. Tool-call and tool-response hooks with a native `toolName`
|
|
151
|
+
use a canonical `tool` resource; other classified hooks use the fixed
|
|
152
|
+
`openclaw` agent resource. SDK 0.8.2 serializes that resource at the request's
|
|
153
|
+
top-level `resource` field and repeats the same attribution under
|
|
154
|
+
`metadata.silmaril.governance`. A tool name remains a flat `tool` identity.
|
|
155
|
+
The plugin does not infer an MCP server, emit an `mcp_tool` resource, or treat
|
|
156
|
+
ordinary metadata as authenticated principal or resource identity.
|
|
157
|
+
|
|
133
158
|
Each hook invocation classifies the current event text at most once. The plugin reads current prompt, tool, message, and lifecycle fields and does not read a transcript `messages` array. It sets `metadata.conversationId` from the child session, session, session key, or parent session, in that order. The Firewall backend owns the incremental sequence for that conversation id.
|
|
134
159
|
|
|
135
160
|
Omit `mode` to use the mode on the classifier response, or set it to `shadow`,
|
|
@@ -182,18 +207,17 @@ not represented as independently verified prevention.
|
|
|
182
207
|
|
|
183
208
|
## Install
|
|
184
209
|
|
|
185
|
-
Version `1.2.
|
|
210
|
+
Version `1.2.11` is the prepared package version for this release. It keeps
|
|
211
|
+
`@silmaril-security/sdk` at `0.8.2`.
|
|
186
212
|
|
|
187
|
-
|
|
213
|
+
After `1.2.11` is published, install that exact npm registry release:
|
|
188
214
|
|
|
189
215
|
```sh
|
|
190
|
-
openclaw plugins install
|
|
216
|
+
openclaw plugins install npm:@silmaril-security/firewall-plugin@1.2.11
|
|
191
217
|
openclaw plugins enable firewall-plugin
|
|
192
218
|
openclaw gateway restart
|
|
193
219
|
```
|
|
194
220
|
|
|
195
|
-
Publishing this version requires a new immutable tag `v1.2.9` and the normal release workflow. Never replace an existing package version or tag.
|
|
196
|
-
|
|
197
221
|
This repository also supports direct source loading and two local CLI install styles.
|
|
198
222
|
|
|
199
223
|
OpenClaw does not automatically discover or pull this repository by plugin id.
|
|
@@ -233,7 +257,7 @@ generated tarball:
|
|
|
233
257
|
npm install
|
|
234
258
|
npm run build
|
|
235
259
|
npm pack
|
|
236
|
-
openclaw plugins install ./silmaril-security-firewall-plugin-1.2.
|
|
260
|
+
openclaw plugins install ./silmaril-security-firewall-plugin-1.2.11.tgz
|
|
237
261
|
openclaw plugins enable firewall-plugin
|
|
238
262
|
openclaw gateway restart
|
|
239
263
|
```
|
package/dist/index.js
CHANGED
|
@@ -225,11 +225,14 @@ function omitUndefined(record) {
|
|
|
225
225
|
|
|
226
226
|
// index.ts
|
|
227
227
|
var PLUGIN_ID = "firewall-plugin";
|
|
228
|
-
var PLUGIN_VERSION = "1.2.
|
|
228
|
+
var PLUGIN_VERSION = "1.2.11";
|
|
229
|
+
var OPENCLAW_AGENT_ID = "openclaw";
|
|
229
230
|
var LOCAL_EVIDENCE_POLICY_VERSION = "openclaw-plugin-policy-v1";
|
|
230
231
|
var DEFAULT_CLASSIFY_TIMEOUT_MS = 2500;
|
|
231
232
|
var MIN_CLASSIFY_TIMEOUT_MS = 250;
|
|
232
233
|
var MAX_CLASSIFY_TIMEOUT_MS = 1e4;
|
|
234
|
+
var HOOK_CLEANUP_MARGIN_MS = 1e3;
|
|
235
|
+
var MAX_PLUGIN_HOOK_TIMEOUT_MS = MAX_CLASSIFY_TIMEOUT_MS + HOOK_CLEANUP_MARGIN_MS;
|
|
233
236
|
var OUTBOUND_DEDUPE_TTL_MS = 5e3;
|
|
234
237
|
var MAX_OUTBOUND_DEDUPE_ENTRIES = 256;
|
|
235
238
|
var MAC_DEVICE_NAME_TIMEOUT_MS = 100;
|
|
@@ -249,12 +252,15 @@ var index_default = definePluginEntry({
|
|
|
249
252
|
description: "Passes OpenClaw hook payloads to Silmaril and renders readable blocked-decision feedback",
|
|
250
253
|
register(api) {
|
|
251
254
|
startMacDeviceNameLookup();
|
|
252
|
-
const
|
|
255
|
+
const classifierTimeoutMs = readIntegerInRange(
|
|
253
256
|
readRecord(api.pluginConfig)?.timeoutMs,
|
|
254
257
|
MIN_CLASSIFY_TIMEOUT_MS,
|
|
255
258
|
MAX_CLASSIFY_TIMEOUT_MS
|
|
256
259
|
) ?? DEFAULT_CLASSIFY_TIMEOUT_MS;
|
|
257
|
-
const hookOptions = {
|
|
260
|
+
const hookOptions = {
|
|
261
|
+
priority: 0,
|
|
262
|
+
timeoutMs: pluginHookBudgetMs(classifierTimeoutMs)
|
|
263
|
+
};
|
|
258
264
|
let missingConfigWarned = false;
|
|
259
265
|
let runtimeClient;
|
|
260
266
|
const outboundClassificationCache = /* @__PURE__ */ new Map();
|
|
@@ -277,14 +283,7 @@ var index_default = definePluginEntry({
|
|
|
277
283
|
agentInputClassificationCache.clear();
|
|
278
284
|
runtimeClient = {
|
|
279
285
|
config,
|
|
280
|
-
state:
|
|
281
|
-
firewall: new Firewall({
|
|
282
|
-
apiKey: config.apiKey,
|
|
283
|
-
apiUrl: config.apiUrl,
|
|
284
|
-
timeoutMs: config.timeoutMs,
|
|
285
|
-
...config.mode ? { mode: config.mode } : {}
|
|
286
|
-
})
|
|
287
|
-
}
|
|
286
|
+
state: createRuntimeState(config)
|
|
288
287
|
};
|
|
289
288
|
}
|
|
290
289
|
return runtimeClient;
|
|
@@ -307,7 +306,7 @@ var index_default = definePluginEntry({
|
|
|
307
306
|
return;
|
|
308
307
|
}
|
|
309
308
|
const result = await classifyOnce(
|
|
310
|
-
runtime.state.
|
|
309
|
+
runtime.state.classifier,
|
|
311
310
|
text,
|
|
312
311
|
meta,
|
|
313
312
|
agentInputClassificationCache,
|
|
@@ -349,7 +348,7 @@ var index_default = definePluginEntry({
|
|
|
349
348
|
return;
|
|
350
349
|
}
|
|
351
350
|
const result = await classifyOnce(
|
|
352
|
-
runtime.state.
|
|
351
|
+
runtime.state.classifier,
|
|
353
352
|
text,
|
|
354
353
|
meta,
|
|
355
354
|
agentInputClassificationCache,
|
|
@@ -375,7 +374,7 @@ var index_default = definePluginEntry({
|
|
|
375
374
|
try {
|
|
376
375
|
const runtimeConfig = runtime.config;
|
|
377
376
|
const text = safeStringify(event?.params ?? {});
|
|
378
|
-
const result = await classifyHookPayload(runtime.state.
|
|
377
|
+
const result = await classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId);
|
|
379
378
|
if (shouldBlockClassification(runtimeConfig, result)) {
|
|
380
379
|
emitOpenClawLocalEvidence(
|
|
381
380
|
meta,
|
|
@@ -415,7 +414,7 @@ var index_default = definePluginEntry({
|
|
|
415
414
|
logSkipped(meta, "empty_payload");
|
|
416
415
|
return;
|
|
417
416
|
}
|
|
418
|
-
const result = await classifyHookPayload(runtime.state.
|
|
417
|
+
const result = await classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId);
|
|
419
418
|
emitOpenClawLocalEvidence(meta, text, result, runtime.config, "allowed", false);
|
|
420
419
|
} catch (err) {
|
|
421
420
|
logError(meta, err);
|
|
@@ -434,7 +433,7 @@ var index_default = definePluginEntry({
|
|
|
434
433
|
logSkipped(meta, "empty_payload");
|
|
435
434
|
return;
|
|
436
435
|
}
|
|
437
|
-
void classifyHookPayload(runtime.state.
|
|
436
|
+
void classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId).then((result) => {
|
|
438
437
|
emitOpenClawLocalEvidence(meta, text, result, runtime.config, "allowed", false);
|
|
439
438
|
}).catch((err) => logError(meta, err));
|
|
440
439
|
} catch (err) {
|
|
@@ -456,7 +455,7 @@ var index_default = definePluginEntry({
|
|
|
456
455
|
}
|
|
457
456
|
const runtimeConfig = runtime.config;
|
|
458
457
|
const result = await classifyOnce(
|
|
459
|
-
runtime.state.
|
|
458
|
+
runtime.state.classifier,
|
|
460
459
|
text,
|
|
461
460
|
meta,
|
|
462
461
|
outboundClassificationCache,
|
|
@@ -488,7 +487,7 @@ var index_default = definePluginEntry({
|
|
|
488
487
|
return;
|
|
489
488
|
}
|
|
490
489
|
const result = await classifyOnce(
|
|
491
|
-
runtime.state.
|
|
490
|
+
runtime.state.classifier,
|
|
492
491
|
text,
|
|
493
492
|
meta,
|
|
494
493
|
outboundClassificationCache,
|
|
@@ -530,7 +529,7 @@ var index_default = definePluginEntry({
|
|
|
530
529
|
logSkipped(meta, "empty_payload");
|
|
531
530
|
return;
|
|
532
531
|
}
|
|
533
|
-
const result = await classifyHookPayload(runtime.state.
|
|
532
|
+
const result = await classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId);
|
|
534
533
|
emitOpenClawLocalEvidence(meta, text, result, runtime.config, "allowed", false);
|
|
535
534
|
} catch (err) {
|
|
536
535
|
logError(meta, err);
|
|
@@ -549,7 +548,7 @@ var index_default = definePluginEntry({
|
|
|
549
548
|
logSkipped(meta, "empty_payload");
|
|
550
549
|
return;
|
|
551
550
|
}
|
|
552
|
-
const result = await classifyHookPayload(runtime.state.
|
|
551
|
+
const result = await classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId);
|
|
553
552
|
emitOpenClawLocalEvidence(meta, text, result, runtime.config, "allowed", false);
|
|
554
553
|
} catch (err) {
|
|
555
554
|
logError(meta, err);
|
|
@@ -568,7 +567,7 @@ var index_default = definePluginEntry({
|
|
|
568
567
|
logSkipped(meta, "empty_payload");
|
|
569
568
|
return;
|
|
570
569
|
}
|
|
571
|
-
const result = await classifyHookPayload(runtime.state.
|
|
570
|
+
const result = await classifyHookPayload(runtime.state.classifier, text, meta, runtime.config.endpointId);
|
|
572
571
|
emitOpenClawLocalEvidence(meta, text, result, runtime.config, "allowed", false);
|
|
573
572
|
} catch (err) {
|
|
574
573
|
logError(meta, err);
|
|
@@ -579,6 +578,65 @@ var index_default = definePluginEntry({
|
|
|
579
578
|
function sameRuntimeConfig(left, right) {
|
|
580
579
|
return left.apiKey === right.apiKey && left.apiUrl === right.apiUrl && left.timeoutMs === right.timeoutMs && left.mode === right.mode && left.endpointId === right.endpointId;
|
|
581
580
|
}
|
|
581
|
+
function createRuntimeState(config) {
|
|
582
|
+
const firewall = new Firewall({
|
|
583
|
+
apiKey: config.apiKey,
|
|
584
|
+
apiUrl: config.apiUrl,
|
|
585
|
+
timeoutMs: config.timeoutMs,
|
|
586
|
+
...config.mode ? { mode: config.mode } : {}
|
|
587
|
+
});
|
|
588
|
+
return {
|
|
589
|
+
classifier: createBoundedClassificationClient(firewall, config.timeoutMs)
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function createBoundedClassificationClient(firewall, timeoutMs) {
|
|
593
|
+
return {
|
|
594
|
+
classify(text, options) {
|
|
595
|
+
return withClassificationDeadline(
|
|
596
|
+
timeoutMs,
|
|
597
|
+
(signal) => firewall.classify(text, { ...options, signal })
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
function withClassificationDeadline(timeoutMs, classify) {
|
|
603
|
+
const controller = new AbortController();
|
|
604
|
+
let settled = false;
|
|
605
|
+
let timer;
|
|
606
|
+
return new Promise((resolve, reject) => {
|
|
607
|
+
const settle = (finish, value) => {
|
|
608
|
+
if (settled) return;
|
|
609
|
+
settled = true;
|
|
610
|
+
clearTimeout(timer);
|
|
611
|
+
finish(value);
|
|
612
|
+
};
|
|
613
|
+
const fail = (error) => {
|
|
614
|
+
if (settled) return;
|
|
615
|
+
settled = true;
|
|
616
|
+
clearTimeout(timer);
|
|
617
|
+
reject(error);
|
|
618
|
+
};
|
|
619
|
+
timer = setTimeout(() => {
|
|
620
|
+
const error = new DOMException(
|
|
621
|
+
"Silmaril classification deadline exceeded",
|
|
622
|
+
"TimeoutError"
|
|
623
|
+
);
|
|
624
|
+
controller.abort(error);
|
|
625
|
+
fail(error);
|
|
626
|
+
}, timeoutMs);
|
|
627
|
+
let classification;
|
|
628
|
+
try {
|
|
629
|
+
classification = classify(controller.signal);
|
|
630
|
+
} catch (error) {
|
|
631
|
+
fail(error);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
Promise.resolve(classification).then(
|
|
635
|
+
(result) => settle(resolve, result),
|
|
636
|
+
(error) => fail(error)
|
|
637
|
+
);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
582
640
|
function resolveRuntimeConfig(rawConfig) {
|
|
583
641
|
const config = readRecord(rawConfig);
|
|
584
642
|
const apiKey = readString(config?.silmarilApiKey) ?? readString(config?.apiKey);
|
|
@@ -619,6 +677,12 @@ function readIntegerInRange(value, min, max) {
|
|
|
619
677
|
}
|
|
620
678
|
return integerValue;
|
|
621
679
|
}
|
|
680
|
+
function pluginHookBudgetMs(classifierTimeoutMs) {
|
|
681
|
+
return Math.min(
|
|
682
|
+
classifierTimeoutMs + HOOK_CLEANUP_MARGIN_MS,
|
|
683
|
+
MAX_PLUGIN_HOOK_TIMEOUT_MS
|
|
684
|
+
);
|
|
685
|
+
}
|
|
622
686
|
function readBoolean(value) {
|
|
623
687
|
if (typeof value === "boolean") {
|
|
624
688
|
return value;
|
|
@@ -652,16 +716,17 @@ function omitUndefined2(record) {
|
|
|
652
716
|
Object.entries(record).filter((entry) => entry[1] !== void 0)
|
|
653
717
|
);
|
|
654
718
|
}
|
|
655
|
-
async function classifyHookPayload(
|
|
719
|
+
async function classifyHookPayload(classifier, text, meta, endpointId) {
|
|
656
720
|
const trimmed = text.trim();
|
|
657
721
|
if (!trimmed) {
|
|
658
722
|
logSkipped(meta, "empty_payload");
|
|
659
723
|
return void 0;
|
|
660
724
|
}
|
|
661
|
-
const result = await
|
|
725
|
+
const result = await classifier.classify(text, {
|
|
662
726
|
hook: meta.hook,
|
|
663
727
|
toolName: meta.toolName,
|
|
664
728
|
requestId: buildStableRequestId(meta, text),
|
|
729
|
+
governance: buildGovernanceContext(meta),
|
|
665
730
|
metadata: withProvenance({
|
|
666
731
|
eventType: meta.hookName,
|
|
667
732
|
conversationId: meta.conversationId,
|
|
@@ -675,17 +740,25 @@ async function classifyHookPayload(firewall, text, meta, endpointId) {
|
|
|
675
740
|
}));
|
|
676
741
|
return result;
|
|
677
742
|
}
|
|
678
|
-
|
|
743
|
+
function buildGovernanceContext(meta) {
|
|
744
|
+
const isToolBoundary = meta.hook === HookLabel.TOOL_CALL || meta.hook === HookLabel.TOOL_RESPONSE;
|
|
745
|
+
const resource = isToolBoundary && meta.toolName ? { kind: "tool", id: meta.toolName } : { kind: "agent", id: OPENCLAW_AGENT_ID };
|
|
746
|
+
return {
|
|
747
|
+
agent: OPENCLAW_AGENT_ID,
|
|
748
|
+
resource
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
async function classifyOnce(classifier, text, meta, cache, endpointId, now = Date.now()) {
|
|
679
752
|
const key = outboundDedupeKey(meta, text);
|
|
680
753
|
pruneOutboundCache(cache, now);
|
|
681
754
|
if (!key) {
|
|
682
|
-
return classifyHookPayload(
|
|
755
|
+
return classifyHookPayload(classifier, text, meta, endpointId);
|
|
683
756
|
}
|
|
684
757
|
const existing = cache.get(key);
|
|
685
758
|
if (existing && now - existing.createdAt <= OUTBOUND_DEDUPE_TTL_MS) {
|
|
686
759
|
return existing.result;
|
|
687
760
|
}
|
|
688
|
-
const result = classifyHookPayload(
|
|
761
|
+
const result = classifyHookPayload(classifier, text, meta, endpointId);
|
|
689
762
|
cache.set(key, { createdAt: now, result });
|
|
690
763
|
if (cache.size > MAX_OUTBOUND_DEDUPE_ENTRIES) {
|
|
691
764
|
const oldest = cache.keys().next().value;
|
|
@@ -1304,9 +1377,15 @@ var __testInternals = {
|
|
|
1304
1377
|
readRecord,
|
|
1305
1378
|
readString,
|
|
1306
1379
|
readIntegerInRange,
|
|
1380
|
+
pluginHookBudgetMs,
|
|
1381
|
+
HOOK_CLEANUP_MARGIN_MS,
|
|
1382
|
+
MAX_PLUGIN_HOOK_TIMEOUT_MS,
|
|
1383
|
+
createBoundedClassificationClient,
|
|
1384
|
+
withClassificationDeadline,
|
|
1307
1385
|
readBoolean,
|
|
1308
1386
|
readMode,
|
|
1309
1387
|
classifyHookPayload,
|
|
1388
|
+
buildGovernanceContext,
|
|
1310
1389
|
classifyOnce,
|
|
1311
1390
|
classifyOutboundOnce: classifyOnce,
|
|
1312
1391
|
outboundDedupeKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silmaril-security/firewall-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"CLAUDE.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@silmaril-security/sdk": "0.
|
|
27
|
+
"@silmaril-security/sdk": "0.8.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"esbuild": "0.28.0",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"./dist/index.js"
|
|
36
36
|
],
|
|
37
37
|
"compat": {
|
|
38
|
-
"pluginApi": ">=2026.
|
|
39
|
-
"minGatewayVersion": "2026.
|
|
38
|
+
"pluginApi": ">=2026.8.2",
|
|
39
|
+
"minGatewayVersion": "2026.8.2"
|
|
40
40
|
},
|
|
41
41
|
"build": {
|
|
42
|
-
"openclawVersion": "2026.
|
|
43
|
-
"pluginSdkVersion": "2026.
|
|
42
|
+
"openclawVersion": "2026.11.2",
|
|
43
|
+
"pluginSdkVersion": "2026.11.2"
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|