openzoo 0.45.0 → 0.45.1
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 +16 -0
- package/package.json +1 -1
package/lib/proxy.js
CHANGED
|
@@ -722,6 +722,22 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
722
722
|
if (isChat && response.ok && upCt.includes('application/json')) {
|
|
723
723
|
let data = null;
|
|
724
724
|
try { data = await response.clone().json(); } catch { /* not JSON after all */ }
|
|
725
|
+
// PREPAID CALLS STILL COST MONEY. The block above only meters calls
|
|
726
|
+
// where THIS proxy answered a 402 and paid. When prepaid credit covers
|
|
727
|
+
// the quote the gateway serves 200 on the FIRST request, so there is
|
|
728
|
+
// no 402, no payment and no receipt — and the session read $0.05 / 2
|
|
729
|
+
// calls while the credit balance had actually fallen $3.017 -> $1.395
|
|
730
|
+
// over a 30-question run. The receipt still rides the response body,
|
|
731
|
+
// so meter it from there.
|
|
732
|
+
if (!paid && data?.x402 && typeof data.x402.billedUsd === 'number') {
|
|
733
|
+
const x = data.x402;
|
|
734
|
+
sessionSpent += x.billedUsd;
|
|
735
|
+
sessionCogs += typeof x.cogsUsd === 'number' ? x.cogsUsd : x.billedUsd / MARKUP;
|
|
736
|
+
sessionDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
|
|
737
|
+
paidCalls += 1;
|
|
738
|
+
if (viaTunnel) tunnelSpent += x.billedUsd;
|
|
739
|
+
say(`credit -> $${x.billedUsd.toFixed(6)} · session $${sessionSpent.toFixed(6)}`);
|
|
740
|
+
}
|
|
725
741
|
if (data?.object === 'chat.completion') {
|
|
726
742
|
if (rKey) replayPut(rKey, data, response.headers.get('x-payment-response'));
|
|
727
743
|
// Anthropic-shaped caller gets an Anthropic-shaped answer, streamed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.1",
|
|
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",
|