aiperture 0.3.0__tar.gz
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.
- aiperture-0.3.0/.github/workflows/publish.yml +29 -0
- aiperture-0.3.0/.gitignore +15 -0
- aiperture-0.3.0/.mcp.json +9 -0
- aiperture-0.3.0/CLAUDE.md +254 -0
- aiperture-0.3.0/LICENSE +190 -0
- aiperture-0.3.0/PKG-INFO +570 -0
- aiperture-0.3.0/README.md +534 -0
- aiperture-0.3.0/SECURITY_FIXES_PLAN.md +1987 -0
- aiperture-0.3.0/TODO.md +567 -0
- aiperture-0.3.0/aiperture/__init__.py +3 -0
- aiperture-0.3.0/aiperture/api/__init__.py +5 -0
- aiperture-0.3.0/aiperture/api/app.py +44 -0
- aiperture-0.3.0/aiperture/api/auth.py +46 -0
- aiperture-0.3.0/aiperture/api/routes/__init__.py +0 -0
- aiperture-0.3.0/aiperture/api/routes/artifacts.py +181 -0
- aiperture-0.3.0/aiperture/api/routes/audit.py +137 -0
- aiperture-0.3.0/aiperture/api/routes/config.py +36 -0
- aiperture-0.3.0/aiperture/api/routes/health.py +57 -0
- aiperture-0.3.0/aiperture/api/routes/intelligence.py +41 -0
- aiperture-0.3.0/aiperture/api/routes/metrics.py +13 -0
- aiperture-0.3.0/aiperture/api/routes/permissions.py +240 -0
- aiperture-0.3.0/aiperture/cli.py +179 -0
- aiperture-0.3.0/aiperture/config.py +220 -0
- aiperture-0.3.0/aiperture/db/__init__.py +5 -0
- aiperture-0.3.0/aiperture/db/engine.py +75 -0
- aiperture-0.3.0/aiperture/mcp_server.py +767 -0
- aiperture-0.3.0/aiperture/metrics.py +80 -0
- aiperture-0.3.0/aiperture/models/__init__.py +45 -0
- aiperture-0.3.0/aiperture/models/artifact.py +68 -0
- aiperture-0.3.0/aiperture/models/audit.py +38 -0
- aiperture-0.3.0/aiperture/models/intelligence.py +24 -0
- aiperture-0.3.0/aiperture/models/permission.py +83 -0
- aiperture-0.3.0/aiperture/models/verdict.py +175 -0
- aiperture-0.3.0/aiperture/permissions/__init__.py +47 -0
- aiperture-0.3.0/aiperture/permissions/challenge.py +214 -0
- aiperture-0.3.0/aiperture/permissions/crowd.py +162 -0
- aiperture-0.3.0/aiperture/permissions/engine.py +915 -0
- aiperture-0.3.0/aiperture/permissions/explainer.py +114 -0
- aiperture-0.3.0/aiperture/permissions/intelligence.py +242 -0
- aiperture-0.3.0/aiperture/permissions/learning.py +292 -0
- aiperture-0.3.0/aiperture/permissions/presets.py +167 -0
- aiperture-0.3.0/aiperture/permissions/resource.py +105 -0
- aiperture-0.3.0/aiperture/permissions/risk.py +572 -0
- aiperture-0.3.0/aiperture/permissions/scope_normalize.py +232 -0
- aiperture-0.3.0/aiperture/permissions/similarity.py +281 -0
- aiperture-0.3.0/aiperture/plugins.py +157 -0
- aiperture-0.3.0/aiperture/stores/__init__.py +6 -0
- aiperture-0.3.0/aiperture/stores/artifact_store.py +209 -0
- aiperture-0.3.0/aiperture/stores/audit_store.py +233 -0
- aiperture-0.3.0/claude/plans/2026-03-01-intelligent-permission-verdicts.md +653 -0
- aiperture-0.3.0/docs/plugins.md +116 -0
- aiperture-0.3.0/docs/setup-claude-code.md +283 -0
- aiperture-0.3.0/docs/setup-openclaw.md +301 -0
- aiperture-0.3.0/examples/openclaw.json +14 -0
- aiperture-0.3.0/examples/openclaw_demo.py +275 -0
- aiperture-0.3.0/examples/openclaw_setup.sh +61 -0
- aiperture-0.3.0/examples/system_prompt.md +81 -0
- aiperture-0.3.0/main.py +19 -0
- aiperture-0.3.0/pyproject.toml +71 -0
- aiperture-0.3.0/tests/__init__.py +0 -0
- aiperture-0.3.0/tests/conftest.py +30 -0
- aiperture-0.3.0/tests/test_api.py +683 -0
- aiperture-0.3.0/tests/test_artifacts.py +72 -0
- aiperture-0.3.0/tests/test_auth.py +158 -0
- aiperture-0.3.0/tests/test_challenge.py +198 -0
- aiperture-0.3.0/tests/test_circuit_breaker.py +148 -0
- aiperture-0.3.0/tests/test_cli.py +218 -0
- aiperture-0.3.0/tests/test_compliance.py +189 -0
- aiperture-0.3.0/tests/test_config_api.py +169 -0
- aiperture-0.3.0/tests/test_content_awareness.py +195 -0
- aiperture-0.3.0/tests/test_crowd.py +128 -0
- aiperture-0.3.0/tests/test_explainer.py +64 -0
- aiperture-0.3.0/tests/test_hash_chain.py +116 -0
- aiperture-0.3.0/tests/test_intelligence.py +108 -0
- aiperture-0.3.0/tests/test_mcp.py +792 -0
- aiperture-0.3.0/tests/test_metrics.py +94 -0
- aiperture-0.3.0/tests/test_nonce_persistence.py +89 -0
- aiperture-0.3.0/tests/test_openclaw_integration.py +554 -0
- aiperture-0.3.0/tests/test_permissions.py +257 -0
- aiperture-0.3.0/tests/test_plugins.py +230 -0
- aiperture-0.3.0/tests/test_presets.py +82 -0
- aiperture-0.3.0/tests/test_rate_limiting.py +77 -0
- aiperture-0.3.0/tests/test_resource.py +86 -0
- aiperture-0.3.0/tests/test_revocation.py +167 -0
- aiperture-0.3.0/tests/test_risk.py +95 -0
- aiperture-0.3.0/tests/test_risk_deep.py +217 -0
- aiperture-0.3.0/tests/test_rubber_stamping.py +113 -0
- aiperture-0.3.0/tests/test_scope_normalize.py +111 -0
- aiperture-0.3.0/tests/test_sensitive_paths.py +84 -0
- aiperture-0.3.0/tests/test_session_risk.py +101 -0
- aiperture-0.3.0/tests/test_similarity.py +440 -0
- aiperture-0.3.0/tests/test_temporal_decay.py +77 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
|
|
22
|
+
- name: Install build tools
|
|
23
|
+
run: pip install build
|
|
24
|
+
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: python -m build
|
|
27
|
+
|
|
28
|
+
- name: Publish to PyPI
|
|
29
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# CLAUDE.md — AIperture
|
|
2
|
+
|
|
3
|
+
## What This Is
|
|
4
|
+
|
|
5
|
+
AIperture is the permission layer for AI agents. It controls what passes through.
|
|
6
|
+
|
|
7
|
+
It sits between enterprises and whatever AI agent runtimes they use (Claude Code, OpenAI Agents SDK, Google ADK, LangChain, etc.). It does not run agents. It does not make LLM calls. It does not care which model is on the other end.
|
|
8
|
+
|
|
9
|
+
Three core capabilities:
|
|
10
|
+
1. **Permission Engine** — Deterministic RBAC + ReBAC + learning from human decisions
|
|
11
|
+
2. **Artifact Persistence** — SHA-256 verified, immutable audit trail of every agent output
|
|
12
|
+
3. **Intelligence** — Cross-org anonymized signals with differential privacy
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
cd aiperture
|
|
18
|
+
source .venv312/bin/activate
|
|
19
|
+
aiperture configure # interactive setup wizard (writes .aiperture.env)
|
|
20
|
+
aiperture serve # start API server at localhost:8100
|
|
21
|
+
aiperture mcp-serve # start MCP server on stdio
|
|
22
|
+
aiperture init-db # initialize database
|
|
23
|
+
python -m pytest tests/ -v # run all tests
|
|
24
|
+
python examples/openclaw_demo.py # run learning loop demo
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Tech Stack
|
|
28
|
+
|
|
29
|
+
- **Python 3.12** + **FastAPI** + **SQLModel** + **SQLite** (default)
|
|
30
|
+
- **MCP** (Model Context Protocol) for Claude Code integration
|
|
31
|
+
- Zero LLM calls anywhere in the codebase
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
aiperture/
|
|
37
|
+
├── aiperture/
|
|
38
|
+
│ ├── api/ # FastAPI routes
|
|
39
|
+
│ │ ├── auth.py # Bearer token auth (AIPERTURE_API_KEY) + plugin auth_backend
|
|
40
|
+
│ │ ├── app.py # FastAPI app factory + plugin loading
|
|
41
|
+
│ │ └── routes/
|
|
42
|
+
│ │ ├── permissions.py # /permissions/* endpoints
|
|
43
|
+
│ │ ├── artifacts.py # /artifacts/* endpoints
|
|
44
|
+
│ │ ├── audit.py # /audit/* endpoints + /audit/verify-chain (hash chain integrity)
|
|
45
|
+
│ │ ├── config.py # /config endpoints (GET + PATCH runtime tuning)
|
|
46
|
+
│ │ ├── health.py # /health endpoint (DB + plugin health checkers)
|
|
47
|
+
│ │ ├── intelligence.py # /intelligence/* endpoints
|
|
48
|
+
│ │ └── metrics.py # /metrics endpoint (Prometheus format)
|
|
49
|
+
│ ├── db/ # Database engine (SQLite/Postgres) + plugin db_engine
|
|
50
|
+
│ ├── models/ # SQLModel table definitions + dataclasses
|
|
51
|
+
│ │ ├── permission.py # Permission, PermissionLog, TaskPermission, ConsumedNonce
|
|
52
|
+
│ │ ├── artifact.py # Artifact with SHA-256 hashing
|
|
53
|
+
│ │ ├── audit.py # AuditEvent (append-only, hash-chained)
|
|
54
|
+
│ │ ├── intelligence.py # GlobalPermissionStat (cross-org DP stats)
|
|
55
|
+
│ │ └── verdict.py # PermissionVerdict, RiskAssessment, OrgSignal, etc.
|
|
56
|
+
│ ├── permissions/ # Permission engine + learning + intelligence
|
|
57
|
+
│ │ ├── engine.py # RBAC + ReBAC + auto-learning + rate limiting + risk budget + rubber-stamping + temporal decay + metrics
|
|
58
|
+
│ │ ├── learning.py # Pattern detection from decision history
|
|
59
|
+
│ │ ├── intelligence.py # Cross-org DP intelligence + plugin intelligence_backend
|
|
60
|
+
│ │ ├── risk.py # OWASP-based risk classification + plugin risk_rules
|
|
61
|
+
│ │ ├── crowd.py # Org-level crowd signals
|
|
62
|
+
│ │ ├── similarity.py # Taxonomy-based pattern similarity
|
|
63
|
+
│ │ ├── explainer.py # Human-readable action explanations
|
|
64
|
+
│ │ ├── resource.py # Scope → resource normalization
|
|
65
|
+
│ │ ├── challenge.py # HMAC challenge-response + DB-persisted nonce replay protection
|
|
66
|
+
│ │ ├── presets.py # Bootstrap presets (developer, readonly, minimal)
|
|
67
|
+
│ │ └── scope_normalize.py # Scope normalization for learning
|
|
68
|
+
│ ├── stores/ # Persistence layer
|
|
69
|
+
│ │ ├── artifact_store.py
|
|
70
|
+
│ │ └── audit_store.py # Hash-chained writes + verify_chain() + plugin audit_hook
|
|
71
|
+
│ ├── metrics.py # Prometheus counters, histograms, gauges for observability
|
|
72
|
+
│ ├── plugins.py # Plugin registry + Protocol definitions (open-core)
|
|
73
|
+
│ ├── config.py # Settings via AIPERTURE_* env vars + plugin config
|
|
74
|
+
│ ├── cli.py # CLI entry point (serve | mcp-serve | init-db | configure | bootstrap | revoke)
|
|
75
|
+
│ └── mcp_server.py # MCP server (14 tools, stdio transport) + plugin mcp_tools
|
|
76
|
+
├── docs/
|
|
77
|
+
│ └── plugins.md # Plugin development guide
|
|
78
|
+
├── examples/
|
|
79
|
+
│ ├── openclaw_demo.py # Dual-mode demo (real OpenClaw or simulated)
|
|
80
|
+
│ ├── openclaw.json # OpenClaw config wiring AIperture as MCP server
|
|
81
|
+
│ ├── openclaw_setup.sh # Setup script for isolated demo workspace
|
|
82
|
+
│ └── system_prompt.md # System prompt for AIperture-gated agent
|
|
83
|
+
├── tests/
|
|
84
|
+
├── main.py # Server entry point
|
|
85
|
+
└── pyproject.toml
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## API Endpoints
|
|
89
|
+
|
|
90
|
+
### Health (`/health`)
|
|
91
|
+
- `GET /health` — Database connectivity probe (returns `healthy` or `degraded` with details)
|
|
92
|
+
|
|
93
|
+
### Permissions (`/permissions`)
|
|
94
|
+
- `POST /permissions/check` — Check if an action is permitted (with optional enrichment)
|
|
95
|
+
- `POST /permissions/record` — Record a human's decision (for learning)
|
|
96
|
+
- `POST /permissions/grant` — Grant task-scoped permission (ReBAC)
|
|
97
|
+
- `GET /permissions/patterns` — View learned patterns
|
|
98
|
+
- `GET /permissions/stats` — Decision statistics
|
|
99
|
+
- `GET /permissions/similar` — Find similar permission patterns
|
|
100
|
+
- `GET /permissions/explain` — Get human-readable action explanation with risk
|
|
101
|
+
|
|
102
|
+
### Artifacts (`/artifacts`)
|
|
103
|
+
- `POST /artifacts/store` — Store with automatic SHA-256 verification
|
|
104
|
+
- `GET /artifacts/costs/summary` — Cost breakdown by provider/model
|
|
105
|
+
- `GET /artifacts/task/{task_id}` — List artifacts by task
|
|
106
|
+
- `GET /artifacts/{id}` — Retrieve artifact
|
|
107
|
+
- `POST /artifacts/{id}/verify` — Re-verify integrity
|
|
108
|
+
|
|
109
|
+
### Audit (`/audit`)
|
|
110
|
+
- `GET /audit/events` — Query with filters
|
|
111
|
+
- `GET /audit/events/{id}` — Single event detail
|
|
112
|
+
- `GET /audit/entity/{type}/{id}` — Entity history
|
|
113
|
+
- `GET /audit/count` — Total event count
|
|
114
|
+
- `GET /audit/verify-chain` — Verify hash chain integrity (tamper detection)
|
|
115
|
+
|
|
116
|
+
### Config (`/config`)
|
|
117
|
+
- `GET /config` — Current tunable settings and descriptions
|
|
118
|
+
- `PATCH /config` — Update tunable settings at runtime (persists to `.aiperture.env`)
|
|
119
|
+
|
|
120
|
+
### Intelligence (`/intelligence`)
|
|
121
|
+
- `GET /intelligence/global-signal` — Cross-org DP-protected permission signal
|
|
122
|
+
|
|
123
|
+
### Metrics (`/metrics`)
|
|
124
|
+
- `GET /metrics` — Prometheus-compatible metrics (counters, histograms, gauges)
|
|
125
|
+
|
|
126
|
+
## MCP Tools
|
|
127
|
+
|
|
128
|
+
14 tools exposed via MCP (stdio transport):
|
|
129
|
+
|
|
130
|
+
### Permission tools
|
|
131
|
+
- `check_permission` — Enriched permission check with risk, explanation, crowd signal, HMAC challenge
|
|
132
|
+
- `approve_action` / `deny_action` — Record human decisions (requires valid HMAC challenge token)
|
|
133
|
+
- `explain_action` — Human-readable explanation with risk assessment
|
|
134
|
+
- `get_permission_patterns` — View learned auto-approve/deny patterns
|
|
135
|
+
|
|
136
|
+
### Compliance tools
|
|
137
|
+
- `report_tool_execution` — Report that an agent executed a tool (for compliance tracking)
|
|
138
|
+
- `get_compliance_report` — Compare executions vs permission checks to find compliance gaps
|
|
139
|
+
|
|
140
|
+
### Revocation tools
|
|
141
|
+
- `revoke_permission_pattern` — Revoke auto-approval for a (tool, action, scope) pattern
|
|
142
|
+
- `list_auto_approved_patterns` — List all patterns currently being auto-approved
|
|
143
|
+
|
|
144
|
+
### Artifact tools
|
|
145
|
+
- `store_artifact` / `verify_artifact` — SHA-256 verified artifact storage
|
|
146
|
+
- `get_cost_summary` — Token and cost breakdown
|
|
147
|
+
|
|
148
|
+
### Audit & config tools
|
|
149
|
+
- `get_audit_trail` — Compliance audit trail
|
|
150
|
+
- `get_config` — Read tunable configuration settings
|
|
151
|
+
|
|
152
|
+
## Security Architecture
|
|
153
|
+
|
|
154
|
+
1. **HTTP API authentication** — Optional bearer token auth via `AIPERTURE_API_KEY` env var. When set, all HTTP API routes require `Authorization: Bearer <key>`. MCP server (stdio) is unaffected. When unset, open access for local development.
|
|
155
|
+
2. **HMAC challenge-response** — Every non-ALLOW verdict includes a cryptographic challenge token (HMAC-SHA256 signed with a server-side secret in `challenge.py`). `approve_action`/`deny_action` require a valid challenge, preventing agents from self-approving without human involvement.
|
|
156
|
+
3. **No config mutation via MCP** — The `update_config` MCP tool was removed. Agents can read config (`get_config`) but cannot lower thresholds. Config changes require the CLI wizard or HTTP API.
|
|
157
|
+
4. **Deep risk analysis** — `risk.py` unpacks shell wrappers (`bash -c`, `sudo`), pipe-to-exec (`curl | sh`), scripting oneliners (`python -c "os.system(...)"`), and `find -exec`. Inner command risk is what counts. Recursion depth is capped at 5 levels to prevent DoS. HIGH/CRITICAL actions are never auto-approved.
|
|
158
|
+
5. **Fail-closed circuit breaker** — If the database becomes unavailable during a permission check, the engine fails closed (defaults to deny). The `GET /health` endpoint probes database connectivity.
|
|
159
|
+
6. **Compliance tracking** — `report_tool_execution` records tool executions. `get_compliance_report` compares executions against permission checks to find unchecked tool usage.
|
|
160
|
+
7. **Bootstrap presets** — `presets.py` provides `developer` (75 patterns), `readonly` (48), `minimal` (0) to reduce first-session approval fatigue.
|
|
161
|
+
8. **Content awareness** — `content_hash` parameter in `check_permission` differentiates writes by content. Session cache key is a 5-tuple: `(tool, action, scope, session_id, content_hash)`.
|
|
162
|
+
9. **Scope normalization** — `scope_normalize.py` groups command variants (e.g., `git log --oneline -5` → `git log*`) for faster learning.
|
|
163
|
+
10. **Revocation** — `engine.revoke_pattern()` soft-deletes decisions via `revoked_at` timestamp. Excluded from learning, crowd signals, and pattern detection. Preserved for audit.
|
|
164
|
+
11. **Rate limiting** — Per-session rate limiter (`AIPERTURE_RATE_LIMIT_PER_MINUTE`, default 200). In-memory counter with 1-minute sliding window. Exceeding returns DENY with `rate_limit_exceeded` factor. Prevents DoS and permission enumeration.
|
|
165
|
+
12. **Cumulative session risk scoring** — Tracks cumulative risk per session (`AIPERTURE_SESSION_RISK_BUDGET`, default 50.0). When exhausted, all subsequent checks escalate to ASK regardless of learned patterns. Prevents "death by a thousand cuts" data exfiltration.
|
|
166
|
+
13. **Sensitive path protection** — `AIPERTURE_SENSITIVE_PATTERNS` (configurable glob list) skips scope normalization for sensitive files (secrets, credentials, keys, .env). Requires exact-match learning instead of wildcard patterns.
|
|
167
|
+
14. **Temporal pattern decay** — `AIPERTURE_PATTERN_MAX_AGE_DAYS` (default 90). Auto-learned patterns expire if the most recent human decision is older than the configured age. Forces periodic re-confirmation.
|
|
168
|
+
15. **Rubber-stamping detection** — Tracks approval velocity per `(session_id, tool, action)`. If 5+ approvals within 60s (configurable), flags with `:rapid` suffix. Rapid decisions are excluded from learning engine calculations.
|
|
169
|
+
16. **HMAC nonce persistence** — `ConsumedNonce` SQLModel table persists used nonces to database. In-memory cache as first-level check, DB as fallback. Closes replay attack window across server restarts.
|
|
170
|
+
17. **Hash-chained audit trail** — Each `AuditEvent` stores `previous_hash` and `event_hash` (SHA-256). `GET /audit/verify-chain` walks the chain to detect tampering, deletions, or reordering. SOC 2 compliant.
|
|
171
|
+
18. **Prometheus metrics** — `GET /metrics` endpoint exposes `aiperture_permission_checks_total`, `aiperture_permission_check_duration_seconds`, cache hit/miss counters, auto-approve/deny counters, rate limit counters, risk budget exhaustion counters, and audit metrics.
|
|
172
|
+
|
|
173
|
+
## Architecture Rules
|
|
174
|
+
|
|
175
|
+
1. **Zero LLM calls.** Every decision is deterministic — glob matching, database queries, statistics.
|
|
176
|
+
2. **Append-only audit.** AuditEvents are never deleted or modified.
|
|
177
|
+
3. **SHA-256 everything.** Every artifact is hashed on storage. Integrity re-verifiable at any time.
|
|
178
|
+
4. **Fire-and-forget logging.** Audit/logging never breaks the primary operation.
|
|
179
|
+
5. **Provider agnostic.** The `runtime_id` field tracks which external runtime produced an artifact, but AIperture never calls any LLM.
|
|
180
|
+
6. **Differential privacy.** Cross-org intelligence uses RAPPOR-style local DP. True decisions never leave the org.
|
|
181
|
+
|
|
182
|
+
## Configuration
|
|
183
|
+
|
|
184
|
+
Config precedence (highest first):
|
|
185
|
+
1. Shell env vars (`export AIPERTURE_*=...`) — always win
|
|
186
|
+
2. `.aiperture.env` file values (written by `aiperture configure` or `PATCH /config`)
|
|
187
|
+
3. Defaults in Settings class
|
|
188
|
+
|
|
189
|
+
Run `aiperture configure` for an interactive setup wizard, or use `PATCH /config` at runtime.
|
|
190
|
+
|
|
191
|
+
### All settings (`AIPERTURE_*` env vars)
|
|
192
|
+
|
|
193
|
+
| Variable | Default | Tunable? | Description |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `AIPERTURE_DB_BACKEND` | `sqlite` | No | `sqlite` or `postgres` |
|
|
196
|
+
| `AIPERTURE_DB_PATH` | `aiperture.db` | No | SQLite file path |
|
|
197
|
+
| `AIPERTURE_POSTGRES_URL` | `` | No | Postgres connection URL |
|
|
198
|
+
| `AIPERTURE_PERMISSION_LEARNING_ENABLED` | `true` | Yes | Auto-learn from human decisions |
|
|
199
|
+
| `AIPERTURE_PERMISSION_LEARNING_MIN_DECISIONS` | `10` | Yes | Min decisions before auto-deciding |
|
|
200
|
+
| `AIPERTURE_AUTO_APPROVE_THRESHOLD` | `0.95` | Yes | Approval rate to auto-approve |
|
|
201
|
+
| `AIPERTURE_AUTO_DENY_THRESHOLD` | `0.05` | Yes | Approval rate to auto-deny |
|
|
202
|
+
| `AIPERTURE_INTELLIGENCE_ENABLED` | `false` | Yes | Enable cross-org DP intelligence (opt-in) |
|
|
203
|
+
| `AIPERTURE_INTELLIGENCE_EPSILON` | `1.0` | Yes | DP noise level (higher = less private) |
|
|
204
|
+
| `AIPERTURE_INTELLIGENCE_MIN_ORGS` | `5` | Yes | Min orgs before surfacing global signal |
|
|
205
|
+
| `AIPERTURE_SENSITIVE_PATTERNS` | `*secret*,*credential*,...` | Yes | Comma-separated glob patterns for sensitive files (skip scope normalization) |
|
|
206
|
+
| `AIPERTURE_PATTERN_MAX_AGE_DAYS` | `90` | Yes | Days before auto-learned patterns expire without human reconfirmation |
|
|
207
|
+
| `AIPERTURE_RAPID_APPROVAL_WINDOW_SECONDS` | `60` | Yes | Time window for rubber-stamping detection |
|
|
208
|
+
| `AIPERTURE_RAPID_APPROVAL_MIN_COUNT` | `5` | Yes | Min approvals within window to flag as rubber-stamping |
|
|
209
|
+
| `AIPERTURE_RATE_LIMIT_PER_MINUTE` | `200` | Yes | Max permission checks per session per minute (0 = unlimited) |
|
|
210
|
+
| `AIPERTURE_SESSION_RISK_BUDGET` | `50.0` | Yes | Cumulative risk budget per session before escalating to ASK |
|
|
211
|
+
| `AIPERTURE_ARTIFACT_STORAGE_DIR` | `` | No | Artifact file storage directory |
|
|
212
|
+
| `AIPERTURE_API_KEY` | `` | No | Bearer token for HTTP API auth (empty = open access) |
|
|
213
|
+
| `AIPERTURE_API_HOST` | `0.0.0.0` | No | API server bind host |
|
|
214
|
+
| `AIPERTURE_API_PORT` | `8100` | No | API server port |
|
|
215
|
+
|
|
216
|
+
"Tunable" settings can be updated at runtime via `PATCH /config` or the CLI wizard (`aiperture configure`). Infrastructure settings (No) require restart.
|
|
217
|
+
|
|
218
|
+
## OpenClaw Integration
|
|
219
|
+
|
|
220
|
+
AIperture integrates with [OpenClaw (ClawDBot)](https://github.com/clawdbot/openclaw) as an MCP server. OpenClaw is an open-source AI agent that supports MCP tool servers.
|
|
221
|
+
|
|
222
|
+
### Quick Start (with OpenClaw)
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Prerequisites
|
|
226
|
+
npm install -g openclaw@latest # install OpenClaw
|
|
227
|
+
pip install -e . # install AIperture
|
|
228
|
+
|
|
229
|
+
# Option A: Setup script
|
|
230
|
+
bash examples/openclaw_setup.sh
|
|
231
|
+
cd /tmp/aiperture-openclaw-demo && openclaw chat
|
|
232
|
+
|
|
233
|
+
# Option B: Python demo (auto-detects OpenClaw)
|
|
234
|
+
python examples/openclaw_demo.py
|
|
235
|
+
|
|
236
|
+
# Option C: Simulated mode (no OpenClaw needed)
|
|
237
|
+
python examples/openclaw_demo.py --sim
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### How It Works
|
|
241
|
+
|
|
242
|
+
1. `examples/openclaw.json` wires AIperture as an MCP server with fast-learning thresholds (3 decisions, 80% threshold)
|
|
243
|
+
2. `examples/system_prompt.md` instructs the agent to call `check_permission` before every action
|
|
244
|
+
3. The agent asks to read a file -> AIperture denies (no history)
|
|
245
|
+
4. User approves 3 times -> AIperture learns the pattern
|
|
246
|
+
5. Agent asks to read another file -> AIperture auto-approves
|
|
247
|
+
|
|
248
|
+
### Config Files
|
|
249
|
+
|
|
250
|
+
| File | Purpose |
|
|
251
|
+
|------|---------|
|
|
252
|
+
| `examples/openclaw.json` | MCP server config (points AIperture at an isolated DB) |
|
|
253
|
+
| `examples/system_prompt.md` | Instructs the agent to gate all actions through AIperture |
|
|
254
|
+
| `examples/openclaw_setup.sh` | Creates `/tmp/aiperture-openclaw-demo/` with fresh DB |
|
aiperture-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Aperture Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|