@blockrun/clawrouter 0.12.285 → 0.12.287

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.
@@ -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.285",
3
+ "version": "0.12.287",
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.10.0",
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": "^2.9.0",
100
- "@x402/evm": "^2.9.0",
101
- "@x402/fetch": "^2.9.0",
102
- "@x402/svm": "^2.9.0",
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
103
  "axios": "^1.20.0",
104
104
  "bs58": "^6.0.0",
105
105
  "https-proxy-agent": "^9.1.0",
106
106
  "undici": "^8.11.2",
107
- "viem": "^2.39.3"
107
+ "viem": "~2.56.9"
108
108
  },
109
109
  "peerDependencies": {
110
110
  "openclaw": ">=2025.1.0"
@@ -115,6 +115,7 @@
115
115
  }
116
116
  },
117
117
  "devDependencies": {
118
+ "@blockrun/model-catalog": "https://codeload.github.com/BlockRunAI/model-catalog/tar.gz/465c45941fb8ea9d6858fe8402abc8ba8934be90",
118
119
  "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/e38958bba9af0aaa788c5baafbdaff539638b7c9",
119
120
  "@eslint/js": "^10.0.1",
120
121
  "eslint": "^10.2.0",
@@ -141,7 +142,10 @@
141
142
  "@solana-program/compute-budget": "^0.18.1",
142
143
  "@solana-program/token": "^0.16.1",
143
144
  "@solana-program/token-2022": "^0.16.1",
144
- "proxy-addr": "^2.0.8"
145
+ "proxy-addr": "^2.0.8",
146
+ "@x402/svm": {
147
+ "@solana/program-client-core": "$@solana/kit"
148
+ }
145
149
  },
146
150
  "engines": {
147
151
  "node": ">=22"