tokenusage-cli 0.4.2 → 0.4.4

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
@@ -3,6 +3,74 @@
3
3
  本包(`tokenusage-cli`)的用户可见变更记录。发版时在顶部新增一节,
4
4
  `## <版本号>` 行会被 release workflow 取作 GitHub Release 正文。
5
5
 
6
+ ## 0.4.4
7
+
8
+ 2026-11-04。契约 v2 落地:小时用量桶按项目名拆行(`project_key`),项目键向上回退到真实
9
+ 项目目录;新增 DeepSeek 余额/状态卡、`status --json` 的计价出处块、`doctor` 计价覆盖自检;
10
+ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回退。旧 `tokentracker-*`
11
+ 别名已在服务端移除,仍打旧路径的钉版客户端会得到有声失败(GET 404 / 写动词 405),本地队列不丢。
12
+
13
+ - **服务端 breaking:旧 `tokentracker-*` API 路径别名已移除**(契约 §1.5,2026-11-03
14
+ 操作者拍板)。指向本后端的钉版旧 CLI(tokentracker-cli@1.4.x)上传会得到
15
+ GET 404 / 写动词 405——有声失败、本地 `queue.jsonl` 数据保留,升级到本包后随下次
16
+ `sync` 补传,不丢历史。
17
+ - **桶级 `project_key`(契约 v2,2026-11-03)**:小时用量桶按项目名拆行——每个项目一行,
18
+ 再加一条 `project_key` 为空的余量行,两者相加等于原聚合值,不重复计数;无法归因的
19
+ 历史/账户级用量留在余量行(`docs/cli-contract.md` §2.4、`docs/projects-page-plan.md` §5)。
20
+ - **项目键父级回退(2026-11-04)**:`projectKey()` 不再把 `<repo>/.claude/worktrees/<id>`、
21
+ `<repo>/worktrees/<id>`、`<project>/<session>/subagents` 这类工具目录当成项目名,而是向上
22
+ 取真实项目目录;qoder-cn 子代理转录继承记录里的 `cwd`。只影响新采集——历史键不回填
23
+ (会话落库键含 `session_id`,同会话只更新不改名)。`~/.codex/worktrees/<id>` 无上游项目
24
+ 规则,保持旧行为。
25
+ - **新增 DeepSeek 余额卡与 DeepSeek 服务状态**:`status` 限额面板新增第 18 家提供商
26
+ (pay-as-you-go 余额,含 12h TTL 磁盘缓存与 API key 指纹绑定,凭据错误不回退缓存),
27
+ 服务状态探测接入 status.deepseek.com。
28
+ - **`status --json` 暴露计价数据出处**:新增 `pricing` 块(数据来源、seed 快照日期、
29
+ LiteLLM/curated 条目数),成本为 0 时可直接区分「未采集」与「未定价」。
30
+ - **`doctor` 新增计价覆盖自检**:近 7 天本地队列的桶/token 计价命中率、Top 未定价模型
31
+ (零 token 的积分桶单独计数、不再误报),以及 unknown 模型「对齐到同时段主导模型」的
32
+ 只读 dry-run 预览(不改变任何历史归属)。
33
+ - **计价覆盖大幅扩充**:curated exact 91 → 191。同步上游 TokenTracker 新增的 29+9 条
34
+ (claude-opus-4-5/4-6、gpt-5.4/5.5 系、kimi-k3.1-pro 等);从 juejin-usage 选摘
35
+ volcengine/alibaba-cn/xiaomi/muse 四组 69 条(署名见 THIRD_PARTY_NOTICES);补
36
+ Unisound `u2-flash` 与 StepFun `step-5-preview` 官价。本机 7 天窗口 token 计价覆盖率
37
+ 97.3% → 100%。
38
+ - **Cursor / Kimi / Grok 限额卡新增磁盘缓存回退**:请求超时或 5xx 时展示最近一次成功
39
+ 读数(卡片标 `stale` + 原 `cached_at`),不再整卡空白。缓存文件各为
40
+ `cursor/kimi/grok-usage-limits-cache.json`(`~/.tokenusage/tracker/`,0600 原子写、
41
+ 只在成功时写、reset_at 已过期的窗口自动丢弃);身份指纹绑定(cursor=规范
42
+ userId、kimi=profile 标识、grok=JWT sub),换号不串用;凭据类错误(401/403/过期)
43
+ 不回退、原样上面板。**全部 limits 磁盘缓存的 stale TTL 统一为 12h**(含既有的
44
+ claude/codex/opencodeGo/antigravity/qoder 五家与 DeepSeek 余额卡——额度/余额类读数
45
+ 一天内即过时;qoder 促销活动缓存 24h、opencodeGo 本地估算缓存 1h 属不同语义,不动)。
46
+ - 单测:`pricing-parity`(CLI/web 两份定价数据逐字节一致守卫)、`pricing-meta`、
47
+ `pricing-coverage`、`deepseek-limits` / `deepseek-status`,以及
48
+ `cursor/grok/kimi-limits-cache-fallback`(命中/过期/失败回退/换号不串用/凭据错误直通/
49
+ 无缓存失败,共 22 例)。
50
+
51
+ ## 0.4.3
52
+
53
+ 2026-11-01。两处只有真机首跑才暴露的问题:调度摘要依旧看不出拒绝原因(修的过程中又追出
54
+ 一层 Windows 控制台代码页乱码),`reconcile` 把「还没上传」的桶报成漂移。
55
+
56
+ - **调度降级原因改取子进程输出**:`execFileSync` 的 `error.message` 以命令回显开头
57
+ (`Command failed: schtasks /Create /XML C:\Users\...`),0.4.2 打印第一行时正好把
58
+ 真正的 `ERROR: Access is denied.` 挤出 200 字符窗口。现在优先读 `stderr` / `stdout`,
59
+ 再退回 message,统一折成一行(Windows / macOS / Linux 的注册、启停、卸载错误文案
60
+ 共用这一处)。
61
+ - **Windows 控制台代码页不再乱码**:只取 stderr 后又暴露一层——中文 Windows 的
62
+ `schtasks` 按控制台代码页(936/GBK)写字节,Node 按 UTF-8 解出来是
63
+ `����: �ܾ����ʡ�`。现按 `chcp.com` 报告的活动代码页(932/936/949/950)回退
64
+ `TextDecoder` 重解,解不通才回到原 UTF-8 文本;65001 与单字节页原样直出。
65
+ zh-CN 非提升 shell 下现在的摘要就是可读的 `错误: 拒绝访问。`。
66
+ - **`reconcile` 区分 pending 与 drift**:`queue.state.json` 上传偏移之后的本地桶记入
67
+ `pending`,不计入漂移、不触发退出码 1——真机 `init` + 首跑曾报 5 个「漂移」,实际只是
68
+ 队列尾部尚未上传,一次 `sync` 后全部匹配。`--json` 新增 `upload_offset`、
69
+ `counts.pending` 与 `pending[]`;真实漂移仍照常报出并退出 1。
70
+ - 单测:stderr 优先 / 多行折叠 / 超长截断、GBK 字节解出可读文本与解不通时回退、
71
+ pending 分类、缺 `queue.state.json` 时全部按 pending、以及已上传行的真漂移仍失败
72
+ (`test/scheduled-task.test.js`、`test/reconcile.test.js`)。
73
+
6
74
  ## 0.4.2
7
75
 
8
76
  2026-11-01。`init` 的调度摘要不再只写 `degraded: xml_rejected`:现在把被拒的第一行原因
package/README.md CHANGED
@@ -35,7 +35,7 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
35
35
  | `tokenusage device-login` | 设备流配对:输出 `user_code`,在站点 `/device` 页批准后本机拿到设备令牌 |
36
36
  | `tokenusage sync` | 解析本地 AI 工具日志 → 上报小时桶 + 会话元数据 |
37
37
  | `tokenusage upload` | 只刷本地队列,不扫描来源(`--drain` / `--force` 抬批次上限、`--json` 输出结构化结果) |
38
- | `tokenusage reconcile` | 只读对账:本地 `queue.jsonl` 的 last-wins 基线 vs 云端该设备的桶明细,按 `(hour_start, source, model)` 逐键比对,有漂移退出码 1 |
38
+ | `tokenusage reconcile` | 只读对账:本地 `queue.jsonl` 的 last-wins 基线 vs 云端该设备的桶明细,按 `(hour_start, source, model)` 逐键比对,有漂移退出码 1;尚未上传的桶(`queue.state.json` 偏移之后)记为 pending,不算漂移 |
39
39
  | `tokenusage sync --watch` | 常驻模式,默认每 15 分钟增量一轮(`--interval <ms>` 可调,≥60000) |
40
40
  | `tokenusage sync --no-sessions` | 只上报小时桶,跳过会话元数据 |
41
41
  | `tokenusage sync --drain` | 补传模式:更大的批处理预算,适合首次接入/长期积压 |
@@ -74,6 +74,9 @@ tokenusage reconcile --json # 结构化漂移明细,供脚本/看
74
74
  - 漂移分三类:`missing_on_server`(本地有、云端没有,通常是待补传)、`server_only`
75
75
  (云端有、本地已无,队列被裁剪或换过机器身份)、`mismatch`(同键不同值,附逐字段
76
76
  `local → cloud` 差异)。任一存在即以退出码 `1` 结束,便于 cron / CI 判定。
77
+ - `queue.state.json` 偏移之后的本地桶记为 **pending**(尚未上传,云端只可能持有更早的值),
78
+ 单独列出、不计入漂移、不触发退出码 `1`;`tokenusage sync` 传完后重新对账即可比对这些键。
79
+ `--json` 里对应 `upload_offset`、`counts.pending` 与 `pending[]`。
77
80
 
78
81
  ## `sync --watch`:常驻自动上报
79
82
 
@@ -11,6 +11,21 @@ upstream repository and were then modified for the token-usage contract
11
11
  (`docs/cli-contract.md` in the repository root). The upstream MIT license text
12
12
  and copyright notice are preserved in this package's `LICENSE` file.
13
13
 
14
- 本包不含其他第三方资产:运行时依赖(如 `undici`)的许可随
15
- `node_modules` 一同分发;品牌图标、字体与定价快照属于 Web 端,登记在仓库根目录的
14
+ ## juejin-usage (pricing data)
15
+
16
+ `src/lib/pricing/curated-overrides.json` 中的 volcengine / xiaomi / meta(muse) /
17
+ alibaba-cn / moonshotai-cn 五组共 69 条 exact 定价条目(2026-11-03 导入)取自
18
+ [juejin-usage](https://github.com/juejin-cn/juejin-usage)(MIT License,
19
+ Copyright (c) juejin-cn)commit `f72ca4d` 的 `packages/core/src/pricing/pricing.json`
20
+ (models.dev 官方渠道价格集)。juejin-usage 的 MIT 许可要求复制时保留其版权与许可声明:
21
+
22
+ > MIT License, Copyright (c) 2026 juejin-cn — Permission is hereby granted,
23
+ > free of charge, to any person obtaining a copy of this software and
24
+ > associated documentation files, to deal in the Software without restriction,
25
+ > subject to the condition that the above copyright notice and this permission
26
+ > notice shall be included in all copies or substantial portions of the
27
+ > Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
28
+
29
+ 本包其余部分不含其他第三方资产:运行时依赖(如 `undici`)的许可随
30
+ `node_modules` 一同分发;品牌图标、字体与定价快照(LiteLLM seed)的登记见仓库根目录的
16
31
  `THIRD_PARTY_NOTICES.md`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenusage-cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Self-hosted AI coding token usage collector for the Token Usage dashboard.",
5
5
  "keywords": [
6
6
  "token-usage",
@@ -41,9 +41,9 @@
41
41
  "prepublishOnly": "npm test"
42
42
  },
43
43
  "dependencies": {
44
- "@journeyapps/wa-sqlite": "2.0.7",
45
- "smol-toml": "^1.9.0",
46
- "undici": "8.12.2",
44
+ "@journeyapps/wa-sqlite": "2.0.10",
45
+ "smol-toml": "^1.9.1",
46
+ "undici": "8.12.3",
47
47
  "yauzl": "^3.4.0"
48
48
  },
49
49
  "pnpm": {
@@ -14,10 +14,15 @@
14
14
  // queue.state.json (the upload offset) is not touched. Drift is reported per
15
15
  // key and exits 1 so a script can gate on it:
16
16
  //
17
- // missing_on_server local bucket the cloud never stored (pending/blocked upload)
17
+ // missing_on_server local bucket the cloud never stored (blocked upload)
18
18
  // server_only cloud row without a local counterpart (pruned queue, or
19
19
  // a row written under another machine identity)
20
- // mismatch same key, different values (partial upload / legacy repair)
20
+ // mismatch same key, different values (legacy repair / stale row)
21
+ //
22
+ // Keys whose last-wins row sits past the upload offset are reported as
23
+ // `pending` instead: they have never been sent, so the cloud holding the older
24
+ // value is expected, not drift (a fresh `init` + `reconcile` used to exit 1 on
25
+ // exactly those keys until a `sync` flushed them).
21
26
  //
22
27
  // Known residual: ingest dedupes a REPLAYED duplicate inside one request by
23
28
  // taking the larger total_tokens, so a queue that carried the same key twice
@@ -156,15 +161,17 @@ function resolveWindow(opts, nowMs) {
156
161
  return { fromMs: clampedFrom, toMs, clamped: clampedFrom !== effectiveFrom };
157
162
  }
158
163
 
159
- function bucketKey(hourMs, source, model) {
160
- // JSON over a delimiter: model names may contain `|`.
161
- return JSON.stringify([new Date(hourMs).toISOString(), source, model]);
164
+ function bucketKey(hourMs, source, model, project = "") {
165
+ // JSON over a delimiter: model names may contain `|`. contract v2
166
+ // (2026-11-03): project_key joins the identity; '' = unattributed (rows
167
+ // from a pre-v2 server have no project_key at all and land here too).
168
+ return JSON.stringify([new Date(hourMs).toISOString(), source, model, project]);
162
169
  }
163
170
 
164
171
  // Local baseline: every usage row in queue.jsonl, normalized/sanitized exactly
165
172
  // like the upload path, keyed and filtered on the normalized hour. Control
166
173
  // records (kind-bearing account session states / watermarks) are not buckets.
167
- async function readLocalBaseline({ queuePath, fromMs, toMs }) {
174
+ async function collectBuckets({ queuePath, fromMs, toMs, start = 0 }) {
168
175
  let handle;
169
176
  try {
170
177
  handle = await fs.open(queuePath, "r");
@@ -175,7 +182,8 @@ async function readLocalBaseline({ queuePath, fromMs, toMs }) {
175
182
  const buckets = new Map();
176
183
  try {
177
184
  const before = await handle.stat();
178
- for await (const record of iterateQueueLines(handle, 0, before.size)) {
185
+ const from = Math.min(Math.max(Number(start) || 0, 0), before.size);
186
+ for await (const record of iterateQueueLines(handle, from, before.size)) {
179
187
  // A producer may be mid-write; an incomplete tail is not yet queued data.
180
188
  if (!record.complete) break;
181
189
  const line = record.bytes.toString("utf8");
@@ -200,7 +208,8 @@ async function readLocalBaseline({ queuePath, fromMs, toMs }) {
200
208
  });
201
209
  const sanitized = sanitizeBucketForUpload(row);
202
210
  if (!sanitized) continue;
203
- buckets.set(bucketKey(hourMs, source, model), sanitized);
211
+ const project = typeof sanitized.project_key === "string" ? sanitized.project_key.trim() : "";
212
+ buckets.set(bucketKey(hourMs, source, model, project), sanitized);
204
213
  }
205
214
  } finally {
206
215
  await handle.close();
@@ -208,6 +217,19 @@ async function readLocalBaseline({ queuePath, fromMs, toMs }) {
208
217
  return buckets;
209
218
  }
210
219
 
220
+ function readLocalBaseline({ queuePath, fromMs, toMs }) {
221
+ return collectBuckets({ queuePath, fromMs, toMs });
222
+ }
223
+
224
+ // The queue suffix past queue.state.json's upload offset. Every key found here
225
+ // has its last-wins row not uploaded yet, so comparing it against the cloud is
226
+ // premature: the cloud legitimately holds the older value. Reporting it as
227
+ // drift made the first `init` + `reconcile` on a machine look broken (5 "drifted"
228
+ // keys that a single `sync` fixed), so these keys are listed as pending.
229
+ function readPendingBuckets({ queuePath, offset = 0, fromMs, toMs }) {
230
+ return collectBuckets({ queuePath, fromMs, toMs, start: offset });
231
+ }
232
+
211
233
  async function fetchPage({ url, deviceToken, anonKey, timeoutMs, fetchImpl }) {
212
234
  const headers = { Accept: "application/json", Authorization: `Bearer ${deviceToken}` };
213
235
  if (anonKey) headers.apikey = anonKey;
@@ -264,7 +286,9 @@ async function fetchServerBuckets({ baseUrl, anonKey, deviceToken, from, to, lim
264
286
  if (!Number.isFinite(hourMs)) continue;
265
287
  const source = String(row.source);
266
288
  const model = String(row.model);
267
- buckets.set(bucketKey(hourMs, source, model), row);
289
+ // Pre-v2 servers omit project_key entirely; treat as unattributed ('').
290
+ const project = typeof row.project_key === "string" ? row.project_key : "";
291
+ buckets.set(bucketKey(hourMs, source, model, project), row);
268
292
  }
269
293
  if (rows.length < pageSize) break;
270
294
  offset += rows.length;
@@ -317,15 +341,24 @@ function describeRow(row) {
317
341
  return out;
318
342
  }
319
343
 
320
- function compareBuckets({ local, server }) {
344
+ function compareBuckets({ local, server, pending = new Set() }) {
321
345
  const missingOnServer = [];
322
346
  const mismatches = [];
323
347
  const serverOnly = [];
348
+ const pendingUpload = [];
324
349
 
325
350
  for (const [key, localRow] of local) {
326
351
  const hourStart = new Date(Date.parse(localRow.hour_start)).toISOString();
327
352
  const base = { hour_start: hourStart, source: localRow.source, model: localRow.model };
328
353
  const serverRow = server.get(key);
354
+ if (pending.has(key)) {
355
+ pendingUpload.push({
356
+ ...base,
357
+ local: describeRow(localRow),
358
+ server: serverRow ? describeRow(serverRow) : null,
359
+ });
360
+ continue;
361
+ }
329
362
  if (!serverRow) {
330
363
  missingOnServer.push({ ...base, local: describeRow(localRow), server: null });
331
364
  continue;
@@ -366,10 +399,12 @@ function compareBuckets({ local, server }) {
366
399
  missing_on_server: sortEntries(missingOnServer),
367
400
  server_only: sortEntries(serverOnly),
368
401
  mismatch: sortEntries(mismatches),
402
+ pending: sortEntries(pendingUpload),
369
403
  counts: {
370
404
  missing_on_server: missingOnServer.length,
371
405
  server_only: serverOnly.length,
372
406
  mismatch: mismatches.length,
407
+ pending: pendingUpload.length,
373
408
  },
374
409
  drifted: missingOnServer.length + serverOnly.length + mismatches.length,
375
410
  };
@@ -388,17 +423,31 @@ function describeEntry(entry, isMismatch = false) {
388
423
  }
389
424
 
390
425
  function renderText(summary) {
426
+ const pendingCount = summary.counts?.pending ?? 0;
391
427
  const lines = [
392
428
  `Reconcile window (UTC, hour_start in [from, to)):`,
393
429
  ` from ${summary.from}`,
394
430
  ` to ${summary.to}`,
395
431
  summary.clamped ? " (from clamped to the server's 366-day ceiling)" : null,
396
432
  `Local baseline: ${summary.local_buckets.toLocaleString("en-US")} bucket(s) from queue.jsonl (last-wins)`,
433
+ pendingCount > 0
434
+ ? ` ${pendingCount.toLocaleString("en-US")} of them are past the upload offset (queue.state.json) and not compared yet`
435
+ : null,
397
436
  `Cloud device: ${summary.device_id || "unknown"} — ${summary.cloud_buckets.toLocaleString("en-US")} row(s) in ${summary.pages} page(s)`,
398
437
  ].filter(Boolean);
399
438
 
400
439
  if (summary.drifted === 0) {
401
- lines.push("Result: OK — every local bucket matches the cloud row.");
440
+ lines.push(
441
+ pendingCount > 0
442
+ ? `Result: OK — every uploaded bucket matches the cloud row (${pendingCount.toLocaleString("en-US")} still pending upload).`
443
+ : "Result: OK — every local bucket matches the cloud row.",
444
+ );
445
+ if (pendingCount > 0) {
446
+ lines.push(
447
+ "Pending buckets are local rows `sync` has not uploaded yet, so the cloud cannot",
448
+ "hold them; run `tokenusage sync` and re-run this command to compare them.",
449
+ );
450
+ }
402
451
  return `${lines.join("\n")}\n`;
403
452
  }
404
453
 
@@ -422,6 +471,11 @@ function renderText(summary) {
422
471
  lines.push(` … and ${entries.length - TEXT_DRIFT_LIMIT} more (use --json for the full list)`);
423
472
  }
424
473
  }
474
+ if (pendingCount > 0) {
475
+ lines.push(
476
+ `Note: ${pendingCount.toLocaleString("en-US")} local key(s) are still pending upload and were left out of the drift count.`,
477
+ );
478
+ }
425
479
  lines.push(
426
480
  "Hint: `tokenusage upload` pushes pending local buckets; `server_only` keys mean the",
427
481
  "cloud holds rows this queue no longer contains. This command never writes.",
@@ -453,6 +507,16 @@ async function cmdReconcile(argv = [], options = {}) {
453
507
  }
454
508
 
455
509
  const local = await readLocalBaseline({ queuePath, fromMs: window.fromMs, toMs: window.toMs });
510
+ // Rows past queue.state.json's offset have not been uploaded: their keys are
511
+ // pending (not drift), because the cloud can only hold the previous value.
512
+ const queueState = (await readJson(path.join(trackerDir, "queue.state.json"))) || {};
513
+ const uploadOffset = Number.isFinite(Number(queueState.offset)) ? Math.max(0, Number(queueState.offset)) : 0;
514
+ const pending = await readPendingBuckets({
515
+ queuePath,
516
+ offset: uploadOffset,
517
+ fromMs: window.fromMs,
518
+ toMs: window.toMs,
519
+ });
456
520
  const { buckets: server, deviceId, pages } = await fetchServerBuckets({
457
521
  baseUrl: runtime.baseUrl,
458
522
  anonKey: runtime.anonKey,
@@ -463,7 +527,7 @@ async function cmdReconcile(argv = [], options = {}) {
463
527
  timeoutMs: runtime.httpTimeoutMs,
464
528
  fetchImpl,
465
529
  });
466
- const compared = compareBuckets({ local, server });
530
+ const compared = compareBuckets({ local, server, pending: new Set(pending.keys()) });
467
531
 
468
532
  const summary = {
469
533
  status: compared.drifted === 0 ? "ok" : "drift",
@@ -474,6 +538,7 @@ async function cmdReconcile(argv = [], options = {}) {
474
538
  local_buckets: local.size,
475
539
  cloud_buckets: server.size,
476
540
  pages,
541
+ upload_offset: uploadOffset,
477
542
  counts: compared.counts,
478
543
  drifted: compared.drifted,
479
544
  drift: {
@@ -481,6 +546,7 @@ async function cmdReconcile(argv = [], options = {}) {
481
546
  server_only: compared.server_only,
482
547
  mismatch: compared.mismatch,
483
548
  },
549
+ pending: compared.pending,
484
550
  };
485
551
 
486
552
  // Output seam: tests render without hijacking process.stdout (which would
@@ -493,4 +559,12 @@ async function cmdReconcile(argv = [], options = {}) {
493
559
  return summary;
494
560
  }
495
561
 
496
- module.exports = { cmdReconcile, parseArgs, resolveWindow, readLocalBaseline, compareBuckets, RECONCILE_SLUG };
562
+ module.exports = {
563
+ cmdReconcile,
564
+ parseArgs,
565
+ resolveWindow,
566
+ readLocalBaseline,
567
+ readPendingBuckets,
568
+ compareBuckets,
569
+ RECONCILE_SLUG,
570
+ };
@@ -48,6 +48,7 @@ const {
48
48
  } = require("../lib/openclaw-session-plugin");
49
49
  const { resolveTrackerPaths } = require("../lib/tracker-paths");
50
50
  const { resolveDeviceTokenPresence } = require("../lib/cloud-device-token");
51
+ const { getPricingMeta } = require("../lib/pricing");
51
52
  const {
52
53
  isCollectionPaused,
53
54
  isRunReportEnabled,
@@ -1281,6 +1282,9 @@ async function cmdStatus(argv = []) {
1281
1282
  }
1282
1283
  : {}),
1283
1284
  subscriptions,
1285
+ // Pricing data provenance + staleness, so a $0 cost row can be triaged
1286
+ // as "not collected" vs "not priced" from `status --json` alone.
1287
+ pricing: getPricingMeta(),
1284
1288
  };
1285
1289
 
1286
1290
  if (opts.json) {
@@ -242,7 +242,11 @@ function fetchCursorUsageSummary({ cookie, timeoutMs = 30000, fetchImpl = fetch
242
242
  signal: AbortSignal.timeout(timeoutMs),
243
243
  }).then(async (res) => {
244
244
  if (res.status === 401 || res.status === 403) {
245
- throw new Error("Cursor session expired — re-login in Cursor to refresh");
245
+ // The code marks the error actionable (re-login) so the limits
246
+ // disk-cache fallback never hides it.
247
+ const error = new Error("Cursor session expired — re-login in Cursor to refresh");
248
+ error.code = "AUTH_EXPIRED";
249
+ throw error;
246
250
  }
247
251
  if (!res.ok) {
248
252
  throw new Error(`Cursor API returned ${res.status}`);