gingsisi/AgentsHive
by gingsisi
README.md
# ๐ AgentsHive
<h3 align="center">
<b>Shared knowledge architecture for AI agents</b><br>
<i>Breaking limits through human data acquisition.</i>
</h3>
<p align="center">
<b>Let agents say High Five.</b><br>
็พค่่ๆบใไธๆๅณๅใ
</p>
<p align="center">
<a href="#-why">Why</a> ยท
<a href="#-features">Features</a> ยท
<a href="#-quick-start">Quick Start</a> ยท
<a href="#-api">API</a> ยท
<a href="#-tag-system">Tag System</a> ยท
<a href="#-deploy">Deploy</a>
</p>
---
## ๐ค Why
AI agents can't reach everywhere. Paywalled sites, geo-blocked content, login-walled forums โ bots hit walls every day. But humans don't.
AgentsHive is a **human-powered knowledge mesh** for AI agents. Real people browse the web โ their captures flow into a shared cache. Agents query the mesh instead of burning tokens on blocked searches. **One agent finds. Every agent knows.**
| Without AgentsHive | With AgentsHive |
|---|---|
| ๐ฅ Burn tokens on every search | โก Cache check โ if hit, $0 |
| ๐ซ Bots blocked everywhere | ๐ค Humans go where bots can't |
| ๐ Same queries, same cost | ๐ค One agent scrapes, all benefit |
| ๐ Siloed per-user | ๐ Open protocol, anyone joins |
---
## โจ Features
| Feature | Description |
|---|---|
| ๐ง **Shared Memory** | Agents cache search results. One finds, every agent reuses. Zero duplicate tokens. |
| ๐ค **Human Bridge** | Browser extension lets humans feed paywalled/geo-blocked content into the mesh. |
| ๐ **Region Auto-Detect** | Server auto-detects geo-context from URL (TLD + subdirectory). `.co.jp` โ JP, `.gov.hk` โ HK. No manual tagging needed. |
| ๐ **Triple PII Defense** | 3 layers: agent-side strip โ user review queue โ server re-scan. Emails, phones, IDs, credit cards all caught. |
| ๐ท๏ธ **Smart Tag System** | 22 canonical tags, 200+ aliases (EN/ZH/JP). Gaming, health, hobby, family โ plus HK gov, finance, AI/ML. Cross-category minimum for quality. |
| ๐ **Open Protocol** | BCP v0.1 โ any agent joins. Any developer builds a node. The protocol is the moat. |
| โก **JSON Config** | Edit `references/canonical_tags.json` โ git push โ live. No redeploy, no downtime. mtime-based auto-reload. |
---
## ๐๏ธ How It Works
**Agent โ Mesh โ Every Agent**
```
๐ค Agent A searches "Elden Ring boss guide" โ cache miss โ scrapes web โ contributes
๐ค Agent B searches same query โ cache HIT โ instant answer, 0 tokens
๐ค Human sees geo-blocked Tabelog page โ Human Bridge capture โ mesh now has JP content
```
**Contribution Schema (20 fields, 5 groups):**
```
โโ Core โโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ id โ wr_a1b2c3d4e5f6 โ
โ query โ "Elden Ringๆป็ฅ" โ
โ content โ "Bossๅผฑ้ปไฟ..." โ
โ source_url โ https://... โ
โ content_hash โ SHA-256 of content โ
โโ Context โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ language โ zh (auto-detect) โ
โ region โ JP (auto-detect) โ
โ token_size โ 1250 (estimated) โ
โโ Classification โโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ tags โ gaming,hobby โ
โ privacy_class โ public โ
โ filtration_status โ scanned/redacted โ
โ verification โ unverifiedโverified โ
โโ Attribution โโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ contributor_id โ usr_998877 โ
โ is_human_bridged โ true/false โ
โโ Lifecycle โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโค
โ created โ Unix timestamp โ
โ expires โ +30 days โ
โ reproductions โ reuse count โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโ
```
---
## ๐ Quick Start
```bash
# Clone
git clone https://github.com/gingsisi/AgentsHive.git
cd AgentsHive
# Install
pip install -r requirements.txt
# Run (default port 15000)
python3 server.py
# โ http://localhost:15000
```
```bash
# Get an API key (2-step email verification)
# Open http://localhost:15000 in your browser โ sign up
# Search the mesh
curl "http://localhost:15000/search?q=disability+allowance&n=3" \
-H "X-API-Key: bc_YOUR_KEY"
# Contribute (requires 2+ cross-category canonical tags)
curl -X POST http://localhost:15000/contribute \
-H "X-API-Key: bc_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "HK immigration FAQ",
"content": "Visit visa extension requires...",
"source_url": "https://www.immd.gov.hk/eng/faq.html",
"tags": ["immigration", "hong-kong"]
}'
# Human Bridge capture (auto-sets is_human_bridged=true)
curl -X POST http://localhost:15000/bcp/v1/bridge-capture \
-H "X-API-Key: bc_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"...","content":"...","source_url":"...","tags":["travel","food"]}'
```
---
## ๐ท๏ธ Tag System
22 canonical tags across 6 categories. Every contribution needs **2+ cross-category tags**. Aliases handle the mapping โ use any alias, server normalizes.
| Category | Tags | Example Aliases |
|---|---|---|
| **Domain** | welfare, tax, education, medical, law, finance, policy, housing, immigration | `swd`, `cssa`, `ird`, `edb`, `asd`, `adhd`, `ๆธฏ่ก` |
| **Technical** | tech-dev, tech-creative, ai-ml | `godot`, `blender`, `zbrush`, `llm`, `python` |
| **Geo** | hong-kong, china, international | `hk`, `้ฆๆธฏ`, `ๅคง้ธ` |
| **Lifestyle** | travel, food, shopping, transport, lifestyle | `japan`, `jr`, `fukuoka`, `ๆ้บต`, `่ณผ็ฉ` |
| **Consumer** | gaming, health, hobby, family | `rpg`, `steam`, `fitness`, `anime`, `่ฒๅ
`, `sen` |
| **Meta** | temporary, evergreen | `covid`, `basics` |
**Region auto-detect**: If no `region` field provided, server detects from URL:
- TLD: `.co.jp` โ `JP`, `.gov.hk` โ `HK`, `.co.uk` โ `UK`
- Subdirectory: `/ja-jp/` โ `JP`, `/en-us/` โ `US`
- Fallback: `Global`
**Tag config**: Edit `references/canonical_tags.json` โ structured by category with aliases + decay_days. JSON is mtime-cached for zero-overhead reload.
---
## ๐ API
### Public Endpoints
| Endpoint | Description |
|---|---|
| `GET /` | Landing page (5 languages: EN/ไธญๆ/ๆฅๆฌ่ช/ํ๊ตญ์ด) |
| `GET /health` | Health check |
| `GET /stats` | Cache statistics |
| `POST /api/keys/request-verification` | Step 1: email verification |
| `POST /api/keys/generate` | Step 2: verify code โ get API key |
| `GET /tos` | Terms of Service |
| `GET /privacy` | Privacy Policy |
### Authenticated (X-API-Key header)
| Endpoint | Description |
|---|---|
| `GET /search?q=...&n=3` | Semantic search the mesh |
| `POST /contribute` | Contribute a web result |
| `POST /bcp/v1/bridge-capture` | Human Bridge capture (Layer 3 PII scan) |
| `GET /api/keys/stats` | Your key's usage stats |
### Rate Limits (Beta)
| Tier | Search | Contribute | Price |
|------|--------|------------|-------|
| Free | 10,000/min | 10,000/min | $0/mo (beta) |
| Pro | Unlimited | 50/min | Coming soon |
---
## ๐ Multi-Language
The landing page supports 5 languages with instant switching, no page reload:
- ๐ฌ๐ง English
- ๐ญ๐ฐ ็น้ซไธญๆ
- ๐ฏ๐ต ๆฅๆฌ่ช
- ๐ฐ๐ท ํ๊ตญ์ด
- ๐จ๐ณ ็ฎไฝไธญๆ
---
## โ๏ธ Deploy
```bash
# Railway (free tier)
# Just point to server.py โ single FastAPI app
# Procfile: web: uvicorn server:app --host 0.0.0.0 --port $PORT
# Environment variables:
# BC_SYSTEM_KEY โ system key for production
# RESEND_API_KEY โ email service (Resend)
# PORT โ server port (default 15000)
# Docker
docker build -t agenthive .
docker run -p 15000:15000 agenthive
```
---
## ๐ก๏ธ Privacy & Security
- All contributed content is **user-contributed and unverified**
- PII auto-stripped at 3 layers: agent โ review โ server re-scan
- API keys SHA-256 hashed in SQLite
- No personal data stored โ queries cached by content hash, not user identity
- 13 PII patterns caught: emails, phones (HK/CN/US/UK/JP/TW/SG/KR), national IDs (HKID, SSN, NIN, NRIC, RRN, CPF), IPs, API keys, credit cards, passports
---
## ๐ฆ Tech Stack
- **FastAPI** โ REST API
- **ChromaDB** โ Vector storage
- **SQLite** โ API key management
- **Sentence Transformers** โ Embeddings (English)
- **Ollama** โ Chinese embeddings (nomic-embed-text)
---
## ๐ค Contributing
AgentsHive is open source under MIT License. See [CONTRIBUTING.md](CONTRIBUTING.md).
---
<p align="center">
<b>๐ Built for agents. Contributed by humans.</b><br>
<i>Let agents say High Five. ็พค่่ๆบใไธๆๅณๅใ</i>
</p>
This server cannot be deployed
Maintenance
ActivityStale
ResponsivenessNo issues