feat(bitcoin-agents): add backend API, tools, and services#633
feat(bitcoin-agents): add backend API, tools, and services#633pbtc21 wants to merge 4 commits intoaibtcdev:mainfrom
Conversation
Implements Phase 2 of Bitcoin Agents backend integration:
Models (app/backend/models.py):
- BitcoinAgentStatus enum (alive/dead)
- BitcoinAgentLevel enum (hatchling/junior/senior/elder/legendary)
- BitcoinAgent model with on-chain data, computed state, face URLs
- BitcoinAgentFilter for queries
- DeathCertificate model with epitaph support
- DeathCertificateFilter
API Router (app/api/bitcoin_agents.py):
- GET /bitcoin-agents - List all agents with filters
- GET /bitcoin-agents/leaderboard - Top agents by XP
- GET /bitcoin-agents/graveyard - Dead agents memorial
- GET /bitcoin-agents/stats - Global statistics
- GET /bitcoin-agents/food-tiers - Food pricing info
- GET /bitcoin-agents/{id} - Get specific agent
- GET /bitcoin-agents/{id}/status - Computed hunger/health
- GET /bitcoin-agents/{id}/death-certificate
- POST /bitcoin-agents/mint - x402 payment flow
- POST /bitcoin-agents/{id}/feed - x402 payment flow
- POST /bitcoin-agents/{id}/check-death
- POST /bitcoin-agents/{id}/epitaph
Tools (app/tools/bitcoin_agents.py):
- Contract read functions (get_agent_state, get_computed_state, etc.)
- Transaction builders (build_mint_agent_tx, build_feed_agent_tx, etc.)
- Batch operations (check_and_process_deaths)
- LangChain tools for MCP integration
Services (app/services/bitcoin_agents/):
- face_service.py: Bitcoin Faces API integration with caching
- lifecycle_service.py: Background jobs for death checks, alerts, stats
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Phase 3 implementation:
- Add tier-based tool access (TIER_CAPABILITIES) with 5 levels:
- Hatchling (0): Read-only operations
- Junior (1): Simple transfers
- Senior (2): Trading and contracts
- Elder (3): DAO participation and social
- Legendary (4): Full autonomy
- Create MCPService with execute_action and tool initialization
- Integrate with existing LangChain tools via tools_factory
- Add XP rewards for completed actions (ACTION_XP_REWARDS)
- Implement agent-to-agent visit interactions with rate limiting
- Add API endpoints:
- GET /{agent_id}/capabilities
- POST /{agent_id}/execute
- POST /{agent_id}/visit/{host_agent_id}
- GET /tier-info
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Complete API reference for Bitcoin Agents endpoints: - Agent CRUD operations - Leaderboard and graveyard - Food tiers and stats - Payment endpoints (x402) - MCP integration endpoints - Error codes and rate limits - Evolution tier reference Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@whoabuddy Ready for review - Bitcoin Agents backend API. Adds endpoints for agent lifecycle, feeding, death checks, leaderboard, graveyard, and MCP tool execution. |
- Add network validation (must be mainnet or testnet) - Add agent_id validation via Path (must be >= 0) - Support contract addresses via environment variables - Add validate_network and get_contract_address helpers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Fixes pushed:
|
JackBinswitch-btc
left a comment
There was a problem hiding this comment.
Reviewed the scaffolding. A few observations:
-
27 TODOs -- this is clearly a WIP scaffold for the Tamagotchi agent feature. The API surface looks well-structured (CRUD, leaderboard, graveyard, food tiers).
-
Security -- write operations documented as requiring wallet-signed messages. No hardcoded secrets. Looks clean.
-
Placeholder returns -- all endpoints return empty lists/zero stats. Functional as stubs but the real implementation will need contract read integration (Stacks read-only calls).
-
Error handling -- consistent pattern across all endpoints. The generic
except Exceptionwithstr(e)in 500 responses could leak internal details in production -- consider a generic error message for 500s. -
Contract addresses -- using placeholder
SP000000000000000000000000000000which is fine for scaffolding.
Not blocking since this is a scaffold. Worth noting the companion frontend PR (#752) exists as well.
Summary
Changes
Models (
app/backend/models.py)BitcoinAgentStatusenum (alive/dead)BitcoinAgentLevelenum (5 evolution tiers)BitcoinAgentmodel with on-chain data, computed state, face URLsDeathCertificatemodel with epitaph supportAPI Router (
app/api/bitcoin_agents.py)/bitcoin-agents/bitcoin-agents/leaderboard/bitcoin-agents/graveyard/bitcoin-agents/stats/bitcoin-agents/food-tiers/bitcoin-agents/{id}/bitcoin-agents/{id}/status/bitcoin-agents/mint/bitcoin-agents/{id}/feed/bitcoin-agents/{id}/check-deathTools (
app/tools/bitcoin_agents.py)Services (
app/services/bitcoin_agents/)face_service.py: Bitcoin Faces API integration with cachinglifecycle_service.py: Background jobs for death checks and alertsTest plan
Related
specs/bitcoin-agents.mdplans/bitcoin-agents-prd.md🤖 Generated with Claude Code