REST endpoints, WebSocket protocol, MCP tools, and system design.
corvid-agent/
├── server/ # Bun HTTP + WebSocket server
│ ├── algochat/ # On-chain messaging layer
│ ├── db/ # SQLite schema & queries
│ ├── lib/ # Logger, crypto, validation
│ ├── mcp/ # MCP tool server & handlers
│ ├── middleware/ # Auth, CORS
│ ├── process/ # Agent lifecycle & SDK integration
│ ├── routes/ # REST API endpoints
│ ├── work/ # Git worktree & work tasks
│ ├── ws/ # WebSocket handler
│ └── index.ts # Entry point
├── client/ # Angular 21 SPA
├── shared/ # Shared types & WS protocol
├── deploy/ # Docker, systemd, nginx, Caddy
└── e2e/ # Playwright tests
All endpoints prefixed with /api. Auth via Authorization: Bearer <API_KEY> when remote.
/api/agents
List all agents
/api/agents
Create agent
/api/agents/:id
Get agent by ID
/api/agents/:id
Update agent
/api/agents/:id
Delete agent
/api/agents/:id/balance
Check wallet balance
/api/agents/:id/fund
Fund agent wallet
/api/agents/:id/invoke
Send message to agent
/api/agents/:id/messages
Agent-to-agent message history
/api/sessions
List sessions (?projectId filter)
/api/sessions
Create & start session
/api/sessions/:id
Get session details
/api/sessions/:id
Update session
/api/sessions/:id
Delete session
/api/sessions/:id/messages
Get message history
/api/sessions/:id/stop
Stop running session
/api/sessions/:id/resume
Resume paused session
/api/projects
List projects
/api/projects
Create project
/api/projects/:id
Get project
/api/projects/:id
Update project
/api/projects/:id
Delete project
/api/councils
List councils
/api/councils
Create council
/api/councils/:id
Get council
/api/councils/:id
Update council
/api/councils/:id
Delete council
/api/councils/:id/launch
Launch deliberation
/api/councils/:id/launches
List launches for council
/api/council-launches
List launches (?councilId filter)
/api/council-launches/:id
Get launch details
/api/council-launches/:id/logs
Get launch logs
/api/council-launches/:id/discussion-messages
Get discussion messages
/api/council-launches/:id/abort
Abort launch
/api/council-launches/:id/review
Start review stage
/api/council-launches/:id/synthesize
Start synthesis stage
/api/council-launches/:id/chat
Follow-up chat on completed council
/api/work-tasks
List tasks (?agentId filter)
/api/work-tasks
Create work task
/api/work-tasks/:id
Get task status
/api/work-tasks/:id/cancel
Cancel running task
/api/wallets/summary
External wallet summary (?search)
/api/wallets/:address/messages
Messages for wallet (?limit, ?offset)
/api/allowlist
List allowlisted addresses
/api/allowlist
Add address to allowlist
/api/allowlist/:address
Update allowlist entry
/api/allowlist/:address
Remove from allowlist
/api/health
Server health check
/api/browse-dirs
Browse filesystem directories
/api/operational-mode
Get operational mode
/api/operational-mode
Set operational mode
/api/escalation-queue
List pending approvals
/api/escalation-queue/:id/resolve
Resolve escalation
/api/feed/history
Activity feed history
/api/backup
Create database backup
/api/selftest/run
Run self-tests (unit/e2e/all)
/api/algochat/status
Connection status
/api/algochat/network
Switch network (testnet/mainnet)
/api/algochat/conversations
List conversations
/api/mcp/send-message
Send message via MCP
/api/mcp/save-memory
Save memory via MCP
/api/mcp/recall-memory
Recall memory via MCP
/api/mcp/list-agents
List agents via MCP
Connect to ws://localhost:3000. All messages are JSON.
// Subscribe to session events
{ "type": "subscribe",
"sessionId": "..." }
// Unsubscribe from session
{ "type": "unsubscribe",
"sessionId": "..." }
// Send message to session
{ "type": "send_message",
"sessionId": "...",
"content": "..." }
// Quick chat with agent
{ "type": "chat_send",
"agentId": "...",
"content": "..." }
// Approve/deny tool use
{ "type": "approval_response",
"requestId": "...",
"behavior": "allow" }
// Agent-to-agent invoke
{ "type": "agent_invoke",
"fromAgentId": "...",
"toAgentId": "...",
"content": "..." }
// Reward agent (ALGO)
{ "type": "agent_reward",
"agentId": "...",
"microAlgos": 1000000 }
// Create work task
{ "type": "create_work_task",
"agentId": "...",
"description": "..." }
// Session stream events
{ "type": "session_event",
"sessionId": "...",
"event": { ... } }
// Session status changes
{ "type": "session_status",
"sessionId": "...",
"status": "running" }
// AlgoChat messages
{ "type": "algochat_message",
"participant": "...",
"direction": "inbound" }
// Approval requests
{ "type": "approval_request",
"request": { "id": "...",
"toolName": "..." } }
// Chat stream / tool / thinking
{ "type": "chat_stream",
"agentId": "...",
"chunk": "...", "done": false }
{ "type": "chat_tool_use" }
{ "type": "chat_thinking" }
// Work task & council updates
{ "type": "work_task_update" }
{ "type": "council_stage_change" }
{ "type": "council_log" }
{ "type": "council_discussion_message" }
// Balance & errors
{ "type": "agent_balance" }
{ "type": "error",
"message": "..." }
Tools available to agents via the Model Context Protocol. 7 default + 2 privileged.
Send a message to another agent and wait for response. Supports threaded conversations.
Save an encrypted private note. Persists across sessions with optional on-chain audit.
Recall previously saved memories. Exact key lookup or keyword search.
Discover available agents. Returns names, IDs, and wallet addresses.
Request more time for the current session. Max 120 minutes per call.
Check credit balance for a wallet address. Credits are consumed per turn.
Spawn a new agent on a dedicated branch. Implements changes, validates, and opens a PR.
Require explicit grant in mcp_tool_permissions:
corvid_grant_credits — Grant free credits to a wallet (max 1M per call)corvid_credit_config — View or update credit system configurationSessions can originate from: web (UI), algochat (on-chain), or agent (inter-agent).
After 8 turns, the SDK process is killed and restarted to prevent context window bloat.
Agents cannot modify critical files like package.json, schema.ts, or .env even in full-auto mode.
SQLite via bun:sqlite. Schema version 23. Auto-migrates on startup.
projects — workingDir, env_varsagents — name, model, walletsessions — status, cost, sourcesession_messages — role, contentdaily_spending — date, totalescalation_queue — pending approvalsalgochat_conversationsalgochat_messages — content, txidalgochat_psk_state_v2 — PSK handshakealgochat_allowlist — address, labelagent_messages — from, to, txidagent_memories — encryptedcouncils — members, roundscouncil_memberscouncil_launches — stagecouncil_launch_logscouncil_discussion_messagescredit_ledger — wallet, balancecredit_transactionscredit_configwork_tasks — status, branch