zames_pro 2.82.127 → 2.82.129

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/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.82.129] - 2026-10-24
11
+
12
+ ### Fixed
13
+
14
+ - **tui:** a compact token count never renders 1000k or 1000.0M
15
+
16
+ ## [2.82.128] - 2026-10-24
17
+
18
+ ### Fixed
19
+
20
+ - **qwen:** a negative usage count is not a context size
21
+
10
22
  ## [2.82.127] - 2026-10-24
11
23
 
12
24
  ### Changed
@@ -508,7 +508,20 @@ export function formatCompactTokens(tokens) {
508
508
  if (typeof tokens !== 'number' || !Number.isFinite(tokens) || tokens < 0) {
509
509
  return '';
510
510
  }
511
- const n = Math.round(tokens);
511
+ let n = Math.round(tokens);
512
+ // Promote BEFORE rendering when the ROUNDED value would read as a full next
513
+ // unit: 999 949 -> '1000k' (nonsense kilo) while the percentage beside it
514
+ // already says 100%, and 999 950 000 -> '1000.0M'. Same rule as
515
+ // attachments.formatSize.
516
+ if (Math.round(n / 1000) >= 1000 && n < 1_000_000)
517
+ n = 1_000_000;
518
+ if (Math.round((n / 1_000_000) * 10) / 10 >= 1000 && n < 1_000_000_000) {
519
+ n = 1_000_000_000;
520
+ }
521
+ if (n >= 1_000_000_000) {
522
+ const b = n / 1_000_000_000;
523
+ return (Number.isInteger(b) ? String(b) : b.toFixed(1)) + 'B';
524
+ }
512
525
  if (n >= 1_000_000) {
513
526
  const m = n / 1_000_000;
514
527
  return (Number.isInteger(m) ? String(m) : m.toFixed(1)) + 'M';
@@ -153,6 +153,14 @@ export function extractAnswer(body) {
153
153
  // accumulated_token_usage. (`total_tokens` = prompt + answer, so it inflates
154
154
  // the number by the answer length; it is only the fallback when input_tokens
155
155
  // is absent.) Null when the body carries no usage.
156
+ // A token count is a FINITE NON-NEGATIVE number, the same rule DeepSeek and
157
+ // GLM apply: a negative payload (a nonsense reply, a wrapped `int` in a proxy
158
+ // build) used to become `browser._lastTokenUsage` as-is, so the context badge
159
+ // vanished (tokenStatusLevel rejects a negative count) and the auto-compact
160
+ // percentage went negative and never fired. Treat it as "no usage".
161
+ function isUsageCount(v) {
162
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0;
163
+ }
156
164
  export function extractTokenUsage(body) {
157
165
  let lastInput = null;
158
166
  let lastTotal = null;
@@ -161,9 +169,9 @@ export function extractTokenUsage(body) {
161
169
  if (!usage || typeof usage !== 'object')
162
170
  continue;
163
171
  const u = usage;
164
- if (typeof u.input_tokens === 'number' && Number.isFinite(u.input_tokens))
172
+ if (isUsageCount(u.input_tokens))
165
173
  lastInput = u.input_tokens;
166
- if (typeof u.total_tokens === 'number' && Number.isFinite(u.total_tokens))
174
+ if (isUsageCount(u.total_tokens))
167
175
  lastTotal = u.total_tokens;
168
176
  }
169
177
  if (lastInput !== null)
@@ -175,9 +183,9 @@ export function extractTokenUsage(body) {
175
183
  const obj = JSON.parse(body);
176
184
  const usage = obj?.usage;
177
185
  if (usage) {
178
- if (typeof usage.input_tokens === 'number')
186
+ if (isUsageCount(usage.input_tokens))
179
187
  return usage.input_tokens;
180
- if (typeof usage.total_tokens === 'number')
188
+ if (isUsageCount(usage.total_tokens))
181
189
  return usage.total_tokens;
182
190
  }
183
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zames_pro",
3
- "version": "2.82.127",
3
+ "version": "2.82.129",
4
4
  "description": "Terminal coding agent that drives a real browser to chat with DeepSeek, Qwen and other web LLMs — no API key required. Reads and edits files, runs commands, commits to git, like Claude Code / Codex CLI.",
5
5
  "type": "module",
6
6
  "bin": {