tokenusage-cli 0.4.6 → 0.4.7

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,36 @@
3
3
  本包(`tokenusage-cli`)的用户可见变更记录。发版时在顶部新增一节,
4
4
  `## <版本号>` 行会被 release workflow 取作 GitHub Release 正文。
5
5
 
6
+ > 0.4.x 之前的条目为压缩摘要;细节与当时的验收记录见 `docs/cli-release.md`
7
+ > 与 `docs/archive/`。
8
+
9
+ ## 0.4.7
10
+
11
+ 2026-11-05。CLI 输出面批次,零契约变更,服务端无需同步升级:命令自报设备身份 + 采集结果摘要补全。
12
+ 一个账户有两台采集机(家机 / 公司机),而 `status` / `sync` 的输出正是被贴进发版清单与工单的
13
+ 那段文字——以前它从不说「我是哪台机器」,也不说「传了多少 token」,于是「本机」与「另一台」
14
+ 在文档里混成一团(`docs/cli-release.md` §四与§五之间「本机」的指代就翻转过一次)。
15
+
16
+ - **每条命令自报设备身份**:`status` / `sync` / `upload` / `reconcile` / `doctor` / `init`
17
+ 的文本输出都带一行 `- Device: <hostname> #<machine_id 前 8 位> (id <device_id>)`,未配对时
18
+ 显示 `(not paired)`;`reconcile` 另加 `Local device:` 与 `Cloud device:` 并列。
19
+ 设备名规则与契约 `docs/cli-contract.md` §2.2 一致(打印的是**默认名**;仪表盘里改过的
20
+ 云端当前名不改变这个稳定标识)。
21
+ - **`status --json` 新增 `device` 块**:`name` / `hostname` / `machine_id` / `device_id`;
22
+ `--light` 表格新增 `Device` 与 `Device ID` 两行。
23
+ - **`doctor` 新增 `runtime.device_identity` 检查**:有 `machine_id` 记 OK,缺失记 warn;
24
+ 检查项数由 15 增至 16。
25
+ - **`sync` 摘要补全**:新增 token 数(`Uploaded: 2 rows (23,604,640 tokens), 0 skipped`)、
26
+ 会话数、积分、耗时、失败原因;会话上传原本单独打一行且排在汇总之前,现并入汇总。
27
+ 摘要抽成纯函数 `buildSyncSummaryLines` 以便单测。
28
+ - **数字统一千分位**:文件数 / 行数 / token 数按 `1,234` 输出。
29
+ - **自动运行日志**:`sync.log` 的 JSONL 补 `tokens` / `credits` / `sessions_uploaded` /
30
+ `sessions_skipped` / `duration_ms` 字段(纯追加,不改既有字段)。
31
+ - **`upload` 命令**:加 `- Device:` 与 `- Credits in this upload:`。
32
+ - **身份种子回退**:`uninstall --purge` 删掉 `~/.tokenusage` 后,purge 存活的
33
+ `~/.config/tokenusage/machine-id` 仍能恢复 `machine_id`,命令依旧认得出这台机器。
34
+ 身份计算全程只读,不生成也不改写 id。
35
+
6
36
  ## 0.4.6
7
37
 
8
38
  2026-11-05。上游对齐补丁 + 限额面板落地:Cursor cache-only 行、Qoder credits/准入/时间戳、
@@ -59,7 +89,7 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
59
89
  `sync` 补传,不丢历史。
60
90
  - **桶级 `project_key`(契约 v2,2026-11-03)**:小时用量桶按项目名拆行——每个项目一行,
61
91
  再加一条 `project_key` 为空的余量行,两者相加等于原聚合值,不重复计数;无法归因的
62
- 历史/账户级用量留在余量行(`docs/cli-contract.md` §2.4、`docs/projects-page-plan.md` §5)。
92
+ 历史/账户级用量留在余量行(契约 §2.4)。
63
93
  - **项目键父级回退(2026-11-04)**:`projectKey()` 不再把 `<repo>/.claude/worktrees/<id>`、
64
94
  `<repo>/worktrees/<id>`、`<project>/<session>/subagents` 这类工具目录当成项目名,而是向上
65
95
  取真实项目目录;qoder-cn 子代理转录继承记录里的 `cwd`。只影响新采集——历史键不回填
@@ -73,9 +103,9 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
73
103
  - **`doctor` 新增计价覆盖自检**:近 7 天本地队列的桶/token 计价命中率、Top 未定价模型
74
104
  (零 token 的积分桶单独计数、不再误报),以及 unknown 模型「对齐到同时段主导模型」的
75
105
  只读 dry-run 预览(不改变任何历史归属)。
76
- - **计价覆盖大幅扩充**:curated exact 91 → 191。同步上游 TokenTracker 新增的 29+9 条
77
- (claude-opus-4-5/4-6、gpt-5.4/5.5 系、kimi-k3.1-pro 等);从 juejin-usage 选摘
78
- volcengine/alibaba-cn/xiaomi/muse 四组 69 条(署名见 THIRD_PARTY_NOTICES);补
106
+ - **计价覆盖大幅扩充**:curated exact 91 → 191。同步上游新增的 29+9 条
107
+ (claude-opus-4-5/4-6、gpt-5.4/5.5 系、kimi-k3.1-pro 等);从参照项目选摘
108
+ volcengine/alibaba-cn/xiaomi/muse 四组 69 条(署名见 `THIRD_PARTY_NOTICES.md`);补
79
109
  Unisound `u2-flash` 与 StepFun `step-5-preview` 官价。本机 7 天窗口 token 计价覆盖率
80
110
  97.3% → 100%。
81
111
  - **Cursor / Kimi / Grok 限额卡新增磁盘缓存回退**:请求超时或 5xx 时展示最近一次成功
@@ -103,7 +133,7 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
103
133
  共用这一处)。
104
134
  - **Windows 控制台代码页不再乱码**:只取 stderr 后又暴露一层——中文 Windows 的
105
135
  `schtasks` 按控制台代码页(936/GBK)写字节,Node 按 UTF-8 解出来是
106
- `����: �ܾ����ʡ�`。现按 `chcp.com` 报告的活动代码页(932/936/949/950)回退
136
+ `: ܾʡ`。现按 `chcp.com` 报告的活动代码页(932/936/949/950)回退
107
137
  `TextDecoder` 重解,解不通才回到原 UTF-8 文本;65001 与单字节页原样直出。
108
138
  zh-CN 非提升 shell 下现在的摘要就是可读的 `错误: 拒绝访问。`。
109
139
  - **`reconcile` 区分 pending 与 drift**:`queue.state.json` 上传偏移之后的本地桶记入
@@ -118,22 +148,17 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
118
148
 
119
149
  2026-11-01。`init` 的调度摘要不再只写 `degraded: xml_rejected`:现在把被拒的第一行原因
120
150
  (如 `ERROR: Access is denied.`,超过 100 字符截断)一并打印,用户能据此判断是「需要
121
- 管理员权限」还是「任务定义本身有问题」。
122
-
123
- - Windows:非提升 shell 下 `schtasks /Create /XML` 必然 `Access is denied`,降级路径照旧
124
- 每小时采集(隐藏窗口);要启用 catch-up / retry / 无执行时限,需以管理员身份重跑
125
- `tokenusage init`。
126
- - 单测覆盖:原因可见、超长命令输出截断(`test/scheduled-task.test.js`)。
151
+ 管理员权限」还是「任务定义本身有问题」。Windows:非提升 shell 下 `schtasks /Create /XML`
152
+ 必然 `Access is denied`,降级路径照旧每小时采集(隐藏窗口);要启用 catch-up / retry /
153
+ 无执行时限,需以管理员身份重跑 `tokenusage init`。单测覆盖原因可见与超长输出截断。
127
154
 
128
155
  ## 0.4.1
129
156
 
130
157
  2026-11-01。修复 `tokenusage reconcile` 在真实队列上的误报:队列行写的是
131
- `conversation_count`(`docs/cli-contract.md` §2.4 的线名),小时表列名是
132
- `conversations`,按字段名直接比较会把每一行都报成 `conversations local 0 → cloud N`
133
- (本机首跑 41/43 行误报)。现在按别名归一后比较,真实差异仍照常报出。
134
-
135
- - 会话数比较读 `conversations`,缺失时回退 `conversation_count`(两者都没有按 0)。
136
- - 单测按真实队列形态(只带 `conversation_count`)覆盖,并断言真差异仍落在 `conversations` 字段。
158
+ `conversation_count`(契约 §2.4 的线名),小时表列名是 `conversations`,按字段名直接比较
159
+ 会把每一行都报成 `conversations local 0 → cloud N`(本机首跑 41/43 行误报)。现在按别名
160
+ 归一后比较,真实差异仍照常报出。会话数比较读 `conversations`,缺失时回退
161
+ `conversation_count`(两者都没有按 0)。
137
162
 
138
163
  ## 0.4.0
139
164
 
@@ -147,10 +172,9 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
147
172
  命令都有效,未知命令抛 `UNKNOWN_COMMAND`。
148
173
  - **新增 `tokenusage upload`**:只刷本地队列、不扫描来源(`--drain` / `--force`
149
174
  抬批次上限,`--json` 输出结构),与 `sync` 共用 `drainQueueToCloud` 与
150
- `sync.lock`;`sync --upload-only` 为同一实现的别名。积压较多时不必再等
151
- 全量扫描。
152
- - **`--source` 严格校验**:非法 id 直接报错并列出可用列表(此前静默降级为全量
153
- 扫描,容易误以为只采了某个来源)。
175
+ `sync.lock`;`sync --upload-only` 为同一实现的别名。积压较多时不必再等全量扫描。
176
+ - **`--source` 严格校验**:非法 id 直接报错并列出可用列表(此前静默降级为全量扫描,
177
+ 容易误以为只采了某个来源)。
154
178
  - **`sessions` 严格解析**:未知参数、缺值、非法 `--format` 均报错;`--out` 改为
155
179
  原子写(0600),避免脚本拿到半截 JSON / CSV。
156
180
  - **`--watch` 失败退避**:连续失败按 1x → 2x → 5x 拉长间隔并在 stderr 提示,
@@ -181,13 +205,11 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
181
205
  明细。命令不上传、不改写队列、不动上传 offset,后端读取面为
182
206
  `GET /api/functions/token-usage-reconcile`(契约 §2.13)。
183
207
  - 测试 76 → 130 条(新增 `cli-dispatch` / `args-strict` / `scheduled-task` /
184
- `queue-row-normalize` / `integration-gate` / `reconcile`;`integration-gate` 锁定
185
- 「选中才写工具配置」与 `upload` 未配对即拒绝,`reconcile` 锁定窗口解析、last-wins
186
- 基线、漂移分类与退出码)。
208
+ `queue-row-normalize` / `integration-gate` / `reconcile`)。
187
209
 
188
210
  ## 0.3.0
189
211
 
190
- 新增三个采集来源/维度,修复 Windows 下 Qoder 会话的发现与口径问题。
212
+ 2026-10-31。新增三个采集来源/维度,修复 Windows 下 Qoder 会话的发现与口径问题。
191
213
 
192
214
  - **Trae CN 本地库接入**:`resolveTraeDbPaths` 新增 `Trae CN` 安装目录
193
215
  (与 `Trae` / `TRAE SOLO` 同 schema,共享应用密钥直接解密)。此前国内版
@@ -207,157 +229,111 @@ curated 定价扩到 191 条,Cursor / Kimi / Grok 限额卡补磁盘缓存回
207
229
 
208
230
  ## 0.2.6
209
231
 
210
- 移除从未接线的错误上报 SDK,安装体积与运行时副本明显变小;采集行为不变。
232
+ 2026-10-30。移除从未接线的错误上报 SDK,安装体积与运行时副本明显变小;采集行为不变。
211
233
 
212
234
  - 删除 `@sentry/node` 与 `src/lib/sentry.js`、`src/lib/telemetry-pref.js`:
213
235
  CLI 只在启动时 init 了 Sentry,`captureException` 没有任何调用点,实际从不上报;
214
236
  但它在运行时副本里占 44 MB(67.5 MB 的约 65%),全局安装还带入
215
237
  `@sentry/bundler-plugins` 的构建期依赖链(安装总量 93.1 MB 中约 59 MB)。
216
- 移除后运行时副本 22.9 MB(实测 462 个文件)、干净 prefix 安装 23 MB
217
- (此前 93.1 MB),且不再有第三方上报入口。
238
+ 移除后运行时副本 22.9 MB(实测 462 个文件)、干净 prefix 安装 23 MB。
218
239
  - `bin/tokenusage.js` 未捕获异常的兜底里还留着一个 `require('../src/lib/sentry')`
219
240
  (包在 try/catch 里,删模块后永不生效的残留);一并删除,守卫测试改为同时扫描
220
241
  `src/` 与 `bin/`。
221
242
  - README 隐私边界同步:CLI 不做匿名心跳、也不做任何第三方错误上报。
222
- - `THIRD_PARTY_NOTICES.md` 的运行时依赖示例去掉 `@sentry/node`。
223
243
  - 新增 `test/packaging.test.js` 守卫:`@sentry/*` 不得重新出现在依赖或源码中;
224
244
  运行时副本回归测试改用 `yauzl` 的传递依赖 `pend` 验证扁平闭包复制。
225
- - 未随本版改动:macOS/Linux 原生调度、`init` 逐工具集成选择(见
226
- `docs/cli-release.md` §四,等真机验证/形态确认后再做)。
227
245
 
228
246
  ## 0.2.5
229
247
 
230
- 0.2.4 验收后的小修:去掉安装警告、修正初始化重复文案,并补 Windows CI。
248
+ 2026-10-30。0.2.4 验收后的小修:去掉安装警告、修正初始化重复文案,并补 Windows CI。
231
249
 
232
250
  - 移除 `@mongodb-js/zstd` 与两处 Node 20 zstd 回落分支:包 `engines` 已是
233
251
  `>=22.19`,`node:zlib` 自带 zstd。`npm i -g` 不再出现 `prebuild-install`
234
252
  弃用警告,运行时副本也少一个 native 依赖。
235
- - 修 `init` 跳过行重复文案:detail 已以 `Skipped` 开头时不再叠加
236
- `Skipped - ` 前缀(此前显示 `Skipped - Skipped (--no-integrations)`)。
237
- - 顺手去掉 `--dry-run` 收尾的重复 `Dry run complete` 行,只保留
238
- `Run init without --dry-run to apply changes.`。
239
- - README 补齐 `init` 的 `--yes` / `--dry-run` / `--no-open` / `--link-code`
240
- 参数说明。
253
+ - 修 `init` 跳过行重复文案与 `--dry-run` 收尾的重复行。
241
254
  - CI 新增 `windows-latest` job:跑 CLI 测试 + `init --dry-run` 烟测并断言
242
255
  输出不含 `Skipped - Skipped`,避免 VBS / 入口类回归只靠发版前人工验收。
243
256
 
244
257
  ## 0.2.4
245
258
 
246
- 计划任务抗 Node 版本切换 + 自检一次性收口的采集可靠性修复(发 0.2.3 后立即补;
247
- 家里机实测发现)。
248
-
249
- - 0.2.3 的隐藏 VBS 把 npm 全局前缀里的包路径写死,而 nvm-windows 的全局前缀
250
- 按 Node 版本分目录(如 `E:\nvm\nvm\v24.4.1\node_modules\tokenusage-cli`)。
251
- `nvm use` 之后该路径消失,任务每小时以 "file not found" 失败
252
- (`LastTaskResult` 非 0、日志停更),而任务本身看起来仍"已注册"。
253
- - VBS 现在先 `FileExists` 探测包路径,缺失时回落到 init 复制到数据目录的自包含
254
- 运行时 `~/.tokenusage/tracker/app/bin/tracker.js`,采集不中断。
255
- - VBS 的引号改用 `Chr(34)` 拼接(不再依赖转义写法),行为不变:wscript 直接起
256
- node、隐藏窗口、用退出码回填 `LastTaskResult`。
257
- - 运行时副本改为"依赖闭包"复制:旧实现整目录 `fs.cp`,在 pnpm 安装下只复制到
258
- junction 链接(副本里 `node_modules` 只有 1 项),副本一跑就是
259
- `Cannot find module`;现在按依赖图逐个复制真实目录,npm / pnpm 两种布局都能
260
- 得到自包含副本。
261
- - 副本先复制到 `app.new` 暂存目录,**实际启动一遍**(`require` 全部直接依赖 +
262
- `--version`)通过后才替换 `app` 并写 `.runtime-ready` 标记。没有标记的副本
263
- 一律不使用——半成品副本在忽略输出的后台进程里静默死掉,表现与"采集正常"
264
- 完全一样,这是最难排查的一类失败。
265
- - notify / OpenClaw hook / OpenClaw session plugin / sync 自动重试脚本统一按
266
- "带标记的副本 → 已安装包入口 → npx" 三级选择启动器。
267
- - `tokenusage doctor` 新增 `runtime.copy` 检查:缺标记、版本落后都会给出
268
- warn 与重跑 `init` 的建议(升级 CLI 后重跑之前先能看见)。
269
- - `init` 复制失败不再静默:报告里列一行(stderr 同时提示),并说明会自动回退。
270
- - `uninstall` 一并清理暂存目录 `app.new`。
271
- - 后台 spawn 全部加 `windowsHide`(notify 之外的 hook / 自动重试 / 本地 API),
272
- 避免 GUI 宿主(如 oh-my-pi)每轮闪一个控制台窗口。
259
+ 2026-10-29。计划任务抗 Node 版本切换 + 自检一次性收口的采集可靠性修复。
260
+
261
+ - 0.2.3 的隐藏 VBS 把 npm 全局前缀里的包路径写死,而 nvm-windows 的全局前缀按
262
+ Node 版本分目录。`nvm use` 之后该路径消失,任务每小时以 "file not found" 失败
263
+ (`LastTaskResult` 非 0、日志停更),而任务本身看起来仍"已注册"。VBS 现在先
264
+ `FileExists` 探测包路径,缺失时回落到 init 复制到数据目录的自包含运行时。
265
+ - 运行时副本改为"依赖闭包"复制(旧实现整目录 `fs.cp`,在 pnpm 安装下只复制到
266
+ junction 链接,副本一跑就是 `Cannot find module`),并先复制到 `app.new` 暂存
267
+ 目录、**实际启动一遍**通过后才替换并写 `.runtime-ready` 标记。
268
+ - notify / OpenClaw hook / 自动重试脚本统一按"带标记的副本 → 已安装包入口 → npx"
269
+ 三级选择启动器。
270
+ - `tokenusage doctor` 新增 `runtime.copy` 检查;`init` 复制失败不再静默;
271
+ `uninstall` 一并清理暂存目录 `app.new`;后台 spawn 全部加 `windowsHide`。
273
272
  - `sync --watch --interval=<毫秒>` 等号写法不再泄漏进 sync 参数(此前会被当成
274
- 未知参数导致每一轮失败);低于 1 分钟仍按 15 分钟处理。
275
- - 仍然建议升级或切换 Node 版本后重跑一次
276
- `tokenusage init --yes --no-integrations --no-open`:回落副本是上次 init 的
277
- 快照,重跑才会同步到最新版本。
273
+ 未知参数导致每一轮失败)。
278
274
 
279
275
  ## 0.2.3
280
276
 
281
- 修复 0.2.x 计划任务的两个隐藏缺陷(0.2.2 升级验收时实测发现)。
277
+ 2026-10-28。修复 0.2.x 计划任务的两个隐藏缺陷(0.2.2 升级验收时实测发现)。
282
278
 
283
279
  - 计划任务指向错误入口:init 注册的隐藏 VBS 调用的是 `src/cli.js`——那是只
284
280
  导出 `run()` 的库文件、没有命令行入口,任务 0.1 秒内以退出码 0 结束,
285
- 既不采集也不写日志,`LastTaskResult` 永远是 0(看起来永远成功)。VBS 现
286
- 固定指向包内 `bin/tokenusage.js`,并有回归测试锁定(禁止再指向 `src/cli.js`)。
287
- - 定时运行不落日志:`sync --from-scheduled` 只打印到 stdout,隐藏窗口下没有
288
- 任何 trail,与 0.2.2 发布说明不符。现在所有自动风味运行(scheduled / hook /
289
- retry / watch)统一追加到滚动日志 `~/.tokenusage/tracker/logs/sync.log`。
290
- - 已注册过任务的机器:升级后重跑一次
291
- `tokenusage init --yes --no-integrations --no-open` 即可修正任务入口。
292
- - 品牌残留:init 启动横幅的 ASCII 与大标题仍是上游的 TOKEN TRACKER,
293
- local-api 的兜底设备名也写 Token Tracker;按 AGENTS 命名约束统一为
294
- Token Usage,并加回归测试防回潮。
281
+ 既不采集也不写日志。VBS 现固定指向包内 `bin/tokenusage.js`,并有回归测试锁定。
282
+ - 定时运行不落日志:所有自动风味运行(scheduled / hook / retry / watch)统一追加
283
+ 到滚动日志 `~/.tokenusage/tracker/logs/sync.log`。
284
+ - 品牌残留:init 启动横幅与 local-api 兜底设备名统一为 Token Usage,并加回归测试防回潮。
295
285
  - 移除上游遗留的匿名安装心跳(`POST /api/functions/tokenusage-telemetry`):
296
- 本仓库契约与 Web 端都没有该路由,每次 sync 只会拿到 404 并进退避,还与启动屏
297
- "只有 token 计数离开本机"的口径冲突。要统计安装量,先补服务端路由再恢复。
298
- - 修正 local-api 遗留的本地服务 spawn 路径(`bin/tracker.js` 自 fork 起就不
299
- 存在),并新增发包自检测试:bin 入口存在、spawn 路径可解析、无孤儿端点。
300
- - `--help` 补齐 `init --no-integrations/--no-task` 与 `sync --interval`。
301
- - 修正 `sync --watch --interval <ms>` 的非法值处理:README 承诺低于 1 分钟回退
302
- 15 分钟,但此前参数会漏进 cmdSync,导致每轮以 `Unknown option: --interval`
303
- 失败;现在该参数始终被剥离,并有单测覆盖。
286
+ 本仓库契约与 Web 端都没有该路由,每次 sync 只会拿到 404 并进退避。
287
+ - 修正 `sync --watch --interval <ms>` 的非法值处理:该参数始终被剥离,并有单测覆盖。
304
288
  - 署名与包元数据收敛:`description` 去掉 fork 字样;`THIRD_PARTY_NOTICES.md`
305
- 只保留上游 TokenTracker 一节(其余条目是 Web 端资产,本仓库已不存在也不随包);
306
- README 的来源说明收为一句,指向 `LICENSE` / `THIRD_PARTY_NOTICES.md`。
289
+ 只保留上游一节。
307
290
 
308
291
  ## 0.2.2
309
292
 
310
- 新机初始化修复与采集口径修正。
293
+ 2026-10-27。新机初始化修复与采集口径修正。
311
294
 
312
295
  - 修复严重初始化缺陷:从 npm 安装后 `tokenusage init` 必崩(包内缺少
313
296
  `bin/tracker.js`——fork 改名 bin 后安装器没跟着改,0.1.0 起所有已发布版本
314
297
  受影响;单测因跳过运行时拷贝未覆盖)。新增防回归测试直接执行运行时拷贝。
315
298
  - init 新增 `--no-integrations`:只做扫描根配置、计划任务注册与运行上报,
316
- **不改动任何 AI 工具的配置**(不装 hooks/notify/插件)。只要定时采集、
317
- 不想被触碰各工具配置的机器终于可以安全重跑 init。
318
- - init 的欢迎屏与完成屏改为显示真实站点地址(原先写死一个本地端口残留)。
319
- - 计划任务运行的口径修正:init 注册的隐藏任务改跑 `sync --from-scheduled`,
320
- 运行记录正确标记为"定时"(此前记成"手动"),并写入滚动日志(此前隐藏
321
- 运行无任何日志痕迹)。已在 0.2.0/0.2.1 注册过任务的机器重跑一次 init 即可升级。
299
+ **不改动任何 AI 工具的配置**。
300
+ - init 的欢迎屏与完成屏改为显示真实站点地址。
301
+ - 计划任务运行的口径修正:改跑 `sync --from-scheduled`,运行记录正确标记为"定时"
302
+ 并写入滚动日志。
322
303
 
323
304
  ## 0.2.1
324
305
 
325
- 修复 0.2.0 的严重回归:运行上报的版本号读取用了错误的相对路径(`Cannot find
326
- module '../package.json'`),导致每轮 `sync` 启动即崩溃——定时与手动采集全部
327
- 中断。本地包实测通过后发布;并新增防回归测试,锁定嵌套模块的 package.json
328
- require 深度,此类问题不再可能静默通过测试。
306
+ 2026-10-27。修复 0.2.0 的严重回归:运行上报的版本号读取用了错误的相对路径
307
+ (`Cannot find module '../package.json'`),导致每轮 `sync` 启动即崩溃——定时与手动
308
+ 采集全部中断。本地包实测通过后发布;并新增防回归测试,锁定嵌套模块的 package.json
309
+ require 深度。
329
310
 
330
311
  ## 0.2.0
331
312
 
332
- 采集控制与运行记录:采集器从此可暂停、可审计。
313
+ 2026-10-26。采集控制与运行记录:采集器从此可暂停、可审计。
333
314
 
334
315
  - 新增 `tokenusage pause` / `resume`:一键暂停/恢复自动采集。暂停期间
335
316
  `sync --auto` / `--watch`(含通知触发)静默退出,手动 `tokenusage sync`
336
317
  不受影响;`status` 显示当前采集状态。
337
- - `init` 接管 Windows 计划任务注册:每小时任务由 init 创建(默认经 VBS
338
- 隐藏窗口运行,不再弹 conhost 黑框;`--no-task` 可跳过);pause/resume
339
- 顺势启停任务;`uninstall` 一并清理任务与脚本。
340
- - 同步日志改为滚动文件(`~/.tokenusage/tracker/logs/sync.log`,1 MiB 轮转
341
- 一代),不再依赖注册时的 `>>` 重定向。
342
- - 每轮 sync 结束后向服务端上报一条运行记录(时间、触发方式、结果、耗时、
343
- 上报量),仪表盘新增"采集记录"页;空跑也上报,作为采集器心跳。上报为
344
- 尽力而为,失败只记本地日志,绝不影响用量数据采集;不想上报可在 init 时
318
+ - `init` 接管 Windows 计划任务注册(默认经 VBS 隐藏窗口运行;`--no-task` 可跳过);
319
+ pause/resume 顺势启停任务;`uninstall` 一并清理任务与脚本。
320
+ - 同步日志改为滚动文件(`~/.tokenusage/tracker/logs/sync.log`,1 MiB 轮转一代)。
321
+ - 每轮 sync 结束后向服务端上报一条运行记录(时间、触发方式、结果、耗时、上报量),
322
+ 仪表盘新增"采集记录"页;空跑也上报,作为采集器心跳。不想上报可在 init 时
345
323
  `--run-report=off` 关闭。
346
324
  - 正确性修复:zcode 恢复行补齐 billable/cost 字段;含 `|` 的模型名不再破坏
347
325
  用量桶键的往返解析;OpenCode 负 delta 不再产生负计数;`TOKENUSAGE_*`
348
- 环境变量优先于旧 `INSFORGE_*` 名(旧名保留兼容);移除 init 中的死常量。
326
+ 环境变量优先于旧 `INSFORGE_*` 名(旧名保留兼容)。
349
327
 
350
328
  ## 0.1.0
351
329
 
352
- 首个公开发布版本:TokenTracker CLI 采集端 fork,重接到 token-usage 契约
353
- (`docs/cli-contract.md`)。
330
+ 2026-10-24。首个公开发布版本:上游 CLI 采集端 fork,重接到 token-usage 契约。
354
331
 
355
332
  - 设备流配对(`device-login`)、`init`、`sync`(含 `--watch` / `--drain`)、
356
333
  `status`、`sessions`、`doctor`、`diagnostics`、`uninstall`
357
334
  - 会话上传走隐私白名单:只传聚合 token 数字,标题 / 路径 / 正文永不出本机
358
335
  - 上传链路防毒行硬化:契约非法的用量桶 / 账户会话状态在出批前丢弃或修正,
359
- 而不是让 ingest 边缘整批 400、队头永久停摆;Grok ACP 小数计数器解析期取整;
360
- 会话 ID 校验对齐服务端的完整 Unicode Cc 控制字符范围
336
+ 而不是让 ingest 边缘整批 400、队头永久停摆
361
337
  - 请求日志降噪:`node:sqlite` 每次加载都打印的 ExperimentalWarning 不再
362
338
  混入重定向的同步日志
363
339
  - 要求 Node ≥ 22.19(undici 8 的引擎下限;undici 仅用于代理支持)
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # tokenusage-cli
2
2
 
3
- 自托管 AI 编码 token 用量采集器,为 [token-usage](https://github.com/baiwumm/token-usage)(自托管仪表盘)上报数据,指向其契约(`docs/cli-contract.md`)。代码来源与许可见 `LICENSE` 与 `THIRD_PARTY_NOTICES.md`。
3
+ 自托管 AI 编码 token 用量采集器,为 [token-usage](https://github.com/baiwumm/token-usage)(自托管仪表盘)上报数据,指向其契约([CLI 契约](https://github.com/baiwumm/token-usage/blob/main/docs/cli-contract.md))。代码来源与许可见 `LICENSE` 与 `THIRD_PARTY_NOTICES.md`。
4
4
 
5
5
  > 运行要求:Node ≥ 22.19(由上传依赖 undici 8 的引擎下限决定)。
6
6
 
7
7
  ## 快速开始(三步)
8
8
 
9
9
  ```bash
10
- # 1) 初始化:扫描根配置、各工具用量 hook、并注册每小时自动采集的计划任务
10
+ # 1) 初始化:扫描根配置、各工具用量 hook,并注册每小时自动采集的计划任务
11
11
  # (Windows 经 VBS 隐藏窗口运行,不弹黑框;--no-task 可跳过任务注册。增强任务定义
12
12
  # 需要管理员权限,非提升 shell 下会自动降级为普通每小时触发并提示 degraded)
13
13
  tokenusage init
@@ -31,20 +31,17 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
31
31
 
32
32
  | 命令 | 说明 |
33
33
  |---|---|
34
- | `tokenusage init` | 本地初始化:扫描根配置、各工具 hook 安装、注册每小时计划任务(Windows 隐藏窗口)。`--no-task` 跳过任务;`--run-report=off` 关闭运行记录上报;`--integrations <ids,all,none>` 逐工具选择要接管的集成(缺省在交互确认里多选),`--no-integrations` 等于 `none`(只做纯定时采集);`--yes` 非交互;`--dry-run` 只预览不落盘;`--no-open` 不打开浏览器。不含配对 |
34
+ | `tokenusage init` | 本地初始化:扫描根配置、各工具 hook 安装、注册每小时计划任务(Windows 隐藏窗口)、刷新运行时副本。**不含配对** |
35
35
  | `tokenusage device-login` | 设备流配对:输出 `user_code`,在站点 `/device` 页批准后本机拿到设备令牌 |
36
36
  | `tokenusage sync` | 解析本地 AI 工具日志 → 上报小时桶 + 会话元数据 |
37
- | `tokenusage upload` | 只刷本地队列,不扫描来源(`--drain` / `--force` 抬批次上限、`--json` 输出结构化结果) |
38
- | `tokenusage reconcile` | 只读对账:本地 `queue.jsonl` 的 last-wins 基线 vs 云端该设备的桶明细,按 `(hour_start, source, model)` 逐键比对,有漂移退出码 1;尚未上传的桶(`queue.state.json` 偏移之后)记为 pending,不算漂移 |
39
- | `tokenusage sync --watch` | 常驻模式,默认每 15 分钟增量一轮(`--interval <ms>` 可调,≥60000) |
40
- | `tokenusage sync --no-sessions` | 只上报小时桶,跳过会话元数据 |
41
- | `tokenusage sync --drain` | 补传模式:更大的批处理预算,适合首次接入/长期积压 |
42
- | `tokenusage pause` / `resume` | 暂停/恢复自动采集:定时任务、hook、`--watch` 全部静默停手,手动 `sync` 不受影响(同步启停系统的调度项) |
43
- | `tokenusage status` | 本地状态:Base URL、令牌、采集状态、运行上报开关、队列积压、最近解析/上传时间 |
44
- | `tokenusage doctor` | 体检(运行时 / 网络 / 各工具配置),`--json` 输出 |
45
- | `tokenusage diagnostics` | 诊断信息导出 |
46
- | `tokenusage sessions` | 本地导出会话分析(JSON/CSV,元数据级);`--out <file>` 原子写(0600) |
47
- | `tokenusage uninstall [--purge]` | 移除 hook 与计划任务;`--purge` 连数据目录一起删 |
37
+ | `tokenusage upload` | 只刷本地队列,不扫描来源 |
38
+ | `tokenusage reconcile` | 只读对账:本地 `queue.jsonl` 的 last-wins 基线 vs 云端该设备的桶明细,按 `(hour_start, source, model)` 逐键比对,有漂移退出码 1 |
39
+ | `tokenusage pause` / `resume` | 暂停/恢复自动采集:定时任务、hook、`--watch` 全部静默停手,手动 `sync` 不受影响 |
40
+ | `tokenusage status` | 本地状态:Base URL、令牌、设备身份、采集状态、队列积压、最近解析/上传时间 |
41
+ | `tokenusage doctor` | 体检(运行时 / 网络 / 各工具配置),critical 时退出码非 0 |
42
+ | `tokenusage diagnostics` | 诊断信息导出(家目录路径脱敏为 `~`) |
43
+ | `tokenusage sessions` | 本地导出会话分析(JSON/CSV,元数据级) |
44
+ | `tokenusage uninstall [--purge]` | 移除 hook、计划任务与运行时副本;`--purge` 连数据目录一起删(保留机器身份) |
48
45
 
49
46
  配置优先级:CLI 参数 > `~/.tokenusage/.../config.json` > 环境变量(`TOKENUSAGE_BASE_URL` 等)> 内置默认(你的部署地址 + 其公开 publishable key)。
50
47
 
@@ -52,7 +49,63 @@ tokenusage sync --drain # 首次/积压补传(更大的批处理预算)
52
49
  参数写错(未知命令 / 未知参数 / 非法取值)只输出一行 `Error: ...` 加 `Hint:`,退出码
53
50
  `2`;其余运行错误退出码 `1`。要堆栈加 `--debug`。
54
51
 
55
- 只补传积压、不重扫本地日志:
52
+ ### 常用参数
53
+
54
+ <details>
55
+ <summary><code>init</code></summary>
56
+
57
+ | 参数 | 说明 |
58
+ |---|---|
59
+ | `--base-url <url>` | 后端地址(默认托管实例) |
60
+ | `--dashboard-url <url>` | 成功提示里显示的仪表盘地址 |
61
+ | `--anon-key <key>` / `--anon-key-file <path>` | 自托管实例的 publishable key |
62
+ | `--integrations <ids,all,none>` | 逐工具选择要接管的集成;`none` == `--no-integrations`(只做纯定时采集) |
63
+ | `--no-integrations` | 不碰任何工具配置 |
64
+ | `--no-task` | 不注册自动采集计划任务 |
65
+ | `--run-report=on\|off` | 运行记录上报开关(关闭即不再上报心跳) |
66
+ | `--yes` | 非交互 |
67
+ | `--dry-run` | 只预览不落盘 |
68
+ | `--no-open` | 不自动打开浏览器 |
69
+
70
+ 已移除:`--email` / `--password` / `--device-name` / `--link-code` / `--no-auth`(浏览器登录已下线,配对走 `device-login`)。
71
+ </details>
72
+
73
+ <details>
74
+ <summary><code>sync</code></summary>
75
+
76
+ | 参数 | 说明 |
77
+ |---|---|
78
+ | `--watch` / `--interval <ms>` | 常驻模式,默认每 15 分钟一轮(下限 60000) |
79
+ | `--upload-only` | 不扫描来源,只刷队列(等同 `upload`) |
80
+ | `--source <id>` | 只扫单个来源;未知 id 直接报错(不再静默全扫) |
81
+ | `--drain` | 抬批次上限,补传整个积压 |
82
+ | `--no-sessions` | 只上报小时桶,跳过会话元数据 |
83
+ | `--publish-account` | 本地发布账户级来源(cursor / trae-cn) |
84
+ | `--all-local-sources` | 连后台来源一起扫 |
85
+ | `--auto` | 自动档:认暂停标志与云端同步开关 |
86
+ | `--from-notify` / `--from-openclaw` / `--from-retry` / `--from-scheduled` | 触发标记(hook / 计划任务用) |
87
+ | `--wait-for-lock` | 遇并发 sync 等待而不是跳过 |
88
+ | `--background` / `--lightweight` | 精简扫描档 |
89
+ | `--repair-grok` | 从会话快照重建 Grok 行 |
90
+
91
+ 可用 `--source` id 见 `tokenusage sync --help` 的来源清单。
92
+ </details>
93
+
94
+ <details>
95
+ <summary><code>upload</code> / <code>reconcile</code> / <code>status</code> / <code>doctor</code> / <code>diagnostics</code> / <code>sessions</code> / <code>device-login</code></summary>
96
+
97
+ | 命令 | 参数 |
98
+ |---|---|
99
+ | `upload` | `--drain` / `--force`(抬批次上限、忽略冷却)、`--json` |
100
+ | `reconcile` | `--days <n>`(默认 7,上限 366)、`--from` / `--to`(UTC 日历日,裸日期含当天整天)、`--limit <n>`(1–2000)、`--json` |
101
+ | `status` | `--diagnostics`(含路径 / 光标 / WSL·Kiro 探针)、`--json`、`--light`(无 ANSI 的 ASCII 表)、`--limits`(各家配额面板,会读本机凭据并访问厂商 API)、`--no-spinner`、`--probe-keychain` / `--probe-keychain-details`(macOS) |
102
+ | `doctor` | `--json`、`--out <file>`、`--base-url <url>` |
103
+ | `diagnostics` | `--out <file>` |
104
+ | `sessions` | `--from` / `--to`、`--format json\|csv`(或 `--csv`)、`--out <file>`(原子写,0600)、`--refresh`、`--no-git` |
105
+ | `device-login` | `--json`、`--base-url <url>` |
106
+ </details>
107
+
108
+ ### 只补传积压、不重扫本地日志
56
109
 
57
110
  ```bash
58
111
  tokenusage upload # 刷队列(默认最多 5 批,每批 200 条)
@@ -60,7 +113,7 @@ tokenusage upload --drain # 大积压补传(最多 100 批)
60
113
  tokenusage upload --json # 结构化结果,便于脚本消费
61
114
  ```
62
115
 
63
- 对账(只读,不上传、不改队列、不动上传 offset):
116
+ ### 对账(只读,不上传、不改队列、不动上传 offset)
64
117
 
65
118
  ```bash
66
119
  tokenusage reconcile # 最近 7 天
@@ -142,8 +195,7 @@ CLI 未配对也能正常用,只是**降级为“只采集、不上报”**:
142
195
 
143
196
  上报内容只有**聚合用量**:
144
197
 
145
- - 小时桶:每工具每小时六项 token 计数、模型名,以及积分(仅积分制来源上报,
146
- 如 Qoder;独立维度,不参与 token 与成本口径)。
198
+ - 小时桶:每工具每小时六项 token 计数、模型名、项目名(basename),以及积分(仅积分制来源上报,如 Qoder;独立维度,不参与 token 与成本口径)。
147
199
  - 会话元数据:`session_id`(厂商会话 UUID,或无 UUID 来源的本地稳定指纹)、来源、起止时间、项目 basename、token 拆分、每模型用量、积分(仅积分制来源)。
148
200
 
149
201
  **永不上传**:prompt / 助手正文 / 工具参数 / 命令输出 / diff / 会话标题 / 本地绝对路径 / resume 命令。测试(`test/session-upload.test.js`)用字段白名单锁定该边界。
@@ -152,7 +204,20 @@ CLI 不发送匿名安装心跳,也不做任何第三方错误上报:上游
152
204
 
153
205
  ## 数据目录
154
206
 
155
- `~/.tokenusage/`(`0700` 目录 + `0600` 文件):`tracker/config.json`(配对与运行配置)、`tracker/app/`(自包含运行时副本,`.runtime-ready` 记录版本)、上传队列(`queue.jsonl` + offset)、会话分析 sidecar、`session-upload-watermarks.json`(增量水位)、`tracker/logs/sync.log`(自动采集滚动日志)、暂停标志。与旧版 tokentracker CLI 的 `~/.tokentracker/` 互不干扰,迁移期两套 CLI 可在同一台机器共存。
207
+ `~/.tokenusage/`(`0700` 目录 + `0600` 文件):
208
+
209
+ | 文件 | 用途 |
210
+ |---|---|
211
+ | `tracker/config.json` | 配对与运行配置(base URL、设备令牌、机器 id) |
212
+ | `tracker/app/` | 自包含运行时副本(`.runtime-ready` 记录版本) |
213
+ | `tracker/queue.jsonl` / `queue.state.json` | 上传队列与上传 offset(对账基线) |
214
+ | `tracker/project.queue.jsonl` | 项目级队列(`project_key` 分桶) |
215
+ | `tracker/cursors.json` | 各来源增量光标 |
216
+ | `tracker/session-upload-watermarks.json` | 会话上报增量水位 |
217
+ | `tracker/upload.throttle.json` | 上传节流状态 |
218
+ | `tracker/logs/sync.log` | 自动采集滚动日志(JSONL) |
219
+
220
+ 暂停标志另存。与旧版 tokentracker CLI 的 `~/.tokentracker/` 互不干扰,迁移期两套 CLI 可在同一台机器共存。
156
221
 
157
222
  ## 自包含运行时副本(0.2.4+)
158
223
 
@@ -170,7 +235,9 @@ init 会把当前 CLI 及其依赖闭包复制到 `~/.tokenusage/tracker/app`,
170
235
 
171
236
  ## provider 支持面
172
237
 
173
- 解析器随上游全量保留(仅未配置对应工具时休眠不扫描):claude、codex、zcode、opencode、cursor、trae / trae-cn、grok、kimi、gemini、qoder、antigravity、openclaw 等。操作者实际启用面以 `tokenusage status` 为准;未使用的解析器不产生任何上传。
238
+ 解析器随上游全量保留(仅未配置对应工具时休眠不扫描)。**完整来源清单以
239
+ `tokenusage sync --help` 为准**(当前 46 个本地来源 + 5 个后台来源);操作者实际启用面
240
+ 以 `tokenusage status` 为准,未使用的解析器不产生任何上传。
174
241
 
175
242
  注:`cursor` / `trae-cn` 为账户级来源,会话元数据不会为其上传(服务端契约亦整段跳过)。
176
243
 
@@ -182,4 +249,4 @@ pnpm --filter tokenusage-cli test
182
249
  ```
183
250
 
184
251
  发布走仓库的 `cli-v*` tag 触发的 GitHub Actions(Trusted Publishing,见
185
- `docs/cli-release.md`)。
252
+ [CLI 发版手册](https://github.com/baiwumm/token-usage/blob/main/docs/cli-release.md))。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenusage-cli",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Self-hosted AI coding token usage collector for the Token Usage dashboard.",
5
5
  "keywords": [
6
6
  "token-usage",
package/src/cli.js CHANGED
@@ -53,6 +53,7 @@ const COMMANDS = [
53
53
  " --run-report=on|off Persist the per-run telemetry preference (§2.11)",
54
54
  " --yes Skip the interactive confirmation",
55
55
  " --dry-run Preview without writing anything",
56
+ " --no-open Do not open a browser window on success",
56
57
  ],
57
58
  notes: [
58
59
  "The hourly schedule uses Task Scheduler on Windows, launchd on macOS and a",
@@ -6,6 +6,7 @@ const { resolveTrackerPaths } = require("../lib/tracker-paths");
6
6
  const { collectTrackerDiagnostics } = require("../lib/diagnostics");
7
7
  const { resolveRuntimeConfig } = require("../lib/runtime-config");
8
8
  const { resolveDeviceTokenPresence } = require("../lib/cloud-device-token");
9
+ const { resolveLocalDeviceIdentity } = require("../lib/device-identity");
9
10
  const { buildDoctorReport } = require("../lib/doctor");
10
11
 
11
12
  async function cmdDoctor(argv = []) {
@@ -37,11 +38,13 @@ async function cmdDoctor(argv = []) {
37
38
  }
38
39
  const diagnostics = await collectTrackerDiagnostics({ home });
39
40
  const cliPath = process.argv[1] ? path.resolve(process.argv[1]) : null;
41
+ const deviceIdentity = resolveLocalDeviceIdentity({ config, home });
40
42
 
41
43
  const report = await buildDoctorReport({
42
44
  runtime,
43
45
  diagnostics,
44
46
  fetch: globalThis.fetch,
47
+ deviceIdentity,
45
48
  paths: {
46
49
  trackerDir,
47
50
  configPath,
@@ -104,6 +104,7 @@ const {
104
104
  } = require("../lib/cli-ui");
105
105
  const { renderLocalReport, renderAuthTransition, renderSuccessBox } = require("../lib/init-flow");
106
106
  const { maybeShowStarCta } = require("../lib/star-cta");
107
+ const { buildDeviceIdentity } = require("../lib/device-identity");
107
108
 
108
109
  const ASCII_LOGO = [
109
110
  "████████╗ ██████╗ ██╗ ██╗███████╗███╗ ██╗",
@@ -368,7 +369,14 @@ async function cmdInit(argv, options = {}) {
368
369
  ahaSpinner.stop();
369
370
  }
370
371
 
371
- renderLocalSuccess({ firstSync, dashboardUrl: runtime.dashboardUrl || DEFAULT_DASHBOARD_URL });
372
+ renderLocalSuccess({
373
+ firstSync,
374
+ dashboardUrl: runtime.dashboardUrl || DEFAULT_DASHBOARD_URL,
375
+ deviceIdentity: buildDeviceIdentity({
376
+ config: existingConfig && typeof existingConfig === "object" ? existingConfig : {},
377
+ hostname: os.hostname(),
378
+ }),
379
+ });
372
380
  await maybeShowStarCta({ trackerDir });
373
381
  }
374
382
 
@@ -397,7 +405,7 @@ function renderWelcome(dashboardUrl = DEFAULT_DASHBOARD_URL) {
397
405
  );
398
406
  }
399
407
 
400
- function renderLocalSuccess({ firstSync, dashboardUrl = DEFAULT_DASHBOARD_URL } = {}) {
408
+ function renderLocalSuccess({ firstSync, dashboardUrl = DEFAULT_DASHBOARD_URL, deviceIdentity = null } = {}) {
401
409
  const lines = ["", `${BOLD}Setup complete!${RESET}`, ""];
402
410
 
403
411
  if (firstSync && firstSync.totalTokens > 0) {
@@ -413,6 +421,16 @@ function renderLocalSuccess({ firstSync, dashboardUrl = DEFAULT_DASHBOARD_URL }
413
421
  );
414
422
  }
415
423
 
424
+ // Which machine was just set up — one account can have several collectors,
425
+ // and the setup output gets pasted into runbooks.
426
+ if (deviceIdentity) {
427
+ lines.push(
428
+ ` Device: ${deviceIdentity.name}${
429
+ deviceIdentity.device_id ? ` (id ${deviceIdentity.device_id})` : " (not paired)"
430
+ }`,
431
+ );
432
+ }
433
+
416
434
  lines.push(
417
435
  "",
418
436
  ` Dashboard: ${CYAN}${dashboardUrl}${RESET}`,
@@ -43,6 +43,7 @@ const { sanitizeBucketForUpload } = require("../lib/ingest-sanitize");
43
43
  const { basenameKey } = require("../lib/project-key");
44
44
  const { TOKEN_COLUMNS } = require("../lib/account-usage-dedup");
45
45
  const { UsageError, unknownOptionError } = require("../lib/cli-errors");
46
+ const { buildDeviceIdentity } = require("../lib/device-identity");
46
47
 
47
48
  const RECONCILE_SLUG = "token-usage-reconcile";
48
49
  const DAY_MS = 86_400_000;
@@ -440,6 +441,7 @@ function renderText(summary) {
440
441
  pendingCount > 0
441
442
  ? ` ${pendingCount.toLocaleString("en-US")} of them are past the upload offset (queue.state.json) and not compared yet`
442
443
  : null,
444
+ `Local device: ${summary.device_name || "unknown machine"}${summary.machine_id ? ` (machine ${summary.machine_id.slice(0, 8)})` : ""}`,
443
445
  `Cloud device: ${summary.device_id || "unknown"} — ${summary.cloud_buckets.toLocaleString("en-US")} row(s) in ${summary.pages} page(s)`,
444
446
  ].filter(Boolean);
445
447
 
@@ -506,6 +508,7 @@ async function cmdReconcile(argv = [], options = {}) {
506
508
 
507
509
  const config = (await readJson(path.join(trackerDir, "config.json"))) || {};
508
510
  const runtime = assertInsforgeRuntime(resolveRuntimeConfig({ config, env: process.env }));
511
+ const deviceIdentity = buildDeviceIdentity({ config, hostname: os.hostname() });
509
512
  if (!runtime.deviceToken) {
510
513
  throw new UsageError("This machine is not paired with a dashboard yet.", {
511
514
  code: "NO_DEVICE_TOKEN",
@@ -542,6 +545,8 @@ async function cmdReconcile(argv = [], options = {}) {
542
545
  to,
543
546
  clamped: window.clamped,
544
547
  device_id: deviceId,
548
+ device_name: deviceIdentity.name,
549
+ machine_id: deviceIdentity.machine_id,
545
550
  local_buckets: local.size,
546
551
  cloud_buckets: server.size,
547
552
  pages,
@@ -49,6 +49,8 @@ const {
49
49
  } = require("../lib/openclaw-session-plugin");
50
50
  const { resolveTrackerPaths } = require("../lib/tracker-paths");
51
51
  const { resolveDeviceTokenPresence } = require("../lib/cloud-device-token");
52
+ const { resolveLocalDeviceIdentity } = require("../lib/device-identity");
53
+ const { formatDeviceLine } = require("../lib/progress");
52
54
  const { getPricingMeta } = require("../lib/pricing");
53
55
  const {
54
56
  isCollectionPaused,
@@ -1073,12 +1075,22 @@ async function cmdStatus(argv = []) {
1073
1075
  config: config || {},
1074
1076
  });
1075
1077
 
1078
+ // Which collector machine is this? Two machines report into one account, so
1079
+ // every status output has to name itself — see lib/device-identity.js.
1080
+ const deviceIdentity = resolveLocalDeviceIdentity({ config: config || {}, home });
1081
+
1076
1082
  if (opts.json || opts.light) {
1077
1083
  const summary = {
1078
1084
  version: pkg.version,
1079
1085
  generated_at: new Date().toISOString(),
1080
1086
  base_url: config?.baseUrl || null,
1081
1087
  device_token_set: deviceTokenPresence.set,
1088
+ device: {
1089
+ name: deviceIdentity.name,
1090
+ hostname: deviceIdentity.hostname,
1091
+ machine_id: deviceIdentity.machine_id,
1092
+ device_id: deviceIdentity.device_id,
1093
+ },
1082
1094
  queue: {
1083
1095
  pending_bytes: pendingBytes,
1084
1096
  size_bytes: queueSize,
@@ -1316,6 +1328,7 @@ async function cmdStatus(argv = []) {
1316
1328
  "Status:",
1317
1329
  `- Base URL: ${config?.baseUrl || "unset"}`,
1318
1330
  `- Device token: ${deviceTokenPresence.set ? "set" : "unset"}`,
1331
+ formatDeviceLine(deviceIdentity),
1319
1332
  collectionPaused
1320
1333
  ? "- Collection: PAUSED (auto/notify/watch syncs skip; manual sync runs; `tokenusage resume` to re-enable)"
1321
1334
  : "- Collection: active",
@@ -1751,6 +1764,8 @@ function renderLightTable(summary) {
1751
1764
  push("Version", summary.version);
1752
1765
  push("Base URL", summary.base_url);
1753
1766
  push("Device token", summary.device_token_set ? "set" : "unset");
1767
+ push("Device", summary.device?.name);
1768
+ push("Device ID", summary.device?.device_id);
1754
1769
  push("Queue pending (bytes)", summary.queue.pending_bytes);
1755
1770
  push("Queue size (bytes)", summary.queue.size_bytes);
1756
1771
  push("Last parse", summary.last_parse);
@@ -1887,5 +1902,6 @@ module.exports = {
1887
1902
  cmdStatus,
1888
1903
  formatUsageLimitRows,
1889
1904
  parseArgs,
1905
+ renderLightTable,
1890
1906
  summarizeQoderDetail,
1891
1907
  };
@@ -158,7 +158,8 @@ const {
158
158
  resolveZcodeInstallPaths,
159
159
  } = require("../lib/rollout");
160
160
  const { computeClaudeGroundTruthBuckets } = require("../lib/claude-categorizer");
161
- const { createProgress, renderBar, formatNumber, formatBytes } = require("../lib/progress");
161
+ const { createProgress, renderBar, formatNumber, formatBytes, formatDuration, formatDeviceLine } = require("../lib/progress");
162
+ const { buildDeviceIdentity } = require("../lib/device-identity");
162
163
  const {
163
164
  DEFAULTS: AUTO_UPLOAD_DEFAULTS,
164
165
  normalizeState: normalizeUploadState,
@@ -572,6 +573,58 @@ async function clearSyncSkip(trackerDir) {
572
573
  }
573
574
  }
574
575
 
576
+ /**
577
+ * The human summary of one sync run.
578
+ *
579
+ * Pure on purpose: the summary is what ends up pasted into runbooks and issue
580
+ * trackers, so it has to state WHICH machine ran, how much was uploaded (in
581
+ * tokens, not just rows), how many sessions moved, what is still pending and
582
+ * how long it took. Extracted from cmdSync so it can be unit-tested.
583
+ */
584
+ function buildSyncSummaryLines({
585
+ deviceIdentity = null,
586
+ totalParsed = 0,
587
+ totalBuckets = 0,
588
+ uploadResult = {},
589
+ sessionUploadSummary = null,
590
+ hasDeviceToken = false,
591
+ pendingBytes = 0,
592
+ drain = false,
593
+ durationMs = 0,
594
+ uploadError = null,
595
+ warning = null,
596
+ } = {}) {
597
+ const uploadedTokens = Number(uploadResult.tokens || 0);
598
+ const uploadedCredits = Number(uploadResult.credits || 0);
599
+ const inserted = Number(uploadResult.inserted || 0);
600
+ const rowWord = inserted === 1 ? "row" : "rows";
601
+ const lines = ["Sync finished:"];
602
+ if (deviceIdentity) lines.push(formatDeviceLine(deviceIdentity));
603
+ lines.push(
604
+ `- Parsed files: ${formatNumber(totalParsed)}`,
605
+ `- New 30-min buckets queued: ${formatNumber(totalBuckets)}`,
606
+ hasDeviceToken
607
+ ? `- Uploaded: ${formatNumber(inserted)} ${rowWord} (${formatNumber(uploadedTokens)} tokens), ${formatNumber(uploadResult.skipped)} skipped`
608
+ : "- Uploaded: skipped (no device token)",
609
+ );
610
+ if (hasDeviceToken && uploadedCredits > 0) {
611
+ lines.push(`- Credits: ${formatNumber(uploadedCredits)}`);
612
+ }
613
+ if (sessionUploadSummary) {
614
+ lines.push(
615
+ `- Sessions: ${formatNumber(sessionUploadSummary.uploaded)}/${formatNumber(sessionUploadSummary.pending)} uploaded (upserted ${formatNumber(sessionUploadSummary.upserted)}, skipped ${formatNumber(sessionUploadSummary.skipped)})`,
616
+ );
617
+ }
618
+ if (hasDeviceToken && pendingBytes > 0 && !drain) {
619
+ lines.push(`- Remaining: ${formatBytes(pendingBytes)} pending (run sync again, or use --drain)`);
620
+ }
621
+ lines.push(`- Duration: ${formatDuration(durationMs)}`);
622
+ if (uploadError) lines.push(`- Upload error: ${uploadError.message || uploadError}`);
623
+ if (warning) lines.push(`- Warning: ${warning}`);
624
+ lines.push("");
625
+ return lines;
626
+ }
627
+
575
628
  async function cmdSync(argv, context = {}) {
576
629
  context = context && typeof context === "object" ? context : {};
577
630
  const opts = parseArgs(argv);
@@ -597,6 +650,8 @@ async function cmdSync(argv, context = {}) {
597
650
  const syncDiagnostics = diagnostics && typeof diagnostics === "object" ? diagnostics : null;
598
651
  const home = context.home || os.homedir();
599
652
  const trackerDir = context.trackerDataDir || (await resolveTrackerPaths({ home })).trackerDir;
653
+ // Wall clock for the run summary (the §2.11 run record keeps its own).
654
+ const syncStartedAtMs = Date.now();
600
655
  // Collection pause (0.2.0): auto-flavored runs exit silently — no lock, no
601
656
  // log line, no run record. A manual sync is the user's explicit request
602
657
  // and runs regardless of the flag.
@@ -3641,6 +3696,9 @@ async function cmdSync(argv, context = {}) {
3641
3696
  let uploadAttempted = false;
3642
3697
  let uploadError = null;
3643
3698
  let autoUploadDecision = null;
3699
+ // Session upload counters, folded into the final summary instead of being
3700
+ // printed on their own line before it.
3701
+ let sessionUploadSummary = null;
3644
3702
 
3645
3703
  if (canUpload() && (opts.auto || opts.publishAccount) && runtime.deviceToken && runtime.baseUrl &&
3646
3704
  (!isBackgroundLightweightSync || opts.publishAccount)) {
@@ -3831,17 +3889,21 @@ async function cmdSync(argv, context = {}) {
3831
3889
  canUpload,
3832
3890
  });
3833
3891
  if (result.pending > 0) {
3834
- const sessionSuffix =
3835
- result.upserted || result.skippedServer
3836
- ? ` (upserted ${result.upserted}, skipped ${result.skippedServer})`
3837
- : "";
3838
- const sessionLine =
3839
- `Sessions: ${result.uploaded}/${result.pending} uploaded${sessionSuffix}`;
3840
-
3841
- if (!opts.auto) {
3842
- process.stdout.write(`${sessionLine}\n`);
3843
- } else {
3844
- autoLog(sessionLine);
3892
+ sessionUploadSummary = {
3893
+ uploaded: result.uploaded,
3894
+ pending: result.pending,
3895
+ upserted: result.upserted,
3896
+ skipped: (result.skippedServer || 0) + (result.skippedLocal || 0),
3897
+ };
3898
+ // Auto runs keep the rolling log line; a manual run reports the same
3899
+ // counters inside the final summary block (printing here would put
3900
+ // the sessions line above the summary it belongs to).
3901
+ if (opts.auto) {
3902
+ const sessionSuffix =
3903
+ result.upserted || result.skippedServer
3904
+ ? ` (upserted ${result.upserted}, skipped ${result.skippedServer})`
3905
+ : "";
3906
+ autoLog(`Sessions: ${result.uploaded}/${result.pending} uploaded${sessionSuffix}`);
3845
3907
  }
3846
3908
  }
3847
3909
  syncRun?.noteSessions({
@@ -3904,28 +3966,28 @@ async function cmdSync(argv, context = {}) {
3904
3966
 
3905
3967
  if (!autoishSync) {
3906
3968
  const codexRecordOnlyWarning = formatRecordOnlyWarning(countRecordOnlyFiles(cursors));
3969
+ const deviceIdentity = buildDeviceIdentity({ config: runtimeConfig, hostname: os.hostname() });
3907
3970
  process.stdout.write(
3908
- [
3909
- "Sync finished:",
3910
- `- Parsed files: ${totalParsed}`,
3911
- `- New 30-min buckets queued: ${totalBuckets}`,
3912
- runtime.deviceToken
3913
- ? `- Uploaded: ${uploadResult.inserted} inserted, ${uploadResult.skipped} skipped`
3914
- : "- Uploaded: skipped (no device token)",
3915
- runtime.deviceToken && pendingBytes > 0 && !opts.drain
3916
- ? `- Remaining: ${formatBytes(pendingBytes)} pending (run sync again, or use --drain)`
3917
- : null,
3918
- codexRecordOnlyWarning ? `- Warning: ${codexRecordOnlyWarning}` : null,
3919
- "",
3920
- ]
3921
- .filter(Boolean)
3922
- .join("\n"),
3971
+ buildSyncSummaryLines({
3972
+ deviceIdentity,
3973
+ totalParsed,
3974
+ totalBuckets,
3975
+ uploadResult,
3976
+ sessionUploadSummary,
3977
+ hasDeviceToken: Boolean(runtime.deviceToken),
3978
+ pendingBytes,
3979
+ drain: Boolean(opts.drain),
3980
+ durationMs: Date.now() - syncStartedAtMs,
3981
+ uploadError,
3982
+ warning: codexRecordOnlyWarning,
3983
+ }).join("\n"),
3923
3984
  );
3924
3985
  } else {
3925
3986
  autoLog(
3926
3987
  `Auto sync finished — parsed ${totalParsed} files, +${totalBuckets} buckets, ` +
3927
3988
  (runtime.deviceToken
3928
3989
  ? `uploaded ${uploadResult.inserted}, skipped ${uploadResult.skipped}` +
3990
+ `, ${uploadResult.tokens || 0} tokens` +
3929
3991
  (pendingBytes > 0 ? `, pending ${formatBytes(pendingBytes)}` : ", queue drained")
3930
3992
  : "upload skipped (no device token)"),
3931
3993
  {
@@ -3934,7 +3996,12 @@ async function cmdSync(argv, context = {}) {
3934
3996
  buckets: totalBuckets,
3935
3997
  inserted: uploadResult.inserted,
3936
3998
  skipped: uploadResult.skipped,
3999
+ tokens: uploadResult.tokens || 0,
4000
+ credits: uploadResult.credits || 0,
4001
+ sessions_uploaded: sessionUploadSummary ? sessionUploadSummary.uploaded : 0,
4002
+ sessions_skipped: sessionUploadSummary ? sessionUploadSummary.skipped : 0,
3937
4003
  pending_bytes: pendingBytes,
4004
+ duration_ms: Date.now() - syncStartedAtMs,
3938
4005
  uploaded: Boolean(runtime.deviceToken),
3939
4006
  },
3940
4007
  );
@@ -4112,6 +4179,7 @@ function recordCodexColdScanAudit(
4112
4179
  module.exports = {
4113
4180
  cmdSync,
4114
4181
  acquireSyncLock,
4182
+ buildSyncSummaryLines,
4115
4183
  readQueueBatch,
4116
4184
  drainQueueToCloud,
4117
4185
  normalizeSyncSource,
@@ -18,6 +18,8 @@ const path = require("node:path");
18
18
  const fs = require("node:fs/promises");
19
19
 
20
20
  const { resolveTrackerPaths } = require("../lib/tracker-paths");
21
+ const { formatDeviceLine } = require("../lib/progress");
22
+ const { buildDeviceIdentity } = require("../lib/device-identity");
21
23
  const { readJson } = require("../lib/fs");
22
24
  const { cloudUsageResetBlocksUpload } = require("../lib/cloud-usage-reset");
23
25
  const { compactPendingQueue } = require("../lib/upload-queue");
@@ -134,9 +136,11 @@ async function cmdUpload(argv, options = {}) {
134
136
  process.stdout.write(
135
137
  [
136
138
  "Upload complete.",
139
+ formatDeviceLine(buildDeviceIdentity({ config, hostname: os.hostname() })),
137
140
  `- Requests: ${result.batches}`,
138
141
  `- Rows inserted: ${result.inserted.toLocaleString("en-US")} (skipped ${result.skipped.toLocaleString("en-US")})`,
139
142
  `- Tokens in this upload: ${result.tokens.toLocaleString("en-US")}`,
143
+ result.credits > 0 ? `- Credits in this upload: ${result.credits.toLocaleString("en-US")}` : null,
140
144
  `- Pending bytes: ${beforeBytes} → ${afterBytes}`,
141
145
  afterBytes > 0 ? "- Backlog remains; run `tokenusage upload --drain` or retry later." : null,
142
146
  "",
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ const fs = require("node:fs");
4
+ const os = require("node:os");
5
+ const path = require("node:path");
6
+
7
+ // Hostname fallback — the contract (§2.2) uses this when client_info carries
8
+ // no hostname, so the cloud device name stays `<host> #<machine_id[:8]>`.
9
+ const FALLBACK_DEVICE_NAME = "Token Usage CLI";
10
+
11
+ function trimmedString(value) {
12
+ return typeof value === "string" && value.trim() ? value.trim() : "";
13
+ }
14
+
15
+ function readSeedMachineId(seedPath) {
16
+ try {
17
+ return trimmedString(fs.readFileSync(seedPath, "utf8"));
18
+ } catch {
19
+ return "";
20
+ }
21
+ }
22
+
23
+ function defaultSeedPath(home = os.homedir()) {
24
+ return path.join(home, ".config", "tokenusage", "machine-id");
25
+ }
26
+
27
+ /**
28
+ * This machine's cloud device identity.
29
+ *
30
+ * The device name is defined by docs/cli-contract.md §2.2:
31
+ * `<client_info hostname> #<machine_id first 8 chars>`
32
+ * — client_info without a hostname falls back to "Token Usage CLI", a missing
33
+ * machine_id drops the suffix. The cloud derives it the same way from the
34
+ * `client_info` / `machine_id` the CLI sends at device-flow time, so the name
35
+ * computed here matches the dashboard's device card byte for byte.
36
+ *
37
+ * Why the CLI bothers to print it: two collector machines report into one
38
+ * account, and `status` output is what gets pasted into issue trackers and
39
+ * release checklists. Without the identity in the output, a reader cannot tell
40
+ * which machine produced a number — that is how "this machine" and "the other
41
+ * machine" got mixed up in the docs.
42
+ *
43
+ * Read-only on purpose: unlike getOrCreateMachineId() this never mints or
44
+ * persists an id, so `status` stays a safe command to run anywhere.
45
+ */
46
+ function buildDeviceIdentity({
47
+ config = {},
48
+ hostname = os.hostname(),
49
+ seedPath = null,
50
+ home = os.homedir(),
51
+ } = {}) {
52
+ const machineId =
53
+ trimmedString(config.machineId) || (seedPath ? readSeedMachineId(seedPath) : "");
54
+ const deviceId = trimmedString(config.deviceId);
55
+ const host = trimmedString(hostname) || FALLBACK_DEVICE_NAME;
56
+ const suffix = machineId ? machineId.slice(0, 8) : "";
57
+
58
+ return {
59
+ name: suffix ? `${host} #${suffix}` : host,
60
+ hostname: host,
61
+ machine_id: machineId || null,
62
+ device_id: deviceId || null,
63
+ };
64
+ }
65
+
66
+ /**
67
+ * Identity of the machine this CLI runs on, reading the tracker config plus
68
+ * the purge-surviving identity seed (so `status` still names the device after
69
+ * a `uninstall --purge` wiped ~/.tokenusage).
70
+ */
71
+ function resolveLocalDeviceIdentity({ config = {}, home = os.homedir() } = {}) {
72
+ return buildDeviceIdentity({
73
+ config,
74
+ hostname: os.hostname(),
75
+ seedPath: defaultSeedPath(home),
76
+ home,
77
+ });
78
+ }
79
+
80
+ module.exports = {
81
+ FALLBACK_DEVICE_NAME,
82
+ buildDeviceIdentity,
83
+ resolveLocalDeviceIdentity,
84
+ };
package/src/lib/doctor.js CHANGED
@@ -10,11 +10,13 @@ async function buildDoctorReport({
10
10
  diagnostics = null,
11
11
  fetch = globalThis.fetch,
12
12
  now = () => new Date(),
13
+ deviceIdentity = null,
13
14
  paths = {},
14
15
  } = {}) {
15
16
  const checks = [];
16
17
 
17
18
  checks.push(...buildRuntimeChecks(runtime));
19
+ checks.push(...buildDeviceIdentityChecks(deviceIdentity));
18
20
 
19
21
  if (paths.trackerDir) {
20
22
  checks.push(await checkTrackerDir(paths.trackerDir));
@@ -131,6 +133,34 @@ function buildRuntimeChecks(runtime = {}) {
131
133
  return checks;
132
134
  }
133
135
 
136
+ /**
137
+ * Which collector machine is this? The account has two of them, and every
138
+ * doctor report gets pasted into release checklists — without the device
139
+ * identity in the report, a reader cannot tell the two apart.
140
+ */
141
+ function buildDeviceIdentityChecks(deviceIdentity) {
142
+ const checks = [];
143
+ if (!deviceIdentity) return checks;
144
+
145
+ const machineId = deviceIdentity.machine_id || null;
146
+ checks.push({
147
+ id: "runtime.device_identity",
148
+ status: machineId ? "ok" : "warn",
149
+ detail: machineId
150
+ ? `device ${deviceIdentity.name} (id ${deviceIdentity.device_id || "unpaired"})`
151
+ : `device ${deviceIdentity.name} (machine_id missing)`,
152
+ critical: false,
153
+ meta: {
154
+ name: deviceIdentity.name || null,
155
+ hostname: deviceIdentity.hostname || null,
156
+ machine_id: machineId,
157
+ device_id: deviceIdentity.device_id || null,
158
+ },
159
+ });
160
+
161
+ return checks;
162
+ }
163
+
134
164
  async function checkTrackerDir(trackerDir) {
135
165
  try {
136
166
  const st = await fs.stat(trackerDir);
@@ -180,7 +210,7 @@ async function checkTrackerDir(trackerDir) {
180
210
  }
181
211
  }
182
212
 
183
- // B3 (docs/upstream-comparison-plan.md §2): pricing coverage of the local
213
+ // B3 (docs/archive/upstream-2026-11-03.md): pricing coverage of the local
184
214
  // last-wins queue over the trailing 7 days, plus the C2 unknown-alignment
185
215
  // dry-run preview. Informational only — never critical, never writes.
186
216
  async function checkPricingCoverage(trackerDir) {
@@ -502,4 +532,4 @@ function summarizeChecks(checks = []) {
502
532
  return summary;
503
533
  }
504
534
 
505
- module.exports = { buildDoctorReport };
535
+ module.exports = { buildDoctorReport, buildDeviceIdentityChecks };
@@ -113,7 +113,7 @@ function getPricingRevision() {
113
113
 
114
114
  // Read-only snapshot of where pricing data came from and how stale it is.
115
115
  // Surfaced by `status --json` so a $0 cost can be triaged as "not collected"
116
- // vs "not priced" without digging into cache files (docs/upstream-comparison-plan.md §1 A3).
116
+ // vs "not priced" without digging into cache files (docs/archive/upstream-2026-11-03.md A3).
117
117
  function getPricingMeta() {
118
118
  return {
119
119
  source: state.source,
@@ -2,7 +2,7 @@
2
2
 
3
3
  // Read-only pricing-coverage and unknown-model alignment analysis over the
4
4
  // local last-wins queue baseline (queue.jsonl). Used by `doctor`
5
- // (docs/upstream-comparison-plan.md §2 B3 + §3 C2 dry-run). This module never
5
+ // (docs/archive/upstream-2026-11-03.md B3 + §3 C2 dry-run). This module never
6
6
  // writes anything; the alignment preview is a dry-run projection only and does
7
7
  // NOT change any bucket's stored or displayed model.
8
8
 
@@ -68,9 +68,38 @@ function formatBytes(bytes) {
68
68
  return `${fixed} ${units[i]}`;
69
69
  }
70
70
 
71
+ function formatDuration(ms) {
72
+ const n = Number(ms);
73
+ if (!Number.isFinite(n) || n < 0) return "0s";
74
+ if (n < 1) return "0s";
75
+ if (n < 1000) return `${Math.round(n)}ms`;
76
+ const seconds = n / 1000;
77
+ if (seconds < 60) return `${seconds.toFixed(seconds < 10 ? 1 : 0)}s`;
78
+ const minutes = Math.floor(seconds / 60);
79
+ if (minutes < 60) return `${minutes}m ${String(Math.round(seconds - minutes * 60)).padStart(2, "0")}s`;
80
+ const hours = Math.floor(minutes / 60);
81
+ return `${hours}h ${String(minutes - hours * 60).padStart(2, "0")}m`;
82
+ }
83
+
84
+ /**
85
+ * The one line that says which collector machine produced this output.
86
+ *
87
+ * One account has two collector machines, and command output gets pasted into
88
+ * release checklists and issue trackers. Without the identity, "the machine"
89
+ * is ambiguous — the device name is the cloud's own name for it
90
+ * (docs/cli-contract.md §2.2), so it matches the dashboard device card.
91
+ */
92
+ function formatDeviceLine(identity, { label = "Device", indent = "- " } = {}) {
93
+ const name = identity?.name || "unknown machine";
94
+ const id = identity?.device_id;
95
+ return `${indent}${label}: ${name}${id ? ` (id ${id})` : " (not paired)"}`;
96
+ }
97
+
71
98
  module.exports = {
72
99
  createProgress,
73
100
  renderBar,
74
101
  formatNumber,
75
102
  formatBytes,
103
+ formatDuration,
104
+ formatDeviceLine,
76
105
  };