dsh-message-actions 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 aijacko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.cn.md ADDED
@@ -0,0 +1,289 @@
1
+ # DSH 插件 dsh-message-actions
2
+
3
+ [English](README.md) · 中文
4
+
5
+ ## 简介
6
+
7
+ **让 DSH 的每一轮对话都可控、可分享、可计量。**
8
+
9
+ DSH 本身没有撤回和删除,发错一句只能重开会话;想把一段对话发给别人,也得自己复制排版。部分插件功能堆得重、数据去向不透明,于是干脆自己写一个:需要的功能都有,能不碰的数据就不碰。
10
+
11
+ - 发错消息:鼠标移到提问行点「撤回」,整轮问答消失,原文回到输入框,改完再发。
12
+ - 想清掉跑偏的探索:问行「删除」删整轮;只去掉某一步的工具调用,就点该工具行右侧的垃圾桶。
13
+ - 想分享给同事:多选轮次,导出 Markdown 或生成长图 PNG,都在本地完成、不上传。
14
+ - 想知道刚才那轮花了多少:侧边栏显示余额 / 日用 / 单次消耗(卡片上简写为「单次」);本地模型自动收起为「本地模型 · 无需计费」。
15
+
16
+ 用不上的功能可以在设置里关闭。比如关掉费用统计后,插件会停止余额取数与记账,也不再渲染侧边栏卡片;删除、分享、导出等开关同理,关掉后对应入口与动作都不再出现。它不常驻面板、不弹更新提示、不发系统通知,也不会改写你的提问;分享 / 导出会打开临时全屏选择浮层,撤回 / 删除会按设置弹出确认框,都是正常交互。
17
+
18
+ ---
19
+
20
+ ## 功能
21
+
22
+ | 功能 | 说明 |
23
+ |---|---|
24
+ | **撤回** | 点一下,整轮问答从会话里消失,原文与图片 / 文件一起回到输入框,改完再发 |
25
+ | **删除** | 问行删整轮问答;工具行删该步内容(同一步的答行 / 其它工具结果会一并遮蔽,其它步骤不受影响) |
26
+ | **删至末尾** | 从这一条起全部清掉,适合把一个话题彻底收尾 |
27
+ | **分享长图** | 全屏勾选想要的轮次,一键生成长图 PNG,本地生成、不上传 |
28
+ | **导出 Markdown** | 同样多选,按轮次导出带「问 / 答」结构的 `.md` |
29
+ | **回答统计** | 每条回答下方显示 `tok · 字 · ¥0.0023`,体量与这一条自己的估算金额一眼看清 |
30
+ | **确认弹窗** | 撤回 / 删除 / 删至末尾共用紧凑弹窗:宽屏 420px,窄屏贴边满宽,按钮行始终排得下 |
31
+ | **导航同步** | 删除后侧边栏对应刻度自动隐藏并收拢空隙,不留「幽灵条目」 |
32
+ | **费用卡片** | 余额 / 日用 / 单次消耗 一眼看完,有单行 / 多行两套计费样式 |
33
+ | **统计表** | 费用行末尾的小图标打开统计浮层:Token 汇总、24 小时 / 30 天时间线、各会话成本与预算使用,数据来自本机真实会话日志 |
34
+ | **峰谷提示** | 高峰橙、谷价蓝,告诉你现在贵不贵、几点切换 |
35
+ | **余额口径** | 主数字展示账户可用总余额(充值余额 + 赠金),逐钱包截断至分;赠金拆分只在悬停提示,不再单独占行,也不提供手工校正 |
36
+ | **中英双语** | 跟随 DSH 语言,界面与悬浮提示自动切换 |
37
+ | **浮层键盘** | 分享 / 导出浮层内 `Enter` 执行主操作(生成图片 / 导出);确认框内 `Enter` 确认、`Esc` 取消;焦点在输入框内时不拦截,主操作禁用或生成中时不做任何事 |
38
+
39
+ 删除采用的是**墓碑式表面替换**:只追加一条标记并遮蔽原区间,不改写历史日志,也不影响其他会话。标记持久化在会话事件日志里,因此刷新页面、切换到其它对话再切回、以及重启 DSH 后,被删内容都不会重新出现。`/messages` 与 `full=1` 都会按墓碑重算可见节点,而不是只相信宿主表面。
40
+
41
+ ---
42
+
43
+ ## 费用卡片
44
+
45
+ **单行样式**(默认,无背景、单行居左):
46
+
47
+ ```
48
+ ▲ 余额 ¥6.00 日用 ¥0.08 单次 ¥0.02
49
+ ```
50
+
51
+ **多行样式**(带背景卡片与峰谷文字行):
52
+
53
+ ```
54
+ 余额 ¥6.00 日用 ¥0.08 单次 ¥0.02
55
+ ▲ 谷价 · 明日 9:00 起高峰
56
+ ```
57
+
58
+ 新安装默认是**单行样式**;已经保存过偏好的用户沿用原来的选择,不会因为改默认值被重置。
59
+
60
+ - 高峰 = 暖橙,谷价 = 冷蓝;14px SVG 状态图标,左侧一眼可辨。
61
+ - 侧边栏收起时自动降级为一个钱币图标,悬停即可看到余额。
62
+ - 本地模型 / 非 DeepSeek 路由自动收起为「本地模型 · 无需计费」,不打扰。
63
+
64
+ | 项 | 含义 |
65
+ |---|---|
66
+ | 余额 | DeepSeek 账户可用总余额(人民币充值余额 + 赠金),逐钱包截断至分;赠金已并入主数字,悬停提示给出「含赠金 ¥x」拆分。最短间隔 60 秒刷新一次;点击卡片可强制刷新,不受该间隔限制 |
67
+ | 日用 | 今天(北京时间)的花费:轮次结算时**立即**累加,随后由余额下降观测做差额校正,不会重复计入 |
68
+ | 单次 | 最近一轮消耗的换算金额;默认常驻,可设 0–600 秒后自动隐藏 |
69
+
70
+ - 「单次消耗」按官方价目(`deepseek-flash` / `deepseek-v4-pro`)与实际用量估算;内部记账精度高于界面显示精度,避免很小的费用被舍成 0。
71
+ - **单条回答金额**:每条回答下方的统计行末尾显示这一条自己的估算金额,例如 `240 tok · 18 字 · ¥0.0023`(保留 4 位小数、带 `¥`;不足万分之一元显示 `<¥0.0001`,为 0 显示 `¥0.0000`)。只累计这一条回答自己的 usage,同一轮多步不会重复计价;本地 / 非 DeepSeek 路由显示「本地」。整轮合计仍在侧边栏「单次」,悬停提示会说明两者的区别。
72
+ - 峰谷按北京时间:工作日 `09:00–12:00`、`14:00–18:00` 为高峰,其余为谷价;谷价为高峰的 `0.5` 倍。
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、进程内存、系统负载与运行时间**不并入**:本插件只关心消息与费用。
94
+
95
+ ---
96
+
97
+ ## 安装
98
+
99
+ ### 从插件市场安装
100
+
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.4`。
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。
129
+
130
+ ### 本地安装
131
+
132
+ ```bash
133
+ git clone <repository-url> dsh-message-actions
134
+ cd dsh-message-actions
135
+ node build.mjs # 生成 lib/
136
+ node test/check.mjs # 应输出 ALL CHECKS PASSED
137
+ ```
138
+
139
+ 把构建后的目录装进 DSH profile:
140
+
141
+ ```bash
142
+ pnpm add "file:/path/to/dsh-message-actions"
143
+ ```
144
+
145
+ - `pnpm add file:` 是**复制**语义:改代码后需卸载重装(或加 `--force`)。
146
+ - 宿主侧改动(`src/index.mjs`、Config)需重启 DSH;纯客户端改动可「禁用 → 启用插件」或刷新页面。
147
+ - 登记:把包名加入 profile `package.json` 的 `dsh.profile.bundles`。
148
+ **不要**在 profile 的 `cordis.patch.yml` 里再追加 `insert`——插件包自带的 patch 已在 bundle 层插入自身,重复 insert 会导致设置页「无法保存设置」。
149
+
150
+ ---
151
+
152
+ ## 使用
153
+
154
+ 1. 鼠标悬停在任意**提问**上,右侧出现:撤回、分享、导出、删除、删至末尾。
155
+ 2. 鼠标悬停在**工具调用行**上,右侧出现「删除该工具行」;删除的是该 `(turn, step)` 的节点集合——同一步的答行 / 其它工具结果会一并消失,其它步骤不受影响。
156
+ 3. 每条**回答**下方显示 `tok · 字 · ¥0.0023`,最后一段是这一条回答自己的估算金额(本地路由显示「本地」)。
157
+ 4. 撤回与删除类操作默认弹出确认框(宽屏 420px 紧凑面板,窄屏贴边满宽,三个入口一致);关闭「操作确认」后直接执行;确认后对应内容消失,侧边栏刻度同步隐藏。
158
+ 5. 分享 / 导出打开全屏选择面板,每张卡片显示该轮的「问」与「答」预览,可单选、多选或全选;生成时再按需拉取完整原文。拉全文或生成图片 / 文件失败时会提示,并**保留面板与已选轮次**方便重试,只有成功下载才关闭。
159
+ 6. 生成回复期间所有按钮置灰,避免与运行中的会话冲突;极端竞态下的写入仍会返回 `423 AGENT_BUSY`。
160
+
161
+ ### 余额口径
162
+
163
+ 卡片上的「余额」直接读取 DeepSeek 账户服务,展示**可用总余额**:
164
+
165
+ - 主数字 = **充值余额(CNY 钱包)+ 赠金 / 奖金钱包(`bonusWallets`)**,每个钱包按官方规则截断至分后相加:原始余额 `5.999…` 显示 `¥5.99`,不会进位成 `¥6.00`。
166
+ - 赠金**已并入主数字**,不再单独拆行;悬停提示给出「含赠金 ¥x」的拆分,便于和官方「赠金余额」那一行对照。
167
+ - 「日用」按同一总额的下降观测,因此余额显示与记账基准一致。
168
+ - **不再提供手工校正**:充值 / 退款只会把观测基准移到新余额,不存在被手工输入悄悄覆盖的可能。设置页保留一段简短口径说明。
169
+
170
+ ---
171
+
172
+ ## 设置
173
+
174
+ 设置 → 插件 → **dsh-message-actions**,页内两个标签,改动**即时保存并立即生效**。
175
+
176
+ **消息操作**
177
+
178
+ | 开关 | 作用 |
179
+ |---|---|
180
+ | 撤回 | 提问行显示「撤回」 |
181
+ | 分享 | 提问行显示「分享」 |
182
+ | 导出 | 提问行显示「导出」 |
183
+ | 删除 | 提问行删除整轮问答;工具行删除该步工具结果 |
184
+ | 删至末尾 | 提问行显示「删至末尾」 |
185
+ | 操作确认 | 撤回与删除类操作是否弹确认框 |
186
+ | 回答统计 | 回答下方是否显示 `tok · 字 · 金额` |
187
+ | 提示音音色 | 默认双音 / 短铃 / 轻提示 / 关闭;选中即开启并试听,选「关闭」即关闭完成提示音(没有独立开关行) |
188
+ | 音量 | 0–100 滑杆(默认 50,步进 5):作用于全部音色,0% 静音、50% 为标准音量、100% 为两倍;拖动时数字实时跟手但不写配置,松手(或键盘抬起 / 失焦 / 拖动结束)后一次性保存并试听一次 |
189
+
190
+ **费用统计**
191
+
192
+ | 设置 | 作用 |
193
+ |---|---|
194
+ | 费用统计 | 侧边栏显示余额 / 日用 / 单次消耗;关闭后停止取数与记账 |
195
+ | 计费样式 | `单行样式`(默认,无背景)/ `多行样式`(带背景与峰谷行),即时切换并持久保存 |
196
+ | 单次消耗 | 每轮结束后显示本轮金额;关闭后不再渲染该组 |
197
+ | 自动关闭 | 本轮金额显示秒数(0–600,0 = 常驻) |
198
+ | 峰谷定价行 | 显示当前时段与下一次切换时间 |
199
+ | 统计表 | 右侧按钮为「打开统计表」,打开统计浮层;位于峰谷定价行与余额口径说明之间。设置页只写数据用途,预算说明只放在浮层内 |
200
+ | 余额口径 | 主数字 = 充值余额 + 赠金,逐钱包截断至分;赠金拆分只在悬停提示,不单独占行;无手工校正 |
201
+
202
+ ---
203
+
204
+ ## 隐私与安全
205
+
206
+ 这一节只写代码里实际做了的事情。它是降低风险的设计,不是「零风险」的承诺;下面每条都能在 `src/` 里找到对应实现。
207
+
208
+ **接口只对本机开放**
209
+
210
+ - 插件不自建端口,路由注册在 DSH 现有的 `webServer` 上。
211
+ - 每个请求都校验 `Host` 必须是 `localhost`、`127.0.0.0/8` 或 `::1`,否则返回 `403`;这挡住了 DNS rebinding 与局域网来源。
212
+ - 浏览器请求还要过 `Sec-Fetch-Site`:只接受 `same-origin` / `none`,或非浏览器客户端缺失该头;显式拒绝 `cross-site` 与 `same-site`。
213
+ - 携带 `Origin` 的请求必须与宿主当前同源;宿主给不出期望 `Origin` 时,带 `Origin` 的请求一律拒绝。
214
+
215
+ **响应头与写请求**
216
+
217
+ - 所有 JSON 响应统一带 `cache-control: no-store`、`x-content-type-options: nosniff`、`referrer-policy: no-referrer`、`cross-origin-resource-policy: same-origin`、`content-security-policy: default-src 'none'; frame-ancestors 'none'`。
218
+ - 写请求只接受 `content-type: application/json`;请求体上限 1MB,超限返回 `413` 并排空连接;方法不匹配返回 `405`(带 `allow` 头),错误体同样是统一 JSON。
219
+ - 不返回任何 CORS 放行头。
220
+
221
+ **会话数据**
222
+
223
+ - `GET /messages` 是**摘要接口**:只回消息 id、轮次、step、最多 200 字符的短预览、用量与工具 `callId`,不含正文。客户端不设固定轮询定时器:会话 DOM 变化时触发,经 120ms 合并调度,并用 3 秒 TTL 避免重复请求。
224
+ - 摘要支持增量:带 `since=<上次 version>` 只回 `seq > since` 的行(并附 `removedSeqs` 告知这段时间被删的行);不带 `since` 仍是全量快照。删除状态(`goneTurns` / `goneTools`)始终全量返回,因此增量刷新后已删内容不会复活。
225
+ - `preview` 只对真实提问与助手回答生成;system / developer 消息、运行时注入的上下文与工具结果一律回空,正文不会被该接口回传(代码位置:`src/shared.cjs` 的 `messagesSummaryOf`)。
226
+ - 分享图与导出需要全文时,才按选中的轮次请求 `full=1`,且只返回问 / 答文本。
227
+
228
+ **费用数据**
229
+
230
+ - 只存一个本地文件:`$DSH_HOME`(默认 `~/.dsh`)下的 `plugins/dsh-message-actions/cost-state.json`。
231
+ - 写入方式是「同目录临时文件(`0600`)→ `fsync` → `rename`」整份替换,避免写一半留下坏文件;目录按 `0700` 创建。
232
+ - 内容只有余额观测、按日消费与预算额度,没有对话正文。
233
+ - 预算保存只在状态文件写成功后才算成功:只读状态文件返回 `500 READ_ONLY`,写盘失败返回 `500 WRITE_FAILED` 并回滚内存值,界面提示「保存失败」而不是假装成功。
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 防抖)按当前音量试听一次,拖动过程中不播放。
238
+
239
+ **网络**
240
+
241
+ - 插件自身不直接向外部地址发起请求;客户端只请求同源的 `/dsh-message-actions/*`。
242
+ - 余额通过宿主已登录的 DeepSeek 账户服务(`deepseekAccount`)读取,这一步的网络请求由宿主发起;未登录时显示「未登录」。
243
+ - 插件不保存任何密钥;判断是否走 API key 时只向宿主凭据服务查询「是否存在」,不落盘、不回传。
244
+
245
+ ---
246
+
247
+ ## 已知限制
248
+
249
+ - 删除粒度:问行删整轮;工具行删该 step,会连带遮蔽同一步的答行与其它工具结果,其它步骤不受影响。
250
+ - 不支持撤销删除,也不会清理跨会话记忆。
251
+ - 删除标记保存在会话事件日志里:刷新、切换对话、重启 DSH 都不会恢复;如果手动删除整个会话目录,标记会随会话一起消失。
252
+ - 若宿主重建会话表面时没有重放墓碑,插件会根据 `goneTools` 重新隐藏工具行;这些行仍留在 DOM 中(CSS `display:none`),超大会话可能保留少量不可见节点。
253
+ - 侧边栏刻度由官方虚拟列表绘制,删过内容后滚过该区域可能出现空白。
254
+ - 入口依赖宿主的会话 DOM 结构:DSH 大版本升级后按钮可能不再出现(结果是静默消失,不会误删)。
255
+ - 「单次消耗」只含大模型调用费用,不含搜索 / 插件等外部计费。
256
+ - Web 模式未实测:同机 `localhost` 可能可用,局域网 / 远程访问会被安全围栏拒绝。
257
+
258
+ ---
259
+
260
+ ## 开发
261
+
262
+ ```bash
263
+ node build.mjs # 构建到 lib/
264
+ node test/check.mjs # 离线断言,当前 2909 项
265
+ # 另有真实会话日志回归:18/18
266
+ ```
267
+
268
+ ```
269
+ src/
270
+ ├── index.mjs # 宿主:Config + HTTP 路由 + 费用 / 会话统计服务
271
+ ├── client.js # 客户端:槽位、DOM 注入、分享 / 导出浮层、费用卡片
272
+ ├── shared.cjs # 宿主与客户端共用的纯函数(可离线测试)
273
+ ├── store.cjs # 费用状态文件原子读写、损坏恢复
274
+ ├── http.cjs # HTTP 工具:JSON 响应、413 排空、请求体读取
275
+ └── i18n.cjs # 中英文案单一来源(构建时生成 locale/*.json)
276
+ test/check.mjs # 无依赖的断言脚本
277
+ ```
278
+
279
+
280
+ - 版本:`0.2.4`(npm 与 GitHub Release 均已发布)
281
+ - 发布说明:[v0.2.4](https://github.com/aijacko/dsh-message-actions/releases/tag/v0.2.4)
282
+ - 兼容:DSH `0.2.1-rc.5` 与 `0.2.2-rc.1`;`0.2.2-rc.1`(web profile)已实测,旧版走 portal 探测失败回退
283
+ - 依赖:无运行时第三方依赖
284
+
285
+ ---
286
+
287
+ ## License
288
+
289
+ [MIT](LICENSE)
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ # DSH plugin dsh-message-actions
2
+
3
+ English · [中文](README.cn.md)
4
+
5
+ ## Overview
6
+
7
+ **Make every turn in DSH controllable, shareable, and measurable.**
8
+
9
+ DSH has no recall or delete built in: send a message by mistake and your only option is to start a new session; share a conversation and you end up copying, pasting, and re-formatting by hand. Some plugins are overloaded with features or vague about where conversation data ends up, so I wrote my own: the features I needed, and data I don't need to touch stays untouched.
10
+
11
+ - Sent the wrong message: hover over a question row, click "Recall", the whole turn disappears and the text returns to the composer; edit and resend.
12
+ - Cleaning up a tangent: "Delete" on the question row removes the whole turn; to drop just one step's tool call, click the trash icon on that tool row.
13
+ - Sharing with a colleague: select the turns you want, export Markdown or generate a long PNG, all locally, nothing uploaded.
14
+ - Wondering what the last turn cost: the sidebar shows balance / today / per-turn cost (shown as "Bal / Today / Turn" on the card); local models collapse to "Local · no billing".
15
+
16
+ Features you don't use can be turned off in settings. Turn off cost statistics, for example, and the plugin stops fetching balances and recording spend, and stops rendering the sidebar card. The delete, share, and export switches work the same way: turn them off and their entries and actions disappear. It adds no persistent panel, no update prompts, and no system notifications, and it never rewrites your question. Share and export open a temporary full-screen picker, and recall / delete show a confirmation dialog according to your settings — all normal interactions.
17
+
18
+ ---
19
+
20
+ ## Features
21
+
22
+ | Feature | What it does |
23
+ |---|---|
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 |
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) |
26
+ | **Delete to end** | Removes everything from this message to the end, for closing off a topic |
27
+ | **Share as image** | Pick the turns you want in a full-screen overlay and generate a long PNG, generated locally, never uploaded |
28
+ | **Export Markdown** | Same selection, exports a `.md` with question / answer structure per turn |
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 |
31
+ | **Rail sync** | After deletion, the matching sidebar ticks hide and the gaps close, leaving no ghost entries |
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 |
34
+ | **Peak / off-peak hint** | Peak in orange, off-peak in blue, showing whether now is expensive and when it switches |
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 |
36
+ | **Bilingual UI** | Follows the DSH language; interface and tooltips switch automatically |
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 |
38
+
39
+ Deletion uses **tombstone-style surface replacement**: it only appends a marker and hides the original span; it never rewrites the history log and doesn't affect other sessions. The marker is persisted in the session event log, so deleted content stays hidden after a page refresh, after switching to another conversation and back, and after restarting DSH. `/messages` and `full=1` both recompute the visible set from those markers instead of trusting the host surface alone.
40
+
41
+ ---
42
+
43
+ ## Cost card
44
+
45
+ **Single-line** (default, no background, one row aligned left):
46
+
47
+ ```
48
+ ▲ Bal ¥6.00 Today ¥0.08 Turn ¥0.02
49
+ ```
50
+
51
+ **Multi-line** (with a background card and a peak / off-peak text row):
52
+
53
+ ```
54
+ Bal ¥6.00 Today ¥0.08 Turn ¥0.02
55
+ ▲ Off-peak · peak at 9:00 tomorrow
56
+ ```
57
+
58
+ New installations default to **single-line**; users who have already saved a preference keep their choice and are not reset by the new default.
59
+
60
+ - Peak = warm orange, off-peak = cool blue; 14px SVG status icons, readable at a glance on the left.
61
+ - When the sidebar collapses, the card degrades to a coin icon; hover to see the balance.
62
+ - Local models / non-DeepSeek routing collapse to "Local · no billing", out of the way.
63
+
64
+ | Item | Meaning |
65
+ |---|---|
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 |
68
+ | Turn | Converted cost of the most recent turn; shown by default, can hide after 0–600 seconds |
69
+
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.
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.
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.
94
+
95
+ ---
96
+
97
+ ## Installation
98
+
99
+ ### Install from the plugin marketplace
100
+
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.4`.
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.
129
+
130
+ ### Local install
131
+
132
+ ```bash
133
+ git clone <repository-url> dsh-message-actions
134
+ cd dsh-message-actions
135
+ node build.mjs # writes lib/
136
+ node test/check.mjs # should print ALL CHECKS PASSED
137
+ ```
138
+
139
+ Install the built directory into a DSH profile:
140
+
141
+ ```bash
142
+ pnpm add "file:/path/to/dsh-message-actions"
143
+ ```
144
+
145
+ - `pnpm add file:` uses **copy** semantics: after editing code, reinstall (or pass `--force`).
146
+ - Host-side changes (`src/index.mjs`, Config) need a DSH restart; client-only changes can be picked up by disabling → enabling the plugin, or refreshing the page.
147
+ - Registration: add the package name to `dsh.profile.bundles` in the profile `package.json`.
148
+ **Do not** append another `insert` in the profile's `cordis.patch.yml` — the package's own patch already inserts itself at the bundle layer, and a duplicate insert makes the settings page fail to save.
149
+
150
+ ---
151
+
152
+ ## Usage
153
+
154
+ 1. Hover over any **question** row: Recall, Share, Export, Delete, Delete to end appear on the right.
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.
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.
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.
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`.
160
+
161
+ ### Balance scope
162
+
163
+ The card's **Bal** is read directly from the DeepSeek account service and shows the **total available balance**:
164
+
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.
169
+
170
+ ---
171
+
172
+ ## Settings
173
+
174
+ Settings → Plugins → **dsh-message-actions**; the page has two tabs, and changes **save immediately and apply right away**.
175
+
176
+ **Message Actions**
177
+
178
+ | Toggle | Effect |
179
+ |---|---|
180
+ | Recall | Show "Recall" on question rows |
181
+ | Share | Show "Share" on question rows |
182
+ | Export | Show "Export" on question rows |
183
+ | Delete | Question row deletes the whole exchange; tool row deletes that step's tool results |
184
+ | Delete to end | Show "Delete to end" on question rows |
185
+ | Confirm actions | Whether recall and delete actions ask for confirmation |
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 |
189
+
190
+ **Cost Statistics**
191
+
192
+ | Setting | Effect |
193
+ |---|---|
194
+ | Cost statistics | Show balance / today / per-turn cost in the sidebar; when off, stop fetching and recording |
195
+ | Style | `Single-line` (default, no background) / `Multi-line` (card with the peak / off-peak row), switch instantly and persist |
196
+ | Per-turn | Show the cost of each finished turn; when off, don't render that group |
197
+ | Auto-hide | Seconds before the turn cost hides (0–600, 0 = always) |
198
+ | Peak/off-peak | Show the current pricing period and the next switch |
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 |
201
+
202
+ ---
203
+
204
+ ## Privacy and security
205
+
206
+ This section only describes what the code actually does. It is risk reduction, not a "zero-risk" promise; every claim below maps to an implementation under `src/`.
207
+
208
+ **The interface is reachable from this machine only**
209
+
210
+ - The plugin doesn't open its own port; routes register on DSH's existing `webServer`.
211
+ - Every request checks that `Host` is `localhost`, `127.0.0.0/8`, or `::1`, otherwise it returns `403`; this blocks DNS rebinding and LAN origins.
212
+ - Browser requests also go through `Sec-Fetch-Site`: only `same-origin` / `none`, or a non-browser client that omits the header, is accepted; `cross-site` and `same-site` are rejected explicitly.
213
+ - Requests carrying `Origin` must be same-origin with the host; when the host can't provide an expected `Origin`, any request with `Origin` is rejected.
214
+
215
+ **Response headers and write requests**
216
+
217
+ - Every JSON response carries `cache-control: no-store`, `x-content-type-options: nosniff`, `referrer-policy: no-referrer`, `cross-origin-resource-policy: same-origin`, and `content-security-policy: default-src 'none'; frame-ancestors 'none'`.
218
+ - Write requests only accept `content-type: application/json`; the body limit is 1MB, and oversized bodies get `413` with the connection drained; a wrong method gets `405` (with an `allow` header), and the error body is the same JSON shape.
219
+ - No CORS allow headers are returned.
220
+
221
+ **Conversation data**
222
+
223
+ - `GET /messages` is a **summary** interface: it returns message ids, turn, step, a preview of at most 200 characters, usage, and the tool `callId`; no body text. The client has no fixed polling timer: it refetches when the conversation DOM changes, coalesced by a 120 ms scheduler, with a 3-second TTL to avoid duplicate requests.
224
+ - The summary supports incremental reads: a request with `since=<last version>` returns only rows with `seq > since` (plus `removedSeqs` for rows deleted since then); without `since` it still returns the full snapshot. Deletion state (`goneTurns` / `goneTools`) is always returned in full, so deleted content stays hidden after an incremental refresh.
225
+ - `preview` is only generated for real questions and assistant answers; system / developer messages, runtime-injected context, and tool results are always empty, so their text is never returned by this endpoint (implementation: `messagesSummaryOf` in `src/shared.cjs`).
226
+ - Share images and export fetch full text only for the selected turns via `full=1`, and only questions / answers are returned.
227
+
228
+ **Cost data**
229
+
230
+ - Only one local file: `cost-state.json` under `$DSH_HOME` (default `~/.dsh`), in `plugins/dsh-message-actions/`.
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`.
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.
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.
238
+
239
+ **Network**
240
+
241
+ - The plugin itself does not make requests to external addresses; the client only calls same-origin `/dsh-message-actions/*`.
242
+ - The balance is read through the host's signed-in DeepSeek account service (`deepseekAccount`); that network request is made by the host. When signed out, it shows "Signed out".
243
+ - The plugin stores no keys; to decide whether an API-key path applies, it only asks the host credential service whether one exists, without persisting it or returning it.
244
+
245
+ ---
246
+
247
+ ## Known limitations
248
+
249
+ - Deletion granularity: the question row deletes the whole turn; the tool row deletes that step, hiding the answer and other tool results in the same step. Other steps are unaffected.
250
+ - No undo for deletion, and no cross-session memory cleanup.
251
+ - Deletion markers live in the session event log. They survive refresh, conversation switching, and a DSH restart; deleting the session directory removes the markers along with the session.
252
+ - If the host ever rebuilt the conversation surface without replaying the tombstone, this plugin hides the removed tool rows again from `goneTools`; the hidden rows still exist in the DOM (CSS `display:none`), so very large sessions may keep some invisible nodes.
253
+ - The sidebar ticks are drawn by the official virtual list; after deleting content, scrolling past that area may show blank space.
254
+ - Entries depend on the host's conversation DOM structure: after a major DSH upgrade the buttons may stop appearing (they disappear silently rather than deleting the wrong thing).
255
+ - "Per-turn cost" covers model calls only, not external billing such as search or plugins.
256
+ - Web mode is untested: `localhost` on the same machine may work; LAN / remote access is rejected by the security fence.
257
+
258
+ ---
259
+
260
+ ## Development
261
+
262
+ ```bash
263
+ node build.mjs # build to lib/
264
+ node test/check.mjs # offline assertions, 2909 currently
265
+ # plus a real session-log regression: 18/18
266
+ ```
267
+
268
+ ```
269
+ src/
270
+ ├── index.mjs # host: Config + HTTP routes + cost / session-stats services
271
+ ├── client.js # client: slots, DOM injection, share / export overlay, cost card
272
+ ├── shared.cjs # pure functions shared by host and client (offline testable)
273
+ ├── store.cjs # cost state file: atomic read/write, recovery on corrupt files
274
+ ├── http.cjs # HTTP helpers: JSON responses, 413 drain, body reading
275
+ └── i18n.cjs # single source for Chinese/English copy (builds locale/*.json)
276
+ test/check.mjs # dependency-free assertion script
277
+ ```
278
+
279
+
280
+ - Version: `0.2.4` (published on both npm and GitHub Releases)
281
+ - Release: [v0.2.4](https://github.com/aijacko/dsh-message-actions/releases/tag/v0.2.4)
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
283
+ - Dependencies: none at runtime
284
+
285
+ ---
286
+
287
+ ## License
288
+
289
+ [MIT](LICENSE)
package/icon.svg CHANGED
@@ -1,5 +1,10 @@
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="#247bbf"/>
3
- <path d="M19 20h26M19 31h15" stroke="#ffffff" stroke-width="5" stroke-linecap="round"/>
4
- <path d="M42 26l2.4 2.6 5.6-6" stroke="#ffffff" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
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
+ <g stroke="#2563eb" stroke-linecap="round">
5
+ <path d="M23 23h18M23 30h18M23 37h18" stroke-width="3.2"/>
6
+ <circle cx="34" cy="23" r="3.6" fill="#2563eb" stroke="none"/>
7
+ <circle cx="27.5" cy="30" r="3.6" fill="#2563eb" stroke="none"/>
8
+ <circle cx="38" cy="37" r="3.6" fill="#2563eb" stroke="none"/>
9
+ </g>
10
+ </svg>
package/lib/client.js CHANGED
@@ -19,6 +19,15 @@ window.__ModuleLoader__.load({
19
19
  ReactDOMClient = null;
20
20
  }
21
21
 
22
+ // createPortal 来自 react-dom(不是 react-dom/client)。单独探测:
23
+ // 拿不到时浮层退回宿主槽位渲染,不影响按钮与弹窗功能。
24
+ let ReactDOM = null;
25
+ try {
26
+ ReactDOM = require("react-dom");
27
+ } catch {
28
+ ReactDOM = null;
29
+ }
30
+
22
31
  let PRIMITIVES = null;
23
32
  try {
24
33
  PRIMITIVES = require("@deepseek-ai/dsh-client-ui-primitives");
@@ -2242,12 +2251,12 @@ const CSS = `
2242
2251
  .dma-stats{order:1;display:inline-flex;align-items:center;font-size:11px;line-height:1;color:var(--dsw-alias-label-tertiary,#8a919e);white-space:nowrap;user-select:text;margin-inline:2px}
2243
2252
  [data-dma-hidden="1"]{display:none!important}
2244
2253
  [data-dma-rail="1"]{display:none!important}
2245
- .dma-overlay{position:fixed;inset:0;z-index:2147483000;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.45));display:flex;align-items:center;justify-content:center}
2246
- .dma-panel{width:min(680px,calc(100vw - 48px));max-height:80vh;display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1,#ffffff);border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));border-radius:var(--dsw-radius-panel,12px);box-shadow:var(--dsw-elevation-panel,0 18px 48px rgba(0,0,0,.18));overflow:hidden;color:var(--dsw-alias-label-primary,#1f2329)}
2254
+ .dma-overlay{position:fixed;inset:0;z-index:2147483000;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.45));display:grid;place-items:center;padding:16px;overflow:auto}
2255
+ .dma-panel{width:min(680px,calc(100vw - 48px));max-height:calc(100vh - 32px);display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1,#ffffff);border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));border-radius:var(--dsw-radius-panel,12px);box-shadow:var(--dsw-elevation-panel,0 18px 48px rgba(0,0,0,.18));overflow:hidden;color:var(--dsw-alias-label-primary,#1f2329)}
2247
2256
  .dma-confirm{width:min(420px,calc(100vw - 48px))}
2248
2257
  @media (max-width:480px){.dma-confirm{width:calc(100vw - 32px)}.dma-panel-foot{gap:8px}.dma-panel-foot .dma-btn{padding:0 12px}}
2249
- .dma-panel-head{padding:16px 20px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));font-size:16px;font-weight:600}
2250
- .dma-panel-body{overflow:auto;padding:12px 16px}
2258
+ .dma-panel-head{flex:none;padding:16px 20px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));font-size:16px;font-weight:600}
2259
+ .dma-panel-body{flex:1 1 auto;min-height:0;overflow:auto;padding:12px 16px}
2251
2260
  .dma-round{display:flex;gap:12px;align-items:flex-start;padding:10px 8px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.08));border-radius:8px}
2252
2261
  .dma-round:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.04))}
2253
2262
  .dma-round-box{flex:0 0 auto;width:20px;height:20px;border-radius:50%;border:1.5px solid var(--dsw-alias-border-l3,#c9ced6);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:0;background:transparent;color:transparent;margin-top:2px}
@@ -2261,7 +2270,7 @@ const CSS = `
2261
2270
  .dma-round-tag-a{color:var(--dsw-alias-label-tertiary,#8a919e)}
2262
2271
  .dma-round-a{color:var(--dsw-alias-label-secondary,#5b6472)}
2263
2272
  .dma-round-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2264
- .dma-panel-foot{display:flex;align-items:center;justify-content:space-between;padding:12px 20px;border-top:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1))}
2273
+ .dma-panel-foot{flex:none;display:flex;align-items:center;justify-content:space-between;padding:12px 20px;border-top:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1))}
2265
2274
  .dma-panel-foot .dma-btn{width:auto;height:32px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3,#c9ced6);border-radius:8px;color:var(--dsw-alias-label-secondary,#5b6472)}
2266
2275
  .dma-panel-foot .dma-primary{background:var(--dsw-alias-button-primary-fill,#4c8dff);color:var(--dsw-alias-label-primary-inverted,#fff);border-color:transparent}
2267
2276
  .dma-panel-foot .dma-primary.dma-danger{background:var(--dsw-alias-state-error-primary,#e5484d);color:#fff}
@@ -2401,9 +2410,9 @@ module.exports = {
2401
2410
  };
2402
2411
  return module.exports;
2403
2412
  })();
2404
- const BUILD = "2026-11-06T20:01:34.544Z";
2413
+ const BUILD = "2026-11-07T12:14:19.227Z";
2405
2414
  // 构建时由 build.mjs 用 package.json 的 version 替换,避免设置页显示旧版本。
2406
- const VERSION = "0.2.2";
2415
+ const VERSION = "0.2.4";
2407
2416
 
2408
2417
  if (typeof console !== "undefined" && typeof console.info === "function") {
2409
2418
  console.info("[dsh-message-actions] build", BUILD);
@@ -2468,12 +2477,12 @@ const exports = module.exports;
2468
2477
 
2469
2478
  const meta = {
2470
2479
  zh: {
2471
- title: '消息费用',
2472
- description: '撤回、删除、删至末尾;多选分享与导出对话;回答统计;DeepSeek 账户余额、日用与单次费用统计。'
2480
+ title: 'dsh-message-actions',
2481
+ description: '功能:撤回、删除、删至末尾、多选分享与导出,每条回答的用量计费、余额费用展示、对话完成声音提示等。'
2473
2482
  },
2474
2483
  en: {
2475
- title: 'Messages & Cost',
2476
- description: 'Recall, delete, and delete-to-end messages; multi-select share and export; per-answer statistics; DeepSeek balance, daily spend, and per-turn cost.'
2484
+ title: 'dsh-message-actions',
2485
+ description: 'Features: recall, delete, delete-to-end, multi-select share and export; per-reply usage billing, balance and cost display, and a completion sound.'
2477
2486
  }
2478
2487
  };
2479
2488
 
@@ -2537,7 +2546,7 @@ const zh = {
2537
2546
  'cost.tab.actions': '消息操作',
2538
2547
  'cost.tab.billing': '费用统计',
2539
2548
  'cost.balance': '余额',
2540
- 'cost.bonusHint': '赠金 {bonus}',
2549
+ 'cost.bonusHint': '含赠金 {bonus}',
2541
2550
  'cost.daily': '日用',
2542
2551
  'cost.perTurn': '单次',
2543
2552
  'cost.peak': '高峰价',
@@ -2565,7 +2574,7 @@ const zh = {
2565
2574
  'cost.settings.layoutDesc': '单行样式去背景、所有数字排成一行;多行样式带背景卡片与峰谷文字行',
2566
2575
  'cost.layout.default': '多行样式',
2567
2576
  'cost.layout.compact': '单行样式',
2568
- 'cost.balanceNote': '余额直接读取 DeepSeek 账户的充值余额(按官方规则截断至分,不含赠金;赠金另以悬停提示)。「日用」按账户余额实际下降观测,「单次」按官方价目换算,两者口径不同,不要求逐轮对齐。',
2577
+ 'cost.balanceNote': '余额直接读取 DeepSeek 账户的可用总余额(充值余额 + 赠金钱包,逐钱包按官方规则截断至分;赠金已并入主数字,悬停提示给出拆分)。「日用」按同一总额的实际下降观测,「单次」按官方价目换算,两者口径不同,不要求逐轮对齐。',
2569
2578
  'cost.settings.statsTable': '统计表',
2570
2579
  'cost.settings.statsTableDesc': '查看 Token 用量、消耗时间线与各会话成本',
2571
2580
  'cost.settings.statsTableButton': '打开统计表',
@@ -2616,7 +2625,7 @@ const zh = {
2616
2625
  'stats.budgetUsed': '已用',
2617
2626
  'stats.budgetCancel': '取消',
2618
2627
  'stats.moneyBudget': '预算',
2619
- 'stats.moneyBalanceSub': '充值余额',
2628
+ 'stats.moneyBalanceSub': '账户总余额(含赠金)',
2620
2629
  'stats.moneyDailySub': '今日累计',
2621
2630
  'stats.moneyTurnSub': '最近一轮',
2622
2631
  'stats.moneyEdit': '修改预算',
@@ -2700,7 +2709,7 @@ const en = {
2700
2709
  'cost.tab.actions': 'Message Actions',
2701
2710
  'cost.tab.billing': 'Cost Statistics',
2702
2711
  'cost.balance': 'Bal',
2703
- 'cost.bonusHint': 'Bonus {bonus}',
2712
+ 'cost.bonusHint': 'incl. bonus {bonus}',
2704
2713
  'cost.daily': 'Today',
2705
2714
  'cost.perTurn': 'Turn',
2706
2715
  'cost.peak': 'Peak',
@@ -2728,7 +2737,7 @@ const en = {
2728
2737
  'cost.settings.layoutDesc': 'Single-line drops the background and keeps all numbers on one row; multi-line keeps the card and the pricing-period line',
2729
2738
  'cost.layout.default': 'Multi-line',
2730
2739
  'cost.layout.compact': 'Single-line',
2731
- 'cost.balanceNote': 'Balance is read directly from the DeepSeek account recharge balance (truncated to the cent like the official page, excluding bonus credits, which are shown separately on hover). "Today" is observed from the actual balance drop; "Turn" is converted from official list prices — different bases, so they need not match turn by turn.',
2740
+ 'cost.balanceNote': 'Balance is the DeepSeek account total available balance (recharge wallets + bonus wallets, each truncated to the cent like the official page; bonus is merged into the main figure and broken out on hover). "Today" observes drops in that same total; "Turn" is converted from official list prices — different bases, so they need not match turn by turn.',
2732
2741
  'cost.settings.statsTable': 'Stats table',
2733
2742
  'cost.settings.statsTableDesc': 'Token usage, usage timeline and per-session cost',
2734
2743
  'cost.settings.statsTableButton': 'Open stats table',
@@ -2779,7 +2788,7 @@ const en = {
2779
2788
  'stats.budgetUsed': 'used',
2780
2789
  'stats.budgetCancel': 'Cancel',
2781
2790
  'stats.moneyBudget': 'Budget',
2782
- 'stats.moneyBalanceSub': 'Recharge balance',
2791
+ 'stats.moneyBalanceSub': 'Total balance (incl. bonus)',
2783
2792
  'stats.moneyDailySub': 'Since midnight',
2784
2793
  'stats.moneyTurnSub': 'Latest turn',
2785
2794
  'stats.moneyEdit': 'Edit budget',
@@ -4255,7 +4264,26 @@ return module.exports;
4255
4264
  ));
4256
4265
  }
4257
4266
 
4258
- // 确认弹窗 + 分享/导出浮层控制器(input.overlay 槽位)
4267
+ /**
4268
+ * 确认框与分享/导出面板的唯一挂载路径。
4269
+ * 新版宿主会给输入区容器加 `will-change: transform`,使 `position:fixed`
4270
+ * 的包含块变成输入区而不是视口;portal 到 document.body 可彻底脱离该容器,
4271
+ * 同时不受其 `overflow:hidden` 裁剪。
4272
+ * 拿不到 createPortal / body 时原样返回,退回槽位渲染,保证旧宿主可用。
4273
+ */
4274
+ function mountOverlay(node) {
4275
+ if (node && ReactDOM && typeof ReactDOM.createPortal === "function" &&
4276
+ typeof document !== "undefined" && document.body) {
4277
+ try {
4278
+ return ReactDOM.createPortal(node, document.body);
4279
+ } catch {
4280
+ // 探测失败按旧路径渲染,弹窗不会消失。
4281
+ }
4282
+ }
4283
+ return node;
4284
+ }
4285
+
4286
+ // 确认弹窗 + 分享/导出浮层控制器(input.overlay 槽位只作为渲染触发点)
4259
4287
  function OverlayController(props) {
4260
4288
  const { t: tt, useOverlay, useData, confirmAction, dismiss, runShare, runExport } = props;
4261
4289
  const view = useOverlay((v) => v.view);
@@ -4263,17 +4291,16 @@ return module.exports;
4263
4291
 
4264
4292
  if (!view) return null;
4265
4293
 
4294
+ let panel = null;
4266
4295
  if (view.kind === "confirm") {
4267
- return e(ConfirmOverlay, {
4296
+ panel = e(ConfirmOverlay, {
4268
4297
  t: tt,
4269
4298
  view,
4270
4299
  onDismiss: dismiss,
4271
4300
  confirmAction
4272
4301
  });
4273
- }
4274
-
4275
- if (view.kind === "pick") {
4276
- return e(PickOverlay, {
4302
+ } else if (view.kind === "pick") {
4303
+ panel = e(PickOverlay, {
4277
4304
  t: tt,
4278
4305
  mode: view.mode,
4279
4306
  seedTurn: view.turn,
@@ -4284,7 +4311,7 @@ return module.exports;
4284
4311
  });
4285
4312
  }
4286
4313
 
4287
- return null;
4314
+ return panel ? mountOverlay(panel) : null;
4288
4315
  }
4289
4316
 
4290
4317
  // 分享/导出多选列表
@@ -4928,10 +4955,7 @@ return module.exports;
4928
4955
  e("span", { className: "dma-stats-card-label" }, tt("cost.balance")),
4929
4956
  e("span", { className: "dma-stats-card-value" },
4930
4957
  Number.isFinite(ledger.balanceCents) ? formatYuanCents(ledger.balanceCents) : "—"),
4931
- e("span", { className: "dma-stats-card-sub" },
4932
- ledger.bonusCents > 0
4933
- ? tt("cost.bonusHint", { bonus: formatYuanCents(ledger.bonusCents) })
4934
- : tt("stats.moneyBalanceSub"))
4958
+ e("span", { className: "dma-stats-card-sub" }, tt("stats.moneyBalanceSub"))
4935
4959
  )
4936
4960
  : null,
4937
4961
  ledger
@@ -5393,13 +5417,13 @@ return module.exports;
5393
5417
  const status = value ? value.status : "stale";
5394
5418
  const lastTurn = value && value.lastTurn ? value.lastTurn : null;
5395
5419
 
5396
- // 余额口径:直接展示官方「充值余额」(不含赠金;赠金在提示里单列),
5397
- // 全部按分计,不做元级四舍五入。缺充值字段时才退回总额。
5420
+ // 余额口径:主数字 = 充值余额 + 赠金钱包(与「日用」观测的总额同基准),
5421
+ // 全部按分计,不做元级四舍五入;赠金拆分只在悬停提示,不再单独占行。
5398
5422
  const rechargeCents = balance && Number.isFinite(balance.rechargeCents) ? balance.rechargeCents : null;
5399
5423
  const bonusCents = balance && Number.isFinite(balance.bonusCents) ? balance.bonusCents : null;
5400
5424
  const totalCents = balance && Number.isFinite(balance.totalCents) ? balance.totalCents : null;
5401
5425
  const balanceCents = balance && balance.updatedAt > 0
5402
- ? (rechargeCents !== null ? rechargeCents : totalCents)
5426
+ ? (totalCents !== null ? totalCents : rechargeCents)
5403
5427
  : null;
5404
5428
  const bonusTitle = bonusCents !== null && bonusCents > 0
5405
5429
  ? " · " + tt("cost.bonusHint", { bonus: formatYuanCents(bonusCents) })
package/lib/index.js CHANGED
@@ -1058,8 +1058,8 @@ function createStatsService(ctx, cost, config) {
1058
1058
  const rechargeCents = Number.isFinite(b.rechargeCents) ? b.rechargeCents : null;
1059
1059
  const bonusCents = Number.isFinite(b.bonusCents) ? b.bonusCents : null;
1060
1060
  const totalCents = Number.isFinite(b.totalCents) ? b.totalCents : null;
1061
- // 与侧边栏费用卡片完全同一口径:直接展示官方「充值余额」(不含赠金)。
1062
- const balanceCents = rechargeCents !== null ? rechargeCents : totalCents;
1061
+ // 与侧边栏费用卡片完全同一口径:充值余额 + 赠金钱包 = 账户可用总余额。
1062
+ const balanceCents = totalCents !== null ? totalCents : rechargeCents;
1063
1063
  ledger = {
1064
1064
  balanceCents,
1065
1065
  rechargeCents,
package/lib/shared.cjs CHANGED
@@ -2209,12 +2209,12 @@ const CSS = `
2209
2209
  .dma-stats{order:1;display:inline-flex;align-items:center;font-size:11px;line-height:1;color:var(--dsw-alias-label-tertiary,#8a919e);white-space:nowrap;user-select:text;margin-inline:2px}
2210
2210
  [data-dma-hidden="1"]{display:none!important}
2211
2211
  [data-dma-rail="1"]{display:none!important}
2212
- .dma-overlay{position:fixed;inset:0;z-index:2147483000;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.45));display:flex;align-items:center;justify-content:center}
2213
- .dma-panel{width:min(680px,calc(100vw - 48px));max-height:80vh;display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1,#ffffff);border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));border-radius:var(--dsw-radius-panel,12px);box-shadow:var(--dsw-elevation-panel,0 18px 48px rgba(0,0,0,.18));overflow:hidden;color:var(--dsw-alias-label-primary,#1f2329)}
2212
+ .dma-overlay{position:fixed;inset:0;z-index:2147483000;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.45));display:grid;place-items:center;padding:16px;overflow:auto}
2213
+ .dma-panel{width:min(680px,calc(100vw - 48px));max-height:calc(100vh - 32px);display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1,#ffffff);border:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));border-radius:var(--dsw-radius-panel,12px);box-shadow:var(--dsw-elevation-panel,0 18px 48px rgba(0,0,0,.18));overflow:hidden;color:var(--dsw-alias-label-primary,#1f2329)}
2214
2214
  .dma-confirm{width:min(420px,calc(100vw - 48px))}
2215
2215
  @media (max-width:480px){.dma-confirm{width:calc(100vw - 32px)}.dma-panel-foot{gap:8px}.dma-panel-foot .dma-btn{padding:0 12px}}
2216
- .dma-panel-head{padding:16px 20px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));font-size:16px;font-weight:600}
2217
- .dma-panel-body{overflow:auto;padding:12px 16px}
2216
+ .dma-panel-head{flex:none;padding:16px 20px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));font-size:16px;font-weight:600}
2217
+ .dma-panel-body{flex:1 1 auto;min-height:0;overflow:auto;padding:12px 16px}
2218
2218
  .dma-round{display:flex;gap:12px;align-items:flex-start;padding:10px 8px;border-bottom:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.08));border-radius:8px}
2219
2219
  .dma-round:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.04))}
2220
2220
  .dma-round-box{flex:0 0 auto;width:20px;height:20px;border-radius:50%;border:1.5px solid var(--dsw-alias-border-l3,#c9ced6);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:0;background:transparent;color:transparent;margin-top:2px}
@@ -2228,7 +2228,7 @@ const CSS = `
2228
2228
  .dma-round-tag-a{color:var(--dsw-alias-label-tertiary,#8a919e)}
2229
2229
  .dma-round-a{color:var(--dsw-alias-label-secondary,#5b6472)}
2230
2230
  .dma-round-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
2231
- .dma-panel-foot{display:flex;align-items:center;justify-content:space-between;padding:12px 20px;border-top:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1))}
2231
+ .dma-panel-foot{flex:none;display:flex;align-items:center;justify-content:space-between;padding:12px 20px;border-top:.5px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1))}
2232
2232
  .dma-panel-foot .dma-btn{width:auto;height:32px;padding:0 14px;border:.5px solid var(--dsw-alias-border-l3,#c9ced6);border-radius:8px;color:var(--dsw-alias-label-secondary,#5b6472)}
2233
2233
  .dma-panel-foot .dma-primary{background:var(--dsw-alias-button-primary-fill,#4c8dff);color:var(--dsw-alias-label-primary-inverted,#fff);border-color:transparent}
2234
2234
  .dma-panel-foot .dma-primary.dma-danger{background:var(--dsw-alias-state-error-primary,#e5484d);color:#fff}
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
- "title": "Messages & Cost",
4
- "description": "Recall, delete, and delete-to-end messages; multi-select share and export; per-answer statistics; DeepSeek balance, daily spend, and per-turn cost."
3
+ "title": "dsh-message-actions",
4
+ "description": "Features: recall, delete, delete-to-end, multi-select share and export; per-reply usage billing, balance and cost display, and a completion sound."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
- "title": "消息费用",
4
- "description": "撤回、删除、删至末尾;多选分享与导出对话;回答统计;DeepSeek 账户余额、日用与单次费用统计。"
3
+ "title": "dsh-message-actions",
4
+ "description": "功能:撤回、删除、删至末尾、多选分享与导出,每条回答的用量计费、余额费用展示、对话完成声音提示等。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-message-actions",
3
- "version": "0.2.2",
4
- "description": "消息费用:撤回、删除、删至末尾、分享、导出、回答统计与 DeepSeek 费用统计(DSH 插件)。",
3
+ "version": "0.2.4",
4
+ "description": "功能:撤回、删除、删至末尾、多选分享与导出,每条回答的用量计费、余额费用展示、对话完成声音提示等。",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {