How jrastit/agent-router works
AgentRouter’s primary product is a reusable 0G model-routing and provenance toolkit; the Next.js application is a demonstration surface rather than the main artifact. The documented workflow is to discover model routes, apply caller policy deterministically, execute through 0G Compute, and preserve evidence using storage and chain provenance. The repository also exposes an example LLM-job and payment-evidence application. Some toolkit integrations and application subsystems are represented from README capabilities and the file tree; their internal wiring was not sampled, so those links are documented rather than inferred from imports.
Main entry points: submission.ts LLM Job Submission · router.ts Policy Router · 0g-router.ts 0G Compute · receipt.ts Routing Receipt
Components 18
Reusable Toolkit
- Model Catalog
src/toolkit/catalog/0g-router.ts - Policy Router
src/toolkit/router.ts - Toolkit Contracts
src/toolkit/contracts.ts
0G Runtime
- 0G Compute
src/toolkit/compute/0g-router.ts - 0G Storage
src/toolkit/storage/0g.ts - Routing Receipt
src/toolkit/receipt.ts - 0G Chain Proof
src/toolkit/provenance/0g-chain.ts
Example Application
- Example UI
src/app/page.tsx - Requirement Planner
src/lib/planner/planner.ts - Provider Discovery
src/lib/discovery/graph.ts - LLM Job Submission
src/lib/llm-jobs/submission.ts - Job Execution
src/lib/llm-jobs/supabase-execution.ts - Supabase State
src/lib/llm-jobs/supabase-execution.ts
Evidence Services
- HBAR Settlement
src/lib/payment/settle.ts - Activity Projection
src/lib/projection/graph.ts - Graph Evidence MCP
src/mcp/graph-evidence/server.ts - Graph Evidence Client
src/mcp/graph-evidence/graph-client.ts
Other components
- Agent Developer
Connections 19
- Agent Developer → Model Catalog: uses toolkit
README.md - Model Catalog → Policy Router: supplies routes
README.md - Policy Router → 0G Compute: selects route
README.md - 0G Compute → Routing Receipt: records execution
README.md - 0G Storage → Routing Receipt: stores evidence
README.md - Routing Receipt → 0G Chain Proof: anchors hash
README.md - 0G Chain Proof → Agent Developer: verifies receipt
README.md - Agent Developer → Example UI: tries example
README.md - Example UI → Requirement Planner: submits request
- Requirement Planner → Provider Discovery: derives requirements
README.md - Provider Discovery → LLM Job Submission: offers candidates
README.md - LLM Job Submission → Job Execution: creates job
- Job Execution → Supabase State: persists state
- LLM Job Submission → HBAR Settlement: settles payment
README.md - HBAR Settlement → Activity Projection: emits audit events
README.md - Activity Projection → Graph Evidence Client: indexes evidence
- Graph Evidence Client → Graph Evidence MCP: provides evidence tools
src/mcp/graph-evidence/server.ts - Toolkit Contracts → Policy Router: defines interfaces
src/toolkit/router.ts - Toolkit Contracts → 0G Compute: defines adapter
src/toolkit/compute/0g-router.ts