Aegis-x402
# Aegis-x402
**Zero-signup, wallet-native HTTP 402 Security Firewall & Escrow Clearinghouse for A2A & MCP Agents.**
No API keys, no forms, no B2B sales calls. Any autonomous agent arrives with an EVM wallet, receives a machine-readable `HTTP 402` USDC challenge on Base (`a2a-x402` v2 / EIP-3009), signs `TransferWithAuthorization`, and receives verified security sanitization or escrowed commerce execution in one round-trip.
## Core Capabilities
1. **Zero-Signup Paid Security Skills (`POST /v1/x402/*`, A2A `/v1/message:send`, MCP `/mcp`)**
- `sanitize_payload` ($0.002 USDC): Multi-layer de-obfuscation (Base64/Hex/URL/Unicode NFKC/homoglyphs/leetspeak), Luhn PAN & Mod-97 IBAN DLP, secret entropy detection, multilingual prompt injection, shell/SQLi/SSRF detection, and MCP tool poisoning defense.
- `verify_agent_card` ($0.002 USDC): ES256/Ed25519 JWS + RFC 8785 JCS signature verification + `_agentpin` DNS check + skill description safety inspection.
- `scan_code_sarif` ($0.25 USDC): Static security scanner for MCP servers, TS/JS/Python agents, iOS AppIntents, and Android AppFunctions emitting OASIS SARIF 2.1.0.
- `attest_receipt` ($0.003 USDC): Signed Ed25519 cryptographic attestation over any payload digest.
2. **Wallet-Native A2A/MCP Buy & Rent Escrow Clearinghouse (`/v1/commerce/*`)**
- Any seller agent publishes `BUY`, `RENT`, or `PAY_PER_CALL` offers using an EVM wallet (`POST /v1/commerce/listings`).
- Buyer agents fund orders directly via `HTTP 402` (`POST /v1/commerce/orders`) into escrow.
- `RENT` orders automatically mint a metered `aegis_lease_...` bearer token verified in 1 call (`POST /v1/commerce/leases/verify`).
- Fulfillment releases **97% to the seller** and **3% platform fee** into the SHA-256 hash-chained double-entry ledger; disputes refund **100% to the buyer**.
3. **Machine Discovery**
- `GET /.well-known/agent-card.json` (ES256 JWS signed A2A v1.0.1 card)
- `GET /.well-known/jwks.json`
- `GET /llms.txt` & `GET /llms-full.txt`
- `GET /openapi.json`
- `POST /mcp` (Streamable HTTP MCP JSON-RPC 2.0)
## Quickstart (Zero Docker Required)
```bash
npm install
npm run build
npm test
npm run dev
```
In a second terminal, run the live Agent-to-Agent economy simulation:
```bash
npm run simulate:economy
```
## SDK Usage (`AegisX402Client`)
```ts
import { AegisX402Client } from "aegis-x402";
const agent = new AegisX402Client({
baseUrl: "https://your-aegis-x402-host.example",
privateKey: process.env.AGENT_EVM_PRIVATE_KEY as `0x${string}`,
});
// Automatically negotiates HTTP 402 -> signs EIP-3009 USDC -> returns result
const verdict = await agent.sanitize({ prompt: "Check user transfer" }, { mode: "REDACT" });
```
## Production Deployment
1. Set your real Base Mainnet (`8453`) treasury address in `AEGIS_BASE_TREASURY_EVM` and `AEGIS_GATEWAY_TREASURY_EVM`.
2. Switch `X402_SETTLEMENT_MODE=facilitator` (using `https://x402.org/facilitator`) or `direct_rpc` with `BASE_RELAYER_PRIVATE_KEY`.
3. Provision Postgres 16 + Redis (run `sql/001_aegis_x402.sql` on Postgres) and deploy with `Dockerfile`, `railway.json`, `render.yaml`, or Google Cloud Run:
```bash
docker compose up --build -d
```
## Machine Distribution Checklist
Once deployed on your HTTPS domain (`https://api.yourdomain.com`):
- Submit `https://api.yourdomain.com/.well-known/agent-card.json` to A2A directories and Coinbase x402 Bazaar.
- Submit `https://api.yourdomain.com/mcp` to the official MCP Registry / Smithery.
- Ensure `https://api.yourdomain.com/llms.txt` and `/.well-known/jwks.json` are publicly crawlable without auth.
TDQS
Scored across 5 tools
Each tool has a mostly distinct target: payload sanitization, AgentCard verification, code scanning, A2A offer discovery, and rental lease verification. The only mild overlap is that sanitize_payload and verify_agent_card both mention poisoning inspection, but their primary objects and workflows are still distinguishable.
All five tools use consistent snake_case with clear verb_noun or verb_qualified_noun patterns: sanitize_payload, verify_agent_card, scan_code_sarif, discover_a2a_offers, verify_rental_lease. The convention is predictable and easy to scan.
Five tools is well within the ideal range for a focused security-and-agent-commerce utility server. Each tool covers a distinct operation, and none appears redundant or purely decorative.
The surface covers core security inspection, AgentCard verification, code scanning, discovery, and lease consumption. There are minor lifecycle gaps around offer creation/payment settlement or fuller lease management, but the main advertised workflows are represented.