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 +109 -241
- package/lib/client.js +7319 -4485
- package/lib/http.cjs +37 -1
- package/lib/index.js +625 -83
- package/lib/session-manager.mjs +1164 -0
- package/lib/sessions.cjs +210 -0
- package/lib/shared.cjs +2883 -2357
- package/lib/store.cjs +288 -265
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +8 -2
- package/README.cn.md +0 -289
package/README.md
CHANGED
|
@@ -1,289 +1,157 @@
|
|
|
1
|
-
|
|
1
|
+
# 消息管家(dsh-message-actions)
|
|
2
2
|
|
|
3
|
-
English
|
|
3
|
+
[English](README-en.md) | **中文**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[](https://github.com/aijacko/dsh-message-actions)
|
|
10
|
+

|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
> **兼容性**:已适配最新版 DSH(`0.2.2-rc.5`),desktop / web profile 均已实测。
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
**功能:撤回、删除、删至末尾、多选分享与导出;删除会话、回收站、恢复、批量操作;用量计费、余额与费用展示;对话完成提示音。** 宿主本身没有撤回、删除与费用视图,这个插件把这几件事补齐:消息操作、分享导出、会话管理、用量计费全部在本机完成,不上传对话内容。
|
|
10
15
|
|
|
11
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
| Feature | What it does |
|
|
18
|
+
| 消息操作与费用卡片 | 设置 · 消息操作 |
|
|
23
19
|
|---|---|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
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
|
+
|  |  |
|
|
21
|
+
| **设置 · 会话管理** | **设置 · 费用统计** |
|
|
22
|
+
|  |  |
|
|
46
23
|
|
|
47
|
-
|
|
48
|
-
▲ Bal ¥6.00 Today ¥0.08 Turn ¥0.02
|
|
49
|
-
```
|
|
24
|
+
## 功能一览
|
|
50
25
|
|
|
51
|
-
|
|
26
|
+
### 消息操作
|
|
52
27
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
28
|
+
- **撤回**:悬停提问行点「撤回」,整轮问答消失,原文与图片 / 文件回到输入框,改完可直接重发;回复生成中的会话不可撤回。
|
|
29
|
+
- **删除**:问行删除整轮问答;工具行只删该步工具结果,同一步的答行会一并遮蔽,其它步骤不受影响。
|
|
30
|
+
- **删至末尾**:从选中的这一条起清掉后面的全部内容,适合给一个话题收尾。
|
|
31
|
+
- 删除采用墓碑式遮蔽:只追加标记、不改写历史日志;刷新、切换会话、重启 DSH 后都不会复活。
|
|
57
32
|
|
|
58
|
-
|
|
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
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
+
### 会话管理
|
|
82
50
|
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
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
|
-
|
|
59
|
+
### 提示音与音量
|
|
94
60
|
|
|
95
|
-
|
|
61
|
+
- 完成提示音由客户端现场合成,不联网、不加载音频文件,同一轮只响一次。
|
|
62
|
+
- 音色可选默认双音 / 短铃 / 轻提示 / 关闭;音量 `0–100`(默认 `50` 为标准音量,`0` 为静音)。
|
|
96
63
|
|
|
97
|
-
##
|
|
64
|
+
## 安装
|
|
98
65
|
|
|
99
|
-
###
|
|
66
|
+
### 方式一:插件市场(推荐)
|
|
100
67
|
|
|
101
|
-
1.
|
|
102
|
-
2.
|
|
68
|
+
1. 插件 → **插件市场** 标签 → 搜索 `dsh-message-actions`。
|
|
69
|
+
2. 卡片右侧点「安装」;装好后同一张卡片显示「已安装」。
|
|
103
70
|
|
|
104
|
-
###
|
|
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 #
|
|
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
|
-
- `
|
|
146
|
-
-
|
|
147
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
+
## 配置项
|
|
216
87
|
|
|
217
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
### 哪些请求不计费
|
|
229
112
|
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
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
|
-
|
|
118
|
+
### 第三方网关与覆盖清单
|
|
240
119
|
|
|
241
|
-
|
|
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
|
-
|
|
124
|
+
第三方价格按 **精确模型名 → 最长模型前缀 → provider → 全局兜底** 依次匹配;都未命中时显示「未配置」,只统计 token、金额记 `0`,不会套用官方价。
|
|
248
125
|
|
|
249
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
##
|
|
154
|
+
## 反馈
|
|
288
155
|
|
|
289
|
-
[
|
|
156
|
+
- 问题与建议:[GitHub Issues](https://github.com/aijacko/dsh-message-actions/issues)
|
|
157
|
+
- 许可证:[MIT](LICENSE)
|