openzoo 0.50.17 → 0.50.18

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.
Files changed (2) hide show
  1. package/lib/x402.js +24 -6
  2. package/package.json +1 -1
package/lib/x402.js CHANGED
@@ -433,13 +433,31 @@ export function receiptLine(accept, settle) {
433
433
  : (Number.isFinite(billed) && billed > 0 && Number.isFinite(direct) ? direct / billed : null);
434
434
  // Wallet path: OpenRouter price, plus 33% of savings vs direct when any.
435
435
  // Never print extra.markup — that field is leftover 3× and is not the quote.
436
- const saves = ratio != null
437
- ? (ratio >= 1.05
438
- ? ` (${ratio.toFixed(1)}× cheaper than direct)`
439
- : ' (at OpenRouter price nothing to compress; bind a corpus to save)')
440
- : (Number.isFinite(saved) && saved > 0
436
+ //
437
+ // THE BASIS DECIDES THE CLAIM, NOT THE RATIO'S SIZE.
438
+ //
439
+ // This used to gate the discount purely on `ratio >= 1.05`, which is the
440
+ // wrong test: on the `markup` basis the gateway sets directUsd to its OWN
441
+ // forwarded cost so downstream sums stay like-for-like (quote.ts), and
442
+ // savesVsDirect is computed against that same internal number — so the ratio
443
+ // can read well above 1 while billedUsd and directUsd are IDENTICAL.
444
+ // MEASURED 2026-08-28 on a live short-body call: billed $0.0013178, direct
445
+ // $0.0013178, savesVsDirect 1.457 — and this line printed "1.5× cheaper than
446
+ // direct" on a call that by its own two dollar figures saved nothing.
447
+ //
448
+ // The 402's own `description` already guards this correctly by branching on
449
+ // q.pricing; the receipt did not, so the challenge told the truth and the
450
+ // receipt for the same call did not. Only the counterfactual basis — leCore
451
+ // actually spilled, so "what this would have cost sent whole" is a real
452
+ // computed number — has earned the discount claim.
453
+ const counterfactual = x.pricing === 'counterfactual';
454
+ const saves = !counterfactual
455
+ ? ' (at OpenRouter price — nothing to compress; bind a corpus to save)'
456
+ : ratio != null && ratio >= 1.05
457
+ ? ` (${ratio.toFixed(1)}× cheaper than direct)`
458
+ : Number.isFinite(saved) && saved > 0
441
459
  ? ` ($${saved.toFixed(4)} saved vs direct)`
442
- : ' (at OpenRouter price — short body)');
460
+ : ' (at OpenRouter price — nothing to compress; bind a corpus to save)';
443
461
  const tx = settle?.transaction || settle?.txHash || settle?.signature;
444
462
  const rail = railOf(accept);
445
463
  return `paid ${usd}${saves}${rail ? ` · rail ${rail}` : ''}${tx ? ` · tx ${tx}` : ''}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.50.17",
3
+ "version": "0.50.18",
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",