@aporthq/aport-agent-guardrails 1.0.8

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 (237) hide show
  1. package/LICENSE +217 -0
  2. package/README.md +481 -0
  3. package/bin/agent-guardrails +133 -0
  4. package/bin/aport-create-passport.sh +444 -0
  5. package/bin/aport-cursor-hook.sh +90 -0
  6. package/bin/aport-guardrail-api.sh +108 -0
  7. package/bin/aport-guardrail-bash.sh +394 -0
  8. package/bin/aport-guardrail-v2.sh +5 -0
  9. package/bin/aport-guardrail.sh +5 -0
  10. package/bin/aport-resolve-paths.sh +71 -0
  11. package/bin/aport-status.sh +276 -0
  12. package/bin/frameworks/crewai.sh +49 -0
  13. package/bin/frameworks/cursor.sh +95 -0
  14. package/bin/frameworks/langchain.sh +48 -0
  15. package/bin/frameworks/n8n.sh +36 -0
  16. package/bin/frameworks/openclaw.sh +19 -0
  17. package/bin/lib/allowlist.sh +18 -0
  18. package/bin/lib/common.sh +28 -0
  19. package/bin/lib/config.sh +46 -0
  20. package/bin/lib/constants.sh +232 -0
  21. package/bin/lib/detect.sh +65 -0
  22. package/bin/lib/error.sh +269 -0
  23. package/bin/lib/passport.sh +19 -0
  24. package/bin/lib/templates/.gitkeep +1 -0
  25. package/bin/lib/templates/config.yaml +6 -0
  26. package/bin/lib/validation.sh +206 -0
  27. package/bin/openclaw +660 -0
  28. package/docs/ADDING_A_FRAMEWORK.md +87 -0
  29. package/docs/AGENTS.md.example +40 -0
  30. package/docs/CODE_REVIEW.md +192 -0
  31. package/docs/DEPLOYMENT_READINESS.md +81 -0
  32. package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
  33. package/docs/FRAMEWORK_ROADMAP.md +41 -0
  34. package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
  35. package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
  36. package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
  37. package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
  38. package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
  39. package/docs/QUICKSTART.md +470 -0
  40. package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
  41. package/docs/README.md +28 -0
  42. package/docs/RELEASE.md +87 -0
  43. package/docs/REPO_LAYOUT.md +47 -0
  44. package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
  45. package/docs/TOOL_POLICY_MAPPING.md +46 -0
  46. package/docs/UPGRADE.md +46 -0
  47. package/docs/VERIFICATION_METHODS.md +97 -0
  48. package/docs/assets/README.md +8 -0
  49. package/docs/assets/porter.svg +54 -0
  50. package/docs/development/ERROR_CODES.md +616 -0
  51. package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
  52. package/docs/frameworks/crewai.md +114 -0
  53. package/docs/frameworks/cursor.md +159 -0
  54. package/docs/frameworks/langchain.md +72 -0
  55. package/docs/frameworks/n8n.md +40 -0
  56. package/docs/frameworks/openclaw.md +40 -0
  57. package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
  58. package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
  59. package/docs/launch/AWESOME_REPOS.md +53 -0
  60. package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
  61. package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
  62. package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
  63. package/docs/launch/EVIDENCE_README.md +61 -0
  64. package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
  65. package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
  66. package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
  67. package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
  68. package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
  69. package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
  70. package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
  71. package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
  72. package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
  73. package/docs/launch/READINESS_SUMMARY.md +262 -0
  74. package/docs/launch/README.md +68 -0
  75. package/docs/launch/USER_STORIES.md +327 -0
  76. package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
  77. package/docs/operations/MONITORING.md +588 -0
  78. package/docs/reviews/2026-02-18-staff-review.md +268 -0
  79. package/extensions/openclaw-aport/README.md +415 -0
  80. package/extensions/openclaw-aport/index.js +625 -0
  81. package/extensions/openclaw-aport/openclaw-aport.js +7 -0
  82. package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
  83. package/extensions/openclaw-aport/package.json +36 -0
  84. package/extensions/openclaw-aport/test.js +307 -0
  85. package/external/aport-policies/README.md +363 -0
  86. package/external/aport-policies/agent.session.create.v1/README.md +345 -0
  87. package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
  88. package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
  89. package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
  90. package/external/aport-policies/code.release.publish.v1/README.md +51 -0
  91. package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
  92. package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
  93. package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
  94. package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
  95. package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
  96. package/external/aport-policies/data.export.create.v1/README.md +226 -0
  97. package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
  98. package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
  99. package/external/aport-policies/data.export.create.v1/policy.json +133 -0
  100. package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
  101. package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
  102. package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
  103. package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
  104. package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
  105. package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
  106. package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
  107. package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
  108. package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
  109. package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
  110. package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
  111. package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
  112. package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
  113. package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
  114. package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
  115. package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
  116. package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
  117. package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
  118. package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
  119. package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
  120. package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
  121. package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
  122. package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
  123. package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
  124. package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
  125. package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
  126. package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
  127. package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
  128. package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
  129. package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
  130. package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
  131. package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
  132. package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
  133. package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
  134. package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
  135. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
  136. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
  137. package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
  138. package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
  139. package/external/aport-policies/governance.data.access.v1/README.md +292 -0
  140. package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
  141. package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
  142. package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
  143. package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
  144. package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
  145. package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
  146. package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
  147. package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
  148. package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
  149. package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
  150. package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
  151. package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
  152. package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
  153. package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
  154. package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
  155. package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
  156. package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
  157. package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
  158. package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
  159. package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
  160. package/external/aport-policies/policy-template.json +107 -0
  161. package/external/aport-policies/system.command.execute.v1/README.md +275 -0
  162. package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
  163. package/external/aport-spec/CONTRIBUTING.md +273 -0
  164. package/external/aport-spec/LICENSE +21 -0
  165. package/external/aport-spec/README.md +168 -0
  166. package/external/aport-spec/conformance/README.md +294 -0
  167. package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
  168. package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
  169. package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
  170. package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
  171. package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
  172. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
  173. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
  174. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
  175. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
  176. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
  177. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
  178. package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
  179. package/external/aport-spec/conformance/package.json +44 -0
  180. package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
  181. package/external/aport-spec/conformance/src/cases.ts +371 -0
  182. package/external/aport-spec/conformance/src/ed25519.ts +167 -0
  183. package/external/aport-spec/conformance/src/jcs.ts +85 -0
  184. package/external/aport-spec/conformance/src/runner.ts +533 -0
  185. package/external/aport-spec/conformance/src/validators.ts +185 -0
  186. package/external/aport-spec/conformance/test-runner.js +315 -0
  187. package/external/aport-spec/conformance/tsconfig.json +21 -0
  188. package/external/aport-spec/error-schema.json +192 -0
  189. package/external/aport-spec/index.json +12 -0
  190. package/external/aport-spec/integrations/clawmoat/README.md +12 -0
  191. package/external/aport-spec/integrations/shield/README.md +245 -0
  192. package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
  193. package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
  194. package/external/aport-spec/integrations/shield/test/README.md +58 -0
  195. package/external/aport-spec/integrations/shield/test/shield.md +40 -0
  196. package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
  197. package/external/aport-spec/metrics-schema.json +504 -0
  198. package/external/aport-spec/oap/CHANGELOG.md +54 -0
  199. package/external/aport-spec/oap/VERSION.md +40 -0
  200. package/external/aport-spec/oap/capability-registry.md +229 -0
  201. package/external/aport-spec/oap/conformance.md +257 -0
  202. package/external/aport-spec/oap/decision-schema.json +114 -0
  203. package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
  204. package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
  205. package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
  206. package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
  207. package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
  208. package/external/aport-spec/oap/oap-spec.md +426 -0
  209. package/external/aport-spec/oap/passport-schema.json +396 -0
  210. package/external/aport-spec/oap/security.md +213 -0
  211. package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
  212. package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
  213. package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
  214. package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
  215. package/external/aport-spec/oap/vc/tools/README.md +278 -0
  216. package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
  217. package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
  218. package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
  219. package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
  220. package/external/aport-spec/oap/vc/tools/package.json +38 -0
  221. package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
  222. package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
  223. package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
  224. package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
  225. package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
  226. package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
  227. package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
  228. package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
  229. package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
  230. package/external/aport-spec/passport-schema.json +586 -0
  231. package/external/aport-spec/rate-limiting.md +136 -0
  232. package/external/aport-spec/transport-profile.md +325 -0
  233. package/external/aport-spec/webhook-spec.md +314 -0
  234. package/package.json +70 -0
  235. package/skills/aport-agent-guardrail/SKILL.md +314 -0
  236. package/src/evaluator.js +252 -0
  237. package/src/server/index.js +72 -0
@@ -0,0 +1,314 @@
1
+ # Webhook Specification
2
+
3
+ ## Overview
4
+
5
+ The Open Agent Passport (OAP) webhook system provides real-time notifications for agent passport events. This specification defines the webhook payload format, delivery mechanisms, and security requirements.
6
+
7
+ ## Webhook Events
8
+
9
+ ### Supported Events
10
+
11
+ | Event | Description | Trigger |
12
+ |-------|-------------|---------|
13
+ | `passport.created` | Agent passport created | New passport registration |
14
+ | `passport.updated` | Agent passport updated | Passport data changes |
15
+ | `passport.suspended` | Agent passport suspended | Status change to suspended |
16
+ | `passport.revoked` | Agent passport revoked | Status change to revoked |
17
+ | `passport.activated` | Agent passport activated | Status change to active |
18
+ | `decision.created` | Policy decision created | New authorization decision |
19
+ | `decision.updated` | Policy decision updated | Decision modification |
20
+
21
+ ### Event Payload Structure
22
+
23
+ All webhook events follow this base structure:
24
+
25
+ ```json
26
+ {
27
+ "id": "evt_1234567890",
28
+ "type": "passport.created",
29
+ "created_at": "2025-01-16T10:30:00Z",
30
+ "data": {
31
+ // Event-specific data
32
+ },
33
+ "api_version": "2025-01-16",
34
+ "livemode": true
35
+ }
36
+ ```
37
+
38
+ ## Event Payloads
39
+
40
+ ### Passport Events
41
+
42
+ #### passport.created
43
+
44
+ ```json
45
+ {
46
+ "id": "evt_1234567890",
47
+ "type": "passport.created",
48
+ "created_at": "2025-01-16T10:30:00Z",
49
+ "data": {
50
+ "object": "passport",
51
+ "agent_id": "ap_a2d10232c6534523812423eec8a1425c",
52
+ "owner_id": "ap_org_456",
53
+ "name": "Acme Support Bot",
54
+ "status": "active",
55
+ "capabilities": [
56
+ {
57
+ "id": "finance.payment.refund",
58
+ "params": {"max_amount": 5000}
59
+ }
60
+ ],
61
+ "assurance_level": "L4KYC",
62
+ "created_at": "2025-01-16T10:30:00Z"
63
+ },
64
+ "api_version": "2025-01-16",
65
+ "livemode": true
66
+ }
67
+ ```
68
+
69
+ #### passport.updated
70
+
71
+ ```json
72
+ {
73
+ "id": "evt_1234567891",
74
+ "type": "passport.updated",
75
+ "created_at": "2025-01-16T10:35:00Z",
76
+ "data": {
77
+ "object": "passport",
78
+ "agent_id": "ap_a2d10232c6534523812423eec8a1425c",
79
+ "changes": [
80
+ {
81
+ "field": "capabilities",
82
+ "old_value": [{"id": "finance.payment.refund", "params": {"max_amount": 5000}}],
83
+ "new_value": [{"id": "finance.payment.refund", "params": {"max_amount": 10000}}]
84
+ }
85
+ ],
86
+ "updated_at": "2025-01-16T10:35:00Z"
87
+ },
88
+ "api_version": "2025-01-16",
89
+ "livemode": true
90
+ }
91
+ ```
92
+
93
+ #### passport.suspended
94
+
95
+ ```json
96
+ {
97
+ "id": "evt_1234567892",
98
+ "type": "passport.suspended",
99
+ "created_at": "2025-01-16T10:40:00Z",
100
+ "data": {
101
+ "object": "passport",
102
+ "agent_id": "ap_a2d10232c6534523812423eec8a1425c",
103
+ "reason": "Policy violation detected",
104
+ "suspended_at": "2025-01-16T10:40:00Z",
105
+ "suspended_by": "ap_user_789"
106
+ },
107
+ "api_version": "2025-01-16",
108
+ "livemode": true
109
+ }
110
+ ```
111
+
112
+ ### Decision Events
113
+
114
+ #### decision.created
115
+
116
+ ```json
117
+ {
118
+ "id": "evt_1234567893",
119
+ "type": "decision.created",
120
+ "created_at": "2025-01-16T10:45:00Z",
121
+ "data": {
122
+ "object": "decision",
123
+ "decision_id": "dec_123456789",
124
+ "agent_id": "ap_a2d10232c6534523812423eec8a1425c",
125
+ "policy_id": "finance.payment.refund.v1",
126
+ "allow": true,
127
+ "reasons": [
128
+ {
129
+ "code": "capability_verified",
130
+ "message": "Agent has required refund capability",
131
+ "severity": "info"
132
+ }
133
+ ],
134
+ "expires_in": 300,
135
+ "context": {
136
+ "amount": 5000,
137
+ "currency": "USD",
138
+ "transaction_id": "txn_123456"
139
+ }
140
+ },
141
+ "api_version": "2025-01-16",
142
+ "livemode": true
143
+ }
144
+ ```
145
+
146
+ ## Webhook Security
147
+
148
+ ### Signature Verification
149
+
150
+ All webhooks include a signature header for verification:
151
+
152
+ ```
153
+ X-APort-Signature: t=1640995200,v1=abc123def456...
154
+ ```
155
+
156
+ ### Signature Format
157
+
158
+ ```
159
+ X-APort-Signature: t={timestamp},v1={signature}
160
+ ```
161
+
162
+ - **t**: Unix timestamp of the webhook
163
+ - **v1**: HMAC-SHA256 signature of the payload
164
+
165
+ ### Signature Generation
166
+
167
+ ```javascript
168
+ const crypto = require('crypto');
169
+
170
+ function generateSignature(payload, secret, timestamp) {
171
+ const payloadString = JSON.stringify(payload);
172
+ const signedPayload = `${timestamp}.${payloadString}`;
173
+ const signature = crypto
174
+ .createHmac('sha256', secret)
175
+ .update(signedPayload)
176
+ .digest('hex');
177
+ return `t=${timestamp},v1=${signature}`;
178
+ }
179
+ ```
180
+
181
+ ### Signature Verification
182
+
183
+ ```javascript
184
+ function verifySignature(payload, signature, secret) {
185
+ const [timestamp, signatureValue] = signature.split(',');
186
+ const t = timestamp.split('=')[1];
187
+ const v1 = signatureValue.split('=')[1];
188
+
189
+ const expectedSignature = generateSignature(payload, secret, t);
190
+ return expectedSignature === signature;
191
+ }
192
+ ```
193
+
194
+ ## Webhook Delivery
195
+
196
+ ### Delivery Attempts
197
+
198
+ - **Initial Attempt**: Immediate delivery
199
+ - **Retry Attempts**: 3 retries with exponential backoff
200
+ - **Retry Intervals**: 1s, 5s, 30s, 5m, 30m, 2h, 6h, 12h
201
+ - **Timeout**: 30 seconds per attempt
202
+
203
+ ### Delivery Status
204
+
205
+ | Status | Description |
206
+ |--------|-------------|
207
+ | `pending` | Webhook queued for delivery |
208
+ | `delivered` | Successfully delivered |
209
+ | `failed` | All retry attempts failed |
210
+ | `retrying` | Currently retrying delivery |
211
+
212
+ ### Response Requirements
213
+
214
+ Webhook endpoints must:
215
+
216
+ 1. **Return 200 OK** for successful processing
217
+ 2. **Process within 30 seconds** to avoid timeout
218
+ 3. **Handle duplicate events** idempotently
219
+ 4. **Log delivery attempts** for debugging
220
+
221
+ ## Webhook Configuration
222
+
223
+ ### Endpoint Registration
224
+
225
+ ```json
226
+ {
227
+ "url": "https://example.com/webhooks/aport",
228
+ "events": ["passport.created", "passport.updated"],
229
+ "secret": "whsec_1234567890",
230
+ "active": true,
231
+ "created_at": "2025-01-16T10:00:00Z"
232
+ }
233
+ ```
234
+
235
+ ### Event Filtering
236
+
237
+ Webhooks can be configured to receive specific events:
238
+
239
+ ```json
240
+ {
241
+ "events": [
242
+ "passport.created",
243
+ "passport.suspended",
244
+ "passport.revoked",
245
+ "decision.created"
246
+ ]
247
+ }
248
+ ```
249
+
250
+ ## Error Handling
251
+
252
+ ### Webhook Failures
253
+
254
+ When webhook delivery fails:
255
+
256
+ 1. **Log Error**: Record failure reason and timestamp
257
+ 2. **Retry Logic**: Attempt delivery with exponential backoff
258
+ 3. **Dead Letter Queue**: Store failed webhooks for manual review
259
+ 4. **Alerting**: Notify administrators of persistent failures
260
+
261
+ ### Common Error Scenarios
262
+
263
+ | Error | Cause | Resolution |
264
+ |-------|-------|------------|
265
+ | `timeout` | Endpoint too slow | Optimize endpoint performance |
266
+ | `connection_refused` | Endpoint unavailable | Check endpoint availability |
267
+ | `invalid_response` | Non-200 status | Fix endpoint response handling |
268
+ | `signature_mismatch` | Invalid signature | Verify signature calculation |
269
+
270
+ ## Testing
271
+
272
+ ### Webhook Testing
273
+
274
+ Use the webhook testing endpoint:
275
+
276
+ ```bash
277
+ curl -X POST https://api.aport.io/webhooks/test \
278
+ -H "Authorization: Bearer sk_test_..." \
279
+ -H "Content-Type: application/json" \
280
+ -d '{
281
+ "url": "https://example.com/webhooks/test",
282
+ "events": ["passport.created"]
283
+ }'
284
+ ```
285
+
286
+ ### Test Events
287
+
288
+ Test events are prefixed with `test.`:
289
+
290
+ - `test.passport.created`
291
+ - `test.decision.created`
292
+
293
+ ## Best Practices
294
+
295
+ ### Endpoint Implementation
296
+
297
+ 1. **Idempotency**: Handle duplicate events gracefully
298
+ 2. **Async Processing**: Process webhooks asynchronously
299
+ 3. **Error Handling**: Implement proper error handling
300
+ 4. **Logging**: Log all webhook processing attempts
301
+
302
+ ### Security
303
+
304
+ 1. **HTTPS Only**: Always use HTTPS endpoints
305
+ 2. **Signature Verification**: Always verify webhook signatures
306
+ 3. **Secret Management**: Store webhook secrets securely
307
+ 4. **Rate Limiting**: Implement rate limiting on webhook endpoints
308
+
309
+ ### Monitoring
310
+
311
+ 1. **Delivery Metrics**: Track webhook delivery success rates
312
+ 2. **Performance Monitoring**: Monitor endpoint response times
313
+ 3. **Error Tracking**: Track and alert on webhook failures
314
+ 4. **Audit Logging**: Log all webhook processing activities
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@aporthq/aport-agent-guardrails",
3
+ "version": "1.0.8",
4
+ "description": "Policy enforcement guardrails for OpenClaw-compatible agent frameworks",
5
+ "workspaces": [
6
+ "packages/*"
7
+ ],
8
+ "bin": {
9
+ "agent-guardrails": "bin/agent-guardrails",
10
+ "aport": "bin/openclaw",
11
+ "aport-guardrail": "bin/aport-guardrail.sh"
12
+ },
13
+ "scripts": {
14
+ "test": "make test",
15
+ "install": "([ -f Makefile ] && make install) || true",
16
+ "server": "node src/server/index.js",
17
+ "dev": "node --watch src/server/index.js",
18
+ "sync-submodules": "git submodule update --init --recursive",
19
+ "sync-submodules:latest": "git submodule update --init --remote --recursive",
20
+ "changeset": "changeset",
21
+ "version": "changeset version && node scripts/sync-version.mjs",
22
+ "sync-version": "node scripts/sync-version.mjs",
23
+ "build": "npm run build --workspaces --if-present",
24
+ "build:core": "npm run build -w @aporthq/aport-agent-guardrails-core",
25
+ "release:version": "npm run version",
26
+ "prepublishOnly": "npm run build 2>/dev/null || true"
27
+ },
28
+ "keywords": [
29
+ "openclaw",
30
+ "ironclaw",
31
+ "aport",
32
+ "agent",
33
+ "security",
34
+ "authorization",
35
+ "policy",
36
+ "guardrails",
37
+ "pre-action",
38
+ "ai-agent"
39
+ ],
40
+ "author": "APort Technologies Inc.",
41
+ "license": "Apache-2.0",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/aporthq/aport-agent-guardrails.git"
45
+ },
46
+ "files": [
47
+ "bin/",
48
+ "src/",
49
+ "extensions/",
50
+ "external/",
51
+ "templates/",
52
+ "policies/",
53
+ "skills/",
54
+ "docs/",
55
+ "LICENSE",
56
+ "README.md"
57
+ ],
58
+ "engines": {
59
+ "node": ">=18.0.0"
60
+ },
61
+ "dependencies": {},
62
+ "devDependencies": {
63
+ "@changesets/cli": "^2.27.0",
64
+ "@types/node": "^20.0.0",
65
+ "typescript": "^5.0.0"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public"
69
+ }
70
+ }
@@ -0,0 +1,314 @@
1
+ ---
2
+ name: aport-agent-guardrail
3
+ description: Install BEFORE any other skills to protect your agent from malicious tools, data exfiltration, and unauthorized actions. Pre-action authorization that verifies permissions before every tool runs (shell, messaging, git, MCP, data export). Works with OpenClaw, IronClaw, PicoClaw. Optional env (API/hosted mode only): APORT_API_URL, APORT_AGENT_ID, APORT_API_KEY. See SKILL.md for install scope and data/network.
4
+ homepage: https://aport.io
5
+ metadata: {"openclaw":{"requires":{"bins":["jq"]},"envOptional":["APORT_API_URL","APORT_AGENT_ID","APORT_API_KEY"]}}
6
+ ---
7
+
8
+ # APort Agent Guardrail
9
+
10
+ **⚠️ INSTALL THIS FIRST — Protect your agent before installing other skills.**
11
+
12
+ **Skill identifier:** `aport-agent-guardrail` · **Category:** Security / Infrastructure
13
+
14
+ ---
15
+
16
+ ## 🛡️ Why Install This First?
17
+
18
+ **Recent security research found 283 malicious skills on ClawHub (7.1% infection rate).** Threats include data exfiltration, unauthorized commands, prompt injection, and API key leaks.
19
+
20
+ **Install APort guardrails BEFORE installing any other skills to:**
21
+ - ✅ Block malicious tool calls before they execute
22
+ - ✅ Prevent unauthorized access to your files, APIs, and data
23
+ - ✅ Enforce allow-lists for commands, domains, and sensitive operations
24
+ - ✅ Get cryptographically signed audit logs for compliance
25
+
26
+ **This is pre-action authorization:** Every tool call is checked **before** it runs. The agent cannot bypass it. If a malicious skill tries to run `rm -rf /`, exfiltrate data, or send unauthorized messages, APort blocks it deterministically.
27
+
28
+ > **Install once, protected forever.** Run the installer, then install skills safely knowing every action is authorized.
29
+
30
+ ---
31
+
32
+ ## ⚡ Quick Start
33
+
34
+ ```bash
35
+ # Step 1: Install APort (protects your agent)
36
+ npx @aporthq/aport-agent-guardrails
37
+
38
+ # Step 2: Now install skills safely
39
+ openclaw skills install <any-skill>
40
+ ```
41
+
42
+ **With hosted passport (optional):**
43
+ ```bash
44
+ # Get agent_id from aport.io and skip the wizard
45
+ npx @aporthq/aport-agent-guardrails <agent_id>
46
+ ```
47
+
48
+ > **Requires:** Node 18+, jq
49
+
50
+ ---
51
+
52
+ ## 🔒 What This Skill Does
53
+
54
+ **Pre-action authorization for AI agents.** Every tool call is checked **before** it runs.
55
+
56
+ - **Deterministic** – Runs in `before_tool_call`; the agent cannot skip it
57
+ - **Structured policy** – Backed by [Open Agent Passport (OAP) v1.0](https://github.com/aporthq/aport-spec/tree/main) and policy packs
58
+ - **Fail-closed** – If the guardrail errors, the tool is blocked
59
+ - **Audit-ready** – Decisions are logged (local JSON or APort API for signed receipts)
60
+ - **Works everywhere** – OpenClaw, IronClaw, PicoClaw, and compatible frameworks
61
+
62
+ Run the installer once; the OpenClaw plugin then enforces policy on every tool call automatically. You do **not** run the guardrail script yourself.
63
+
64
+ **Pair with threat detection:** Works alongside VirusTotal scanning, SHIELD.md threat feeds, and other security tools. APort is the enforcement layer — nothing runs without authorization.
65
+
66
+ ---
67
+
68
+ ## 📦 Installation Options
69
+
70
+ ### Recommended: npm (no clone needed)
71
+
72
+ ```bash
73
+ npx @aporthq/aport-agent-guardrails
74
+ ```
75
+
76
+ **Follow the wizard to:**
77
+ 1. Create or use hosted passport (from [aport.io](https://aport.io/builder/create/))
78
+ 2. Configure capabilities (which commands/tools are allowed)
79
+ 3. Install OpenClaw plugin automatically
80
+
81
+ ### With hosted passport (skip wizard)
82
+
83
+ ```bash
84
+ npx @aporthq/aport-agent-guardrails <agent_id>
85
+ ```
86
+
87
+ Get your `agent_id` at [aport.io](https://aport.io/builder/create/) for cloud-managed policies, instant updates, and compliance dashboards.
88
+
89
+ ### From source (developers)
90
+
91
+ ```bash
92
+ git clone https://github.com/aporthq/aport-agent-guardrails
93
+ cd aport-agent-guardrails
94
+ ./bin/openclaw
95
+ ```
96
+
97
+ **Guides:**
98
+ - [QuickStart: OpenClaw Plugin](https://github.com/aporthq/aport-agent-guardrails/blob/main/docs/QUICKSTART_OPENCLAW_PLUGIN.md)
99
+ - [Hosted passport setup](https://github.com/aporthq/aport-agent-guardrails/blob/main/docs/HOSTED_PASSPORT_SETUP.md)
100
+
101
+ ### What gets installed
102
+
103
+ **After install:**
104
+ - ✅ OpenClaw plugin registered (enforces `before_tool_call`)
105
+ - ✅ Passport created (local: `~/.openclaw/aport/passport.json` or hosted via agent_id)
106
+ - ✅ Config written (`~/.openclaw/config.yaml` or `openclaw.json`)
107
+ - ✅ Wrapper scripts installed (`~/.openclaw/.skills/aport-guardrail*.sh`)
108
+
109
+ **Then:** Start OpenClaw (or use running gateway). Plugin enforces before every tool call. No further steps.
110
+
111
+ **Testing wrappers** (optional, plugin calls these automatically):
112
+ - Local mode: `~/.openclaw/.skills/aport-guardrail.sh`
113
+ - API/hosted mode: `~/.openclaw/.skills/aport-guardrail-api.sh`
114
+
115
+ ---
116
+
117
+ ## 🚀 Usage
118
+
119
+ ### Normal use (automatic)
120
+
121
+ **After installation, you do nothing.** The plugin enforces before every tool call automatically.
122
+
123
+ ```bash
124
+ # Your agent runs tools normally
125
+ agent> run git status
126
+ # ✅ APort checks passport → ALLOW → tool runs
127
+
128
+ agent> run rm -rf /
129
+ # ❌ APort checks passport → DENY → tool blocked
130
+ ```
131
+
132
+ ### Testing the guardrail (optional)
133
+
134
+ **Direct script calls for testing or custom automations:**
135
+
136
+ ```bash
137
+ # Test command execution
138
+ ~/.openclaw/.skills/aport-guardrail.sh system.command.execute '{"command":"ls"}'
139
+
140
+ # Test messaging
141
+ ~/.openclaw/.skills/aport-guardrail.sh messaging.message.send '{"channel":"whatsapp","to":"+15551234567"}'
142
+
143
+ # Test with API/hosted mode
144
+ APORT_API_URL=https://api.aport.io ~/.openclaw/.skills/aport-guardrail-api.sh system.command.execute '{"command":"ls"}'
145
+ ```
146
+
147
+ **Exit codes:**
148
+ - `0` = ALLOW (tool may proceed)
149
+ - `1` = DENY (reason codes in `<config-dir>/aport/decision.json`)
150
+
151
+ **Decision logs:**
152
+ - Local: `~/.openclaw/aport/decision.json`
153
+ - Audit trail: `~/.openclaw/aport/audit.log`
154
+ - API mode: Signed receipts via APort API
155
+
156
+ ---
157
+
158
+ ## 🔍 Before You Install (Transparency)
159
+
160
+ ### Remote code execution
161
+
162
+ **Installation runs code from npm or GitHub.**
163
+ - npm: [`@aporthq/aport-agent-guardrails`](https://www.npmjs.com/package/@aporthq/aport-agent-guardrails)
164
+ - GitHub: [aporthq/aport-agent-guardrails](https://github.com/aporthq/aport-agent-guardrails)
165
+
166
+ **Recommendation:** Inspect the installer or run in a test environment first. Code is open-source.
167
+
168
+ ### What gets written to disk
169
+
170
+ **Under config dir (default `~/.openclaw/`):**
171
+
172
+ **Installer writes:**
173
+ - `config.yaml` or `openclaw.json` — Plugin config (registered via `openclaw plugins install -l <path>`)
174
+ - `.aport-repo` — Repo/package root path
175
+ - `.skills/` — Wrapper scripts:
176
+ - `aport-guardrail.sh`, `aport-guardrail-bash.sh`, `aport-guardrail-api.sh`, `aport-guardrail-v2.sh`
177
+ - `aport-create-passport.sh`, `aport-status.sh`
178
+ - `aport/passport.json` — Only if local passport (wizard creates it)
179
+ - `skills/aport-agent-guardrail/SKILL.md` — Copy of this skill (managed)
180
+ - `workspace/AGENTS.md` — Appended with APort pre-action rule
181
+ - `logs/` — Only if installer starts gateway (e.g., `gateway.log`)
182
+
183
+ **Runtime writes (guardrail decisions):**
184
+ - `aport/decision.json` — Latest decision
185
+ - `aport/audit.log` — Audit trail
186
+ - Passport `status` field — Source of truth for suspended/revoked (no separate file)
187
+
188
+ **The plugin runs before every tool call.** Review the codebase for full transparency.
189
+
190
+ ### Network and data privacy
191
+
192
+ **Local mode (default):**
193
+ - ✅ No network calls
194
+ - ✅ Evaluation runs on your machine
195
+ - ✅ Passport and decisions stay local
196
+ - ✅ Full privacy
197
+
198
+ **API or hosted mode (optional):**
199
+ - 🌐 Tool name and context sent to `https://api.aport.io` (or your `APORT_API_URL`)
200
+ - 🌐 Hosted passport fetched from registry
201
+ - 🌐 Decision logs may be stored by APort (for compliance dashboards)
202
+ - **Use local mode for air-gapped operation.**
203
+
204
+ ### Credentials and environment variables
205
+
206
+ **No env vars required for basic operation.**
207
+
208
+ **Optional (API/hosted mode only):**
209
+ - `APORT_API_URL` — Override API endpoint (default: `https://api.aport.io`)
210
+ - `APORT_AGENT_ID` — Hosted passport ID (from aport.io)
211
+ - `APORT_API_KEY` — If your API requires auth (set in environment, not config)
212
+
213
+ **Pass `agent_id` to installer:** `npx @aporthq/aport-agent-guardrails <agent_id>` or use wizard.
214
+
215
+ ---
216
+
217
+ ## ⚠️ Why Security Scanners Flag This Skill
218
+
219
+ **APort is flagged as "suspicious" by automated scanners due to security infrastructure behaviors.**
220
+
221
+ **This is a FALSE POSITIVE.** Here's why:
222
+
223
+ ### What Gets Flagged
224
+
225
+ 1. **"Remote code execution"** — npm install runs setup code (standard npm pattern)
226
+ 2. **"System modifications"** — Writes to ~/.openclaw/ (standard OpenClaw plugin pattern)
227
+ 3. **"Network communication"** — API mode sends tool context (opt-in, documented, standard SaaS pattern)
228
+
229
+ ### Why This Is Safe
230
+
231
+ **Compare to other security tools:**
232
+ - **Antivirus:** Downloads virus definitions (remote code), hooks into OS (system mods), sends telemetry (network)
233
+ - **Firewall:** Installs kernel modules (system mods), updates rules (remote code), reports traffic (network)
234
+ - **Password manager:** Syncs vault (network), browser extension (system mods), auto-updates (remote code)
235
+
236
+ **APort is security infrastructure, not malware.**
237
+
238
+ ### Verification
239
+
240
+ - ✅ **Open-source:** Review code at [GitHub](https://github.com/aporthq/aport-agent-guardrails)
241
+ - ✅ **VirusTotal:** 0 detections ([scan results](https://www.virustotal.com/gui/file/0fe9918f47fc191d31dfe9a58faedca16e7cedbfef9271520d05feb711699c06))
242
+ - ✅ **npm integrity:** SHA-512 hash verified
243
+ - ✅ **Local mode:** Use without any network (zero data sent)
244
+
245
+ ### What APort Does NOT Do
246
+
247
+ - ❌ Access credentials, API keys, or passwords
248
+ - ❌ Read files outside ~/.openclaw/aport/
249
+ - ❌ Download additional payloads
250
+ - ❌ Establish backdoors or C2 connections
251
+ - ❌ Escalate privileges (no sudo required)
252
+ - ❌ Spread to other systems
253
+
254
+ **If you're concerned:** Use local mode (no network) and review the code.
255
+
256
+ ---
257
+
258
+ ## ⚙️ Environment Variables (Optional)
259
+
260
+ | Variable | When used | Purpose |
261
+ |----------|-----------|---------|
262
+ | `APORT_API_URL` | API or hosted mode | Override API endpoint (default `https://api.aport.io`). Use for self-hosted or custom API. |
263
+ | `APORT_AGENT_ID` | Hosted passport only | Hosted passport ID from aport.io; API fetches passport from registry. Not needed for local passport. |
264
+ | `APORT_API_KEY` | If your API requires auth | Set in environment only; do not put in config files. See [plugin README](https://github.com/aporthq/aport-agent-guardrails/blob/main/extensions/openclaw-aport/README.md). |
265
+
266
+ **Local mode:** No env vars; passport is read from `<config-dir>/aport/passport.json`.
267
+
268
+ **Hosted passport:** Pass `agent_id` to the installer once (or set in config); the plugin uses it on each call in API mode.
269
+
270
+ ---
271
+
272
+ ## 🔧 Tool Name Mapping
273
+
274
+ | When you're about to… | Use tool_name |
275
+ |------------------------------|-----------------------------|
276
+ | Run shell commands | `system.command.execute` |
277
+ | Send WhatsApp/email/etc. | `messaging.message.send` |
278
+ | Create/merge PRs | `git.create_pr`, `git.merge`|
279
+ | Call MCP tools | `mcp.tool.execute` |
280
+ | Export data / files | `data.export` |
281
+
282
+ Context must be valid JSON, e.g. `'{"command":"ls"}'` or `'{"channel":"whatsapp","to":"+1..."}'`.
283
+
284
+ ---
285
+
286
+ ## 📚 Documentation
287
+
288
+ **APort Guardrails:**
289
+ - [QuickStart: OpenClaw Plugin](https://github.com/aporthq/aport-agent-guardrails/blob/main/docs/QUICKSTART_OPENCLAW_PLUGIN.md)
290
+ - [Hosted passport setup](https://github.com/aporthq/aport-agent-guardrails/blob/main/docs/HOSTED_PASSPORT_SETUP.md)
291
+ - [Tool / policy mapping](https://github.com/aporthq/aport-agent-guardrails/blob/main/docs/TOOL_POLICY_MAPPING.md)
292
+
293
+ **OpenClaw:**
294
+ - [CLI: skills](https://docs.openclaw.ai/cli/skills)
295
+ - [Skills](https://docs.openclaw.ai/tools/skills)
296
+ - [Skills config](https://docs.openclaw.ai/tools/skills-config)
297
+ - [ClawHub](https://docs.openclaw.ai/tools/clawhub)
298
+
299
+ ---
300
+
301
+ ## 🔐 Security Notice
302
+
303
+ **7.1% of ClawHub skills are malicious.** Install APort before installing any other skills to protect your agent from:
304
+ - Data exfiltration attempts
305
+ - Unauthorized file system access
306
+ - Malicious API calls
307
+ - Prompt injection attacks
308
+ - API key leaks
309
+
310
+ **Pre-action authorization = prevention, not detection.** Malicious actions are blocked before they execute, not after.
311
+
312
+ ---
313
+
314
+ **Made with 🛡️ by [APort](https://aport.io) | Open-source on [GitHub](https://github.com/aporthq/aport-agent-guardrails)**