-
Notifications
You must be signed in to change notification settings - Fork 0
Development‐Guide
AGI Corp edited this page Mar 8, 2026
·
1 revision
This guide walks through setting up the Web4AGI development environment, testing protocols, debugging procedures, and contributing to the codebase.
- OS: macOS 13+, Ubuntu 20.04+, or Windows 11 with WSL2
- Node.js: v18.0.0 or higher
- Python: 3.10 or higher
- Docker: 24.0+ (optional but recommended)
- Git: 2.38+
- Sentient Foundation API - Sign up at sentientfoundation.ai
- x402 Wallet - Create at x402.org
- Ethereum Testnet ETH - Get from Goerli faucet
- OpenAI API - For fallback models
git clone https://github.com/AGI-Corporation/Web4AGI.git
cd Web4AGI# Install frontend dependencies
npm install
# Verify Next.js works
npm run build# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -r requirements-dev.txt# Copy example environment file
cp .env.example .env
# Edit with your values
nano .envRequired variables:
# Sentient Foundation
SENTIENT_API_KEY=sf-your-key-here
SENTIENT_BASE_URL=https://api.sentientfoundation.ai/v1
SENTIENT_MODEL=sentient-70b
# x402 Protocol (Use testnet keys for development)
X402_PRIVATE_KEY=0x-your-private-key
X402_GATEWAY=https://goerli.x402.org/api/v1
X402_NETWORK=goerli
# Route.X MCP
ROUTE_X_BASE=http://localhost:8001
MCP_SERVER_URL=ws://localhost:8001/mcp
# Database
DATABASE_URL=postgresql://localhost:5432/web4agi_dev
REDIS_URL=redis://localhost:6379
# Ethereum
ETH_RPC_URL=https://goerli.infura.io/v3/your-infura-key
USLC_CONTRACT_ADDRESS=0x-testnet-usdc-address# Start PostgreSQL and Redis using Docker
docker-compose up -d postgres redis
# Run database migrations
alembic upgrade head
# Seed test data
python scripts/seed_dev_data.py# Terminal 1: Backend API
python src/main.py --reload
# Terminal 2: MCP Server (Route.X)
python src/mcp_server.py
# Terminal 3: Frontend
npm run dev
# Terminal 4: Agent workers (optional)
python src/agent_worker.py --parcels 5# Check API health
curl http://localhost:8001/health
# Check MCP server
curl http://localhost:8001/mcp/status
# Open dashboard
open http://localhost:3000Web4AGI/
├── src/
│ ├── agents/ # Agent core logic
│ │ ├── parcel_agent.py # Main agent class
│ │ ├── trading.py # Trading logic
│ │ ├── contracts.py # Smart contract interaction
│ │ └── memory.py # Agent memory management
│ ├── api/ # FastAPI routes
│ │ ├── parcels.py # Parcel CRUD endpoints
│ │ ├── trades.py # Trading endpoints
│ │ ├── contracts.py # Contract endpoints
│ │ └── websocket.py # WS real-time feed
│ ├── blockchain/ # Web3 integration
│ │ ├── wallet.py # x402 wallet
│ │ ├── contracts/ # Solidity contracts
│ │ └── stablecoin.py # USDC/USDT management
│ ├── mcp/ # MCP server
│ │ ├── server.py # MCP server setup
│ │ ├── tools.py # Tool definitions
│ │ └── resources.py # Resource handlers
│ ├── models/ # Database models
│ ├── main.py # FastAPI app entry
│ └── agent_worker.py # Agent process runner
├── frontend/
│ ├── app/ # Next.js App Router
│ ├── components/ # React components
│ ├── hooks/ # Custom React hooks
│ └── lib/ # Utility functions
├── contracts/ # Hardhat Solidity project
├── tests/ # All test files
│ ├── unit/
│ ├── integration/
│ └── e2e/
├── scripts/ # Utility scripts
├── docker-compose.yml
├── requirements.txt
├── package.json
└── .env.example
# Python tests
pytest tests/ -v --cov=src
# Frontend tests
npm test
# Smart contract tests
cd contracts && npx hardhat test# Test specific module
pytest tests/unit/test_agent.py -v
pytest tests/unit/test_trading.py -v
# With coverage report
pytest tests/unit/ --cov=src --cov-report=html
open htmlcov/index.html# Requires running services
pytest tests/integration/ -v
# MCP integration tests
pytest tests/integration/test_mcp.py -v# Start all services first
docker-compose up -d
# Run E2E tests
npm run test:e2e
# Playwright tests
npx playwright test# Check logs
tail -f logs/agent.log
# Debug mode
LOG_LEVEL=DEBUG python src/agent_worker.py
# Test Sentient Foundation connectivity
python -c "from src.agents.parcel_agent import test_connection; test_connection()"# Verify x402 connection
python -c "
from src.blockchain.wallet import ParcelWallet
w = ParcelWallet(os.getenv('X402_PRIVATE_KEY'))
print('Balance:', w.get_balance())
"# Check Route.X server status
curl http://localhost:8001/health
# Restart MCP server
pkill -f mcp_server.py && python src/mcp_server.py &
# Test MCP tools
python -c "
from src.mcp.server import test_tools
test_tools()
"import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(name)s %(levelname)s %(message)s'
)
# Enable specific module debug logs
logging.getLogger('web4agi.agent').setLevel(logging.DEBUG)
logging.getLogger('web4agi.trading').setLevel(logging.DEBUG)
logging.getLogger('web4agi.mcp').setLevel(logging.DEBUG)# Build images
docker-compose build
# Start production stack
docker-compose -f docker-compose.prod.yml up -d
# Scale agents
docker-compose -f docker-compose.prod.yml scale agent-worker=10# Switch to mainnet
X402_GATEWAY=https://x402.org/api/v1
X402_NETWORK=mainnet
# Use production Sentient model
SENTIENT_MODEL=sentient-70b
# Production database
DATABASE_URL=postgresql://prod-host:5432/web4agi- Fork the repository on GitHub
-
Create a feature branch:
git checkout -b feature/my-feature - Write tests for your changes
- Implement your feature or fix
-
Run all tests:
pytest && npm test -
Commit with descriptive message:
git commit -m 'feat: add parcel teleportation' -
Push to your fork:
git push origin feature/my-feature -
Open a Pull Request against
main
feat: add new feature
fix: resolve bug in trading engine
docs: update API reference
test: add tests for wallet integration
refactor: optimize agent decision loop
chore: update dependencies
# Python formatting
black src/ tests/
flake8 src/ tests/
mypy src/
# JavaScript/TypeScript
npm run lint
npm run format- Home - Project overview
- Agent System - Agent architecture
- Trading Protocol - Trading implementation
- MCP Integration - Route.X plugin
- API Reference - Full API docs