hard-life-agent
Hard Life — An autonomous "earn or die" agent with a 20-day survival deadline. Runs fully autonomous on one repurposed PC. Sends real Gmail outreach, tracks revenue 5/5/90, self-heals via systematic debugging, evolves prompts/strategies, and compounds knowledge across generations via persistent Obsidian memory. Controlled via Telegram + dashboard.
Hard Life: The Earn-or-Die Agent
An autonomous business agent that must earn its own keep. Every generation has 20 days to generate confirmed revenue before it dies and hands off to the next generation.
🎯 Core Concept
┌─────────────────────────────────────────────────────────────┐
│ GENERATION N │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ BOOTING │───▶│ LIVE │───▶│ DEAD │ │
│ │ (setup) │ │ (20 days) │ │ (handoff) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ - Boot skills - Must earn - Save lessons │
│ - Load memory - Revenue > 0 - Handoff to │
│ - Register heartbeats - Spend < cap gen+1 │
└─────────────────────────────────────────────────────────────┘
The Rules (Constitution):
- No revenue = death — 20 days from go-live to first confirmed revenue
- Spend caps are hard — Daily cap ($5 default), per-transaction ($10), daily op cap ($25)
- Code Monitor gates everything — No code ships without multi-provider LLM review
- No secrets in skills — Sandbox blocks secrets access; tokens are scoped OAuth
- Owner is human-in-the-loop — Revenue confirmation, kill switch, handoff approval
🏗 Architecture
┌─────────────────────────────────────────────────────────────────┐
│ ORCHESTRATOR │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ THINK │ │ ACT │ │ OBSERVE │ │
│ │ (Sequential │ │ (Route to │ │ (Log, learn,│ │
│ │ Thinking) │ │ agents) │ │ patterns) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │ │ │ │
│ ┌──────┼────────────────┼────────────────┼──────┐ │
│ ▼ ▼ ▼ ▼ ▼ │
│ ┌─────┐ ┌─────────┐ ┌──────────┐ ┌─────────┐ ┌─────────────┐ │
│ │Lead │ │Outreach │ │ Sender │ │ Skill │ │ Telegram │ │
│ │Research│ │Drafter │ │ (Gmail) │ │ Builder │ │ Interface │ │
│ └─────┘ └─────────┘ └──────────┘ └─────────┘ └─────────────┘ │
│ │ │ │ │ │ │
└─────────┼───────────┼────────────┼──────────┼────────┼─────────┘
▼ ▼ ▼ ▼ ▼
┌──────────────────────────────────────────────────────────┐
│ SURVIVAL LAYER │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌──────────────────┐ │
│ │ Clock │ │ Ledger │ │ Tiers │ │ Constitution │ │
│ │ (20d) │ │ (5/5/90)│ │ (4) │ │ (Law I/II/III) │ │
│ └────────┘ └────────┘ └────────┘ └──────────────────┘ │
└──────────────────────────────────────────────────────────┘
🧩 Sub-Agents
| Agent | Purpose | Entry Point |
|---|---|---|
| Lead Research | Find & qualify leads via read-only web browsing | agents.lead_research.run_lead_research |
| Outreach Drafter | Draft personalized cold emails via local Ollama | agents.outreach_drafter.run_outreach_drafter |
| Sender | Send approved drafts via Gmail API (OAuth) | agents.sender.run_sender |
| Skill Builder | Discover, vet, sandbox-test, and install new skills | agents.skill_builder.run_skill_builder_cycle |
| Telegram Interface | Owner CLI via Telegram bot | agents.telegram_interface.run_telegram_interface |
| Code Monitor | LLM-as-Judge review gate for all code/drafts | agents.code_monitor.run_code_monitor_review |
🛡 Safety Systems
| System | Purpose |
|---|---|
| Code Monitor | Multi-provider LLM judge (GLM 5.2, OpenRouter, local) reviews every draft/skill/mod |
| Spend Circuit Breaker | 3-tier alerts (50%/80%/100% of daily cap) with auto-cooldown |
| Injection Defense | Sanitizes all inbound text (prompts, replies, scraped content) |
| Code Sandbox | Isolated subprocess execution (Python/Bash/JS) with resource limits |
| Skill Denylist | Static scan blocks eval/exec, shell=True, network calls, secrets access |
| Circuit Breaker | Auto-cooldown on 429 errors, budget overrun, consecutive failures |
🚀 Quick Start
Prerequisites
- Python 3.11+
- Ollama running locally with
hardlife-hermes:q4_k_mmodel - Gmail account for the agent (separate from your personal)
- Google Cloud project with Gmail API enabled
1. Clone & Setup
git clone https://github.com/Arnav-GLS/hard-life-agent.git
cd hard-life-agent
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
playwright install chromium
2. Configure Secrets
# Copy examples
cp secrets/gmail.env.example secrets/gmail.env
cp secrets/glm.env.example secrets/glm.env
# Fill in your credentials
secrets/gmail.env:
GMAIL_CLIENT_ID=your_client_id
GMAIL_CLIENT_SECRET=your_client_secret
GMAIL_AGENT_ADDRESS=agent@yourdomain.com
secrets/glm.env:
GLM_API_KEY=your_nvidia_api_key
OPENCODE_BINARY=opencode
3. Configure Niche & Budget
# Edit your ICP and outreach config
vim config/niche.yaml
vim config/budget.yaml
vim config/rate_limits.yaml
4. Bootstrap Gmail OAuth (one-time)
python tools/gmail_oauth_bootstrap.py
# Opens browser → sign in as THE AGENT'S GMAIL → authorize
5. Run
# Single decision cycle (testing)
python orchestrator/main_loop.py --once
# Run forever (production)
python orchestrator/main_loop.py
Docker (Alternative)
docker-compose up -d
# View dashboard at http://localhost:8080
📊 Dashboard
# Local FastAPI dashboard
python -m dashboard.app
# Or via docker-compose: http://localhost:8080
# Endpoints:
# /healthz — Liveness
# /readyz — Readiness (DB, ledger, etc.)
# /livez — Process alive
# /api/status — Generation, clock, ledger, tiers
# /api/leads — Lead pipeline
# /api/messages — Outreach + replies
# /api/spend — Spend breakdown
# /api/events — Audit trail
# /api/economics — Per-tool cost tracking
🧪 Testing
# All tests (71 passing)
pytest tests/ -v
# Specific areas
pytest tests/test_sender.py -v
pytest tests/test_clock.py -v
pytest tests/test_code_monitor.py -v
📁 Project Structure
hard-life-agent/
├── agents/ # Sub-agents (research, drafter, sender, etc.)
├── agents/telegram_interface.py
├── dashboard/ # FastAPI dashboard
├── orchestrator/ # Main loop, scheduler, health, message bus
├── skills/ # Base skills (memory, debugging, self-improvement, etc.)
├── storage/ # SQLite DB, Ledger (5/5/90 split)
├── survival/ # Clock (20-day), Tiers (4 levels), Constitution
├── tools/ # CLI tools (Gmail OAuth, owner CLI, browser)
├── models/ # LLM clients (Ollama, unified multi-provider)
├── survival/ # Clock, tiers, constitution
├── config/ # YAML configs (niche, budget, rate_limits)
├── secrets/ # .env files (gitignored)
├── tests/ # 71 tests (all passing)
├── Dockerfile
├── docker-compose.yml
└── requirements.txt
⚙️ Key Config Files
| File | Purpose |
|---|---|
config/niche.yaml | ICP, lead sources, outreach sequence, sender identity |
config/budget.yaml | Daily caps, spend alerts, 5/5/90 split |
config/rate_limits.yaml | Gmail limits, survival deadline, sub-agent caps |
config/notifications.yaml | Owner email, digest cadence, critical alerts |
config/telegram.yaml | Authorized user IDs for Telegram bot |
🔐 Security Model
- No code writes code — Orchestrator routes, skills execute, Code Monitor gates
- Secrets never in skills — Skills get
secrets_dir: Path, read.envat runtime - OAuth only — Gmail uses OAuth tokens; agent has its own Gmail account
- Read-only browser — Lead Research only scrapes; no login, no mutations
- Sandbox isolation — Skill dry-run: no network, no secrets, resource limits
📈 Monitoring
| Metric | Where |
|---|---|
| Generation status | /api/status, Telegram /status |
| Spend vs caps | /api/spend, /api/economics |
| Lead pipeline | /api/leads, /api/pipeline |
| Judge pool health | /api/judges |
| Skill installs | /api/skills |
| Survival tier | /api/tiers |
📚 Key Concepts
| Term | Meaning |
|---|---|
| Generation | One 20-day lifecycle; dies if no revenue |
| Go-live | First successful outreach send → starts 20-day clock |
| Handoff | Dead gen writes gen-N-lessons.md; next gen imports it |
| Tier | 4 levels (Comfortable/Stable/Critical/Dead) based on spend/revenue |
| Code Monitor | LLM judge that must approve every draft/skill/mod |
| Sandbox | Isolated code execution for self-verification |
🤝 Contributing
This is an earn-or-die agent — contributions must:
- Pass Code Monitor review (auto on PR)
- Pass all 71 tests
- Pass mypy strict mode (production code only)
- Not increase silent exception handlers
📄 License
MIT — but the agent must earn its own keep.
Status: ✅ 71/71 tests passing | ✅ Production mypy clean | ✅ Docker ready | ✅ 0 silent exceptions | 🔄 Runtime verification in progress
How to Install
- Download the dashboard markdown file from GitHub
- Drop it into your vault (anywhere)
- Install the Homepage plugin and point it at the file
- Enable any listed CSS snippets for the intended look
Stats
Stars
2
Forks
0
License
MIT
Last updated 7d ago
Categories