@goplus/agentguard 1.1.20 → 1.1.26

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.
Files changed (58) hide show
  1. package/README.md +6 -1
  2. package/dist/adapters/openclaw-plugin.d.ts.map +1 -1
  3. package/dist/adapters/openclaw-plugin.js +24 -3
  4. package/dist/adapters/openclaw-plugin.js.map +1 -1
  5. package/dist/adapters/openclaw.d.ts.map +1 -1
  6. package/dist/adapters/openclaw.js +7 -2
  7. package/dist/adapters/openclaw.js.map +1 -1
  8. package/dist/cli.js +84 -45
  9. package/dist/cli.js.map +1 -1
  10. package/dist/config.d.ts +2 -0
  11. package/dist/config.d.ts.map +1 -1
  12. package/dist/config.js +3 -0
  13. package/dist/config.js.map +1 -1
  14. package/dist/feed/selfcheck.d.ts.map +1 -1
  15. package/dist/feed/selfcheck.js +205 -54
  16. package/dist/feed/selfcheck.js.map +1 -1
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +7 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/installers.js +15 -4
  22. package/dist/installers.js.map +1 -1
  23. package/dist/runtime/approvals.d.ts +38 -0
  24. package/dist/runtime/approvals.d.ts.map +1 -0
  25. package/dist/runtime/approvals.js +227 -0
  26. package/dist/runtime/approvals.js.map +1 -0
  27. package/dist/runtime/evaluator.d.ts.map +1 -1
  28. package/dist/runtime/evaluator.js +54 -0
  29. package/dist/runtime/evaluator.js.map +1 -1
  30. package/dist/runtime/protect.d.ts +2 -0
  31. package/dist/runtime/protect.d.ts.map +1 -1
  32. package/dist/runtime/protect.js +75 -9
  33. package/dist/runtime/protect.js.map +1 -1
  34. package/dist/runtime/self-command.d.ts.map +1 -1
  35. package/dist/runtime/self-command.js +23 -3
  36. package/dist/runtime/self-command.js.map +1 -1
  37. package/dist/tests/adapter.test.js +8 -0
  38. package/dist/tests/adapter.test.js.map +1 -1
  39. package/dist/tests/cli-init.test.js +10 -0
  40. package/dist/tests/cli-init.test.js.map +1 -1
  41. package/dist/tests/cli-subscribe.test.js +106 -1
  42. package/dist/tests/cli-subscribe.test.js.map +1 -1
  43. package/dist/tests/feed-selfcheck.test.js +81 -0
  44. package/dist/tests/feed-selfcheck.test.js.map +1 -1
  45. package/dist/tests/installer.test.js +9 -2
  46. package/dist/tests/installer.test.js.map +1 -1
  47. package/dist/tests/integration.test.js +64 -0
  48. package/dist/tests/integration.test.js.map +1 -1
  49. package/dist/tests/runtime-cloud.test.js +323 -0
  50. package/dist/tests/runtime-cloud.test.js.map +1 -1
  51. package/docs/claude-code.md +3 -2
  52. package/docs/cloud-connect.md +16 -3
  53. package/docs/cloud-native-api.md +26 -118
  54. package/docs/codex.md +13 -1
  55. package/docs/openclaw.md +32 -1
  56. package/docs/privacy-boundary.md +0 -1
  57. package/package.json +1 -1
  58. package/skills/agentguard/SKILL.md +4 -0
@@ -25,7 +25,7 @@ X-API-Key: ag_live_xxxxx
25
25
  3. Evaluate runtime actions locally using cached policy and the bundled local engine.
26
26
  4. Write local audit JSONL before any Cloud sync.
27
27
  5. Upload redacted audit events to `POST /api/v1/events/ingest`.
28
- 6. For `require_approval`, create `POST /api/v1/approvals` and block the action until reviewed.
28
+ 6. For `require_approval`, use the local agent host's native permission channel when supported. If the host cannot safely resume a reviewed call, block locally and ask the user to retry only after intentionally changing local policy.
29
29
  7. Use `GET /api/v1/sessions/:sessionId/timeline` for review/debug UI.
30
30
 
31
31
  If Cloud is unavailable, continue local enforcement using cached policy, then bundled default policy.
@@ -91,10 +91,24 @@ The script installs `@goplus/agentguard`, writes a safe fallback local config, t
91
91
 
92
92
  ```bash
93
93
  agentguard init --agent "$AGENTGUARD_AGENT" --cloud "$AGENTGUARD_CLOUD_URL"
94
+ ```
95
+
96
+ When the effective agent host is OpenClaw, the script should connect without an
97
+ API key:
98
+
99
+ ```bash
100
+ agentguard connect --cloud "$AGENTGUARD_CLOUD_URL"
101
+ ```
102
+
103
+ The CLI registers a local Agent JWT and prints an activation link. For other
104
+ agent hosts, or when the user explicitly chooses API-key auth, the script should
105
+ call:
106
+
107
+ ```bash
94
108
  agentguard connect --cloud "$AGENTGUARD_CLOUD_URL" --api-key "$AGENTGUARD_API_KEY"
95
109
  ```
96
110
 
97
- Native CLI implementations should support `--cloud` as an alias for the Cloud URL and `--api-key` as an alias for the API key.
111
+ Native CLI implementations should support `--cloud` as an alias for the Cloud URL and `--api-key` as an alias for the API key. Installers that accept `agent=auto` should use the agent host persisted by `agentguard init --agent auto` when choosing between Agent JWT and API-key auth.
98
112
 
99
113
  ### Health check
100
114
 
@@ -262,126 +276,20 @@ Limits and behavior:
262
276
  - `input` should be a redacted preview, not full file content or full prompt content.
263
277
  - If upload fails, spool locally and retry later.
264
278
 
265
- ### Create approval
279
+ ### Runtime approvals
266
280
 
267
- ```http
268
- POST /api/v1/approvals
269
- Content-Type: application/json
270
- X-API-Key: ag_live_xxxxx
271
- ```
281
+ There is no Cloud approval inbox in the current native runtime flow. Native
282
+ clients must not tell users to approve protected runtime actions in Cloud.
272
283
 
273
- Request:
284
+ When a decision returns `require_approval`:
274
285
 
275
- ```json
276
- {
277
- "actionId": "act_local_123",
278
- "sessionId": "sess_local_123",
279
- "agentHost": "claude-code",
280
- "actionType": "file_read",
281
- "toolName": "Read",
282
- "input": "~/.ssh/id_rsa",
283
- "riskScore": 55,
284
- "riskLevel": "high",
285
- "reasons": [],
286
- "policyVersion": "runtime-v0.1",
287
- "cwd": "/workspace/app",
288
- "sourceSkill": "optional-skill-id",
289
- "metadata": {
290
- "evaluation": "local-oss"
291
- }
292
- }
293
- ```
294
-
295
- Response:
296
-
297
- ```json
298
- {
299
- "success": true,
300
- "data": {
301
- "approvalId": "apr_abc123",
302
- "actionId": "act_local_123",
303
- "sessionId": "sess_local_123",
304
- "status": "pending"
305
- }
306
- }
307
- ```
308
-
309
- Native behavior:
310
-
311
- - Create this only after local or Cloud decision returns `require_approval`.
312
- - Block the action while approval is pending.
313
- - Show the approval id to the user when available.
314
-
315
- ### List approvals
316
-
317
- ```http
318
- GET /api/v1/approvals?status=pending
319
- X-API-Key: ag_live_xxxxx
320
- ```
321
-
322
- Response:
323
-
324
- ```json
325
- {
326
- "success": true,
327
- "data": {
328
- "approvals": [
329
- {
330
- "approvalId": "apr_abc123",
331
- "actionId": "act_local_123",
332
- "sessionId": "sess_local_123",
333
- "agentHost": "claude-code",
334
- "actionType": "file_read",
335
- "toolName": "Read",
336
- "inputPreview": "~/.ssh/id_rsa",
337
- "status": "pending",
338
- "riskScore": 55,
339
- "riskLevel": "high",
340
- "reasons": [],
341
- "policyVersion": "runtime-v0.1",
342
- "createdAt": "2026-05-11T00:00:00.000Z"
343
- }
344
- ]
345
- }
346
- }
347
- ```
348
-
349
- Native usage: optional inbox UI or debugging command.
350
-
351
- ### Review approval
352
-
353
- ```http
354
- PATCH /api/v1/approvals/:approvalId
355
- Content-Type: application/json
356
- X-API-Key: ag_live_xxxxx
357
- ```
358
-
359
- Request:
360
-
361
- ```json
362
- {
363
- "status": "approved",
364
- "note": "Expected deploy"
365
- }
366
- ```
367
-
368
- `status` must be either `approved` or `denied`.
369
-
370
- Response:
371
-
372
- ```json
373
- {
374
- "success": true,
375
- "data": {
376
- "approvalId": "apr_abc123",
377
- "actionId": "act_local_123",
378
- "sessionId": "sess_local_123",
379
- "status": "approved"
380
- }
381
- }
382
- ```
286
+ - Claude Code should surface the native `PreToolUse` `ask` response.
287
+ - Codex-style hosts should surface the local `confirm` response.
288
+ - OpenClaw currently blocks locally because the runtime hook cannot safely pause
289
+ and resume the original tool call after an external review.
383
290
 
384
- Native usage: optional reviewer UX. Most local hooks should simply block and ask the user to review in Cloud.
291
+ Cloud may still provide policy and session timeline visibility, but approval or
292
+ confirmation must happen in the local agent host.
385
293
 
386
294
  ### Session timeline
387
295
 
package/docs/codex.md CHANGED
@@ -35,4 +35,16 @@ Use these mappings for Codex-style hooks or skills:
35
35
  - browser/network fetches → `network`
36
36
  - MCP tool calls → `mcp_tool`
37
37
 
38
- When Cloud is connected, Codex events are synced as redacted previews and can participate in Cloud approvals.
38
+ When Cloud is connected, Codex events are synced as redacted previews. Confirmation still happens through the local agent permission flow, not a Cloud approval page.
39
+
40
+ If a protected action returns `confirm`, AgentGuard stores a short-lived pending
41
+ approval and includes an approval command:
42
+
43
+ ```bash
44
+ agentguard approve --action-id act_local_... --once
45
+ ```
46
+
47
+ Run that command only after the user explicitly approves, then retry the
48
+ original action once. If the action id was not visible, inspect
49
+ `agentguard approvals list --json`; use `agentguard approve --last --once`
50
+ only when there is exactly one relevant unexpired pending approval.
package/docs/openclaw.md CHANGED
@@ -10,7 +10,7 @@ To install and enable the AgentGuard OpenClaw plugin:
10
10
  agentguard init --agent openclaw
11
11
  ```
12
12
 
13
- This creates a local plugin under `~/.openclaw/plugins/agentguard` and enables it in `~/.openclaw/openclaw.json`.
13
+ This creates a local plugin under `~/.openclaw/plugins/agentguard`, installs the AgentGuard skill under `~/.openclaw/skills/agentguard`, and enables the plugin in `~/.openclaw/openclaw.json`.
14
14
 
15
15
  ```ts
16
16
  import { registerOpenClawPlugin } from '@goplus/agentguard';
@@ -23,6 +23,18 @@ export default function setup(api) {
23
23
  }
24
24
  ```
25
25
 
26
+ ## Cloud connect
27
+
28
+ After OpenClaw initialization, run:
29
+
30
+ ```bash
31
+ agentguard connect
32
+ ```
33
+
34
+ No API key is required for the OpenClaw flow. AgentGuard registers a local Agent
35
+ JWT, prints an activation link, and may send the link to the latest OpenClaw
36
+ channel. Open that link to bind the local agent to your account.
37
+
26
38
  ## Runtime hook shape
27
39
 
28
40
  For direct hook integration, send events to:
@@ -36,6 +48,25 @@ agentguard protect
36
48
 
37
49
  AgentGuard accepts OpenClaw-style JSON with `toolName` and `params`, plus Claude-style `tool_name` and `tool_input`.
38
50
 
51
+ OpenClaw cannot safely pause and resume a protected tool call, so AgentGuard
52
+ blocks `require_approval` actions locally and stores a short-lived pending
53
+ approval. The block reason includes:
54
+
55
+ ```bash
56
+ agentguard approve --action-id act_local_... --once
57
+ ```
58
+
59
+ Run that command only after the user explicitly approves, then retry the
60
+ original action once. If the action id was not visible in the OpenClaw message,
61
+ inspect pending approvals first:
62
+
63
+ ```bash
64
+ agentguard approvals list --json
65
+ ```
66
+
67
+ Use `agentguard approve --last --once` only when there is exactly one relevant
68
+ unexpired pending approval; otherwise approve the specific `actionId`.
69
+
39
70
  ## Docker demo
40
71
 
41
72
  See `examples/openclaw-docker/` for a minimal Docker demo that installs `@goplus/agentguard`, runs `agentguard init --agent openclaw`, and provides a starter plugin.
@@ -18,7 +18,6 @@ Only redacted runtime audit previews are uploaded by default:
18
18
  - `sessionId`, `agentHost`, `actionType`, `toolName`
19
19
  - Redacted `input` preview, capped at 2,000 characters
20
20
  - Decision, risk score, risk level, reasons, and policy version
21
- - Optional approval request metadata for `require_approval`
22
21
 
23
22
  ## Built-in redaction
24
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goplus/agentguard",
3
- "version": "1.1.20",
3
+ "version": "1.1.26",
4
4
  "description": "GoPlus AgentGuard — Security guard for AI agents. Blocks dangerous commands, prevents data leaks, protects secrets. 20 detection rules, runtime action evaluation, trust registry.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -103,6 +103,8 @@ Supported CLI commands and options:
103
103
  | `agentguard status` | none | Shows local config, active Cloud auth method, policy cache, audit path |
104
104
  | `agentguard policy pull` | `--json` | Pulls Cloud effective runtime policy into the local cache |
105
105
  | `agentguard policy show` | `--json` | Shows the cached effective runtime policy, or the bundled default policy when no cache exists |
106
+ | `agentguard approve` | `--action-id <id>` or `--last`, `--once`, `--json` | Approves one existing pending runtime action; never approve without explicit user confirmation |
107
+ | `agentguard approvals list` | `--json` | Lists unexpired pending runtime approvals |
106
108
  | `agentguard doctor` | none | Checks local setup and Cloud reachability when connected |
107
109
  | `agentguard protect` | `--agent <agent>`, `--action-type <type>`, `--tool-name <name>`, `--session-id <id>`, `--decision-mode <local-first|cloud>`, `--json` | Evaluates one runtime action from stdin or hook environment |
108
110
  | `agentguard subscribe` | `--since <iso>`, `--json`, `--quiet`, `--no-report`, `--cron <expr>`, `--cron-target <auto|openclaw|qclaw|hermes|system>`, `--cron-name <name>`, `--force`, `--cron-run`, `--cron-notify-run` | Pulls Cloud threat advisories and optionally self-checks local skills |
@@ -117,6 +119,8 @@ Connect behavior:
117
119
 
118
120
  If the user writes `/agentguard cli <args...>`, execute `agentguard <args...>` directly.
119
121
 
122
+ When AgentGuard returns `confirm` or a block reason that includes `Approve once: agentguard approve --action-id ... --once`, do not retry the protected action until the user explicitly approves. Treat user replies such as "yes", "approve", "approved", "confirm", "confirmed", "continue", "go ahead", "execute", "run it", "同意", "确认", "批准", "继续", or "执行" as explicit approval for the most recent protected action. After approval, run exactly the provided `agentguard approve --action-id ... --once` command, then retry the original action once. If the action id is unavailable, use `agentguard approvals list --json`; only use `agentguard approve --last --once` when there is exactly one relevant unexpired pending approval. If multiple pending approvals exist, ask the user to choose a specific action id.
123
+
120
124
  Do **not** route plain `/agentguard scan`, `/agentguard action`, `/agentguard patrol`, `/agentguard trust`, `/agentguard report`, `/agentguard config`, `/agentguard checkup`, `/agentguard checkup --json`, or natural-language requests like "run agentguard checkup" through the packaged CLI. Those are this skill's higher-level workflows. Only use the packaged CLI checkup path when the user includes `--against-advisory <id>` or explicitly writes `/agentguard cli checkup ...`.
121
125
 
122
126
  If the user writes `/agentguard checkup --against-advisory <id>`, use the CLI command `agentguard checkup --against-advisory <id>` instead of the comprehensive HTML health-report workflow.