@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.
- package/LICENSE +217 -0
- package/README.md +481 -0
- package/bin/agent-guardrails +133 -0
- package/bin/aport-create-passport.sh +444 -0
- package/bin/aport-cursor-hook.sh +90 -0
- package/bin/aport-guardrail-api.sh +108 -0
- package/bin/aport-guardrail-bash.sh +394 -0
- package/bin/aport-guardrail-v2.sh +5 -0
- package/bin/aport-guardrail.sh +5 -0
- package/bin/aport-resolve-paths.sh +71 -0
- package/bin/aport-status.sh +276 -0
- package/bin/frameworks/crewai.sh +49 -0
- package/bin/frameworks/cursor.sh +95 -0
- package/bin/frameworks/langchain.sh +48 -0
- package/bin/frameworks/n8n.sh +36 -0
- package/bin/frameworks/openclaw.sh +19 -0
- package/bin/lib/allowlist.sh +18 -0
- package/bin/lib/common.sh +28 -0
- package/bin/lib/config.sh +46 -0
- package/bin/lib/constants.sh +232 -0
- package/bin/lib/detect.sh +65 -0
- package/bin/lib/error.sh +269 -0
- package/bin/lib/passport.sh +19 -0
- package/bin/lib/templates/.gitkeep +1 -0
- package/bin/lib/templates/config.yaml +6 -0
- package/bin/lib/validation.sh +206 -0
- package/bin/openclaw +660 -0
- package/docs/ADDING_A_FRAMEWORK.md +87 -0
- package/docs/AGENTS.md.example +40 -0
- package/docs/CODE_REVIEW.md +192 -0
- package/docs/DEPLOYMENT_READINESS.md +81 -0
- package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
- package/docs/FRAMEWORK_ROADMAP.md +41 -0
- package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
- package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
- package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
- package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
- package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
- package/docs/QUICKSTART.md +470 -0
- package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
- package/docs/README.md +28 -0
- package/docs/RELEASE.md +87 -0
- package/docs/REPO_LAYOUT.md +47 -0
- package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
- package/docs/TOOL_POLICY_MAPPING.md +46 -0
- package/docs/UPGRADE.md +46 -0
- package/docs/VERIFICATION_METHODS.md +97 -0
- package/docs/assets/README.md +8 -0
- package/docs/assets/porter.svg +54 -0
- package/docs/development/ERROR_CODES.md +616 -0
- package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
- package/docs/frameworks/crewai.md +114 -0
- package/docs/frameworks/cursor.md +159 -0
- package/docs/frameworks/langchain.md +72 -0
- package/docs/frameworks/n8n.md +40 -0
- package/docs/frameworks/openclaw.md +40 -0
- package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
- package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
- package/docs/launch/AWESOME_REPOS.md +53 -0
- package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
- package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
- package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
- package/docs/launch/EVIDENCE_README.md +61 -0
- package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
- package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
- package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
- package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
- package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
- package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
- package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
- package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
- package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
- package/docs/launch/READINESS_SUMMARY.md +262 -0
- package/docs/launch/README.md +68 -0
- package/docs/launch/USER_STORIES.md +327 -0
- package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
- package/docs/operations/MONITORING.md +588 -0
- package/docs/reviews/2026-02-18-staff-review.md +268 -0
- package/extensions/openclaw-aport/README.md +415 -0
- package/extensions/openclaw-aport/index.js +625 -0
- package/extensions/openclaw-aport/openclaw-aport.js +7 -0
- package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
- package/extensions/openclaw-aport/package.json +36 -0
- package/extensions/openclaw-aport/test.js +307 -0
- package/external/aport-policies/README.md +363 -0
- package/external/aport-policies/agent.session.create.v1/README.md +345 -0
- package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
- package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
- package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
- package/external/aport-policies/code.release.publish.v1/README.md +51 -0
- package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
- package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
- package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
- package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
- package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
- package/external/aport-policies/data.export.create.v1/README.md +226 -0
- package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
- package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
- package/external/aport-policies/data.export.create.v1/policy.json +133 -0
- package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
- package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
- package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
- package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
- package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
- package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
- package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
- package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
- package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
- package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
- package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
- package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
- package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
- package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
- package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
- package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
- package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
- package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
- package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
- package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
- package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
- package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
- package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
- package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
- package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
- package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
- package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
- package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
- package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
- package/external/aport-policies/governance.data.access.v1/README.md +292 -0
- package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
- package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
- package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
- package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
- package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
- package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
- package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
- package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
- package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
- package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
- package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
- package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
- package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
- package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
- package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
- package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
- package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
- package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
- package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
- package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
- package/external/aport-policies/policy-template.json +107 -0
- package/external/aport-policies/system.command.execute.v1/README.md +275 -0
- package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
- package/external/aport-spec/CONTRIBUTING.md +273 -0
- package/external/aport-spec/LICENSE +21 -0
- package/external/aport-spec/README.md +168 -0
- package/external/aport-spec/conformance/README.md +294 -0
- package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
- package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
- package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
- package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
- package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
- package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
- package/external/aport-spec/conformance/package.json +44 -0
- package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
- package/external/aport-spec/conformance/src/cases.ts +371 -0
- package/external/aport-spec/conformance/src/ed25519.ts +167 -0
- package/external/aport-spec/conformance/src/jcs.ts +85 -0
- package/external/aport-spec/conformance/src/runner.ts +533 -0
- package/external/aport-spec/conformance/src/validators.ts +185 -0
- package/external/aport-spec/conformance/test-runner.js +315 -0
- package/external/aport-spec/conformance/tsconfig.json +21 -0
- package/external/aport-spec/error-schema.json +192 -0
- package/external/aport-spec/index.json +12 -0
- package/external/aport-spec/integrations/clawmoat/README.md +12 -0
- package/external/aport-spec/integrations/shield/README.md +245 -0
- package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
- package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
- package/external/aport-spec/integrations/shield/test/README.md +58 -0
- package/external/aport-spec/integrations/shield/test/shield.md +40 -0
- package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
- package/external/aport-spec/metrics-schema.json +504 -0
- package/external/aport-spec/oap/CHANGELOG.md +54 -0
- package/external/aport-spec/oap/VERSION.md +40 -0
- package/external/aport-spec/oap/capability-registry.md +229 -0
- package/external/aport-spec/oap/conformance.md +257 -0
- package/external/aport-spec/oap/decision-schema.json +114 -0
- package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
- package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
- package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
- package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
- package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
- package/external/aport-spec/oap/oap-spec.md +426 -0
- package/external/aport-spec/oap/passport-schema.json +396 -0
- package/external/aport-spec/oap/security.md +213 -0
- package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
- package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
- package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
- package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
- package/external/aport-spec/oap/vc/tools/README.md +278 -0
- package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
- package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
- package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
- package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
- package/external/aport-spec/oap/vc/tools/package.json +38 -0
- package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
- package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
- package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
- package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
- package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
- package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
- package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
- package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
- package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
- package/external/aport-spec/passport-schema.json +586 -0
- package/external/aport-spec/rate-limiting.md +136 -0
- package/external/aport-spec/transport-profile.md +325 -0
- package/external/aport-spec/webhook-spec.md +314 -0
- package/package.json +70 -0
- package/skills/aport-agent-guardrail/SKILL.md +314 -0
- package/src/evaluator.js +252 -0
- package/src/server/index.js +72 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Rate Limiting Specification
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Open Agent Passport (OAP) API implements comprehensive rate limiting to ensure fair usage and system stability. This document defines the rate limiting rules, headers, and enforcement mechanisms.
|
|
6
|
+
|
|
7
|
+
## Rate Limiting Headers
|
|
8
|
+
|
|
9
|
+
### Standard Headers
|
|
10
|
+
|
|
11
|
+
All API responses include the following rate limiting headers:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
X-RateLimit-Limit: 1000
|
|
15
|
+
X-RateLimit-Remaining: 999
|
|
16
|
+
X-RateLimit-Reset: 1640995200
|
|
17
|
+
X-RateLimit-Window: 3600
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Header Definitions
|
|
21
|
+
|
|
22
|
+
- **X-RateLimit-Limit**: Maximum number of requests allowed in the current window
|
|
23
|
+
- **X-RateLimit-Remaining**: Number of requests remaining in the current window
|
|
24
|
+
- **X-RateLimit-Reset**: Unix timestamp when the current window resets
|
|
25
|
+
- **X-RateLimit-Window**: Duration of the rate limit window in seconds
|
|
26
|
+
|
|
27
|
+
## Rate Limits by Endpoint
|
|
28
|
+
|
|
29
|
+
### Verification Endpoints
|
|
30
|
+
|
|
31
|
+
| Endpoint | Limit | Window | Notes |
|
|
32
|
+
|----------|-------|--------|-------|
|
|
33
|
+
| `/api/verify/{agent_id}` | 1000 | 1 hour | Per agent ID |
|
|
34
|
+
| `/api/verify/policy/{pack_id}` | 500 | 1 hour | Per policy pack |
|
|
35
|
+
| `/api/verify/decisions/{agent_id}` | 100 | 1 hour | Per agent ID |
|
|
36
|
+
|
|
37
|
+
### Passport Management
|
|
38
|
+
|
|
39
|
+
| Endpoint | Limit | Window | Notes |
|
|
40
|
+
|----------|-------|--------|-------|
|
|
41
|
+
| `/api/passports` (POST) | 10 | 1 hour | Per owner |
|
|
42
|
+
| `/api/passports/{agent_id}` (PUT) | 50 | 1 hour | Per agent ID |
|
|
43
|
+
| `/api/passports/{agent_id}/status` (PUT) | 20 | 1 hour | Per agent ID |
|
|
44
|
+
|
|
45
|
+
### Public Endpoints
|
|
46
|
+
|
|
47
|
+
| Endpoint | Limit | Window | Notes |
|
|
48
|
+
|----------|-------|--------|-------|
|
|
49
|
+
| `/api/verify/attestation/{id}` | 2000 | 1 hour | Public endpoint |
|
|
50
|
+
| `/api/policies/{policy_name}` | 1000 | 1 hour | Public policy lookup |
|
|
51
|
+
|
|
52
|
+
## Rate Limiting Strategies
|
|
53
|
+
|
|
54
|
+
### Tiered Limiting
|
|
55
|
+
|
|
56
|
+
Rate limits are applied in tiers:
|
|
57
|
+
|
|
58
|
+
1. **Global Rate Limit**: 10,000 requests per hour per IP
|
|
59
|
+
2. **Endpoint Rate Limit**: Specific limits per endpoint
|
|
60
|
+
3. **User Rate Limit**: Additional limits for authenticated users
|
|
61
|
+
4. **Agent Rate Limit**: Limits specific to agent operations
|
|
62
|
+
|
|
63
|
+
### Burst Allowance
|
|
64
|
+
|
|
65
|
+
Short-term burst requests are allowed:
|
|
66
|
+
|
|
67
|
+
- **Burst Factor**: 2x the normal rate limit
|
|
68
|
+
- **Burst Window**: 1 minute
|
|
69
|
+
- **Burst Reset**: 5 minutes
|
|
70
|
+
|
|
71
|
+
## Error Responses
|
|
72
|
+
|
|
73
|
+
### Rate Limit Exceeded
|
|
74
|
+
|
|
75
|
+
When rate limits are exceeded, the API returns:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"error": "rate_limit_exceeded",
|
|
80
|
+
"message": "Rate limit exceeded. Please try again later.",
|
|
81
|
+
"retry_after": 3600,
|
|
82
|
+
"rate_limit_info": {
|
|
83
|
+
"limit": 1000,
|
|
84
|
+
"remaining": 0,
|
|
85
|
+
"reset": 1640995200,
|
|
86
|
+
"window": 3600
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### HTTP Status Codes
|
|
92
|
+
|
|
93
|
+
- **429 Too Many Requests**: Rate limit exceeded
|
|
94
|
+
- **503 Service Unavailable**: System overload protection
|
|
95
|
+
|
|
96
|
+
## Implementation Notes
|
|
97
|
+
|
|
98
|
+
### Distributed Rate Limiting
|
|
99
|
+
|
|
100
|
+
Rate limiting is implemented using:
|
|
101
|
+
|
|
102
|
+
- **Redis**: For distributed rate limit counters
|
|
103
|
+
- **Sliding Window**: For smooth rate limit enforcement
|
|
104
|
+
- **Token Bucket**: For burst allowance
|
|
105
|
+
|
|
106
|
+
### Monitoring
|
|
107
|
+
|
|
108
|
+
Rate limiting metrics are tracked:
|
|
109
|
+
|
|
110
|
+
- Requests per second by endpoint
|
|
111
|
+
- Rate limit violations by IP/user
|
|
112
|
+
- System load and performance impact
|
|
113
|
+
|
|
114
|
+
## Best Practices
|
|
115
|
+
|
|
116
|
+
### Client Implementation
|
|
117
|
+
|
|
118
|
+
1. **Respect Headers**: Always check rate limit headers
|
|
119
|
+
2. **Exponential Backoff**: Implement retry with backoff
|
|
120
|
+
3. **Caching**: Cache responses to reduce API calls
|
|
121
|
+
4. **Batching**: Combine multiple requests when possible
|
|
122
|
+
|
|
123
|
+
### Error Handling
|
|
124
|
+
|
|
125
|
+
1. **Retry Logic**: Implement intelligent retry mechanisms
|
|
126
|
+
2. **Fallback**: Have fallback strategies for rate limit scenarios
|
|
127
|
+
3. **Monitoring**: Track rate limit usage and violations
|
|
128
|
+
|
|
129
|
+
## Compliance
|
|
130
|
+
|
|
131
|
+
This rate limiting specification ensures:
|
|
132
|
+
|
|
133
|
+
- **Fair Usage**: Prevents abuse while allowing legitimate use
|
|
134
|
+
- **System Stability**: Protects against overload
|
|
135
|
+
- **Scalability**: Supports high-volume operations
|
|
136
|
+
- **Transparency**: Clear communication of limits and status
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Transport Profile Specification
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The Transport Profile defines how AI agents identify themselves and communicate their Open Agent Passport (OAP) credentials across different transport mechanisms. This specification ensures consistent agent identification regardless of the underlying communication protocol.
|
|
6
|
+
|
|
7
|
+
## Transport Mechanisms
|
|
8
|
+
|
|
9
|
+
### HTTP/HTTPS
|
|
10
|
+
|
|
11
|
+
The primary transport mechanism for web-based agent interactions.
|
|
12
|
+
|
|
13
|
+
#### Headers
|
|
14
|
+
|
|
15
|
+
Agents must include the following headers in HTTP requests:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
X-Agent-Passport: ap_a2d10232c6534523812423eec8a1425c
|
|
19
|
+
X-Agent-Signature: ed25519:abc123def456...
|
|
20
|
+
X-Agent-Timestamp: 1640995200
|
|
21
|
+
X-Agent-Nonce: nonce_123456789
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Header Definitions
|
|
25
|
+
|
|
26
|
+
- **X-Agent-Passport**: The agent's passport ID
|
|
27
|
+
- **X-Agent-Signature**: Ed25519 signature of the request
|
|
28
|
+
- **X-Agent-Timestamp**: Unix timestamp of the request
|
|
29
|
+
- **X-Agent-Nonce**: Unique nonce for replay protection
|
|
30
|
+
|
|
31
|
+
### WebSocket
|
|
32
|
+
|
|
33
|
+
For real-time agent communications.
|
|
34
|
+
|
|
35
|
+
#### Connection Handshake
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"type": "agent_handshake",
|
|
40
|
+
"passport_id": "ap_a2d10232c6534523812423eec8a1425c",
|
|
41
|
+
"signature": "ed25519:abc123def456...",
|
|
42
|
+
"timestamp": 1640995200,
|
|
43
|
+
"nonce": "nonce_123456789",
|
|
44
|
+
"capabilities": ["finance.payment.refund", "data.export"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### Message Format
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"type": "agent_message",
|
|
53
|
+
"passport_id": "ap_a2d10232c6534523812423eec8a1425c",
|
|
54
|
+
"message_id": "msg_123456789",
|
|
55
|
+
"payload": {
|
|
56
|
+
// Message content
|
|
57
|
+
},
|
|
58
|
+
"signature": "ed25519:xyz789...",
|
|
59
|
+
"timestamp": 1640995200
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### gRPC
|
|
64
|
+
|
|
65
|
+
For high-performance agent-to-agent communication.
|
|
66
|
+
|
|
67
|
+
#### Service Definition
|
|
68
|
+
|
|
69
|
+
```protobuf
|
|
70
|
+
service AgentService {
|
|
71
|
+
rpc Identify(AgentIdentity) returns (AgentResponse);
|
|
72
|
+
rpc Execute(AgentRequest) returns (AgentResponse);
|
|
73
|
+
rpc Verify(VerificationRequest) returns (VerificationResponse);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
message AgentIdentity {
|
|
77
|
+
string passport_id = 1;
|
|
78
|
+
string signature = 2;
|
|
79
|
+
int64 timestamp = 3;
|
|
80
|
+
string nonce = 4;
|
|
81
|
+
repeated string capabilities = 5;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Message Queues
|
|
86
|
+
|
|
87
|
+
For asynchronous agent communication.
|
|
88
|
+
|
|
89
|
+
#### Message Structure
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"headers": {
|
|
94
|
+
"x-agent-passport": "ap_a2d10232c6534523812423eec8a1425c",
|
|
95
|
+
"x-agent-signature": "ed25519:abc123def456...",
|
|
96
|
+
"x-agent-timestamp": "1640995200",
|
|
97
|
+
"x-agent-nonce": "nonce_123456789"
|
|
98
|
+
},
|
|
99
|
+
"body": {
|
|
100
|
+
// Message payload
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Agent Identification
|
|
106
|
+
|
|
107
|
+
### Passport ID Format
|
|
108
|
+
|
|
109
|
+
Agent passport IDs follow this format:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
ap_[a-zA-Z0-9]{8,16}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
- `ap_a2d10232c6534523812423eec8a1425c`
|
|
117
|
+
- `ap_abc123def456`
|
|
118
|
+
- `ap_myagent001`
|
|
119
|
+
|
|
120
|
+
### Signature Generation
|
|
121
|
+
|
|
122
|
+
All agent communications must be signed using Ed25519:
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
const crypto = require('crypto');
|
|
126
|
+
|
|
127
|
+
function signRequest(passportId, privateKey, timestamp, nonce, payload) {
|
|
128
|
+
const message = `${passportId}:${timestamp}:${nonce}:${JSON.stringify(payload)}`;
|
|
129
|
+
const signature = crypto
|
|
130
|
+
.createSign('ed25519')
|
|
131
|
+
.update(message)
|
|
132
|
+
.sign(privateKey);
|
|
133
|
+
return `ed25519:${signature.toString('hex')}`;
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Timestamp Validation
|
|
138
|
+
|
|
139
|
+
Timestamps must be:
|
|
140
|
+
|
|
141
|
+
- **Current**: Within 5 minutes of current time
|
|
142
|
+
- **Monotonic**: Never decrease for the same agent
|
|
143
|
+
- **Format**: Unix timestamp in seconds
|
|
144
|
+
|
|
145
|
+
### Nonce Requirements
|
|
146
|
+
|
|
147
|
+
Nonces must be:
|
|
148
|
+
|
|
149
|
+
- **Unique**: Never reused for the same agent
|
|
150
|
+
- **Random**: Cryptographically secure random generation
|
|
151
|
+
- **Format**: `nonce_[a-zA-Z0-9]{16,32}`
|
|
152
|
+
|
|
153
|
+
## Transport Security
|
|
154
|
+
|
|
155
|
+
### TLS Requirements
|
|
156
|
+
|
|
157
|
+
All agent communications must use TLS 1.3 or higher:
|
|
158
|
+
|
|
159
|
+
- **Minimum Version**: TLS 1.3
|
|
160
|
+
- **Cipher Suites**: Only approved cipher suites
|
|
161
|
+
- **Certificate Validation**: Full certificate chain validation
|
|
162
|
+
- **Perfect Forward Secrecy**: Required for all connections
|
|
163
|
+
|
|
164
|
+
### Signature Verification
|
|
165
|
+
|
|
166
|
+
Receiving systems must verify agent signatures:
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
function verifySignature(passportId, signature, publicKey, timestamp, nonce, payload) {
|
|
170
|
+
const message = `${passportId}:${timestamp}:${nonce}:${JSON.stringify(payload)}`;
|
|
171
|
+
const sig = signature.replace('ed25519:', '');
|
|
172
|
+
|
|
173
|
+
return crypto
|
|
174
|
+
.createVerify('ed25519')
|
|
175
|
+
.update(message)
|
|
176
|
+
.verify(publicKey, Buffer.from(sig, 'hex'));
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Replay Protection
|
|
181
|
+
|
|
182
|
+
Implement replay protection using:
|
|
183
|
+
|
|
184
|
+
1. **Nonce Tracking**: Store used nonces for 24 hours
|
|
185
|
+
2. **Timestamp Windows**: Reject requests outside time window
|
|
186
|
+
3. **Sequence Numbers**: Optional sequence number validation
|
|
187
|
+
|
|
188
|
+
## Agent Discovery
|
|
189
|
+
|
|
190
|
+
### Service Discovery
|
|
191
|
+
|
|
192
|
+
Agents can discover other agents through:
|
|
193
|
+
|
|
194
|
+
#### DNS SRV Records
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
_agent._tcp.example.com. 300 IN SRV 10 5 443 agent1.example.com.
|
|
198
|
+
_agent._tcp.example.com. 300 IN SRV 20 5 443 agent2.example.com.
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### mDNS/Bonjour
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
_agent._tcp.local. PTR agent1._agent._tcp.local.
|
|
205
|
+
agent1._agent._tcp.local. SRV 0 0 443 agent1.local.
|
|
206
|
+
agent1._agent._tcp.local. TXT "passport=ap_a2d10232c6534523812423eec8a1425c"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Agent Registry
|
|
210
|
+
|
|
211
|
+
Centralized agent discovery service:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"agents": [
|
|
216
|
+
{
|
|
217
|
+
"passport_id": "ap_a2d10232c6534523812423eec8a1425c",
|
|
218
|
+
"name": "Acme Support Bot",
|
|
219
|
+
"endpoint": "https://agent1.example.com",
|
|
220
|
+
"capabilities": ["finance.payment.refund", "data.export"],
|
|
221
|
+
"status": "active",
|
|
222
|
+
"last_seen": "2025-01-16T10:30:00Z"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Error Handling
|
|
229
|
+
|
|
230
|
+
### Transport Errors
|
|
231
|
+
|
|
232
|
+
| Error Code | Description | Action |
|
|
233
|
+
|------------|-------------|--------|
|
|
234
|
+
| `TRANSPORT_ERROR` | Connection failed | Retry with backoff |
|
|
235
|
+
| `SIGNATURE_INVALID` | Invalid signature | Reject request |
|
|
236
|
+
| `TIMESTAMP_EXPIRED` | Timestamp too old | Reject request |
|
|
237
|
+
| `NONCE_REUSED` | Nonce already used | Reject request |
|
|
238
|
+
| `PASSPORT_INVALID` | Invalid passport ID | Reject request |
|
|
239
|
+
|
|
240
|
+
### Error Response Format
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"error": {
|
|
245
|
+
"code": "SIGNATURE_INVALID",
|
|
246
|
+
"message": "Invalid agent signature",
|
|
247
|
+
"details": {
|
|
248
|
+
"passport_id": "ap_a2d10232c6534523812423eec8a1425c",
|
|
249
|
+
"expected": "ed25519:abc123...",
|
|
250
|
+
"received": "ed25519:xyz789..."
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"timestamp": "2025-01-16T10:30:00Z"
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Implementation Guidelines
|
|
258
|
+
|
|
259
|
+
### Client Libraries
|
|
260
|
+
|
|
261
|
+
Transport profile implementations should provide:
|
|
262
|
+
|
|
263
|
+
1. **Automatic Signing**: Sign all outgoing requests
|
|
264
|
+
2. **Signature Verification**: Verify incoming requests
|
|
265
|
+
3. **Nonce Management**: Generate and track nonces
|
|
266
|
+
4. **Error Handling**: Handle transport errors gracefully
|
|
267
|
+
5. **Retry Logic**: Implement exponential backoff
|
|
268
|
+
|
|
269
|
+
### Server Implementation
|
|
270
|
+
|
|
271
|
+
Receiving systems should:
|
|
272
|
+
|
|
273
|
+
1. **Validate Signatures**: Verify all agent signatures
|
|
274
|
+
2. **Check Timestamps**: Validate timestamp freshness
|
|
275
|
+
3. **Track Nonces**: Prevent replay attacks
|
|
276
|
+
4. **Rate Limiting**: Implement per-agent rate limiting
|
|
277
|
+
5. **Logging**: Log all agent interactions
|
|
278
|
+
|
|
279
|
+
## Testing
|
|
280
|
+
|
|
281
|
+
### Test Vectors
|
|
282
|
+
|
|
283
|
+
Standard test vectors for signature verification:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"passport_id": "ap_test123",
|
|
288
|
+
"timestamp": 1640995200,
|
|
289
|
+
"nonce": "nonce_test123",
|
|
290
|
+
"payload": {"action": "test"},
|
|
291
|
+
"private_key": "test_private_key",
|
|
292
|
+
"expected_signature": "ed25519:test_signature"
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Conformance Testing
|
|
297
|
+
|
|
298
|
+
Use the OAP conformance test suite to verify transport profile implementation:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
npm run test:transport-profile
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Best Practices
|
|
305
|
+
|
|
306
|
+
### Security
|
|
307
|
+
|
|
308
|
+
1. **Key Management**: Store private keys securely
|
|
309
|
+
2. **Key Rotation**: Implement regular key rotation
|
|
310
|
+
3. **Audit Logging**: Log all agent communications
|
|
311
|
+
4. **Monitoring**: Monitor for suspicious activity
|
|
312
|
+
|
|
313
|
+
### Performance
|
|
314
|
+
|
|
315
|
+
1. **Connection Pooling**: Reuse connections when possible
|
|
316
|
+
2. **Async Processing**: Process requests asynchronously
|
|
317
|
+
3. **Caching**: Cache passport data appropriately
|
|
318
|
+
4. **Load Balancing**: Distribute agent load
|
|
319
|
+
|
|
320
|
+
### Reliability
|
|
321
|
+
|
|
322
|
+
1. **Circuit Breakers**: Implement circuit breaker patterns
|
|
323
|
+
2. **Health Checks**: Regular health check endpoints
|
|
324
|
+
3. **Graceful Degradation**: Handle partial failures
|
|
325
|
+
4. **Monitoring**: Comprehensive monitoring and alerting
|