Real-time AI threat monitoring. Protect your apps from prompt injection, leaks, and attacks in just a few lines of code.
pip install ai-aegis==1.0.3 Copy PIP instructions
Audit every tool. Catch the threats. All locally.
Getting Started · Verify your install · Dashboard Screenshots
开源与归属:AI Aegis 采用 Apache License 2.0。项目包含经许可演进的 上游代码和模型资产,法定版权、来源与变更说明统一记录在 NOTICE 与 LICENSE 中;产品界面、命令、配置和插件均使用 AI Aegis 标识。
Threat detection, tool permissions, and cost tracking — running locally in real time.
Aegis protects your AI agents at three layers:
100% local — events only leave the machine when you configure a SIEM destination you control.
pip install ai-aegis[app] aegis-app --web Binary installers (.exe / .deb / .rpm / .dmg) are not published yet. pip install ai-aegis[app] is the only supported install path; the releases page hosts source tags only.
Observability & Monitoring — Go to Integrations → OpenClaw, click Install Plugin, restart OpenClaw. Done. No proxy, no env vars.
Block Mode (only if you want to enforce blocking) — Toggle Block Mode on the dashboard. The proxy starts automatically and blocks threats before they reach the LLM. Adds ~10–50ms latency per request. Applies to both plugin and proxy integrations.
If the app fails to launch because ports 8741/8742 are already in use, use --port of your choice — the proxy starts automatically on port+1. See Configuration for proxy or web/api port settings.
Open-source. 100% local by default. No API keys required.
All screenshots are from a local app instance.
Every tool call is recorded to a SHA-256-linked, tamper-evident audit log (re-verify in one click). Inputs are stored as a 200-char preview after secret redaction — raw payloads never persisted. Allow / deny / ask rules per tool, enforced at the agent runtime via PreToolUse hooks or the multi-provider proxy.
Scans every prompt, response, and natural-language tool input for prompt injection (direct + indirect), jailbreaks, PII leaks, credential exfiltration, and tool-result injection. 108 rules covering the OWASP LLM Top 10 + 28 agent-attack chains. Monitor by default; opt-in block mode for hard-stop.
Scan agent skills and tool packages before installing. Static analysis across 10 categories detects shell access, network calls, env var reads, code exec, base64 payloads, symlink escapes, and more. Optional AI review filters false positives automatically.
Per-agent, per-model token and USD spend in real time, with daily budget auto-stop. Plugins read session transcripts locally for a 7-day input/output/cache trend per runtime — no cloud round-trip, no token data leaves your machine.
Forward every threat + tool-call audit to your SOC in OCSF 1.3.0. Supports Splunk HEC, Datadog, Microsoft Sentinel, Google Chronicle, IBM QRadar, OpenTelemetry/OTLP, generic webhook, or a local NDJSON file. Metadata-only by default; raw data is opt-in per destination.
Live dashboard showing every LLM request, tool call, token count, and threat event. Per-agent Replay timeline merges threat scans + tool audits + cost into one feed.
Runs entirely on your machine. No accounts required. No data leaves your infrastructure unless you configure a SIEM destination. Open source under Apache 2.0.
Performance: Rule-based analysis (default) adds ~10–50ms per request. Optional AI analysis adds 1–3s depending on the model and provider — shown on the dashboard so you can measure it against your actual traffic. Tool-permission decisions (allow / block / log_only): see the Tool Permissions guide.
Your AI Stack — LangChain · LlamaIndex · CrewAI · AutoGen · LangGraph · n8n · Dify · OpenClaw/ClawdBot — or any framework that makes HTTP calls to an LLM provider.
LLM Providers — OpenAI · Anthropic · Ollama · Groq · and any OpenAI-compatible API.
Run Anywhere — macOS / Linux / Windows · Docker & Kubernetes · AWS / GCP / Azure · VMs · Lambda / Workers / Vercel.
Native plugin with ZERO latency — runs inside the agent, no proxy needed. Install from the Integrations tab or curl -X POST http://localhost:8741/api/hooks/install. Enable block mode from the dashboard when you want to actively stop threats via proxy.
First-class plugin for Anthropic's Claude Code CLI — PreToolUse enforces tool-permission rules (allow / deny / ask, cloud-syncable), PostToolUse writes a tamper-evident audit row + scans prose tool inputs, UserPromptSubmit catches direct prompt-injection. Optional one-line statusline emitter surfaces live findings next to model / cwd / git state. Loopback-only, fail-open.
# Option A: via the app UI # Open http://127.0.0.1:8741 → Integrations → Claude Code → Install Plugin # Option B: via CLI aegis-app --install-plugin claude-code # Uninstall: aegis-app --uninstall-plugin claude-code # Then, in your Claude Code session: /reload-plugins Full setup guide
Built from real attack chains observed against production agent frameworks:
Alongside the 108 regex rules, the app ships Aegis Guardian, a bundled stdlib-only semantic threat classifier. It runs in parallel with the rule engine and catches obfuscated, paraphrased, buried, or encoded attacks that literal patterns miss. The model is fully local and runs offline — no cloud round-trip and no prompt text leaves your machine.
Install — comes with the app. The inference code and verified model asset are included in the AI Aegis wheel, so a fresh install is immediately offline-capable. Updating ai-aegis updates the model with the application. Air-gapped deployments may override the asset path with AEGIS_GUARDIAN_RUNTIME.
On by default. Toggle it from Settings → Guardian ML Detection (default ON), or force it off globally with the AEGIS_ML_ENABLED=false environment flag. With Guardian disabled the regex rules keep running unchanged, and the layer is fail-open — any model error silently falls back to rules-only so it never breaks the analyze path.
What to expect when it's on. The model is pure Python (zero runtime ML dependencies, no GPU, no network). It analyzes in parallel with regex rules; long documents are windowed with bounded work. The loaded bundle version and availability are visible under Settings → Guardian ML Detection.
Every scan and audit row is stamped with a stable device_id so a customer running Aegis across several laptops or agents can answer "which agent blocked this, which laptop is tampered, which machine spent what?" — not just "one of my installs did this".
Why we need it. A solo developer runs one install. A SOC team runs five to fifty. When an audit chain breaks, or a spike of blocked gmail-send calls shows up, the useful first question is which machine. Without a per-device tag, the answer is "some install" — which is useless in a fleet. device_id pins every row to a specific machine so dashboards, alerts, and compliance reviews can slice by device.
How it's generated (src/aegis/app/utils/device_id.py):
Stability across reinstalls. The OS identifier outlives the app install — so uninstalling and reinstalling Aegis on the same machine gives you the same device_id. Wiping the app data dir AND having no readable OS ID is the only combination that generates a new one. A new physical machine always gets a new ID.
Security / privacy posture — what the customer should know:
In one sentence: device_id is a machine-identifier-per-install, derived locally, hashed before storage, never transmitted except with explicit user opt-in (Cloud Connect or SIEM Forwarder).
Stream every threat detection and tool-call audit into your own SIEM — Splunk HEC, Datadog, Microsoft Sentinel, Google Chronicle, IBM QRadar, an OpenTelemetry collector, a local NDJSON file, or any HTTPS endpoint that accepts JSON. Your data, your pipes.
Why this is safe to ship with zero monetization:
The allow-list is enforced at enqueue time by _assert_metadata_only(). Even if the forwarder code were tampered with, it can't add the forbidden fields back.
Supported destinations (one code path, OCSF 1.3.0 payload):
Configure in Connect → SIEM Forwarder. Add SIEM destination → pick type → paste URL + token → Test → Save. Tokens are stored 0o600 in the app data dir, never in SQLite.
Each carries severity counters, events-over-time by severity, actor and MITRE-ish breakdowns, and a recent-high-severity log feed. MIT-licensed, AS-IS. Full install steps + field reference in docs/siem/README.md; trademark + upstream licenses in docs/siem/NOTICE.
Starter templates — import-test in your own stack and adjust queries / facets / sourcetypes before relying on them for production detections.
SIEM-side integrity verification. Every forwarded tool-call audit row carries its prev_hash and row_hash. Run a nightly search in your SIEM that rebuilds the chain — if a historic row has been tampered with on the local host, the forwarded evidence still tells the true story. That's the actual tamper evidence; the local chain alone is only the low bar.
Scan AI agent skills and tool packages before you install them. Aegis performs static analysis across 10 detection categories, assigns a risk score, and optionally runs an AI review to filter false positives.
┌──────────────────────────────────────────────────────────────────────┐ │ Skill Scanner Flow │ │ │ │ ┌─────────────┐ ┌──────────────────┐ ┌────────────────┐ │ │ │ Skill Dir │────>│ Static Analysis │────>│ Risk Scoring │ │ │ │ or URL │ │ (10 categories) │ │ LOW/MED/HIGH │ │ │ └─────────────┘ └──────────────────┘ └───────┬────────┘ │ │ │ │ │ ┌───────────────────────── │ │ │ v v │ │ ┌─────────────────┐ ┌────────────────────┐ │ │ │ AI Review │ │ Policy Engine │ │ │ │ (optional LLM) │ │ allow/block rules │ │ │ │ FP filtering │ │ trusted publishers│ │ │ └────────┬────────┘ └─────────┬──────────┘ │ │ │ │ │ │ v v │ │ ┌──────────────────────────────────────┐ │ │ │ Verdict: PASS / WARN / BLOCK │ │ │ │ + detailed findings per category │ │ │ └──────────────────────────────────────┘ │ └──────────────────────────────────────────────────────────────────────┘ Detection Categories Category What It Finds shell_exec Subprocess calls, system commands network_domain HTTP requests, socket connections, DNS lookups env_var_read Access to environment variables (API keys, secrets) code_exec eval, dynamic code generation dynamic_import Runtime module loading file_write Writing to disk outside expected paths base64_literal Obfuscated payloads in base64 strings compiled_code .pyc, .so, .dll binaries embedded in the skill symlink_escape Symlinks pointing outside the skill directory missing_manifest No permissions.yml declaring required capabilities AI-Powered Review Enable AI analysis (OpenAI, Anthropic, Ollama, Azure, or Bedrock) to automatically review findings and filter false positives. The AI examines each finding in context and adjusts the risk level — reducing noise without hiding real threats.
Aegis is fully open source. No cloud required. No accounts. No tracking. Run it, fork it, contribute to it.
Built for solo developers and small teams who ship AI agents without a security team or a FinOps budget. If you are building with LangChain, CrewAI, OpenClaw, or any agent framework — and you do not have someone watching your agent traffic and API spend — Aegis is for you.
Run the engine and managed-device control plane in your own server or cloud tenant with the included Docker Compose deployment. It provides real device enrollment, signed policy distribution and application receipts. See Self-hosted Control Plane, then point agents at the engine with AEGIS_ENGINE_ENDPOINT.
Aegis writes aegis.yml to your app data directory on first run with sensible defaults.
The config path is printed at startup — ~/.local/share/aegis/threat-monitor/aegis.yml (Linux), ~/Library/Application Support/Aegis/ThreatMonitor/aegis.yml (macOS), %LOCALAPPDATA%/Aegis/ThreatMonitor/aegis.yml (Windows). Key settings (all editable from the dashboard, which writes back to this file):
server: { host: 127.0.0.1, port: 8741 } # change port if 8741 is taken security: { block_mode: false, output_scan: true } # log/warn by default; flip block_mode to hard-stop budget: { daily_limit: 5.00, warn: true, block: true } # USD/day; daily_limit null to disable tools: { enforcement: true } # apply allow/block tool rules proxy: { integration: openclaw, mode: multi-provider, host: 127.0.0.1, port: 8742 } # integration: openclaw | langchain | langgraph | crewai | hermes | ollama; port defaults to server.port + 1 MCP Policies — Cloud Sync (optional) If your org distributes signed MCP tool-policy bundles from Aegis Cloud, enroll the device once and let the local app long-poll for updates.
1. Admin mints a token in the cloud admin UI (Onboarding → Invite users) and shares the install command.
aegis-app enroll aet_ The local app POSTs /api/v1/devices/enroll, persists org_id + signing key + auth credentials to ~/Library/Application Support/.credentials (macOS — equivalent path on Linux/Windows), and starts the cloud sync loop on next launch.
3. Set AEGIS_API_KEY for stable sync auth (recommended).
The local app accepts two auth methods on /policy/sync. The API key path is canonical — it eliminates the short-lived-JWT refresh fragility that can leave a device unable to sync if the refresh token goes stale.
export AEGIS_API_KEY=sk- Auth method Header sent Source Lifetime Sync stability API key ✅ recommended X-Api-Key: sk-... AEGIS_API_KEY env, then creds.api_key Long-lived Robust — no refresh path needed JWT (fallback) Authorization: Bearer ... Stored from enrollment ~1h, auto-refresh on 401/403 Breaks if the refresh token expires; requires re-enrollment to recover When both are present, the API key wins. device_id rides as X-Aegis-Device-Id on every request regardless of auth method; org_id is resolved server-side from the auth principal.
You can mint API keys in the cloud admin UI under Access Management. Set the env var in your shell profile or systemd service unit so it survives restarts.
4. Cloud Sync starts automatically — no further configuration needed. The local app already defaults to the production cloud endpoints. Override env vars exist for self-hosted / on-prem deployments only.
Synced rules are read-only on the device — authoring lives in the cloud admin. The MCP Policies page (sidebar → Configure → MCP Policies) shows verification status, applied policies + rules, and a Sync Now button for manual refresh.
For LangChain, CrewAI, Ollama, and other non-OpenClaw frameworks, point your application to Aegis's proxy instead of the provider's API. OpenClaw/ClawdBot users only need this when block mode is enabled.
set OPENAI_BASE_URL=http://localhost:8742/openai/v1 set ANTHROPIC_BASE_URL=http://localhost:8742/anthropic PowerShell (current session)
$env:OPENAI_BASE_URL="http://localhost:8742/openai/v1" $env:ANTHROPIC_BASE_URL="http://localhost:8742/anthropic" PowerShell (persistent, per user)
[Environment]::SetEnvironmentVariable( "OPENAI_BASE_URL", "http://localhost:8742/openai/v1", "User" ) Terminal (current session)
export OPENAI_BASE_URL=http://localhost:8742/openai/v1 export ANTHROPIC_BASE_URL=http://localhost:8742/anthropic Persistent (add to ~/.bashrc or ~/.zshrc)
echo 'export OPENAI_BASE_URL=http://localhost:8742/openai/v1' >> ~/.bashrc echo 'export ANTHROPIC_BASE_URL=http://localhost:8742/anthropic' >> ~/.bashrc source ~/.bashrc Every request is scanned for prompt injection. Every response is scanned for data leaks. Every dollar is tracked — whether via native plugin (OpenClaw) or proxy (all other frameworks).
Supported providers (13): openai anthropic gemini ollama groq deepseek mistral xai together cohere cerebras moonshot minimax
git clone https://gitee.com/wan-xianghao/ai-aegis.git cd ai-aegis pip install -e ".[dev,app]" pytest tests/ -v About CI: the workflow definitions in .github/workflows/ are written for GitHub Actions, which does not run on Gitee. They are kept as the project's CI configuration; the Gitee mirror hosts the source and the releases. The command above is what they would run.
A separate cloud product handles MCP tool-permission policy sync across enrolled devices, per-org audit attribution, and per-device fleet slicing. It also adds AI Agent Governance — your agents' governance posture rolled into a single score across the fleet — plus EU AI Act orientation that maps your action-layer logging and tamper-evident tool-call audit to the relevant obligations; orientation only, not legal advice. Sign in for the fleet-wide view — the local install already gives you the single-device snapshot. Strictly additive — the local install above works standalone without it.
The starter SIEM dashboard templates under docs/siem/ (Splunk XML, Sentinel workbook, Datadog + Grafana JSON) are MIT-licensed — see docs/siem/LICENSE and docs/siem/NOTICE for trademark disclaimers.
ai security llm prompt-injection threat-detection threat-monitoring openai claude aegis
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




