Spaces:
Sleeping
Sleeping
File size: 15,057 Bytes
af6094d 459127b af6094d 459127b af6094d 459127b af6094d 459127b af6094d ee9b4cc 459127b af6094d ee9b4cc af6094d 459127b ee9b4cc 459127b af6094d ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b af6094d ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc e5479b8 ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b ee9b4cc 459127b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | ---
title: AgentMask - Secure Multi-Agent System
emoji: ๐ก๏ธ
colorFrom: green
colorTo: red
sdk: gradio
sdk_version: 5.0.0
app_file: app.py
pinned: false
tags:
- mcp-in-action-track-enterprise
- agent
- security
- langgraph
- merkle-tree
- multi-agent
- ecdsa
---
# ๐ก๏ธ AgentMask - Secure Multi-Agent System
> **"Don't Trust, Verify."** โ Transparent, Auditable, and Immutable Reasoning Layer for AI Agents.
[](https://python.org)
[](https://fastapi.tiangolo.com)
[]()
[]()
## ๐ฌ Demo & Submission
Watch the system in action and check out our official submission post:
[](https://youtu.be/d5VVxeBY1Ak)
[-View%20Post-black?style=for-the-badge&logo=x)](https://x.com/SDogan_n/status/1995246903232246076?s=20)
---
## ๐ Hackathon Track
This project was developed for the **MCP 1st Birthday Hackathon**.
- **Track:** `Track 2: MCP in Action`
- **Category Tag:** `mcp-in-action-track-enterprise`
---
## ๐ก Problem: The Black Box Issue
Autonomous AI agents are performing increasingly complex tasks. However, there is a critical problem:
> **How can you prove why an agent made a decision or if it was manipulated during the process?**
In current systems, logs can be deleted or altered, and the agent's thought process remains a **black box**.
---
## ๐ Solution: Cryptographic "Chain-of-Checks"
AgentMask provides not just a "Chain-of-Thought," but a **"Chain-of-Checks" (Audit Chain)**.
### Key Features
| Feature | Description |
|---------|-------------|
| ๐ค **Multi-Agent Orchestration** | Modular agent architecture with parallel and sequential execution |
| ๐ **Merkle Tree Audit Trail** | Every step is hashed with SHA-256, immutable |
| โ๏ธ **ECDSA Block Signing** | Blocks are cryptographically signed (secp256k1) |
| ๐ **Real Web Search** | DuckDuckGo/Serper integration with fallback support |
| ๐ **Developer Console** | Monitoring with real-time graph visualization |
| โก **Parallel Execution** | Concurrent agent execution with asyncio.gather |
| ๐พ **Append-Only Ledger** | WORM (Write-Once-Read-Many) JSON storage |
---
## ๐๏ธ Architecture
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฅ๏ธ Developer Console (FastAPI) โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ POST /run โ โ GET / โ โ GET /health โ โ
โ โ Task Execute โ โ Console UI โ โ Health Check โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ง Orchestrator (The Brain) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Task โ ResearchAgent โ SummarizerAgent โ Final Output โ โ
โ โ (parallel execution support) โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ ๐ ResearchAgent โ โ ๐ SummarizerAgentโ โ ๐ง Future Agents โ
โ - Web Search โ โ - Text Summary โ โ - Critic โ
โ - DuckDuckGo โ โ - Doc Analysis โ โ - Validator โ
โ - Serper API โ โ โ โ - Planner โ
โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Ledger (The Vault) โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ LedgerStoreโ โ Merkle Treeโ โ ECDSA Sign โ โ JSON โ โ
โ โ Entries โโ โ Root Hash โโ โ Blocks โโ โ Storage โ โ
โ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
---
## ๐ Proje Tructure
```
AgentMask/
โโโ pyproject.toml # Proje konfigรผrasyonu & baฤฤฑmlฤฑlฤฑklar
โโโ README.md # this file
โ
โโโ src/ # Ana kaynak kod
โ โโโ __init__.py
โ โโโ orchestrator.py # Multi-agent koordinasyonu
โ โ
โ โโโ agents/ # Agent modรผlleri
โ โ โโโ __init__.py
โ โ โโโ base.py # BaseAgent abstract class
โ โ โโโ research_agent.py # Web search agent
โ โ โโโ summarizer_agent.py # Text summarization agent
โ โ โโโ parallel.py # Parallel execution utilities
โ โ
โ โโโ ledger/ # Kriptografik denetim katmanฤฑ
โ โ โโโ __init__.py
โ โ โโโ merkle.py # Merkle tree calculation
โ โ โโโ store.py # Append-only ledger storage
โ โ โโโ signing.py # ECDSA imzalama
โ โ
โ โโโ tools/ # Harici araรงlar
โ โ โโโ __init__.py
โ โ โโโ searcher.py # Web search abstraction
โ โ
โ โโโ web/ # Web arayรผzรผ
โ โโโ __init__.py
โ โโโ app.py # FastAPI application
โ
โโโ tests/ # Test dosyalarฤฑ
โโโ __init__.py
โโโ test_agents.py # Agent testleri
โโโ test_ledger.py # Ledger & signing testleri
โโโ test_search_integration.py # Search entegrasyon testleri
โโโ test_web_console.py # Web API testleri
```
---
## ๐ Installation
### Requirements
- Python 3.10+
- pip
### Steps
```bash
# 1. Clone the repo
git clone [https://github.com/yourusername/AgentMask.git](https://github.com/yourusername/AgentMask.git)
cd AgentMask
# 2. Create virtual environment
python -m venv .venv
# 3. Activate
# Windows:
.\.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# 4. Install dependencies
pip install -e ".[dev]"
```
---
## ๐งช Running Tests
Bash
# Run all tests
.\.venv\Scripts\python.exe -m pytest -v
# Run a specific test file
.\.venv\Scripts\python.exe -m pytest tests/test_agents.py -v
# Run with coverage
.\.venv\Scripts\python.exe -m pytest --cov=src -v
Test Results: โ
44 tests passed
---
## ๐ฅ๏ธ Running Developer Console
Bash
# Start the web server
cd src/web
uvicorn app:app --reload --port 8000
# Open in browser
# http://localhost:8000
๐จ Terminal-Style Hacker UI
The Developer Console features a terminal-style interface that emphasizes security and transparency:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ AgentMask Terminal โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ [root@agentmask]$ Enter query... โ [โบ EXECUTE] โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ > EXECUTION LOG_ โ > AGENT PIPELINE GRAPH_ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ ๐ MERKLE ROOT HASH: โ โ โ [Flow] [Sequence] [Merkle] โ โ
โ โ a7f3b2c1d4e5f6... โ โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ โ ๐ฅ โ ๐ โ ๐ โ โ
โ
โ โ โ โ โ
โ โโ STEP 1 โโโโโโโโโโโโโโ โ โ Mermaid.js ile interaktif โ โ
โ โ [RESEARCH] โ โ โ graph visualization โ โ
โ โ SHA256: 8a4f2b... โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ > View I/O Data_ โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ
โ โโ STEP 2 โโโโโโโโโโโโโโ โ โ
โ โ [SUMMARIZER] โ โ โ
โ โ SHA256: c3d7e1... โ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Console Features
Feature Description
๐ฅ๏ธ Terminal Aesthetic Neon green (#00ff41) + red (#ff0040) hacker theme
๐ Flow Graph Agent pipeline visualization (Mermaid.js)
๐ Sequence Diagram Agent communication sequence
๐ณ Merkle Tree View Interactive hash tree visualization
๐ Execution Log Detailed I/O log for each step
๐ Merkle Root Cryptographic verification hash
โก Real-time Real-time result display
๐ฑ Responsive Mobile responsive design
---
## ๐ง API Endpoints
| Endpoint | Method | Description |
|----------|--------|----------|
| `/` | GET | Developer Console UI |
| `/run` | POST | Execute task, get results |
| `/health` | GET | Health check |
### POST /run Example
```bash
curl -X POST http://localhost:8000/run \
-H "Content-Type: application/json" \
-d '{"query": "AI in healthcare diagnosis"}'
```
**Response:**
```json
{
"success": true,
"task": {"query": "AI in healthcare diagnosis"},
"steps": [
{
"step": 1,
"agent": "research",
"hash": "a1b2c3...",
"output": {"results": [...]}
},
{
"step": 2,
"agent": "summarizer",
"hash": "d4e5f6...",
"output": {"summary": "..."}
}
],
"merkle_root": "abc123...",
"total_steps": 2
}
```
---
## ๐ Security Features
### Merkle Tree Audit Trail
Every agent step is hashed with SHA-256 and added to a Merkle tree:
```python
from ledger.merkle import compute_merkle_root, hash_leaf
# Hash a single leaf
leaf_hash = hash_leaf("agent action data")
# Compute Merkle root
leaves = ["step1", "step2", "step3"]
root = compute_merkle_root(leaves)
```
### ECDSA Block Signing
Blocks are signed using the secp256k1 curve:
```python
from ledger.signing import ECDSASigner
# Generate key pair
signer = ECDSASigner()
# Sign
signature = signer.sign(block_hash)
# Verify
is_valid = signer.verify(block_hash, signature)
```
### Append-Only Ledger
```python
from ledger.store import LedgerStore
# Create Ledger
store = LedgerStore(storage_path="ledger.json")
# Add Entry
store.add_entry("search", "research", input_data, output_data)
# Create and sign block
block = store.create_block(signer=signer)
# Verify chain
is_valid, message = store.verify_chain()
```
---
## ๐ฎ Roadmap
- [x] **Stage 1**: Multi-Agent core implementation
- [x] **Stage 2**: Developer Console (FastAPI + UI)
- [x] **Stage 3**: Gerรงek Web Search integration
- [x] **Stage 4**: Ledger, ECDSA Signing, Parallel Agents
- [ ] **Stage 5**: LLM integration (OpenAI/Anthropic)
- [ ] **Stage 6**: Critic & Validator agents
- [ ] **Stage 7**: WebSocket real-time streaming
- [ ] **Stage 8**: Distributed ledger (multi-node)
---
## ๐ License
MIT License - See the LICENSE file for details.
---
<p align="center">
<b>๐ก๏ธ AgentMask - Trust Through Transparency</b><br>
<i>"Every decision, every step, cryptographically verifiable."</i>
</p>
|