@blockrun/clawrouter 0.12.284 → 0.12.286
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +67697 -27205
- package/dist/index.d.ts +49 -0
- package/dist/index.js +195720 -158269
- package/docs/configuration.md +49 -0
- package/package.json +17 -13
package/docs/configuration.md
CHANGED
|
@@ -28,6 +28,7 @@ Complete reference for ClawRouter configuration options.
|
|
|
28
28
|
| `BLOCKRUN_WALLET_KEY` | - | Explicit Base wallet override (hex, 0x-prefixed). |
|
|
29
29
|
| `BLOCKRUN_PROXY_PORT` | `8402` | Port for the local x402 proxy server. |
|
|
30
30
|
| `CLAWROUTER_SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint for USDC balance checks. |
|
|
31
|
+
| `CLAWROUTER_SOLANA_BATCH` | (off) | Set to `1` to pay Solana chat calls with batch-settlement: charged what each call cost, not its ceiling. See below. |
|
|
31
32
|
| `CLAWROUTER_DISABLED` | `false` | Set to `true` to disable smart routing (pass requests through as-is). |
|
|
32
33
|
| `CLAWROUTER_WORKER` | - | Set to `1` to enable Worker Mode (earn USDC by running health checks). |
|
|
33
34
|
| `CLAWROUTER_DEBUG_HEADERS` | (on) | Set to `off`/`false`/`0` to suppress the `x-clawrouter-*` debug response headers. |
|
|
@@ -234,6 +235,54 @@ curl -s -m 10 -X POST https://api.mainnet-beta.solana.com \
|
|
|
234
235
|
If that hangs or is refused, point this variable at an endpoint the host can
|
|
235
236
|
reach.
|
|
236
237
|
|
|
238
|
+
### CLAWROUTER_SOLANA_BATCH
|
|
239
|
+
|
|
240
|
+
Pay Solana chat calls with x402 **batch-settlement** instead of one `exact`
|
|
241
|
+
transfer per call (Solana chain only, wallet mode only, off by default):
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
export CLAWROUTER_SOLANA_BATCH=1
|
|
245
|
+
export CLAWROUTER_SOLANA_BATCH_MAX_DEPOSIT='$5' # optional; default $1
|
|
246
|
+
openclaw gateway restart
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`exact` pays every call at its ceiling (the price of `max_tokens`) and settles
|
|
250
|
+
it on-chain before the model answers. With batch-settlement, the first call
|
|
251
|
+
opens a payment channel with a small deposit; each call after that carries a
|
|
252
|
+
signed authorization for its ceiling, and the gateway charges what the call
|
|
253
|
+
actually cost. One on-chain transaction covers many calls.
|
|
254
|
+
|
|
255
|
+
- **Who holds the deposit.** The channel's voucher signer is BlockRun's
|
|
256
|
+
operator key, pinned in ClawRouter (the operator a 402 names is never
|
|
257
|
+
trusted). The deposit is escrow, capped by
|
|
258
|
+
`CLAWROUTER_SOLANA_BATCH_MAX_DEPOSIT` (`$1` by default), and later calls keep
|
|
259
|
+
spending it. A channel idle for 3 days is closed by BlockRun at what has been
|
|
260
|
+
settled, and the unused escrow returns to the wallet on its own (the gateway
|
|
261
|
+
advertises this as `batchPolicy.idleCloseSeconds` in its 402). To get it back
|
|
262
|
+
sooner, close the channel with `@blockrun/llm`'s `closeBatchChannel()` on the
|
|
263
|
+
same wallet; ClawRouter has no close command yet.
|
|
264
|
+
- **Spend limits apply unchanged.** `maxCostPerRun` and the spend policy
|
|
265
|
+
(`clawrouter policy`) check each batch payment at its per-call ceiling before
|
|
266
|
+
it is signed, exactly like an `exact` payment. `maxCostPerRun` then books what
|
|
267
|
+
the call was actually charged; the spend policy's windows keep the ceiling
|
|
268
|
+
(conservative). Both only apply if you set them.
|
|
269
|
+
- **Never pays twice.** A batch payment whose outcome is unknown (sent, no
|
|
270
|
+
receipt) is never replaced: no `exact` fallback, no retry, no next model.
|
|
271
|
+
The request fails with `payment_in_doubt`. A call that batch could not pay
|
|
272
|
+
(channel busy, rate limited, gateway refused the deposit) pays `exact`
|
|
273
|
+
instead, and only when the gateway proved nothing was charged.
|
|
274
|
+
- **Only non-streaming chat completions** use batch (ClawRouter always calls
|
|
275
|
+
the gateway non-streaming). Images, audio, video and other endpoints stay on
|
|
276
|
+
`exact`.
|
|
277
|
+
- Channel state lives in `~/.blockrun/solana-batch/<wallet>.json`, locked to
|
|
278
|
+
one process at a time. A second process on the same wallet pays `exact`.
|
|
279
|
+
|
|
280
|
+
Programmatic: `startProxy({ solanaBatch: true })` or
|
|
281
|
+
`startProxy({ solanaBatch: { maxDeposit: "$5" } })`.
|
|
282
|
+
|
|
283
|
+
The protocol is implemented by `@blockrun/llm`'s `SolanaBatchPayer`, the same
|
|
284
|
+
payer `SolanaLLMClient` uses.
|
|
285
|
+
|
|
237
286
|
---
|
|
238
287
|
|
|
239
288
|
## Wallet Configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockrun/clawrouter",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.286",
|
|
4
4
|
"description": "Smart LLM router — save 84% on inference costs. 88 models (7 free). Pay by credit card (API key) or USDC (x402 wallet).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"url": "git+https://github.com/BlockRunAI/ClawRouter.git"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@blockrun/llm": "^3.
|
|
91
|
+
"@blockrun/llm": "^3.23.1",
|
|
92
92
|
"@noble/hashes": "^2.2.0",
|
|
93
93
|
"@polymarket/builder-relayer-client": "^0.0.10",
|
|
94
94
|
"@polymarket/builder-signing-sdk": "0.0.8",
|
|
@@ -96,15 +96,15 @@
|
|
|
96
96
|
"@scure/bip32": "^2.0.1",
|
|
97
97
|
"@scure/bip39": "^1.5.0",
|
|
98
98
|
"@solana/kit": "^8.4.0",
|
|
99
|
-
"@x402/core": "
|
|
100
|
-
"@x402/evm": "
|
|
101
|
-
"@x402/fetch": "
|
|
102
|
-
"@x402/svm": "
|
|
103
|
-
"axios": "^1.
|
|
99
|
+
"@x402/core": "~2.28.0",
|
|
100
|
+
"@x402/evm": "~2.28.0",
|
|
101
|
+
"@x402/fetch": "~2.28.0",
|
|
102
|
+
"@x402/svm": "~2.28.0",
|
|
103
|
+
"axios": "^1.20.0",
|
|
104
104
|
"bs58": "^6.0.0",
|
|
105
105
|
"https-proxy-agent": "^9.1.0",
|
|
106
|
-
"undici": "^8.
|
|
107
|
-
"viem": "
|
|
106
|
+
"undici": "^8.11.2",
|
|
107
|
+
"viem": "~2.56.9"
|
|
108
108
|
},
|
|
109
109
|
"peerDependencies": {
|
|
110
110
|
"openclaw": ">=2025.1.0"
|
|
@@ -132,15 +132,19 @@
|
|
|
132
132
|
"ws": "^8.21.2",
|
|
133
133
|
"postcss": "^8.5.25",
|
|
134
134
|
"esbuild": "^0.28.1",
|
|
135
|
-
"brace-expansion": "^5.0.
|
|
136
|
-
"fast-uri": "^3.1.
|
|
135
|
+
"brace-expansion": "^5.0.12",
|
|
136
|
+
"fast-uri": "^3.1.8",
|
|
137
137
|
"tar": "^7.5.22",
|
|
138
138
|
"hono": "^4.13.5",
|
|
139
139
|
"@hono/node-server": "^2.1.0",
|
|
140
|
-
"ip-address": "
|
|
140
|
+
"ip-address": "10.7.1",
|
|
141
141
|
"@solana-program/compute-budget": "^0.18.1",
|
|
142
142
|
"@solana-program/token": "^0.16.1",
|
|
143
|
-
"@solana-program/token-2022": "^0.16.1"
|
|
143
|
+
"@solana-program/token-2022": "^0.16.1",
|
|
144
|
+
"proxy-addr": "^2.0.8",
|
|
145
|
+
"@x402/svm": {
|
|
146
|
+
"@solana/program-client-core": "$@solana/kit"
|
|
147
|
+
}
|
|
144
148
|
},
|
|
145
149
|
"engines": {
|
|
146
150
|
"node": ">=22"
|