openzoo 0.48.39 → 0.48.41

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 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();
@@ -209,7 +223,15 @@ export async function launchClaude(argv) {
209
223
  // because OPENZOO_KEEP_TAIL_MSGS bounds what is actually sent.
210
224
  // OPENZOO_KEEP_COMPACT=1 restores stock behaviour.
211
225
  const prevCompact = settings.autoCompactEnabled;
212
- if (process.env.OPENZOO_KEEP_COMPACT !== '1') settings.autoCompactEnabled = false;
226
+ // DO NOT touch autoCompactEnabled. Disabling it here mutated the user's
227
+ // GLOBAL ~/.claude/settings.json and applied to every session, openzoo or
228
+ // not — and because Claude Code's HARD ceiling is separate from its
229
+ // AUTOMATIC compaction, it removed the escape hatch without removing the
230
+ // wall. A live session ended up unable to compact AND unable to continue:
231
+ // every keystroke returned "Context limit reached". Strictly worse than
232
+ // stock. The correct lever is CLAUDE_CODE_MAX_CONTEXT_TOKENS on the
233
+ // spawned process (set below), which is scoped to this launch and leaves
234
+ // compaction available as a fallback.
213
235
  fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
214
236
  fs.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
215
237
  restoreStatus = () => {
@@ -217,6 +239,7 @@ export async function launchClaude(argv) {
217
239
  const cur = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
218
240
  if (prev === undefined) delete cur.statusLine; else cur.statusLine = prev;
219
241
  // Never leave a global setting mutated after we exit.
242
+ // Clean up the flag older builds left behind in global settings.
220
243
  if (prevCompact === undefined) delete cur.autoCompactEnabled;
221
244
  else cur.autoCompactEnabled = prevCompact;
222
245
  fs.writeFileSync(settingsPath, `${JSON.stringify(cur, null, 2)}\n`);
@@ -337,6 +360,20 @@ export async function launchHarness(cmd, args) {
337
360
  delete env.ANTHROPIC_API_KEY; // conflicts with the gateway auth-token path
338
361
  env.ANTHROPIC_BASE_URL = base;
339
362
  env.ANTHROPIC_AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN || 'sk-openzoo';
363
+ // RAISE THE CEILING, because the proxy already removed it.
364
+ //
365
+ // Claude Code counts the WHOLE local transcript against the model's window and
366
+ // hard-stops with "Context limit reached - /compact or /clear to continue". It
367
+ // cannot know the proxy binds the old prefix into leCore and forwards only the
368
+ // system block plus a bounded tail - MEASURED live, 8 of 166 turns actually
369
+ // sent. Disabling auto-compact WITHOUT raising this made it worse: it used to
370
+ // compact and carry on, and instead it just stopped.
371
+ //
372
+ // Safe only because spillTranscript is real: OPENZOO_TAIL_MAX_CHARS bounds what
373
+ // leaves this machine however long the conversation gets.
374
+ if (process.env.OPENZOO_KEEP_COMPACT !== '1' && !process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS) {
375
+ env.CLAUDE_CODE_MAX_CONTEXT_TOKENS = process.env.OPENZOO_CLAUDE_CONTEXT_TOKENS || '1000000';
376
+ }
340
377
  console.error(`openzoo: launching \`${cmd}\` on the zoo (ANTHROPIC_BASE_URL=${base}) — every turn pays x402`);
341
378
  const child = spawn(cmd, args, { stdio: 'inherit', env });
342
379
  child.on('exit', (code) => process.exit(code ?? 0));
package/lib/proxy.js CHANGED
@@ -1111,7 +1111,12 @@ export async function startProxy({ silent = false, requireToken = null, sessionM
1111
1111
  // promptTokens, so a tail that rivals the corpus silently falls
1112
1112
  // back to markup and direct collapses onto billed.
1113
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)}`);
1114
+ // counterfactualTokensUsed is the basis the gateway ACTUALLY priced
1115
+ // on. lecore.corpusTokens is often absent and reading it printed
1116
+ // 'corpus ?' on calls that were pricing fine — which sent a whole
1117
+ // night's debugging after a number that was never the input.
1118
+ const basis = x.counterfactualTokensUsed ?? lc.corpusTokens;
1119
+ log(`spill priced: ${x.pricing} · basis ${basis ?? '?'} tok vs sent ${lc.tokensBefore ?? '?'} -> ${lc.tokensAfter ?? '?'} · billed ${(x.billedUsd ?? 0).toFixed(5)} direct ${(x.directUsd ?? 0).toFixed(5)}`);
1115
1120
  spillSpend += x.billedUsd;
1116
1121
  spillDirect += typeof x.directUsd === 'number' ? x.directUsd : x.billedUsd;
1117
1122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.48.39",
3
+ "version": "0.48.41",
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",