dsh-completion-reminder 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/cordis.patch.yml +7 -0
- package/dist/dsh-completion-reminder.js +590 -0
- package/install.md +97 -0
- package/lib/client.d.ts +34 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +779 -0
- package/lib/client.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/types.d.ts +208 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +72 -0
- package/lib/types.js.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# DSH Completion Reminder
|
|
2
|
+
|
|
3
|
+
为 DeepSeek Harness (DSH) Web GUI 增加 **Agent 完成提醒** 功能的插件。
|
|
4
|
+
当 agent 停止生成(成功 / 主动停止 / 出错)时,弹一个通知给用户。
|
|
5
|
+
|
|
6
|
+
默认走 **浏览器原生通知**(`window.Notification`,首次使用需要用户授权),
|
|
7
|
+
并内置 **七种热门的第三方通知渠道** 供切换:
|
|
8
|
+
|
|
9
|
+
| 渠道 | 适用人群 | 配置字段 |
|
|
10
|
+
|------|----------|----------|
|
|
11
|
+
| 🌐 **browser**(默认) | 任何浏览器 | — |
|
|
12
|
+
| ✈️ **Telegram** | Telegram 重度用户 | `telegramBotToken` / `telegramChatId` |
|
|
13
|
+
| 🍎 **Bark** | iPhone 用户 | `barkKey`(可选 `barkServer`) |
|
|
14
|
+
| 📲 **Pushover** | 跨平台推送服务 | `pushoverToken` / `pushoverUserKey` |
|
|
15
|
+
| 🐦 **Server酱** | 国内微信推送 | `serverchanSendKey` |
|
|
16
|
+
| 🎮 **Discord** | Discord 玩家 / 团队 | `discordWebhookUrl` |
|
|
17
|
+
| 💼 **Slack** | 团队工作区 | `slackWebhookUrl` |
|
|
18
|
+
| 🔗 **Webhook** | 自建服务 | `webhookUrl` |
|
|
19
|
+
| 🛠 **Custom** | 完全自定义 | `customSend(payload)` |
|
|
20
|
+
|
|
21
|
+
## 功能
|
|
22
|
+
|
|
23
|
+
- 🛰 **完成即通知**:检测 DSH 输入工具栏的 send ↔ stop 按钮切换,并结合最后一条消息判断成功 / 主动停止 / 出错
|
|
24
|
+
- 🔔 **浏览器原生通知**:`Notification` API,首次自动请求权限;未授权时回退为页面内 toast
|
|
25
|
+
- 🌍 **七种第三方渠道**:Telegram、Bark、Pushover、Server酱、Discord、Slack、通用 Webhook,外加 Custom 钩子
|
|
26
|
+
- 🪟 **智能抑制**:标签页可见且获得焦点时默认不响(避免打断),可通过 `suppressWhenFocused: false` 关闭
|
|
27
|
+
- ⏱ **防刷屏**:连续完成之间默认 5 秒冷却,可调
|
|
28
|
+
- 🎨 **标题/正文可定制**:`titleTemplate` / `bodyTemplate` 接收上下文返回字符串
|
|
29
|
+
- 🪪 **可观测性**:`onNotify` / `onError` 钩子方便调试与对接
|
|
30
|
+
- ⚡ **装了即用**:声明 `dsh.bundle.patch`,`dsh plugin add` 时由 DSH 自动加入 profile 层并激活
|
|
31
|
+
- 📦 **npm 分发**:CI 自动构建、发布、创建 GitHub Release
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
### npm 安装(推荐)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
dsh plugin --profile web add dsh-completion-reminder
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
插件包内自带 `cordis.patch.yml`(insert 注册项)并在 `package.json` 声明 `dsh.bundle.patch`。
|
|
42
|
+
`dsh plugin add` 完成依赖安装后,DSH 会自动把插件加入 profile 的 bundles 层堆栈,重启后即生效。
|
|
43
|
+
|
|
44
|
+
如果遇到 `ERR_PNPM_ADDING_TO_ROOT`(profile 目录是 pnpm workspace root),补一个 `-w`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
dsh plugin --profile web add -w dsh-completion-reminder
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
然后重启:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
dsh web
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
打开任一会话并触发一次 agent 回复,应该会看到「请求通知权限」的浏览器弹窗。
|
|
57
|
+
授权后,等任务结束即可看到通知。
|
|
58
|
+
|
|
59
|
+
## 配置
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
DSHCompletionReminder.configure({
|
|
63
|
+
provider: 'telegram', // 'browser' (default) | 'telegram' | 'bark' | 'pushover'
|
|
64
|
+
// | 'serverchan' | 'discord' | 'slack'
|
|
65
|
+
// | 'webhook' | 'custom'
|
|
66
|
+
autoRequestPermission: true, // 浏览器模式下自动请求 Notification 权限
|
|
67
|
+
notifyOnSuccess: true, // 成功完成时通知
|
|
68
|
+
notifyOnStopped: true, // 用户主动停止时通知
|
|
69
|
+
notifyOnError: true, // agent 出错时通知
|
|
70
|
+
suppressWhenFocused: true, // 标签页可见且有焦点时不响
|
|
71
|
+
cooldownMs: 5000, // 连续通知之间的最小间隔
|
|
72
|
+
titleTemplate: ({ status }) => 'DSH 已结束', // 自定义标题
|
|
73
|
+
bodyTemplate: ({ model, durationMs }) => `${model} · 用时 ${durationMs}ms`,
|
|
74
|
+
iconUrl: '/favicon.ico',
|
|
75
|
+
clickUrl: location.href,
|
|
76
|
+
|
|
77
|
+
providers: {
|
|
78
|
+
telegramBotToken: '123456:ABC...',
|
|
79
|
+
telegramChatId: '987654321',
|
|
80
|
+
|
|
81
|
+
// barkKey / pushover* / serverchanSendKey / discordWebhookUrl /
|
|
82
|
+
// slackWebhookUrl / webhookUrl 只需按当前 provider 填写。
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
onNotify: (payload, provider) => console.log('delivered via', provider, payload),
|
|
86
|
+
onError: (err, provider) => console.warn('failed via', provider, err),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
DSHCompletionReminder.activate();
|
|
90
|
+
DSHCompletionReminder.deactivate();
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 只走「页面内 toast」?
|
|
94
|
+
|
|
95
|
+
把 `provider` 设为 `'browser'` 即可。如果用户拒绝浏览器通知权限,插件会自动
|
|
96
|
+
回退为页面内的浮动提示,不需要任何额外配置。
|
|
97
|
+
|
|
98
|
+
### 切换到 Telegram?
|
|
99
|
+
|
|
100
|
+
1. 在 Telegram 中 `@BotFather` 创建 bot,拿到 `telegramBotToken`
|
|
101
|
+
2. 给自己发一条消息,访问 `https://api.telegram.org/bot<TOKEN>/getUpdates` 拿到 `chat.id`
|
|
102
|
+
3. 配置:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
DSHCompletionReminder.configure({
|
|
106
|
+
provider: 'telegram',
|
|
107
|
+
providers: {
|
|
108
|
+
telegramBotToken: '<TOKEN>',
|
|
109
|
+
telegramChatId: '<CHAT_ID>',
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 公开 API
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
DSHCompletionReminder.DEFAULTS // 默认配置
|
|
118
|
+
DSHCompletionReminder.configure(opts) // 合并配置(多次调用累加)
|
|
119
|
+
DSHCompletionReminder.activate() // 启动 DOM 观察与通知
|
|
120
|
+
DSHCompletionReminder.deactivate() // 停止一切
|
|
121
|
+
DSHCompletionReminder.requestBrowserPermission() // 手动触发 Notification 权限请求
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`apply(ctx, opts)` 是 DSH Cordis Loader 调用的入口,等价于 `configure(opts); activate()`。
|
|
125
|
+
|
|
126
|
+
## 工作原理
|
|
127
|
+
|
|
128
|
+
- `src/index.ts` 是宿主侧(node)入口,导出空 `apply`,让 Loader 能挂载本包
|
|
129
|
+
- `src/client.ts` 是浏览器侧真正的逻辑,被打包成 `window.__ModuleLoader__.load({ factory })` 格式
|
|
130
|
+
- 一个 `MutationObserver` 监听 `document.body`:
|
|
131
|
+
- 关注工具栏按钮的 `aria-label` / `class` / `textContent` 变化
|
|
132
|
+
- 检测到「running」(如 `停止` / `Stop`)→ 记录开始时间
|
|
133
|
+
- 检测到「idle」→ 触发 `completeRun(status, durationMs)`
|
|
134
|
+
- 读最后一条 `data-role="assistant"` 消息粗略判断 success / stopped / error
|
|
135
|
+
- 根据 `provider` 派发到不同的通知渠道,全部走 `fetch` / `Notification`
|
|
136
|
+
|
|
137
|
+
## 项目结构
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
dsh-completion-reminder/
|
|
141
|
+
├── package.json # npm 包配置,含 dsh.bundle.patch 与 dsh.client 声明
|
|
142
|
+
├── cordis.patch.yml # 包自带的 loader 注册 patch(insert 本插件)
|
|
143
|
+
├── tsconfig.json # TypeScript 配置
|
|
144
|
+
├── src/
|
|
145
|
+
│ ├── index.ts # 服务端入口(桩)
|
|
146
|
+
│ ├── client.ts # 客户端插件 TypeScript 源码
|
|
147
|
+
│ └── types.ts # 类型定义 & 默认值
|
|
148
|
+
├── lib/
|
|
149
|
+
│ ├── index.js # 编译后的服务端入口(纯载体)
|
|
150
|
+
│ └── client.js # DSH __ModuleLoader__ 格式的客户端插件
|
|
151
|
+
├── dist/
|
|
152
|
+
│ └── dsh-completion-reminder.js # 独立脚本(可直接 <script> 加载)
|
|
153
|
+
├── scripts/
|
|
154
|
+
│ ├── build-plugin.js # 构建脚本(tsc 产物 → ModuleLoader 包装)
|
|
155
|
+
│ └── clean.js # 清理 lib/ 和 dist/
|
|
156
|
+
├── .github/workflows/
|
|
157
|
+
│ └── publish.yml # tag 推送 → 构建 → npm 发布 → GitHub Release
|
|
158
|
+
└── test.html # 测试页面(模拟 send ↔ stop 切换)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 发布流程
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npm version patch # 或 minor / major
|
|
165
|
+
git push origin main --tags
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
推送 `v*` tag 后 CI 自动完成构建、npm 发布和 GitHub Release。
|
|
169
|
+
`NPM_TOKEN` 与 `GITHUB_TOKEN` 在仓库 Settings → Secrets 中配置。
|
|
170
|
+
|
|
171
|
+
## 许可
|
|
172
|
+
|
|
173
|
+
MIT
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# dsh-completion-reminder bundle patch: one insert row for the node half.
|
|
2
|
+
# The node half is a pure carrier (empty apply) that lets the Loader mount the
|
|
3
|
+
# package; the browser half ships via exports["./client"] and is discovered
|
|
4
|
+
# through the package.json dsh.client declaration.
|
|
5
|
+
- insert:
|
|
6
|
+
- id: dsh-completion-reminder
|
|
7
|
+
name: 'dsh-completion-reminder'
|