Skip to content

Commit dbedd88

Browse files
authored
Merge pull request #3 from anu-m03/web
Web
2 parents 6d3ef3f + 0baa8d1 commit dbedd88

39 files changed

+3429
-229
lines changed

.env.example

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ──────────────────────────────────────────────────────────
2+
# AgentSafe — Root Environment Variables
3+
# Copy to .env and fill in values. All are optional for
4+
# local dev; the system runs in stub/disabled mode without them.
5+
# ──────────────────────────────────────────────────────────
6+
7+
# ─── Backend ─────────────────────────────────────────────
8+
BACKEND_URL=http://localhost:4000
9+
10+
# ─── QuickNode RPC (Base chain) ──────────────────────────
11+
# Leave empty → backend runs without live chain data
12+
QUICKNODE_RPC_URL=
13+
14+
# ─── Kite AI ─────────────────────────────────────────────
15+
# Leave empty → deterministic keyword-based stubs
16+
KITE_BASE_URL=
17+
KITE_API_KEY=
18+
19+
# ─── Base Chain ──────────────────────────────────────────
20+
BASE_CHAIN_ID=8453
21+
22+
# ─── Frontend ────────────────────────────────────────────
23+
NEXT_PUBLIC_BACKEND_URL=http://localhost:4000
24+
NEXT_PUBLIC_BASE_CHAIN_ID=8453

README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,63 @@ pnpm dev
3939
## Useful Commands
4040

4141
```bash
42-
pnpm build # Build all packages
42+
pnpm build # Build all packages (shared → contracts → web + backend)
4343
pnpm lint # Lint all packages
44+
pnpm test # Run tests across all packages
45+
pnpm healthcheck # Validate backend API against Zod schemas (backend must be running)
4446
pnpm format # Format all files with Prettier
4547

4648
# Contracts (from packages/contracts)
4749
forge build
48-
forge test
50+
forge test -vvv
4951
```
5052

53+
## Integration Health Check
54+
55+
Start the backend, then run:
56+
```bash
57+
pnpm healthcheck
58+
```
59+
60+
This validates all 6 API endpoints (`/health`, `/status`, `/api/swarm/evaluate-tx`,
61+
`/api/swarm/logs`, `/api/governance/proposals`, `/api/governance/recommend`) against
62+
canonical Zod schemas. Exit code 0 = all pass.
63+
5164
## Architecture
5265

5366
- **AgentSafe Wallet** – ERC-4337 account abstraction wallet on Base
5467
- **SwarmGuard** – Multi-agent defense system (Sentinel, MEV Watcher, Liquidation Predictor, Scam Detector, Coordinator, Defender)
5568
- **GovernanceSafe** – Proposal parser, risk analysis, vote recommendation, execution with human veto
5669
- **Policy Engine** – On-chain deterministic guardrails that AI cannot override
5770

71+
## Sponsor Integrations
72+
73+
| Sponsor | What | Status |
74+
|---|---|---|
75+
| **Base (Coinbase)** | ERC-4337 smart wallet on Base (chain 8453) | ✅ Contracts + deploy script |
76+
| **QuickNode** | RPC for live block data, tx simulation | ✅ Live when `QUICKNODE_RPC_URL` set |
77+
| **Kite AI** | Proposal summarisation, scam NLP | ✅ Live when `KITE_API_KEY` set, stubs otherwise |
78+
| **Nouns / Snapshot** | Governance proposal ingestion + vote pipeline | ✅ Mock proposals + AI risk analysis |
79+
| **0g** | Decentralised storage for provenance receipts | 🟡 Stub / planned |
80+
81+
See [docs/bounty-proof.md](docs/bounty-proof.md) for full sponsor evidence and
82+
[docs/demo-script.md](docs/demo-script.md) for the 5-7 minute judge walkthrough.
83+
84+
## Frontend Pages
85+
86+
| Route | Description |
87+
|---|---|
88+
| `/dashboard` | System overview — swarm status, proposals, integrations |
89+
| `/defense` | Evaluate transactions through SwarmGuard |
90+
| `/governance` | View proposals, get AI recommendations, veto |
91+
| `/policy` | Policy rules display + consensus simulator |
92+
| `/integrations` | Sponsor proof panel with live/stub badges |
93+
94+
## Docs
95+
96+
- [Demo Script](docs/demo-script.md) — Step-by-step for judges
97+
- [Bounty Proof](docs/bounty-proof.md) — Sponsor-by-sponsor evidence
98+
5899
## License
59100

60101
MIT

apps/backend/.data/logs.jsonl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
{"id":"7567ac1e-432f-4dab-9489-d077d7e60769","timestamp":1771343126540,"type":"INTENT","runId":"8c6e82b4-0aaa-4f84-bb39-3932add59123","payload":{"intent":{"intentId":"18403edf-fd49-4295-990b-9627c87dfb23","runId":"8c6e82b4-0aaa-4f84-bb39-3932add59123","action":"EXECUTE_TX","chainId":8453,"to":"0x0000000000000000000000000000000000000000","value":"2000000000000000000","data":"0x","meta":{"finalSeverity":"HIGH","finalRiskScore":21,"timestamp":1771343126540}}},"level":"INFO"}
1111
{"id":"3beb2f0b-146a-4fc3-a5d0-3425be3d122c","timestamp":1771343126540,"type":"SWARM_END","runId":"8c6e82b4-0aaa-4f84-bb39-3932add59123","payload":{"runId":"8c6e82b4-0aaa-4f84-bb39-3932add59123","decision":"ALLOW"},"level":"INFO"}
1212
{"id":"f0b77d60-6a64-499b-ba5c-d0b61576f459","timestamp":1771343133545,"type":"GOVERNANCE_VOTE","payload":{"proposalId":"proposal-002","recommendation":"AGAINST","confidenceBps":7500,"summary":"Summary: Upgrade proxy to v2.1 — emergency patch Emergency upgrade to fix a critical vulnerability in the proxy contract. The admin key will be rotated and the quorum threshold adjusted from 3/5 to 4/7. Immedi..."},"level":"INFO"}
13+
{"id":"72d702e3-44b5-4c0b-80ad-6a5bbfb1f826","timestamp":1771344577000,"type":"GOVERNANCE_VOTE","payload":{"proposalId":"proposal-001","recommendation":"ABSTAIN","confidenceBps":5500,"summary":"Summary: Increase USDC treasury allocation to 40% This proposal seeks to re-balance the DAO treasury by increasing the USDC allocation from 25% to 40%, reducing ETH exposure. Funds would be moved from the mult..."},"level":"INFO"}
14+
{"id":"4b58b321-dc4c-4d0d-a57b-c39b2eabf53c","timestamp":1771344589036,"type":"GOVERNANCE_VOTE","payload":{"proposalId":"proposal-001","recommendation":"ABSTAIN","confidenceBps":5500,"summary":"Summary: Increase USDC treasury allocation to 40% This proposal seeks to re-balance the DAO treasury by increasing the USDC allocation from 25% to 40%, reducing ETH exposure. Funds would be moved from the mult..."},"level":"INFO"}

apps/backend/.env.example

Lines changed: 0 additions & 18 deletions
This file was deleted.

apps/backend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"build": "tsc",
99
"start": "node dist/index.js",
1010
"clean": "rm -rf dist",
11-
"lint": "echo 'lint: ok'"
11+
"lint": "echo 'lint: ok'",
12+
"test": "echo 'test: ok'"
1213
},
1314
"dependencies": {
1415
"@agent-safe/shared": "workspace:*",

apps/web/README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
11
# @agent-safe/web
22

3-
Next.js frontend dashboard for AgentSafe.
3+
Next.js frontend dashboard for AgentSafe + SwarmGuard.
44

55
## Pages
66

77
| Route | Description |
88
|-------|-------------|
9-
| `/` | Dashboard – balance, risk status, recent events |
10-
| `/transactions` | Transaction preview with simulation + risk scoring |
11-
| `/governance` | Proposals feed, recommendations, veto/vote controls |
12-
| `/swarm` | Real-time swarm agent activity feed |
13-
| `/policies` | Policy engine configuration + kill switch |
9+
| `/dashboard` | Overview — swarm status, agent count, proposals, sponsor summary |
10+
| `/defense` | **SwarmGuard** — evaluate transactions, agent feed + consensus + intent preview |
11+
| `/governance` | **GovernanceSafe** — proposals list, AI recommendation, auto-vote toggle, veto |
12+
| `/policy` | Policy engine rules + consensus simulator |
13+
| `/integrations` | **Sponsor Proof Panel** — Base, QuickNode, Kite AI, Nouns, 0g |
14+
| `/swarm` | Legacy swarm activity feed |
15+
| `/transactions` | Legacy transaction preview with simulation + risk scoring |
16+
| `/policies` | Legacy policy settings + kill switch |
1417

15-
## Run
18+
## Setup
1619

1720
```bash
18-
pnpm dev # starts on http://localhost:3000
21+
# 1. Copy env
22+
cp .env.example .env.local
23+
24+
# 2. Install deps (from repo root)
25+
pnpm install
26+
27+
# 3. Start backend (in another terminal)
28+
cd apps/backend && pnpm dev # http://localhost:4000
29+
30+
# 4. Start frontend
31+
cd apps/web && pnpm dev # http://localhost:3000
1932
```
33+
34+
## Environment Variables
35+
36+
| Variable | Default | Description |
37+
|----------|---------|-------------|
38+
| `NEXT_PUBLIC_BACKEND_URL` | `http://localhost:4000` | Backend API base URL |
39+
| `NEXT_PUBLIC_BASE_CHAIN_ID` | `8453` | Base chain ID |
40+
41+
## Screenshots Checklist (for bounties)
42+
43+
1. **`/integrations`** — Sponsor proof panel showing Base contracts, QuickNode health, Kite AI test, Nouns proposals
44+
2. **`/defense`** — Submit tx → SwarmGuard agent timeline + consensus + intent card
45+
3. **`/governance`** — Proposal list → "Get AI Recommendation" → VoteIntent display + veto
46+
4. **`/dashboard`** — Overview with live status from backend
47+
48+
## Architecture
49+
50+
- **Backend client**: `src/services/backendClient.ts` — typed API client with timeout + error handling
51+
- **Components**: `SwarmFeed.tsx`, `IntentCard.tsx`, `ProposalCard.tsx`, `StatusCard.tsx`
52+
- **App Router**: Next.js 15 with `src/app/` routing
53+
- **Shared types**: imported from `@agent-safe/shared`

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10+
"test": "echo 'test: ok'",
1011
"clean": "rm -rf .next"
1112
},
1213
"dependencies": {

0 commit comments

Comments
 (0)