dsh-notify-say 0.4.67 → 0.4.68
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 +4 -0
- package/lib/config-schema.js +4 -0
- package/lib/index.js +53 -8
- package/package.json +1 -1
- package/test/error-notify-contract.test.mjs +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
> 本文件由 `tools/release-build.ps1` 从开发提交自动生成,**请勿手工编辑**。
|
|
4
4
|
> 只列面向使用者的变更(新增功能与修复),不含内部维护提交。
|
|
5
5
|
|
|
6
|
+
## v0.4.68 — 2026-10-19
|
|
7
|
+
|
|
8
|
+
- fix(notify): v0.4.68 —— error 在 turn/end 当场播报,不等 idle 边沿
|
|
9
|
+
|
|
6
10
|
## v0.4.67 — 2026-10-19
|
|
7
11
|
|
|
8
12
|
- fix(notify): v0.4.67 —— 错误不再被静默吞掉(第 2 批,含播放层反馈)
|
package/lib/config-schema.js
CHANGED
|
@@ -106,6 +106,8 @@ export const FIELD_DEFAULTS = Object.freeze({
|
|
|
106
106
|
volume: 80,
|
|
107
107
|
notifyOnComplete: true,
|
|
108
108
|
notifyOnError: true,
|
|
109
|
+
/** v0.4.68:子代理会话出错是否提醒。默认开 —— 完成可以合并,错误不能合并掉。 */
|
|
110
|
+
notifyOnSubagentError: true,
|
|
109
111
|
notifyOnBlocked: true,
|
|
110
112
|
notifyOnAborted: false,
|
|
111
113
|
notifyOnApproval: true,
|
|
@@ -196,6 +198,8 @@ export function buildConfig(z) {
|
|
|
196
198
|
.description('回合正常完成时提醒'),
|
|
197
199
|
notifyOnError: z.boolean().default(FIELD_DEFAULTS.notifyOnError)
|
|
198
200
|
.description('回合出错时提醒(播失败语音)'),
|
|
201
|
+
notifyOnSubagentError: z.boolean().default(FIELD_DEFAULTS.notifyOnSubagentError)
|
|
202
|
+
.description('子代理会话出错时也提醒(默认开:完成可以合并,错误不能静默)'),
|
|
199
203
|
notifyOnBlocked: z.boolean().default(FIELD_DEFAULTS.notifyOnBlocked)
|
|
200
204
|
.description('回合被拦截时提醒(蜂鸣,不播失败语音)'),
|
|
201
205
|
notifyOnAborted: z.boolean().default(FIELD_DEFAULTS.notifyOnAborted)
|
package/lib/index.js
CHANGED
|
@@ -315,6 +315,8 @@ function normalizeConfig(raw) {
|
|
|
315
315
|
if (!raw || typeof raw !== 'object') return out;
|
|
316
316
|
for (const k of ['notifyOnComplete', 'notifyOnError', 'notifyOnBlocked', 'notifyOnAborted',
|
|
317
317
|
'notifyOnApproval', 'notifyOnQuestion', 'voice', 'subagents', 'idleGate',
|
|
318
|
+
// v0.4.68:子代理出错单独开关(完成可以合并,错误不能合并掉)
|
|
319
|
+
'notifyOnSubagentError',
|
|
318
320
|
// v0.4.2
|
|
319
321
|
'showToast', 'jumpWhenBackground', 'jumpWhenForeground', 'multiJumpRule',
|
|
320
322
|
// v0.4.3:开发开关
|
|
@@ -686,6 +688,7 @@ export function effectiveForClient(c) {
|
|
|
686
688
|
volume: g.volume,
|
|
687
689
|
notifyOnComplete: g.notifyOnComplete,
|
|
688
690
|
notifyOnError: g.notifyOnError,
|
|
691
|
+
notifyOnSubagentError: g.notifyOnSubagentError,
|
|
689
692
|
notifyOnBlocked: g.notifyOnBlocked,
|
|
690
693
|
notifyOnAborted: g.notifyOnAborted,
|
|
691
694
|
notifyOnApproval: g.notifyOnApproval,
|
|
@@ -990,7 +993,7 @@ export function apply(ctx, config) {
|
|
|
990
993
|
+ `after ${SPAWN_TIMEOUT_MS}ms`);
|
|
991
994
|
fallbackBeep(which);
|
|
992
995
|
} else if (code === 0) {
|
|
993
|
-
appendNotifyLog(`[play-ok] ${which} kind=${psKind || '?'}
|
|
996
|
+
appendNotifyLog(`[play-ok] ${which} kind=${psKind || '?'}`);
|
|
994
997
|
} else {
|
|
995
998
|
const tail = stderrTail ? ' stderr=' + stderrTail.replace(/\s+/g, ' ').slice(-300) : '';
|
|
996
999
|
appendNotifyLog(`[play-fail] ${which} kind=${psKind || '?'} `
|
|
@@ -1854,7 +1857,7 @@ function hasVoiceLine(psKind) {
|
|
|
1854
1857
|
}
|
|
1855
1858
|
|
|
1856
1859
|
/** completed / error / blocked / 其它 四分支 → 文案 + 门控 → 交给空闲门。 */
|
|
1857
|
-
function handleDone(session, agent, kind) {
|
|
1860
|
+
function handleDone(session, agent, kind, evKey) {
|
|
1858
1861
|
let gate;
|
|
1859
1862
|
let psKind;
|
|
1860
1863
|
let title;
|
|
@@ -1905,7 +1908,7 @@ function hasVoiceLine(psKind) {
|
|
|
1905
1908
|
scheduleOrNotify(session, agent, psKind, title, body);
|
|
1906
1909
|
return;
|
|
1907
1910
|
}
|
|
1908
|
-
emitDone(session, psKind, title, body);
|
|
1911
|
+
emitDone(session, psKind, title, body, evKey);
|
|
1909
1912
|
}
|
|
1910
1913
|
|
|
1911
1914
|
/** 审批提醒正文。 */
|
|
@@ -2043,15 +2046,57 @@ function hasVoiceLine(psKind) {
|
|
|
2043
2046
|
try {
|
|
2044
2047
|
const type = event && event.type;
|
|
2045
2048
|
if (type === 'turn/end') {
|
|
2046
|
-
//
|
|
2047
|
-
//
|
|
2048
|
-
//
|
|
2049
|
-
//
|
|
2049
|
+
// ⚠️ v0.4.68(第 3 批):**error / blocked 当场播报,不等 idle 边沿**。
|
|
2050
|
+
//
|
|
2051
|
+
// 原先是「turn/end 只记账 → 等 agent/status 转 idle 再读记账播报」。
|
|
2052
|
+
// 这条链多了一个脆弱依赖:那个 idle 边沿若没来(或晚来、或被别的状态
|
|
2053
|
+
// 穿插),错误就永远不播。用户 2026-10-19 的实测正是如此 —— 出错时没
|
|
2054
|
+
// 有语音,是他自己看到界面红色提示、手动发了「继续工作」才开始下一轮。
|
|
2055
|
+
//
|
|
2056
|
+
// 数据支撑(2195 个真实会话 / 6262 条 turn/end):
|
|
2057
|
+
// 同一 turn 出现多条 turn/end: 0 ← 提前播不会重复
|
|
2058
|
+
// 同一 turn 出现多种 kind: 0 ← 不会与 completed 冲突
|
|
2059
|
+
//
|
|
2060
|
+
// 分工:
|
|
2061
|
+
// error / blocked → 当场播(错误要立刻叫人,等 idle 没意义)
|
|
2062
|
+
// completed / 其它 → 仍记账等 idle(合并多轮 + 走空闲门)
|
|
2050
2063
|
const endTurn = event && event.data && typeof event.data.turn === 'number'
|
|
2051
2064
|
? event.data.turn
|
|
2052
2065
|
: undefined;
|
|
2066
|
+
const endKind = reasonKindOf(event.data);
|
|
2067
|
+
|
|
2068
|
+
if (endKind === 'error' || endKind === 'blocked') {
|
|
2069
|
+
// 随手拿 agent(用于 shouldNotifySession 的子代理判定);拿不到也行。
|
|
2070
|
+
let a;
|
|
2071
|
+
try {
|
|
2072
|
+
const as = svc('agents');
|
|
2073
|
+
if (as && typeof as.get === 'function') a = as.get(sessionKey(session));
|
|
2074
|
+
} catch { a = undefined; }
|
|
2075
|
+
|
|
2076
|
+
if (!shouldNotifySession(session) && endKind === 'error') {
|
|
2077
|
+
// 子代理的 error:受独立开关控制(v0.4.68 新增 notifyOnSubagentError)。
|
|
2078
|
+
if (!cfg.notifyOnSubagentError) {
|
|
2079
|
+
skipLog('subagent-error-off', endKind, session, 'notifyOnSubagentError=false');
|
|
2080
|
+
return;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
const evKey = endTurn !== undefined ? `turn:${sessionKey(session)}:${endTurn}` : undefined;
|
|
2085
|
+
// 直接走 handleDone:它内部对非 completed 的 kind 是立即 emitDone,
|
|
2086
|
+
// 不进空闲门。evKey 与 idle 路径同键,万一两条都走到会被互斥层拦住。
|
|
2087
|
+
try {
|
|
2088
|
+
handleDone(session, a, endKind, evKey);
|
|
2089
|
+
} catch (e) {
|
|
2090
|
+
console.warn('[dsh-notify-say] turn/end immediate notify failed: ' + String((e && e.message) || e));
|
|
2091
|
+
}
|
|
2092
|
+
// 不写 lastTurnEnd —— 避免 idle 路径再播一次。
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2096
|
+
// completed 及以后的其他 kind:仍记账,等 idle 边沿统一处理。
|
|
2097
|
+
// (v0.4.66:带 turn 号,消费时校验,防止复用上一轮的 reason。)
|
|
2053
2098
|
rememberBounded(lastTurnEnd, sessionKey(session),
|
|
2054
|
-
{ kind:
|
|
2099
|
+
{ kind: endKind, turn: endTurn, at: Date.now() },
|
|
2055
2100
|
Date.now(), (v) => v && v.at);
|
|
2056
2101
|
} else if (type === 'approval/asked') handleApprovalAsked(session, event.data);
|
|
2057
2102
|
else if (type === 'approval/decided') handleApprovalDecided(event.data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-notify-say",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.68",
|
|
4
4
|
"description": "Desktop notifications for DSH Desktop that actually speak: Windows TTS out of the box (zero download), VOICEVOX voice packs optional, a selectable system-sound fallback, and an idle gate that waits for running subagents before saying the turn is done. Includes a settings-page GUI (sound source, per-event overrides, jump-back-to-session, cooldowns) and a self hot-reload for development.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -151,4 +151,36 @@ test('P13: 并发丢弃必须能定位是哪条通知', () => {
|
|
|
151
151
|
test('P14: spawnTts 要透传 psKind(TTS 失败也要能定位)', () => {
|
|
152
152
|
const body = fnBody('function spawnTts(args, psKind) {');
|
|
153
153
|
assert.match(body, /spawnNotify\(args, psKind\)/, 'spawnTts 必须透传 psKind');
|
|
154
|
+
});
|
|
155
|
+
// ══ 第 3 批:error 当场播报(2026-10-19 真机排查的根因)══════════════════
|
|
156
|
+
test('P15: error / blocked 必须在 turn/end 当场播,不等 idle 边沿', () => {
|
|
157
|
+
const idx = INDEX.indexOf("if (type === 'turn/end') {");
|
|
158
|
+
assert.ok(idx > 0, '要有 turn/end 处理');
|
|
159
|
+
const seg = INDEX.slice(idx, idx + 2200);
|
|
160
|
+
// 必须有 error/blocked 的立即播报分支
|
|
161
|
+
assert.match(seg, /endKind === 'error' \|\| endKind === 'blocked'/,
|
|
162
|
+
'必须有 error/blocked 的当场播报分支');
|
|
163
|
+
// 该分支必须 return(不能落下去写 lastTurnEnd,否则 idle 路径会再播一次)
|
|
164
|
+
const branch = seg.slice(seg.indexOf("endKind === 'error'"));
|
|
165
|
+
assert.match(branch, /return;/, '当场播后必须 return,避免走到 lastTurnEnd 记账');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test('P16: 数据依据 —— 不得因"怕重复"而把 error 也走记账路径', () => {
|
|
169
|
+
// 2026-10-19 实测 2195 个会话 / 6262 条 turn/end:
|
|
170
|
+
// 同一 turn 多条 turn/end = 0,同一 turn 多种 kind = 0
|
|
171
|
+
// 所以不存在"提前播会重复"的问题。
|
|
172
|
+
const idx = INDEX.indexOf("if (type === 'turn/end') {");
|
|
173
|
+
const seg = INDEX.slice(idx, idx + 2200);
|
|
174
|
+
assert.match(seg, /error .* 当场播报|当场播报,不等 idle|error \/ blocked → 当场播/,
|
|
175
|
+
'代码里应保留这条判断的依据说明,防止后人又改回"等 idle"');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('P17: 子代理错误要有独立开关(默认开)', () => {
|
|
179
|
+
assert.match(INDEX, /notifyOnSubagentError/,
|
|
180
|
+
'子代理错误要能单独控制:不打扰于子代理完成,但不能静默子代理错误');
|
|
181
|
+
// 默认值定义在 config-schema.js(FIELD_DEFAULTS),不在 index.js
|
|
182
|
+
const SCHEMA = readFileSync(join(ROOT, 'lib/config-schema.js'), 'utf8');
|
|
183
|
+
const m = SCHEMA.match(/notifyOnSubagentError:\s*(true|false)/);
|
|
184
|
+
assert.ok(m, 'config-schema.js 里要有默认值');
|
|
185
|
+
assert.equal(m[1], 'true', '默认必须开 —— 错误不该被静默');
|
|
154
186
|
});
|