This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ZeroAgent is a TypeScript npm framework for self-evolving AI agents. Agents start with zero tools, generate tools on demand via LLM, store them permanently on-chain (0G Storage), and reuse them across tasks and agent networks. Built as a hackathon entry for ETHGlobal Open Agents 2026.
# Build all packages
pnpm build
# Watch mode (all packages)
pnpm dev
# Dashboard only
cd packages/dashboard && pnpm dev # Next.js dev server
cd packages/dashboard && pnpm build # Next.js production build
cd packages/dashboard && pnpm lint # Next.js lintcd packages/demo-agent && pnpm demo # 12-step demo sequence# Run from root with tsx
tsx scripts/test-storage.ts # 0G upload/download (ZERO_G_PRIVATE_KEY required)
tsx scripts/test-agent.ts # Full evolution loop (ZERO_G_PRIVATE_KEY required)
tsx scripts/test-ens-identity.ts # ENS read/write - 11 test cases
# AXL P2P test (Windows PowerShell, requires local AXL binary at ./local-axl/)
powershell -ExecutionPolicy Bypass -File scripts/test-axl-local.ps1pnpm test:storage # → tsx scripts/test-storage.ts
pnpm test:agent # → tsx scripts/test-agent.tspackages/
core/ → @zero-agents/core (main published framework, ~1,650 LOC)
demo-agent/ → @zero-agents/demo-agent (ResearchAgent example)
dashboard/ → @zero-agents/dashboard (Next.js monitoring UI, placeholder)
scripts/ → Integration tests
docs/ → API reference, guides
All packages use ESM ("type": "module"), TypeScript strict mode, and are managed via pnpm workspaces.
When a task arrives:
- Search
ToolRegistryby name/description - HIT → execute cached tool → done
- MISS →
EvolutionEngine.evolve():ToolGeneratorcalls 0G Compute broker → falls back to OpenAIgpt-4o-miniToolSandboxexecutes code inisolated-vm(16MB, 3s timeout) → falls back to NodevmToolEvaluatorgenerates 2 LLM test cases, scores ≥ 0.7 to pass- On failure: retry up to 3× with error feedback
- On pass:
ToolRegistry.saveTool()uploads JSON blob to 0G Storage
- Tool is now cached locally and on-chain for future agents
| Module | Purpose |
|---|---|
self-evolving-agent.ts |
Main agent class (EventEmitter), orchestrates all subsystems |
evolution-engine.ts |
3-attempt retry loop with feedback |
generation/tool-generator.ts |
LLM tool code generation (0G Compute → OpenAI fallback) |
sandbox/tool-sandbox.ts |
isolated-vm execution with Node vm fallback |
sandbox/tool-evaluator.ts |
LLM test generation + pass/fail scoring |
storage/zero-g.ts |
0G Storage upload/download (ethers.js signer) |
storage/tool-registry.ts |
Tool index: local .zero-agent-index.json + 0G root hashes + in-memory cache |
identity/ens-identity-manager.ts |
ENS text records on Sepolia (viem) |
communication/axl-client.ts |
HTTP client for Gensyn AXL (polling GET /recv, POST /send) |
communication/agent-coordinator.ts |
Routes AXL messages → agent task handling + tool sharing |
- Fallback chains: 0G Compute → OpenAI for generation; isolated-vm → Node vm for sandboxing
- Retry with feedback: evolution engine captures sandbox/eval errors and passes them back to the generator
- Local pointer + on-chain truth:
.zero-agent-index.jsonmaps tool names to 0G root hashes; in-memory cache for hot tools - EventEmitter steps: agent emits
search,miss,generating,sandboxing,evaluating,saving,executing,done,errorfor real-time observability
- 0G Testnet RPC:
https://evmrpc-testnet.0g.ai - 0G Indexer:
https://indexer-storage-testnet-turbo.0g.ai - Sepolia ENS: Public Resolver at
0xE99638b40E4Fff0129D56f03b55b6bbC4BBE49b5 - Gensyn AXL:
http://localhost:9002
ZERO_G_PRIVATE_KEY # Required: 0G testnet signing key
OPENAI_API_KEY # Optional: fallback LLM (gpt-4o-mini)
ENS_PRIVATE_KEY # Optional: for ENS text record writes
ENS_NAME # Optional: agent's ENS name (e.g. my-agent.eth)
SEPOLIA_RPC_URL # Optional: custom Sepolia RPC
Copy .env.example to .env before running any scripts.
Root tsconfig.json enforces:
strict: true,noUnusedLocals,noUnusedParameters,noImplicitReturns- Target: ES2020, Module: ESNext, Resolution: bundler
- Declaration maps + source maps enabled
All packages extend the root config with rootDir: src / outDir: dist.
- Node.js 20+ (required for
isolated-vmnative module) - pnpm 8+
- Windows: Visual Studio Build Tools 2022 for native module compilation
AGENTS.md— Cursor AI project rules and sponsor integration contextpackages/core/src/index.ts— All public exportspackages/demo-agent/scripts/run-demo.ts— 12-step demo sequence showing full framework usagedocs/api-reference.md— Full API documentation