@laraveladmin/dsh-stay-awake 0.3.0 → 0.3.2
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 +26 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +90 -8
- package/docs/VERIFICATION.md +29 -0
- package/index.js +17 -8
- package/market/index.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# 变更记录 · Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- **失败提示音误判**:之前把 `error` / `aborted` / `interrupted` / `blocked` 都当成失败。实际上 DSH 自己的
|
|
8
|
+
聊天视图只对 `error`(以及重启补写的 `interrupted`)显示失败行,`aborted`(用户停止、父轮次收尾)、
|
|
9
|
+
`blocked`(守卫拒绝一步)、`max-tokens`、`forked` 都不算失败。所以成功完成也偶尔响 `Basso`。
|
|
10
|
+
- 现在只把 `error` 当作失败;一次工作段里有多个回合时以**最后一个普通会话回合**为准(重试成功不会再响失败音)。
|
|
11
|
+
- **子代理会话不再参与音效判断**:父轮次结束时会收尾子代理,那是一条 `aborted`,之前被当成失败;子代理内部的
|
|
12
|
+
prompt 也不再算作「用户发起的任务」(`soundOnlyUserTasks`)。
|
|
13
|
+
- 新增 4 项回归测试:子代理失败不污染父轮次成功、非失败结束不响、最后回合决定、子代理 prompt 不算用户任务。
|
|
14
|
+
单测 109 → 113。
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## 0.3.1 — 2026-12-03
|
|
18
|
+
|
|
19
|
+
### 修复
|
|
20
|
+
|
|
21
|
+
- 窗口缩小后弹层位置偶尔不对:CSS anchor positioning 只把弹层「绑」在触发点上,并不保证它落在视口内——
|
|
22
|
+
`left` 锚定触发点会让宽面板溢出右边缘,`@position-try` 回退又只改纵向。现在改为**测量后定位**:
|
|
23
|
+
打开时、窗口 resize、composer 滚动、弹层自身尺寸变化(状态行、语言切换、提示)都会重新计算,
|
|
24
|
+
取「优先在触发点上方、放不下就放下方」,左右按视口 12px 边距夹紧;触发点被窄屏布局隐藏或滚出视口时
|
|
25
|
+
回退到输入框上方居中;高度超过视口时改为内部滚动。
|
|
26
|
+
- 定位完成前弹层 `visibility:hidden`,避免先画在错误位置再跳一下。
|
|
27
|
+
|
|
28
|
+
|
|
3
29
|
## 0.3.0 — 2026-12-03
|
|
4
30
|
|
|
5
31
|
### 新功能:断网自动重试
|
package/README.en.md
CHANGED
|
@@ -36,7 +36,7 @@ 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
|
|
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
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
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.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ DSH 跑长任务时你离开电脑,系统按空闲策略休眠:进程被挂
|
|
|
36
36
|
三种时机各响一声,不用盯着屏幕——声音在**运行 DSH 的这台机器**上播放,窗口最小化也听得到。
|
|
37
37
|
|
|
38
38
|
- **完成**:一次「工作段」(从有工作到全部结束)结束时响一次,含后台任务与多会话。默认 `Glass`。
|
|
39
|
-
-
|
|
39
|
+
- **失败**:只有这一轮**真的报错**(`error`)才响,默认 `Basso`。你主动按停止、审批被拒、子代理被父轮次收尾、`max-tokens`/`forked` 这类结束都不算失败;一个工作段里有多个回合时,以**最后一个普通会话回合**的结果为准,重试成功不会还响失败音。
|
|
40
40
|
- **需要你回答**:agent 用 `ask_user_question` 提问、或工具调用等审批时立刻响,默认 `Ping`——这是唯一一个「回合还没结束也响」的情况,否则它会一直安静地等你。
|
|
41
41
|
- 短于 20 秒的任务不响;goal/定时任务等自主轮次不响,避免连响(但提问/审批仍然会提醒你)。
|
|
42
42
|
- 弹层「提示音」总开关控制全部三种;旁边三个小按钮「完成 / 失败 / 提醒」可分别试听。
|
package/client.js
CHANGED
|
@@ -202,19 +202,15 @@ window.__ModuleLoader__.load({
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
const CSS = `
|
|
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
|
|
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}
|
|
206
206
|
.dsa-pill[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}
|
|
207
207
|
@media (hover:hover){.dsa-pill:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}
|
|
208
208
|
.dsa-pill:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
209
209
|
.dsa-pill svg{flex:none;width:14px;height:14px}
|
|
210
210
|
.dsa-label{text-overflow:ellipsis;min-width:0;overflow:hidden}
|
|
211
211
|
.dsa-dot{width:5px;height:5px;border-radius:50%;flex:none}
|
|
212
|
-
.dsa-panel{position:fixed;
|
|
213
|
-
|
|
214
|
-
.dsa-panel{position-anchor:--dsh-stay-awake-panel;top:auto;bottom:max(12px, calc(anchor(top) + 8px));left:max(12px, anchor(left));right:auto;transform:none;height:fit-content;max-height:calc(100dvh - 24px);position-try-fallbacks:--dsa-below, --dsa-wide}
|
|
215
|
-
}
|
|
216
|
-
@position-try --dsa-below{top:max(12px, calc(anchor(bottom) + 8px));bottom:auto}
|
|
217
|
-
@position-try --dsa-wide{left:12px;right:12px;justify-self:stretch}
|
|
212
|
+
.dsa-panel{position:fixed;z-index:1100;box-sizing:border-box;height:fit-content;min-height:0;border:0;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);width:max-content;min-width:min(300px,100vw - 24px);max-width:min(440px,100vw - 24px);max-height:calc(100dvh - 24px);overflow:hidden auto;margin:0;padding:16px;font-size:12px;line-height:18px;cursor:default;pointer-events:auto;text-align:left;visibility:hidden}
|
|
213
|
+
.dsa-panel[data-positioned="true"]{visibility:visible}
|
|
218
214
|
.dsa-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;color:var(--dsw-alias-label-primary);font-weight:500}
|
|
219
215
|
.dsa-head-label{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
220
216
|
.dsa-head-label svg{flex:none;width:14px;height:14px}
|
|
@@ -378,6 +374,59 @@ window.__ModuleLoader__.load({
|
|
|
378
374
|
return { text: `\u2713 ${t('panel.saved')}` }
|
|
379
375
|
}
|
|
380
376
|
|
|
377
|
+
const useLayoutEffect = typeof React.useLayoutEffect === 'function' ? React.useLayoutEffect : React.useEffect
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Place the popover above its trigger, clamped to the viewport.
|
|
381
|
+
*
|
|
382
|
+
* CSS anchor positioning kept the panel attached but did not keep it inside
|
|
383
|
+
* a smaller window: anchoring `left` to the trigger let a wide panel run
|
|
384
|
+
* off the right edge, and the `@position-try` fallbacks only moved it
|
|
385
|
+
* vertically. Measuring here means a resized window, a scrolled composer
|
|
386
|
+
* and a re-wrapped toolbar all end with the panel fully on screen.
|
|
387
|
+
* @param {HTMLElement} panel
|
|
388
|
+
*/
|
|
389
|
+
function placePanel(panel) {
|
|
390
|
+
const doc = globalThis.document
|
|
391
|
+
const win = globalThis.window
|
|
392
|
+
if (!panel || !doc || !win) return
|
|
393
|
+
const viewportW = win.innerWidth || doc.documentElement?.clientWidth || 0
|
|
394
|
+
const viewportH = win.innerHeight || doc.documentElement?.clientHeight || 0
|
|
395
|
+
if (viewportW === 0 || viewportH === 0) return
|
|
396
|
+
const margin = 12
|
|
397
|
+
const gap = 8
|
|
398
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max)
|
|
399
|
+
// The height cap belongs to the viewport, not to the content: a taller
|
|
400
|
+
// panel scrolls instead of poking out of a short window.
|
|
401
|
+
panel.style.maxHeight = `${Math.max(160, viewportH - margin * 2)}px`
|
|
402
|
+
const width = panel.offsetWidth
|
|
403
|
+
const height = panel.offsetHeight
|
|
404
|
+
const trigger = doc.querySelector('[data-dsa-anchor="stay-awake"]')
|
|
405
|
+
const rect = trigger && typeof trigger.getBoundingClientRect === 'function' ? trigger.getBoundingClientRect() : null
|
|
406
|
+
const anchored = rect !== null && (rect.width > 0 || rect.height > 0)
|
|
407
|
+
&& rect.bottom > 0 && rect.top < viewportH
|
|
408
|
+
let left
|
|
409
|
+
let top
|
|
410
|
+
if (anchored) {
|
|
411
|
+
left = clamp(rect.left, margin, Math.max(margin, viewportW - width - margin))
|
|
412
|
+
const above = rect.top - gap - height
|
|
413
|
+
if (above >= margin) {
|
|
414
|
+
top = above
|
|
415
|
+
} else {
|
|
416
|
+
const below = rect.bottom + gap
|
|
417
|
+
top = below + height <= viewportH - margin ? below : Math.max(margin, viewportH - height - margin)
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
// Trigger hidden (narrow layout) or scrolled away: stay reachable above
|
|
421
|
+
// the composer instead of anchoring to a zero-sized box.
|
|
422
|
+
left = clamp(Math.round((viewportW - width) / 2), margin, Math.max(margin, viewportW - width - margin))
|
|
423
|
+
top = Math.max(margin, viewportH - height - 120)
|
|
424
|
+
}
|
|
425
|
+
panel.style.left = `${Math.round(left)}px`
|
|
426
|
+
panel.style.top = `${Math.round(Math.max(margin, top))}px`
|
|
427
|
+
panel.dataset.positioned = 'true'
|
|
428
|
+
}
|
|
429
|
+
|
|
381
430
|
function Moon({ color }) {
|
|
382
431
|
return h(
|
|
383
432
|
'svg',
|
|
@@ -455,6 +504,7 @@ window.__ModuleLoader__.load({
|
|
|
455
504
|
{
|
|
456
505
|
type: 'button',
|
|
457
506
|
className: 'dsa-pill dsa-root',
|
|
507
|
+
'data-dsa-anchor': 'stay-awake',
|
|
458
508
|
'aria-expanded': snapshot.open === true,
|
|
459
509
|
'aria-haspopup': 'dialog',
|
|
460
510
|
onClick: () => store.toggle(),
|
|
@@ -476,6 +526,38 @@ window.__ModuleLoader__.load({
|
|
|
476
526
|
function Panel({ store, t, act }) {
|
|
477
527
|
const snapshot = useStore(store)
|
|
478
528
|
const open = snapshot.open === true
|
|
529
|
+
const panelRef = React.useRef(null)
|
|
530
|
+
|
|
531
|
+
// Reposition on open, on viewport changes, on composer scroll and when
|
|
532
|
+
// the panel's own size changes (status rows, locale switch, notice).
|
|
533
|
+
useLayoutEffect(() => {
|
|
534
|
+
if (!open) return undefined
|
|
535
|
+
const panel = panelRef.current
|
|
536
|
+
if (panel === null) return undefined
|
|
537
|
+
let frame = 0
|
|
538
|
+
const schedule = () => {
|
|
539
|
+
if (frame !== 0) return
|
|
540
|
+
if (typeof globalThis.requestAnimationFrame === 'function') {
|
|
541
|
+
frame = globalThis.requestAnimationFrame(() => {
|
|
542
|
+
frame = 0
|
|
543
|
+
placePanel(panel)
|
|
544
|
+
})
|
|
545
|
+
} else {
|
|
546
|
+
placePanel(panel)
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
placePanel(panel)
|
|
550
|
+
const observer = typeof globalThis.ResizeObserver === 'function' ? new globalThis.ResizeObserver(schedule) : null
|
|
551
|
+
observer?.observe(panel)
|
|
552
|
+
globalThis.window?.addEventListener('resize', schedule)
|
|
553
|
+
globalThis.window?.addEventListener('scroll', schedule, true)
|
|
554
|
+
return () => {
|
|
555
|
+
observer?.disconnect()
|
|
556
|
+
globalThis.window?.removeEventListener('resize', schedule)
|
|
557
|
+
globalThis.window?.removeEventListener('scroll', schedule, true)
|
|
558
|
+
if (frame !== 0 && typeof globalThis.cancelAnimationFrame === 'function') globalThis.cancelAnimationFrame(frame)
|
|
559
|
+
}
|
|
560
|
+
}, [open])
|
|
479
561
|
useTick(open)
|
|
480
562
|
const status = snapshot.status
|
|
481
563
|
const failures = snapshot.failures
|
|
@@ -549,7 +631,7 @@ window.__ModuleLoader__.load({
|
|
|
549
631
|
|
|
550
632
|
return h(
|
|
551
633
|
'div',
|
|
552
|
-
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand') },
|
|
634
|
+
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand'), ref: panelRef },
|
|
553
635
|
stylesheet === null ? h('style', { key: 'css' }, CSS) : null,
|
|
554
636
|
h(
|
|
555
637
|
'div',
|
package/docs/VERIFICATION.md
CHANGED
|
@@ -211,6 +211,35 @@
|
|
|
211
211
|
| 提问/审批提醒音实际听感 | 需要宿主重启加载新代码并真实触发一次 `ask_user_question` 或审批;本进程内无法重启宿主 | 用户重启后提问一次即可确认 |
|
|
212
212
|
| 繁体中文在 DSH 语言列表中出现并可选中 | `addLanguage` 注册成功后由 DSH 的「语言」设置行渲染,本会话无浏览器控制权 | 重启后在 设置 → 语言 中查看「繁體中文」 |
|
|
213
213
|
|
|
214
|
+
## 0.3.1 弹层定位改为测量后夹紧(2026-12-03)
|
|
215
|
+
|
|
216
|
+
- **问题**:窗口缩小后弹层位置偶尔不对。根因是 CSS anchor positioning 的语义:`bottom: anchor(top)`
|
|
217
|
+
保证纵向跟随,`left: max(12px, anchor(left))` 只保证贴住触发点左缘——面板 `width: max-content`
|
|
218
|
+
(最大 440px)在窄窗口下会直接溢出右边缘;`@position-try` 的两个回退只改纵向/或依赖
|
|
219
|
+
`justify-self: stretch`(对 `position: fixed` 不生效),所以「有时候」不生效。
|
|
220
|
+
- **改法**:`placePanel()` 用 `getBoundingClientRect()` 测量触发点与弹层,按 `12px` 视口边距夹紧
|
|
221
|
+
`left/top`:优先放触发点上方(间距 8px),放不下放下方,仍放不下则贴边并让弹层内部滚动;
|
|
222
|
+
触发点不可见(窄屏布局隐藏 / 已滚出视口)时回退到输入框上方居中。`useLayoutEffect` 在首帧绘制前
|
|
223
|
+
完成定位(定位前 `visibility: hidden`),并监听 `resize`、捕获阶段 `scroll` 与 `ResizeObserver`。
|
|
224
|
+
- 自动化:纯前端改动,109 项测试保持全绿;`node --check` 通过。
|
|
225
|
+
- 未验证:窄窗口、反复缩放、滚动后的观感需要刷新页面后目视确认(本会话无浏览器控制权)。
|
|
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
|
+
|
|
214
243
|
## 未验证(明确记录,不代替验证)
|
|
215
244
|
|
|
216
245
|
| 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
|
-
|
|
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 {
|
|
@@ -213,17 +218,21 @@ export function start(ctx, rawConfig, deps = {}) {
|
|
|
213
218
|
sync()
|
|
214
219
|
}),
|
|
215
220
|
ctx.on('session/event', (session, event) => {
|
|
216
|
-
// Subagent sessions are not resumed automatically
|
|
217
|
-
// the
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
+
// Subagent sessions are not resumed automatically (their parent owns
|
|
222
|
+
// the work) and are not part of the sound decision: their turns are
|
|
223
|
+
// routinely closed by the parent, which used to look like a failure.
|
|
224
|
+
const ordinary = session?.header?.parentSession === undefined && session?.header?.origin !== 'subagent'
|
|
225
|
+
if (ordinary) resumeTracker.observe(session.id, event)
|
|
221
226
|
if (event?.type === 'user/message') {
|
|
222
|
-
|
|
227
|
+
// A subagent's internal prompt is not a task the user started, so it
|
|
228
|
+
// must not make a background completion audible.
|
|
229
|
+
if (ordinary) pendingUserSound = true
|
|
223
230
|
return
|
|
224
231
|
}
|
|
225
232
|
if (event?.type === 'turn/end') {
|
|
226
|
-
|
|
233
|
+
// The *last* ordinary turn decides the cue: a failure the user then
|
|
234
|
+
// retried into a success must not keep the failure sound.
|
|
235
|
+
if (ordinary) lastOutcome = SOUND_ERROR_KINDS.has(event.data?.reason?.kind) ? 'error' : 'ok'
|
|
227
236
|
return
|
|
228
237
|
}
|
|
229
238
|
if (config.includeMaintenance !== true) return
|
package/market/index.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laraveladmin/dsh-stay-awake",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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",
|