@laraveladmin/dsh-stay-awake 0.2.14 → 0.3.0
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/CHANGELOG.md +40 -0
- package/README.en.md +35 -11
- package/README.md +35 -11
- package/client.js +152 -12
- package/docs/REQUIREMENTS.md +35 -11
- package/docs/VERIFICATION.md +44 -0
- package/index.js +107 -1
- package/lib/auto-resume.js +95 -0
- package/lib/config.js +35 -0
- package/lib/probe.js +50 -0
- package/lib/resume.js +173 -0
- package/lib/server.js +22 -8
- package/lib/sound.js +19 -4
- package/lib/state.js +2 -1
- package/locale/en.json +1 -1
- package/locale/zh-Hant.json +6 -0
- package/locale/zh.json +1 -1
- package/market/index.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# 变更记录 · Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 新功能:断网自动重试
|
|
6
|
+
|
|
7
|
+
- 合盖休眠导致正在跑的一轮断网失败后,网络恢复时**自动按下 DSH 的「重试」**:调用宿主
|
|
8
|
+
`sessionController.prompt` 发送空内容(`retry` 来源)消息重跑失败的那一步,不往对话里插文字、
|
|
9
|
+
不重放已完成的工具调用。
|
|
10
|
+
- 触发判定与 DSH 自己的可续跑语义一致:本轮有被接纳的人类输入、有一次失败的模型请求、以网络类错误
|
|
11
|
+
(默认 `TRANSPORT` / `TIMEOUT`)结束;用户中断、等待审批、限流/服务端错误不触发。
|
|
12
|
+
- 重试前用 **TCP 探测**(默认 `api.deepseek.com:443`,只建连不发数据)确认网络真的恢复;
|
|
13
|
+
宿主休眠时定时器暂停,唤醒后 Wi-Fi 未连通就继续等。
|
|
14
|
+
- 预算:每会话每次故障最多 3 次、60 分钟内有效;用户自己发消息或该轮成功完成会重置;子代理会话不处理。
|
|
15
|
+
- 弹层新增「断网自动重试」开关(默认开,持久化到 `state.json`),开关下方实时显示
|
|
16
|
+
「等待网络恢复… / 正在自动重试… / 自动重试未成功」,底部状态行提示「已自动重试」。
|
|
17
|
+
- 宿主协议升到 3;不再假设旧宿主可用:协议不匹配时弹层提示重新加载。
|
|
18
|
+
|
|
19
|
+
### 新功能:需要你回答时响一声
|
|
20
|
+
|
|
21
|
+
- agent 提问(`ask_user_question`)或工具调用等审批时立即响一声——这是唯一「回合还没结束也会响」的
|
|
22
|
+
提示音,否则它在你离开后会一直安静地等。监听宿主 waterfall 事件 `user-questions/request` 与
|
|
23
|
+
`approval/request`,旁路调用 `next()`,不干扰问答本身。
|
|
24
|
+
- 第三种音效:macOS `Ping`、Windows `SystemSounds.Question`、Linux `message.oga`,可自定义
|
|
25
|
+
`questionSound`;受同一个「提示音」总开关约束,1 秒节流防连响。
|
|
26
|
+
|
|
27
|
+
### 界面与多语言
|
|
28
|
+
|
|
29
|
+
- 弹层「完成提示音」改名「提示音」,旁边改为「完成 / 失败 / 提醒」三个小按钮,可分别试听三种音效
|
|
30
|
+
(宿主 `test-sound` 新增 `kind` 参数,未知值 400)。
|
|
31
|
+
- 新增**繁体中文**完整字典:DSH 只内置简体,插件通过 `ctx.locale.addLanguage` 贡献可选语言
|
|
32
|
+
「繁體中文」(id `zh-Hant`,回退 `zh`),并新增 `locale/zh-Hant.json` 供插件管理器显示;三套字典
|
|
33
|
+
各 54 键、键集合一致。
|
|
34
|
+
|
|
35
|
+
### 文档与测试
|
|
36
|
+
|
|
37
|
+
- README 中英新增「断网自动重试」「提示音(含提问提醒)」章节与繁体说明,并更正「不联网」表述:
|
|
38
|
+
唯一外发动作是探测,且可关闭。
|
|
39
|
+
- REQUIREMENTS 新增 FR-12 与 AC-21~24、FR-10.15~17;VERIFICATION 记录本轮验证范围与未验证项。
|
|
40
|
+
- 新增 28 项测试(失败判定状态机、探测、调度器、预算/窗口、开关、提问提醒、试听三音效),单测 81 → 109。
|
|
41
|
+
|
|
42
|
+
|
|
3
43
|
## 0.2.14 — 2026-12-03
|
|
4
44
|
|
|
5
45
|
### 修复
|
package/README.en.md
CHANGED
|
@@ -31,14 +31,27 @@ Most existing plugins equate "a task" with "a session in the running state". DSH
|
|
|
31
31
|
|
|
32
32
|
The rule is a pure function: `wanted = enabled && (agents + maintenance + jobs > 0)`. Exactly one system power assertion is held process-wide.
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Sounds
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Three moments each get one cue, played on the machine that runs the DSH host — they reach you even when the window is minimised.
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
38
|
+
- **Done**: one chime per work segment (from work starting to everything finishing), including background jobs and multiple sessions. `Glass` by default.
|
|
39
|
+
- **Failed**: the turn ended with an error or an interrupt. `Basso` by default.
|
|
40
|
+
- **Your turn**: the agent asked a question (`ask_user_question`) or a tool call waits for approval — rings immediately. `Ping` by default. This is the only cue that can fire while the turn is still open; without it the agent would wait for you in silence.
|
|
41
|
+
- Segments shorter than 20 seconds stay silent; autonomous goal/scheduled rounds stay silent (questions and approvals still ring).
|
|
42
|
+
- The panel's **Sounds** master switch covers all three; three small buttons (Done / Error / Alert) audition each cue.
|
|
43
|
+
- Sound files, volume, the minimum duration and whether questions ring live in `cordis.patch.yml`.
|
|
44
|
+
|
|
45
|
+
## Retry after reconnect
|
|
46
|
+
|
|
47
|
+
A closed lid drops the connection under a running turn: DSH retries `TRANSPORT` / `TIMEOUT` five times with backoff, then stops and waits for you to press Retry. This feature **presses that button for you once the network is back**.
|
|
48
|
+
|
|
49
|
+
- **Trigger**: a turn ended with a network-class failure (default `TRANSPORT` / `TIMEOUT`) after you had sent input and a model request had actually been attempted. User aborts, approval waits, rate limits and server errors never trigger it.
|
|
50
|
+
- **When it fires**: every 15 seconds the plugin makes a **TCP connection probe** to `api.deepseek.com:443` — handshake only, no request data, no session content read. The retry happens on the first successful probe. Timers are suspended during host sleep, so after a wake it simply keeps waiting until Wi-Fi is really up.
|
|
51
|
+
- **How it retries**: exactly like the Retry button — an **empty `retry` message** re-runs the failed step. No text is injected into the conversation and completed tool calls are not replayed.
|
|
52
|
+
- **Budget**: at most **3** automatic retries per failure, valid for **60 minutes**. A message you send yourself, or a later successful turn, resets the budget. Subagent sessions are left alone (their parent owns the failure).
|
|
53
|
+
- **Off means off**: switching the panel toggle off clears the queue immediately; a host restart does not keep pending retries.
|
|
54
|
+
- **Dependency**: needs DSH's `sessionController` service (present in Desktop and Web). Without it the feature degrades silently — keep-awake and the sound keep working.
|
|
42
55
|
|
|
43
56
|
## Behaviour
|
|
44
57
|
|
|
@@ -157,13 +170,22 @@ Override the row by id in the profile's `cordis.patch.yml`:
|
|
|
157
170
|
reconcileSeconds: 60 # reconciliation interval, 0 = disabled
|
|
158
171
|
maxMaintenanceMinutes: 120 # longest a maintenance bracket may stay open
|
|
159
172
|
caffeinatePath: /usr/bin/caffeinate # macOS only, advanced override
|
|
160
|
-
sound: true #
|
|
173
|
+
sound: true # sounds master switch (panel toggle)
|
|
161
174
|
soundOnError: true # different sound for failures
|
|
162
175
|
soundMinSeconds: 20 # stay silent below this duration, 0 = always
|
|
163
176
|
soundOnlyUserTasks: true # ignore autonomous rounds
|
|
177
|
+
soundOnQuestion: true # ring when a question/approval waits (no separate toggle)
|
|
178
|
+
questionSound: '' # custom "your turn" sound file (absolute path)
|
|
164
179
|
soundVolume: 1 # 0-3, macOS/Linux
|
|
165
180
|
successSound: '' # custom completion file (absolute path)
|
|
166
181
|
errorSound: '' # custom failure file
|
|
182
|
+
autoResume: true # retry after reconnect (panel toggle)
|
|
183
|
+
autoResumeCodes: [TRANSPORT, TIMEOUT] # failure codes that trigger it
|
|
184
|
+
autoResumeProbeHost: api.deepseek.com # probe target (TCP, no data sent)
|
|
185
|
+
autoResumeProbePort: 443
|
|
186
|
+
autoResumeProbeIntervalMs: 15000 # probe interval
|
|
187
|
+
autoResumeWindowMinutes: 60 # how long a failure stays retryable
|
|
188
|
+
autoResumeMaxAttempts: 3 # automatic retries per failure
|
|
167
189
|
```
|
|
168
190
|
|
|
169
191
|
Invalid values fall back to their defaults with a warning; a bad config never blocks loading.
|
|
@@ -185,7 +207,8 @@ Clicking the icon or the "Stay awake" label opens a panel **above the status bar
|
|
|
185
207
|
|---|---|
|
|
186
208
|
| Enabled | Turning it off releases the assertion immediately |
|
|
187
209
|
| Allow display sleep | On = block system sleep only; off = keep the screen on too |
|
|
188
|
-
|
|
|
210
|
+
| Sounds | One cue when a task ends, fails, or needs your answer; three buttons audition each |
|
|
211
|
+
| Retry after reconnect | Retry the turn that failed offline once the network is back (on by default) |
|
|
189
212
|
| Hold for | 30 min / 2 h / cancel, for temporary keeps |
|
|
190
213
|
| Status block | Active sources, scope, backend, hold duration, error reason |
|
|
191
214
|
| Footer | Where advanced options live, source link, version |
|
|
@@ -232,12 +255,13 @@ systemd-inhibit --list
|
|
|
232
255
|
|
|
233
256
|
**Compatibility**: `package.json` declares `engines.dsh: >=0.2.0`, which the plugin market uses for its compatibility badge; older DSH versions are refused.
|
|
234
257
|
|
|
235
|
-
**Local writes**: exactly one state file, `~/.dsh/plugin-data/dsh-stay-awake/state.json` (the
|
|
258
|
+
**Local writes and network**: exactly one state file, `~/.dsh/plugin-data/dsh-stay-awake/state.json` (the panel preferences). It does not modify system power plans, request privileges, read session content, or use the network for update checks. The one outbound action is the **TCP reachability probe** (default `api.deepseek.com:443`, handshake only, no data) while Retry after reconnect is enabled; turning that toggle off stops it.
|
|
236
259
|
|
|
237
260
|
## Internationalization
|
|
238
261
|
|
|
239
|
-
- The
|
|
240
|
-
-
|
|
262
|
+
- The indicator and panel follow the active DSH locale with three complete dictionaries: **Simplified Chinese, Traditional Chinese and English**; other locales fall back to English.
|
|
263
|
+
- DSH ships Simplified Chinese only, so the plugin registers 「繁體中文」 through `ctx.locale.addLanguage` (id `zh-Hant`, falling back to `zh`): plugin copy becomes fully Traditional while the rest of the GUI falls back to Simplified and stays readable.
|
|
264
|
+
- The plugin manager title and description are localized as well (`locale/zh.json`, `locale/zh-Hant.json`, `locale/en.json`).
|
|
241
265
|
- Repository documentation: [简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md).
|
|
242
266
|
|
|
243
267
|
## Development
|
package/README.md
CHANGED
|
@@ -31,14 +31,27 @@ DSH 跑长任务时你离开电脑,系统按空闲策略休眠:进程被挂
|
|
|
31
31
|
|
|
32
32
|
判定为纯函数:`wanted = enabled && (会话 + 维护期 + 后台任务 > 0)`。全局只持有一个系统电源断言。
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## 提示音
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
三种时机各响一声,不用盯着屏幕——声音在**运行 DSH 的这台机器**上播放,窗口最小化也听得到。
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
38
|
+
- **完成**:一次「工作段」(从有工作到全部结束)结束时响一次,含后台任务与多会话。默认 `Glass`。
|
|
39
|
+
- **失败**:这一轮以错误/中断结束,默认 `Basso`。
|
|
40
|
+
- **需要你回答**:agent 用 `ask_user_question` 提问、或工具调用等审批时立刻响,默认 `Ping`——这是唯一一个「回合还没结束也响」的情况,否则它会一直安静地等你。
|
|
41
|
+
- 短于 20 秒的任务不响;goal/定时任务等自主轮次不响,避免连响(但提问/审批仍然会提醒你)。
|
|
42
|
+
- 弹层「提示音」总开关控制全部三种;旁边三个小按钮「完成 / 失败 / 提醒」可分别试听。
|
|
43
|
+
- 音效文件、音量、最短时长、是否提醒提问在 `cordis.patch.yml` 配置。
|
|
44
|
+
|
|
45
|
+
## 断网自动重试
|
|
46
|
+
|
|
47
|
+
合盖休眠会让正在跑的那一轮断网失败:DSH 自己会按 `TRANSPORT` / `TIMEOUT` 退避重试 5 次,仍失败就停下等你点「重试」。这个功能在**网络恢复后替你按下那个按钮**。
|
|
48
|
+
|
|
49
|
+
- **触发条件**:某一轮以网络类错误结束(默认 `TRANSPORT` / `TIMEOUT`),且这一轮有你发出的输入、也真的发起过模型请求。用户主动中断、等待审批、限流/服务端错误都不会触发。
|
|
50
|
+
- **生效时机**:每 15 秒对 `api.deepseek.com:443` 做一次 **TCP 连接探测**——只建连,不发任何数据、不读会话内容;通了才重试。宿主休眠时定时器本来就会暂停,唤醒后 Wi-Fi 还没连上就继续等。
|
|
51
|
+
- **重试方式**:等价于界面上的「重试」按钮——发一条**空内容的 retry 消息**重跑失败的那一步,不会往对话里塞文字,也不会重放已完成的工具调用。
|
|
52
|
+
- **上限**:每个会话每次故障最多自动重试 **3 次**、**60 分钟**内有效;你在这期间自己发了消息、或这一轮后来成功完成,计数就重置。子代理会话不处理(由父会话负责)。
|
|
53
|
+
- **关掉即取消**:关闭弹层里的开关会立即清空等待队列;宿主重启后不保留待重试队列。
|
|
54
|
+
- **依赖**:需要 DSH 的 `sessionController` 服务(桌面版与 Web 版都提供);拿不到时功能静默降级,不影响保活与提示音。
|
|
42
55
|
|
|
43
56
|
## 释放与自愈
|
|
44
57
|
|
|
@@ -158,13 +171,22 @@ DSH 默认不带任何索引源。添加本项目随 npm 包发布的索引文
|
|
|
158
171
|
reconcileSeconds: 60 # 对账间隔,0 = 关闭
|
|
159
172
|
maxMaintenanceMinutes: 120 # 维护期括号的最长有效期
|
|
160
173
|
caffeinatePath: /usr/bin/caffeinate # 仅 macOS,高级覆盖
|
|
161
|
-
sound: true #
|
|
174
|
+
sound: true # 提示音总开关(弹层开关)
|
|
162
175
|
soundOnError: true # 失败/中断用不同音效
|
|
163
176
|
soundMinSeconds: 20 # 短于该时长不响,0 = 都响
|
|
164
177
|
soundOnlyUserTasks: true # 只响用户发起的任务,自主轮次不响
|
|
178
|
+
soundOnQuestion: true # 提问/等待审批时提醒(默认开,无独立开关)
|
|
179
|
+
questionSound: '' # 自定义「提醒」音文件(绝对路径)
|
|
165
180
|
soundVolume: 1 # 0~3,macOS/Linux 生效
|
|
166
181
|
successSound: '' # 自定义完成音文件(绝对路径)
|
|
167
182
|
errorSound: '' # 自定义失败音文件
|
|
183
|
+
autoResume: true # 断网自动重试(弹层开关)
|
|
184
|
+
autoResumeCodes: [TRANSPORT, TIMEOUT] # 触发自动重试的失败码
|
|
185
|
+
autoResumeProbeHost: api.deepseek.com # 探测目标(TCP,不发送数据)
|
|
186
|
+
autoResumeProbePort: 443
|
|
187
|
+
autoResumeProbeIntervalMs: 15000 # 探测间隔
|
|
188
|
+
autoResumeWindowMinutes: 60 # 失败后多久内仍然自动重试
|
|
189
|
+
autoResumeMaxAttempts: 3 # 每次故障最多自动重试几次
|
|
168
190
|
```
|
|
169
191
|
|
|
170
192
|
非法值会回落到默认值并记一条 warning,不会导致插件加载失败。
|
|
@@ -186,7 +208,8 @@ DSH 默认不带任何索引源。添加本项目随 npm 包发布的索引文
|
|
|
186
208
|
|---|---|
|
|
187
209
|
| 总开关 | 关掉后立即释放断言,不再自动保持 |
|
|
188
210
|
| 允许屏幕休眠 | 开 = 只防系统休眠;关 = 连屏幕一起保持 |
|
|
189
|
-
|
|
|
211
|
+
| 提示音 | 完成 / 失败 / 需要你回答时各响一声;旁边三个按钮可分别试听 |
|
|
212
|
+
| 断网自动重试 | 网络恢复后自动重试因断网失败的那一轮(默认开) |
|
|
190
213
|
| 临时保持 | 30 分钟 / 2 小时 / 取消,用于临时不想让机器睡 |
|
|
191
214
|
| 状态区 | 活跃源、范围、后端、已持续时长、错误原因 |
|
|
192
215
|
| 底部 | 高级参数在哪改、源码链接、版本号 |
|
|
@@ -235,12 +258,13 @@ systemd-inhibit --list
|
|
|
235
258
|
|
|
236
259
|
**兼容性声明**:`package.json` 声明 `engines.dsh: >=0.2.0`,插件市场据此显示兼容性;低于该版本的 DSH 会被拒绝安装。
|
|
237
260
|
|
|
238
|
-
|
|
261
|
+
**本地写入与网络**:只写一个状态文件 `~/.dsh/plugin-data/dsh-stay-awake/state.json`(弹层里的偏好),不碰系统电源计划、不申请提权、不读取会话内容、不联网检查更新。唯一的外发动作是开启「断网自动重试」后对配置的主机做 **TCP 连接探测**(默认 `api.deepseek.com:443`,只建连、不发送任何数据);关掉该开关即停止。
|
|
239
262
|
|
|
240
263
|
## 多语言
|
|
241
264
|
|
|
242
|
-
-
|
|
243
|
-
-
|
|
265
|
+
- 状态栏指示器与弹层跟随 DSH 当前语言,内置**简体中文、繁體中文、英文**三套完整字典;其余语言回退到英文。
|
|
266
|
+
- DSH 本身只内置简体中文,因此插件通过 `ctx.locale.addLanguage` 注册了「繁體中文」(id `zh-Hant`,回退到 `zh`):选择它之后插件文案是完整繁体,DSH 其余界面回退简体,仍然可读。
|
|
267
|
+
- 插件管理器中的标题与说明同样提供三种语言(`locale/zh.json`、`locale/zh-Hant.json`、`locale/en.json`)。
|
|
244
268
|
- 仓库文档:[简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md)。
|
|
245
269
|
|
|
246
270
|
## 开发
|
package/client.js
CHANGED
|
@@ -22,6 +22,8 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
const NPM_URL = `https://www.npmjs.com/package/${PACKAGE_NAME}/v/`
|
|
23
23
|
const POLL_MIN_MS = 3000
|
|
24
24
|
const POLL_MAX_MS = 60000
|
|
25
|
+
// Host protocol this client understands: 3 adds the auto-resume switch.
|
|
26
|
+
const PROTOCOL = 3
|
|
25
27
|
// A protection indicator must never claim "holding" while it cannot prove it.
|
|
26
28
|
const UNKNOWN_AFTER_FAILURES = 2
|
|
27
29
|
|
|
@@ -60,10 +62,19 @@ window.__ModuleLoader__.load({
|
|
|
60
62
|
'panel.hold30': '30 分钟',
|
|
61
63
|
'panel.hold120': '2 小时',
|
|
62
64
|
'panel.holdCancel': '取消',
|
|
63
|
-
'panel.sound': '
|
|
65
|
+
'panel.sound': '提示音',
|
|
64
66
|
'panel.testSound': '试听',
|
|
67
|
+
'panel.testSuccess': '完成',
|
|
68
|
+
'panel.testError': '失败',
|
|
69
|
+
'panel.testQuestion': '提醒',
|
|
65
70
|
'panel.testPlayed': '试听已播放',
|
|
66
71
|
'panel.testUnavailable': '试听失败:没有可用的播放器',
|
|
72
|
+
'panel.autoResume': '断网自动重试',
|
|
73
|
+
'panel.autoResumeHint': '网络恢复后自动重试因断网失败的那一轮',
|
|
74
|
+
'panel.resumeWaiting': '等待网络恢复…',
|
|
75
|
+
'panel.resumeRetrying': '正在自动重试…',
|
|
76
|
+
'panel.resumeFailed': '自动重试未成功',
|
|
77
|
+
'panel.resumeRetried': '已自动重试(网络已恢复)',
|
|
67
78
|
'panel.holdDisabled': '总开关关闭时无法临时保持',
|
|
68
79
|
'panel.holdLeft': '剩余',
|
|
69
80
|
'panel.saved': '已保存',
|
|
@@ -109,10 +120,19 @@ window.__ModuleLoader__.load({
|
|
|
109
120
|
'panel.hold30': '30 min',
|
|
110
121
|
'panel.hold120': '2 h',
|
|
111
122
|
'panel.holdCancel': 'Cancel',
|
|
112
|
-
'panel.sound': '
|
|
123
|
+
'panel.sound': 'Sounds',
|
|
113
124
|
'panel.testSound': 'Test',
|
|
125
|
+
'panel.testSuccess': 'Done',
|
|
126
|
+
'panel.testError': 'Error',
|
|
127
|
+
'panel.testQuestion': 'Alert',
|
|
114
128
|
'panel.testPlayed': 'Test sound played',
|
|
115
129
|
'panel.testUnavailable': 'Test failed: no player found',
|
|
130
|
+
'panel.autoResume': 'Retry after reconnect',
|
|
131
|
+
'panel.autoResumeHint': 'Retry the turn that failed offline once the network is back',
|
|
132
|
+
'panel.resumeWaiting': 'Waiting for the network…',
|
|
133
|
+
'panel.resumeRetrying': 'Retrying automatically…',
|
|
134
|
+
'panel.resumeFailed': 'Automatic retry did not go through',
|
|
135
|
+
'panel.resumeRetried': 'Retried after the network came back',
|
|
116
136
|
'panel.holdDisabled': 'Enable the plugin first to hold',
|
|
117
137
|
'panel.holdLeft': 'left',
|
|
118
138
|
'panel.saved': 'Saved',
|
|
@@ -123,6 +143,64 @@ window.__ModuleLoader__.load({
|
|
|
123
143
|
'panel.npm': 'View this version on npm',
|
|
124
144
|
}
|
|
125
145
|
|
|
146
|
+
const ZHT = {
|
|
147
|
+
'brand': '守夜',
|
|
148
|
+
'state.connecting': '連線中',
|
|
149
|
+
'state.idle': '未保持',
|
|
150
|
+
'state.releasing': '釋放中',
|
|
151
|
+
'state.holding': '保持中',
|
|
152
|
+
'state.failed': '異常',
|
|
153
|
+
'state.disabled': '已關閉',
|
|
154
|
+
'state.unknown': '狀態未知',
|
|
155
|
+
'detail.backend': '後端',
|
|
156
|
+
'detail.scope': '範圍',
|
|
157
|
+
'detail.sources': '作用中來源',
|
|
158
|
+
'detail.since': '已持續',
|
|
159
|
+
'detail.error': '原因',
|
|
160
|
+
'sources.agents': '會話',
|
|
161
|
+
'sources.maintenance': '維護',
|
|
162
|
+
'sources.jobs': '背景工作',
|
|
163
|
+
'scope.system': '僅系統',
|
|
164
|
+
'scope.display': '含螢幕',
|
|
165
|
+
'unit.none': '無',
|
|
166
|
+
'hint.unreachable': '無法連線宿主狀態服務,DSH 可能正在重新啟動',
|
|
167
|
+
'error.exited': '電源斷言被意外終止,正在重試',
|
|
168
|
+
'error.backend': '無法啟動電源斷言後端',
|
|
169
|
+
'error.unsupported': '目前平台沒有可用的電源後端',
|
|
170
|
+
'error.unknown': '電源斷言發生未知錯誤',
|
|
171
|
+
'backend.caffeinate': 'macOS 系統喚醒(caffeinate)',
|
|
172
|
+
'backend.setthreadexecutionstate': 'Windows 執行狀態鎖',
|
|
173
|
+
'backend.systemd-inhibit': 'systemd 抑制鎖',
|
|
174
|
+
'panel.enabled': '總開關',
|
|
175
|
+
'panel.allowDisplaySleep': '允許螢幕休眠',
|
|
176
|
+
'panel.allowDisplaySleepHint': '開啟後只防止系統休眠,螢幕依系統設定熄滅',
|
|
177
|
+
'panel.hold': '臨時保持',
|
|
178
|
+
'panel.hold30': '30 分鐘',
|
|
179
|
+
'panel.hold120': '2 小時',
|
|
180
|
+
'panel.holdCancel': '取消',
|
|
181
|
+
'panel.sound': '提示音',
|
|
182
|
+
'panel.testSound': '試聽',
|
|
183
|
+
'panel.testSuccess': '完成',
|
|
184
|
+
'panel.testError': '失敗',
|
|
185
|
+
'panel.testQuestion': '提醒',
|
|
186
|
+
'panel.testPlayed': '試聽已播放',
|
|
187
|
+
'panel.testUnavailable': '試聽失敗:沒有可用的播放程式',
|
|
188
|
+
'panel.autoResume': '斷網自動重試',
|
|
189
|
+
'panel.autoResumeHint': '網路恢復後自動重試因斷網失敗的那一輪',
|
|
190
|
+
'panel.resumeWaiting': '等待網路恢復…',
|
|
191
|
+
'panel.resumeRetrying': '正在自動重試…',
|
|
192
|
+
'panel.resumeFailed': '自動重試未成功',
|
|
193
|
+
'panel.resumeRetried': '已自動重試(網路已恢復)',
|
|
194
|
+
'panel.holdDisabled': '總開關關閉時無法臨時保持',
|
|
195
|
+
'panel.holdLeft': '剩餘',
|
|
196
|
+
'panel.saved': '已儲存',
|
|
197
|
+
'panel.saveFailed': '儲存失敗,請重試',
|
|
198
|
+
'panel.staleHost': '宿主端未載入最新版本:請在外掛頁面停用再啟用「守夜」,或重新啟動 DSH',
|
|
199
|
+
'panel.advanced': '防抖、兜底時長等進階參數在 profile 的 cordis.patch.yml 中設定',
|
|
200
|
+
'panel.repo': '開啟程式碼倉庫',
|
|
201
|
+
'panel.npm': '在 npm 查看此版本',
|
|
202
|
+
}
|
|
203
|
+
|
|
126
204
|
const CSS = `
|
|
127
205
|
.dsa-pill{box-sizing:border-box;border-radius:var(--dsw-radius-sm);max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer;anchor-name:--dsh-stay-awake-panel}
|
|
128
206
|
.dsa-pill[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}
|
|
@@ -162,6 +240,11 @@ window.__ModuleLoader__.load({
|
|
|
162
240
|
.dsa-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
|
|
163
241
|
.dsa-button{border:0;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:var(--dsw-radius-sm);padding:4px 10px;cursor:pointer;font:inherit;line-height:16px}
|
|
164
242
|
.dsa-button:active:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
|
243
|
+
.dsa-choices{display:inline-flex;align-items:center;gap:2px;padding:2px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-2);flex:none}
|
|
244
|
+
.dsa-choice{border:0;background:0 0;border-radius:calc(var(--dsw-radius-sm) - 1px);padding:2px 6px;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:14px;cursor:pointer}
|
|
245
|
+
@media (hover:hover){.dsa-choice:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}
|
|
246
|
+
.dsa-choice:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
247
|
+
.dsa-choice:disabled{opacity:.5;cursor:default}
|
|
165
248
|
.dsa-button:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
166
249
|
.dsa-button:disabled{opacity:.5;cursor:default}
|
|
167
250
|
.dsa-button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
@@ -284,6 +367,8 @@ window.__ModuleLoader__.load({
|
|
|
284
367
|
if (notice === null || notice === undefined || notice === 'stale') return null
|
|
285
368
|
if (notice === 'testPlayed') return { text: `\u2713 ${t('panel.testPlayed')}` }
|
|
286
369
|
if (notice === 'testUnavailable') return { text: t('panel.testUnavailable'), tone: 'error' }
|
|
370
|
+
if (notice === 'resumeRetried') return { text: `\u2713 ${t('panel.resumeRetried')}` }
|
|
371
|
+
if (notice === 'resumeFailed') return { text: t('panel.resumeFailed'), tone: 'error' }
|
|
287
372
|
if (notice === 'failed') {
|
|
288
373
|
return {
|
|
289
374
|
text: `${t('panel.saveFailed')}${snapshot.noticeStatus ? ` (${snapshot.noticeStatus})` : ''}`,
|
|
@@ -399,7 +484,9 @@ window.__ModuleLoader__.load({
|
|
|
399
484
|
const enabled = status === null ? true : status.enabled !== false
|
|
400
485
|
const allowDisplaySleep = (status === null ? 'system' : status.scope) === 'system'
|
|
401
486
|
const soundOn = status === null ? true : status.sound !== false
|
|
402
|
-
const
|
|
487
|
+
const autoResumeOn = status === null ? true : status.autoResume !== false
|
|
488
|
+
const resume = status !== null && status.resume !== null && typeof status.resume === 'object' ? status.resume : null
|
|
489
|
+
const staleHost = status !== null && status.protocol !== PROTOCOL
|
|
403
490
|
const counts = status && status.counts ? status.counts : { agents: 0, maintenance: 0, jobs: 0 }
|
|
404
491
|
const holdLeft = status && typeof status.manualUntil === 'number' && status.manualUntil > Date.now()
|
|
405
492
|
? status.manualUntil - Date.now()
|
|
@@ -425,6 +512,16 @@ window.__ModuleLoader__.load({
|
|
|
425
512
|
|
|
426
513
|
if (!open) return null
|
|
427
514
|
|
|
515
|
+
const resumeHint = resume === null
|
|
516
|
+
? t('panel.autoResumeHint')
|
|
517
|
+
: resume.state === 'waiting'
|
|
518
|
+
? t('panel.resumeWaiting')
|
|
519
|
+
: resume.state === 'retrying'
|
|
520
|
+
? t('panel.resumeRetrying')
|
|
521
|
+
: resume.state === 'failed'
|
|
522
|
+
? t('panel.resumeFailed')
|
|
523
|
+
: t('panel.autoResumeHint')
|
|
524
|
+
|
|
428
525
|
const backend = backendInfo(t, status)
|
|
429
526
|
const rows = [
|
|
430
527
|
[t('detail.sources'), `${t('sources.agents')} ${counts.agents ?? 0} · ${t('sources.maintenance')} ${counts.maintenance ?? 0} · ${t('sources.jobs')} ${counts.jobs ?? 0}`],
|
|
@@ -501,14 +598,35 @@ window.__ModuleLoader__.load({
|
|
|
501
598
|
'div',
|
|
502
599
|
{ className: 'dsa-row' },
|
|
503
600
|
h('span', { className: 'dsa-grow' }, t('panel.sound')),
|
|
504
|
-
h(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
601
|
+
h(
|
|
602
|
+
'span',
|
|
603
|
+
{
|
|
604
|
+
className: 'dsa-choices',
|
|
605
|
+
role: 'group',
|
|
606
|
+
'aria-label': t('panel.testSound'),
|
|
607
|
+
title: t('panel.testSound'),
|
|
608
|
+
},
|
|
609
|
+
[['success', 'panel.testSuccess'], ['error', 'panel.testError'], ['question', 'panel.testQuestion']]
|
|
610
|
+
.map(([kind, key]) => h('button', {
|
|
611
|
+
key: kind,
|
|
612
|
+
type: 'button',
|
|
613
|
+
className: 'dsa-choice',
|
|
614
|
+
disabled: unreachable || staleHost,
|
|
615
|
+
title: `${t('panel.testSound')} · ${t(key)}`,
|
|
616
|
+
onClick: () => act({ action: 'test-sound', kind }),
|
|
617
|
+
}, t(key))),
|
|
618
|
+
),
|
|
510
619
|
switchOf(soundOn, () => act({ action: 'set-sound', enabled: !soundOn }), t('panel.sound')),
|
|
511
620
|
),
|
|
621
|
+
h(
|
|
622
|
+
'div',
|
|
623
|
+
{ className: 'dsa-row' },
|
|
624
|
+
h('span', { className: 'dsa-grow' },
|
|
625
|
+
h('div', null, t('panel.autoResume')),
|
|
626
|
+
h('div', { className: 'dsa-sub' }, resumeHint),
|
|
627
|
+
),
|
|
628
|
+
switchOf(autoResumeOn, () => act({ action: 'set-auto-resume', enabled: !autoResumeOn }), t('panel.autoResume'), staleHost),
|
|
629
|
+
),
|
|
512
630
|
),
|
|
513
631
|
h(
|
|
514
632
|
'div',
|
|
@@ -584,12 +702,25 @@ window.__ModuleLoader__.load({
|
|
|
584
702
|
apply(ctx) {
|
|
585
703
|
const t = ctx.locale.bind(NS)
|
|
586
704
|
|
|
705
|
+
// DSH ships Simplified Chinese but not Traditional; a language pack may
|
|
706
|
+
// extend the catalog. Falling back to `zh` means the rest of the GUI
|
|
707
|
+
// stays readable, and only this plugin's copy switches to 繁體中文.
|
|
708
|
+
ctx.effect(() => {
|
|
709
|
+
try {
|
|
710
|
+
return ctx.locale.addLanguage({ id: 'zh-Hant', label: '繁體中文', fallback: 'zh' })
|
|
711
|
+
} catch {
|
|
712
|
+
// Already contributed (another language pack, or a reload): the
|
|
713
|
+
// dictionary registration below is what actually matters.
|
|
714
|
+
return () => {}
|
|
715
|
+
}
|
|
716
|
+
}, 'stay-awake: zh-Hant language')
|
|
717
|
+
|
|
587
718
|
ctx.effect(() => {
|
|
588
719
|
const disposers = []
|
|
589
720
|
try {
|
|
590
|
-
disposers.push(ctx.locale.register(NS, { zh: ZH, en: EN }))
|
|
721
|
+
disposers.push(ctx.locale.register(NS, { zh: ZH, en: EN, 'zh-Hant': ZHT }))
|
|
591
722
|
} catch {
|
|
592
|
-
for (const [locale, dict] of [['zh', ZH], ['en', EN]]) {
|
|
723
|
+
for (const [locale, dict] of [['zh', ZH], ['en', EN], ['zh-Hant', ZHT]]) {
|
|
593
724
|
try {
|
|
594
725
|
disposers.push(ctx.locale.register(NS, locale, dict))
|
|
595
726
|
} catch {
|
|
@@ -643,8 +774,17 @@ window.__ModuleLoader__.load({
|
|
|
643
774
|
const value = await response.json()
|
|
644
775
|
if (cancelled) return
|
|
645
776
|
delay = POLL_MIN_MS
|
|
646
|
-
const
|
|
777
|
+
const before = store.get().status
|
|
778
|
+
const clearStale = store.get().notice === 'stale' && value.protocol === PROTOCOL
|
|
647
779
|
store.set({ status: value, failures: 0, ...(clearStale ? { notice: null, noticeStatus: null } : {}) })
|
|
780
|
+
// The host performs the retry on its own clock, so the only way
|
|
781
|
+
// to report it is a transition between two polls.
|
|
782
|
+
const was = before && before.resume ? before.resume : null
|
|
783
|
+
const now = value && value.resume ? value.resume : null
|
|
784
|
+
if (was !== null && now !== null && was.state !== now.state) {
|
|
785
|
+
if (was.state !== 'retrying' && now.state === 'idle' && now.retries > was.retries) flashNotice('resumeRetried', null)
|
|
786
|
+
else if (was.state !== 'failed' && now.state === 'failed') flashNotice('resumeFailed', null)
|
|
787
|
+
}
|
|
648
788
|
} catch {
|
|
649
789
|
if (cancelled) return
|
|
650
790
|
delay = Math.min(Math.max(delay * 2, POLL_MIN_MS), POLL_MAX_MS)
|
package/docs/REQUIREMENTS.md
CHANGED
|
@@ -257,9 +257,25 @@ wanted = config.enabled && hasWork
|
|
|
257
257
|
| FR-11.2 | 从 Git 安装的用户更新到新的固定 commit;从本地目录(`link:`)安装的用户 `git pull` 即更新,没有版本概念,也不会出现更新提示 |
|
|
258
258
|
| FR-11.3 | Discover 索引源随每次发布更新;**首选 GitHub raw 地址**(推送即生效),jsDelivr 作为备用并在发布流程中主动 purge(无版本 URL 有 CDN 缓存,不 purge 会长期读到旧索引) |
|
|
259
259
|
| FR-11.4 | 更新不得影响用户配置:`cordis.patch.yml` 的 config 与 `state.json` 保留;当前版本在弹层底部显示 |
|
|
260
|
-
| FR-11.5 |
|
|
260
|
+
| FR-11.5 | 插件**不联网检查更新**,更新检测完全交给 DSH;唯一的网络动作是 FR-12 的 TCP 可达性探测,与更新检查无关 |
|
|
261
261
|
| FR-11.6 | 发布流程固定为:改版本 → 重建索引 → 全量测试 → 提交 → 双远端推送 → `npm publish` → purge CDN → 校验(见 `docs/RELEASING.md`) |
|
|
262
262
|
|
|
263
|
+
### FR-12 断网自动重试
|
|
264
|
+
|
|
265
|
+
目标:合盖休眠导致的那一轮断网失败,在用户回到电脑、网络恢复后自动续跑,不需要用户手动点「重试」。
|
|
266
|
+
|
|
267
|
+
| 序号 | 规则 |
|
|
268
|
+
|---|---|
|
|
269
|
+
| FR-12.1 | 判定复用 DSH 自身的可续跑语义:本轮以 `turn/end reason.kind = error` 结束,错误码属于网络类集合(默认 `TRANSPORT`、`TIMEOUT`,可由 `autoResumeCodes` 扩展),且本轮存在被接纳的人类输入(`user/message`,`source.kind = user` 且内容非空)与一次失败的模型请求(`assistant/attempt` 之后没有成功的 `assistant/message`) |
|
|
270
|
+
| FR-12.2 | 不触发的情形:用户主动中断(`aborted`)、等待审批(`blocked`)、`interrupted`、`max-tokens`、限流/服务端错误(默认码集之外的错误码) |
|
|
271
|
+
| FR-12.3 | 只处理普通会话:`header.parentSession` 存在或 `header.origin = subagent` 的子代理会话不参与,由父会话负责 |
|
|
272
|
+
| FR-12.4 | 触发前必须由 **TCP 探测**确认网络可达:间隔 `autoResumeProbeIntervalMs`(默认 15s),目标 `autoResumeProbeHost:Port`(默认 `api.deepseek.com:443`),只做三次握手,不发送任何数据、不读取会话内容 |
|
|
273
|
+
| FR-12.5 | 重试方式等价于界面「重试」按钮:调用宿主 `sessionController.prompt`,`content: []`(产生 `retry` 来源的空消息),`mode: queue`;宿主返回 `session/agent-busy` 时视为不可续跑并清除等待 |
|
|
274
|
+
| FR-12.6 | 预算:每个会话每次故障最多 `autoResumeMaxAttempts`(默认 3)次,`autoResumeWindowMinutes`(默认 60)分钟内有效;用户自己发消息或该轮成功完成会重置预算 |
|
|
275
|
+
| FR-12.7 | 失败受理、宿主缺少 `sessionController`、探测持续失败都只记日志并在弹层状态区提示,不影响保活与提示音 |
|
|
276
|
+
| FR-12.8 | 弹层提供「断网自动重试」开关(默认开,写入 `state.json`);关闭立即清空等待队列;宿主重启不保留待重试队列 |
|
|
277
|
+
| FR-12.9 | 状态可见:`/api/stay-awake` 回包附带 `autoResume` 与 `resume { state, retries, lastSentAt, failure }`,客户端在弹层开关下方显示「等待网络恢复… / 正在自动重试… / 自动重试未成功」,并复用底部状态行提示「已自动重试」;协议版本升到 3 |
|
|
278
|
+
|
|
263
279
|
### FR-10 任务结束提示音
|
|
264
280
|
|
|
265
281
|
目标:用户离开电脑时,任务结束能"听见",不必回来看屏幕。
|
|
@@ -275,20 +291,23 @@ wanted = config.enabled && hasWork
|
|
|
275
291
|
| FR-10.7 | **宿主端播放**(不依赖浏览器自动播放策略,DSH 窗口最小化/后台也能响):macOS `afplay`、Windows `System.Media.SystemSounds`、Linux `paplay`(不可用时静默降级) |
|
|
276
292
|
| FR-10.8 | 播放必须异步、不阻塞事件循环;子进程 `unref`,5 秒未结束则忽略;同一秒内最多播放一次 |
|
|
277
293
|
| FR-10.9 | 播放失败(无播放器、无音频文件、静音)只记日志,不弹错、不影响其它功能 |
|
|
278
|
-
| FR-10.10 |
|
|
279
|
-
| FR-10.11 |
|
|
294
|
+
| FR-10.10 | 支持试听:弹层提供「完成 / 失败 / 提醒」三个小按钮,分别调用宿主播放对应音效,用于确认设备与音量 |
|
|
295
|
+
| FR-10.11 | 弹层只放一个「提示音」总开关(覆盖完成/失败/提醒三种);音效文件、音量、最短时长、是否只响用户任务、是否提醒提问走 `cordis.patch.yml` |
|
|
280
296
|
| FR-10.12 | `sound` 开关与 `enabled`/`scope` 一样持久化到状态文件,重启后保持 |
|
|
281
297
|
|
|
282
298
|
| FR-10.13 | 插件总开关 `enabled=false` 时不响(用户明确关掉了整套防护) |
|
|
283
299
|
| FR-10.14 | 「试听」不受 `sound` 开关与 `enabled` 限制,任何时候都能验证设备与音量 |
|
|
300
|
+
| FR-10.15 | **需要你回答时响一声**:监听 waterfall 事件 `user-questions/request`(`ask_user_question`)与 `approval/request`(工具审批),旁路调用 `next()` 不干扰原流程,播放第三种音效(`Ping` / `SystemSounds.Question` / `message.oga`);这是唯一在回合未结束时也会响的提示音 |
|
|
301
|
+
| FR-10.16 | 提醒音受 `sound` 总开关与 `soundOnQuestion`(默认 true)控制,不受 `soundOnlyUserTasks` 影响(自主轮次提问也要人回答);1 秒节流防连响;播放失败只记日志,绝不打断问答 |
|
|
302
|
+
| FR-10.17 | 试听请求带 `kind ∈ {success, error, question}`,宿主据此播放对应音效;未知 kind 返回 400 |
|
|
284
303
|
|
|
285
304
|
平台默认音效:
|
|
286
305
|
|
|
287
|
-
| 平台 | 完成音 | 失败音 | 说明 |
|
|
288
|
-
|
|
289
|
-
| macOS | `/System/Library/Sounds/Glass.aiff` | `/System/Library/Sounds/Basso.aiff` | 播放器 `afplay`,支持 `-v` 音量 |
|
|
290
|
-
| Windows | `SystemSounds.Asterisk` | `SystemSounds.Hand` | PowerShell 调用,无音量参数 |
|
|
291
|
-
| Linux | `/usr/share/sounds/freedesktop/stereo/complete.oga` | `dialog-error.oga` | `paplay`;文件缺失则静默 |
|
|
306
|
+
| 平台 | 完成音 | 失败音 | 提醒音 | 说明 |
|
|
307
|
+
|---|---|---|---|---|
|
|
308
|
+
| macOS | `/System/Library/Sounds/Glass.aiff` | `/System/Library/Sounds/Basso.aiff` | `/System/Library/Sounds/Ping.aiff` | 播放器 `afplay`,支持 `-v` 音量 |
|
|
309
|
+
| Windows | `SystemSounds.Asterisk` | `SystemSounds.Hand` | `SystemSounds.Question` | PowerShell 调用,无音量参数 |
|
|
310
|
+
| Linux | `/usr/share/sounds/freedesktop/stereo/complete.oga` | `dialog-error.oga` | `message.oga` | `paplay`;文件缺失则静默 |
|
|
292
311
|
|
|
293
312
|
**边界说明**:系统静音、耳机未佩戴、音频设备切走时用户听不到,插件无法感知;DSH 跑在远程主机时声音在远端播放(本插件只作用于运行 Host 的机器)。
|
|
294
313
|
|
|
@@ -405,7 +424,7 @@ Idle ──wanted──▶ Holding ──!wanted──▶ Releasing ──超时
|
|
|
405
424
|
| NFR-1 | 零第三方运行时依赖,零 native 模块 |
|
|
406
425
|
| NFR-2 | 空闲开销:事件驱动 + 60s 对账,无高频轮询;稳态 CPU 占用可忽略,常驻内存增量 < 5MB |
|
|
407
426
|
| NFR-3 | 加载开销 < 50ms;acquire 延迟 < 500ms(Windows PowerShell 冷启动例外) |
|
|
408
|
-
| NFR-4 |
|
|
427
|
+
| NFR-4 | 隐私:不读取会话内容/提示词/文件内容;唯一本地写入是插件自己的状态文件;唯一外发动作是开启「断网自动重试」后对配置主机的 TCP 连接探测(只建连、不发数据,可关闭)。插件不联网检查更新 |
|
|
409
428
|
| NFR-5 | 兼容:不声明 `engines.dsh`;缺 `agents`/`jobs` 等服务时按可用性降级,不得阻塞启动 |
|
|
410
429
|
| NFR-6 | 可测:判定与状态机为纯逻辑,可注入时钟与 spawn;平台命令生成可单测 |
|
|
411
430
|
| NFR-7 | 安全:不修改系统电源计划,不申请提权,不写系统目录 |
|
|
@@ -453,6 +472,10 @@ Idle ──wanted──▶ Holding ──!wanted──▶ Releasing ──超时
|
|
|
453
472
|
| AC-18 | 提示音开启 | `run_in_background` 的 30 秒任务跑完 | 响一次,且不早于后台进程结束 |
|
|
454
473
|
| AC-19 | 提示音开启,`soundOnlyUserTasks` | 自主轮次(goal)结束 | 不响 |
|
|
455
474
|
| AC-20 | 无播放器/静音环境 | 任务结束 | 无异常抛出,插件其余功能正常 |
|
|
475
|
+
| AC-21 | 断网自动重试开启 | 任务中合盖休眠 → 唤醒、网络恢复 | 15–30s 内该轮自动续跑(对话中出现一条 retry 用户消息),无需手动点重试 |
|
|
476
|
+
| AC-22 | 断网自动重试开启 | 网络始终未恢复 | 不重试;弹层状态显示「等待网络恢复…」;恢复后才重试 |
|
|
477
|
+
| AC-23 | 断网自动重试开启 | 用户主动停止回合 → 关闭网络再恢复 | 不触发自动重试 |
|
|
478
|
+
| AC-24 | 断网自动重试开启 | 连续 3 次重试仍失败 | 停止,弹层显示「自动重试未成功」,不再尝试 |
|
|
456
479
|
|
|
457
480
|
平台归属:**AC-1 ~ AC-14 在 macOS 上由作者逐条真机验收**;Windows / Linux 先以单元测试与命令生成验证,真机验收由使用者或 CI 补充(见 §14.3)。
|
|
458
481
|
|
|
@@ -534,7 +557,8 @@ pgrep -fl "caffeinate -i -w"
|
|
|
534
557
|
| FR-1.3 后台任务 | ✅ 实现,逻辑测试覆盖 | `ctx.jobs` 事件 + `jobs.list(sessionId)` 对账;真机需用户在 agent idle 时跑后台任务观察 |
|
|
535
558
|
| FR-1.4 计划任务 | ❌ 未实现 | 仍为 P2 |
|
|
536
559
|
| FR-11 更新与发布运维 | ✅ 流程落地 | 更新由 DSH 插件管理器负责(registry 安装可一键更新、失败回滚);索引首选 GitHub raw,jsDelivr 发布后 purge;发布清单见 docs/RELEASING.md |
|
|
537
|
-
| FR-
|
|
560
|
+
| FR-12 断网自动重试 | ✅ 实现 | TCP 探测后调用宿主 `sessionController.prompt` 空内容 retry;失败码集合、探测目标、预算均可配置;真实合盖断网场景需用户在真机验收(见 VERIFICATION) |
|
|
561
|
+
| FR-10 提示音 | ✅ 实现 | 工作段结束(完成/失败)+ 需要你回答(提问/审批)三类音效、最短时长、仅用户任务、宿主端播放、弹层总开关 + 三种试听、提醒音配置;开关持久化 |
|
|
538
562
|
| FR-2 释放判定 | ✅ 实现并真机验证 | 防抖释放、竞争重算、禁用立即释放 |
|
|
539
563
|
| FR-3 三平台后端 | macOS ✅ 真机;Windows / Linux ✅ 实现 + 单测 | Windows/Linux 电源效果未真机验证 |
|
|
540
564
|
| FR-4.2 `scope` 热切换 | ✅ 实现 | 弹层切换时先起新断言再停旧的;改 `cordis.patch.yml` 的 scope 仍需要插件重载 |
|
|
@@ -542,7 +566,7 @@ pgrep -fl "caffeinate -i -w"
|
|
|
542
566
|
| FR-6 配置 | ✅ 除 `batteryPolicy` / `minBatteryPercent` | 两项未实现,也未暴露,避免"配置了却不生效" |
|
|
543
567
|
| FR-6.2 状态文件 | ✅ 实现 | `~/.dsh/plugin-data/dsh-stay-awake/state.json`,只存弹层里的 enabled/scope/sound;原子写(tmp+rename),损坏或非法值回落默认并记 warning |
|
|
544
568
|
| FR-7 可观测 | 🟡 部分 | 有内存环形日志与 `/api/stay-awake` 状态;无日志导出 |
|
|
545
|
-
| FR-8 UI | ✅ 可交互指示器 +
|
|
569
|
+
| FR-8 UI | ✅ 可交互指示器 + 设置弹层(简中/繁中/英文) | 点击状态栏「守夜」打开 `shell.overlay` 弹层:总开关、允许屏幕休眠、提示音(含完成/失败/提醒三种试听)、断网自动重试、临时保持(30 分钟 / 2 小时 / 取消)、状态详情、源码链接;面板与指示器共享单例状态,一个页面只有一个轮询 |
|
|
546
570
|
| FR-9 生命周期 | ✅ 实现并真机验证 | 禁用即释放、重新启用即重取、宿主 SIGKILL 不残留 |
|
|
547
571
|
|
|
548
572
|
**配置优先级**:`cordis.patch.yml` 提供默认值,弹层改过的 `enabled` / `scope` 以状态文件为准;其余参数(防抖、兜底时长、对账间隔等)只能改 patch。
|