@laraveladmin/dsh-stay-awake 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # 变更记录 · Changelog
2
2
 
3
+ ## 0.3.3 — 2026-12-03
4
+
5
+ ### 改进
6
+
7
+ - 「需要你回答」的提醒音改为**重复提醒直到你回答**:默认每 20 秒响一次、最多 10 分钟,问题被回答后立刻停止
8
+ (监听 waterfall 的 `next()` 结算来取消)。单声 `Ping` 太短太轻,离开屏幕时很容易错过。
9
+ - 新增配置 `questionRepeatSeconds`(默认 20,0 = 只响一次)与 `questionRepeatMaxMinutes`(默认 10)。
10
+ - 新增 2 项测试:未回答时确实重复、回答后停止;配置默认值与钳制。单测 113 → 115。
11
+
12
+ ### 说明
13
+
14
+ - 关于「重启后试听要点两次才出声」:宿主重启后的头几秒插件路由才注册完成,第一次点击可能落在宿主初始化窗口里;
15
+ 插件本身每次点击都会带 `force` 绕过 1 秒节流,不存在需要点两次的逻辑。
16
+
17
+
18
+ ## 0.3.2 — 2026-12-03
19
+
20
+ ### 修复
21
+
22
+ - **失败提示音误判**:之前把 `error` / `aborted` / `interrupted` / `blocked` 都当成失败。实际上 DSH 自己的
23
+ 聊天视图只对 `error`(以及重启补写的 `interrupted`)显示失败行,`aborted`(用户停止、父轮次收尾)、
24
+ `blocked`(守卫拒绝一步)、`max-tokens`、`forked` 都不算失败。所以成功完成也偶尔响 `Basso`。
25
+ - 现在只把 `error` 当作失败;一次工作段里有多个回合时以**最后一个普通会话回合**为准(重试成功不会再响失败音)。
26
+ - **子代理会话不再参与音效判断**:父轮次结束时会收尾子代理,那是一条 `aborted`,之前被当成失败;子代理内部的
27
+ prompt 也不再算作「用户发起的任务」(`soundOnlyUserTasks`)。
28
+ - 新增 4 项回归测试:子代理失败不污染父轮次成功、非失败结束不响、最后回合决定、子代理 prompt 不算用户任务。
29
+ 单测 109 → 113。
30
+
31
+
3
32
  ## 0.3.1 — 2026-12-03
4
33
 
5
34
  ### 修复
package/README.en.md CHANGED
@@ -36,8 +36,8 @@ The rule is a pure function: `wanted = enabled && (agents + maintenance + jobs >
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
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.
39
+ - **Failed**: only when the turn **really errored** (`error`). A stop you pressed, a rejected approval, a subagent wound down by its parent, `max-tokens` or `forked` do not count; when a work segment contains several turns, the **last ordinary-session turn** decides, so a retried success no longer rings the failure cue.
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. One short cue is easy to miss, so it **repeats every 20 seconds until you answer** (capped at 10 minutes) and stops the moment the question is answered.
41
41
  - Segments shorter than 20 seconds stay silent; autonomous goal/scheduled rounds stay silent (questions and approvals still ring).
42
42
  - The panel's **Sounds** master switch covers all three; three small buttons (Done / Error / Alert) audition each cue.
43
43
  - Sound files, volume, the minimum duration and whether questions ring live in `cordis.patch.yml`.
@@ -176,6 +176,8 @@ Override the row by id in the profile's `cordis.patch.yml`:
176
176
  soundOnlyUserTasks: true # ignore autonomous rounds
177
177
  soundOnQuestion: true # ring when a question/approval waits (no separate toggle)
178
178
  questionSound: '' # custom "your turn" sound file (absolute path)
179
+ questionRepeatSeconds: 20 # repeat the cue while unanswered, 0 = once
180
+ questionRepeatMaxMinutes: 10 # longest repeat window
179
181
  soundVolume: 1 # 0-3, macOS/Linux
180
182
  successSound: '' # custom completion file (absolute path)
181
183
  errorSound: '' # custom failure file
package/README.md CHANGED
@@ -36,8 +36,8 @@ DSH 跑长任务时你离开电脑,系统按空闲策略休眠:进程被挂
36
36
  三种时机各响一声,不用盯着屏幕——声音在**运行 DSH 的这台机器**上播放,窗口最小化也听得到。
37
37
 
38
38
  - **完成**:一次「工作段」(从有工作到全部结束)结束时响一次,含后台任务与多会话。默认 `Glass`。
39
- - **失败**:这一轮以错误/中断结束,默认 `Basso`。
40
- - **需要你回答**:agent 用 `ask_user_question` 提问、或工具调用等审批时立刻响,默认 `Ping`——这是唯一一个「回合还没结束也响」的情况,否则它会一直安静地等你。
39
+ - **失败**:只有这一轮**真的报错**(`error`)才响,默认 `Basso`。你主动按停止、审批被拒、子代理被父轮次收尾、`max-tokens`/`forked` 这类结束都不算失败;一个工作段里有多个回合时,以**最后一个普通会话回合**的结果为准,重试成功不会还响失败音。
40
+ - **需要你回答**:agent 用 `ask_user_question` 提问、或工具调用等审批时立刻响,默认 `Ping`——这是唯一一个「回合还没结束也响」的情况,否则它会一直静默等你。单声响很容易被错过,所以**在你回答之前每 20 秒重复一次**(最多 10 分钟),一旦回答就立刻停。
41
41
  - 短于 20 秒的任务不响;goal/定时任务等自主轮次不响,避免连响(但提问/审批仍然会提醒你)。
42
42
  - 弹层「提示音」总开关控制全部三种;旁边三个小按钮「完成 / 失败 / 提醒」可分别试听。
43
43
  - 音效文件、音量、最短时长、是否提醒提问在 `cordis.patch.yml` 配置。
@@ -177,6 +177,8 @@ DSH 默认不带任何索引源。添加本项目随 npm 包发布的索引文
177
177
  soundOnlyUserTasks: true # 只响用户发起的任务,自主轮次不响
178
178
  soundOnQuestion: true # 提问/等待审批时提醒(默认开,无独立开关)
179
179
  questionSound: '' # 自定义「提醒」音文件(绝对路径)
180
+ questionRepeatSeconds: 20 # 未回答时每隔多久再响一次,0 = 只响一次
181
+ questionRepeatMaxMinutes: 10 # 最多重复多久
180
182
  soundVolume: 1 # 0~3,macOS/Linux 生效
181
183
  successSound: '' # 自定义完成音文件(绝对路径)
182
184
  errorSound: '' # 自定义失败音文件
@@ -224,6 +224,35 @@
224
224
  - 自动化:纯前端改动,109 项测试保持全绿;`node --check` 通过。
225
225
  - 未验证:窄窗口、反复缩放、滚动后的观感需要刷新页面后目视确认(本会话无浏览器控制权)。
226
226
 
227
+ ## 0.3.2 失败提示音误判修复(2026-12-03)
228
+
229
+ - **问题**:成功完成的回合偶尔响失败音。根因是判定过宽:`SOUND_ERROR_KINDS` 把
230
+ `error / aborted / interrupted / blocked` 全算失败,而且是「本工作段内任意一次失败就定调」,且不看会话类型。
231
+ - **依据**(读的是当前安装的 DSH 源码 `dsh-client-ui-chat/src/client/conversation-nodes/turn-error.ts`):
232
+ 宿主自己的聊天视图只对 `error` 与重启补写的 `interrupted` 显示失败行;`aborted`(用户/父级取消)、
233
+ `blocked`、`max-tokens`、`forked` 明确没有失败行。本插件只对 `error` 响失败音——
234
+ `interrupted` 是恢复时补写的闭包事件(那一刻进程已经退出,本来也听不到),为避免恢复旧会话时误响也排除。
235
+ - **子代理**:父轮次结束会 `drainDescendants` 收尾子代理,子会话落一条 `aborted`;之前它把全局标记设成
236
+ 失败。现在子代理会话(`header.parentSession` 或 `origin: 'subagent'`)完全不参与音效判断,其内部 prompt
237
+ 也不计为「用户发起的任务」。
238
+ - **最后一次回合决定**:同一工作段内多次 `turn/end` 时以最后一个普通会话回合为准,失败后重试成功不再响失败音。
239
+ - 自动化:新增 4 项接线测试(子代理失败不污染、五类非失败结束不响、最后回合决定、子代理 prompt 不算用户任务),
240
+ 109 → **113 项全绿**;`node --check` 通过。
241
+ - 未验证:真实多代理会话里「成功完成却响失败音」的复现场景需要重启宿主后实测。
242
+
243
+ ## 0.3.3 提问提醒改为重复直到回答(2026-12-03)
244
+
245
+ - **现场数据**:宿主为 0.3.2(弹层底部显示 v0.3.2),三个试听音各不相同、链路正常;用户对「提问提示音」的描述是
246
+ 「不确定 / 很轻」。结论:功能已生效,但单声 `Ping`(约 0.2 秒)在离开屏幕时太容易被错过。
247
+ - **改法**:提问/审批的 waterfall 监听器在调用 `next()` 前后包一层——先响一次,然后每
248
+ `questionRepeatSeconds`(默认 20s)再响一次,直到 `next()` 结算(用户回答/拒绝)或达到
249
+ `questionRepeatMaxMinutes`(默认 10 分钟)为止;定时器 `unref`,插件卸载或回答后立即清除。
250
+ - 自动化:新增 2 项(未回答时重复 ≥3 次、回答后停止;配置默认 20s/10min 与钳制),单测 113 → **115 全绿**。
251
+ - 未验证:真实「离开屏幕时能否被提醒到」的听感需重启宿主后实测。
252
+
253
+ - 关于「重启后试听点两次才出声」:定位为宿主重启后路由注册完成前的初始化窗口(首次点击落空),
254
+ 不是试听逻辑需要两次;`test-sound` 始终以 `force: true` 绕过节流。
255
+
227
256
  ## 未验证(明确记录,不代替验证)
228
257
 
229
258
  | ID / 项 | 原因 | 何时可验 |
package/index.js CHANGED
@@ -100,7 +100,12 @@ export function start(ctx, rawConfig, deps = {}) {
100
100
  let workStartedAt = 0
101
101
  let pendingUserSound = false
102
102
  let lastOutcome = 'ok'
103
- const SOUND_ERROR_KINDS = new Set(['error', 'aborted', 'interrupted', 'blocked'])
103
+ // Only a real failure is a failure for the person listening. DSH's own chat
104
+ // view shows no failure row for `aborted` (user stop, parent cleanup),
105
+ // `blocked` (a guard rejected a step), `max-tokens` or `forked`; those are
106
+ // routine endings, and treating them as errors made successful work ring the
107
+ // failure cue.
108
+ const SOUND_ERROR_KINDS = new Set(['error'])
104
109
 
105
110
  function maybeRing(durationMs) {
106
111
  try {
@@ -170,6 +175,29 @@ export function start(ctx, rawConfig, deps = {}) {
170
175
  }
171
176
  }
172
177
 
178
+ /**
179
+ * A single short cue is easy to miss when the user is away from the screen,
180
+ * so the alert repeats while the question or approval is still unanswered and
181
+ * stops the moment it is answered (the waterfall result settles).
182
+ * @returns {() => void} stop the repeats
183
+ */
184
+ function startQuestionReminder() {
185
+ ringQuestion()
186
+ const repeatMs = Number(config.questionRepeatSeconds) * 1_000
187
+ const maxMs = Number(config.questionRepeatMaxMinutes) * 60_000
188
+ if (!(repeatMs > 0) || !(maxMs > 0) || typeof setInterval !== 'function') return () => {}
189
+ const deadline = clockNow() + maxMs
190
+ const timer = setInterval(() => {
191
+ if (clockNow() >= deadline) {
192
+ clearInterval(timer)
193
+ return
194
+ }
195
+ ringQuestion()
196
+ }, repeatMs)
197
+ if (typeof timer.unref === 'function') timer.unref()
198
+ return () => clearInterval(timer)
199
+ }
200
+
173
201
  const sync = () => {
174
202
  const working = activity.hasWork(config)
175
203
  if (working && !wasWorking) {
@@ -213,17 +241,21 @@ export function start(ctx, rawConfig, deps = {}) {
213
241
  sync()
214
242
  }),
215
243
  ctx.on('session/event', (session, event) => {
216
- // Subagent sessions are not resumed automatically: their parent owns
217
- // the failure and retrying a child out of band would fork the work.
218
- if (session?.header?.parentSession === undefined && session?.header?.origin !== 'subagent') {
219
- resumeTracker.observe(session.id, event)
220
- }
244
+ // Subagent sessions are not resumed automatically (their parent owns
245
+ // the work) and are not part of the sound decision: their turns are
246
+ // routinely closed by the parent, which used to look like a failure.
247
+ const ordinary = session?.header?.parentSession === undefined && session?.header?.origin !== 'subagent'
248
+ if (ordinary) resumeTracker.observe(session.id, event)
221
249
  if (event?.type === 'user/message') {
222
- pendingUserSound = true
250
+ // A subagent's internal prompt is not a task the user started, so it
251
+ // must not make a background completion audible.
252
+ if (ordinary) pendingUserSound = true
223
253
  return
224
254
  }
225
255
  if (event?.type === 'turn/end') {
226
- if (SOUND_ERROR_KINDS.has(event.data?.reason?.kind)) lastOutcome = 'error'
256
+ // The *last* ordinary turn decides the cue: a failure the user then
257
+ // retried into a success must not keep the failure sound.
258
+ if (ordinary) lastOutcome = SOUND_ERROR_KINDS.has(event.data?.reason?.kind) ? 'error' : 'ok'
227
259
  return
228
260
  }
229
261
  if (config.includeMaintenance !== true) return
@@ -250,9 +282,13 @@ export function start(ctx, rawConfig, deps = {}) {
250
282
  ctx.effect(() => {
251
283
  const listen = (name) => {
252
284
  try {
253
- return ctx.on(name, (_payload, next) => {
254
- ringQuestion()
255
- return typeof next === 'function' ? next() : undefined
285
+ return ctx.on(name, async (_payload, next) => {
286
+ const stop = startQuestionReminder()
287
+ try {
288
+ return typeof next === 'function' ? await next() : undefined
289
+ } finally {
290
+ stop()
291
+ }
256
292
  })
257
293
  } catch (error) {
258
294
  log.warn(`stay-awake: could not subscribe to ${name}: ${describe(error)}`)
package/lib/config.js CHANGED
@@ -26,6 +26,10 @@ export const DEFAULTS = Object.freeze({
26
26
  errorSound: '',
27
27
  questionSound: '',
28
28
  soundOnQuestion: true,
29
+ // "Your turn" is easy to miss with a single short cue, so the alert repeats
30
+ // while the question or approval is still waiting for the human.
31
+ questionRepeatSeconds: 20,
32
+ questionRepeatMaxMinutes: 10,
29
33
  soundVolume: 1,
30
34
  // "Retry the turn that died with the network": on by default, but it only
31
35
  // fires for a lost connection, never for a user abort or an approval wait.
@@ -108,6 +112,8 @@ export function normalizeConfig(raw) {
108
112
  errorSound: asOptionalPath(input.errorSound),
109
113
  questionSound: asOptionalPath(input.questionSound),
110
114
  soundOnQuestion: asBoolean(input.soundOnQuestion, DEFAULTS.soundOnQuestion),
115
+ questionRepeatSeconds: asNumber(input.questionRepeatSeconds, DEFAULTS.questionRepeatSeconds, { min: 0, max: 60 * 30 }),
116
+ questionRepeatMaxMinutes: asNumber(input.questionRepeatMaxMinutes, DEFAULTS.questionRepeatMaxMinutes, { min: 0, max: 24 * 60 }),
111
117
  soundVolume: asNumber(input.soundVolume, DEFAULTS.soundVolume, { min: 0, max: 3 }),
112
118
  autoResume: asBoolean(input.autoResume, DEFAULTS.autoResume),
113
119
  autoResumeCodes: asCodes(input.autoResumeCodes, DEFAULTS.autoResumeCodes),
package/market/index.json CHANGED
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "versions": [
53
53
  {
54
- "version": "0.3.1",
55
- "publishTimestamp": 1796301854,
54
+ "version": "0.3.3",
55
+ "publishTimestamp": 1796365892,
56
56
  "source": {
57
57
  "type": "npm"
58
58
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laraveladmin/dsh-stay-awake",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "DeepSeek Harness plugin that keeps the machine awake only while unattended work runs, and retries the turn that died with the network once it is back.",
5
5
  "keywords": [
6
6
  "dsh-plugin",