dsh-ws-recency 0.28.0 → 0.29.1
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/README.md +10 -7
- package/client.js +291 -89
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,12 +96,15 @@ DSH 原生的置顶只把会话顶到**它所属工作区分组的第一行**,
|
|
|
96
96
|
会话下方统计条上的「用量分析」,或会话「…」菜单 →「Token 消耗统计」:
|
|
97
97
|
|
|
98
98
|
- **真实账单**(每步记录的 usage):步数、输入(未缓存)、缓存命中、输出、合计;
|
|
99
|
-
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs
|
|
100
|
-
- **参数 /
|
|
101
|
-
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
99
|
+
- **消耗分布图**(按内容估算):主 agent 自己(思考 / 回复 / 用户消息 / 系统提示)vs 每个工具,每个来源一条横条,按占用长度直观对比。**颜色表示工具族**(命令执行 / 文件操作 / 网络检索 / 子代理 / 其它),每族一个固定色、明艳度不随排名变化,工具名下方有族名小字,图上也有族图例;
|
|
100
|
+
- **参数 / 结果两段**:每个工具那条横条拆成「参数」(浅段,模型自己写的命令 / 文件内容)和「结果」(深段,环境返回的内容),一眼看出贵在输入还是贵在输出。图例在图右上角,悬停柱子也会给出具体拆分;
|
|
101
|
+
- **「参数计入主 agent」开关**(设置 → 通用):工具参数严格说是模型写的,不属于工具消耗。打开后每个工具只算返回结果,参数量并入主 agent——实测一个 pwsh 偏重的会话,pwsh 从 37.6% 掉到约 20%,主 agent 从 40.4% 升到约 58%;
|
|
102
|
+
- **调用次数**:每条横条右侧带「N 次」;图表有一行列头(token / 占比 / 调用)对齐五列;
|
|
103
|
+
- **摘要卡片**:合计(高亮)+ 步数 + 输入(未缓存)+ 缓存命中 + 输出,合计排第一;
|
|
104
|
+
- **两个 tab**:摘要卡片常驻顶部,下面按「分布统计 / 放大归因」分页,打开时记住上次停留的 tab;
|
|
105
|
+
- **放大成本 / 账单归因(0.25.0)**:账单 = 每步上下文之和,所以一块内容的真实成本不是它出现时的 token 数,而是「token × 之后还会被重读多少步」。放大归因页给出:每步上下文曲线(面积≈账单)、账单构成(工具结果 / 工具参数 / 主 agent / 用户 / 系统)、以及按内容块排序的放大排行——进入第几步、原始 token、重读次数、放大后 token、占整场账单的百分比。单次 9k 的 read 在 350 步的会话里会放大成 300 万 token(约 3% 账单),这样小数字才能读出结论。压缩之后旧内容不再重读,放大窗口会从压缩点截断。曲线上的琥珀点标出上下文**涨得最陡的三步**(悬停点或下方那一行,两边一起高亮),下面附一行「第 N 步上下文涨了 X(read 进来 Y)」——「哪一步开始放大」一眼就能看到,不用自己比 96 根柱子。
|
|
106
|
+
|
|
107
|
+
面板底部只有一条口径说明(原来两个 tab 各有一条相同的话)。
|
|
105
108
|
|
|
106
109
|
口径说明:prompt 的 token 是「整段上下文每一步都计费」,没法精确归属到某一条消息,所以「主 agent / 工具」的拆分是按内容长度估算(中文≈1 token/字,英文≈4 字符/token),用来比较占比;**总量是真的**。放大排行里的块大小同样是估算,但账单总量、每步上下文、放大倍数的分母都来自真实 usage。思维链通常不回传给模型,因此不计入放大排行。数据从会话日志算,跨重启也能看。大会话第一次打开约 1–2 秒(29MB 日志实测 1.2 秒),10 秒内重复打开走缓存。
|
|
107
110
|
|
|
@@ -200,7 +203,7 @@ dsh plugin --profile <profile> add github:chyxhtc/dsh-ws-recency
|
|
|
200
203
|
或固定版本的预构建包:
|
|
201
204
|
|
|
202
205
|
```powershell
|
|
203
|
-
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.
|
|
206
|
+
dsh plugin --profile <profile> add https://github.com/chyxhtc/dsh-ws-recency/releases/download/v0.29.1/dsh-ws-recency-0.29.1.tgz
|
|
204
207
|
```
|
|
205
208
|
|
|
206
209
|
装完把 `dsh-ws-recency` 加进 `~/.hypers-work/profiles/<profile>/package.json` 的 `dsh.profile.bundles`,重启应用。
|
package/client.js
CHANGED
|
@@ -131,6 +131,8 @@
|
|
|
131
131
|
".wsr-modal-tools{display:flex;align-items:center;gap:8px;flex:none}",
|
|
132
132
|
".wsr-modal-body{padding:14px;overflow:auto;display:flex;flex-direction:column;gap:12px;font-size:12px}",
|
|
133
133
|
".wsr-stats-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}",
|
|
134
|
+
".wsr-stats-card-primary{box-shadow:inset 0 0 0 1px rgba(79,124,255,.45)}",
|
|
135
|
+
".wsr-stats-card-primary .wsr-stats-value{color:#7aa2ff}",
|
|
134
136
|
".wsr-stats-card{background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));border-radius:8px;padding:8px 10px}",
|
|
135
137
|
".wsr-stats-value{font-size:15px;font-weight:600}",
|
|
136
138
|
".wsr-stats-label{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
@@ -234,18 +236,23 @@
|
|
|
234
236
|
".wsr-chart{display:flex;flex-direction:column;gap:6px}",
|
|
235
237
|
".wsr-chart-head{display:flex;align-items:center;justify-content:space-between;gap:10px}",
|
|
236
238
|
".wsr-chart-title{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
237
|
-
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px;align-items:center;gap:8px}",
|
|
238
239
|
".wsr-chart-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}",
|
|
240
|
+
".wsr-chart-row{display:grid;grid-template-columns:120px 1fr 64px 56px 48px;align-items:center;gap:8px}",
|
|
241
|
+
".wsr-chart-family{font-size:10px;color:var(--dsw-alias-label-tertiary);margin-top:-2px}",
|
|
242
|
+
".wsr-family-legend{padding-bottom:4px}",
|
|
239
243
|
".wsr-chart-track{height:8px;border-radius:4px;background:rgba(255,255,255,.06);overflow:hidden;display:flex}",
|
|
240
244
|
".wsr-chart-fill{height:100%;border-radius:0;min-width:0}",
|
|
241
245
|
".wsr-chart-group{display:flex;height:100%;min-width:2px;border-radius:4px;overflow:hidden}",
|
|
242
246
|
".wsr-chart-swatch{width:8px;height:8px;border-radius:2px;background:hsl(217, 88%, 50%)}",
|
|
243
|
-
".wsr-chart-swatch-dim{background:hsl(217,
|
|
247
|
+
".wsr-chart-swatch-dim{background:hsl(217, 32%, 84%)}",
|
|
244
248
|
".wsr-chart-legend{display:flex;flex-wrap:wrap;gap:10px;align-items:center}",
|
|
245
249
|
".wsr-chart-legend-item{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
246
250
|
".wsr-chart-legend-text{white-space:nowrap}",
|
|
247
251
|
".wsr-chart-value{text-align:right;font-variant-numeric:tabular-nums}",
|
|
248
252
|
".wsr-chart-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}",
|
|
253
|
+
".wsr-chart-calls{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:10px;font-variant-numeric:tabular-nums}",
|
|
254
|
+
".wsr-chart-headrow{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
255
|
+
".wsr-chart-value-head,.wsr-chart-share-head,.wsr-chart-calls-head{text-align:right}",
|
|
249
256
|
".wsr-stats-details{display:flex;flex-direction:column;gap:8px}",
|
|
250
257
|
".wsr-stats-table{display:flex;flex-direction:column}",
|
|
251
258
|
".wsr-stats-row{display:grid;grid-template-columns:1.4fr .6fr .8fr .8fr .8fr .6fr;gap:6px;padding:6px 4px;border-bottom:.5px solid rgba(255,255,255,.06)}",
|
|
@@ -271,6 +278,14 @@
|
|
|
271
278
|
".wsr-context-chart{display:flex;align-items:flex-end;gap:2px;height:54px;padding-top:4px;border-bottom:.5px solid rgba(255,255,255,.08)}",
|
|
272
279
|
".wsr-context-bar{flex:1;min-width:1px;border-radius:1px 1px 0 0;background:linear-gradient(180deg,rgba(79,124,255,.9),rgba(79,124,255,.3))}",
|
|
273
280
|
".wsr-context-caption{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
281
|
+
".wsr-context-jump{position:relative;cursor:pointer}",
|
|
282
|
+
".wsr-context-jump-hit{position:absolute;left:50%;top:-9px;width:22px;height:22px;margin-left:-11px;display:flex;align-items:center;justify-content:center;border-radius:50%;cursor:pointer}",
|
|
283
|
+
".wsr-context-jump-dot{width:6px;height:6px;border-radius:50%;background:#d99a2b;transition:transform .12s,box-shadow .12s}",
|
|
284
|
+
".wsr-context-jump-hit-hot .wsr-context-jump-dot{transform:scale(1.8);box-shadow:0 0 0 4px rgba(217,154,43,.25)}",
|
|
285
|
+
".wsr-context-jump:hover .wsr-context-bar-inner{filter:brightness(1.15)}",
|
|
286
|
+
".wsr-context-jumps{display:flex;flex-direction:column;gap:2px}",
|
|
287
|
+
".wsr-context-jump-row{font-size:11px;color:var(--dsw-alias-label-secondary);padding:1px 4px;border-radius:4px;transition:background .12s,color .12s}",
|
|
288
|
+
".wsr-context-jump-row-hot{background:rgba(217,154,43,.16);color:var(--dsw-alias-label-primary)}",
|
|
274
289
|
".wsr-kind-legend{display:flex;flex-wrap:wrap;gap:10px}",
|
|
275
290
|
".wsr-kind{display:flex;align-items:center;gap:5px;font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
276
291
|
".wsr-kind-dot{width:8px;height:8px;border-radius:2px;flex:none}",
|
|
@@ -282,8 +297,8 @@
|
|
|
282
297
|
".wsr-amplified-meta{font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
283
298
|
".wsr-amplified-value{text-align:right;font-weight:600;font-variant-numeric:tabular-nums;font-size:12px}",
|
|
284
299
|
".wsr-amplified-share{text-align:right;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}",
|
|
285
|
-
".wsr-amplified-if{grid-column:1 / -1;font-size:10px;color:var(--dsw-alias-label-tertiary)}",
|
|
286
300
|
".wsr-amplified-empty{font-size:11px;color:var(--dsw-alias-label-tertiary)}",
|
|
301
|
+
".wsr-stats-footnote{padding-top:6px;border-top:.5px solid rgba(255,255,255,.06)}",
|
|
287
302
|
".wsr-toggle{width:100%;height:28px;padding:0 12px 0 calc(28px + var(--dsh-workspace-indent,0px));cursor:pointer;text-align:left;color:var(--dsw-alias-label-tertiary);background:0 0;border:none;font-size:12px}",
|
|
288
303
|
".wsr-toggle:hover{color:var(--dsw-alias-label-secondary)}",
|
|
289
304
|
'[' + STATE_ATTR + '="running"] [class*="_title"]{color:#4f8ef7}',
|
|
@@ -352,12 +367,16 @@
|
|
|
352
367
|
"stats.agent": "\u4e3b agent",
|
|
353
368
|
"stats.col.source": "\u6765\u6e90",
|
|
354
369
|
"stats.col.calls": "\u8c03\u7528",
|
|
370
|
+
"stats.callsShort": "{n} 次",
|
|
371
|
+
"stats.col.tokensShort": "token",
|
|
372
|
+
"stats.col.shareShort": "占比",
|
|
355
373
|
"stats.col.args": "\u53c2\u6570",
|
|
356
374
|
"stats.col.results": "\u7ed3\u679c",
|
|
357
375
|
"stats.col.total": "\u4f30\u7b97",
|
|
358
376
|
"stats.col.share": "\u5360\u6bd4",
|
|
359
377
|
"stats.note": "\u5408\u8ba1\u6765\u81ea\u6bcf\u6b65\u8bb0\u5f55\u7684\u771f\u5b9e usage\uff08\u7f13\u5b58\u547d\u4e2d + \u8f93\u5165 + \u8f93\u51fa\uff09\uff1b\u672c\u8868\u6309\u6765\u6e90\u7684\u62c6\u5206\u662f\u6309\u5185\u5bb9\u957f\u5ea6\u4f30\u7b97\uff08\u4e2d\u6587\u7ea6 1 token/\u5b57\uff0c\u82f1\u6587\u7ea6 4 \u5b57\u7b26/token\uff09\uff0c\u7528\u4e8e\u6bd4\u8f83\u5360\u6bd4\uff0c\u4e0d\u662f\u8ba1\u8d39\u53e3\u5f84\u3002",
|
|
360
378
|
"stats.agentDetail": "主 agent 构成:思考 {reasoning} · 回复 {text} · 用户消息 {user} · 系统提示 {system}",
|
|
379
|
+
"stats.split": "输入 {input} · 缓存命中 {cache} · 输出 {output}",
|
|
361
380
|
"stats.diagnose.unmounted": "\n\n(宿主半已加载,但统计路由没挂上——重启应用再试)",
|
|
362
381
|
"stats.diagnose.noHost": "\n\n(宿主半未加载:需要重启应用加载新版本)",
|
|
363
382
|
"menu.move": "移动到工作区…",
|
|
@@ -458,14 +477,23 @@
|
|
|
458
477
|
"archive.workspace": "工作区",
|
|
459
478
|
"move.failed": "移动失败:",
|
|
460
479
|
"stats.chart": "消耗分布",
|
|
480
|
+
"stats.family.shell": "命令执行",
|
|
481
|
+
"stats.family.files": "文件操作",
|
|
482
|
+
"stats.family.web": "网络检索",
|
|
483
|
+
"stats.family.agents": "子代理/协作",
|
|
484
|
+
"stats.family.misc": "其它工具",
|
|
485
|
+
"stats.family.other": "未归类",
|
|
461
486
|
"composer.analysis": "用量分析",
|
|
462
487
|
"stats.legend.args": "参数(模型写的)",
|
|
463
488
|
"stats.legend.results": "结果(环境返回的)",
|
|
489
|
+
"stats.barTooltip": "{name} 共 {total}:参数 {args}({argsShare}),结果 {results}({resultsShare})",
|
|
464
490
|
"stats.argModeNote": "当前把工具参数计入主 agent:每个工具只算返回结果,表格里「参数」列显示为淡色(那些 token 记在主 agent 那一行)。",
|
|
465
491
|
"stats.amplified.title": "放大成本(账单归因)",
|
|
466
492
|
"stats.amplified.summary": "账单 {bill} token;可归因内容经重读放大后占 {share}({attributed})",
|
|
467
493
|
"stats.amplified.contextCaption": "每步上下文(面积≈账单):越早进入的内容被重读越多",
|
|
468
494
|
"stats.amplified.point": "第 {step} 步 · {context}",
|
|
495
|
+
"stats.amplified.jump": "第 {step} 步上下文涨了 {rise}",
|
|
496
|
+
"stats.amplified.jumpFrom": "({name} 进来 {tokens})",
|
|
469
497
|
"stats.amplified.meta": "第 {entry} 步进入 · {tokens} token × {remaining} 次重读",
|
|
470
498
|
"stats.amplified.whatIf": "若压到 20%,可省 {save}({share})",
|
|
471
499
|
"stats.amplified.empty": "没有可归因的放大内容(压缩后或旧日志可能缺失)",
|
|
@@ -519,12 +547,16 @@
|
|
|
519
547
|
"stats.agent": "main agent",
|
|
520
548
|
"stats.col.source": "source",
|
|
521
549
|
"stats.col.calls": "calls",
|
|
550
|
+
"stats.callsShort": "{n}x",
|
|
551
|
+
"stats.col.tokensShort": "tokens",
|
|
552
|
+
"stats.col.shareShort": "share",
|
|
522
553
|
"stats.col.args": "args",
|
|
523
554
|
"stats.col.results": "results",
|
|
524
555
|
"stats.col.total": "estimate",
|
|
525
556
|
"stats.col.share": "share",
|
|
526
557
|
"stats.note": "Totals come from the recorded per-step usage (cache read + input + output). The per-source split is estimated from content length (about 1 token per CJK character, 4 characters per token otherwise) so the shares are comparable, not billable.",
|
|
527
558
|
"stats.agentDetail": "Agent composition: reasoning {reasoning} \u00b7 reply {text} \u00b7 user messages {user} \u00b7 system prompt {system}",
|
|
559
|
+
"stats.split": "input {input} \u00b7 cache hit {cache} \u00b7 output {output}",
|
|
528
560
|
"stats.diagnose.unmounted": "\n\n(the host half is loaded but the statistics route did not mount - restart the app and retry)",
|
|
529
561
|
"stats.diagnose.noHost": "\n\n(the host half is not loaded: restart the app to pick up the new version)",
|
|
530
562
|
"menu.move": "Move to workspace\u2026",
|
|
@@ -624,14 +656,23 @@
|
|
|
624
656
|
"archive.workspace": "workspace",
|
|
625
657
|
"move.failed": "Move failed: ",
|
|
626
658
|
"stats.chart": "Where the tokens went",
|
|
659
|
+
"stats.family.shell": "shell",
|
|
660
|
+
"stats.family.files": "files",
|
|
661
|
+
"stats.family.web": "web",
|
|
662
|
+
"stats.family.agents": "subagents",
|
|
663
|
+
"stats.family.misc": "other tools",
|
|
664
|
+
"stats.family.other": "unclassified",
|
|
627
665
|
"composer.analysis": "Usage analysis",
|
|
628
666
|
"stats.legend.args": "arguments (written by the model)",
|
|
629
667
|
"stats.legend.results": "results (returned by the environment)",
|
|
668
|
+
"stats.barTooltip": "{name}: {total} total - arguments {args} ({argsShare}), results {results} ({resultsShare})",
|
|
630
669
|
"stats.argModeNote": "Tool arguments currently count towards the agent: each tool shows only its results, and the table's \"args\" column is faded because those tokens sit on the agent's row.",
|
|
631
670
|
"stats.amplified.title": "Amplified cost (what the bill pays for)",
|
|
632
671
|
"stats.amplified.summary": "Bill {bill} tokens; attributable content amplifies to {share} ({attributed})",
|
|
633
672
|
"stats.amplified.contextCaption": "Context per step (area ≈ bill): earlier content is re-read more",
|
|
634
673
|
"stats.amplified.point": "step {step} · {context}",
|
|
674
|
+
"stats.amplified.jump": "step {step} grew by {rise}",
|
|
675
|
+
"stats.amplified.jumpFrom": "({name} brought {tokens})",
|
|
635
676
|
"stats.amplified.meta": "entered at step {entry} · {tokens} tokens × {remaining} re-reads",
|
|
636
677
|
"stats.amplified.whatIf": "at 20%, saves {save} ({share})",
|
|
637
678
|
"stats.amplified.empty": "No amplifiable content (compacted or older logs may lack it)",
|
|
@@ -1940,7 +1981,14 @@
|
|
|
1940
1981
|
*/
|
|
1941
1982
|
function chartBar(entry, largest) {
|
|
1942
1983
|
var line = statsDiv("wsr-chart-row");
|
|
1943
|
-
|
|
1984
|
+
var labelCell = statsDiv("wsr-chart-label", entry.name);
|
|
1985
|
+
/* The colour now means a family, so the name cell says which one: a
|
|
1986
|
+
colour without a caption is a riddle, not an encoding. It lives in
|
|
1987
|
+
the name cell so the five-column grid stays intact. */
|
|
1988
|
+
if (typeof entry.family === "string" && entry.family !== "") {
|
|
1989
|
+
labelCell.appendChild(statsDiv("wsr-chart-family", t("stats.family." + entry.family)));
|
|
1990
|
+
}
|
|
1991
|
+
line.appendChild(labelCell);
|
|
1944
1992
|
var track = statsDiv("wsr-chart-track");
|
|
1945
1993
|
var group = statsDiv("wsr-chart-group");
|
|
1946
1994
|
var width = largest > 0 ? (entry.value / largest) * 100 : 0;
|
|
@@ -1952,69 +2000,85 @@
|
|
|
1952
2000
|
if (argsPart > 0) {
|
|
1953
2001
|
var argsSeg = statsDiv("wsr-chart-fill wsr-bar-args");
|
|
1954
2002
|
argsSeg.style.width = argsPart.toFixed(2) + "%";
|
|
1955
|
-
argsSeg.style.background = sourceColorDim(entry.hue
|
|
2003
|
+
argsSeg.style.background = sourceColorDim(entry.hue);
|
|
1956
2004
|
group.appendChild(argsSeg);
|
|
1957
2005
|
}
|
|
1958
2006
|
var resultsSeg = statsDiv("wsr-chart-fill wsr-bar-results");
|
|
1959
2007
|
resultsSeg.style.width = (100 - argsPart).toFixed(2) + "%";
|
|
1960
|
-
resultsSeg.style.background = sourceColor(entry.hue
|
|
2008
|
+
resultsSeg.style.background = sourceColor(entry.hue);
|
|
1961
2009
|
group.appendChild(resultsSeg);
|
|
2010
|
+
/* What the two shades mean, on the thing that has them: the legend is
|
|
2011
|
+
a row away and reads like a second chart header. */
|
|
2012
|
+
if (argsPart > 0) {
|
|
2013
|
+
group.setAttribute("title", t("stats.barTooltip", {
|
|
2014
|
+
name: entry.name,
|
|
2015
|
+
total: formatTokens(entry.value),
|
|
2016
|
+
args: formatTokens(entry.args || 0),
|
|
2017
|
+
argsShare: formatShare((entry.value > 0 ? (entry.args || 0) / entry.value : 0)),
|
|
2018
|
+
results: formatTokens(entry.results || 0),
|
|
2019
|
+
resultsShare: formatShare((entry.value > 0 ? (entry.results || 0) / entry.value : 0)),
|
|
2020
|
+
}));
|
|
2021
|
+
}
|
|
1962
2022
|
track.appendChild(group);
|
|
1963
2023
|
line.appendChild(track);
|
|
1964
2024
|
line.appendChild(statsDiv("wsr-chart-value", formatTokens(entry.value)));
|
|
1965
2025
|
line.appendChild(statsDiv("wsr-chart-share", formatShare(entry.share)));
|
|
2026
|
+
/* The count the chart cannot draw: a bar says how heavy a source is,
|
|
2027
|
+
the call count says how often it got there. The details table used to
|
|
2028
|
+
be the only place for it. It always renders (empty for rows without
|
|
2029
|
+
a count) so the five-column grid stays aligned. */
|
|
2030
|
+
line.appendChild(statsDiv(
|
|
2031
|
+
"wsr-chart-calls",
|
|
2032
|
+
typeof entry.calls === "number" && entry.calls > 0 ? t("stats.callsShort", { n: String(entry.calls) }) : "",
|
|
2033
|
+
));
|
|
1966
2034
|
return line;
|
|
1967
2035
|
}
|
|
1968
2036
|
|
|
1969
2037
|
/**
|
|
1970
|
-
* Colour identity for a source.
|
|
2038
|
+
* Colour identity for a source, by tool family.
|
|
1971
2039
|
*
|
|
1972
|
-
* The
|
|
1973
|
-
*
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
1976
|
-
*
|
|
2040
|
+
* The colour answers one question - what kind of work is this - so the
|
|
2041
|
+
* hue is the family, not the tool: five named families with a fixed
|
|
2042
|
+
* vividness, and unknown tools fall back to the same neutral instead of a
|
|
2043
|
+
* hash. Ranking no longer modulates anything: a faded tail colour told the
|
|
2044
|
+
* reader nothing they could act on.
|
|
1977
2045
|
*/
|
|
1978
|
-
var
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
subagent: 250, subagent_fork: 250, workflow: 250, spawn_teammate: 250, send_message: 250, wait_agent: 250,
|
|
1985
|
-
ask_user_question: 12, present: 12,
|
|
1986
|
-
skill: 60, create_goal: 60, update_goal: 60,
|
|
1987
|
-
};
|
|
1988
|
-
var TOOL_PREFIX_HUES = [
|
|
1989
|
-
["mcp__", 235],
|
|
1990
|
-
["browser_", 0],
|
|
1991
|
-
["univer_", 175],
|
|
1992
|
-
["weknora_", 300],
|
|
1993
|
-
["job_", 330],
|
|
1994
|
-
["team_", 250],
|
|
2046
|
+
var TOOL_FAMILIES = [
|
|
2047
|
+
{ key: "shell", hue: 32, tools: ["pwsh", "powershell", "shell", "bash", "command", "cmd", "run_code"], prefixes: [] },
|
|
2048
|
+
{ key: "files", hue: 152, tools: ["read", "write", "edit", "grep", "glob", "str_replace_editor", "ls", "delete", "move_file"], prefixes: ["univer_"] },
|
|
2049
|
+
{ key: "web", hue: 205, tools: ["web_fetch", "web_search", "platform_search", "multi_search", "advanced_search", "domain_search", "video_search", "browser_"], prefixes: ["browser_"] },
|
|
2050
|
+
{ key: "agents", hue: 268, tools: ["subagent", "subagent_fork", "workflow", "spawn_teammate", "send_message", "wait_agent", "task"], prefixes: ["team_"] },
|
|
2051
|
+
{ key: "misc", hue: 330, tools: ["todo_write", "todo_read", "todo", "job_output", "job_list", "job_kill", "skill", "create_goal", "update_goal", "ask_user_question", "present", "weknora_"], prefixes: ["job_", "weknora_", "mcp__"] },
|
|
1995
2052
|
];
|
|
2053
|
+
/** The neutral an unknown tool gets: no family, no claim of one. */
|
|
2054
|
+
var TOOL_FAMILY_NEUTRAL = { key: "other", hue: 210 };
|
|
1996
2055
|
|
|
1997
|
-
function
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2056
|
+
function toolFamily(name) {
|
|
2057
|
+
if (typeof name !== "string" || name === "") return TOOL_FAMILY_NEUTRAL;
|
|
2058
|
+
var key = name.toLowerCase();
|
|
2059
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) {
|
|
2060
|
+
var family = TOOL_FAMILIES[i];
|
|
2061
|
+
if (family.tools.indexOf(key) !== -1) return family;
|
|
2062
|
+
for (var p = 0; p < family.prefixes.length; p += 1) {
|
|
2063
|
+
if (key.indexOf(family.prefixes[p]) === 0) return family;
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
return TOOL_FAMILY_NEUTRAL;
|
|
2001
2067
|
}
|
|
2002
2068
|
|
|
2003
2069
|
function sourceHue(name) {
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
return
|
|
2070
|
+
return toolFamily(name).hue;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/** The hue of a family key, for the legend swatches. */
|
|
2074
|
+
function hueOfFamily(key) {
|
|
2075
|
+
for (var i = 0; i < TOOL_FAMILIES.length; i += 1) if (TOOL_FAMILIES[i].key === key) return TOOL_FAMILIES[i].hue;
|
|
2076
|
+
return TOOL_FAMILY_NEUTRAL.hue;
|
|
2011
2077
|
}
|
|
2012
2078
|
|
|
2013
|
-
/**
|
|
2014
|
-
function sourceColor(hue
|
|
2015
|
-
|
|
2016
|
-
var lightness = Math.min(64, 50 + rank * 2);
|
|
2017
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2079
|
+
/** One vividness for every family bar: colour means "which family", not "how big". */
|
|
2080
|
+
function sourceColor(hue) {
|
|
2081
|
+
return "hsl(" + hue + ", 72%, 58%)";
|
|
2018
2082
|
}
|
|
2019
2083
|
|
|
2020
2084
|
/**
|
|
@@ -2022,12 +2086,12 @@
|
|
|
2022
2086
|
*
|
|
2023
2087
|
* It has to be a real colour rather than an opacity: the segment sits on a
|
|
2024
2088
|
* solid bar of the same hue, so a translucent copy of it would composite
|
|
2025
|
-
* back to exactly the same colour and the split would be invisible.
|
|
2089
|
+
* back to exactly the same colour and the split would be invisible. The
|
|
2090
|
+
* gap between the two is deliberately wide - a 20-point lightness step read
|
|
2091
|
+
* as one smudged bar in the reported panel.
|
|
2026
2092
|
*/
|
|
2027
|
-
function sourceColorDim(hue
|
|
2028
|
-
|
|
2029
|
-
var lightness = Math.min(76, 66 + rank * 2);
|
|
2030
|
-
return "hsl(" + hue + ", " + saturation + "%, " + lightness + "%)";
|
|
2093
|
+
function sourceColorDim(hue) {
|
|
2094
|
+
return "hsl(" + hue + ", 32%, 84%)";
|
|
2031
2095
|
}
|
|
2032
2096
|
|
|
2033
2097
|
var AMPLIFIED_KIND = {
|
|
@@ -2046,6 +2110,91 @@
|
|
|
2046
2110
|
* block's tokens times the number of later steps that re-read it. The
|
|
2047
2111
|
* host half computes that attribution; this only draws it.
|
|
2048
2112
|
*/
|
|
2113
|
+
/** Chart/list pairs whose jump markers highlight together on hover. */
|
|
2114
|
+
var jumpHoverHosts = [];
|
|
2115
|
+
/** Document-level listener for jump hover; registered once per panel open. */
|
|
2116
|
+
var jumpHoverBound = false;
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Highlight one jump: the bar, its dot and the row that spells it out.
|
|
2120
|
+
*
|
|
2121
|
+
* Both the chart and the list live under the same section, so the pairing
|
|
2122
|
+
* is by `data-wsr-jump*` attributes rather than by DOM position (the chart
|
|
2123
|
+
* is downsampled and a bar may cover several steps).
|
|
2124
|
+
*/
|
|
2125
|
+
function highlightJumpRow(event) {
|
|
2126
|
+
var target = event !== undefined && event.currentTarget !== undefined ? event.currentTarget : null;
|
|
2127
|
+
if (target === null || typeof target.getAttribute !== "function") return;
|
|
2128
|
+
var step = target.getAttribute("data-wsr-jump-hit");
|
|
2129
|
+
if (step === null) return;
|
|
2130
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2131
|
+
var host = jumpHoverHosts[i];
|
|
2132
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2133
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2134
|
+
for (var r = 0; r < rows.length; r += 1) {
|
|
2135
|
+
rows[r].className = "wsr-context-jump-row" + (rows[r].getAttribute("data-wsr-jump-row") === step ? " wsr-context-jump-row-hot" : "");
|
|
2136
|
+
}
|
|
2137
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2138
|
+
for (var h = 0; h < hits.length; h += 1) {
|
|
2139
|
+
hits[h].className = "wsr-context-jump-hit" + (hits[h].getAttribute("data-wsr-jump-hit") === step ? " wsr-context-jump-hit-hot" : "");
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
function clearJumpHighlight() {
|
|
2145
|
+
for (var i = 0; i < jumpHoverHosts.length; i += 1) {
|
|
2146
|
+
var host = jumpHoverHosts[i];
|
|
2147
|
+
if (host.chart === null || typeof host.chart.querySelectorAll !== "function") continue;
|
|
2148
|
+
var rows = host.chart.querySelectorAll("[data-wsr-jump-row]");
|
|
2149
|
+
for (var r = 0; r < rows.length; r += 1) rows[r].className = "wsr-context-jump-row";
|
|
2150
|
+
var hits = host.chart.querySelectorAll("[data-wsr-jump-hit]");
|
|
2151
|
+
for (var h = 0; h < hits.length; h += 1) hits[h].className = "wsr-context-jump-hit";
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
/** The three steepest rises in the context curve, with the block behind each. */
|
|
2156
|
+
function contextJumps(amplified) {
|
|
2157
|
+
var series = Array.isArray(amplified.series) ? amplified.series : [];
|
|
2158
|
+
var blocks = Array.isArray(amplified.blocks) ? amplified.blocks : [];
|
|
2159
|
+
var rises = [];
|
|
2160
|
+
for (var i = 1; i < series.length; i += 1) {
|
|
2161
|
+
var rise = Number(series[i].context) - Number(series[i - 1].context);
|
|
2162
|
+
if (rise > 0) rises.push({ step: Number(series[i].step), rise: rise });
|
|
2163
|
+
}
|
|
2164
|
+
rises.sort(function (a, b) { return b.rise - a.rise; });
|
|
2165
|
+
var picked = [];
|
|
2166
|
+
for (var r = 0; r < rises.length && picked.length < 3; r += 1) {
|
|
2167
|
+
var rise2 = rises[r];
|
|
2168
|
+
/* Two markers next to each other would read as one long jump; keep
|
|
2169
|
+
the bars they sit on apart so each mark stays a single step. */
|
|
2170
|
+
var close = false;
|
|
2171
|
+
for (var p = 0; p < picked.length; p += 1) {
|
|
2172
|
+
if (Math.abs(picked[p].step - rise2.step) < Math.max(2, Math.round(series.length / 10))) close = true;
|
|
2173
|
+
}
|
|
2174
|
+
if (close) continue;
|
|
2175
|
+
/* The entering block: the biggest one whose entry step is this one,
|
|
2176
|
+
or (downsampled curves) the last entry at or before it. */
|
|
2177
|
+
var best = null;
|
|
2178
|
+
for (var b = 0; b < blocks.length; b += 1) {
|
|
2179
|
+
var block = blocks[b];
|
|
2180
|
+
if (Number(block.entry) > rise2.step) continue;
|
|
2181
|
+
if (best === null || Number(block.entry) > Number(best.entry)) best = block;
|
|
2182
|
+
}
|
|
2183
|
+
var label = t("stats.amplified.jump", {
|
|
2184
|
+
step: String(rise2.step),
|
|
2185
|
+
rise: formatTokens(rise2.rise),
|
|
2186
|
+
});
|
|
2187
|
+
if (best !== null && Number(best.entry) === rise2.step) {
|
|
2188
|
+
label += " " + t("stats.amplified.jumpFrom", {
|
|
2189
|
+
name: best.kind === "tool" ? String(best.name) : t("stats.agent"),
|
|
2190
|
+
tokens: formatTokens(best.tokens),
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
picked.push({ step: rise2.step, rise: rise2.rise, label: label });
|
|
2194
|
+
}
|
|
2195
|
+
return picked;
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2049
2198
|
function buildAmplified(stats) {
|
|
2050
2199
|
var amplified = stats.amplified;
|
|
2051
2200
|
if (amplified === null || amplified === undefined || !Array.isArray(amplified.series)) return null;
|
|
@@ -2067,14 +2216,49 @@
|
|
|
2067
2216
|
if (Number(series[i].context) > largest) largest = Number(series[i].context);
|
|
2068
2217
|
}
|
|
2069
2218
|
var chart = statsDiv("wsr-context-chart");
|
|
2219
|
+
/* Mark the steps where the window grew the most. A single read of a
|
|
2220
|
+
large file shows up here as one tall jump, which is the question the
|
|
2221
|
+
whole amplified view exists to answer, so the jump gets a marker
|
|
2222
|
+
instead of leaving the reader to compare 96 bars by eye. */
|
|
2223
|
+
var jumps = contextJumps(amplified);
|
|
2224
|
+
var jumpByStep = {};
|
|
2225
|
+
for (var jj = 0; jj < jumps.length; jj += 1) jumpByStep[jumps[jj].step] = jumps[jj];
|
|
2070
2226
|
for (var j = 0; j < series.length; j += 1) {
|
|
2071
2227
|
var bar = statsDiv("wsr-context-bar");
|
|
2072
2228
|
bar.style.height = Math.max(2, Math.round((Number(series[j].context) / largest) * 100)) + "%";
|
|
2073
|
-
|
|
2229
|
+
var jump = jumpByStep[Number(series[j].step)];
|
|
2230
|
+
if (jump !== undefined) {
|
|
2231
|
+
bar.className = "wsr-context-bar wsr-context-jump";
|
|
2232
|
+
bar.setAttribute("data-wsr-jump", String(jump.step));
|
|
2233
|
+
bar.setAttribute("title", jump.label);
|
|
2234
|
+
/* A hover target that is big enough to hit: a 5px dot on a 3px bar
|
|
2235
|
+
is unraisable without aiming, and the label lives in the row
|
|
2236
|
+
below, so hovering the bar also lifts that row. */
|
|
2237
|
+
var hit = statsDiv("wsr-context-jump-hit");
|
|
2238
|
+
hit.setAttribute("data-wsr-jump-hit", String(jump.step));
|
|
2239
|
+
hit.appendChild(statsDiv("wsr-context-jump-dot"));
|
|
2240
|
+
hit.addEventListener("mouseenter", highlightJumpRow);
|
|
2241
|
+
hit.addEventListener("mouseleave", clearJumpHighlight);
|
|
2242
|
+
bar.appendChild(hit);
|
|
2243
|
+
} else {
|
|
2244
|
+
bar.setAttribute("title", t("stats.amplified.point", { step: String(series[j].step), context: formatTokens(series[j].context) }));
|
|
2245
|
+
}
|
|
2074
2246
|
chart.appendChild(bar);
|
|
2075
2247
|
}
|
|
2076
2248
|
section.appendChild(chart);
|
|
2077
2249
|
section.appendChild(statsDiv("wsr-context-caption", t("stats.amplified.contextCaption")));
|
|
2250
|
+
if (jumps.length > 0) {
|
|
2251
|
+
var jumpList = statsDiv("wsr-context-jumps");
|
|
2252
|
+
for (var jl = 0; jl < jumps.length; jl += 1) {
|
|
2253
|
+
var jumpRow = statsDiv("wsr-context-jump-row", jumps[jl].label);
|
|
2254
|
+
jumpRow.setAttribute("data-wsr-jump-row", String(jumps[jl].step));
|
|
2255
|
+
jumpList.appendChild(jumpRow);
|
|
2256
|
+
}
|
|
2257
|
+
section.appendChild(jumpList);
|
|
2258
|
+
}
|
|
2259
|
+
/* The rows only make sense while the chart is on screen; hovering a
|
|
2260
|
+
bar or its row lifts both, which is what "挪上去更明显" means here. */
|
|
2261
|
+
jumpHoverHosts.push({ chart: chart, list: section });
|
|
2078
2262
|
|
|
2079
2263
|
var kinds = amplified.byKind || [];
|
|
2080
2264
|
if (kinds.length > 0) {
|
|
@@ -2110,37 +2294,34 @@
|
|
|
2110
2294
|
row.appendChild(main);
|
|
2111
2295
|
row.appendChild(statsDiv("wsr-amplified-value", formatTokens(block.amplified)));
|
|
2112
2296
|
row.appendChild(statsDiv("wsr-amplified-share", formatShare(block.share || 0)));
|
|
2113
|
-
if (Number(block.remaining) > 0 && Number(block.saving) > 0) {
|
|
2114
|
-
row.appendChild(statsDiv("wsr-amplified-if", t("stats.amplified.whatIf", {
|
|
2115
|
-
save: formatTokens(block.saving),
|
|
2116
|
-
share: formatShare(Number(block.saving) / (bill > 0 ? bill : 1)),
|
|
2117
|
-
})));
|
|
2118
|
-
}
|
|
2119
2297
|
list.appendChild(row);
|
|
2120
2298
|
}
|
|
2121
2299
|
section.appendChild(list);
|
|
2122
|
-
section.appendChild(statsDiv("wsr-stats-note", t("stats.amplified.note")));
|
|
2123
2300
|
return section;
|
|
2124
2301
|
}
|
|
2125
2302
|
|
|
2126
2303
|
function renderStats(body, stats) {
|
|
2127
2304
|
body.textContent = "";
|
|
2128
2305
|
while (body.firstChild !== null) body.removeChild(body.firstChild);
|
|
2306
|
+
/* A re-render replaces the DOM the hover handlers pointed at. */
|
|
2307
|
+
jumpHoverHosts.length = 0;
|
|
2129
2308
|
var totals = stats.totals || {};
|
|
2130
2309
|
var estimate = stats.estimate || {};
|
|
2131
2310
|
var agent = estimate.agent || {};
|
|
2132
2311
|
|
|
2312
|
+
/* Five cards as before, bill first: it is the number the rest of the
|
|
2313
|
+
panel explains, so it leads and carries the accent. */
|
|
2133
2314
|
var grid = document.createElement("div");
|
|
2134
2315
|
grid.className = "wsr-stats-grid";
|
|
2135
2316
|
var cards = [
|
|
2136
|
-
[t("stats.
|
|
2137
|
-
[t("stats.
|
|
2138
|
-
[t("stats.
|
|
2139
|
-
[t("stats.
|
|
2140
|
-
[t("stats.
|
|
2317
|
+
[t("stats.total"), formatTokens(totals.totalTokens), true],
|
|
2318
|
+
[t("stats.steps"), formatTokens(stats.steps), false],
|
|
2319
|
+
[t("stats.input"), formatTokens(totals.inputTokens), false],
|
|
2320
|
+
[t("stats.cache"), formatTokens(totals.cacheReadTokens), false],
|
|
2321
|
+
[t("stats.output"), formatTokens(totals.outputTokens), false],
|
|
2141
2322
|
];
|
|
2142
2323
|
for (var i = 0; i < cards.length; i += 1) {
|
|
2143
|
-
var card = statsDiv("wsr-stats-card");
|
|
2324
|
+
var card = statsDiv("wsr-stats-card" + (cards[i][2] === true ? " wsr-stats-card-primary" : ""));
|
|
2144
2325
|
card.appendChild(statsDiv("wsr-stats-value", cards[i][1]));
|
|
2145
2326
|
card.appendChild(statsDiv("wsr-stats-label", cards[i][0]));
|
|
2146
2327
|
grid.appendChild(card);
|
|
@@ -2188,50 +2369,65 @@
|
|
|
2188
2369
|
value: value,
|
|
2189
2370
|
share: shareOf(value),
|
|
2190
2371
|
hue: sourceHue(tool.name),
|
|
2372
|
+
family: toolFamily(tool.name).key,
|
|
2191
2373
|
rank: j + 1,
|
|
2374
|
+
calls: tool.calls || 0,
|
|
2192
2375
|
args: args,
|
|
2376
|
+
results: results,
|
|
2193
2377
|
split: mode !== "agent" && args > 0 && results > 0,
|
|
2194
2378
|
});
|
|
2195
2379
|
}
|
|
2196
2380
|
|
|
2197
2381
|
/* The picture first: one bar per source, split into args and results. */
|
|
2198
|
-
var chart =
|
|
2382
|
+
var chart = document.createElement("div");
|
|
2383
|
+
chart.className = "wsr-chart";
|
|
2384
|
+
var familyOrder = [];
|
|
2385
|
+
var familySeen = {};
|
|
2386
|
+
for (var f = 0; f < entries.length; f += 1) {
|
|
2387
|
+
var fam = entries[f].family;
|
|
2388
|
+
if (typeof fam === "string" && fam !== "" && familySeen[fam] !== true) {
|
|
2389
|
+
familySeen[fam] = true;
|
|
2390
|
+
familyOrder.push(fam);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
if (familyOrder.length > 0) {
|
|
2394
|
+
var familyLegend = statsDiv("wsr-kind-legend wsr-family-legend");
|
|
2395
|
+
for (var fl = 0; fl < familyOrder.length; fl += 1) {
|
|
2396
|
+
var famItem = statsDiv("wsr-kind");
|
|
2397
|
+
var famDot = statsDiv("wsr-kind-dot");
|
|
2398
|
+
famDot.style.background = sourceColor(hueOfFamily(familyOrder[fl]));
|
|
2399
|
+
famItem.appendChild(famDot);
|
|
2400
|
+
famItem.appendChild(statsDiv("", t("stats.family." + familyOrder[fl])));
|
|
2401
|
+
familyLegend.appendChild(famItem);
|
|
2402
|
+
}
|
|
2403
|
+
chart.appendChild(familyLegend);
|
|
2404
|
+
}
|
|
2199
2405
|
var chartHead = statsDiv("wsr-chart-head");
|
|
2200
2406
|
chartHead.appendChild(statsDiv("wsr-chart-title", t("stats.chart")));
|
|
2201
2407
|
if (mode !== "agent") chartHead.appendChild(chartLegend());
|
|
2202
2408
|
chart.appendChild(chartHead);
|
|
2409
|
+
/* A header row keeps the count column from reading as a stray number. */
|
|
2410
|
+
var callHead = statsDiv("wsr-chart-row wsr-chart-headrow");
|
|
2411
|
+
callHead.appendChild(statsDiv("wsr-chart-label", ""));
|
|
2412
|
+
callHead.appendChild(statsDiv("wsr-chart-track-head", ""));
|
|
2413
|
+
callHead.appendChild(statsDiv("wsr-chart-value-head", t("stats.col.tokensShort")));
|
|
2414
|
+
callHead.appendChild(statsDiv("wsr-chart-share-head", t("stats.col.shareShort")));
|
|
2415
|
+
callHead.appendChild(statsDiv("wsr-chart-calls-head", t("stats.col.calls")));
|
|
2416
|
+
chart.appendChild(callHead);
|
|
2203
2417
|
var largest = 1;
|
|
2204
2418
|
for (var m = 0; m < entries.length; m += 1) if (entries[m].value > largest) largest = entries[m].value;
|
|
2205
2419
|
for (var k = 0; k < entries.length; k += 1) chart.appendChild(chartBar(entries[k], largest));
|
|
2206
2420
|
var distributionPanel = statsDiv("wsr-stats-panel");
|
|
2207
2421
|
distributionPanel.appendChild(chart);
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
var table = statsDiv("wsr-stats-table");
|
|
2214
|
-
var head = document.createElement("div");
|
|
2215
|
-
head.className = "wsr-stats-row wsr-stats-head";
|
|
2216
|
-
var columns = ["stats.col.source", "stats.col.calls", "stats.col.args", "stats.col.results", "stats.col.total", "stats.col.share"];
|
|
2217
|
-
for (var n = 0; n < columns.length; n += 1) head.appendChild(statsDiv("wsr-td", t(columns[n])));
|
|
2218
|
-
table.appendChild(head);
|
|
2219
|
-
table.appendChild(statsRow(t("stats.agent"), stats.steps, null, null, agentValue, shareOf(agentValue)));
|
|
2220
|
-
for (var q = 0; q < tools.length; q += 1) {
|
|
2221
|
-
var toolRow = tools[q];
|
|
2222
|
-
var toolArgs = toolRow.args || 0;
|
|
2223
|
-
var toolResults = toolRow.results || 0;
|
|
2224
|
-
var toolValue = mode === "agent" ? toolResults : (toolRow.total || toolArgs + toolResults);
|
|
2225
|
-
table.appendChild(statsRow(toolRow.name, toolRow.calls, toolArgs, toolResults, toolValue, shareOf(toolValue), mode === "agent"));
|
|
2226
|
-
}
|
|
2227
|
-
detailsPanel.appendChild(table);
|
|
2228
|
-
detailsPanel.appendChild(statsDiv("wsr-stats-detail", t("stats.agentDetail", {
|
|
2422
|
+
/* The agent's own split is the one number the bars cannot show: the
|
|
2423
|
+
rows for tools already name their source, so a whole table was
|
|
2424
|
+
repeating the chart. It sits under the chart instead. */
|
|
2425
|
+
distributionPanel.appendChild(statsDiv("wsr-stats-detail", t("stats.agentDetail", {
|
|
2229
2426
|
reasoning: formatTokens(agent.reasoning),
|
|
2230
2427
|
text: formatTokens(agent.text),
|
|
2231
2428
|
user: formatTokens(agent.user),
|
|
2232
2429
|
system: formatTokens(agent.system),
|
|
2233
2430
|
})));
|
|
2234
|
-
if (mode === "agent") detailsPanel.appendChild(statsDiv("wsr-stats-note", t("stats.argModeNote")));
|
|
2235
2431
|
|
|
2236
2432
|
var tabs = statsDiv("wsr-stats-tabs");
|
|
2237
2433
|
tabs.setAttribute("role", "tablist");
|
|
@@ -2242,7 +2438,7 @@
|
|
|
2242
2438
|
amplifiedPanel.appendChild(amplifiedSection);
|
|
2243
2439
|
defs.push(["amplified", "stats.tab.amplified", amplifiedPanel]);
|
|
2244
2440
|
}
|
|
2245
|
-
defs.
|
|
2441
|
+
if (mode === "agent") defs[0][2].appendChild(statsDiv("wsr-stats-note", t("stats.argModeNote")));
|
|
2246
2442
|
var tabButtons = {};
|
|
2247
2443
|
var selectTab = function (id) {
|
|
2248
2444
|
statsTab = id;
|
|
@@ -2271,10 +2467,16 @@
|
|
|
2271
2467
|
})(defs[d]);
|
|
2272
2468
|
}
|
|
2273
2469
|
var initialTab = statsTab;
|
|
2274
|
-
|
|
2470
|
+
/* A remembered tab may name a view this build no longer has. */
|
|
2471
|
+
var known = false;
|
|
2472
|
+
for (var kt = 0; kt < defs.length; kt += 1) if (defs[kt][0] === initialTab) known = true;
|
|
2473
|
+
if (!known) initialTab = "distribution";
|
|
2275
2474
|
selectTab(initialTab);
|
|
2276
2475
|
body.appendChild(tabs);
|
|
2277
2476
|
body.appendChild(panels);
|
|
2477
|
+
/* One口径 note for the whole dialog: both views are estimates over the
|
|
2478
|
+
same logs, and repeating it under each view crowded out the numbers. */
|
|
2479
|
+
body.appendChild(statsDiv("wsr-stats-note wsr-stats-footnote", t("stats.note")));
|
|
2278
2480
|
}
|
|
2279
2481
|
|
|
2280
2482
|
function openStatsPanel(sessionId) {
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import { dirname, join } from "node:path";
|
|
|
32
32
|
export const name = "ws-recency";
|
|
33
33
|
|
|
34
34
|
/** Version marker reported by the health route. */
|
|
35
|
-
export const HOST_VERSION = "0.
|
|
35
|
+
export const HOST_VERSION = "0.29.1";
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Exact routes the client half calls. Registered on the bare web server, so they
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ws-recency",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "Sidebar session management for DeepSeek Harness: workspace groups sorted by latest activity, stale history folded, a global pinned section, follow-up marks, session delete into a recoverable trash, archived sessions managed from that same trash panel, per-session token statistics with an argument/result split and an option to count tool arguments as the agent's writing, moving a session to another workspace, and a literal content search that jumps to the turn a word was said in.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chyxhtc",
|