dsh-plugin-turn-notify
Manifest validDSH 回合结束通知插件 — 系统原生通知 + 提示音,成功/出错/受阻/截断文案各异
dsh-plugin-turn-notify
每当一个 DSH 回合结束,弹出系统原生通知并播放提示音(类似 OpenCode / Claude Code 的完成提醒)。
纯 Host 端 ESM 插件,零运行时依赖;通知通过 Node 子进程调用平台命令实现。
事件从哪里来
DSH 没有独立的 turn/end cordis 事件。turn/end 是 agent loop 写入会话日志的会话事件
(session.append('turn/end', { turn, reason }),见 @deepseek-ai/dsh-agent-loop),
每个持久化会话事件都会以 session/event(session, event) 的形式广播到全局总线,
event 的信封与日志一致:{ type, seq, time, data }。
因此监听方式是:
ctx.on('session/event', onSessionEvent, { global: true })
// onSessionEvent 内只处理 event.type === 'turn/end'
global: true 保证监听器挂在 profile 级作用域,不会被发出事件的 session/agent 作用域回收,
任何会话的回合结束都能收到。
目录结构
dsh-plugin-turn-notify/
├── package.json # dsh.bundle.patch + locale/icon 导出
├── cordis.patch.yml # bundle 层:insert 插件行与默认 config
├── index.js # apply(ctx, config):事件监听、过滤、分发
├── lib/
│ ├── format.js # 载荷逐字段校验、摘要/耗时/文案拼装
│ ├── notify.js # Windows toast / macOS osascript / Linux notify-send
│ └── log.js # 永不抛出的 console 日志
├── scripts/
│ ├── test-turn-end.js # 手动触发一次通知(真实后端)
│ └── selftest.js # 离线自检(含假 ctx 的接线测试)
├── locale/{en,zh}.json # Plugin Manager / Settings 显示元数据
└── icon.svg
配置
bundle 层的 cordis.patch.yml 只负责 insert 插件行。要改默认值,请在
$DSH_PROFILE_DIR/cordis.patch.yml 里用相同 id 覆盖该行(匹配覆盖会替换整个 config,
所以要把需要保留的键一并写出):
- id: turn-notify
name: dsh-plugin-turn-notify
config:
enabled: true # 总开关
sound: true # 附带系统提示音
reasons: # 触发提醒的 turn/end reason.kind
- completed # 成功
- error # 出错
- blocked # 受阻
- max-tokens # 输出被截断
subagents: false # false = 忽略子代理会话,只提醒主会话
locale: auto # auto | zh | en
debounceMs: 800 # 同一会话 800ms 内不重复提醒
minDurationMs: 0 # 短于该时长的回合一概不提醒
includeSummary: true # 附最后一段 assistant 文本
summaryLength: 80 # 摘要字符数上限
可选 reason:completed error blocked max-tokens aborted interrupted forked。
未列出的原因一律不提醒。未识别的字段被忽略,非法值回落到默认值并打印一条 warn。
通知内容
标题:回合完成 · default-workspace # <原因标题> · <workspace 目录名,缺失时取 session 短 id>
正文:已完成 · 12.4s · 最后一段 assistant 文本前 80 字符
- 成功用
done提示音(Asterisk / Glass / complete),失败类原因用alert(Hand / Basso / dialog-error)。 - 耗时来自同回合最新的
turn/start事件的time;取不到时不显示。 subagents: true时子代理回合只记录,不单独弹窗;随后主回合通知尾注(subagent <label>)。
安装
dsh plugin 只是把 pnpm 转发到 profile 目录,并且会登记 bundle;只用 pnpm add 不会登记。
# 1) 本地目录(开发调试;以链接方式装入,改代码后重启即生效)
dsh plugin --profile desktop add "<PROJECT_ROOT>\dsh-plugin-turn-notify"
# 2) 发布到 npm 之后
dsh plugin --profile desktop add dsh-plugin-turn-notify
# 3) GitHub 仓库(打进主分支提交)
dsh plugin --profile desktop add "github:<user>/dsh-plugin-turn-notify"
# 卸载
dsh plugin --profile desktop remove dsh-plugin-turn-notify
Desktop 应用内也可以用 plugin_manager 的 install_bundle,target 传上面的 spec 或绝对目录;
它和 dsh plugin 走同一套 pnpm 实现,并负责 bundle 选择。
安装成功后检查三处:
$DSH_PROFILE_DIR/package.json的dependencies出现该包,dsh.profile.bundles出现dsh-plugin-turn-notify;cordis_inspect_query按name: dsh-plugin-turn-notify能查到已激活的行(id 为turn-notify);- 插件行 config 的 JSON Schema 与本文「配置」一致。
必须开新会话:插件在会话创建时装载。已在运行的会话不会加载新插件,日志里也不会有
[turn-notify]。
发布到插件市场
DSH 桌面端装的「插件市场」是 dshmarket,它读的是
awesome-dsh-plugin.com/plugins.json 这份社区精选目录
(当前约 5900 条),不是 DSH 官方 @deepseek-ai/dsh-plugin-market 的 format-1 index。
所以“能在市场里搜到并一键安装”只有一条路:向
awesome-dsh-plugin/awesome-dsh-plugin 提 PR。
收录条件(逐条自查)
| 条件 | 本插件状态 |
|---|---|
package.json 声明 dsh.bundle.patch | ✅ ./cordis.patch.yml |
仓库根有 cordis.patch.yml,含 - insert: - id/name | ✅ |
| 真实可用的代码,非占位/纯 README | ✅ 2000+ 行含自检 |
| 仓库创建满 1 天(CI 自动检查) | ⏳ 新建仓库需等一天 |
仓库加 dsh-plugin topic | 需在 GitHub 设置里添加 |
| 描述准确、无营销词 | 见下方 YAML |
提交内容
在 PR 中新增一个文件 data/plugins/laobinghongcha__dsh-plugin-turn-notify.yml:
url: https://github.com/laobinghongcha/dsh-plugin-turn-notify
name: laobinghongcha/dsh-plugin-turn-notify
category: notify
description:
en: 'Desktop notification plus system sound when a DSH turn finishes, with distinct wording for completed, failed, blocked, and truncated turns.'
zh: 'DSH 回合结束时弹出系统通知并播放提示音;成功、出错、受阻、截断的文案各不相同。'
含 : 的英文描述必须加引号,否则 YAML 会解析失败。category 取 notify(该目录支持的取值之一)。
在收录前先自己装上
市场收录不是安装的前提,三种方式都能立刻用:
# GitHub 直装(推荐,无需 npm)
dsh plugin --profile desktop add "github:laobinghongcha/dsh-plugin-turn-notify"
# 本地目录
dsh plugin --profile desktop add "<PROJECT_ROOT>\dsh-plugin-turn-notify"
# profile 的 cordis.patch.yml —— 改默认配置
- id: turn-notify
name: dsh-plugin-turn-notify
config:
enabled: true
sound: true
subagents: false
reasons: [completed, error, blocked, max-tokens]
发布到 npm(可选)
收录后市场会用 npm 或 GitHub 安装。想走 npm:
npm login
npm pack --dry-run # 核对 files:index.js lib/ locale/ icon.svg cordis.patch.yml
npm publish
files 已排除 market/、scripts/,不会把发布脚本打进安装包。
验证
-
离线自检:
node scripts/selftest.js→ 13 sections passed。 -
真实通知链路(不依赖事件):
node scripts/test-turn-end.js # completed node scripts/test-turn-end.js error "自定义摘要" zh # 失败文案 + 中文成功输出
sent through windows-toast(或osascript/notify-send)。 -
触发一次真实 turn/end:在装好插件的 profile 里开新会话(包被重新加载才会生效), 发一句
你好让 agent 跑完一个回合。回合结束时日志应出现[turn-notify] notifying (completed): 回合完成 · <workspace> — ...,桌面弹出通知。 出错文案可以用node scripts/test-turn-end.js max-tokens预览。
失败处理与边界
- 通知失败只写 console(
[turn-notify] notification failed via ...),不会 reject、不阻塞 agent loop; 监听器整体包在try/catch里,抛错也不会回到发事件的循环。 - 跨边界内容全部逐字段校验:
reason.kind必须在白名单内,turn必须是非负整数,cwd/sessionId/ 摘要都做长度截断,缺字段降级而不抛错。 - 用户/模型文本只通过子进程环境变量传给 PowerShell,从不拼进脚本;Windows 辅助脚本写在
%LOCALAPPDATA%\dsh-turn-notify(被沙箱拒绝时回落到os.tmpdir()\dsh-turn-notify)。 - 沙箱限制:DSH 的 Windows 文件沙箱不允许
node以管道方式捕获子进程输出 (spawn ... EPERM),因此本会话内运行测试脚本时 PowerShell 无法启动,日志会显示notification failed via windows: ... spawn EPERM。这是测试环境的限制,不是插件缺陷: 已完成的部分是自检、脚本生成,以及把生成好的launch.ps1在沙箱外手动执行(返回toast/balloon,退出码 0)。 由 DSH Host 进程直接拉起插件时不受该沙箱限制。
已知限制
- 无包身份(package identity)的进程不能使用 WinRT toast:脚本会写
HKCU\Software\Classes\AppUserModelId\DeepSeek Harness注册项,但在某些宿主上CreateToastNotifier仍返回0x80073D54,此时自动降级为托盘气泡(windows-balloon),再降级为消息框。 - Linux 依赖
notify-send(libnotify)与canberra-gtk-play/paplay;缺失时提醒不可见但只记日志。 - macOS 首次通知需要用户在“系统设置 → 通知”里允许对应宿主应用。
Comments
Loading…
Similar plugins
by 610la
DSH 通知中心插件:对话/任务完成、报错、等待批准等事件触发浏览器通知 + 21 种匹配音效
★ 15
↓ 177/wk
MIT
JavaScript
Sep 2, 2026
dsh plugin --profile web add @lyhalal/dsh-notification-centerby zhaoxuejie
DSH 桌面通知插件:任务完成 / 等待输入 / 失败时,右下角弹窗 + 音效 + 手机推送(Windows / macOS / Linux)
★ 0
MIT
JavaScript
Sep 7, 2026
dsh plugin --profile web add dsh-plugin-desktop-noticeby better-er
dsh·通知叮咚插件。agent 提问或跑完一轮时,弹浏览器系统通知并让宿主进程播放 Windows 内置提示音,人跑去别的窗口时也能被叫回来;纯插件自包含,不改 DSH 源码。
★ 2
↓ 102/wk
MIT
TypeScript
Oct 8, 2026
dsh plugin --profile web add dsh-notify-dingby messageer
DSH会话停止/阻塞时提醒:右上角 toast + 提示音(WebAudio)+ 系统通知(Windows/macOS 通知中心,页面失焦时弹)。
★ 0
MIT
JavaScript
Sep 2, 2026
dsh plugin --profile web add dsh-task-notifyDSH 的 Gotify 通知插件
★ 0
NOASSERTION
JavaScript
dsh plugin --profile web add dsh-gotify-notifyby Vuitier
DSH web plugin: chime on turn complete & intervention needed。DSH任务完成提示音插件
★ 0
MIT
JavaScript
Sep 1, 2026
dsh plugin --profile web add dsh-sound-notify