AgentShield
Health Uyari
- License — License: Apache-2.0
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 9 GitHub stars
Code Uyari
- process.env — Environment variable access in apps/control-plane/src/app.module.ts
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Security gateway for AI agents: Ed25519-signed tool calls, policies, human approvals, budgets, circuit breakers, and a tamper-evident audit log. Works with LangGraph, LangChain, CrewAI, and MCP.
AgentShield
Documentation: agentshield-docs.vercel.app
AgentShield is a security and reliability layer for autonomous agents. Tool calls are authenticated, authorized, and recorded outside the agent that requested them. This repository implements that path for registered agents, the sample.echo adapter, and an http.request adapter that reaches only configured hosts, injects their credentials, and refuses internal networks. Owners can rotate, suspend, and revoke credentials. An approver can approve or reject a pending request, and the gateway consumes an approval once. Signed calls are counted against request, tool-call, and token budgets. Repeated adapter failures open a circuit. Oversized arguments and a burst of denies open incidents that an auditor can list. An owner or admin can run a chaos scenario, and a missing observation is stored as a failure. Python and TypeScript clients sign the request. LangGraph, LangChain, CrewAI, and MCP send every tool call through those clients and cannot run a tool locally.
The control plane and gateway answer liveness. Readiness is 200 only when their databases answer. The dashboard is an operations console: after sign-in it streams events, lists approvals with the request under review, and lets an operator approve or reject, register, suspend, resume, and revoke agents, edit policies, run chaos scenarios, and manage members. It shows each person only what their role may do. AGENTSHIELD_ENV=production requires DATABASE_URL to use the agentshield_app role.
Layout
apps/control-plane NestJS management API
apps/dashboard Next.js operations console
apps/intelligence-engine Python content analysis: prompt injection and secret leaks
apps/docs Documentation site (Next.js + Fumadocs), deployed at agentshield-docs.vercel.app
runtime/gateway Go enforcement process and tool adapters
runtime/policy-engine Deterministic allow, deny, and require_approval
runtime/identity Ed25519 request signatures
sdk/python Python client. Signs the raw body it sends
sdk/typescript TypeScript client. Same signing input
integrations/langgraph LangGraph node that calls the Python client
integrations/mcp MCP server that calls the Python client
integrations/langchain LangChain tools that call the Python client
integrations/crewai CrewAI tools that call the Python client
examples/sample-agent Demonstration that uses the Python client
docs Architecture, security model, ADRs, OpenAPI
infrastructure/docker Compose and the PostgreSQL migration
Decisions
The policy evaluator is an in-process Go library, not an OPA sidecar. Agent requests are signed with Ed25519 over the raw body. Missing policy is deny. PostgreSQL is the transactional store. ClickHouse is not deployed. The records are in docs/adr/.
Local data services
Docker Desktop has to be running.
docker compose up -d
docker compose ps
Published ports bind to 127.0.0.1. The database user, Redis, NATS, and MinIO use the development defaults in .env.example. Those values are not for any other environment. Postgres applies every file in infrastructure/docker/postgres/migrations/ in lexical order when the data volume is created. An existing volume does not pick up a new file. Apply 0002_user_sessions.sql through 0006_event_pipeline.sql with psql if schema_migrations does not list them. Each file is safe to run twice. The control plane also inserts any missing catalog scenario when an experiment starts. Reset the volume with docker compose down -v only when you can lose the local data.
Mailpit catches local mail. With SMTP_URL=smtp://127.0.0.1:1025 on the control plane, member invitations are emailed and appear at http://127.0.0.1:8025. Nothing is delivered outside your machine. Without SMTP_URL, a new member gets a one-time temporary password and must replace it at first sign-in.
Event relay
The event relay publishes every committed security event to NATS JetStream, writes evidence bundles for flagged content and failed tool runs to MinIO, and computes per-minute tool reliability.
$env:DATABASE_URL = "postgres://agentshield:[email protected]:5432/agentshield?sslmode=disable"
$env:NATS_URL = "nats://127.0.0.1:4222"
$env:MINIO_ENDPOINT = "127.0.0.1:9000"
$env:MINIO_ROOT_USER = "agentshield"
$env:MINIO_ROOT_PASSWORD = "agentshield-dev-only"
go run ./runtime/gateway/cmd/event-relay
It listens on 127.0.0.1:8083 for /health/live and /health/ready, which reports the outbox backlog. Events wait in PostgreSQL while it is stopped and go out when it starts. Subscribe to agentshield.events.<organization>.<event type> on stream AGENTSHIELD_EVENTS. Give the control plane the same MINIO_* variables to read evidence in the console. See docs/adr/0016-phase-9-event-pipeline.md.
MinIO's evidence bucket is agentshield-evidence. The server image is cgr.dev/chainguard/minio because the upstream minio/minio image is no longer published for anonymous pulls. After Compose starts that image, the console is at http://127.0.0.1:9001.
Run everything in containers
docker compose --profile app up -d --build
docker compose --profile app run --rm control-plane node apps/control-plane/dist/bootstrap.js
This builds and starts the gateway, event relay, control plane, dashboard, and intelligence engine next to the data services. The console is at http://127.0.0.1:3000. The bootstrap command creates the owner from AGENTSHIELD_BOOTSTRAP_*, which default to the values in .env.example. Every image runs as a non-root user on a read-only filesystem with all capabilities dropped, and checks its own health. The gateway has only sample.echo unless you set GATEWAY_TOOLS_CONFIG to a file you mount into it. docker compose up -d without the profile still starts only the data services, for running the applications from source as below.
Metrics and dashboards
docker compose --profile app --profile observability up -d --build
Prometheus scrapes every service. Grafana opens on http://127.0.0.1:3001 with the AgentShield dashboard, which shows:
- request rates and latency
- decisions by outcome
- executions by tool
- content analysis findings
- the event pipeline
Metrics are served on separate ports from the APIs and carry no organization or agent labels. See infrastructure/monitoring/README.md. Benchmarks and a recorded baseline are in benchmarks/.
Kubernetes and released images
infrastructure/kubernetes has Kustomize manifests:
- a dev overlay that runs the whole stack on a local cluster
- a production overlay as a starting point
Pushing a v*.*.* tag publishes signed multi-architecture images to ghcr.io/<owner>/agentshield-<service>. See infrastructure/kubernetes/README.md for deployment and for verifying signatures with cosign.
Application processes
npm install
npm run build --workspace @agentshield/control-plane
npm start --workspace @agentshield/control-plane
The control plane listens on 127.0.0.1:8080. GET /health/ready returns 200 when DATABASE_URL points at a database that answers, and 503 otherwise.
Create the first organization before registering an agent. The command refuses AGENTSHIELD_ENV=production.
$env:DATABASE_URL = "postgres://agentshield:[email protected]:5432/agentshield?sslmode=disable"
$env:AGENTSHIELD_BOOTSTRAP_EMAIL = "[email protected]"
$env:AGENTSHIELD_BOOTSTRAP_PASSWORD = "change-me-local-only"
$env:AGENTSHIELD_BOOTSTRAP_DISPLAY_NAME = "Local Owner"
$env:AGENTSHIELD_BOOTSTRAP_ORG_NAME = "Local"
$env:AGENTSHIELD_BOOTSTRAP_ORG_SLUG = "local"
npm run build --workspace @agentshield/control-plane
npm run bootstrap --workspace @agentshield/control-plane
Then POST /api/v1/sessions with that email and password. The token is shown once.
$env:Path = "$pwd\.tools\go\bin;$env:Path" # only if go is not already installed
go run ./runtime/gateway/cmd/gateway
The gateway listens on 127.0.0.1:8081. It authorizes requests when DATABASE_URL and REDIS_URL are set and those services answer. Without them, readiness stays 503 and authorize does not return allow.
$env:DATABASE_URL = "postgres://agentshield:[email protected]:5432/agentshield?sslmode=disable"
$env:REDIS_URL = "redis://127.0.0.1:6379/0"
go run ./runtime/gateway/cmd/gateway
Set GATEWAY_TOOLS_CONFIG to a tools file such as docs/examples/gateway-tools.json to enable http.request. runtime/gateway/README.md describes the file and the adapter's limits.
examples/sample-agent/ uses the Python SDK to call sample.echo. integrations/langgraph, integrations/langchain, integrations/crewai, and integrations/mcp are the framework entry points. All of them call the SDK and refuse a local tool function.
$env:PYTHONPATH = "apps/intelligence-engine"
python -m agentshield_intelligence
The intelligence process listens on 127.0.0.1:8082. Set INTELLIGENCE_URL=http://127.0.0.1:8082 on the gateway to check tool results for prompt injection and tool arguments for secrets. Findings come back to the agent as analysis and open alerts in the console. They never change a policy decision, and a slow or stopped analyzer never blocks a call. See apps/intelligence-engine/README.md.
npm run dev --workspace @agentshield/dashboard
The console is at http://127.0.0.1:3000.
AGENTSHIELD_ENV=production is allowed for the control plane and gateway only when DATABASE_URL uses agentshield_app. The intelligence process runs in production only with INTELLIGENCE_TOKEN set, and the gateway must send the same token.
Tests
powershell -File scripts/test.ps1
powershell -File scripts/lint.ps1
Go tests cover signatures, policy precedence, redaction, the audit hash, gateway decisions, and a PostgreSQL rollback of the audit insert. Python tests cover the analyzer's attack and benign corpora, its limits, and its HTTP handling, the sample signing input, and the repository contracts. The control plane tests cover configuration, policy documents, health, and a local registration flow when PostgreSQL is reachable. The dashboard tests cover the proxy's origin and path checks and the policy editor's checks.
Contracts
docs/api/control-plane.openapi.yaml and docs/api/gateway.openapi.yaml are the target API. docs/api/README.md says which operations exist. Unimplemented routes are not stubbed as successful empty responses.
License
Apache License 2.0. See LICENSE.
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi