dsh-message-actions 0.2.1 → 0.2.3
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.cn.md +83 -44
- package/README.md +84 -45
- package/icon.svg +4 -4
- package/lib/client.js +1973 -248
- package/lib/index.js +445 -55
- package/lib/shared.cjs +618 -31
- package/lib/store.cjs +13 -8
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +2 -2
package/README.cn.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DSH 插件 dsh-message-actions
|
|
1
|
+
# DSH 插件 dsh-message-actions
|
|
2
2
|
|
|
3
3
|
[English](README.md) · 中文
|
|
4
4
|
|
|
@@ -17,36 +17,22 @@ DSH 本身没有撤回和删除,发错一句只能重开会话;想把一段
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
## 界面截图
|
|
21
|
-
|
|
22
|
-
**提问行操作按钮、回答下方的统计信息、侧边栏底部的费用卡片**
|
|
23
|
-
|
|
24
|
-

|
|
25
|
-
|
|
26
|
-
**设置 → 消息费用 → 消息操作**
|
|
27
|
-
|
|
28
|
-

|
|
29
|
-
|
|
30
|
-
**设置 → 消息费用 → 费用统计**
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
20
|
## 功能
|
|
37
21
|
|
|
38
22
|
| 功能 | 说明 |
|
|
39
23
|
|---|---|
|
|
40
|
-
| **撤回** |
|
|
24
|
+
| **撤回** | 点一下,整轮问答从会话里消失,原文与图片 / 文件一起回到输入框,改完再发 |
|
|
41
25
|
| **删除** | 问行删整轮问答;工具行删该步内容(同一步的答行 / 其它工具结果会一并遮蔽,其它步骤不受影响) |
|
|
42
26
|
| **删至末尾** | 从这一条起全部清掉,适合把一个话题彻底收尾 |
|
|
43
27
|
| **分享长图** | 全屏勾选想要的轮次,一键生成长图 PNG,本地生成、不上传 |
|
|
44
28
|
| **导出 Markdown** | 同样多选,按轮次导出带「问 / 答」结构的 `.md` |
|
|
45
|
-
| **回答统计** | 每条回答下方显示 `tok ·
|
|
29
|
+
| **回答统计** | 每条回答下方显示 `tok · 字 · ¥0.0023`,体量与这一条自己的估算金额一眼看清 |
|
|
30
|
+
| **确认弹窗** | 撤回 / 删除 / 删至末尾共用紧凑弹窗:宽屏 420px,窄屏贴边满宽,按钮行始终排得下 |
|
|
46
31
|
| **导航同步** | 删除后侧边栏对应刻度自动隐藏并收拢空隙,不留「幽灵条目」 |
|
|
47
32
|
| **费用卡片** | 余额 / 日用 / 单次消耗 一眼看完,有单行 / 多行两套计费样式 |
|
|
33
|
+
| **统计表** | 费用行末尾的小图标打开统计浮层:Token 汇总、24 小时 / 30 天时间线、各会话成本与预算使用,数据来自本机真实会话日志 |
|
|
48
34
|
| **峰谷提示** | 高峰橙、谷价蓝,告诉你现在贵不贵、几点切换 |
|
|
49
|
-
|
|
|
35
|
+
| **余额口径** | 主数字展示账户可用总余额(充值余额 + 赠金),逐钱包截断至分;赠金拆分只在悬停提示,不再单独占行,也不提供手工校正 |
|
|
50
36
|
| **中英双语** | 跟随 DSH 语言,界面与悬浮提示自动切换 |
|
|
51
37
|
| **浮层键盘** | 分享 / 导出浮层内 `Enter` 执行主操作(生成图片 / 导出);确认框内 `Enter` 确认、`Esc` 取消;焦点在输入框内时不拦截,主操作禁用或生成中时不做任何事 |
|
|
52
38
|
|
|
@@ -77,22 +63,69 @@ DSH 本身没有撤回和删除,发错一句只能重开会话;想把一段
|
|
|
77
63
|
|
|
78
64
|
| 项 | 含义 |
|
|
79
65
|
|---|---|
|
|
80
|
-
| 余额 | DeepSeek
|
|
81
|
-
| 日用 |
|
|
66
|
+
| 余额 | DeepSeek 账户可用总余额(人民币充值余额 + 赠金),逐钱包截断至分;赠金已并入主数字,悬停提示给出「含赠金 ¥x」拆分。最短间隔 60 秒刷新一次;点击卡片可强制刷新,不受该间隔限制 |
|
|
67
|
+
| 日用 | 今天(北京时间)的花费:轮次结算时**立即**累加,随后由余额下降观测做差额校正,不会重复计入 |
|
|
82
68
|
| 单次 | 最近一轮消耗的换算金额;默认常驻,可设 0–600 秒后自动隐藏 |
|
|
83
69
|
|
|
84
70
|
- 「单次消耗」按官方价目(`deepseek-flash` / `deepseek-v4-pro`)与实际用量估算;内部记账精度高于界面显示精度,避免很小的费用被舍成 0。
|
|
71
|
+
- **单条回答金额**:每条回答下方的统计行末尾显示这一条自己的估算金额,例如 `240 tok · 18 字 · ¥0.0023`(保留 4 位小数、带 `¥`;不足万分之一元显示 `<¥0.0001`,为 0 显示 `¥0.0000`)。只累计这一条回答自己的 usage,同一轮多步不会重复计价;本地 / 非 DeepSeek 路由显示「本地」。整轮合计仍在侧边栏「单次」,悬停提示会说明两者的区别。
|
|
85
72
|
- 峰谷按北京时间:工作日 `09:00–12:00`、`14:00–18:00` 为高峰,其余为谷价;谷价为高峰的 `0.5` 倍。
|
|
86
|
-
-
|
|
87
|
-
-
|
|
73
|
+
- 「日用」以**轮次结算累加为主**:`turn/end` 落地时立刻按当轮估算金额入桶,与「单次」同一时刻更新;余额观测随后只补「实际下降 − 已结算」的差额,估算偏高时不做减法,因此不会把同一轮计两次。
|
|
74
|
+
- 余额上升(充值 / 退款)时不会冲减已记消费,也不保留任何手工校正;下一次观测只把基准移到新余额。
|
|
75
|
+
- 余额全程以**分**为整数解析与展示,不做元级四舍五入。主数字取**充值余额 + 赠金**,每个钱包都与官方一样截断至分后相加,因此原始字符串 `5.999…` 显示为 `¥5.99`,不会变成 `¥6.00`;赠金拆分只在悬停提示,不再单独占行。
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 统计表
|
|
80
|
+
|
|
81
|
+
侧边栏费用行(`余额 ¥6.02 | 日用 ¥0.00 | 单次`)的**末尾**有一个小图表图标:悬停显示「统计表」,点击打开统计浮层。也可以在 **设置 → dsh-message-actions → 费用统计** 标签页中,点「峰谷定价行」下方的「打开统计表」按钮打开;该按钮不再有开关,费用卡片显示时图标始终可用。
|
|
82
|
+
|
|
83
|
+
- 数据来自**本机真实会话日志**,通过宿主的官方 `sessionQuery` 读取;与「单次」用的是同一批 `assistant/message` usage 记录,因此 token、成本与费用卡片同口径。
|
|
84
|
+
- **第一行四张卡**:总 Token 消耗(含缓存命中占比)、会话数量(含运行中数量)、**预算**(金额 + 进度条)、**预算使用**(百分比 + 剩余)。
|
|
85
|
+
- **第二行四张卡**:余额、日用、单次、**估算成本**,与上方指标卡同尺寸、同圆角、同字号层级。**预算卡**显示预算金额,副行是「剩余 ¥x · 已用 y%」,金额右侧是「修改预算」紧凑小按钮(25px 高、`0 9px` 内边距、11.5px 字、6px 圆角、主色填充),不会比金额更抢眼;点金额仍可直接编辑。编辑态为一行不换行、统一 `gap:7px`:`[¥ 92px 输入框(最窄 64px、13px 字、2×6 内边距)] [保存] [取消]`,保存与取消均为 25px 小按钮(取消为次级描边),回车保存、Esc 取消;卡片宽度 ≤181px 时由容器查询把间距收到 4px、按钮内边距收到 5px / 4px,整行约 135px,仍在 136px 内容宽内不换行;预算说明压成一行 10px 小字、超出省略号,不换行撑高卡片。余额 / 日用 / 单次三张卡与侧边栏费用卡片使用同一状态数据与格式化函数,三个数字逐字一致。窄窗口自动折成 2×2,第 1–2 / 3–4 张一行、第 5–6 / 7–8 张一行,不挤压变形。
|
|
86
|
+
- **计费口径**:只有 **DeepSeek 官方模型**计费。本地 / 非 DeepSeek 路由(ollama、localhost、自定义网关)产生的 token 仍照常统计,但成本记 `0`,不进入「估算成本」「预算使用」与「日用」。时间线每根柱子下方另加一条 3px **计费细条**:深蓝 = DeepSeek 计费,中性灰 = 本地不计费——四色分类已占用蓝色系,所以不改分类色,而是叠加一层独立编码;这份计费说明与四色图例「输入 / 缓存命中 / 缓存写入 / 输出」在**同一行**,四色居左、计费居右(`space-between` 右对齐,同为 11px 字),宽度不足时两组整体换行、不重叠不错位。会话表中纯本地会话的成本列显示「本地 · 不计费」而不是 `¥0.00`,合计同步排除;面板底部用一句话说明该规则。
|
|
87
|
+
- **时间线**:近 24 小时 / 近 30 天,按输入 / 缓存命中 / 缓存写入 / 输出分类,带图例、计费细条与峰值标注。
|
|
88
|
+
- **会话表**:会话名、tokens、成本、更新时间;运行中与子会话有标记,按用量从大到小排序,纯本地会话成本列显示「本地」。
|
|
89
|
+
- **预算**:点预算卡的「修改预算」(或直接点金额)进入编辑态(人民币,默认 ¥5,填 `0` 不显示占比、只显示估算成本),写入与费用统计相同的 `cost-state.json`;旧状态文件没有该字段时自动按 ¥5 兜底。预算**只用于计算「预算使用」占比与剩余额度**,用来提示本期花了多少;不参与计费,也不影响余额与单次换算。
|
|
90
|
+
- 估算成本使用与「单次」相同的官方价目与峰谷规则,且只对 DeepSeek 官方模型计价。底部另有一行对照:费用卡片的「日用」与「累计观测」来自余额下降,口径不同,只作参考。
|
|
91
|
+
- `Esc` 关闭浮层,打开者重新获得焦点,初始焦点在关闭按钮上——与分享 / 导出浮层一致。
|
|
92
|
+
|
|
93
|
+
CPU、进程内存、系统负载与运行时间**不并入**:本插件只关心消息与费用。
|
|
88
94
|
|
|
89
95
|
---
|
|
90
96
|
|
|
91
97
|
## 安装
|
|
92
98
|
|
|
93
|
-
###
|
|
99
|
+
### 从插件市场安装
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
1. 插件 → **插件市场** 标签 → 搜索框输入 `dsh-message-actions`。
|
|
102
|
+
2. 卡片右侧点「安装」;装好后同一张卡片显示「已安装」徽标。
|
|
103
|
+
|
|
104
|
+
### 添加插件(按包名)
|
|
105
|
+
|
|
106
|
+
1. 插件 → 右上角 **+ 添加插件**。
|
|
107
|
+
2. 输入 `dsh-message-actions`;默认源慢时,「安装源」选 **中国大陆镜像源**。
|
|
108
|
+
3. 点「安装」。已装时会提示「该插件已安装,如需升级,请卸载后重新安装」。
|
|
109
|
+
|
|
110
|
+
### 从 npm 安装
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm install dsh-message-actions
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
已发布包为 `dsh-message-actions@0.2.3`。
|
|
117
|
+
|
|
118
|
+
### 自建市场索引源(可选)
|
|
119
|
+
|
|
120
|
+
市场未收录或想固定来源时,可以添加本插件自己的索引:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/market/index.json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
1. 插件 → **实验性插件** → 更多 → 打开 **自定义插件市场**。
|
|
127
|
+
2. 插件 → **发现** → **添加索引源** → 粘贴上面的 URL。
|
|
128
|
+
3. 搜索 `dsh-message-actions`,确认来源是 npm 包与注册表,安装后重启 DSH。
|
|
96
129
|
|
|
97
130
|
### 本地安装
|
|
98
131
|
|
|
@@ -120,26 +153,25 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
120
153
|
|
|
121
154
|
1. 鼠标悬停在任意**提问**上,右侧出现:撤回、分享、导出、删除、删至末尾。
|
|
122
155
|
2. 鼠标悬停在**工具调用行**上,右侧出现「删除该工具行」;删除的是该 `(turn, step)` 的节点集合——同一步的答行 / 其它工具结果会一并消失,其它步骤不受影响。
|
|
123
|
-
3. 每条**回答**下方显示 `tok ·
|
|
124
|
-
4.
|
|
156
|
+
3. 每条**回答**下方显示 `tok · 字 · ¥0.0023`,最后一段是这一条回答自己的估算金额(本地路由显示「本地」)。
|
|
157
|
+
4. 撤回与删除类操作默认弹出确认框(宽屏 420px 紧凑面板,窄屏贴边满宽,三个入口一致);关闭「操作确认」后直接执行;确认后对应内容消失,侧边栏刻度同步隐藏。
|
|
125
158
|
5. 分享 / 导出打开全屏选择面板,每张卡片显示该轮的「问」与「答」预览,可单选、多选或全选;生成时再按需拉取完整原文。拉全文或生成图片 / 文件失败时会提示,并**保留面板与已选轮次**方便重试,只有成功下载才关闭。
|
|
126
159
|
6. 生成回复期间所有按钮置灰,避免与运行中的会话冲突;极端竞态下的写入仍会返回 `423 AGENT_BUSY`。
|
|
127
160
|
|
|
128
|
-
###
|
|
161
|
+
### 余额口径
|
|
129
162
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
校正后余额 = 基线 − 已观测消费 + 实际累计到账 − 非调用扣减
|
|
134
|
-
```
|
|
163
|
+
卡片上的「余额」直接读取 DeepSeek 账户服务,展示**可用总余额**:
|
|
135
164
|
|
|
136
|
-
|
|
165
|
+
- 主数字 = **充值余额(CNY 钱包)+ 赠金 / 奖金钱包(`bonusWallets`)**,每个钱包按官方规则截断至分后相加:原始余额 `5.999…` 显示 `¥5.99`,不会进位成 `¥6.00`。
|
|
166
|
+
- 赠金**已并入主数字**,不再单独拆行;悬停提示给出「含赠金 ¥x」的拆分,便于和官方「赠金余额」那一行对照。
|
|
167
|
+
- 「日用」按同一总额的下降观测,因此余额显示与记账基准一致。
|
|
168
|
+
- **不再提供手工校正**:充值 / 退款只会把观测基准移到新余额,不存在被手工输入悄悄覆盖的可能。设置页保留一段简短口径说明。
|
|
137
169
|
|
|
138
170
|
---
|
|
139
171
|
|
|
140
172
|
## 设置
|
|
141
173
|
|
|
142
|
-
设置 → 插件 →
|
|
174
|
+
设置 → 插件 → **dsh-message-actions**,页内两个标签,改动**即时保存并立即生效**。
|
|
143
175
|
|
|
144
176
|
**消息操作**
|
|
145
177
|
|
|
@@ -151,7 +183,9 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
151
183
|
| 删除 | 提问行删除整轮问答;工具行删除该步工具结果 |
|
|
152
184
|
| 删至末尾 | 提问行显示「删至末尾」 |
|
|
153
185
|
| 操作确认 | 撤回与删除类操作是否弹确认框 |
|
|
154
|
-
| 回答统计 | 回答下方是否显示 `tok ·
|
|
186
|
+
| 回答统计 | 回答下方是否显示 `tok · 字 · 金额` |
|
|
187
|
+
| 提示音音色 | 默认双音 / 短铃 / 轻提示 / 关闭;选中即开启并试听,选「关闭」即关闭完成提示音(没有独立开关行) |
|
|
188
|
+
| 音量 | 0–100 滑杆(默认 50,步进 5):作用于全部音色,0% 静音、50% 为标准音量、100% 为两倍;拖动时数字实时跟手但不写配置,松手(或键盘抬起 / 失焦 / 拖动结束)后一次性保存并试听一次 |
|
|
155
189
|
|
|
156
190
|
**费用统计**
|
|
157
191
|
|
|
@@ -162,7 +196,8 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
162
196
|
| 单次消耗 | 每轮结束后显示本轮金额;关闭后不再渲染该组 |
|
|
163
197
|
| 自动关闭 | 本轮金额显示秒数(0–600,0 = 常驻) |
|
|
164
198
|
| 峰谷定价行 | 显示当前时段与下一次切换时间 |
|
|
165
|
-
|
|
|
199
|
+
| 统计表 | 右侧按钮为「打开统计表」,打开统计浮层;位于峰谷定价行与余额口径说明之间。设置页只写数据用途,预算说明只放在浮层内 |
|
|
200
|
+
| 余额口径 | 主数字 = 充值余额 + 赠金,逐钱包截断至分;赠金拆分只在悬停提示,不单独占行;无手工校正 |
|
|
166
201
|
|
|
167
202
|
---
|
|
168
203
|
|
|
@@ -194,9 +229,12 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
194
229
|
|
|
195
230
|
- 只存一个本地文件:`$DSH_HOME`(默认 `~/.dsh`)下的 `plugins/dsh-message-actions/cost-state.json`。
|
|
196
231
|
- 写入方式是「同目录临时文件(`0600`)→ `fsync` → `rename`」整份替换,避免写一半留下坏文件;目录按 `0700` 创建。
|
|
197
|
-
-
|
|
198
|
-
-
|
|
232
|
+
- 内容只有余额观测、按日消费与预算额度,没有对话正文。
|
|
233
|
+
- 预算保存只在状态文件写成功后才算成功:只读状态文件返回 `500 READ_ONLY`,写盘失败返回 `500 WRITE_FAILED` 并回滚内存值,界面提示「保存失败」而不是假装成功。
|
|
199
234
|
- 文件超过 4MB 会自动重建为默认状态,并记一条含原因与大小的诊断日志;未超限但 JSON 损坏时,原文件改名为 `cost-state.bad-<时间戳>.json` 留档。
|
|
235
|
+
- 结算完成即推送:客户端用 `wait=<lastTurn.at>` 的长轮询(最长 10 秒)挂在 `/cost/state` 上,宿主处理 `turn/end` 后立刻返回,单次费用不用等下一次 5 秒轮询;提示音在同一次状态更新里触发,和数字同时出现。
|
|
236
|
+
- 提示音由客户端用 Web Audio 现场合成,不加载音频文件、不联网、不写状态文件;默认双音 880→660Hz 基准音量 0.18,短铃为三角波,轻提示为单音 523Hz。基准增益乘以音量倍数(50% = 1×,100% = 2×),0% 直接不发声。同一轮只响一次。
|
|
237
|
+
- 浏览器要求至少一次用户交互后才能发声:插件加载时会挂一次 `pointerdown` / `keydown` 监听提前解锁 `AudioContext`;若播放时仍被挂起,会在 `resume()` 成功后静默重试一次,不弹提示。设置页选中音色会立即试听;音量滑杆只在提交时(松手 / 键盘抬起 / 失焦 / 拖动结束,120ms 防抖)按当前音量试听一次,拖动过程中不播放。
|
|
200
238
|
|
|
201
239
|
**网络**
|
|
202
240
|
|
|
@@ -223,13 +261,13 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
223
261
|
|
|
224
262
|
```bash
|
|
225
263
|
node build.mjs # 构建到 lib/
|
|
226
|
-
node test/check.mjs # 离线断言,当前
|
|
264
|
+
node test/check.mjs # 离线断言,当前 2909 项
|
|
227
265
|
# 另有真实会话日志回归:18/18
|
|
228
266
|
```
|
|
229
267
|
|
|
230
268
|
```
|
|
231
269
|
src/
|
|
232
|
-
├── index.mjs # 宿主:Config +
|
|
270
|
+
├── index.mjs # 宿主:Config + HTTP 路由 + 费用 / 会话统计服务
|
|
233
271
|
├── client.js # 客户端:槽位、DOM 注入、分享 / 导出浮层、费用卡片
|
|
234
272
|
├── shared.cjs # 宿主与客户端共用的纯函数(可离线测试)
|
|
235
273
|
├── store.cjs # 费用状态文件原子读写、损坏恢复
|
|
@@ -239,8 +277,9 @@ test/check.mjs # 无依赖的断言脚本
|
|
|
239
277
|
```
|
|
240
278
|
|
|
241
279
|
|
|
242
|
-
- 版本:`0.2.
|
|
243
|
-
-
|
|
280
|
+
- 版本:`0.2.3`(npm 与 GitHub Release 均已发布)
|
|
281
|
+
- 发布说明:[v0.2.3](https://github.com/aijacko/dsh-message-actions/releases/tag/v0.2.3)
|
|
282
|
+
- 兼容:DSH `0.2.1-rc.5` 与 `0.2.2-rc.1`;`0.2.2-rc.1`(web profile)已实测,旧版走 portal 探测失败回退
|
|
244
283
|
- 依赖:无运行时第三方依赖
|
|
245
284
|
|
|
246
285
|
---
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# DSH plugin dsh-message-actions
|
|
1
|
+
# DSH plugin dsh-message-actions
|
|
2
2
|
|
|
3
3
|
English · [中文](README.cn.md)
|
|
4
4
|
|
|
@@ -17,36 +17,22 @@ Features you don't use can be turned off in settings. Turn off cost statistics,
|
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
|
-
## Screenshots
|
|
21
|
-
|
|
22
|
-
**Actions on the question row, reply statistics under answers, and the cost card at the bottom of the sidebar**
|
|
23
|
-
|
|
24
|
-

|
|
25
|
-
|
|
26
|
-
**Settings → Messages & Cost → Message Actions**
|
|
27
|
-
|
|
28
|
-

|
|
29
|
-
|
|
30
|
-
**Settings → Messages & Cost → Cost Statistics**
|
|
31
|
-
|
|
32
|
-

|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
20
|
## Features
|
|
37
21
|
|
|
38
22
|
| Feature | What it does |
|
|
39
23
|
|---|---|
|
|
40
|
-
| **Recall** | One click removes the whole exchange from the session and restores the original text to the composer, ready to resend |
|
|
24
|
+
| **Recall** | One click removes the whole exchange from the session and restores the original text plus image / file attachments to the composer, ready to resend |
|
|
41
25
|
| **Delete** | Question row deletes the whole exchange; tool row deletes that step (the answer and other tool results in the same step are hidden too, other steps are unaffected) |
|
|
42
26
|
| **Delete to end** | Removes everything from this message to the end, for closing off a topic |
|
|
43
27
|
| **Share as image** | Pick the turns you want in a full-screen overlay and generate a long PNG, generated locally, never uploaded |
|
|
44
28
|
| **Export Markdown** | Same selection, exports a `.md` with question / answer structure per turn |
|
|
45
|
-
| **Reply statistics** | `tok · chars` under every answer
|
|
29
|
+
| **Reply statistics** | `tok · chars · ¥0.0023` under every answer — its size and this reply's own estimated cost at a glance |
|
|
30
|
+
| **Confirmation dialog** | Recall / delete / delete-to-end share one compact dialog: 420px on wide screens, edge-to-edge on narrow screens, with the button row always fitting |
|
|
46
31
|
| **Rail sync** | After deletion, the matching sidebar ticks hide and the gaps close, leaving no ghost entries |
|
|
47
32
|
| **Cost card** | Balance / today / per-turn cost at a glance, with single-line and multi-line billing styles |
|
|
33
|
+
| **Statistics** | Small icon at the end of the cost row opens a panel with token totals, a 24 h / 30 d timeline, per-session cost and budget usage, built from real local session logs |
|
|
48
34
|
| **Peak / off-peak hint** | Peak in orange, off-peak in blue, showing whether now is expensive and when it switches |
|
|
49
|
-
| **Balance
|
|
35
|
+
| **Balance scope** | The main figure is the account's **total available balance** (top-up + bonus), each wallet truncated to the cent; bonus is merged into the main figure and broken out in the hover tooltip only, with no manual adjustment layer |
|
|
50
36
|
| **Bilingual UI** | Follows the DSH language; interface and tooltips switch automatically |
|
|
51
37
|
| **Overlay keyboard** | In the share / export overlay, `Enter` runs the primary action (Share image / Export); in a confirmation dialog it confirms, and `Esc` cancels. Enter is ignored while focus is in a text field, and when the primary action is disabled or busy |
|
|
52
38
|
|
|
@@ -77,22 +63,69 @@ New installations default to **single-line**; users who have already saved a pre
|
|
|
77
63
|
|
|
78
64
|
| Item | Meaning |
|
|
79
65
|
|---|---|
|
|
80
|
-
| Bal |
|
|
81
|
-
| Today |
|
|
66
|
+
| Bal | The DeepSeek account **total available balance** (CNY top-up + bonus), each wallet truncated to the cent; bonus is merged into the main figure and broken out as "incl. bonus ¥x" in the hover tooltip. Refreshed at a minimum interval of 60 seconds; clicking the card forces a refresh regardless of that interval |
|
|
67
|
+
| Today | Today's spend (Beijing time): credited **immediately** when a turn settles, then reconciled against balance drops without double counting |
|
|
82
68
|
| Turn | Converted cost of the most recent turn; shown by default, can hide after 0–600 seconds |
|
|
83
69
|
|
|
84
|
-
- "Turn" (per-turn cost) is estimated from official list prices (`deepseek-flash` / `deepseek-v4-pro`) and actual usage; internal accounting is more precise than the UI, so very small costs are not rounded down to zero.
|
|
70
|
+
- "Turn" (per-turn cost) is estimated from official list prices (`deepseek-flash` / `deepseek-v4-pro`) and actual usage; internal accounting is more precise than the UI, so very small costs are not rounded down to zero. Only DeepSeek-routed usage is billed: local models count tokens but add `0` to "Turn" and "Today", and the card collapses to "Local · no billing".
|
|
71
|
+
- **Per-answer cost**: the stats line under each answer ends with that reply's own estimate, e.g. `240 tok · 18 chars · ¥0.0023` (4 decimals with a `¥` prefix; `<¥0.0001` below one ten-thousandth of a yuan, `¥0.0000` at zero). It sums only this reply's usage, so a multi-step turn is not billed twice; local / non-DeepSeek replies show `Local`. The whole-turn total stays in **Turn**, and the hover text explains the difference.
|
|
85
72
|
- Peak / off-peak uses Beijing time: weekdays `09:00–12:00` and `14:00–18:00` are peak, everything else is off-peak; off-peak is `0.5×` the peak price.
|
|
86
|
-
- "Today"
|
|
87
|
-
- When the balance goes up, recorded spend is not reduced
|
|
73
|
+
- "Today" is **settlement-first**: `turn/end` immediately credits the estimated cents to today's bucket, at the same moment as "Turn". Balance observations then only add `actual drop − already settled`; when the estimate is higher than reality nothing is subtracted, so the same turn is never counted twice.
|
|
74
|
+
- When the balance goes up (top-up / refund), recorded spend is not reduced and no manual correction is kept; the next observation simply moves the baseline.
|
|
75
|
+
- Money is parsed and displayed in integer **cents**, never rounded at the yuan level. The main figure is **top-up + bonus**, with each wallet **truncated to the cent** exactly like the official page, so a raw `5.999…` shows as `¥5.99`, not `¥6.00`. Bonus is merged into the main figure and only broken out in the tooltip, not on a separate line.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Statistics
|
|
80
|
+
|
|
81
|
+
A small chart icon sits at the **end of the sidebar cost row** (`Bal ¥6.02 | Today ¥0.00 | Turn`); hovering it shows "Statistics", clicking opens a full-screen overlay. It can also be opened from **Settings → dsh-message-actions → Cost Statistics** via the **Open stats table** button between the peak/off-peak row and the account-scope note; there is no separate toggle, and the icon is always available while the cost card is shown.
|
|
82
|
+
|
|
83
|
+
- Data comes from the **real local session logs** through the host's official `sessionQuery` service — the same assistant usage records that feed the per-turn figure — so tokens, cost and the card agree.
|
|
84
|
+
- **First row, four cards**: total tokens (with cache-hit share), session count (with running count), **budget** (amount + progress bar), **budget usage** (percent + remaining).
|
|
85
|
+
- **Second row, four cards**: balance, today, turn, **estimated cost**, at the same size, radius and type scale as the KPI cards. The **budget card** shows the amount with "Left ¥x · used y%" underneath and a compact **Edit budget** button (25 px height, `0 9px` padding, 11.5 px label, 6 px radius, filled primary) at the right end of the amount row, so it never dominates the figure; clicking the amount still edits in place. The edit state is one no-wrap row with a uniform `gap:7px`: a 92 px input (shrinkable to 64 px, 13 px text, 2×6 px padding) with `¥` / `CNY` affixes, a 25 px **Save** and a 25 px outlined **Cancel**; Enter saves and Esc cancels. Below a ~181 px card width a container query tightens the gap to 4 px and the button paddings to 5 px / 4 px, so the row measures ≈135 px and still fits the 136 px content width of the narrowest card without wrapping. The one-line budget note truncates with an ellipsis instead of wrapping, so the card keeps the same height as its siblings. **Balance / today / turn** are the same state and formatters as the sidebar cost card, so the three figures match character for character. On narrow windows the row wraps to 2×2 with cards 1–2 / 3–4 and 5–6 / 7–8 per line.
|
|
86
|
+
- **Billing scope**: only **official DeepSeek models** are billed. Usage from local / non-DeepSeek providers (ollama, localhost endpoints, custom gateways) still counts toward tokens, but its cost is `0` and it is excluded from estimated cost, budget usage and the daily figure. The timeline adds a separate 3 px **billing bar** under each column — deep blue for DeepSeek-billed tokens, neutral gray for local unbilled tokens — because the four token-category colors already use blue (so the billing split is an additive encode, not a recolor). Its legend now shares the **same row** as the four-colour legend: categories on the left, billing scope right-aligned (`space-between`, same 11 px type); if the row cannot fit both, they wrap as two whole groups instead of overlapping. Local-only session rows show **Local · unbilled** instead of `¥0.00`, and their cost is excluded from the total; the panel note states the rule explicitly.
|
|
87
|
+
- **Timeline**: last 24 hours / last 30 days, split by input / cache hit / cache write / output; legend, billing bar and peak marker included.
|
|
88
|
+
- **Session table**: name, tokens, cost, last updated; running sessions and subagent sessions are tagged, sorted by token usage; local-only sessions show **Local** in the cost column.
|
|
89
|
+
- **Budget**: click **Edit budget** on the budget card (or the amount itself) to edit (CNY, default ¥5, `0` hides the ratio and shows only the estimate). It is saved into the same `cost-state.json` as the rest of the cost data; old state files without the field fall back to ¥5. The budget **only computes the "budget used" ratio and remaining allowance** as a spending hint; it never bills you and does not affect the balance or per-turn figures.
|
|
90
|
+
- The estimate uses the same official prices and peak / off-peak rules as the per-turn figure. A small cross-check line shows the card's "today" and observed total, since those come from balance drops and use a different basis.
|
|
91
|
+
- `Esc` closes the overlay, the opener regains focus, and focus starts on the close button — same behaviour as the share / export overlays.
|
|
92
|
+
|
|
93
|
+
CPU, process memory, system load and uptime are deliberately **not** included; this plugin is about messages and cost.
|
|
88
94
|
|
|
89
95
|
---
|
|
90
96
|
|
|
91
97
|
## Installation
|
|
92
98
|
|
|
93
|
-
###
|
|
99
|
+
### Install from the plugin marketplace
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
1. Plugins → **Plugin marketplace** tab → type `dsh-message-actions` in the search box.
|
|
102
|
+
2. Click **Install** on the card. Once installed, the card shows the **Installed** badge.
|
|
103
|
+
|
|
104
|
+
### Add the plugin by package name
|
|
105
|
+
|
|
106
|
+
1. Plugins → **+ Add plugin** (top right).
|
|
107
|
+
2. Enter `dsh-message-actions`; if the default registry is slow, choose **Mainland China mirror** as the install source.
|
|
108
|
+
3. Click **Install**. If it is already installed, DSH tells you: "This plugin is already installed. To upgrade, uninstall and reinstall it."
|
|
109
|
+
|
|
110
|
+
### Install from npm
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm install dsh-message-actions
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The published package is `dsh-message-actions@0.2.3`.
|
|
117
|
+
|
|
118
|
+
### Self-hosted market index source (optional)
|
|
119
|
+
|
|
120
|
+
The plugin also has its own market index, useful when a marketplace does not list it or you want a pinned source:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/market/index.json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
1. Plugins → **Experimental plugins** → More → turn on **Custom plugin marketplace**.
|
|
127
|
+
2. Plugins → **Discover** → **Add index source** → paste the URL above.
|
|
128
|
+
3. Search `dsh-message-actions`, check that the source is the npm package and registry, install, then restart DSH.
|
|
96
129
|
|
|
97
130
|
### Local install
|
|
98
131
|
|
|
@@ -120,26 +153,25 @@ pnpm add "file:/path/to/dsh-message-actions"
|
|
|
120
153
|
|
|
121
154
|
1. Hover over any **question** row: Recall, Share, Export, Delete, Delete to end appear on the right.
|
|
122
155
|
2. Hover over a **tool-call row**: "Delete tool" appears on the right; it deletes the node set for that `(turn, step)` — the answer and other tool results in the same step disappear too; other steps are unaffected.
|
|
123
|
-
3. Under every **answer**, `tok · chars` is shown.
|
|
124
|
-
4. Recall and delete actions ask for confirmation by default; turn off "Confirm actions" to run them immediately. After confirming, the content disappears and the sidebar ticks hide in sync.
|
|
156
|
+
3. Under every **answer**, `tok · chars · ¥0.0023` is shown; the last segment is that reply's own estimated cost (`Local` for non-DeepSeek routes).
|
|
157
|
+
4. Recall and delete actions ask for confirmation by default, using one compact 420px dialog on wide screens and an edge-to-edge dialog on narrow screens; turn off "Confirm actions" to run them immediately. After confirming, the content disappears and the sidebar ticks hide in sync.
|
|
125
158
|
5. Share / export opens a full-screen picker; each card shows the question and answer preview for that turn, and you can select one, several, or all; full text is fetched only when you generate. If fetching full text or generating the image / file fails, a toast appears and the picker **stays open with your selection**, so you can retry; it closes only after a successful download.
|
|
126
159
|
6. While a reply is being generated, all buttons are disabled to avoid conflicting with the running session; a write that still races the agent returns `423 AGENT_BUSY`.
|
|
127
160
|
|
|
128
|
-
### Balance
|
|
161
|
+
### Balance scope
|
|
129
162
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
Corrected balance = baseline − observed spend + total credited − non-usage deductions
|
|
134
|
-
```
|
|
163
|
+
The card's **Bal** is read directly from the DeepSeek account service and shows the **total available balance**:
|
|
135
164
|
|
|
136
|
-
|
|
165
|
+
- Main figure = **top-up balance (CNY wallets) + bonus / reward wallets (`bonusWallets`)**, each wallet **truncated to the cent** exactly like the official page: a raw `5.999…` renders `¥5.99`, not `¥6.00`.
|
|
166
|
+
- Bonus is **merged into the main figure**, not split onto its own line; the hover tooltip breaks it out as "incl. bonus ¥x" so it can still be compared with the official **Bonus balance** row.
|
|
167
|
+
- "Today" observes drops in that same total, so the displayed balance and the accounting basis agree.
|
|
168
|
+
- There is **no manual correction layer**: top-ups and refunds simply move the observed baseline, and nothing typed can silently override the figure. The settings page keeps a short note explaining this scope.
|
|
137
169
|
|
|
138
170
|
---
|
|
139
171
|
|
|
140
172
|
## Settings
|
|
141
173
|
|
|
142
|
-
Settings → Plugins → **
|
|
174
|
+
Settings → Plugins → **dsh-message-actions**; the page has two tabs, and changes **save immediately and apply right away**.
|
|
143
175
|
|
|
144
176
|
**Message Actions**
|
|
145
177
|
|
|
@@ -151,7 +183,9 @@ Settings → Plugins → **Messages & Cost**; the page has two tabs, and changes
|
|
|
151
183
|
| Delete | Question row deletes the whole exchange; tool row deletes that step's tool results |
|
|
152
184
|
| Delete to end | Show "Delete to end" on question rows |
|
|
153
185
|
| Confirm actions | Whether recall and delete actions ask for confirmation |
|
|
154
|
-
| Reply statistics | Whether `tok · chars` is shown under answers |
|
|
186
|
+
| Reply statistics | Whether `tok · chars · cost` is shown under answers |
|
|
187
|
+
| Completion tone | Default double / bell / soft / off; picking one turns the chime on and previews it, "Off" turns the completion sound off (there is no separate switch row) |
|
|
188
|
+
| Volume | 0–100 slider (default 50, step 5): applies to all tones — 0% mutes, 50% is normal, 100% is double. The number follows the drag without writing config; on release (or key up / blur / native change) it saves once and previews once |
|
|
155
189
|
|
|
156
190
|
**Cost Statistics**
|
|
157
191
|
|
|
@@ -162,7 +196,8 @@ Settings → Plugins → **Messages & Cost**; the page has two tabs, and changes
|
|
|
162
196
|
| Per-turn | Show the cost of each finished turn; when off, don't render that group |
|
|
163
197
|
| Auto-hide | Seconds before the turn cost hides (0–600, 0 = always) |
|
|
164
198
|
| Peak/off-peak | Show the current pricing period and the next switch |
|
|
165
|
-
|
|
|
199
|
+
| Statistics | The button reads "Open stats table" and opens the overlay; sits between the peak/off-peak row and the account-scope note. The settings row describes only what the data is; the budget note lives inside the overlay only |
|
|
200
|
+
| Balance scope | Main figure = top-up + bonus, each wallet truncated to the cent; bonus broken out in the tooltip only, not on its own line; no manual correction |
|
|
166
201
|
|
|
167
202
|
---
|
|
168
203
|
|
|
@@ -194,9 +229,12 @@ This section only describes what the code actually does. It is risk reduction, n
|
|
|
194
229
|
|
|
195
230
|
- Only one local file: `cost-state.json` under `$DSH_HOME` (default `~/.dsh`), in `plugins/dsh-message-actions/`.
|
|
196
231
|
- Writes are a whole-file replacement: temp file in the same directory (`0600`) → `fsync` → `rename`, so a half-written file can't be left behind; the directory is created with `0700`.
|
|
197
|
-
- Contents are only balance observations,
|
|
198
|
-
-
|
|
232
|
+
- Contents are only balance observations, per-day spend and the budget; no conversation text.
|
|
233
|
+
- Budget writes report success only after the state file is written: a read-only state file returns `500 READ_ONLY`, a failed write returns `500 WRITE_FAILED` and rolls the in-memory value back, so the UI shows "save failed" instead of a false success.
|
|
199
234
|
- A file over 4MB is rebuilt as the default state and logged with the reason and size; a corrupt file under the limit is renamed to `cost-state.bad-<timestamp>.json` and kept.
|
|
235
|
+
- Settlement is pushed: the client long-polls `/cost/state` with `wait=<lastTurn.at>` (up to 10 seconds), and the host answers as soon as `turn/end` is processed, so the per-turn cost does not wait for the next 5-second poll; the chime fires in the same state update as the number.
|
|
236
|
+
- The chime is synthesised in the client with Web Audio; no audio file, no network request, no state file. Default double tone is 880→660 Hz sine at a base gain of 0.18, bell uses triangle waves, soft is a single 523 Hz note. The base gain is multiplied by the volume factor (50% = 1×, 100% = 2×) and 0% stays completely silent. It plays once per turn.
|
|
237
|
+
- Browsers require at least one user gesture before audio: the plugin installs `pointerdown` / `keydown` listeners at load time to unlock the `AudioContext` early. If playback still finds it suspended, it retries once silently after `resume()`; no toast. Picking a tone in Settings previews it immediately; the volume slider previews once on commit only (release / key up / blur / end of drag, debounced 120 ms) and stays silent during the drag.
|
|
200
238
|
|
|
201
239
|
**Network**
|
|
202
240
|
|
|
@@ -223,13 +261,13 @@ This section only describes what the code actually does. It is risk reduction, n
|
|
|
223
261
|
|
|
224
262
|
```bash
|
|
225
263
|
node build.mjs # build to lib/
|
|
226
|
-
node test/check.mjs # offline assertions,
|
|
264
|
+
node test/check.mjs # offline assertions, 2909 currently
|
|
227
265
|
# plus a real session-log regression: 18/18
|
|
228
266
|
```
|
|
229
267
|
|
|
230
268
|
```
|
|
231
269
|
src/
|
|
232
|
-
├── index.mjs # host: Config +
|
|
270
|
+
├── index.mjs # host: Config + HTTP routes + cost / session-stats services
|
|
233
271
|
├── client.js # client: slots, DOM injection, share / export overlay, cost card
|
|
234
272
|
├── shared.cjs # pure functions shared by host and client (offline testable)
|
|
235
273
|
├── store.cjs # cost state file: atomic read/write, recovery on corrupt files
|
|
@@ -239,8 +277,9 @@ test/check.mjs # dependency-free assertion script
|
|
|
239
277
|
```
|
|
240
278
|
|
|
241
279
|
|
|
242
|
-
- Version: `0.2.
|
|
243
|
-
-
|
|
280
|
+
- Version: `0.2.3` (published on both npm and GitHub Releases)
|
|
281
|
+
- Release: [v0.2.3](https://github.com/aijacko/dsh-message-actions/releases/tag/v0.2.3)
|
|
282
|
+
- Compatible with: DSH `0.2.1-rc.5` and `0.2.2-rc.1`; `0.2.2-rc.1` (web profile) verified, older hosts take the portal fallback
|
|
244
283
|
- Dependencies: none at runtime
|
|
245
284
|
|
|
246
285
|
---
|
package/icon.svg
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
|
|
2
|
-
<rect x="4" y="4" width="56" height="56" rx="13" fill="#
|
|
3
|
-
<path d="
|
|
4
|
-
<path d="
|
|
5
|
-
</svg>
|
|
2
|
+
<rect x="4" y="4" width="56" height="56" rx="13" fill="#2563eb"/>
|
|
3
|
+
<path d="M20 15h24a9 9 0 0 1 9 9v10a9 9 0 0 1-9 9H31l-9 8v-8h-2a9 9 0 0 1-9-9V24a9 9 0 0 1 9-9z" fill="#ffffff"/>
|
|
4
|
+
<path d="M26 23l6 7 6-7M32 30v11M27.5 35h9M27.5 39h9" fill="none" stroke="#2563eb" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|