DeepSeek Harness Notification
August 13, 2026 · View on GitHub
让 DSH(DeepSeek Harness)每次完成回答时,自动播放 macOS 系统提示音并弹出系统通知。
效果:回答完成 → 叮一声 + 右上角横幅「老大,OK啦 / 快来看看」+ 自定义图标。

功能特性
- 🔔 自动监听 DSH 的
agent/turn-stopping事件(回合关闭 = 回答完成) - 🔊 播放 macOS 系统提示音(默认
Glass.aiff,可配置) - 🖼 通知显示自定义 App 图标(左侧)与自定义文字
- 🎯 只对顶层会话触发,后台子代理 / workflow 完成时不会乱响
- ⚙️ 文字、图标、音效全部可在配置里改,无需改代码
- 💾 永久生效:作为 DSH host 组合的静态插件,重启不丢失
目录结构
deepseek-harness-notification/
├── plugin/
│ ├── index.mjs # Cordis 插件本体(必须 ESM,原因见下)
│ └── cordis.patch.yml # DSH 组合挂载示例
├── notifier/
│ └── main.swift # macOS 通知工具源码(UNUserNotificationCenter 新 API)
└── README.md
工作原理
DSH 完成回答
→ 插件收到 agent/turn-stopping 事件
→ 过滤:仅顶层会话 agent(agents.roots())
→ 执行命令:
afplay <提示音> ;
Notifier.app -title "<标题>" -message "<正文>"
→ 右上角弹出横幅通知(左侧 = Notifier.app 的 App 图标)
安装步骤
1. 编译并安装通知工具(Notifier.app)
# 编译(需要 Xcode 命令行工具)
cd notifier
swiftc -framework UserNotifications -framework AppKit -o notifier main.swift
# 打包成 app(必须有 bundle id 才能用通知 API)
mkdir -p /Applications/Notifier.app/Contents/MacOS
cp notifier /Applications/Notifier.app/Contents/MacOS/
# 创建 Info.plist(bundle id 建议用 com.<you>.notifier,需与 main.swift 一致)
# 参考下面的 Info.plist 模板
# 注册到 LaunchServices
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/Notifier.app
# 首次授权:用 open 启动,弹系统权限框后点「允许」
open /Applications/Notifier.app
Info.plist 模板:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key><string>com.example.notifier</string>
<key>CFBundleName</key><string>Notifier</string>
<key>CFBundleDisplayName</key><string>Notifier</string>
<key>CFBundleExecutable</key><string>notifier</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.0</string>
<key>CFBundleVersion</key><string>1</string>
<key>LSMinimumSystemVersion</key><string>12.0</string>
</dict>
</plist>
2. 配置自定义图标(可选)
macOS 通知左侧显示的是 Notifier.app 的 App 图标。准备一张 512×512 的 PNG,转成 icns:
mkdir -p icon.iconset
sips -z 16 16 icon.png --out icon.iconset/icon_16x16.png
sips -z 32 32 icon.png --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 icon.png --out icon.iconset/icon_32x32.png
sips -z 64 64 icon.png --out icon.iconset/icon_32x32@2x.png
sips -z 128 128 icon.png --out icon.iconset/icon_128x128.png
sips -z 256 256 icon.png --out icon.iconset/icon_128x128@2x.png
sips -z 256 256 icon.png --out icon.iconset/icon_256x256.png
sips -z 512 512 icon.png --out icon.iconset/icon_256x256@2x.png
sips -z 512 512 icon.png --out icon.iconset/icon_512x512.png
sips -z 1024 1024 icon.png --out icon.iconset/icon_512x512@2x.png
iconutil -c icns icon.iconset -o icon.icns
mkdir -p /Applications/Notifier.app/Contents/Resources
cp icon.icns /Applications/Notifier.app/Contents/Resources/
plutil -replace CFBundleIconFile -string "icon.icns" /Applications/Notifier.app/Contents/Info.plist
codesign --force --deep --sign - /Applications/Notifier.app
⚠️ 改图标后如果通知左侧仍显示空白,是 macOS 通知中心的图标缓存——换一个 bundle id 重新授权即可刷新。
3. 安装 DSH 插件
把 plugin/index.mjs 复制到你的 DSH profile 插件目录(例如 ~/.dsh/profiles/web/plugins/knock-knock/),然后在 profile 的 cordis.patch.yml 里挂载:
- insert:
- id: knock-knock-notify
name: './plugins/knock-knock/index.mjs?v=1' # 改代码后把 v= 数字 +1
config:
title: '老大,OK啦'
message: '快来看看'
icon: '/Users/<你>/Library/.../icon.png' # 预留(当前版本已不用右侧大图)
# sound: '/System/Library/Sounds/Glass.aiff' # 可选
4. 重启 DSH
重启 dsh web 进程(或下次启动时自动生效),发一条消息验证:回答完成时应该听到提示音并看到横幅通知。
自定义
所有文案和音效都在 cordis.patch.yml 的 config 里:
| 配置项 | 说明 | 默认值 |
|---|---|---|
title | 通知标题 | 老大,OK啦 |
message | 通知正文 | 快来看看 |
sound | 提示音路径 | /System/Library/Sounds/Glass.aiff |
已知注意事项
- 仅支持 macOS:依赖
afplay和系统通知 API - 必须用 ESM(.mjs):CJS 模块缓存不含 URL 查询参数,热重载改
?v=N不会重新加载代码(改完代码建议重启 DSH) - 沙箱:插件在 host 层执行命令受默认
workspace-write沙箱限制,代码里已显式使用danger-full-access策略,无需额外配置 - macOS 26+ 通知 API:
osascript display notification和terminal-notifier用的 NSUserNotification 旧 API 在 macOS 26 上不再渲染横幅,所以本项目用 UNUserNotificationCenter 新 API 自编译通知工具 - 通知图标缓存:首次投递时若 app 无图标,通知中心会缓存空白;换 bundle id 可刷新
License
MIT