前言¶
在 DeepSeek Harness(DSH)里跑 Agent 任务时,一个 turn 可能持续多步工具调用,进程在后台跑完或失败时,如果不盯着客户端,很容易错过结果。网络抖动、模型请求超时或限流还会让任务直接停在 error,需要手动再发一条「继续」才能续跑。
下面介绍的 dsh-task-notifier(npm:@lizhijie429/dsh-task-notifier,维护者 lizhijie429,分类:工作流)只做两件事:根据持久化会话事件判断任务结束态并调用系统通知;在符合配置的可继续失败下,自动向当前会话发送「继续」。它不猜测运行中状态,只读 turn/start、llm/retry、turn/end 等事件。
这是什么¶
DSH Host 侧 Cordis 插件,零运行时依赖,纯 ESM 单目录结构,可按绝对路径挂载,无需构建。当前 package 版本为 0.2.5,engines.dsh 要求 DSH >=0.2.1-0 <0.3.0,许可证 MIT。
通知通道按平台选择:Windows Toast(PowerShell 5.1 WinRT,注册 DSH.TaskNotifier AUMID,使用 DSH 图标与名称,而非「Windows PowerShell」)、macOS osascript、Linux notify-send,也可设为 log 或 none 降级。另可订阅审批事件,在 DSH 审批面板需要你授权且未在宽限期内被自动处理时发系统提醒。
核心功能¶
任务状态与通知¶
插件把一个任务等同于一个 turn:多步工具仍只在该 turn/end 时发一次完成/失败类通知(除非单独开启逐步或开始通知)。
状态来自 turn/end 的 reason.kind,例如:
completed/max-tokens:完成或触达输出上限(可配置是否通知)error/blocked/interrupted:失败或阻塞(默认可通知错误)aborted:用户取消(默认不通知)
默认开启 notifyOnComplete、notifyOnError;notifyOnStart、notifyOnStep 默认关闭,避免刷屏。默认不通知子代理会话(notifySubagents: false);子代理也不会自动继续。
可选 notifyOnApproval:持久化 approval/asked 后,若 approvalGraceMs(默认 1000ms)内没有 approval/decided,则发「需要授权」类系统通知;授权仍须在 DSH 审批面板完成。
自动继续¶
在 autoContinue.enabled 为 true 时,任务以 error 结束且失败码落在 autoContinue.retryableCodes(网络/模型请求类等)内,插件会在 Agent 进入 idle 时通过 agent.followup() 入队一条用户消息(默认文案「继续」),而不是在 turn/end 监听器里直接 append,以避免 Session 重入限制。
默认 requireRetryExhausted: false:多数网络与模型请求类失败会直接尝试继续;设为 true 时更严格,需结合 llm/retry 链判定重试预算是否耗尽。每个任务最多 maxAttempts 次(默认 3,硬上限 50),两次继续之间受 cooldownMs(默认 5000)约束。若 inbox 已有下一轮驱动条目,会跳过继续并记录,避免与 goal/schedule 等冲突。
自动消息的 source 为 { kind: 'task-notifier', plugin: 'task-notifier' },符合 DSH 持久化 v4 对 producer kind 的要求。
调试与配置校验¶
非法配置项不会抛错:逐项回退默认值,写 Host 日志与 JSONL 调试日志(默认 <插件目录>/state/task-notifier.log,256KB 轮转)。挂载成功时日志中应出现 plugin.mounted。
安装与启用¶
DSH 桌面端 desktop profile 被 Electron 占用,dsh plugin 等 CLI 无法直接改它,推荐编辑用户补丁层并指向插件 index.mjs 的绝对路径。普通 profile(web / headless / 自建)可用 dsh plugin add。
方式一:desktop profile(推荐桌面端)¶
编辑 $env:USERPROFILE\.dsh\profiles\desktop\cordis.patch.yml(Windows 示例,将 <user> 换成你的用户名),追加:
- insert:
- id: task-notifier
name: 'C:\Users\<user>\.dsh\plugins\dsh-task-notifier\index.mjs'
config:
channel: auto
logFile: 'C:\Users\<user>\.dsh\plugins\dsh-task-notifier\state\task-notifier.log'
notifyOnStart: false
notifyOnComplete: true
notifyOnError: true
notifyOnAbort: false
notifyOnStep: false
notifySubagents: false
titlePrefix: DSH
maxBodyChars: 240
autoContinue:
enabled: true
message: 继续
maxAttempts: 3
cooldownMs: 5000
requireRetryExhausted: false
保存后,desktop 的 patchReload 缺省为 live 时通常热加载;未生效则重启 DeepSeek Harness。验证:查看 state/task-notifier.log 是否出现 plugin.mounted。
方式二:bundle 安装到 web / headless 等 profile¶
已发布到 npm 时:
dsh plugin --profile web add "@lizhijie429/dsh-task-notifier"
从 GitHub 安装(无构建步骤):
dsh plugin --profile web add "github:lizhijie429/dsh-task-notifier"
本地目录安装:
cd "$env:USERPROFILE\.dsh\plugins\dsh-task-notifier"
dsh plugin --profile web add "file:$PWD"
package.json 的 dsh.bundle.patch 会加载 cordis.patch.yml 中的默认配置(插件 id 为 task-notifier)。
方式三:临时验证(不改 profile)¶
$pluginDir = "$env:USERPROFILE\.dsh\plugins\dsh-task-notifier"
$patch = @"
- insert:
- id: task-notifier
name: '$pluginDir\index.mjs'
config:
channel: log
logFile: '$pluginDir\state\e2e.log'
autoContinue: { enabled: true, message: 继续, maxAttempts: 2, cooldownMs: 0 }
"@
Set-Content -Path "$env:TEMP\task-notifier.patch.yml" -Value $patch -Encoding UTF8
dsh headless --patch "$env:TEMP\task-notifier.patch.yml" "只回复 OK,不要调用工具。"
典型配置片段¶
仅想收通知、关闭自动继续时,可在同一 id: task-notifier 的 config 中覆盖:
autoContinue:
enabled: false
仅在网络类失败且重试耗尽后才自动继续:
autoContinue:
enabled: true
requireRetryExhausted: true
锁屏安全:includePreview 默认为 false,不在通知正文附带模型输出预览。
完整字段见仓库 README 配置表(如 channel、approvalGraceMs、autoContinue.respectProviderRetryAfter 等)。
适用场景与注意¶
适合长时间 headless / 桌面后台跑 Agent、需要系统级提醒任务完成或失败,并希望在 TRANSPORT、TIMEOUT、RATE_LIMIT 等可恢复错误后少点一次「继续」的场景。需要盯审批时,可配合 notifyOnApproval 减少漏看授权。
使用前请注意:
- 插件以当前 DSH 进程权限运行,会执行平台通知命令(PowerShell、
osascript、notify-send等);安装前请阅读 GitHub 源码 与 MIT 许可证,确认符合你的环境策略。 AUTH、UNKNOWN(且无网络特征)等失败默认不会自动继续;自动继续有次数与冷却上限,不能替代正确的 API 密钥或模型配置。- 社区插件目录 SkillHub 条目 为独立站点展示,与 DeepSeek / 幻方无官方从属关系;DSH 生态主张「一切皆插件」,本插件是社区维护的工作流类扩展。
结尾¶
dsh-task-notifier 用持久化事件驱动通知与续跑,Windows 上 Toast 以 DSH 品牌展示,并覆盖 Linux/macOS 与纯日志通道。按需挂载到 desktop 或通过 dsh plugin add 装入 profile 即可。