@aporthq/aport-agent-guardrails 1.0.21 → 1.0.22

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.
@@ -1,69 +1,153 @@
1
1
  # APort Guardrails — OpenClaw
2
2
 
3
- OpenClaw is an open-source AI agent platform with a plugin system and built-in `before_tool_call` hooks. APort integrates via two paths:
4
-
5
- - **Native `guardrails:` config** (recommended) — OpenClaw's built-in `GuardrailProvider` interface loads `OAPGuardrailProvider` directly. No plugin needed.
6
- - **Plugin** (legacy, still works) — The `openclaw-aport` plugin registers a `before_tool_call` hook.
7
-
8
- Both paths use the same evaluator, passport, and policies.
3
+ APort integrates with the current public OpenClaw release as a plugin. The plugin registers `before_tool_call` and blocks disallowed tools before execution. No OpenClaw core patch or native guardrail-provider merge is required.
9
4
 
10
5
  ## Quick start
11
6
 
12
7
  ```bash
13
- npm install @aporthq/aport-agent-guardrails-core
14
8
  npx @aporthq/aport-agent-guardrails openclaw
15
9
  ```
16
10
 
17
- The first command installs the provider. The second runs the passport wizard.
11
+ If you already have a hosted passport on aport.io, pass the `agent_id` and skip local passport creation:
12
+
13
+ ```bash
14
+ npx @aporthq/aport-agent-guardrails openclaw ap_your_agent_id
15
+ ```
16
+
17
+ The setup command:
18
+
19
+ 1. Chooses your OpenClaw config directory
20
+ 2. Creates a local passport or wires a hosted `agent_id`
21
+ 3. Installs the `openclaw-aport` plugin with `openclaw plugins install -l ...`
22
+ 4. Writes `plugins.entries.openclaw-aport` config into your OpenClaw config files
23
+ 5. Installs APort wrappers in `CONFIG_DIR/.skills/` for manual status checks and smoke tests
24
+
25
+ After setup, start OpenClaw with the generated config:
26
+
27
+ ```bash
28
+ openclaw gateway start --config ~/.openclaw/config.yaml
29
+ ```
30
+
31
+ ## What OpenClaw already gives you
32
+
33
+ OpenClaw already ships meaningful runtime security controls:
34
+
35
+ - sandboxing and OpenShell decide where tools run
36
+ - tool policy decides which tools are callable
37
+ - elevated execution gates host-level exec outside the sandbox
38
+ - install-time scanning blocks obviously dangerous plugin bundles
39
+
40
+ Those controls matter, and for many single-runtime deployments they may be enough.
41
+
42
+ ## What APort adds
43
+
44
+ APort is useful when you need authorization and audit beyond OpenClaw's built-in containment and static tool policy:
45
+
46
+ - per-agent identity and passport-based capability limits
47
+ - parameter-aware authorization, not just tool allow/deny
48
+ - local or hosted kill switch by suspending the passport
49
+ - signed decision receipts and centralized audit in API mode
50
+ - the same policy model across OpenClaw, CrewAI, DeerFlow, LangChain, and other runtimes
18
51
 
19
- ## Config (native recommended)
52
+ In short: OpenClaw secures where tools run and which tools exist; APort secures whether a specific action is authorized for a specific agent right now.
20
53
 
21
- Add to your OpenClaw `config.yaml`:
54
+ ## Configuration
55
+
56
+ The installer writes the plugin config for you. A minimal manual config looks like this:
22
57
 
23
58
  ```yaml
24
- guardrails:
59
+ plugins:
25
60
  enabled: true
26
- provider:
27
- use: "@aporthq/aport-agent-guardrails-core"
28
- config:
29
- framework: "openclaw"
61
+ entries:
62
+ openclaw-aport:
63
+ enabled: true
64
+ config:
65
+ mode: api
66
+ passportFile: ~/.openclaw/aport/passport.json
67
+ apiUrl: https://api.aport.io
68
+ failClosed: true
69
+ allowUnmappedTools: true
30
70
  ```
31
71
 
32
- This loads `OAPGuardrailProvider` as a core guardrail service — runs before plugin hooks, cannot be bypassed by disabling a plugin.
72
+ Hosted passport mode uses `agentId` instead of `passportFile`:
33
73
 
34
- ## Config (plugin — legacy)
74
+ ```yaml
75
+ plugins:
76
+ enabled: true
77
+ entries:
78
+ openclaw-aport:
79
+ enabled: true
80
+ config:
81
+ mode: api
82
+ agentId: ap_your_agent_id
83
+ apiUrl: https://api.aport.io
84
+ failClosed: true
85
+ allowUnmappedTools: true
86
+ ```
35
87
 
36
- The setup wizard (`npx @aporthq/aport-agent-guardrails openclaw`) installs the `openclaw-aport` plugin automatically. This registers a `before_tool_call` hook that calls the same evaluator.
88
+ ## Modes
37
89
 
38
- Both approaches are supported. The native config is recommended for new deployments.
90
+ ### API mode
39
91
 
40
- ## How it works
92
+ Best for production, signed decisions, and cloud kill switch workflows.
93
+
94
+ - The plugin sends the request context and passport or `agentId` to `api.aport.io`
95
+ - The API returns a signed decision
96
+ - If your deployment needs authentication, set `apiKey` in plugin config
97
+
98
+ ### Local mode
99
+
100
+ Best for privacy-sensitive or offline environments.
101
+
102
+ - The plugin evaluates decisions with a built-in JavaScript evaluator
103
+ - No `child_process` spawn is required
104
+ - The installer still writes `guardrailScript` wrappers for manual smoke tests and legacy shell tooling, but current plugin versions do not depend on that script for local-mode enforcement
41
105
 
106
+ ## Manual install for development
107
+
108
+ The public path is `npx @aporthq/aport-agent-guardrails openclaw`. If you are developing locally from a checkout, you can install the plugin directly:
109
+
110
+ ```bash
111
+ openclaw plugins install -l /path/to/aport-agent-guardrails/extensions/openclaw-aport
42
112
  ```
113
+
114
+ Then add the same `plugins.entries.openclaw-aport` config shown above.
115
+
116
+ ## How it works
117
+
118
+ ```text
43
119
  Agent decides to use a tool
44
-
45
-
46
- GuardrailService (native) or Plugin hook (legacy)
47
- │ │
48
- ▼ ▼
49
- OAPGuardrailProvider ──────────────── same Evaluator
50
-
51
- ┌─────┴─────┐
52
- │ │
53
- ALLOW DENY
54
- │ │
55
- Tool runs Agent sees denial reason
120
+ |
121
+ v
122
+ OpenClaw fires before_tool_call
123
+ |
124
+ v
125
+ APort plugin maps tool -> policy pack
126
+ |
127
+ v
128
+ APort evaluates passport + limits (local JS evaluator or API)
129
+ | |
130
+ v v
131
+ allow deny
132
+ | |
133
+ Tool runs Plugin returns block=true
56
134
  ```
57
135
 
58
- - **Provider class:** `OAPGuardrailProvider` from `@aporthq/aport-agent-guardrails-core`
59
- - **Passport:** `~/.openclaw/aport/passport.json` (created by wizard)
60
- - **Config:** `~/.openclaw/aport/config.yaml`
61
- - **Audit log:** `~/.openclaw/aport/audit.log`
136
+ Common mappings include:
62
137
 
63
- ## Suspend (kill switch)
138
+ - `exec`, `exec.run` -> `system.command.execute.v1`
139
+ - `git.create_pr`, `git.merge`, `git.push` -> `code.repository.merge.v1`
140
+ - `message.send` -> `messaging.message.send.v1`
141
+ - `read`, `view`, `glob` -> `data.file.read.v1`
142
+ - `write`, `edit`, `multiedit` -> `data.file.write.v1`
64
143
 
65
- Local: set passport `status` to `suspended`. Remote: use API mode and suspend at [aport.io](https://aport.io).
144
+ ## Kill switch
145
+
146
+ - Local passport: set `status` to `suspended` in `~/.openclaw/aport/passport.json`
147
+ - Hosted passport: suspend the passport at aport.io
66
148
 
67
149
  ## Status
68
150
 
69
- Shipped; in production. Native `guardrails:` config available when [OpenClaw #46441](https://github.com/openclaw/openclaw/issues/46441) merges.
151
+ Current public OpenClaw integration: plugin-based.
152
+
153
+ Future path: if OpenClaw ships a native guardrail-provider seam upstream, APort can also plug into that provider path. That is not the current public default.
@@ -1,9 +1,15 @@
1
1
  # Changelog - APort OpenClaw Plugin
2
2
 
3
- ## 1.0.21
4
-
5
3
  All notable changes to the APort OpenClaw plugin will be documented in this file.
6
4
 
5
+ ## [1.0.22] - 2026-04-13
6
+
7
+ ### Fixed
8
+ - Replaced the old shell-spawning runtime with a scanner-safe JavaScript plugin runtime for local and API evaluation.
9
+ - Added current OpenClaw compatibility metadata in `package.json` and aligned the hook return shape with the documented `before_tool_call` contract.
10
+ - Kept `alwaysVerifyEachToolCall` as a deprecated manifest field so existing installs continue to load during upgrade.
11
+ - Updated the public install and migration docs to match the plugin-based OpenClaw path.
12
+
7
13
  ## [1.0.21] - 2026-02-19
8
14
 
9
15
  ### Changed - OpenClaw 2026.2 Compatibility
@@ -1,398 +1,45 @@
1
1
  # OpenClaw Plugin Migration Guide
2
2
 
3
- > **Note**: This is the **OpenClaw-specific plugin** within the broader [aport-agent-guardrails](https://github.com/aporthq/aport-agent-guardrails) repository, which provides guardrails for multiple AI agent frameworks including LangChain, CrewAI, n8n, Cursor, and OpenClaw.
3
+ This guide is for teams upgrading older APort OpenClaw installs to the current scanner-safe plugin bundle.
4
4
 
5
- ## Breaking Changes in OpenClaw 2026.2
5
+ ## What changed
6
6
 
7
- The APort OpenClaw plugin has been updated to comply with OpenClaw 2026.2's new plugin architecture. If you're upgrading from an older version, please read this guide.
7
+ Current plugin versions:
8
8
 
9
- ## What Changed
9
+ - ship JavaScript runtime files only (`index.js` plus helpers)
10
+ - use a built-in JavaScript local evaluator instead of spawning `child_process`
11
+ - call the hosted API directly in API mode
12
+ - avoid source-linked `plugins.load.paths` entries that point into transient `npx` cache directories
10
13
 
11
- ### Old Architecture (Pre-2026.2)
14
+ ## Recommended upgrade path
12
15
 
13
- ```javascript
14
- // Old: Function-based plugin
15
- export default function (api) {
16
- api.on("before_tool_call", async (event, ctx) => {
17
- // handler code
18
- });
19
- }
20
- ```
21
-
22
- **Package.json:**
23
- ```json
24
- {
25
- "openclaw": {
26
- "extensions": ["openclaw-aport"] // ❌ String reference
27
- }
28
- }
29
- ```
30
-
31
- ### New Architecture (2026.2+)
32
-
33
- ```typescript
34
- // New: Object-based plugin with TypeScript
35
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
36
-
37
- const plugin = {
38
- id: "openclaw-aport",
39
- name: "APort Guardrails",
40
- description: "...",
41
- configSchema: { /* JSON Schema */ },
42
- register(api: OpenClawPluginApi) {
43
- api.on("before_tool_call", async (event, ctx) => {
44
- // handler code
45
- });
46
- },
47
- };
48
-
49
- export default plugin;
50
- ```
51
-
52
- **Package.json:**
53
- ```json
54
- {
55
- "openclaw": {
56
- "extensions": ["./index.ts"] // ✅ Path to TypeScript file
57
- }
58
- }
59
- ```
60
-
61
- ## Key Architectural Changes
62
-
63
- ### 1. Plugin Structure
64
-
65
- | Old | New |
66
- |-----|-----|
67
- | Export function | Export object with `id`, `name`, `description`, `configSchema`, `register()` |
68
- | JavaScript (.js) | TypeScript (.ts) preferred |
69
- | Immediate execution | Lazy loading via `register()` method |
70
-
71
- ### 2. Type Safety
72
-
73
- ```typescript
74
- // Import OpenClaw types
75
- import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
76
-
77
- // Config type safety
78
- interface APortPluginConfig {
79
- mode?: "local" | "api";
80
- agentId?: string;
81
- passportFile?: string;
82
- // ...
83
- }
84
- ```
85
-
86
- ### 3. Entry Point
87
-
88
- The `openclaw.extensions` field in `package.json` must now point to a file path:
89
-
90
- ```json
91
- {
92
- "openclaw": {
93
- "extensions": ["./index.ts"] // Path to entry file
94
- }
95
- }
96
- ```
97
-
98
- ### 4. Dev Dependencies
99
-
100
- ```json
101
- {
102
- "devDependencies": {
103
- "openclaw": ">=2026.2.0",
104
- "@types/node": "^18.0.0",
105
- "typescript": "^5.0.0"
106
- }
107
- }
108
- ```
109
-
110
- ## Upgrading from Old Installation
111
-
112
- If you had the old plugin installed (OpenClaw < 2026.2), you need to **remove the old installation first** to avoid conflicts.
113
-
114
- ### Step 1: Remove Old Plugin Configuration
115
-
116
- Edit your OpenClaw config file (usually `~/.openclaw/openclaw.json` or `~/.openclaw/config.json`) and remove:
117
-
118
- - `plugins.load.paths` — delete the entry pointing to `openclaw-aport`
119
- - `plugins.entries.openclaw-aport` — delete the entire block
120
- - `plugins.installs.openclaw-aport` — delete the entire block
121
-
122
- **Keep** `plugins.entries` intact if other plugins are configured (e.g. `whatsapp`).
123
-
124
- **Example — Before:**
125
-
126
- ```json
127
- {
128
- "plugins": {
129
- "load": {
130
- "paths": [
131
- "/path/to/aport-agent-guardrails/extensions/openclaw-aport"
132
- ]
133
- },
134
- "entries": {
135
- "whatsapp": { "enabled": false },
136
- "openclaw-aport": {
137
- "enabled": true,
138
- "config": { "mode": "api", "passportFile": "..." }
139
- }
140
- },
141
- "installs": {
142
- "openclaw-aport": {
143
- "source": "path",
144
- "sourcePath": "/path/to/openclaw-aport",
145
- "installPath": "/path/to/openclaw-aport"
146
- }
147
- }
148
- }
149
- }
150
- ```
151
-
152
- **After:**
153
-
154
- ```json
155
- {
156
- "plugins": {
157
- "entries": {
158
- "whatsapp": { "enabled": false }
159
- }
160
- }
161
- }
162
- ```
163
-
164
- ### Step 2: Restart Gateway
16
+ Re-run the public setup command:
165
17
 
166
18
  ```bash
167
- openclaw gateway restart
19
+ npx @aporthq/aport-agent-guardrails openclaw
168
20
  ```
169
21
 
170
- ### Step 3: Verify Clean State
22
+ That will:
171
23
 
172
- ```bash
173
- openclaw gateway status
174
- openclaw plugins list
175
- ```
176
-
177
- Confirm: no config errors, `openclaw-aport` not listed, RPC probe shows `ok`.
24
+ 1. Reinstall the plugin
25
+ 2. Refresh `plugins.entries.openclaw-aport`
26
+ 3. Remove stale source-linked `plugins.load.paths` and `plugins.installs.openclaw-aport` entries
27
+ 4. Refresh the APort wrappers under `CONFIG_DIR/.skills/`
178
28
 
179
- ### Step 4: Install New Version
29
+ ## Development upgrade path
180
30
 
181
- Now install the updated plugin:
31
+ If you are working from a local checkout:
182
32
 
183
33
  ```bash
184
- # Link for development (recommended)
185
34
  openclaw plugins install -l /path/to/aport-agent-guardrails/extensions/openclaw-aport
186
-
187
- # Or install from directory
188
- openclaw plugins install /path/to/aport-agent-guardrails/extensions/openclaw-aport
189
- ```
190
-
191
- This will:
192
- - Add the new plugin configuration to your config
193
- - Link to the `index.ts` entry point
194
- - Apply the new object-based plugin structure
195
-
196
- ### Step 5: Configure Plugin
197
-
198
- Edit your OpenClaw config (now in YAML format, typically `~/.openclaw/config.yaml`):
199
-
200
- ```yaml
201
- plugins:
202
- enabled: true
203
- entries:
204
- openclaw-aport:
205
- enabled: true
206
- config:
207
- mode: local # or "api"
208
- passportFile: ~/.openclaw/aport/passport.json
209
- guardrailScript: ~/.openclaw/.skills/aport-guardrail-bash.sh
210
- failClosed: true
211
- allowUnmappedTools: true
212
- ```
213
-
214
- ### Step 6: Restart and Verify
215
-
216
- ```bash
217
- openclaw gateway restart
218
- openclaw plugins list
219
- ```
220
-
221
- You should see:
222
-
223
35
  ```
224
- ┌──────────────┬──────────┬────────┬────────────────────────────────┬─────────┐
225
- │ Name │ ID │ Status │ Source │ Version │
226
- ├──────────────┼──────────┼────────┼────────────────────────────────┼─────────┤
227
- │ APort │ openclaw │ loaded │ ~/path/to/openclaw-aport/ │ 1.0.0 │
228
- │ Guardrails │ -aport │ │ index.ts │ │
229
- ```
230
-
231
- ## Fresh Installation (No Previous Version)
232
-
233
- ### Verify Fresh Installation
234
-
235
- ```bash
236
- # Link for development (recommended)
237
- openclaw plugins install -l /path/to/aport-agent-guardrails/extensions/openclaw-aport
238
-
239
- # Then check
240
- openclaw plugins list
241
- ```
242
-
243
- You should see:
244
- ```
245
- ┌──────────────┬──────────┬────────┬────────────────────────────────┬─────────┐
246
- │ Name │ ID │ Status │ Source │ Version │
247
- ├──────────────┼──────────┼────────┼────────────────────────────────┼─────────┤
248
- │ APort │ openclaw │ loaded │ ~/path/to/openclaw-aport/ │ 1.0.0 │
249
- │ Guardrails │ -aport │ │ index.ts │ │
250
- ```
251
-
252
- Then configure in your `config.yaml` (see Configuration section above).
253
-
254
- ## Configuration
255
-
256
- Configuration remains the same in your OpenClaw `config.yaml`:
257
-
258
- ```yaml
259
- plugins:
260
- enabled: true
261
- entries:
262
- openclaw-aport:
263
- enabled: true
264
- config:
265
- mode: local # or "api"
266
- passportFile: ~/.openclaw/aport/passport.json
267
- guardrailScript: ~/.openclaw/.skills/aport-guardrail-bash.sh
268
- failClosed: true
269
- allowUnmappedTools: true
270
- ```
271
-
272
- ## Testing
273
-
274
- Run the plugin unit tests:
275
-
276
- ```bash
277
- cd extensions/openclaw-aport
278
- node test.js
279
- ```
280
-
281
- Expected output:
282
- ```
283
- # tests 21
284
- # pass 21
285
- # fail 0
286
- ```
287
-
288
- ## Backwards Compatibility
289
-
290
- The old `index.js` file is preserved for backwards compatibility with tests and older OpenClaw versions. However, OpenClaw 2026.2+ will use `index.ts`.
291
-
292
- ## Troubleshooting
293
-
294
- ### Old Plugin Still Loading After Upgrade
295
-
296
- **Symptom:**
297
- ```
298
- [plugins] [APort] Loaded: ...
299
- ```
300
- But you're seeing errors or the plugin isn't working correctly.
301
-
302
- **Solution:**
303
- The old plugin is still configured. Follow "Step 1: Remove Old Plugin Configuration" above and restart the gateway:
304
-
305
- ```bash
306
- # 1. Edit config to remove old entries
307
- vim ~/.openclaw/openclaw.json # or config.json
308
-
309
- # 2. Restart
310
- openclaw gateway restart
311
-
312
- # 3. Verify old plugin is gone
313
- openclaw plugins list # Should NOT show openclaw-aport
314
-
315
- # 4. Reinstall new version
316
- openclaw plugins install -l /path/to/aport-agent-guardrails/extensions/openclaw-aport
317
- ```
318
-
319
- ### Plugin Not Loading
320
-
321
- **Error:**
322
- ```
323
- Config validation failed: plugins: plugin: extension entry escapes package directory
324
- ```
325
-
326
- **Solution:**
327
- Ensure `package.json` has:
328
- ```json
329
- {
330
- "openclaw": {
331
- "extensions": ["./index.ts"] // Must be a file path, not a string reference
332
- }
333
- }
334
- ```
335
-
336
- ### Config File Format Confusion
337
-
338
- OpenClaw 2026.2 uses YAML (`config.yaml`) for primary configuration, but plugin install metadata lives in JSON (`openclaw.json`):
339
-
340
- - **`~/.openclaw/config.yaml`** - Your main config (plugins.entries, passport paths, etc.)
341
- - **`~/.openclaw/openclaw.json`** - Plugin install metadata (managed by `openclaw plugins install`)
342
-
343
- When upgrading, edit the **JSON file** to remove old plugin entries, then use **YAML file** for new plugin configuration.
344
-
345
- ### TypeScript Errors
346
-
347
- OpenClaw uses `jiti` to load TypeScript files at runtime, so you don't need to compile `.ts` to `.js`. However, for type checking during development:
348
-
349
- ```bash
350
- npm install
351
- npx tsc --noEmit # Check types without compiling
352
- ```
353
-
354
- ### Import Errors
355
-
356
- **Error:**
357
- ```
358
- Cannot find module 'openclaw/plugin-sdk'
359
- ```
360
-
361
- **Solution:**
362
- Ensure OpenClaw is installed:
363
- ```bash
364
- npm install -g openclaw
365
- ```
366
-
367
- Or add to devDependencies:
368
- ```json
369
- {
370
- "devDependencies": {
371
- "openclaw": ">=2026.2.0"
372
- }
373
- }
374
- ```
375
-
376
- ## Security Note
377
-
378
- OpenClaw 2026.2 introduced stricter security controls:
379
- - Agent-based access controls (`allowedAgents`)
380
- - Disabled plugin runtime command execution primitive
381
- - Explicit opt-in for deprecated features
382
-
383
- These changes don't affect the APort plugin's functionality but provide additional security layers at the OpenClaw level.
384
36
 
385
- ## Resources
37
+ Then re-run the installer or update `plugins.entries.openclaw-aport` in your config.
386
38
 
387
- - [OpenClaw Plugin Documentation](https://docs.openclaw.ai/tools/plugin)
388
- - [OpenClaw GitHub](https://github.com/openclaw/openclaw)
389
- - [APort Documentation](https://github.com/aporthq/aport-agent-guardrails)
39
+ ## Local mode
390
40
 
391
- ## Version Compatibility
41
+ Local mode still exists, but current plugin versions evaluate locally in JavaScript. The `guardrailScript` field remains for manual shell-based smoke tests and legacy tooling; the plugin no longer depends on it for local-mode enforcement.
392
42
 
393
- | OpenClaw Version | APort Plugin |
394
- |------------------|--------------|
395
- | < 2026.2 | Use old `index.js` (function-based) |
396
- | >= 2026.2 | Use new `index.ts` (object-based) |
43
+ ## If you previously installed from an old `npx` cache path
397
44
 
398
- The plugin now requires OpenClaw 2026.2.0 or later.
45
+ Older setups could leave `openclaw.json` pointing at a transient `~/.npm/_npx/.../extensions/openclaw-aport` directory. Re-running the setup command cleans that up.