zames_pro 2.82.127 → 2.82.128

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,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.82.128] - 2026-10-24
11
+
12
+ ### Fixed
13
+
14
+ - **qwen:** a negative usage count is not a context size
15
+
10
16
  ## [2.82.127] - 2026-10-24
11
17
 
12
18
  ### Changed
@@ -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.128",
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": {