openzoo 0.48.40 → 0.48.42

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,25 @@ 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
+ // STOP CLAUDE CODE COMPACTING ON A WINDOW THAT IS NOT REAL.
147
+ //
148
+ // It counts the WHOLE local transcript and compacts against a window it looks
149
+ // up from the MODEL NAME — hardcoded 200k for a recognised Claude id, which is
150
+ // why `/autocompact 1m` answered "capped to 200k by model" and why raising
151
+ // CLAUDE_CODE_MAX_CONTEXT_TOKENS alone did nothing. It never sees that the
152
+ // proxy binds the prefix and forwards ~8 of 166 turns.
153
+ //
154
+ // An `openzoo-` alias is the same model upstream (models.js resolves by
155
+ // SUFFIX, so openzoo-claude-sonnet-5 -> anthropic/claude-sonnet-5) but is not
156
+ // in that table, so the client falls back to the advertised context_length —
157
+ // which this gateway publishes as 128,000,000.
158
+ //
159
+ // OPENZOO_NO_ALIAS=1 opts out. Worth knowing: model-specific client behaviour
160
+ // (thinking budget, tool formats) also keys off the name, so if a session
161
+ // behaves oddly this is the first thing to turn off.
162
+ if (process.env.OPENZOO_NO_ALIAS !== '1' && !process.env.ANTHROPIC_MODEL) {
163
+ env.ANTHROPIC_MODEL = process.env.OPENZOO_CLAUDE_ALIAS || 'openzoo-claude-sonnet-5';
164
+ }
146
165
  // RAISE THE CEILING, because the proxy already removed it.
147
166
  //
148
167
  // Claude Code counts the WHOLE local transcript against the model's window and
@@ -223,7 +242,15 @@ export async function launchClaude(argv) {
223
242
  // because OPENZOO_KEEP_TAIL_MSGS bounds what is actually sent.
224
243
  // OPENZOO_KEEP_COMPACT=1 restores stock behaviour.
225
244
  const prevCompact = settings.autoCompactEnabled;
226
- if (process.env.OPENZOO_KEEP_COMPACT !== '1') settings.autoCompactEnabled = false;
245
+ // DO NOT touch autoCompactEnabled. Disabling it here mutated the user's
246
+ // GLOBAL ~/.claude/settings.json and applied to every session, openzoo or
247
+ // not — and because Claude Code's HARD ceiling is separate from its
248
+ // AUTOMATIC compaction, it removed the escape hatch without removing the
249
+ // wall. A live session ended up unable to compact AND unable to continue:
250
+ // every keystroke returned "Context limit reached". Strictly worse than
251
+ // stock. The correct lever is CLAUDE_CODE_MAX_CONTEXT_TOKENS on the
252
+ // spawned process (set below), which is scoped to this launch and leaves
253
+ // compaction available as a fallback.
227
254
  fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
228
255
  fs.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
229
256
  restoreStatus = () => {
@@ -231,6 +258,7 @@ export async function launchClaude(argv) {
231
258
  const cur = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
232
259
  if (prev === undefined) delete cur.statusLine; else cur.statusLine = prev;
233
260
  // Never leave a global setting mutated after we exit.
261
+ // Clean up the flag older builds left behind in global settings.
234
262
  if (prevCompact === undefined) delete cur.autoCompactEnabled;
235
263
  else cur.autoCompactEnabled = prevCompact;
236
264
  fs.writeFileSync(settingsPath, `${JSON.stringify(cur, null, 2)}\n`);
@@ -351,6 +379,25 @@ export async function launchHarness(cmd, args) {
351
379
  delete env.ANTHROPIC_API_KEY; // conflicts with the gateway auth-token path
352
380
  env.ANTHROPIC_BASE_URL = base;
353
381
  env.ANTHROPIC_AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN || 'sk-openzoo';
382
+ // STOP CLAUDE CODE COMPACTING ON A WINDOW THAT IS NOT REAL.
383
+ //
384
+ // It counts the WHOLE local transcript and compacts against a window it looks
385
+ // up from the MODEL NAME — hardcoded 200k for a recognised Claude id, which is
386
+ // why `/autocompact 1m` answered "capped to 200k by model" and why raising
387
+ // CLAUDE_CODE_MAX_CONTEXT_TOKENS alone did nothing. It never sees that the
388
+ // proxy binds the prefix and forwards ~8 of 166 turns.
389
+ //
390
+ // An `openzoo-` alias is the same model upstream (models.js resolves by
391
+ // SUFFIX, so openzoo-claude-sonnet-5 -> anthropic/claude-sonnet-5) but is not
392
+ // in that table, so the client falls back to the advertised context_length —
393
+ // which this gateway publishes as 128,000,000.
394
+ //
395
+ // OPENZOO_NO_ALIAS=1 opts out. Worth knowing: model-specific client behaviour
396
+ // (thinking budget, tool formats) also keys off the name, so if a session
397
+ // behaves oddly this is the first thing to turn off.
398
+ if (process.env.OPENZOO_NO_ALIAS !== '1' && !process.env.ANTHROPIC_MODEL) {
399
+ env.ANTHROPIC_MODEL = process.env.OPENZOO_CLAUDE_ALIAS || 'openzoo-claude-sonnet-5';
400
+ }
354
401
  // RAISE THE CEILING, because the proxy already removed it.
355
402
  //
356
403
  // Claude Code counts the WHOLE local transcript against the model's window and
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.40",
3
+ "version": "0.48.42",
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",