How blockrunai/clawrouter works
ClawRouter is a local LLM routing gateway and agent-facing plugin: an agent or application submits model/tool requests, local routing selects a capable model, and the proxy reaches BlockRun/provider services with API-key or wallet/x402 billing. The repository also provides model compression, wallet management, partner tools, Polymarket operations, and a desktop dashboard for proxy, agent, and wallet management. The main entrypoint, desktop manager, compression, and Polymarket client excerpts support the links shown; broader feature links are limited to README capabilities and explicit exported/runtime paths.
Main entry points: index.ts Plugin entry · proxy.ts Local proxy · manager.ts Runtime manager · auth.ts Wallet and auth
Components 28
Request Routing
- Plugin entry
src/index.ts - Model router
src/router/index.ts - Local proxy
src/proxy.ts - Provider gateway
src/provider.ts - Context compression
src/compression/index.ts - Model catalog
src/models.ts - Response cache
src/response-cache.ts - Usage statistics
src/stats.ts
Identity and Billing
- Wallet and auth
src/auth.ts - Wallet derivation
src/wallet.ts - Session billing
src/session.ts - Balance checks
src/balance.ts - Payment preauthorization
src/payment-preauth.ts - Local state
src/response-store.ts
Agent Capabilities
- Market operations
src/polymarket/tool.ts - Market client
src/polymarket/client.ts - Partner tools
src/partners/tools.ts - Web search
src/web-search-provider.ts
Desktop Management
- Desktop dashboard
apps/desktop/src/App.tsx - Desktop API
apps/desktop/src/api.ts - Electron IPC
apps/desktop/electron/main.ts - Runtime manager
apps/desktop/electron/core/manager.ts - Service supervisor
apps/desktop/electron/core/supervisor.ts
Other components
- Agent / SDK
- BlockRun gateway
- Model providers
- Blockchain networks
- Polymarket CLOB
Connections 29
- Agent / SDK → Plugin entry: submits requests
- Plugin entry → Local proxy: forwards requests
- Plugin entry → Model router: selects models
- Model router → Model catalog: resolves aliases
- Local proxy → Context compression: compresses context
- Local proxy → Provider gateway: dispatches inference
- Provider gateway → BlockRun gateway: sends API calls
- Provider gateway → Model providers: sends inference
- Local proxy → Response cache: checks cache
- Local proxy → Usage statistics: records usage
- Plugin entry → Wallet and auth: resolves credentials
- Wallet and auth → Wallet derivation: derives keys
- Plugin entry → Session billing: manages billing session
- Session billing → Balance checks: checks funds
- Session billing → Payment preauthorization: preauthorizes payment
- Payment preauthorization → Blockchain networks: settles x402
- Wallet and auth → Local state: persists wallet state
- Plugin entry → Market operations: exposes market tools
- Market operations → Market client: places market operations
- Market client → Polymarket CLOB: authenticates and trades
- Plugin entry → Partner tools: registers partner tools
- Plugin entry → Web search: provides search
- Desktop dashboard → Desktop API: invokes dashboard actions
- Desktop API → Electron IPC: sends IPC
- Electron IPC → Runtime manager: dispatches operations
- Runtime manager → Service supervisor: controls proxy service
- Service supervisor → Local proxy: starts and monitors
- Runtime manager → Wallet and auth: reads wallet state
- Runtime manager → BlockRun gateway: requests balances and onramp