openzoo 0.48.36 → 0.48.38
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/launch.js +9 -2
- package/lib/proxy.js +26 -1
- package/package.json +1 -1
package/lib/launch.js
CHANGED
|
@@ -177,9 +177,16 @@ export async function launchClaude(argv) {
|
|
|
177
177
|
// ALWAYS shown, 4dp, even at 1.0000. Hiding it when there is no saving
|
|
178
178
|
// reads as "no data"; printing 1.0000x says "measured, and it is level"
|
|
179
179
|
// — which is the difference between an omission and a fact.
|
|
180
|
-
+ 'const sx=Number(j.savingX);const sv=Number(j.savedUsd)||0;'
|
|
180
|
+
+ 'const sx=Number(j.savingX);const sv=Number((j.spilled||{}).savedUsd ?? j.savedUsd)||0;'
|
|
181
181
|
+ 'const col=(sx>1)?"\\x1b[32m":"\\x1b[90m";'
|
|
182
|
-
|
|
182
|
+
// Prefer the SPILLED-call ratio: the session-wide one averages in every
|
|
183
|
+
// small turn that had nothing to offload, so it slides toward 1.0 as a
|
|
184
|
+
// conversation grows and reads as the mechanism failing when it is not.
|
|
185
|
+
+ 'const sx2=Number(sp.savingX);'
|
|
186
|
+
+ 'const on=(isFinite(sx2)&&sx2>0)?sx2:sx;'
|
|
187
|
+
+ 'const lbl=(isFinite(sx2)&&sx2>0)?"x on spilled":"x vs direct";'
|
|
188
|
+
+ 'const col2=(on>1)?"\\x1b[32m":"\\x1b[90m";'
|
|
189
|
+
+ 'const save=(on==null||!isFinite(on))?"":(" \\u00b7 "+col2+on.toFixed(4)+lbl+(sv>0?(" ($"+sv.toFixed(4)+" saved)"):"")+"\\x1b[0m");'
|
|
183
190
|
+ 'process.stdout.write("\\x1b[38;5;208m\\u25cf\\x1b[0m openzoo $"+(Number(j.spendUsd)||0).toFixed(4)+" "+(j.paidCalls||0)+" call"+((j.paidCalls||0)===1?"":"s")+save+spill+cr+" \\u00b7 x402")}'
|
|
184
191
|
+ 'catch{process.stdout.write("\\x1b[38;5;208m\\u25cf\\x1b[0m openzoo \\u00b7 x402")}})\'\n');
|
|
185
192
|
fs.chmodSync(scriptPath, 0o755);
|
package/lib/proxy.js
CHANGED
|
@@ -355,7 +355,11 @@ async function spillTranscript(body, log) {
|
|
|
355
355
|
// in the bound corpus and comes back through recall.
|
|
356
356
|
let tailStart = cut;
|
|
357
357
|
{
|
|
358
|
-
|
|
358
|
+
// 24000 was still too fat: MEASURED on 9 live spilled calls, direct came
|
|
359
|
+
// back identical to billed to the cent, i.e. the gateway never computed a
|
|
360
|
+
// counterfactual because promptTokens >= corpusTokens. The tail has to be
|
|
361
|
+
// small enough that the BOUND corpus is the bigger number.
|
|
362
|
+
const budget = Number(process.env.OPENZOO_TAIL_MAX_CHARS || 6000);
|
|
359
363
|
let used = 0;
|
|
360
364
|
for (let i = msgs.length - 1; i >= cut; i--) {
|
|
361
365
|
used += msgText(msgs[i]).length;
|
|
@@ -554,6 +558,13 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
554
558
|
let spillCalls = 0;
|
|
555
559
|
let spilledChars = 0;
|
|
556
560
|
let spillReuses = 0;
|
|
561
|
+
// Spend/direct for ONLY the calls that spilled. The session-wide savingX
|
|
562
|
+
// averages these with every small turn that had nothing to offload, so it
|
|
563
|
+
// slides toward 1.0 as a conversation grows — which reads as the mechanism
|
|
564
|
+
// degrading when it is just the mix changing. OBSERVED: 1.3166 -> 1.1823
|
|
565
|
+
// while spilled calls and offloaded tokens both sat completely still.
|
|
566
|
+
let spillSpend = 0;
|
|
567
|
+
let spillDirect = 0;
|
|
557
568
|
// CREDIT, CACHED. Users cannot tell prepaid credit from wallet balance and
|
|
558
569
|
// have to guess whether a call was even paid for ("I don't think x402 made me
|
|
559
570
|
// pay this at all"). The status line runs EVERY turn, so this is refreshed at
|
|
@@ -681,6 +692,10 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
681
692
|
// saving is actually made of.
|
|
682
693
|
tokensApprox: Math.round(spilledChars / 4),
|
|
683
694
|
reusedBinds: spillReuses,
|
|
695
|
+
spend: spillSpend,
|
|
696
|
+
direct: spillDirect,
|
|
697
|
+
savedUsd: Math.max(0, spillDirect - spillSpend),
|
|
698
|
+
savingX: spillSpend > 0 ? Number((spillDirect / spillSpend).toFixed(4)) : null,
|
|
684
699
|
},
|
|
685
700
|
spendUsd: sessionSpent,
|
|
686
701
|
creditUsd,
|
|
@@ -995,9 +1010,11 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
995
1010
|
}
|
|
996
1011
|
: init.headers,
|
|
997
1012
|
});
|
|
1013
|
+
let didSpill = false;
|
|
998
1014
|
let result;
|
|
999
1015
|
if (cached) {
|
|
1000
1016
|
spillCalls += 1;
|
|
1017
|
+
didSpill = true;
|
|
1001
1018
|
spilledChars += cached.corpus?.length || 0;
|
|
1002
1019
|
if (cached.reused) spillReuses += 1;
|
|
1003
1020
|
result = await send(cached.body, cached.contextId, cached.topK);
|
|
@@ -1039,6 +1056,10 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1039
1056
|
// attach call that is the whole bound corpus, which is why it can be
|
|
1040
1057
|
// orders of magnitude above what was billed. directUsd is exact and
|
|
1041
1058
|
// always present; savesVsDirect is the same number as a ratio.
|
|
1059
|
+
if (didSpill) {
|
|
1060
|
+
spillSpend += receipt.billedUsd || 0;
|
|
1061
|
+
spillDirect += typeof receipt.directUsd === 'number' ? receipt.directUsd : (receipt.billedUsd || 0);
|
|
1062
|
+
}
|
|
1042
1063
|
sessionDirect += typeof receipt.directUsd === 'number'
|
|
1043
1064
|
? receipt.directUsd
|
|
1044
1065
|
: typeof receipt.savesVsDirect === 'number'
|
|
@@ -1084,6 +1105,10 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1084
1105
|
sessionSpent += x.billedUsd;
|
|
1085
1106
|
sessionCogs += typeof x.cogsUsd === 'number' ? x.cogsUsd : x.billedUsd / MARKUP;
|
|
1086
1107
|
sessionDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
|
|
1108
|
+
if (didSpill) {
|
|
1109
|
+
spillSpend += x.billedUsd;
|
|
1110
|
+
spillDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
|
|
1111
|
+
}
|
|
1087
1112
|
paidCalls += 1;
|
|
1088
1113
|
if (viaTunnel) tunnelSpent += x.billedUsd;
|
|
1089
1114
|
say(`credit -> $${x.billedUsd.toFixed(6)} · session $${sessionSpent.toFixed(6)}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.38",
|
|
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",
|