@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,1640 @@
|
|
|
1
|
+
# APort Framework Support Strategy & Architecture
|
|
2
|
+
|
|
3
|
+
**Version:** 2.0 (Comprehensive)
|
|
4
|
+
**Last Updated:** 2026-02-18
|
|
5
|
+
**Status:** Living Document (Public)
|
|
6
|
+
|
|
7
|
+
> **Implementation aligned with v1.0.8:** Package renames (npm/PyPI), PyPI automation, security hardening, and docs are reflected in [CHANGELOG.md](../../CHANGELOG.md). This plan’s “Implementation status” table and DEPLOYMENT_READINESS are the source of truth for what is shipped.
|
|
8
|
+
|
|
9
|
+
> **Vision:** One command (`npx @aporthq/aport-agent-guardrails` or `pip install aport-agent-guardrails`) that brings pre-action authorization to ANY AI agent framework—code, low-code, or no-code.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Implementation status (current vs plan)
|
|
14
|
+
|
|
15
|
+
**Use this section when assessing readiness.** The plan below describes the target architecture; this table reflects what is **actually implemented** as of the last doc update.
|
|
16
|
+
|
|
17
|
+
| Plan pillar | Implemented? | Where to look |
|
|
18
|
+
|-------------|---------------|---------------|
|
|
19
|
+
| **Shared layer** (passport wizard, policy packs, guardrail scripts, config helpers) | ✅ Yes | `bin/aport-create-passport.sh`, `bin/aport-guardrail-*.sh`, `bin/lib/*.sh`, `external/aport-policies/`. Tests: `tests/unit`, `tests/test-*.sh`. |
|
|
20
|
+
| **Single dispatcher CLI** | ✅ Yes | `bin/agent-guardrails` — detection, `--framework`, env overrides. Tests: `tests/frameworks/<name>/setup.sh`. Framework scripts run wizard + write config; they do **not** auto-install pip/npm packages (except OpenClaw full installer). |
|
|
21
|
+
| **TypeScript core (evaluator, config, passport)** | ✅ Yes | `packages/core/src/core/evaluator.ts`, `config.ts`, `passport.ts`, `pathUtils.ts` — full implementation: API + local bash, native fetch in sync path, config YAML, passport loading. **Fail-closed by default** when passport/script missing (`fail_open_when_missing_config` or `APORT_FAIL_OPEN_WHEN_MISSING_CONFIG=1` for legacy). Jest: `packages/core/src/core/*.test.ts`. |
|
|
22
|
+
| **Node LangChain adapter** | ✅ Yes | `packages/langchain/src/middleware.ts` — `APortGuardrailCallback`, `GuardrailViolationError`, uses core `Evaluator`. Jest: `middleware.test.ts`. |
|
|
23
|
+
| **Node CrewAI adapter** | ✅ Yes | `packages/crewai/src/middleware.ts` — `beforeToolCall`, `registerAPortGuardrail`, `withAPortGuardrail`, uses core `verifySync`; module-level Evaluator reuse. Feature parity with Python. |
|
|
24
|
+
| **Node Cursor package** | ✅ Yes | `packages/cursor` — `Evaluator`, `getHookPath()`. `activate()`/`deactivate()` are no-op stubs reserved for future VS Code extension. Runtime enforcement is bash hook from CLI. |
|
|
25
|
+
| **Python LangChain/CrewAI adapters** | ✅ Yes | `python/langchain_adapter`, `python/crewai_adapter` — PyPI packages, CLIs, E2E in CI. |
|
|
26
|
+
| **OpenClaw plugin** | ✅ Yes | `extensions/openclaw-aport/`, `bin/openclaw` — full installer + tests. |
|
|
27
|
+
| **Cursor hook** | ✅ Yes | `bin/frameworks/cursor.sh`, `bin/aport-cursor-hook.sh` — unit + integration tests. |
|
|
28
|
+
| **n8n custom node** | ❌ No | n8n is **coming soon**. Config/installer only; no custom node; `@aporthq/aport-agent-guardrails-n8n` not published. See `docs/frameworks/n8n.md`. |
|
|
29
|
+
| **Release CI** | ✅ Yes | `.github/workflows/release.yml` — on tag push: publishes root + core, langchain, crewai, cursor to npm; Python to PyPI; GitHub Release. |
|
|
30
|
+
|
|
31
|
+
**Single source of truth for deployability:** [DEPLOYMENT_READINESS.md](../DEPLOYMENT_READINESS.md). Production-ready today: OpenClaw, Cursor, Python LangChain/CrewAI, **and** the Node CLI + Node packages (root, core, langchain, crewai, cursor).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Table of Contents
|
|
36
|
+
|
|
37
|
+
1. [Executive Summary](#executive-summary)
|
|
38
|
+
2. [Original Request & Goals](#original-request--goals)
|
|
39
|
+
3. [Architecture Overview](#architecture-overview)
|
|
40
|
+
4. [Framework Rankings & Justification](#framework-rankings--justification)
|
|
41
|
+
5. [Technical Architecture](#technical-architecture)
|
|
42
|
+
6. [Repository Structure](#repository-structure)
|
|
43
|
+
7. [Shared Components Strategy](#shared-components-strategy)
|
|
44
|
+
8. [Per-Framework Integration Patterns](#per-framework-integration-patterns)
|
|
45
|
+
9. [Implementation Roadmap](#implementation-roadmap)
|
|
46
|
+
10. [Success Metrics](#success-metrics)
|
|
47
|
+
11. [Open Questions](#open-questions)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Executive Summary
|
|
52
|
+
|
|
53
|
+
### The Problem
|
|
54
|
+
Every AI agent framework (LangChain, CrewAI, OpenClaw, AutoGen, etc.) needs pre-action authorization, but each has different:
|
|
55
|
+
- Runtime architecture (Node, Python, Rust)
|
|
56
|
+
- Hook mechanisms (middleware, decorators, callbacks)
|
|
57
|
+
- Configuration patterns
|
|
58
|
+
- Developer personas (code vs low-code vs no-code)
|
|
59
|
+
|
|
60
|
+
### The Solution
|
|
61
|
+
**Single unified installer** for each language ecosystem that:
|
|
62
|
+
1. **Detects or prompts** for target framework
|
|
63
|
+
2. **Runs shared passport creation flow** (same wizard, same OAP v1.0 format)
|
|
64
|
+
3. **Installs framework-specific integration** (middleware, decorator, config)
|
|
65
|
+
4. **Supports hosted or local** (agent_id-only or passport.json)
|
|
66
|
+
|
|
67
|
+
### The Architecture
|
|
68
|
+
```
|
|
69
|
+
Common Layer (Shared):
|
|
70
|
+
- Passport wizard (OAP v1.0)
|
|
71
|
+
- Policy packs (JSON, SHIELD import)
|
|
72
|
+
- Verification logic (API client or local evaluator)
|
|
73
|
+
- Config management
|
|
74
|
+
|
|
75
|
+
Framework Layer (Diverges):
|
|
76
|
+
- Node: npm packages with framework-specific hooks
|
|
77
|
+
- Python: pip packages with decorators/middleware
|
|
78
|
+
- Low/No-Code: HTTP/webhook integrations
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### The Opportunity
|
|
82
|
+
- **200K+ GitHub stars** across top frameworks
|
|
83
|
+
- **1M+ developers** building AI agents
|
|
84
|
+
- **94% of enterprises** plan to expand agent use in 2026
|
|
85
|
+
- **Minimal APort adoption today** = greenfield opportunity
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Original Request & Goals
|
|
90
|
+
|
|
91
|
+
### User Request (Verbatim)
|
|
92
|
+
> "I want a single command:
|
|
93
|
+
> - `npx @aporthq/aport-agent-guardrails` for Node agent frameworks
|
|
94
|
+
> - Similar command for Python (deploy to PyPI?)
|
|
95
|
+
>
|
|
96
|
+
> The tool should:
|
|
97
|
+
> 1. First ask for the framework
|
|
98
|
+
> 2. Passport creation happens the same way
|
|
99
|
+
> 3. Only divergence: how passport is saved and evaluator (if local)
|
|
100
|
+
>
|
|
101
|
+
> Possible: packages for each framework for SEO, then main command calls sub-packages
|
|
102
|
+
>
|
|
103
|
+
> Goal: Find common reusable tools and utils. Think like a Staff Developer with extensive backend, opensource, security experience."
|
|
104
|
+
|
|
105
|
+
### Success Criteria
|
|
106
|
+
1. ✅ **Single entry point** per language (npx, pip)
|
|
107
|
+
2. ✅ **Maximum code reuse** across frameworks
|
|
108
|
+
3. ✅ **Minimal maintenance burden** for new frameworks
|
|
109
|
+
4. ✅ **SEO/discovery** via framework-specific packages
|
|
110
|
+
5. ✅ **Production-ready** architecture that scales
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Architecture Overview
|
|
115
|
+
|
|
116
|
+
### High-Level Flow
|
|
117
|
+
|
|
118
|
+
```mermaid
|
|
119
|
+
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#f0f9ff','primaryTextColor':'#0c4a6e','primaryBorderColor':'#0284c7'}}}%%
|
|
120
|
+
flowchart TB
|
|
121
|
+
Start([Developer runs install command]) --> Detect[Detect or prompt for framework]
|
|
122
|
+
Detect --> Wizard[Shared Passport Wizard<br/>OAP v1.0 format]
|
|
123
|
+
Wizard --> Choice{Hosted or Local?}
|
|
124
|
+
Choice -->|Hosted| HostedFlow[agent_id only<br/>API verification]
|
|
125
|
+
Choice -->|Local| LocalFlow[passport.json<br/>Local or API verification]
|
|
126
|
+
HostedFlow --> Install[Install framework integration]
|
|
127
|
+
LocalFlow --> Install
|
|
128
|
+
Install --> Configure[Write framework config]
|
|
129
|
+
Configure --> Test[Run smoke test]
|
|
130
|
+
Test --> Done([✅ Ready to use])
|
|
131
|
+
|
|
132
|
+
style Start fill:#0277bd,stroke:#01579b,color:#fff
|
|
133
|
+
style Wizard fill:#ff6f00,stroke:#bf360c,color:#fff
|
|
134
|
+
style Install fill:#2e7d32,stroke:#1b5e20,color:#fff
|
|
135
|
+
style Done fill:#388e3c,stroke:#1b5e20,color:#fff
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Core Principle: Shared + Divergent
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
142
|
+
│ SHARED LAYER (90% of code) │
|
|
143
|
+
├─────────────────────────────────────────────────────────────┤
|
|
144
|
+
│ • Passport wizard (bin/aport-create-passport.sh) │
|
|
145
|
+
│ • Policy packs (external/aport-policies/*) │
|
|
146
|
+
│ • Verification logic (src/evaluator.js, bin/*-bash.sh) │
|
|
147
|
+
│ • Config templates (lib/templates/*.yaml) │
|
|
148
|
+
│ • Status/diagnostic tools (bin/aport-status.sh) │
|
|
149
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
150
|
+
│
|
|
151
|
+
┌────────────┴────────────┬──────────────┐
|
|
152
|
+
▼ ▼ ▼
|
|
153
|
+
┌───────────────┐ ┌─────────────────┐ ┌──────────────┐
|
|
154
|
+
│ NODE LAYER │ │ PYTHON LAYER │ │ HTTP LAYER │
|
|
155
|
+
├───────────────┤ ├─────────────────┤ ├──────────────┤
|
|
156
|
+
│ • TypeScript │ │ • Decorators │ │ • Webhooks │
|
|
157
|
+
│ middleware │ │ • Async context │ │ • REST API │
|
|
158
|
+
│ • Config: │ │ • Config: │ │ • Config: │
|
|
159
|
+
│ YAML/JSON │ │ .aport/ │ │ URL + key │
|
|
160
|
+
└───────────────┘ └─────────────────┘ └──────────────┘
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Framework Rankings & Justification
|
|
166
|
+
|
|
167
|
+
### Ranking Methodology
|
|
168
|
+
|
|
169
|
+
**Scoring Matrix (100 points total):**
|
|
170
|
+
- **Estimated Users (30 pts):** GitHub stars, downloads, community size
|
|
171
|
+
- **ROI vs Effort (25 pts):** Integration complexity vs adoption potential
|
|
172
|
+
- **APort Adoption Potential (25 pts):** How well pre-action authorization fits use case
|
|
173
|
+
- **Strategic Value (20 pts):** Ecosystem position, enterprise adoption, growth trajectory
|
|
174
|
+
|
|
175
|
+
### Rankings Table
|
|
176
|
+
|
|
177
|
+
| Rank | Framework | Category | Est. Users | Effort | ROI Score | APort Fit | Total | Status | Notes |
|
|
178
|
+
|------|-----------|----------|------------|--------|-----------|-----------|-------|--------|-------|
|
|
179
|
+
| **1** | **OpenClaw** | Code (Node) | 200K+ ⭐ | Low | 25/25 | 25/25 | **95/100** | ✅ Shipped | Already integrated; moving to OpenAI foundation |
|
|
180
|
+
| **2** | **LangChain/LangGraph** | Code (Python) | 80K+ ⭐, massive enterprise | Medium | 24/25 | 24/25 | **92/100** | 🎯 Priority | Market leader, proven enterprise adoption |
|
|
181
|
+
| **3** | **Cursor IDE** | IDE (Node/Electron) | 1M+ users, $500M ARR | Medium | 23/25 | 25/25 | **91/100** | 🎯 Priority | 50% Fortune 500 use it; pre-execution hooks needed |
|
|
182
|
+
| **4** | **CrewAI** | Code (Python) | 20K+ ⭐, growing fast | Medium | 22/25 | 23/25 | **88/100** | 🎯 Priority | Multi-agent focus; strong community |
|
|
183
|
+
| **5** | **n8n** | Low-Code (Node) | 50K+ ⭐, open-source | Low | 23/25 | 21/25 | **87/100** | 🚀 High | 70+ AI nodes; webhook integration simple |
|
|
184
|
+
| **6** | **Microsoft AutoGen** | Code (Python) | 35K+ ⭐, MS backing | Medium | 21/25 | 22/25 | **86/100** | 🚀 High | Enterprise adoption; Microsoft ecosystem |
|
|
185
|
+
| **7** | **Zapier AI Actions** | No-Code | 8000+ app integrations | Low | 20/25 | 20/25 | **83/100** | 🚀 High | Largest connector library; webhook integration |
|
|
186
|
+
| **8** | **FlowiseAI** | Low-Code (Node) | 30K+ ⭐ | Low | 21/25 | 19/25 | **82/100** | 🟡 Medium | LangChain-based; visual builder |
|
|
187
|
+
| **9** | **LlamaIndex Agents** | Code (Python) | 40K+ ⭐ | Medium | 19/25 | 20/25 | **81/100** | 🟡 Medium | RAG + agents; callback hooks |
|
|
188
|
+
| **10** | **Semantic Kernel** | Code (C#/Python) | 22K+ ⭐, MS backing | High | 18/25 | 20/25 | **80/100** | 🟡 Medium | .NET ecosystem; enterprise focus |
|
|
189
|
+
| **11** | **Goose CLI** | Code (Node) | Developer tool | Medium | 19/25 | 19/25 | **78/100** | 🟡 Medium | CLI-first; hook system exists |
|
|
190
|
+
| **12** | **OpenAI Agents SDK** | Code (Python/Node) | Official OpenAI | Medium | 18/25 | 21/25 | **77/100** | ⏳ Future | SDK still evolving; wait for stable API |
|
|
191
|
+
| **13** | **IronClaw** | Code (Rust/Node) | OpenClaw fork | Medium | 17/25 | 18/25 | **76/100** | ⏳ Future | Rust performance focus |
|
|
192
|
+
| **14** | **Anthropic Tool Use** | Code (Python) | Official Claude | Medium | 17/25 | 19/25 | **75/100** | ⏳ Future | Tool use SDK; callback hooks |
|
|
193
|
+
| **15** | **Windsurf IDE** | IDE (Node) | 100K+ users, growing | Medium | 16/25 | 18/25 | **74/100** | ⏳ Future | Cascades multi-file editing |
|
|
194
|
+
| **16** | **Make (Integromat)** | No-Code | 500K+ users | Low | 18/25 | 16/25 | **73/100** | 🟡 Medium | Visual automation; HTTP modules |
|
|
195
|
+
| **17** | **AutoGPT** | Code (Python) | 180K+ ⭐ (legacy) | High | 14/25 | 17/25 | **71/100** | 🔵 Backlog | Declining activity; watch for resurgence |
|
|
196
|
+
| **18** | **Temporal Workflows** | Code (Go/TS) | Enterprise infra | High | 16/25 | 16/25 | **70/100** | 🔵 Backlog | Activity interceptors exist |
|
|
197
|
+
| **19** | **AWS Bedrock Agents** | Cloud (Python) | AWS ecosystem | Medium | 15/25 | 17/25 | **69/100** | 🔵 Backlog | Lambda hooks; IAM integration |
|
|
198
|
+
| **20** | **Langroid** | Code (Python) | 4K+ ⭐ | Medium | 14/25 | 15/25 | **67/100** | 🔵 Backlog | Actor-based; smaller community |
|
|
199
|
+
| **21** | **PicoClaw** | Code (Go) | OpenClaw fork | High | 13/25 | 15/25 | **66/100** | 🔵 Backlog | Go ecosystem; smaller base |
|
|
200
|
+
| **22** | **Google AI Studio** | Cloud (Python/Node) | Google ecosystem | Medium | 13/25 | 16/25 | **65/100** | 🔵 Backlog | Guardrail APIs exist |
|
|
201
|
+
| **23** | **NanoClaw** | Code (Python) | OpenClaw fork | High | 12/25 | 14/25 | **64/100** | 🔵 Backlog | Python port; smaller base |
|
|
202
|
+
| **24** | **Slack Bolt Framework** | Code (Node/Python) | Enterprise bots | Medium | 12/25 | 13/25 | **62/100** | 🔵 Backlog | Middleware hooks; bot focus |
|
|
203
|
+
| **25** | **Microsoft Teams Bots** | Code (C#/Node) | Enterprise | Medium | 11/25 | 13/25 | **60/100** | 🔵 Backlog | Bot framework; Azure integration |
|
|
204
|
+
|
|
205
|
+
### Category Breakdown
|
|
206
|
+
|
|
207
|
+
#### Code Frameworks (Python) — 8 frameworks
|
|
208
|
+
**Why prioritize:** Largest AI/ML developer community, established patterns (decorators, async middleware)
|
|
209
|
+
|
|
210
|
+
**Top Picks:**
|
|
211
|
+
1. LangChain/LangGraph (92/100) — Market leader
|
|
212
|
+
2. CrewAI (88/100) — Multi-agent specialist
|
|
213
|
+
3. Microsoft AutoGen (86/100) — Enterprise backing
|
|
214
|
+
|
|
215
|
+
#### Code Frameworks (Node/TypeScript) — 6 frameworks
|
|
216
|
+
**Why prioritize:** Web3, DevTools, IDE extensions; TypeScript = enterprise adoption
|
|
217
|
+
|
|
218
|
+
**Top Picks:**
|
|
219
|
+
1. OpenClaw (95/100) — Already shipped
|
|
220
|
+
2. n8n (87/100) — Low-code + code hybrid
|
|
221
|
+
3. FlowiseAI (82/100) — Visual LangChain
|
|
222
|
+
|
|
223
|
+
#### IDE/Editor Extensions — 3 frameworks
|
|
224
|
+
**Why prioritize:** Developers use daily; massive potential reach
|
|
225
|
+
|
|
226
|
+
**Top Picks:**
|
|
227
|
+
1. Cursor IDE (91/100) — $500M ARR, 50% Fortune 500
|
|
228
|
+
2. Windsurf (74/100) — Growing Cascade competitor
|
|
229
|
+
3. VS Code extensions (future)
|
|
230
|
+
|
|
231
|
+
#### Low-Code/No-Code — 4 frameworks
|
|
232
|
+
**Why prioritize:** Non-technical users; simple HTTP integration; massive TAM
|
|
233
|
+
|
|
234
|
+
**Top Picks:**
|
|
235
|
+
1. n8n (87/100) — Open-source; 70+ AI nodes
|
|
236
|
+
2. Zapier AI (83/100) — 8000+ integrations
|
|
237
|
+
3. Make (73/100) — 500K+ users
|
|
238
|
+
|
|
239
|
+
#### Cloud Platforms — 3 frameworks
|
|
240
|
+
**Why prioritize:** Enterprise budgets; compliance requirements
|
|
241
|
+
|
|
242
|
+
**Top Picks:**
|
|
243
|
+
1. AWS Bedrock Agents (69/100) — Lambda hooks
|
|
244
|
+
2. Google AI Studio (65/100) — Guardrail APIs
|
|
245
|
+
3. Azure (future)
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Technical Architecture
|
|
250
|
+
|
|
251
|
+
### 1. Single Command, Multiple Entry Points
|
|
252
|
+
|
|
253
|
+
#### Node Ecosystem
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Option 1: Main CLI (detects framework)
|
|
257
|
+
npx @aporthq/aport-agent-guardrails
|
|
258
|
+
|
|
259
|
+
# Option 2: Framework-specific (SEO)
|
|
260
|
+
npx @aporthq/aport-agent-guardrails-langchain
|
|
261
|
+
npx @aporthq/aport-agent-guardrails-crewai
|
|
262
|
+
npx @aporthq/aport-agent-guardrails-n8n
|
|
263
|
+
|
|
264
|
+
# Option 3: Direct framework argument
|
|
265
|
+
npx @aporthq/aport-agent-guardrails --framework=langchain
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### Python Ecosystem
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Option 1: Main CLI
|
|
272
|
+
pip install aport-agent-guardrails
|
|
273
|
+
aport setup
|
|
274
|
+
|
|
275
|
+
# Option 2: Framework-specific (SEO)
|
|
276
|
+
pip install aport-agent-guardrails-langchain
|
|
277
|
+
aport-langchain setup
|
|
278
|
+
|
|
279
|
+
# Option 3: Python module
|
|
280
|
+
python -m aport_guardrails --framework=crewai
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 2. Package Strategy: Monorepo + SEO Packages
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
Repository Structure:
|
|
287
|
+
aport-agent-guardrails/
|
|
288
|
+
packages/
|
|
289
|
+
core/ # @aporthq/aport-agent-guardrails (main)
|
|
290
|
+
langchain/ # @aporthq/aport-agent-guardrails-langchain
|
|
291
|
+
crewai/ # @aporthq/aport-agent-guardrails-crewai
|
|
292
|
+
n8n/ # @aporthq/aport-agent-guardrails-n8n
|
|
293
|
+
python/
|
|
294
|
+
aport_guardrails/ # aport-agent-guardrails (main)
|
|
295
|
+
langchain_adapter/ # aport-agent-guardrails-langchain
|
|
296
|
+
crewai_adapter/ # aport-agent-guardrails-crewai
|
|
297
|
+
|
|
298
|
+
Strategy:
|
|
299
|
+
- Main package = full installer with all adapters
|
|
300
|
+
- Framework-specific = thin wrapper calling main package
|
|
301
|
+
- Benefits: SEO (appears in "langchain security"), discoverability
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 3. Shared Components (90% Reuse)
|
|
305
|
+
|
|
306
|
+
#### Core Shared Logic
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
bin/
|
|
310
|
+
lib/
|
|
311
|
+
common.sh # Shared bash functions
|
|
312
|
+
passport.sh # Passport creation wizard
|
|
313
|
+
config.sh # Config file management
|
|
314
|
+
allowlist.sh # Command allowlisting
|
|
315
|
+
aport-create-passport.sh # Main wizard (all frameworks use this)
|
|
316
|
+
aport-status.sh # Status checker (all frameworks)
|
|
317
|
+
|
|
318
|
+
src/
|
|
319
|
+
core/
|
|
320
|
+
evaluator.ts # API verification client (Node)
|
|
321
|
+
passport.ts # Passport schema validation
|
|
322
|
+
config.ts # Config management
|
|
323
|
+
evaluators/
|
|
324
|
+
api.ts # API mode evaluator
|
|
325
|
+
local.ts # Local bash evaluator wrapper
|
|
326
|
+
|
|
327
|
+
python/
|
|
328
|
+
aport_guardrails/
|
|
329
|
+
core/
|
|
330
|
+
evaluator.py # API verification client (Python)
|
|
331
|
+
passport.py # Passport schema validation
|
|
332
|
+
config.py # Config management
|
|
333
|
+
evaluators/
|
|
334
|
+
api.py # API mode evaluator
|
|
335
|
+
local.py # Local evaluator wrapper
|
|
336
|
+
|
|
337
|
+
external/ # Git submodules (shared policies)
|
|
338
|
+
aport-policies/
|
|
339
|
+
system.command.execute.v1/
|
|
340
|
+
mcp.tool.execute.v1/
|
|
341
|
+
[... other policy packs ...]
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### What's Shared (Same Code Everywhere)
|
|
345
|
+
|
|
346
|
+
1. **Passport Creation** (bin/aport-create-passport.sh)
|
|
347
|
+
- OAP v1.0 wizard
|
|
348
|
+
- JSON schema validation
|
|
349
|
+
- Hosted vs local choice
|
|
350
|
+
- Credential storage
|
|
351
|
+
|
|
352
|
+
2. **Policy Packs** (external/aport-policies/)
|
|
353
|
+
- JSON definitions
|
|
354
|
+
- SHIELD import
|
|
355
|
+
- Evaluation rules
|
|
356
|
+
- All frameworks reference same files
|
|
357
|
+
|
|
358
|
+
3. **Verification Logic** (`packages/core/src/core/evaluator.ts`, `python/aport_guardrails/core/evaluator.py`)
|
|
359
|
+
- **Both implemented.** Node: API + local bash, native fetch in sync path; Python: API + local. Request/response handling, error handling, config/passport loading.
|
|
360
|
+
|
|
361
|
+
4. **Config Management** (src/core/config.ts, python/aport_guardrails/core/config.py)
|
|
362
|
+
- Read/write config files
|
|
363
|
+
- Environment variable handling
|
|
364
|
+
- Credential management
|
|
365
|
+
|
|
366
|
+
#### What Diverges (Framework-Specific)
|
|
367
|
+
|
|
368
|
+
1. **Integration Hook** (where guardrail is called)
|
|
369
|
+
- LangChain: AsyncCallbackHandler
|
|
370
|
+
- CrewAI: Task decorator
|
|
371
|
+
- OpenClaw: before_tool_call plugin
|
|
372
|
+
- n8n: Custom HTTP node
|
|
373
|
+
|
|
374
|
+
2. **Config File Location**
|
|
375
|
+
- OpenClaw: ~/.openclaw/aport-config.yaml
|
|
376
|
+
- LangChain: .aport/config.yaml or ~/.aport/langchain/
|
|
377
|
+
- n8n: n8n credentials store
|
|
378
|
+
|
|
379
|
+
3. **Middleware/Decorator Pattern**
|
|
380
|
+
- Node: TypeScript classes
|
|
381
|
+
- Python: async decorators
|
|
382
|
+
- No-code: HTTP webhook
|
|
383
|
+
|
|
384
|
+
### 4. Verification Flow (Identical Logic, Different Wrappers)
|
|
385
|
+
|
|
386
|
+
```mermaid
|
|
387
|
+
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#f0f9ff','primaryTextColor':'#0c4a6e'}}}%%
|
|
388
|
+
sequenceDiagram
|
|
389
|
+
participant Framework as 🔧 Framework<br/>(LangChain/OpenClaw/n8n)
|
|
390
|
+
participant Adapter as 📦 APort Adapter<br/>(framework-specific)
|
|
391
|
+
participant Core as 🛡️ Core Evaluator<br/>(shared)
|
|
392
|
+
participant API as 🌐 APort API<br/>(or local script)
|
|
393
|
+
|
|
394
|
+
Framework->>Adapter: Tool call intercepted
|
|
395
|
+
Note over Adapter: Maps tool → OAP capability<br/>(framework-specific logic)
|
|
396
|
+
Adapter->>Core: evaluate(passport, policy, context)
|
|
397
|
+
Note over Core: Load config, prepare request<br/>(shared logic)
|
|
398
|
+
Core->>API: POST /api/verify
|
|
399
|
+
API-->>Core: Allow/Deny + reasons
|
|
400
|
+
Note over Core: Parse decision, log audit<br/>(shared logic)
|
|
401
|
+
Core-->>Adapter: Decision object
|
|
402
|
+
Note over Adapter: Format framework response<br/>(framework-specific)
|
|
403
|
+
Adapter-->>Framework: Allow or throw error
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Key Insight:** Only the adapter layer (10% of code) is framework-specific. 90% is shared.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## Repository Structure
|
|
411
|
+
|
|
412
|
+
### Current State (OpenClaw-focused)
|
|
413
|
+
|
|
414
|
+
```
|
|
415
|
+
aport-agent-guardrails/
|
|
416
|
+
├── bin/
|
|
417
|
+
│ ├── openclaw # OpenClaw-specific setup
|
|
418
|
+
│ ├── aport-create-passport.sh # Shared wizard
|
|
419
|
+
│ ├── aport-guardrail-bash.sh # Local evaluator
|
|
420
|
+
│ └── aport-guardrail-api.sh # API evaluator
|
|
421
|
+
├── src/
|
|
422
|
+
│ ├── evaluator.js # API client
|
|
423
|
+
│ └── server/ # Optional proxy
|
|
424
|
+
├── extensions/
|
|
425
|
+
│ └── openclaw-aport/ # OpenClaw plugin
|
|
426
|
+
├── external/ # Git submodules
|
|
427
|
+
│ ├── aport-spec/
|
|
428
|
+
│ └── aport-policies/
|
|
429
|
+
├── docs/
|
|
430
|
+
├── tests/
|
|
431
|
+
└── package.json
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Target State (Multi-Framework)
|
|
435
|
+
|
|
436
|
+
```
|
|
437
|
+
aport-agent-guardrails/
|
|
438
|
+
├── bin/
|
|
439
|
+
│ ├── agent-guardrails # 🆕 Main dispatcher
|
|
440
|
+
│ ├── lib/
|
|
441
|
+
│ │ ├── common.sh # 🆕 Shared bash functions
|
|
442
|
+
│ │ ├── passport.sh # 🆕 Refactored wizard logic
|
|
443
|
+
│ │ ├── config.sh # 🆕 Config helpers
|
|
444
|
+
│ │ └── templates/ # 🆕 Config templates
|
|
445
|
+
│ ├── frameworks/ # 🆕 Framework scripts
|
|
446
|
+
│ │ ├── openclaw.sh
|
|
447
|
+
│ │ ├── langchain.sh
|
|
448
|
+
│ │ ├── crewai.sh
|
|
449
|
+
│ │ └── n8n.sh
|
|
450
|
+
│ ├── aport-create-passport.sh # Now calls lib/passport.sh
|
|
451
|
+
│ ├── aport-guardrail-bash.sh # Local evaluator
|
|
452
|
+
│ └── aport-guardrail-api.sh # API evaluator
|
|
453
|
+
├── packages/ # 🆕 Monorepo packages
|
|
454
|
+
│ ├── core/ # @aporthq/aport-agent-guardrails
|
|
455
|
+
│ │ ├── src/
|
|
456
|
+
│ │ │ ├── index.ts # Main CLI entry point
|
|
457
|
+
│ │ │ ├── core/
|
|
458
|
+
│ │ │ │ ├── evaluator.ts # Shared evaluator
|
|
459
|
+
│ │ │ │ ├── passport.ts # Passport handling
|
|
460
|
+
│ │ │ │ └── config.ts # Config management
|
|
461
|
+
│ │ │ ├── frameworks/ # Framework adapters
|
|
462
|
+
│ │ │ │ ├── base.ts # Base adapter class
|
|
463
|
+
│ │ │ │ ├── openclaw.ts
|
|
464
|
+
│ │ │ │ ├── langchain.ts
|
|
465
|
+
│ │ │ │ └── n8n.ts
|
|
466
|
+
│ │ │ └── cli.ts # CLI logic
|
|
467
|
+
│ │ ├── package.json
|
|
468
|
+
│ │ └── tsconfig.json
|
|
469
|
+
│ ├── langchain/ # @aporthq/aport-agent-guardrails-langchain
|
|
470
|
+
│ │ ├── src/
|
|
471
|
+
│ │ │ ├── index.ts # Exports middleware
|
|
472
|
+
│ │ │ └── middleware.ts # LangChain callback
|
|
473
|
+
│ │ └── package.json # Thin wrapper → core
|
|
474
|
+
│ ├── crewai/ # @aporthq/aport-agent-guardrails-crewai
|
|
475
|
+
│ ├── n8n/ # @aporthq/aport-agent-guardrails-n8n
|
|
476
|
+
│ └── cursor/ # @aporthq/aport-agent-guardrails-cursor
|
|
477
|
+
├── python/ # 🆕 Python packages
|
|
478
|
+
│ ├── aport_guardrails/ # aport-agent-guardrails (main)
|
|
479
|
+
│ │ ├── __init__.py
|
|
480
|
+
│ │ ├── cli.py # Main CLI
|
|
481
|
+
│ │ ├── core/
|
|
482
|
+
│ │ │ ├── evaluator.py # Shared evaluator
|
|
483
|
+
│ │ │ ├── passport.py
|
|
484
|
+
│ │ │ └── config.py
|
|
485
|
+
│ │ ├── frameworks/
|
|
486
|
+
│ │ │ ├── base.py
|
|
487
|
+
│ │ │ ├── langchain.py
|
|
488
|
+
│ │ │ └── crewai.py
|
|
489
|
+
│ │ └── setup.py
|
|
490
|
+
│ ├── langchain_adapter/ # aport-agent-guardrails-langchain
|
|
491
|
+
│ │ ├── __init__.py # Exports decorator
|
|
492
|
+
│ │ ├── middleware.py # LangChain async callback
|
|
493
|
+
│ │ └── setup.py # Depends on aport-agent-guardrails
|
|
494
|
+
│ └── crewai_adapter/ # aport-agent-guardrails-crewai
|
|
495
|
+
├── integrations/ # 🆕 Framework-specific code
|
|
496
|
+
│ ├── openclaw/
|
|
497
|
+
│ │ └── extensions/ # Plugin code
|
|
498
|
+
│ ├── langchain/
|
|
499
|
+
│ │ ├── middleware.py # Python middleware
|
|
500
|
+
│ │ ├── middleware.ts # Node middleware
|
|
501
|
+
│ │ └── examples/
|
|
502
|
+
│ ├── crewai/
|
|
503
|
+
│ │ ├── decorator.py # Task decorator
|
|
504
|
+
│ │ └── examples/
|
|
505
|
+
│ ├── n8n/
|
|
506
|
+
│ │ ├── nodes/ # Custom nodes
|
|
507
|
+
│ │ └── credentials/
|
|
508
|
+
│ └── cursor/
|
|
509
|
+
│ └── extension/ # VS Code extension
|
|
510
|
+
├── extensions/
|
|
511
|
+
│ └── openclaw-aport/ # Keep for backward compat
|
|
512
|
+
├── external/ # Git submodules (unchanged)
|
|
513
|
+
│ ├── aport-spec/
|
|
514
|
+
│ └── aport-policies/
|
|
515
|
+
├── docs/
|
|
516
|
+
│ ├── frameworks/ # 🆕 Per-framework docs
|
|
517
|
+
│ │ ├── openclaw.md
|
|
518
|
+
│ │ ├── langchain.md
|
|
519
|
+
│ │ ├── crewai.md
|
|
520
|
+
│ │ └── n8n.md
|
|
521
|
+
│ └── FRAMEWORK_SUPPORT_PLAN.md # This doc
|
|
522
|
+
├── tests/
|
|
523
|
+
│ ├── core/ # Shared tests
|
|
524
|
+
│ └── frameworks/ # Framework-specific tests
|
|
525
|
+
├── lerna.json # 🆕 Monorepo management
|
|
526
|
+
├── package.json # Root package
|
|
527
|
+
└── pyproject.toml # 🆕 Python monorepo
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Key Design Decisions
|
|
531
|
+
|
|
532
|
+
1. **Monorepo Structure**
|
|
533
|
+
- ✅ **Pro:** Single source of truth; atomic changes across frameworks
|
|
534
|
+
- ✅ **Pro:** Shared CI/CD; easier version management
|
|
535
|
+
- ⚠️ **Con:** Larger repo size
|
|
536
|
+
- **Verdict:** Use Lerna (Node) + Poetry workspaces (Python)
|
|
537
|
+
|
|
538
|
+
2. **Framework-Specific Packages**
|
|
539
|
+
- ✅ **Pro:** SEO (show up in "langchain security" searches)
|
|
540
|
+
- ✅ **Pro:** Lighter install for single-framework users
|
|
541
|
+
- ✅ **Pro:** Clear entry point per framework
|
|
542
|
+
- **Implementation:** Thin wrappers that depend on core package
|
|
543
|
+
|
|
544
|
+
3. **Shared vs Separate Git Repos**
|
|
545
|
+
- ❌ **Separate:** Hard to keep passport wizard in sync
|
|
546
|
+
- ✅ **Single repo:** Easier to maintain shared logic
|
|
547
|
+
- **Verdict:** Single repo with clear boundaries
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
## Shared Components Strategy
|
|
552
|
+
|
|
553
|
+
### What Must Be Shared (Non-Negotiable)
|
|
554
|
+
|
|
555
|
+
#### 1. Passport Format (OAP v1.0)
|
|
556
|
+
**Why:** Interoperability. Same passport works across all frameworks.
|
|
557
|
+
|
|
558
|
+
**Shared Files:**
|
|
559
|
+
- `external/aport-spec/oap/oap-spec.md` (submodule)
|
|
560
|
+
- `bin/aport-create-passport.sh` (wizard)
|
|
561
|
+
- Schema validation in evaluator
|
|
562
|
+
|
|
563
|
+
**Framework Divergence:** Only storage location
|
|
564
|
+
- OpenClaw: `~/.openclaw/passport.json`
|
|
565
|
+
- LangChain: `~/.aport/langchain/passport.json`
|
|
566
|
+
- Hosted: No file (agent_id only)
|
|
567
|
+
|
|
568
|
+
#### 2. Policy Packs
|
|
569
|
+
**Why:** Consistency. Same policy definitions across frameworks.
|
|
570
|
+
|
|
571
|
+
**Shared Files:**
|
|
572
|
+
- `external/aport-policies/` (submodule)
|
|
573
|
+
- All JSON policy packs
|
|
574
|
+
- SHIELD import adapter
|
|
575
|
+
|
|
576
|
+
**Framework Divergence:** Policy → tool mapping
|
|
577
|
+
- OpenClaw: `exec.run` → `system.command.execute.v1`
|
|
578
|
+
- LangChain: `ShellTool` → `system.command.execute.v1`
|
|
579
|
+
- Different tool names, same policy
|
|
580
|
+
|
|
581
|
+
#### 3. Verification Logic
|
|
582
|
+
**Why:** Security. Core authorization logic must be identical.
|
|
583
|
+
|
|
584
|
+
**Shared Implementation:**
|
|
585
|
+
```typescript
|
|
586
|
+
// packages/core/src/core/evaluator.ts
|
|
587
|
+
export class Evaluator {
|
|
588
|
+
async verify(
|
|
589
|
+
passport: Passport,
|
|
590
|
+
policy: PolicyPack,
|
|
591
|
+
context: ToolContext
|
|
592
|
+
): Promise<Decision> {
|
|
593
|
+
// 1. Load config (API URL, agent_id)
|
|
594
|
+
// 2. Prepare request body
|
|
595
|
+
// 3. Call API or local script
|
|
596
|
+
// 4. Parse decision
|
|
597
|
+
// 5. Log audit trail
|
|
598
|
+
// 6. Return allow/deny
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
**Python Mirror:**
|
|
604
|
+
```python
|
|
605
|
+
# python/aport_guardrails/core/evaluator.py
|
|
606
|
+
class Evaluator:
|
|
607
|
+
async def verify(
|
|
608
|
+
self,
|
|
609
|
+
passport: Passport,
|
|
610
|
+
policy: PolicyPack,
|
|
611
|
+
context: ToolContext
|
|
612
|
+
) -> Decision:
|
|
613
|
+
# Identical logic to TypeScript
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
**Framework Divergence:** Only the wrapper
|
|
617
|
+
- LangChain: Calls evaluator from `AsyncCallbackHandler`
|
|
618
|
+
- OpenClaw: Calls evaluator from plugin
|
|
619
|
+
- n8n: Calls evaluator from HTTP node
|
|
620
|
+
|
|
621
|
+
### What Can Diverge (Framework-Specific)
|
|
622
|
+
|
|
623
|
+
#### 1. Integration Hook
|
|
624
|
+
**Why:** Each framework has different extension APIs.
|
|
625
|
+
|
|
626
|
+
**Examples:**
|
|
627
|
+
- **LangChain:** `AsyncCallbackHandler.on_tool_start()`
|
|
628
|
+
- **CrewAI:** `@task_wrapper` decorator
|
|
629
|
+
- **OpenClaw:** `before_tool_call` plugin
|
|
630
|
+
- **n8n:** Custom HTTP node
|
|
631
|
+
|
|
632
|
+
#### 2. Config File Format
|
|
633
|
+
**Why:** Match framework conventions.
|
|
634
|
+
|
|
635
|
+
**Examples:**
|
|
636
|
+
- **OpenClaw:** YAML in `~/.openclaw/aport-config.yaml`
|
|
637
|
+
- **LangChain:** JSON in `.aport/config.json`
|
|
638
|
+
- **n8n:** Stored in n8n credentials
|
|
639
|
+
|
|
640
|
+
**Shared Logic:** All configs have same fields, just different serialization.
|
|
641
|
+
|
|
642
|
+
#### 3. Installation Flow
|
|
643
|
+
**Why:** Different frameworks have different setup steps.
|
|
644
|
+
|
|
645
|
+
**Shared Steps (90%):**
|
|
646
|
+
1. Prompt for framework
|
|
647
|
+
2. Run passport wizard (shared)
|
|
648
|
+
3. Choose hosted or local (shared)
|
|
649
|
+
4. Write config (shared logic, different path)
|
|
650
|
+
5. Run smoke test (shared)
|
|
651
|
+
|
|
652
|
+
**Divergent Steps (10%):**
|
|
653
|
+
- OpenClaw: Install plugin via `~/.openclaw/config.yaml`
|
|
654
|
+
- LangChain: Add middleware import to user code
|
|
655
|
+
- n8n: Install custom node via UI
|
|
656
|
+
|
|
657
|
+
### Shared Utils Library
|
|
658
|
+
|
|
659
|
+
```typescript
|
|
660
|
+
// packages/core/src/utils/index.ts
|
|
661
|
+
export class SharedUtils {
|
|
662
|
+
// Config management
|
|
663
|
+
static loadConfig(path: string): Config { }
|
|
664
|
+
static writeConfig(path: string, config: Config): void { }
|
|
665
|
+
|
|
666
|
+
// Passport handling
|
|
667
|
+
static loadPassport(pathOrAgentId: string): Passport { }
|
|
668
|
+
static validatePassport(passport: Passport): ValidationResult { }
|
|
669
|
+
|
|
670
|
+
// Policy management
|
|
671
|
+
static loadPolicy(capability: string): PolicyPack { }
|
|
672
|
+
static mapToolToCapability(frameworkName: string, toolName: string): string { }
|
|
673
|
+
|
|
674
|
+
// Verification
|
|
675
|
+
static async callVerifyAPI(req: VerifyRequest): Promise<VerifyResponse> { }
|
|
676
|
+
static parseDecision(response: VerifyResponse): Decision { }
|
|
677
|
+
|
|
678
|
+
// Audit
|
|
679
|
+
static logDecision(decision: Decision, context: Context): void { }
|
|
680
|
+
}
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
**Why this works:**
|
|
684
|
+
- All frameworks import `@aporthq/aport-agent-guardrails-core`
|
|
685
|
+
- Framework adapters call `SharedUtils` methods
|
|
686
|
+
- Changes to shared logic update all frameworks instantly
|
|
687
|
+
|
|
688
|
+
---
|
|
689
|
+
|
|
690
|
+
## Per-Framework Integration Patterns
|
|
691
|
+
|
|
692
|
+
### Pattern Categories
|
|
693
|
+
|
|
694
|
+
#### Category A: Code Frameworks (Middleware/Decorator)
|
|
695
|
+
**Examples:** LangChain, CrewAI, AutoGen
|
|
696
|
+
|
|
697
|
+
**Integration Pattern:**
|
|
698
|
+
1. User imports middleware/decorator
|
|
699
|
+
2. Middleware wraps tool execution
|
|
700
|
+
3. Calls shared evaluator before tool runs
|
|
701
|
+
4. Returns allow/deny
|
|
702
|
+
|
|
703
|
+
**Code Example (LangChain):**
|
|
704
|
+
```python
|
|
705
|
+
from langchain.callbacks import AsyncCallbackHandler
|
|
706
|
+
from aport_guardrails.core import Evaluator
|
|
707
|
+
|
|
708
|
+
class APortGuardrailCallback(AsyncCallbackHandler):
|
|
709
|
+
def __init__(self, passport_path: str):
|
|
710
|
+
self.evaluator = Evaluator(passport_path)
|
|
711
|
+
|
|
712
|
+
async def on_tool_start(self, tool_name: str, input_str: str, **kwargs):
|
|
713
|
+
# Map tool name to OAP capability
|
|
714
|
+
capability = self._map_tool(tool_name)
|
|
715
|
+
|
|
716
|
+
# Load policy pack for capability
|
|
717
|
+
policy = self.evaluator.load_policy(capability)
|
|
718
|
+
|
|
719
|
+
# Prepare context
|
|
720
|
+
context = {"tool": tool_name, "input": input_str}
|
|
721
|
+
|
|
722
|
+
# Verify
|
|
723
|
+
decision = await self.evaluator.verify(
|
|
724
|
+
passport=self.passport,
|
|
725
|
+
policy=policy,
|
|
726
|
+
context=context
|
|
727
|
+
)
|
|
728
|
+
|
|
729
|
+
# Deny if not allowed
|
|
730
|
+
if not decision.allow:
|
|
731
|
+
raise PermissionError(decision.reasons[0].message)
|
|
732
|
+
|
|
733
|
+
# User code:
|
|
734
|
+
from langchain.agents import AgentExecutor
|
|
735
|
+
agent = AgentExecutor(
|
|
736
|
+
callbacks=[APortGuardrailCallback("~/.aport/passport.json")]
|
|
737
|
+
)
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
#### Category B: Plugin Architectures (Hooks)
|
|
741
|
+
**Examples:** OpenClaw, Cursor, Windsurf
|
|
742
|
+
|
|
743
|
+
**Integration Pattern:**
|
|
744
|
+
1. User installs plugin via framework's plugin manager
|
|
745
|
+
2. Plugin registers hooks (before_tool_call, etc.)
|
|
746
|
+
3. Hook calls shared evaluator
|
|
747
|
+
4. Hook returns block=true/false
|
|
748
|
+
|
|
749
|
+
**Code Example (OpenClaw - already implemented):**
|
|
750
|
+
```typescript
|
|
751
|
+
// extensions/openclaw-aport/src/index.ts
|
|
752
|
+
export async function before_tool_call(
|
|
753
|
+
tool: Tool,
|
|
754
|
+
params: ToolParams
|
|
755
|
+
): Promise<{ block: boolean; blockReason?: string }> {
|
|
756
|
+
const evaluator = new Evaluator(config.passportPath);
|
|
757
|
+
const decision = await evaluator.verify(passport, policy, params);
|
|
758
|
+
|
|
759
|
+
if (!decision.allow) {
|
|
760
|
+
return { block: true, blockReason: decision.reasons[0].message };
|
|
761
|
+
}
|
|
762
|
+
return { block: false };
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
#### Category C: Low-Code/No-Code (HTTP/Webhook)
|
|
767
|
+
**Examples:** n8n, Zapier, Make, FlowiseAI
|
|
768
|
+
|
|
769
|
+
**Integration Pattern:**
|
|
770
|
+
1. User adds HTTP request node before action
|
|
771
|
+
2. Node calls APort API (or self-hosted)
|
|
772
|
+
3. Workflow branches on allow/deny
|
|
773
|
+
4. Action executes only if allowed
|
|
774
|
+
|
|
775
|
+
**Visual Flow (n8n):**
|
|
776
|
+
```
|
|
777
|
+
[Trigger] → [HTTP: APort Verify] → [IF: allow?]
|
|
778
|
+
├─ Yes → [Action Node]
|
|
779
|
+
└─ No → [Send Error Notification]
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
**Implementation:**
|
|
783
|
+
- Provide n8n custom node (TypeScript)
|
|
784
|
+
- Node wraps evaluator.verify()
|
|
785
|
+
- User drags node into workflow
|
|
786
|
+
|
|
787
|
+
#### Category D: IDE Extensions
|
|
788
|
+
**Examples:** Cursor, Windsurf, VS Code, JetBrains
|
|
789
|
+
|
|
790
|
+
**Integration Pattern:**
|
|
791
|
+
1. Extension hooks into IDE's agent API
|
|
792
|
+
2. Before agent executes command, call evaluator
|
|
793
|
+
3. Show approval dialog if required
|
|
794
|
+
4. Block execution if denied
|
|
795
|
+
|
|
796
|
+
**Code Example (Cursor):**
|
|
797
|
+
```typescript
|
|
798
|
+
// Extension: cursor_aport.ts
|
|
799
|
+
import * as vscode from 'vscode';
|
|
800
|
+
import { Evaluator } from '@aporthq/aport-agent-guardrails-core';
|
|
801
|
+
|
|
802
|
+
export function activate(context: vscode.ExtensionContext) {
|
|
803
|
+
const evaluator = new Evaluator(/* config */);
|
|
804
|
+
|
|
805
|
+
// Hook into Cursor's agent API (pseudocode)
|
|
806
|
+
cursor.agent.onBeforeToolExecute(async (tool, params) => {
|
|
807
|
+
const decision = await evaluator.verify(passport, policy, params);
|
|
808
|
+
if (!decision.allow) {
|
|
809
|
+
vscode.window.showErrorMessage(decision.reasons[0].message);
|
|
810
|
+
return { cancel: true };
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Framework-Specific Details
|
|
817
|
+
|
|
818
|
+
#### 1. OpenClaw (Already Implemented) ✅
|
|
819
|
+
|
|
820
|
+
**Current Integration:**
|
|
821
|
+
- Plugin: `extensions/openclaw-aport/`
|
|
822
|
+
- Hook: `before_tool_call`
|
|
823
|
+
- Config: `~/.openclaw/aport-config.yaml`
|
|
824
|
+
- Status: Shipped, in production
|
|
825
|
+
|
|
826
|
+
**Refactor for Multi-Framework:**
|
|
827
|
+
- Move to `integrations/openclaw/`
|
|
828
|
+
- Extract shared logic to `packages/core/`
|
|
829
|
+
- Keep `bin/frameworks/openclaw.sh` as installer
|
|
830
|
+
|
|
831
|
+
#### 2. LangChain/LangGraph 🎯
|
|
832
|
+
|
|
833
|
+
**Integration:**
|
|
834
|
+
- Package: `aport-agent-guardrails-langchain` (Python)
|
|
835
|
+
- Hook: `AsyncCallbackHandler.on_tool_start`
|
|
836
|
+
- Config: `.aport/config.yaml` or `~/.aport/langchain/`
|
|
837
|
+
|
|
838
|
+
**Installation Flow:**
|
|
839
|
+
```bash
|
|
840
|
+
pip install aport-agent-guardrails-langchain
|
|
841
|
+
aport-langchain setup
|
|
842
|
+
# → Runs passport wizard
|
|
843
|
+
# → Writes .aport/config.yaml
|
|
844
|
+
# → Prints code snippet
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
**User Code:**
|
|
848
|
+
```python
|
|
849
|
+
from langchain.agents import initialize_agent
|
|
850
|
+
from aport_guardrails_langchain import APortCallback
|
|
851
|
+
|
|
852
|
+
agent = initialize_agent(
|
|
853
|
+
tools=tools,
|
|
854
|
+
llm=llm,
|
|
855
|
+
callbacks=[APortCallback()] # Auto-loads from .aport/config.yaml
|
|
856
|
+
)
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
**Effort:** Medium (3-5 days)
|
|
860
|
+
- AsyncCallbackHandler implementation
|
|
861
|
+
- Tool name → capability mapping
|
|
862
|
+
- Documentation + examples
|
|
863
|
+
|
|
864
|
+
#### 3. CrewAI 🎯
|
|
865
|
+
|
|
866
|
+
**Integration:**
|
|
867
|
+
- Package: `aport-agent-guardrails-crewai` (Python)
|
|
868
|
+
- Hook: Task decorator or crew-level middleware
|
|
869
|
+
- Config: `.aport/config.yaml`
|
|
870
|
+
|
|
871
|
+
**Installation Flow:**
|
|
872
|
+
```bash
|
|
873
|
+
pip install aport-agent-guardrails-crewai
|
|
874
|
+
aport-crewai setup
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
**User Code:**
|
|
878
|
+
```python
|
|
879
|
+
from crewai import Task, Crew
|
|
880
|
+
from aport_guardrails_crewai import with_aport_guardrail
|
|
881
|
+
|
|
882
|
+
@with_aport_guardrail
|
|
883
|
+
class MyTask(Task):
|
|
884
|
+
def execute(self, context):
|
|
885
|
+
# Task logic
|
|
886
|
+
pass
|
|
887
|
+
|
|
888
|
+
crew = Crew(tasks=[MyTask()])
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
**Effort:** Medium (3-5 days)
|
|
892
|
+
- Decorator implementation
|
|
893
|
+
- Hook into CrewAI task execution
|
|
894
|
+
- Multi-agent orchestration support
|
|
895
|
+
|
|
896
|
+
#### 4. Cursor IDE 🎯
|
|
897
|
+
|
|
898
|
+
**Integration:**
|
|
899
|
+
- Package: `@aporthq/aport-agent-guardrails-cursor` (Node)
|
|
900
|
+
- Hook: VS Code extension API
|
|
901
|
+
- Config: VS Code settings.json
|
|
902
|
+
|
|
903
|
+
**Installation Flow:**
|
|
904
|
+
```bash
|
|
905
|
+
npx @aporthq/aport-agent-guardrails cursor
|
|
906
|
+
# → Runs passport wizard
|
|
907
|
+
# → Installs VS Code extension
|
|
908
|
+
# → Configures extension settings
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
**User Experience:**
|
|
912
|
+
1. Cursor agent suggests command
|
|
913
|
+
2. Extension intercepts before execution
|
|
914
|
+
3. Shows inline approval UI if needed
|
|
915
|
+
4. Blocks if denied
|
|
916
|
+
|
|
917
|
+
**Effort:** Medium-High (5-7 days)
|
|
918
|
+
- VS Code extension boilerplate
|
|
919
|
+
- Hook into Cursor agent API (if available)
|
|
920
|
+
- UI for approval dialogs
|
|
921
|
+
- Marketplace submission
|
|
922
|
+
|
|
923
|
+
#### 5. n8n 🚀
|
|
924
|
+
|
|
925
|
+
**Integration:**
|
|
926
|
+
- Package: `@aporthq/aport-agent-guardrails-n8n` (Node)
|
|
927
|
+
- Hook: Custom node
|
|
928
|
+
- Config: n8n credentials store
|
|
929
|
+
|
|
930
|
+
**Installation Flow:**
|
|
931
|
+
```bash
|
|
932
|
+
npx @aporthq/aport-agent-guardrails n8n
|
|
933
|
+
# → Runs passport wizard
|
|
934
|
+
# → Installs custom node in ~/.n8n/custom/
|
|
935
|
+
# → Adds credentials type
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
**User Experience:**
|
|
939
|
+
1. User drags "APort Guardrail" node into workflow
|
|
940
|
+
2. Node configured with agent_id or passport path
|
|
941
|
+
3. Connect to action nodes
|
|
942
|
+
4. Workflow routes on allow/deny
|
|
943
|
+
|
|
944
|
+
**Effort:** Low-Medium (2-4 days)
|
|
945
|
+
- n8n custom node (TypeScript)
|
|
946
|
+
- Credentials type definition
|
|
947
|
+
- Documentation + example workflows
|
|
948
|
+
|
|
949
|
+
#### 6. Microsoft AutoGen 🚀
|
|
950
|
+
|
|
951
|
+
**Integration:**
|
|
952
|
+
- Package: `aport-agent-guardrails-autogen` (Python)
|
|
953
|
+
- Hook: UserProxyAgent tool execution wrapper
|
|
954
|
+
- Config: `.aport/config.yaml`
|
|
955
|
+
|
|
956
|
+
**Installation Flow:**
|
|
957
|
+
```bash
|
|
958
|
+
pip install aport-agent-guardrails-autogen
|
|
959
|
+
aport-autogen setup
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
**User Code:**
|
|
963
|
+
```python
|
|
964
|
+
from autogen import UserProxyAgent
|
|
965
|
+
from aport_guardrails_autogen import APortProxyAgent
|
|
966
|
+
|
|
967
|
+
agent = APortProxyAgent(
|
|
968
|
+
name="assistant",
|
|
969
|
+
# APort guardrail wraps tool execution
|
|
970
|
+
)
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
**Effort:** Medium (3-5 days)
|
|
974
|
+
- Wrap UserProxyAgent or extend
|
|
975
|
+
- Hook into multi-agent conversations
|
|
976
|
+
- Handle approval requests in chat
|
|
977
|
+
|
|
978
|
+
#### 7. Zapier AI Actions 🚀
|
|
979
|
+
|
|
980
|
+
**Integration:**
|
|
981
|
+
- Package: None (HTTP only)
|
|
982
|
+
- Hook: Webhook node
|
|
983
|
+
- Config: Zapier Code step
|
|
984
|
+
|
|
985
|
+
**Installation Flow:**
|
|
986
|
+
```
|
|
987
|
+
Documentation page with Zapier template:
|
|
988
|
+
1. Add "Webhooks by Zapier" action
|
|
989
|
+
2. POST to https://api.aport.io/api/verify
|
|
990
|
+
3. Body: { agentId, capability, context }
|
|
991
|
+
4. Branch on response.allow
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
**User Experience:**
|
|
995
|
+
1. User imports Zapier template
|
|
996
|
+
2. Configures agent_id in template
|
|
997
|
+
3. Template checks permission before action
|
|
998
|
+
4. Sends notification if denied
|
|
999
|
+
|
|
1000
|
+
**Effort:** Low (1-2 days)
|
|
1001
|
+
- Create Zapier template
|
|
1002
|
+
- Documentation
|
|
1003
|
+
- Video tutorial
|
|
1004
|
+
|
|
1005
|
+
---
|
|
1006
|
+
|
|
1007
|
+
## Implementation Roadmap
|
|
1008
|
+
|
|
1009
|
+
### Phase 1: Foundation (Weeks 1-2)
|
|
1010
|
+
|
|
1011
|
+
**Goal:** Refactor existing codebase for multi-framework support
|
|
1012
|
+
|
|
1013
|
+
**Tasks:**
|
|
1014
|
+
1. ✅ Create monorepo structure
|
|
1015
|
+
- Set up Lerna for Node packages
|
|
1016
|
+
- Set up Poetry for Python packages
|
|
1017
|
+
- Migrate existing code to `packages/core/`
|
|
1018
|
+
|
|
1019
|
+
2. ✅ Extract shared components
|
|
1020
|
+
- Refactor `bin/aport-create-passport.sh` → `bin/lib/passport.sh`
|
|
1021
|
+
- Create `bin/lib/common.sh` with shared functions
|
|
1022
|
+
- Extract evaluator to `packages/core/src/core/evaluator.ts`
|
|
1023
|
+
|
|
1024
|
+
3. ✅ Create framework dispatcher
|
|
1025
|
+
- Implement `bin/agent-guardrails` (main entry point)
|
|
1026
|
+
- Implement framework detection
|
|
1027
|
+
- Implement framework selection prompt
|
|
1028
|
+
|
|
1029
|
+
4. ✅ Migrate OpenClaw integration
|
|
1030
|
+
- Move to `integrations/openclaw/`
|
|
1031
|
+
- Create `bin/frameworks/openclaw.sh`
|
|
1032
|
+
- Ensure backward compatibility
|
|
1033
|
+
|
|
1034
|
+
**Deliverables:**
|
|
1035
|
+
- ✅ Monorepo structure
|
|
1036
|
+
- ✅ Shared components extracted
|
|
1037
|
+
- ✅ OpenClaw still works (no regression)
|
|
1038
|
+
- ✅ Foundation for new frameworks
|
|
1039
|
+
|
|
1040
|
+
### Phase 2: Priority Frameworks (Weeks 3-6)
|
|
1041
|
+
|
|
1042
|
+
**Goal:** Ship top 3 frameworks (LangChain, Cursor, CrewAI)
|
|
1043
|
+
|
|
1044
|
+
**Current status:** ✅ Delivered. Node packages (`packages/core`, `langchain`, `crewai`, `cursor`) are implemented with real evaluator and adapters; Jest tests for core and langchain; CI publishes to npm on tag. Python adapters and Cursor hook were already shipped. See [Implementation status (current vs plan)](#implementation-status-current-vs-plan) above.
|
|
1045
|
+
|
|
1046
|
+
#### Week 3: LangChain/LangGraph
|
|
1047
|
+
- ✅ Implement `packages/langchain/` (Node) — APortGuardrailCallback, Jest tests
|
|
1048
|
+
- ✅ Implement `python/langchain_adapter/` (Python)
|
|
1049
|
+
- Create `bin/frameworks/langchain.sh` installer
|
|
1050
|
+
- Write docs + examples
|
|
1051
|
+
- Test with real LangChain agents
|
|
1052
|
+
|
|
1053
|
+
#### Week 4: Cursor IDE
|
|
1054
|
+
- Implement `packages/cursor/` (VS Code extension)
|
|
1055
|
+
- Create `bin/frameworks/cursor.sh` installer
|
|
1056
|
+
- Build approval UI
|
|
1057
|
+
- Submit to VS Code marketplace
|
|
1058
|
+
- Write docs + video tutorial
|
|
1059
|
+
|
|
1060
|
+
#### Week 5: CrewAI
|
|
1061
|
+
- ✅ Implement `python/crewai_adapter/`
|
|
1062
|
+
- ✅ Implement `packages/crewai/` (Node) — beforeToolCall, withAPortGuardrail
|
|
1063
|
+
- ✅ Create `bin/frameworks/crewai.sh` installer
|
|
1064
|
+
- Test with multi-agent crews
|
|
1065
|
+
- Write docs + examples
|
|
1066
|
+
|
|
1067
|
+
#### Week 6: Testing & Launch Prep
|
|
1068
|
+
- E2E tests for all frameworks
|
|
1069
|
+
- CI/CD for multi-package publishing
|
|
1070
|
+
- Update main README
|
|
1071
|
+
- Launch announcement prep
|
|
1072
|
+
|
|
1073
|
+
**Deliverables:**
|
|
1074
|
+
- ✅ LangChain integration (Python + Node)
|
|
1075
|
+
- ✅ Cursor IDE integration (hook + Node package)
|
|
1076
|
+
- ✅ CrewAI integration (Python + Node)
|
|
1077
|
+
- ✅ TypeScript core (evaluator, config, passport) with Jest
|
|
1078
|
+
- ✅ Documentation for all three; release CI
|
|
1079
|
+
- ✅ Ready to announce
|
|
1080
|
+
|
|
1081
|
+
### Phase 3: Low-Code/No-Code (Weeks 7-8)
|
|
1082
|
+
|
|
1083
|
+
**Goal:** Ship n8n, Zapier, FlowiseAI
|
|
1084
|
+
|
|
1085
|
+
#### Week 7: n8n
|
|
1086
|
+
- Implement `packages/n8n/` custom node
|
|
1087
|
+
- Create credentials type
|
|
1088
|
+
- Write installer + docs
|
|
1089
|
+
- Submit to n8n community nodes
|
|
1090
|
+
|
|
1091
|
+
#### Week 8: Zapier + FlowiseAI
|
|
1092
|
+
- Create Zapier template
|
|
1093
|
+
- Write HTTP integration guide
|
|
1094
|
+
- FlowiseAI custom node (similar to n8n)
|
|
1095
|
+
- Video tutorials for all three
|
|
1096
|
+
|
|
1097
|
+
**Deliverables:**
|
|
1098
|
+
- ✅ n8n custom node
|
|
1099
|
+
- ✅ Zapier template
|
|
1100
|
+
- ✅ FlowiseAI integration
|
|
1101
|
+
- ✅ No-code user docs
|
|
1102
|
+
|
|
1103
|
+
### Phase 4: Expand & Optimize (Weeks 9-12)
|
|
1104
|
+
|
|
1105
|
+
**Goal:** Add remaining high-value frameworks, optimize shared code
|
|
1106
|
+
|
|
1107
|
+
#### Week 9: Microsoft AutoGen + Semantic Kernel
|
|
1108
|
+
- AutoGen Python adapter
|
|
1109
|
+
- Semantic Kernel (Python + C#)
|
|
1110
|
+
|
|
1111
|
+
#### Week 10: LlamaIndex + OpenAI Agents SDK
|
|
1112
|
+
- LlamaIndex callback hooks
|
|
1113
|
+
- OpenAI Agents SDK (when stable)
|
|
1114
|
+
|
|
1115
|
+
#### Week 11: Goose + IDE Extensions
|
|
1116
|
+
- Goose CLI integration
|
|
1117
|
+
- Windsurf extension
|
|
1118
|
+
|
|
1119
|
+
#### Week 12: Optimization & Cloud Frameworks
|
|
1120
|
+
- Performance optimization
|
|
1121
|
+
- AWS Bedrock integration
|
|
1122
|
+
- Google AI Studio integration
|
|
1123
|
+
|
|
1124
|
+
**Deliverables:**
|
|
1125
|
+
- ✅ 10+ frameworks supported
|
|
1126
|
+
- ✅ Performance benchmarks
|
|
1127
|
+
- ✅ Cloud platform integrations
|
|
1128
|
+
|
|
1129
|
+
### Phase 5: Long Tail & Enterprise (Ongoing)
|
|
1130
|
+
|
|
1131
|
+
**Goal:** Cover backlog frameworks, enterprise features
|
|
1132
|
+
|
|
1133
|
+
**Backlog (as needed):**
|
|
1134
|
+
- IronClaw, PicoClaw, NanoClaw (OpenClaw forks)
|
|
1135
|
+
- Temporal Workflows
|
|
1136
|
+
- Slack/Teams bot frameworks
|
|
1137
|
+
- AutoGPT (if resurgence)
|
|
1138
|
+
- Langroid
|
|
1139
|
+
- Home automation (Home Assistant)
|
|
1140
|
+
- Custom serverless (Lambda, Cloud Run)
|
|
1141
|
+
|
|
1142
|
+
**Enterprise Features:**
|
|
1143
|
+
- SSO integration
|
|
1144
|
+
- Team policy management
|
|
1145
|
+
- Compliance reporting dashboards
|
|
1146
|
+
- Custom policy pack builder UI
|
|
1147
|
+
|
|
1148
|
+
---
|
|
1149
|
+
|
|
1150
|
+
## Success Metrics
|
|
1151
|
+
|
|
1152
|
+
### Adoption Metrics (Primary)
|
|
1153
|
+
|
|
1154
|
+
| Metric | Target (6 months) | Measurement |
|
|
1155
|
+
|--------|-------------------|-------------|
|
|
1156
|
+
| **Total Installs** | 10,000+ | npm + pip downloads |
|
|
1157
|
+
| **Active Frameworks** | 10+ | Frameworks with >100 installs each |
|
|
1158
|
+
| **GitHub Stars** | 5,000+ | Main repo stars |
|
|
1159
|
+
| **Community Contributions** | 50+ | PRs from external contributors |
|
|
1160
|
+
|
|
1161
|
+
### Framework-Specific Metrics
|
|
1162
|
+
|
|
1163
|
+
| Framework | Target Installs (6mo) | Target Conversion | Notes |
|
|
1164
|
+
|-----------|----------------------|-------------------|-------|
|
|
1165
|
+
| OpenClaw | 2,000 | 1% of 200K stars | Already shipped; growth mode |
|
|
1166
|
+
| LangChain | 3,000 | 0.1% of 3M+ devs | Largest TAM; competitive |
|
|
1167
|
+
| Cursor | 5,000 | 0.5% of 1M users | High-value users; enterprise |
|
|
1168
|
+
| CrewAI | 1,000 | 5% of 20K stars | Strong community; multi-agent focus |
|
|
1169
|
+
| n8n | 1,500 | 3% of 50K stars | Low-code; visual appeal |
|
|
1170
|
+
| AutoGen | 800 | 2% of 35K stars | Enterprise; Microsoft ecosystem |
|
|
1171
|
+
|
|
1172
|
+
### Technical Metrics (Secondary)
|
|
1173
|
+
|
|
1174
|
+
| Metric | Target | Purpose |
|
|
1175
|
+
|--------|--------|---------|
|
|
1176
|
+
| **Shared Code %** | 85%+ | Measure reusability |
|
|
1177
|
+
| **Install Success Rate** | 95%+ | Measure setup quality |
|
|
1178
|
+
| **Verification Latency** | <300ms p99 | Measure performance |
|
|
1179
|
+
| **Framework Add Time** | <3 days | Measure scalability |
|
|
1180
|
+
|
|
1181
|
+
### Business Metrics (Long-Term)
|
|
1182
|
+
|
|
1183
|
+
| Metric | Target (12 months) | Impact |
|
|
1184
|
+
|--------|-------------------|--------|
|
|
1185
|
+
| **API Mode Adoption** | 40% | Drives APort Cloud revenue |
|
|
1186
|
+
| **Enterprise Leads** | 100+ | Cursor/Cursor users → enterprise deals |
|
|
1187
|
+
| **Marketplace Presence** | Top 10 in 3 categories | SEO + discoverability |
|
|
1188
|
+
|
|
1189
|
+
---
|
|
1190
|
+
|
|
1191
|
+
## Open Questions
|
|
1192
|
+
|
|
1193
|
+
### Technical Questions
|
|
1194
|
+
|
|
1195
|
+
1. **Q: Should we support framework version pinning?**
|
|
1196
|
+
- **Context:** LangChain v0.1 vs v0.2 have different APIs
|
|
1197
|
+
- **Options:**
|
|
1198
|
+
- A) Maintain adapters for multiple versions
|
|
1199
|
+
- B) Only support latest stable
|
|
1200
|
+
- C) Let users specify version in config
|
|
1201
|
+
- **Recommendation:** B for MVP, A for popular frameworks as needed
|
|
1202
|
+
|
|
1203
|
+
2. **Q: How to handle framework-specific config schemas?**
|
|
1204
|
+
- **Context:** Each framework has different tool names, params
|
|
1205
|
+
- **Options:**
|
|
1206
|
+
- A) Monolithic config file (all frameworks)
|
|
1207
|
+
- B) Per-framework config files
|
|
1208
|
+
- C) Shared config + framework overrides
|
|
1209
|
+
- **Recommendation:** C (shared passport + framework-specific tool mappings)
|
|
1210
|
+
|
|
1211
|
+
3. **Q: Local evaluator in Python?**
|
|
1212
|
+
- **Context:** Currently bash-only
|
|
1213
|
+
- **Options:**
|
|
1214
|
+
- A) Keep bash, call from Python via subprocess
|
|
1215
|
+
- B) Rewrite in Python
|
|
1216
|
+
- C) Both (Python for speed, bash for portability)
|
|
1217
|
+
- **Recommendation:** A for MVP, B if performance matters
|
|
1218
|
+
|
|
1219
|
+
### Product Questions
|
|
1220
|
+
|
|
1221
|
+
4. **Q: Pricing for framework-specific packages?**
|
|
1222
|
+
- **Context:** Core package free, but framework packages?
|
|
1223
|
+
- **Options:**
|
|
1224
|
+
- A) All free (maximize adoption)
|
|
1225
|
+
- B) Free for top 5, paid for enterprise frameworks
|
|
1226
|
+
- C) Free packages, paid for hosted features
|
|
1227
|
+
- **Recommendation:** C (aligns with current model)
|
|
1228
|
+
|
|
1229
|
+
5. **Q: Support matrix?**
|
|
1230
|
+
- **Context:** Which framework versions do we guarantee support for?
|
|
1231
|
+
- **Proposal:**
|
|
1232
|
+
- Tier 1 (OpenClaw, LangChain, Cursor): 100% coverage, <24h support
|
|
1233
|
+
- Tier 2 (CrewAI, AutoGen, n8n): Best-effort, community support
|
|
1234
|
+
- Tier 3 (Backlog): Community-driven, no official support
|
|
1235
|
+
- **Recommendation:** Publish support tiers clearly
|
|
1236
|
+
|
|
1237
|
+
### Strategic Questions
|
|
1238
|
+
|
|
1239
|
+
6. **Q: Open-source everything?**
|
|
1240
|
+
- **Context:** Framework adapters could be copied by competitors
|
|
1241
|
+
- **Options:**
|
|
1242
|
+
- A) Open-source all (maximize adoption)
|
|
1243
|
+
- B) Core open, enterprise adapters closed
|
|
1244
|
+
- C) Delay source release (binary-only npm packages)
|
|
1245
|
+
- **Recommendation:** A (network effects > IP protection)
|
|
1246
|
+
|
|
1247
|
+
7. **Q: Certification program for community adapters?**
|
|
1248
|
+
- **Context:** Community might build adapters for niche frameworks
|
|
1249
|
+
- **Proposal:**
|
|
1250
|
+
- "APort Certified" badge for adapters that pass test suite
|
|
1251
|
+
- Listed in official docs
|
|
1252
|
+
- Quality signal for users
|
|
1253
|
+
- **Recommendation:** Yes, implement in Phase 4
|
|
1254
|
+
|
|
1255
|
+
8. **Q: Should we build a marketplace?**
|
|
1256
|
+
- **Context:** Policy packs + framework adapters could be a marketplace
|
|
1257
|
+
- **Vision:**
|
|
1258
|
+
- Users browse "LangChain + AWS Bedrock" integrations
|
|
1259
|
+
- Creators publish custom policy packs
|
|
1260
|
+
- APort takes 20% cut
|
|
1261
|
+
- **Recommendation:** Phase 5+ (after product-market fit)
|
|
1262
|
+
|
|
1263
|
+
---
|
|
1264
|
+
|
|
1265
|
+
## Appendix A: Example Installation Flows
|
|
1266
|
+
|
|
1267
|
+
### Example 1: LangChain Developer
|
|
1268
|
+
|
|
1269
|
+
```bash
|
|
1270
|
+
# Install
|
|
1271
|
+
pip install aport-agent-guardrails-langchain
|
|
1272
|
+
|
|
1273
|
+
# Setup
|
|
1274
|
+
aport-langchain setup
|
|
1275
|
+
|
|
1276
|
+
# Interactive prompts:
|
|
1277
|
+
# → Using LangChain framework
|
|
1278
|
+
# → Create new passport or use existing? [New]
|
|
1279
|
+
# → Agent name: my-research-assistant
|
|
1280
|
+
# → Owner: john@example.com
|
|
1281
|
+
# → Capabilities: [x] Command Execution [x] Web Search [ ] File Write
|
|
1282
|
+
# → Allowed commands: git, npm, python, curl
|
|
1283
|
+
# → Verification mode: API (recommended) or Local? [API]
|
|
1284
|
+
# → ✅ Passport created: ap_abc123...
|
|
1285
|
+
# → ✅ Config written to ~/.aport/langchain/config.yaml
|
|
1286
|
+
# → ✅ Test verification: PASSED
|
|
1287
|
+
|
|
1288
|
+
# Copy this code to your agent:
|
|
1289
|
+
"""
|
|
1290
|
+
from langchain.agents import initialize_agent
|
|
1291
|
+
from aport_guardrails_langchain import APortCallback
|
|
1292
|
+
|
|
1293
|
+
agent = initialize_agent(
|
|
1294
|
+
tools=tools,
|
|
1295
|
+
llm=llm,
|
|
1296
|
+
callbacks=[APortCallback()]
|
|
1297
|
+
)
|
|
1298
|
+
"""
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
### Example 2: n8n User (No-Code)
|
|
1302
|
+
|
|
1303
|
+
```bash
|
|
1304
|
+
# Install custom node
|
|
1305
|
+
npx @aporthq/aport-agent-guardrails n8n
|
|
1306
|
+
|
|
1307
|
+
# Interactive prompts:
|
|
1308
|
+
# → Using n8n framework
|
|
1309
|
+
# → Create new passport or use existing? [Use existing]
|
|
1310
|
+
# → Paste agent_id from aport.io: ap_abc123...
|
|
1311
|
+
# → Verification mode: API (required for n8n)
|
|
1312
|
+
# → ✅ Custom node installed to ~/.n8n/custom/
|
|
1313
|
+
# → ✅ Restart n8n to see "APort Guardrail" node
|
|
1314
|
+
#
|
|
1315
|
+
# Next steps:
|
|
1316
|
+
# 1. Restart n8n (systemctl restart n8n)
|
|
1317
|
+
# 2. Open n8n editor
|
|
1318
|
+
# 3. Drag "APort Guardrail" node before any action
|
|
1319
|
+
# 4. Configure node with agent_id: ap_abc123...
|
|
1320
|
+
# 5. Connect to action nodes (Branch on allow/deny)
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
### Example 3: Cursor IDE Developer
|
|
1324
|
+
|
|
1325
|
+
```bash
|
|
1326
|
+
# Install extension
|
|
1327
|
+
npx @aporthq/aport-agent-guardrails cursor
|
|
1328
|
+
|
|
1329
|
+
# Interactive prompts:
|
|
1330
|
+
# → Using Cursor IDE framework
|
|
1331
|
+
# → Create new passport or use existing? [New]
|
|
1332
|
+
# → Agent name: cursor-coding-assistant
|
|
1333
|
+
# → Owner: jane@example.com
|
|
1334
|
+
# → Capabilities: [x] Command Execution [x] File Write
|
|
1335
|
+
# → Allowed commands: git, node, npm, yarn, pnpm
|
|
1336
|
+
# → Verification mode: API (recommended) or Local? [API]
|
|
1337
|
+
# → ✅ Passport created: ap_def456...
|
|
1338
|
+
# → ✅ VS Code extension installed
|
|
1339
|
+
# → ✅ Extension configured in settings.json
|
|
1340
|
+
#
|
|
1341
|
+
# Restart Cursor IDE to activate guardrails.
|
|
1342
|
+
#
|
|
1343
|
+
# What happens next:
|
|
1344
|
+
# - Cursor agent suggests commands
|
|
1345
|
+
# - APort verifies before execution
|
|
1346
|
+
# - Denied commands show inline error
|
|
1347
|
+
# - Approved commands execute normally
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
---
|
|
1351
|
+
|
|
1352
|
+
## Appendix B: Architecture Diagrams
|
|
1353
|
+
|
|
1354
|
+
### System Architecture (All Frameworks)
|
|
1355
|
+
|
|
1356
|
+
```mermaid
|
|
1357
|
+
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#f0f9ff','primaryTextColor':'#0c4a6e'}}}%%
|
|
1358
|
+
graph TB
|
|
1359
|
+
subgraph "Developer Machine"
|
|
1360
|
+
subgraph "Code Frameworks"
|
|
1361
|
+
LC[LangChain Agent]
|
|
1362
|
+
CC[CrewAI Agent]
|
|
1363
|
+
AG[AutoGen Agent]
|
|
1364
|
+
end
|
|
1365
|
+
|
|
1366
|
+
subgraph "IDE Frameworks"
|
|
1367
|
+
CU[Cursor IDE]
|
|
1368
|
+
WS[Windsurf]
|
|
1369
|
+
end
|
|
1370
|
+
|
|
1371
|
+
subgraph "Low-Code Frameworks"
|
|
1372
|
+
N8[n8n Workflow]
|
|
1373
|
+
ZA[Zapier Workflow]
|
|
1374
|
+
end
|
|
1375
|
+
|
|
1376
|
+
subgraph "APort Adapters"
|
|
1377
|
+
ALC[LangChain Adapter]
|
|
1378
|
+
ACC[CrewAI Adapter]
|
|
1379
|
+
AAG[AutoGen Adapter]
|
|
1380
|
+
ACU[Cursor Extension]
|
|
1381
|
+
AN8[n8n Custom Node]
|
|
1382
|
+
end
|
|
1383
|
+
|
|
1384
|
+
subgraph "Shared Core"
|
|
1385
|
+
EVAL[Evaluator<br/>src/core/evaluator.ts]
|
|
1386
|
+
PASS[Passport Loader]
|
|
1387
|
+
POL[Policy Loader]
|
|
1388
|
+
end
|
|
1389
|
+
|
|
1390
|
+
LC --> ALC
|
|
1391
|
+
CC --> ACC
|
|
1392
|
+
AG --> AAG
|
|
1393
|
+
CU --> ACU
|
|
1394
|
+
N8 --> AN8
|
|
1395
|
+
|
|
1396
|
+
ALC --> EVAL
|
|
1397
|
+
ACC --> EVAL
|
|
1398
|
+
AAG --> EVAL
|
|
1399
|
+
ACU --> EVAL
|
|
1400
|
+
AN8 --> EVAL
|
|
1401
|
+
|
|
1402
|
+
EVAL --> PASS
|
|
1403
|
+
EVAL --> POL
|
|
1404
|
+
end
|
|
1405
|
+
|
|
1406
|
+
subgraph "External"
|
|
1407
|
+
API[APort API<br/>api.aport.io]
|
|
1408
|
+
BASH[Local Evaluator<br/>bash script]
|
|
1409
|
+
end
|
|
1410
|
+
|
|
1411
|
+
EVAL -->|API mode| API
|
|
1412
|
+
EVAL -->|Local mode| BASH
|
|
1413
|
+
|
|
1414
|
+
subgraph "Policy Sources"
|
|
1415
|
+
SPEC[aport-spec<br/>submodule]
|
|
1416
|
+
POLS[aport-policies<br/>submodule]
|
|
1417
|
+
SHIELD[SHIELD.md feeds]
|
|
1418
|
+
end
|
|
1419
|
+
|
|
1420
|
+
POL --> POLS
|
|
1421
|
+
POL --> SHIELD
|
|
1422
|
+
|
|
1423
|
+
style LC fill:#3b82f6,color:#fff
|
|
1424
|
+
style CC fill:#3b82f6,color:#fff
|
|
1425
|
+
style AG fill:#3b82f6,color:#fff
|
|
1426
|
+
style CU fill:#8b5cf6,color:#fff
|
|
1427
|
+
style WS fill:#8b5cf6,color:#fff
|
|
1428
|
+
style N8 fill:#10b981,color:#fff
|
|
1429
|
+
style ZA fill:#10b981,color:#fff
|
|
1430
|
+
style EVAL fill:#f59e0b,color:#fff
|
|
1431
|
+
style API fill:#ef4444,color:#fff
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
### Package Dependency Graph
|
|
1435
|
+
|
|
1436
|
+
```mermaid
|
|
1437
|
+
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#f0f9ff','primaryTextColor':'#0c4a6e'}}}%%
|
|
1438
|
+
graph LR
|
|
1439
|
+
subgraph "Published Packages"
|
|
1440
|
+
CORE[@aporthq/aport-agent-guardrails<br/>Core package]
|
|
1441
|
+
LC[@aporthq/aport-agent-guardrails-langchain<br/>LangChain adapter]
|
|
1442
|
+
CC[@aporthq/aport-agent-guardrails-crewai<br/>CrewAI adapter]
|
|
1443
|
+
N8[@aporthq/aport-agent-guardrails-n8n<br/>n8n adapter]
|
|
1444
|
+
CU[@aporthq/aport-agent-guardrails-cursor<br/>Cursor adapter]
|
|
1445
|
+
end
|
|
1446
|
+
|
|
1447
|
+
subgraph "Python Packages"
|
|
1448
|
+
PYCORE[aport-agent-guardrails<br/>Core package]
|
|
1449
|
+
PYLC[aport-agent-guardrails-langchain<br/>LangChain adapter]
|
|
1450
|
+
PYCC[aport-agent-guardrails-crewai<br/>CrewAI adapter]
|
|
1451
|
+
end
|
|
1452
|
+
|
|
1453
|
+
LC --> CORE
|
|
1454
|
+
CC --> CORE
|
|
1455
|
+
N8 --> CORE
|
|
1456
|
+
CU --> CORE
|
|
1457
|
+
|
|
1458
|
+
PYLC --> PYCORE
|
|
1459
|
+
PYCC --> PYCORE
|
|
1460
|
+
|
|
1461
|
+
style CORE fill:#f59e0b,color:#fff
|
|
1462
|
+
style PYCORE fill:#f59e0b,color:#fff
|
|
1463
|
+
style LC fill:#3b82f6,color:#fff
|
|
1464
|
+
style CC fill:#3b82f6,color:#fff
|
|
1465
|
+
style N8 fill:#10b981,color:#fff
|
|
1466
|
+
style CU fill:#8b5cf6,color:#fff
|
|
1467
|
+
style PYLC fill:#3b82f6,color:#fff
|
|
1468
|
+
style PYCC fill:#3b82f6,color:#fff
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
### Verification Flow (Shared Logic)
|
|
1472
|
+
|
|
1473
|
+
```mermaid
|
|
1474
|
+
%%{init: {'theme':'base', 'themeVariables': {'primaryColor':'#f0f9ff','primaryTextColor':'#0c4a6e'}}}%%
|
|
1475
|
+
sequenceDiagram
|
|
1476
|
+
participant F as Framework<br/>(LangChain/OpenClaw/n8n)
|
|
1477
|
+
participant A as Adapter<br/>(framework-specific)
|
|
1478
|
+
participant E as Evaluator<br/>(shared core)
|
|
1479
|
+
participant C as Config<br/>(shared)
|
|
1480
|
+
participant V as Verifier<br/>(API or local)
|
|
1481
|
+
|
|
1482
|
+
F->>A: Tool call intercepted
|
|
1483
|
+
activate A
|
|
1484
|
+
Note over A: Map tool → capability<br/>(framework-specific)
|
|
1485
|
+
A->>E: verify(capability, context)
|
|
1486
|
+
activate E
|
|
1487
|
+
E->>C: Load passport + policy
|
|
1488
|
+
activate C
|
|
1489
|
+
C-->>E: passport, policy
|
|
1490
|
+
deactivate C
|
|
1491
|
+
E->>V: POST /verify (or bash call)
|
|
1492
|
+
activate V
|
|
1493
|
+
V-->>E: Decision (allow/deny + reasons)
|
|
1494
|
+
deactivate V
|
|
1495
|
+
Note over E: Log audit trail<br/>(shared)
|
|
1496
|
+
E-->>A: Decision object
|
|
1497
|
+
deactivate E
|
|
1498
|
+
Note over A: Format response<br/>(framework-specific)
|
|
1499
|
+
A-->>F: Allow or throw error
|
|
1500
|
+
deactivate A
|
|
1501
|
+
```
|
|
1502
|
+
|
|
1503
|
+
---
|
|
1504
|
+
|
|
1505
|
+
## Appendix C: Code Reuse Analysis
|
|
1506
|
+
|
|
1507
|
+
### Current State (OpenClaw-only)
|
|
1508
|
+
|
|
1509
|
+
```
|
|
1510
|
+
Total Lines of Code: ~3,500
|
|
1511
|
+
- Shared: ~2,000 (57%)
|
|
1512
|
+
- Passport wizard: 500
|
|
1513
|
+
- Policy packs: 800 (external submodule)
|
|
1514
|
+
- Evaluator: 400
|
|
1515
|
+
- Config: 300
|
|
1516
|
+
- OpenClaw-specific: ~1,500 (43%)
|
|
1517
|
+
- Plugin: 800
|
|
1518
|
+
- Installer: 500
|
|
1519
|
+
- Tests: 200
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
### Target State (10 Frameworks)
|
|
1523
|
+
|
|
1524
|
+
```
|
|
1525
|
+
Total Lines of Code: ~12,000 (estimate)
|
|
1526
|
+
- Shared: ~5,000 (42% of total, but 90% reuse)
|
|
1527
|
+
- Core evaluator: 1,200
|
|
1528
|
+
- Passport wizard: 700
|
|
1529
|
+
- Config management: 600
|
|
1530
|
+
- Policy packs: 1,500 (external)
|
|
1531
|
+
- Utils: 1,000
|
|
1532
|
+
- Framework-specific: ~7,000 (58% of total, 10% unique per framework)
|
|
1533
|
+
- 10 frameworks × 700 LOC each
|
|
1534
|
+
- Each framework:
|
|
1535
|
+
- Adapter: 400 LOC
|
|
1536
|
+
- Installer: 200 LOC
|
|
1537
|
+
- Tests: 100 LOC
|
|
1538
|
+
|
|
1539
|
+
Reuse Factor: 90% of logic shared across frameworks
|
|
1540
|
+
Maintenance Burden: +700 LOC per new framework (2-3 days)
|
|
1541
|
+
```
|
|
1542
|
+
|
|
1543
|
+
### Maintenance Cost Projection
|
|
1544
|
+
|
|
1545
|
+
**Adding a new framework (after initial setup):**
|
|
1546
|
+
- Adapter implementation: 1-2 days
|
|
1547
|
+
- Installer script: 0.5 days
|
|
1548
|
+
- Documentation + examples: 0.5 days
|
|
1549
|
+
- Testing: 0.5-1 day
|
|
1550
|
+
- **Total: 2.5-4 days per framework**
|
|
1551
|
+
|
|
1552
|
+
**Updating shared logic (benefits all frameworks):**
|
|
1553
|
+
- Passport format change: 1 update = 10 frameworks updated
|
|
1554
|
+
- Policy pack addition: 1 addition = 10 frameworks gain capability
|
|
1555
|
+
- Security fix: 1 fix = 10 frameworks patched
|
|
1556
|
+
|
|
1557
|
+
**ROI of Shared Architecture:**
|
|
1558
|
+
- **Without shared code:** 10 frameworks × 10 days each = 100 days
|
|
1559
|
+
- **With shared code:** 20 days (core) + 10 × 3 days (adapters) = 50 days
|
|
1560
|
+
- **Savings: 50%** for initial implementation
|
|
1561
|
+
- **Ongoing: 90% savings** for updates
|
|
1562
|
+
|
|
1563
|
+
---
|
|
1564
|
+
|
|
1565
|
+
## Appendix D: FAQ for Framework Maintainers
|
|
1566
|
+
|
|
1567
|
+
### Q: I maintain [Framework X]. How do I add APort support?
|
|
1568
|
+
|
|
1569
|
+
**A:** We'd love to collaborate! Two options:
|
|
1570
|
+
|
|
1571
|
+
1. **We build it:** Open an issue at [github.com/aporthq/aport-agent-guardrails](https://github.com/aporthq/aport-agent-guardrails) with:
|
|
1572
|
+
- Framework name + repo link
|
|
1573
|
+
- Extension API docs (how to hook into tool execution)
|
|
1574
|
+
- Estimated user base
|
|
1575
|
+
- We'll prioritize based on our roadmap
|
|
1576
|
+
|
|
1577
|
+
2. **You build it:** Follow our [Adapter Development Guide](docs/ADAPTER_DEVELOPMENT_GUIDE.md):
|
|
1578
|
+
- Fork the repo
|
|
1579
|
+
- Copy `packages/core/src/frameworks/base.ts` as template
|
|
1580
|
+
- Implement 4 methods: `detect()`, `install()`, `verify()`, `test()`
|
|
1581
|
+
- Submit PR with tests + docs
|
|
1582
|
+
- We'll review and publish
|
|
1583
|
+
|
|
1584
|
+
### Q: Does adding APort slow down my framework?
|
|
1585
|
+
|
|
1586
|
+
**A:** Negligible impact:
|
|
1587
|
+
- **API mode:** <300ms p99 (network call)
|
|
1588
|
+
- **Local mode:** <50ms p99 (bash script)
|
|
1589
|
+
- **Overhead:** Adds one HTTP request or subprocess call per tool
|
|
1590
|
+
- **Comparison:** LLM inference (1-5s) >> APort verification (0.05-0.3s)
|
|
1591
|
+
|
|
1592
|
+
### Q: Can users disable it?
|
|
1593
|
+
|
|
1594
|
+
**A:** Yes, multiple ways:
|
|
1595
|
+
- **Framework level:** User doesn't install APort adapter = no guardrails
|
|
1596
|
+
- **Config level:** Set `APORT_ENABLED=false` in config
|
|
1597
|
+
- **Policy level:** Use `allowed_commands: ["*"]` + no blocked patterns = allow all
|
|
1598
|
+
|
|
1599
|
+
APort is opt-in by design.
|
|
1600
|
+
|
|
1601
|
+
### Q: What data does APort see?
|
|
1602
|
+
|
|
1603
|
+
**A:** Only what's needed for authorization:
|
|
1604
|
+
- **API mode:** Tool name, parameters, passport (user's identity)
|
|
1605
|
+
- **NOT sent:** LLM prompts, responses, conversation history, API keys
|
|
1606
|
+
- **Retention:** Decisions logged for audit (30 days default, configurable)
|
|
1607
|
+
|
|
1608
|
+
See [Privacy Policy](https://aport.io/privacy).
|
|
1609
|
+
|
|
1610
|
+
### Q: Is this open-source?
|
|
1611
|
+
|
|
1612
|
+
**A:** Mostly:
|
|
1613
|
+
- **Framework adapters:** Apache 2.0 (open-source)
|
|
1614
|
+
- **Core evaluator:** Apache 2.0 (open-source)
|
|
1615
|
+
- **APort API:** Proprietary (but self-hostable with enterprise license)
|
|
1616
|
+
|
|
1617
|
+
Users can use local mode (100% open-source) or API mode (freemium SaaS).
|
|
1618
|
+
|
|
1619
|
+
---
|
|
1620
|
+
|
|
1621
|
+
## Document Changelog
|
|
1622
|
+
|
|
1623
|
+
| Version | Date | Changes |
|
|
1624
|
+
|---------|------|---------|
|
|
1625
|
+
| 2.0 | 2026-02-17 | Complete rewrite: rankings, architecture, roadmap |
|
|
1626
|
+
| 0.1 | 2026-02-17 | Initial draft (OpenClaw-focused) |
|
|
1627
|
+
|
|
1628
|
+
---
|
|
1629
|
+
|
|
1630
|
+
**Status:** Living Document (will be updated as we ship frameworks)
|
|
1631
|
+
|
|
1632
|
+
**Feedback:** Open an issue at [github.com/aporthq/aport-agent-guardrails/issues](https://github.com/aporthq/aport-agent-guardrails/issues) with "Framework Support:" prefix
|
|
1633
|
+
|
|
1634
|
+
**Contribute:** See [CONTRIBUTING.md](../CONTRIBUTING.md) for adapter development guide
|
|
1635
|
+
|
|
1636
|
+
---
|
|
1637
|
+
|
|
1638
|
+
<p align="center">
|
|
1639
|
+
<em>One command. Any framework. Pre-action authorization for all AI agents.</em>
|
|
1640
|
+
</p>
|