openzoo 0.48.60 → 0.48.61
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 +13 -3
- package/package.json +1 -1
package/lib/proxy.js
CHANGED
|
@@ -1266,7 +1266,7 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1266
1266
|
} catch (err) {
|
|
1267
1267
|
log(`context cache skipped for this call: ${err.message}`);
|
|
1268
1268
|
}
|
|
1269
|
-
const send = (buf, ctxId, topK) => client.fetch(url, {
|
|
1269
|
+
const send = (buf, ctxId, topK, corpusChars) => client.fetch(url, {
|
|
1270
1270
|
...init,
|
|
1271
1271
|
body: buf,
|
|
1272
1272
|
headers: ctxId
|
|
@@ -1275,6 +1275,16 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1275
1275
|
'x-hrr-context': ctxId,
|
|
1276
1276
|
// Only on the spill path — a caller that set its own top-k keeps it.
|
|
1277
1277
|
...(topK ? { 'x-hrr-top-k': String(topK) } : {}),
|
|
1278
|
+
// TELL THE GATEWAY HOW BIG THE CORPUS IS. It has been guessing:
|
|
1279
|
+
// `contextChars` is populated only when a bind passes through the
|
|
1280
|
+
// gateway itself, so on an APPEND — and on every corpus that
|
|
1281
|
+
// includes files the agent read, which never appear in a request
|
|
1282
|
+
// body at all — it has no idea and falls back to the body size.
|
|
1283
|
+
// That is why the counterfactual logged `corpus ?` all day and why
|
|
1284
|
+
// a call whose corpus held 40,777 tokens priced as if it held
|
|
1285
|
+
// 4,303. The proxy assembled the corpus; it is the only party that
|
|
1286
|
+
// knows.
|
|
1287
|
+
...(corpusChars ? { 'x-hrr-corpus-chars': String(corpusChars) } : {}),
|
|
1278
1288
|
}
|
|
1279
1289
|
: init.headers,
|
|
1280
1290
|
});
|
|
@@ -1285,7 +1295,7 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1285
1295
|
didSpill = true;
|
|
1286
1296
|
spilledChars += cached.corpus?.length || 0;
|
|
1287
1297
|
if (cached.reused) spillReuses += 1;
|
|
1288
|
-
result = await send(cached.body, cached.contextId, cached.topK);
|
|
1298
|
+
result = await send(cached.body, cached.contextId, cached.topK, cached.corpus?.length);
|
|
1289
1299
|
// Sidecar wiped between runs: the gateway 404s BEFORE the 402 (nothing
|
|
1290
1300
|
// paid). Never fail on a stale manifest — re-bind once and retry.
|
|
1291
1301
|
if (result.response.status === 404) {
|
|
@@ -1294,7 +1304,7 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1294
1304
|
log('bound context is gone on the zoo — re-binding once...');
|
|
1295
1305
|
forgetContext(config.apiBase, cached.hash);
|
|
1296
1306
|
const rebound = await bindCorpus(cached.corpus, { force: true });
|
|
1297
|
-
result = await send(cached.body, rebound.contextId, cached.topK);
|
|
1307
|
+
result = await send(cached.body, rebound.contextId, cached.topK, cached.corpus?.length);
|
|
1298
1308
|
} else {
|
|
1299
1309
|
res.writeHead(404, { 'content-type': 'application/json' });
|
|
1300
1310
|
res.end(text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.61",
|
|
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",
|