Skip to content

Commit b875ce6

Browse files
author
1bcMax
committed
feat: add proxy reuse and configurable port
- Add BLOCKRUN_PROXY_PORT env var to configure proxy port - Automatically detect and reuse existing proxy (fixes EADDRINUSE) - Add technical documentation (docs/configuration.md, docs/architecture.md) - Add proxy reuse tests (test/proxy-reuse.ts) - Bump version to 0.4.1
1 parent cb45be4 commit b875ce6

7 files changed

Lines changed: 1176 additions & 42 deletions

File tree

README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ One wallet, 30+ models, zero API keys.
1212
[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://typescriptlang.org)
1313
[![Node](https://img.shields.io/badge/node-%E2%89%A520-brightgreen.svg)](https://nodejs.org)
1414

15-
[Docs](https://blockrun.ai/docs) · [Models](https://blockrun.ai/models) · [Telegram](https://t.me/blockrunAI) · [X](https://x.com/BlockRunAI)
15+
[Docs](https://blockrun.ai/docs) · [Models](https://blockrun.ai/models) · [Configuration](docs/configuration.md) · [Architecture](docs/architecture.md) · [Telegram](https://t.me/blockrunAI) · [X](https://x.com/BlockRunAI)
1616

1717
</div>
1818

@@ -283,54 +283,41 @@ If you explicitly want to use a different wallet:
283283

284284
Routing is **client-side** — open source and inspectable.
285285

286-
### Source Structure
287-
288-
```
289-
src/
290-
├── index.ts # Plugin entry point
291-
├── provider.ts # OpenClaw provider registration
292-
├── proxy.ts # Local HTTP proxy + x402 payment
293-
├── models.ts # 30+ model definitions with pricing
294-
├── auth.ts # Wallet key resolution
295-
├── logger.ts # JSON usage logging
296-
├── dedup.ts # Response deduplication (prevents double-charge)
297-
├── payment-cache.ts # Pre-auth optimization (skips 402 round trip)
298-
├── x402.ts # EIP-712 USDC payment signing
299-
└── router/
300-
├── index.ts # route() entry point
301-
├── rules.ts # 14-dimension weighted scoring
302-
├── selector.ts # Tier → model selection
303-
├── config.ts # Default routing config
304-
└── types.ts # TypeScript types
305-
```
286+
**Deep dive:** [docs/architecture.md](docs/architecture.md) — request flow, payment system, optimizations
306287

307288
---
308289

309290
## Configuration
310291

311-
### Override Tier Models
292+
For basic usage, no configuration is needed. For advanced options:
293+
294+
| Setting | Default | Description |
295+
|---------|---------|-------------|
296+
| `BLOCKRUN_PROXY_PORT` | `8402` | Proxy port (env var) |
297+
| `BLOCKRUN_WALLET_KEY` | auto | Wallet private key (env var) |
298+
| `routing.tiers` | see docs | Override tier→model mappings |
299+
| `routing.scoring` | see docs | Custom keyword weights |
300+
301+
**Quick example:**
302+
303+
```bash
304+
# Use different port
305+
export BLOCKRUN_PROXY_PORT=8403
306+
openclaw gateway restart
307+
```
312308

313309
```yaml
314-
# openclaw.yaml
310+
# openclaw.yaml — override models
315311
plugins:
316312
- id: "@blockrun/clawrouter"
317313
config:
318314
routing:
319315
tiers:
320316
COMPLEX:
321317
primary: "openai/gpt-4o"
322-
SIMPLE:
323-
primary: "google/gemini-2.5-flash"
324318
```
325319
326-
### Override Scoring Weights
327-
328-
```yaml
329-
routing:
330-
scoring:
331-
reasoningKeywords: ["proof", "theorem", "formal verification"]
332-
codeKeywords: ["function", "class", "async", "await"]
333-
```
320+
**Full reference:** [docs/configuration.md](docs/configuration.md)
334321
335322
---
336323
@@ -478,6 +465,18 @@ See [`openclaw.security.json`](openclaw.security.json) for detailed security doc
478465

479466
### Port 8402 already in use
480467

468+
As of v0.4.1, ClawRouter automatically detects and reuses an existing proxy on the configured port instead of failing with `EADDRINUSE`. You should no longer see this error.
469+
470+
If you need to use a different port:
471+
472+
```bash
473+
# Set custom port via environment variable
474+
export BLOCKRUN_PROXY_PORT=8403
475+
openclaw gateway restart
476+
```
477+
478+
To manually check/kill the process:
479+
481480
```bash
482481
lsof -i :8402
483482
# Kill the process or restart OpenClaw

0 commit comments

Comments
 (0)