feat(bitcoin-agents): add backend API, tools, and services#633
Open
pbtc21 wants to merge 4 commits intoaibtcdev:mainfrom
Open
feat(bitcoin-agents): add backend API, tools, and services#633pbtc21 wants to merge 4 commits intoaibtcdev:mainfrom
pbtc21 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>
Open
5 tasks
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>
Author
|
@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>
Author
|
Fixes pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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