Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.8.0
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.
๐ฌ Demo & Submission
Watch the system in action and check out our official submission post:
๐ 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
# 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:
{
"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:
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:
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
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
- Stage 1: Multi-Agent core implementation
- Stage 2: Developer Console (FastAPI + UI)
- Stage 3: Gerรงek Web Search integration
- 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.
๐ก๏ธ AgentMask - Trust Through Transparency
"Every decision, every step, cryptographically verifiable."