dsh-message-actions 0.2.4 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,289 +1,157 @@
1
- # DSH plugin dsh-message-actions
1
+ # 消息管家(dsh-message-actions)
2
2
 
3
- English · [中文](README.cn.md)
3
+ [English](README-en.md) | **中文**
4
4
 
5
- ## Overview
5
+ ![version](https://img.shields.io/badge/version-0.2.9-blue)
6
+ ![npm](https://img.shields.io/badge/npm-v0.2.9-orange)
7
+ ![license](https://img.shields.io/badge/license-MIT-green)
8
+ ![DSH](https://img.shields.io/badge/DSH-0.2.2--rc.5-blue)
9
+ [![GitHub repository](https://img.shields.io/badge/GitHub-repository-blue)](https://github.com/aijacko/dsh-message-actions)
10
+ ![awesome](https://img.shields.io/badge/awesome-DSH%20plugin-red)
6
11
 
7
- **Make every turn in DSH controllable, shareable, and measurable.**
12
+ > **兼容性**:已适配最新版 DSH(`0.2.2-rc.5`),desktop / web profile 均已实测。
8
13
 
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.
14
+ **功能:撤回、删除、删至末尾、多选分享与导出;删除会话、回收站、恢复、批量操作;用量计费、余额与费用展示;对话完成提示音。** 宿主本身没有撤回、删除与费用视图,这个插件把这几件事补齐:消息操作、分享导出、会话管理、用量计费全部在本机完成,不上传对话内容。
10
15
 
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".
16
+ ## 界面预览
15
17
 
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 |
18
+ | 消息操作与费用卡片 | 设置 · 消息操作 |
23
19
  |---|---|
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):
20
+ | ![提问行与回答行的撤回、删除、分享、导出按钮;回答行显示 tokens、字数与单条费用;左下角是余额卡片](https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/pic/1.png) | ![消息操作标签:撤回、分享、导出、删除、删至末尾、操作确认、回答统计、提示音与音量](https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/pic/2.png) |
21
+ | **设置 · 会话管理** | **设置 · 费用统计** |
22
+ | ![会话管理标签:删除会话开关、会话与回收站计数、按工作区分组、搜索与状态筛选、批量删除到回收站](https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/pic/3.png) | ![费用统计标签:费用统计开关、计费样式单行/多行、单次消耗、自动关闭、峰谷定价行、统计表入口](https://raw.githubusercontent.com/aijacko/dsh-message-actions/main/pic/4.png) |
46
23
 
47
- ```
48
- ▲ Bal ¥6.00 Today ¥0.08 Turn ¥0.02
49
- ```
24
+ ## 功能一览
50
25
 
51
- **Multi-line** (with a background card and a peak / off-peak text row):
26
+ ### 消息操作
52
27
 
53
- ```
54
- Bal ¥6.00 Today ¥0.08 Turn ¥0.02
55
- ▲ Off-peak · peak at 9:00 tomorrow
56
- ```
28
+ - **撤回**:悬停提问行点「撤回」,整轮问答消失,原文与图片 / 文件回到输入框,改完可直接重发;回复生成中的会话不可撤回。
29
+ - **删除**:问行删除整轮问答;工具行只删该步工具结果,同一步的答行会一并遮蔽,其它步骤不受影响。
30
+ - **删至末尾**:从选中的这一条起清掉后面的全部内容,适合给一个话题收尾。
31
+ - 删除采用墓碑式遮蔽:只追加标记、不改写历史日志;刷新、切换会话、重启 DSH 后都不会复活。
57
32
 
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 |
33
+ ### 分享与导出
69
34
 
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.
35
+ - **多选方式**:悬停任意提问行点「分享」或「导出」进入全屏选择器,点击轮次卡片选中或取消,右上角「全选」可一次选满。
36
+ - **分享长图**:生成 720px 宽的长图 PNG,本地渲染、不上传;总高度超过 12000px 会提示内容过多,建议分批选择。
37
+ - **导出 Markdown**:导出 `# 标题`、`## 问 N`、`### 答` 结构的 `.md`,文件名形如 `dsh-{会话id}-{YYYYMMDD-HHmm}.md`。
38
+ - 生成失败会保留面板与已选轮次,方便重试;生成回复期间按钮置灰,避免与运行中的会话冲突。
76
39
 
77
- ---
40
+ ### 用量与费用
78
41
 
79
- ## Statistics
42
+ - **每条回答的用量与费用**:回答下方显示 `tok · 字 · ¥0.0023`,金额只累计这一条回答自己的 usage,同轮多步不重复计价。
43
+ - **费用在哪里看**:单条金额在回答末尾;本轮合计在侧边栏「单次」;账户余额、日用、单次在余额卡片;按会话 / 按时间汇总在统计表。
44
+ - **余额卡片**:余额为主数字(充值 + 赠金,逐钱包截断至分),悬停可看拆分;本地模型显示「本地模型 · 无需计费」。
45
+ - **统计表**:费用行末尾图标打开,含 Token 汇总、24 小时 / 30 天时间线、各会话成本、来源诊断与第三方价格表。
46
+ - **预算**:统计表内编辑(默认 `¥5`,填 `0` 只显示估算成本)。预算只用于计算占比与剩余额度,不拦截对话;用超后显示「已超预算」,比例按真实值展示、不封顶。
47
+ - **峰谷提示**:工作日 `09:00–12:00`、`14:00–18:00` 为高峰,其余为谷价(高峰的 `0.5×`);高峰橙、谷价蓝。
80
48
 
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.
49
+ ### 会话管理
82
50
 
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.
51
+ - **入口**:侧边栏底部「消息管家」,或 设置 → 消息管家 → 会话管理。
52
+ - **删除到回收站**:软删除,只写回收站索引、日志留在原工作区;单条与批量都直接执行,**不需要输入 `OK`**。
53
+ - **恢复**:单条 / 批量恢复即时生效,无需重启,会话回到原工作区分组。
54
+ - **归档 / 取消归档**:把会话移出常规列表;归档不会移动聊天日志。
55
+ - **彻底清理**:单条 / 批量彻底清理与清空回收站不可恢复,需输入 `OK`(大小写不敏感、忽略首尾空格)。
56
+ - **回收站保留多久**:没有自动过期或 TTL,条目会一直保留,直到你手动彻底清理或清空回收站;软删除期间日志仍占用磁盘。
57
+ - **删除开关**:设置 → 消息管家 → 会话管理顶部可关闭「删除会话」。关闭后:提问行菜单的删除项、批量删除按钮、回收站「彻底删除」与「清空回收站」都会隐藏,宿主也会拒绝删除 / 彻底清理请求(`SESSIONS_DELETE_DISABLED`);恢复、归档、列表读取不受影响。
92
58
 
93
- CPU, process memory, system load and uptime are deliberately **not** included; this plugin is about messages and cost.
59
+ ### 提示音与音量
94
60
 
95
- ---
61
+ - 完成提示音由客户端现场合成,不联网、不加载音频文件,同一轮只响一次。
62
+ - 音色可选默认双音 / 短铃 / 轻提示 / 关闭;音量 `0–100`(默认 `50` 为标准音量,`0` 为静音)。
96
63
 
97
- ## Installation
64
+ ## 安装
98
65
 
99
- ### Install from the plugin marketplace
66
+ ### 方式一:插件市场(推荐)
100
67
 
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.
68
+ 1. 插件 → **插件市场** 标签 → 搜索 `dsh-message-actions`。
69
+ 2. 卡片右侧点「安装」;装好后同一张卡片显示「已安装」。
103
70
 
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
71
+ ### 方式二:本地安装
131
72
 
132
73
  ```bash
133
74
  git clone <repository-url> dsh-message-actions
134
75
  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
76
+ node build.mjs # 生成 lib/
142
77
  pnpm add "file:/path/to/dsh-message-actions"
143
78
  ```
144
79
 
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**
80
+ - `file:` 安装是**复制**语义,改代码后需卸载重装;`lib/` 由构建生成,不要手工编辑。
81
+ - 把包名加入 profile `package.json` 的 `dsh.profile.bundles`;**不要**在 `cordis.patch.yml` 里再追加 `insert`,否则可能出现设置无法保存。
82
+ - 升级插件后需**完全退出并重启 DSH**(含托盘 / 后台进程);仅刷新页面不会加载新的客户端代码。
177
83
 
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.
84
+ 已发布版本 `0.2.9`。
214
85
 
215
- **Response headers and write requests**
86
+ ## 配置项
216
87
 
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.
88
+ 设置 → 插件 → 消息管家,改动即时保存并生效。
220
89
 
221
- **Conversation data**
90
+ | 配置名 | 作用 | 默认值 |
91
+ |---|---|---|
92
+ | 撤回 `recall` | 提问行显示「撤回」 | 开 |
93
+ | 分享 `share` | 提问行显示「分享」 | 开 |
94
+ | 导出 `export` | 提问行显示「导出」 | 开 |
95
+ | 删除 `delete` | 问行删整轮;工具行删该步 | 开 |
96
+ | 删至末尾 `deleteFrom` | 提问行显示「删至末尾」 | 开 |
97
+ | 操作确认 `confirm` | 撤回 / 删除类操作是否弹确认框 | 开 |
98
+ | 回答统计 `stats` | 回答下方显示 token、字数与金额 | 开 |
99
+ | 费用统计 `usageStats` | 侧边栏显示余额 / 日用 / 单次;关闭后停止取数与记账 | 开 |
100
+ | 计费样式 `costLayout` | `compact` 单行样式 / `default` 多行样式 | `compact` |
101
+ | 单次消耗 `costPerTurn` | 每轮结束后显示本轮金额 | 开 |
102
+ | 自动关闭 `costPerTurnAutoClose` | 本轮金额显示秒数,`0` = 常驻 | `0` |
103
+ | 峰谷定价行 `costPeakValley` | 显示当前时段与下一次切换时间 | 开 |
104
+ | 提示音音色 `soundTone` | `double` 双音 / `bell` 短铃 / `soft` 轻提示 / `off` 关闭 | `double` |
105
+ | 音量 `soundVolume` | 提示音音量,`0–100` | `50` |
106
+ | 删除会话 `sessionsDelete` | 会话管理中的删除 / 彻底清理总开关 | 开 |
107
+ | 完成提示音 `sound` | 旧配置兼容字段;`false` 等同于关闭提示音 | 开 |
222
108
 
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.
109
+ ## 计费规则
227
110
 
228
- **Cost data**
111
+ ### 哪些请求不计费
229
112
 
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.
113
+ - **覆盖清单优先**:统计表 → 计费规则里把某 provider 标为 `local`,该来源一律不计费;标为 `always` 则强制计费。
114
+ - **本地地址自动判定**:`localhost`、`*.localhost`、`127.0.0.0/8`、`::1`、`0.0.0.0`、`*.local`、`host.docker.internal` 等容器 / 本机别名,且没有官方域名特征时,判为本地、不计费。
115
+ - **官方来源**:DeepSeek provider 名或官方域名 → 按官方价目计费,高峰 / 谷价生效。
116
+ - **无法确认来源**:默认按第三方计费并标记「来源未确认」,不会静默当作本地。
238
117
 
239
- **Network**
118
+ ### 第三方网关与覆盖清单
240
119
 
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.
120
+ 统计表 → 计费规则可编辑三部分:`overrides`(provider → `local` / `always`)、`prices`(模型价格表)、价格生效后的重算。网关地址由宿主探测并展示在「来源诊断」,不需要手填 baseURL。
244
121
 
245
- ---
122
+ ### 价格表优先级
246
123
 
247
- ## Known limitations
124
+ 第三方价格按 **精确模型名 → 最长模型前缀 → provider → 全局兜底** 依次匹配;都未命中时显示「未配置」,只统计 token、金额记 `0`,不会套用官方价。
248
125
 
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.
126
+ ## 数据与权限
257
127
 
258
- ---
128
+ - **写入位置**:费用状态在 `$DSH_HOME/plugins/dsh-message-actions/cost-state.json`(目录 `0700`、文件 `0600`),保存预算、第三方价格表、消费记录与余额基准。
129
+ - **回收站**:`$DSH_HOME/dsh-message-actions-trash/trash-*/meta.json`(`0600`),加 `purged.json` 墓碑清单;会话日志本身留在原工作区。
130
+ - **删除标记**:撤回 / 删除 / 删至末尾以事件追加到对应会话的 `session.v*.jsonl`,不会重写历史正文。
131
+ - **是否上传**:插件不向任何外部服务发送对话、附件或统计;分享图与 Markdown 都在本地生成。接口只接受本机同源请求,且不新开端口。
132
+ - **凭据**:不保存 API Key、Token、Cookie;余额与用量通过宿主已有会话读取。
133
+ - **备份**:备份上述 `plugins/dsh-message-actions/` 与 `dsh-message-actions-trash/` 两个目录即可;会话日志随 DSH 会话目录一起备份。
134
+ - **彻底卸载**:先在回收站清空(避免残留墓碑与索引),再禁用并移除插件;如需清空统计,删除 `plugins/dsh-message-actions/`。已写入会话日志的删除标记会随日志保留,不会因卸载而恢复显示。
259
135
 
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
- ```
136
+ ## 使用要点
278
137
 
138
+ 1. 悬停提问行:撤回 / 分享 / 导出 / 删除 / 删至末尾;悬停工具行:删除该步工具结果。
139
+ 2. 每条回答下方的统计行给出这一条自己的 token、字数与估算金额;整轮合计看侧边栏「单次」。
140
+ 3. 分享 / 导出浮层内 `Enter` 执行主操作,确认框内 `Enter` 确认、`Esc` 取消;焦点在输入框时不拦截。
141
+ 4. 回收站恢复即时生效;彻底清理不可撤销,且会同时移出工作区索引。
142
+ 5. 删除标记写入会话事件日志;手动删除整个会话目录时,标记随会话一起消失。
143
+ 6. 升级或改动宿主侧代码后需完全退出并重启 DSH;只改客户端且已加载新代码时可「禁用 → 启用插件」或刷新页面。
279
144
 
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
145
+ ## 常见问题
284
146
 
285
- ---
147
+ - **装完看不到任何入口**:先在插件列表确认已启用、profile 的 `dsh.profile.bundles` 含包名,再完全退出并重启 DSH;仍无入口时看开发者工具控制台是否有加载报错。
148
+ - **提示音没声**:检查音色不是「关闭」、音量大于 `0`、系统与浏览器未静音;旧配置里 `sound=false` 也会静音。浏览器要求先有页面交互才允许播放。
149
+ - **费用显示「未配置」**:第三方模型没有命中价格表。到统计表 → 计费规则,按模型名 / 前缀 / provider / 兜底补一条价格;官方或本地来源则检查「来源诊断」里的 baseURL 与覆盖清单。
150
+ - **余额对不上**:余额是账户总额快照,「日用」按总额下降观测,「单次」按价目换算,口径不同不要求逐轮相等;充值 / 退款只更新基准、不冲减已记消费,跨日与长时间间隔不补记差额。
151
+ - **删除被拒绝**:`SESSIONS_DELETE_DISABLED` 表示「删除会话」开关已关闭;`SESSION_RUNNING` 表示该会话正在生成回复;`TRASH_UNAVAILABLE` 多见于旧宿主或插件未启用;非本机来源请求会直接 403。
152
+ - **删除后磁盘没变小**:删除到回收站是软删除,日志仍在原工作区;需要彻底清理或清空回收站才会真正释放空间。
286
153
 
287
- ## License
154
+ ## 反馈
288
155
 
289
- [MIT](LICENSE)
156
+ - 问题与建议:[GitHub Issues](https://github.com/aijacko/dsh-message-actions/issues)
157
+ - 许可证:[MIT](LICENSE)