dsh-notify-on-complete:给 DeepSeek Harness 添加桌面通知

前言

用 DeepSeek Harness(dsh)跑长任务时,终端不一定一直开着,Web UI 也可能被切走。如果任务结束、模型需要提问、或等待审批,开发者需要一种低打扰的方式来知道“该回来了”。

pitetow/dsh-notify-on-complete 就是为此写的 DSH 插件:在运行结束、模型调用 ask_user_question、或等待沙箱提权 / 工具权限审批时发送桌面通知。插件定位为 extension,MIT 许可证,package.json 中版本号为 0.3.0

核心功能

运行结束通知

插件在顶层运行结束后发送通知,并按结果区分正文类型:

  • completed
  • error
  • aborted
  • max-tokens

插件只通知顶层运行,过滤 subagent 会话,判断字段为:

header.origin === 'subagent'

这样可以减少一次 CLI 运行中多个子会话重复通知的情况。

会话中即时提醒

除了运行结束,插件还会在会话过程中触发通知:

  • 模型调用 ask_user_question
  • 等待沙箱提权审批
  • 等待工具权限审批

这些场景通常意味着任务在等待用户输入。插件通过以下配置项精细控制:

  • onBlocked
  • onQuestion
  • onApproval

零运行时依赖

插件不依赖 dsh 内部包。通知通过 Node.js 的 child_process.spawn 以 detached 子进程发出,避免受主进程退出路径影响。

跨平台通知命令

插件根据当前平台选择通知命令:

  • macOS:osascript
  • Linux:notify-send,不可用时回退 kdialog
  • Windows:PowerShell

不支持的平台在加载时跳过并警告,不会在每个事件上抛错。

系统提示音

插件支持系统提示音:

  • macOS:Glass
  • Windows:SystemSounds
  • Linux:canberra-gtk-play,不可用时回退 paplay

可以通过以下配置关闭提示音:

sound: false

安装与启用

前置条件

需要:

  • Node.js ^22
  • 已安装的 dsh CLI
  • pnpm

插件依赖:

@deepseek-ai/cordis@^4.0.1

该依赖由 dsh CLI 提供,pnpm 安装时会自动解析。

一键安装

默认安装命令:

curl -fsSL https://raw.githubusercontent.com/pitetow/dsh-notify-on-complete/main/scripts/install.sh | bash

这条命令会执行远程脚本。安装前建议先查看仓库中的:

scripts/install.sh

安装脚本默认不覆盖已存在的源码目录。如果需要覆盖更新,可以使用:

curl -fsSL https://raw.githubusercontent.com/pitetow/dsh-notify-on-complete/main/scripts/install.sh | bash -s -- --force

注意:--force 会删除并重新下载源码,该目录中的本地编辑会丢失。

安装到其他 profile

默认安装到 web profile。如果要安装到 headless profile:

curl -fsSL https://raw.githubusercontent.com/pitetow/dsh-notify-on-complete/main/scripts/install.sh | bash -s -- --profile headless

验证是否生效

可以检查当前 profile 的配置中是否出现插件:

dsh --profile web --dump-config | grep -n notify-on-complete

如果看到 notify-on-complete 相关条目,说明插件已经进入当前 profile 的配置树。

生效方式:

  • CLI 一次性运行:下次运行生效
  • Web GUI:需要重启 dsh web 进程

典型用法

更新插件

方式一:使用安装脚本强制更新。

curl -fsSL https://raw.githubusercontent.com/pitetow/dsh-notify-on-complete/main/scripts/install.sh | bash -s -- --force

方式二:手动更新本地源码。

cd ~/.dsh/plugins/dsh-notify-on-complete
git pull
pnpm install
pnpm run build
dsh plugin --profile web add link:.

完成后重启或重新运行对应的 dsh 进程。

卸载插件

dsh plugin --profile web remove dsh-notify-on-complete
rm -rf ~/.dsh/plugins/dsh-notify-on-complete

卸载后重启 dsh

适用场景与注意

适合这些情况:

  • 跑较长时间的 DSH 任务,不想一直盯着终端
  • 模型经常调用 ask_user_question,需要等用户回答
  • 任务会触发沙箱提权或工具权限审批
  • 使用 macOS、Linux 或 Windows,并希望用系统通知提醒

安装前需要注意:

  1. 插件会以当前 dsh 进程的权限运行,建议先检查源码和许可证。
  2. curl | bash 会执行远程脚本,建议使用前审查 scripts/install.sh
  3. 安装脚本默认不覆盖已有目录;使用 --force 前确认没有需要保留的本地修改。
  4. Web GUI 场景需要重启 dsh web 进程后生效。

项目地址

GitHub:

https://github.com/pitetow/dsh-notify-on-complete
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜