openzoo 0.50.9 → 0.50.10
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/lib/proxy.js +19 -0
- package/package.json +1 -1
package/lib/proxy.js
CHANGED
|
@@ -752,6 +752,25 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
752
752
|
rememberSpend();
|
|
753
753
|
say(`credit -> $${x.billedUsd.toFixed(6)} · session $${sessionSpent.toFixed(6)}`);
|
|
754
754
|
};
|
|
755
|
+
// A 402 AFTER we attempted payment is a SETTLEMENT failure, not a quote —
|
|
756
|
+
// the client-side balance check is advisory, so a wallet that looks
|
|
757
|
+
// fundable can still fail on-chain, and the gateway answers the paid
|
|
758
|
+
// retry with a fresh 402. Relaying that raw meant Claude Code printed a
|
|
759
|
+
// half-kilobyte accepts[] blob at the user instead of the one thing they
|
|
760
|
+
// need: the price, what the wallet holds, and where to send funds.
|
|
761
|
+
if (response.status === 402) {
|
|
762
|
+
let quoted = '';
|
|
763
|
+
try {
|
|
764
|
+
const q = await response.clone().json();
|
|
765
|
+
const usd = Number(q?.accepts?.[0]?.extra?.billedUsd);
|
|
766
|
+
if (Number.isFinite(usd)) quoted = ` This call needs ≈$${usd.toFixed(4)}.`;
|
|
767
|
+
} catch { /* body was not the quote after all */ }
|
|
768
|
+
jsonErr(res, 402,
|
|
769
|
+
`openzoo wallet underfunded — payment did not settle.${quoted} `
|
|
770
|
+
+ `Fund it and retry: send USDC (or TOKEN/LEOS for half price) to ${client.address} on Solana, `
|
|
771
|
+
+ `or USDC to ${client.evmAddress} on Base. Check with: openzoo balance`);
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
755
774
|
await relay(res, response, meterStreamed);
|
|
756
775
|
} catch (err) {
|
|
757
776
|
if (err instanceof QuoteTooHighError) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.10",
|
|
4
4
|
"description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|