前言¶
用 DeepSeek Harness(DSH)跑長任務時,終端裏往往已有「任務完成」一類提示:Kitty 走 OSC 99,Ghostty / WezTerm 走 OSC 777,iTerm2 走 OSC 9,其它環境則多爲 BEL。這些信號針對的是回合結束,而不是「智能體停在你面前等你」的那兩個節點——工具審批和用戶提問。你離開終端去忙別的事時,恰恰最需要被叫回來。dsh-attention-notify 是社區維護的 DSH 客戶端插件,把上述兩種阻塞場景接到 Linux 桌面的 notify-send,並可選擇點擊通知後把終端窗口拉回前臺。
這是什麼¶
插件全名 dsh-attention-notify,由 PandaAQI 維護,在 DSH 插件目錄中歸類爲客戶端。版本 0.1.0,許可證 MIT,要求 Node.js >= 20,DSH 引擎 >= 0.1.1-rc.1。它監聽權限層與用戶提問流上的事件,在需要審批或回答時彈出桌面通知;不重複終端已有的任務完成通知(由 TUI 的 taskNotifications 負責)。
工作原理簡述¶
審批走 session/event 上的純事件 approval/asked;用戶提問走 Cordis 瀑布 user-questions/request,監聽器在通知之外仍必須調用 next(),避免擋掉終端自帶的提問 UI。通知通過可配置的 command(默認 notify-send)異步拉起,失敗只記日誌,不拖垮當前回合。
┌──────────────────────┐ approval/asked ┌───────────────────┐
│ permission layer │────────────────────▶│ this plugin │
│ user-questions seam │ user-questions/... │ ↓ notify-send │
└──────────────────────┘ └────────┬──────────┘
▼
desktop notification
會觸發哪些通知¶
| Session 事件 | 標題(默認) | 正文 |
|---|---|---|
approval/asked |
需要你審批 | toolName: reason,單行截斷 |
user-questions/request |
需要你回答 | 第一道題的 header/text,其餘以 (+N) 表示 |
環境與依賴¶
| 項目 | 說明 |
|---|---|
| 主機 | 帶 D-Bus 會話的 Linux(Wayland 或 X11) |
notify-send |
來自 libnotify(Debian/Ubuntu 上常爲 libnotify-bin) |
paplay |
可選,來自 pulseaudio-utils;僅當 sound: true 時使用 |
默認實現面向 Linux。macOS 可將 command 改爲 terminal-notifier、soundCommand 改爲 afplay;Windows 無 notify-send,上游明確以 Linux 爲設計目標。
安裝與啓用¶
在目標 profile 下執行官方安裝命令。bundle 補丁只增加一行 loader,不改動宿主配置。
dsh plugin --profile <profile> add dsh-attention-notify
安裝前建議瀏覽 GitHub 倉庫 源碼與 MIT 許可證。插件與當前 dsh 進程同權限運行,只應裝你信任的包。
配置項¶
下列鍵可在插件配置中調整(缺省見第二列):
| 鍵 | 默認 | 含義 |
|---|---|---|
enabled |
true |
總開關 |
approval |
true |
是否在 approval/asked 時通知 |
question |
true |
是否在 user-questions/request 時通知 |
approvalTitle |
需要你審批 |
審批通知標題 |
questionTitle |
需要你回答 |
提問通知標題 |
command |
notify-send |
接受 -a -u <title> <body> 的可執行文件 |
appName |
dsh |
傳給 notify-send -a |
urgency |
normal |
low / normal / critical |
sound |
true |
通知後是否播放 soundFile |
soundCommand |
paplay |
播放器 |
soundFile |
/usr/share/sounds/freedesktop/stereo/message.oga |
留空則不發聲 |
cooldownMs |
1500 |
同一標題在此時長內去重 |
maxBodyChars |
160 |
正文上限,超出以 … 截斷 |
clickAction |
true |
是否註冊可點擊動作 |
actionLabel |
打開窗口 |
動作按鈕文案 |
focus |
true |
點擊後是否嘗試聚焦阻塞中的終端 |
windowsCommand |
niri msg windows |
列窗命令(合成器相關) |
focusCommand |
niri msg action focus-window --id {windowId} |
聚焦命令模板 |
focusAppId |
kitty |
未知 pid 時的後備匹配 |
focusPid |
"" |
窗口屬主 pid,默認 $KITTY_PID |
focusTimeoutMs |
2000 |
單次命令超時 |
不想處理點擊聚焦時,可將 focus 設爲 false。
點擊通知回到終端¶
通知帶 default 動作。點擊正文時守護進程會回調,notify-send -A default=… 的輸出即插件所等待的信號。Wayland 下應用無法直接抬高他人窗口,因此默認通過 niri 查詢並聚焦:
niri msg windows
niri msg action focus-window --id <id>
其它合成器可通過 windowsCommand / focusCommand 模板接入,佔位符支持 {windowId}、{pid}、{appId}。聚焦的是窗口而非 Kitty 單個標籤頁;跨標籤需 Kitty 遠程控制(默認未開)。
本地驗證¶
單元測試不依賴桌面環境:
npm test
在真實機器上可用手工片段模擬審批事件(README 中的 node -e 示例),確認彈窗與文案是否符合配置。
適用場景與限制¶
適合在 Linux 上長時間掛 DSH、又不想盯着終端等審批或問答的開發者。需要注意:
- 僅 Linux 爲開箱路徑;
command可改,但默認假定 D-Bus 與notify-send。 - 無法感知終端是否在前臺;與部分終端內置「聚焦時不響」不同,本插件仍會通知,主要靠
cooldownMs降噪。 - 通知在提問出現時觸發,沒有「仍在等待」的週期性提醒。
- 點擊聚焦與合成器綁定;上游僅提供並測試 niri 路徑。
- 未點擊的通知可能讓
notify-send進程掛到彈窗關閉爲止。
任務完成類提示請繼續用 TUI 自帶能力,本插件刻意不重複。
結尾¶
dsh-attention-notify 補上 DSH 在「等你審批、等你回答」時的桌面側提醒,並可選點擊回到 Kitty 等終端窗口。目錄頁:SkillHub - dsh-attention-notify;源碼與文檔:GitHub - PandaAQI/dsh-attention-notify。DSH 生態強調「一切皆插件」,SkillHub 爲社區目錄,與 DeepSeek / 幻方無官方從屬關係;裝插件前自行覈對源碼與許可證即可。