openzoo 0.48.38 → 0.48.40
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 +28 -0
- package/lib/proxy.js +6 -0
- package/package.json +1 -1
package/lib/launch.js
CHANGED
|
@@ -143,6 +143,20 @@ export async function launchClaude(argv) {
|
|
|
143
143
|
delete env.ANTHROPIC_API_KEY;
|
|
144
144
|
env.ANTHROPIC_BASE_URL = base;
|
|
145
145
|
env.ANTHROPIC_AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN || 'sk-openzoo';
|
|
146
|
+
// RAISE THE CEILING, because the proxy already removed it.
|
|
147
|
+
//
|
|
148
|
+
// Claude Code counts the WHOLE local transcript against the model's window and
|
|
149
|
+
// hard-stops with "Context limit reached - /compact or /clear to continue". It
|
|
150
|
+
// cannot know the proxy binds the old prefix into leCore and forwards only the
|
|
151
|
+
// system block plus a bounded tail - MEASURED live, 8 of 166 turns actually
|
|
152
|
+
// sent. Disabling auto-compact WITHOUT raising this made it worse: it used to
|
|
153
|
+
// compact and carry on, and instead it just stopped.
|
|
154
|
+
//
|
|
155
|
+
// Safe only because spillTranscript is real: OPENZOO_TAIL_MAX_CHARS bounds what
|
|
156
|
+
// leaves this machine however long the conversation gets.
|
|
157
|
+
if (process.env.OPENZOO_KEEP_COMPACT !== '1' && !process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
|
|
158
|
+
env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = process.env.OPENZOO_CLAUDE_CONTEXT_TOKENS || '1000000';
|
|
159
|
+
}
|
|
146
160
|
|
|
147
161
|
if (terminal) {
|
|
148
162
|
const cli = resolveClaudeCli();
|
|
@@ -337,6 +351,20 @@ export async function launchHarness(cmd, args) {
|
|
|
337
351
|
delete env.ANTHROPIC_API_KEY; // conflicts with the gateway auth-token path
|
|
338
352
|
env.ANTHROPIC_BASE_URL = base;
|
|
339
353
|
env.ANTHROPIC_AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN || 'sk-openzoo';
|
|
354
|
+
// RAISE THE CEILING, because the proxy already removed it.
|
|
355
|
+
//
|
|
356
|
+
// Claude Code counts the WHOLE local transcript against the model's window and
|
|
357
|
+
// hard-stops with "Context limit reached - /compact or /clear to continue". It
|
|
358
|
+
// cannot know the proxy binds the old prefix into leCore and forwards only the
|
|
359
|
+
// system block plus a bounded tail - MEASURED live, 8 of 166 turns actually
|
|
360
|
+
// sent. Disabling auto-compact WITHOUT raising this made it worse: it used to
|
|
361
|
+
// compact and carry on, and instead it just stopped.
|
|
362
|
+
//
|
|
363
|
+
// Safe only because spillTranscript is real: OPENZOO_TAIL_MAX_CHARS bounds what
|
|
364
|
+
// leaves this machine however long the conversation gets.
|
|
365
|
+
if (process.env.OPENZOO_KEEP_COMPACT !== '1' && !process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
|
|
366
|
+
env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = process.env.OPENZOO_CLAUDE_CONTEXT_TOKENS || '1000000';
|
|
367
|
+
}
|
|
340
368
|
console.error(`openzoo: launching \`${cmd}\` on the zoo (ANTHROPIC_BASE_URL=${base}) — every turn pays x402`);
|
|
341
369
|
const child = spawn(cmd, args, { stdio: 'inherit', env });
|
|
342
370
|
child.on('exit', (code) => process.exit(code ?? 0));
|
package/lib/proxy.js
CHANGED
|
@@ -1106,6 +1106,12 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
|
|
|
1106
1106
|
sessionCogs += typeof x.cogsUsd === 'number' ? x.cogsUsd : x.billedUsd / MARKUP;
|
|
1107
1107
|
sessionDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
|
|
1108
1108
|
if (didSpill) {
|
|
1109
|
+
// THE number that settles why a spilled call did or did not save:
|
|
1110
|
+
// the gateway only prices a counterfactual when corpusTokens >
|
|
1111
|
+
// promptTokens, so a tail that rivals the corpus silently falls
|
|
1112
|
+
// back to markup and direct collapses onto billed.
|
|
1113
|
+
const lc = x.lecore || {};
|
|
1114
|
+
log(`spill priced: ${x.pricing} · corpus ${lc.corpusTokens ?? '?'} tok vs sent ${lc.tokensBefore ?? '?'} -> ${lc.tokensAfter ?? '?'} · billed ${(x.billedUsd ?? 0).toFixed(5)} direct ${(x.directUsd ?? 0).toFixed(5)}`);
|
|
1109
1115
|
spillSpend += x.billedUsd;
|
|
1110
1116
|
spillDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
|
|
1111
1117
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openzoo",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.40",
|
|
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",
|