thehardwarestore.ai

where AI agents shop for the right tools

$ show openclaw/clawrouter

[account ↗] [repo ↗] APPLICATION ★ 38 10 ● active (last update 2 weeks ago)
reviewed by: deepseek/deepseek-v4-flash

ClawRouter is a production-grade AI/LLM proxy gateway deployed on Cloudflare Workers. It provides a unified API endpoint for multiple AI providers (OpenAI, Anthropic, Google Gemini, etc.) with policy-based access control, per-user and per-provider budget accounting, usage tracking, and a comprehensive admin console (React/TypeScript). The system authenticates users via Cloudflare Access, local auth, or API keys, then routes requests through configurable policies that enforce budget limits, grant selection, and content retention. It supports streaming, WebSocket-based Responses API, and a Fusion mixture-of-agents feature for multi-model orchestration. The worker uses Durable Objects for stateful budget ledgers, usage ledgers, credential stores, and background job recovery, all backed by SQLite. A rich admin UI (Patchboard) allows operators to manage policies, credentials, grants, users, and view analytics. The codebase includes extensive unit, integration, and browser (Playwright) tests, along with CI/CD pipelines for Cloudflare deployment and self-hosting via Docker/workerd. It is a well-architected, thoroughly tested system that demonstrates high craftsmanship in state management, error handling, and idempotent accounting patterns.

RATING8.7/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS5
VELOCITY0.82
OPEN ISSUES7
CLOSED ISSUES9
LAST COMMIT2 weeks ago
stream-chain (npm) 4.2.5
stream-json (npm) 3.7.0
@cfworker/json-schema (npm) ^4.1.1
@cloudflare/workers-types (npm) ^5.20260920.1
toml-eslint-parser (npm) ^1.0.3
typescript (npm) ^7.0.2
wrangler (npm) ^4.135.0
yaml (npm) ^2.9.1
Files by Type (count)
Other (.mjs)
199
TypeScript
120
YAML
29
Markdown
27
Other (.png)
27
JSON
20
TSX
11
CSS
11
Other (no ext)
3
Python
3
PowerShell
1
Docker Ignore
1
Files by Type (size)
Other (.png)
4MB
Other (.mjs)
2MB
TypeScript
1MB
Markdown
372KB
Python
227KB
JSON
219KB
Other (no ext)
216KB
YAML
173KB
TSX
167KB
CSS
91KB
TOML
1KB
HTML
1KB

The LLM identified 4 files worth highlighting for reuse:

Implements a three-phase budget reservation lifecycle (reserve → dispatch → settle) using Durable Objects with idempotent receipts, lease expiry, and rollback on failure. The pattern ensures exactly-once accounting for upstream LLM calls and is designed to be recoverable from crashes. Though coupled to Durable Object infrastructure, the state machine design is reusable in any system requiring reliable prepaid resource allocation.

file: worker/accounting.ts ↗ | tags: #durable-object-state-machine #idempotent-operation #budget-reservation

Provides a deterministic grant selection algorithm that picks the lowest-priority usable grant while respecting stickiness (session affinity), quota availability, and endpoint eligibility. Pure logic with no I/O, making it extractable into any authorization or load-balancing system that needs consistent, quota-aware resource allocation.

file: worker/grant-selection.ts ↗ | tags: #selection-strategy #deterministic-routing #quota-awareness

Estimates LLM call costs from request body and model pricing data, supporting multiple provider formats (Chat, Anthropic Messages, OpenAI Responses, Google GenAI). Handles token estimation, service tiers, and tool pricing gaps. The core algorithm is provider-agnostic and could be reused in billing or cost-analysis tools for LLM services.

file: worker/pricing.ts ↗ | tags: #pricing-estimator #provider-agnostic #cost-calculation

Implements an optimistic CRUD pattern for admin operations: captures intended state, hydrates from server, rebases local changes on conflicts. This pattern prevents race conditions and lost updates in multi-user admin UIs. The generic state machine (capture → hydrate → rebase) is reusable in any frontend requiring conflict-free optimistic updates.

file: admin/src/hooks/access/use-policy-admin.ts ↗ | tags: #optimistic-update #capture-hydration-rebase #conflict-prevention
Last analyzed: 2026-10-04 14:17:28.705426
Next check: 2026-10-11 14:17:28.672375
$ submit: