@idoall/dsh-notify 0.3.4 → 0.4.1
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/CHANGELOG.md +30 -1
- package/README.md +17 -8
- package/README.zh.md +18 -9
- package/dist/client.js +77 -0
- package/dist/index.js +32 -1
- package/dist/update.js +159 -0
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). GitHub Releases use the same bilingual layout as [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/releases/tag/dsh-v0.1.6-alpha.1).
|
|
4
4
|
|
|
5
|
-
## [
|
|
5
|
+
## [0.4.1] - 2026-09-29
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **Declared DeepSeek Harness `0.2.0-rc.1` compatible.** `dsh.engines.dsh` and every `@deepseek-ai/dsh-*` peer move from `>=0.1.7-rc.1 <0.2.0` to `>=0.1.7-rc.1 <0.3.0`, and `dsh.compatibility.dshReleases` gains `0.2.0-rc.1` while keeping `0.1.7-rc.1` and `0.1.7-rc.2`. DSH refuses an incompatible bundle at profile load by peer range, so the old ceiling would have dropped the plugin as soon as `0.2.0` shipped — `0.2.0-rc.1` only loads today because a prerelease still sorts below `0.2.0`.
|
|
10
|
+
|
|
11
|
+
### Verified
|
|
12
|
+
|
|
13
|
+
- **No source change was needed.** The Host events (`agent/status`, `session/event`, `approval/request`, `user-questions/request`, `goal/activation-changed`, `agent/error`, `workflow/end`), the `webServer`/`connection` route and authorization contract, the `jobs` event stream, the two client `slots` seats, and the `--dsw-alias-*` theme tokens are unchanged in `0.2.0-rc.1`; the packages the plugin binds are byte-identical between `dsh-v0.1.7-rc.2` and `dsh-v0.2.0-rc.1`, and the approval-resolves-inline flow it already handles is the same in both.
|
|
14
|
+
- Full verification passed: static source checks, **110 automated tests**, build, and package precondition checks.
|
|
15
|
+
- **Real-machine verification** in an isolated `DSH_HOME` under `/tmp` (the user's profile is never touched) with the plugin installed as `link:` and DSH `0.2.0-rc.1` booted: the composed profile mounted the `dsh-notify` row without a compatibility refusal, `/plugins/dsh-notify/health` answered `guiAvailable: true` with `eventErrors: 0`, `/config`, `/pull`, `/sounds` and `/update` (real npm registry) all answered 200, and the browser rendered **设置 → 通知** with a working self-test toast stack and no page errors.
|
|
16
|
+
- Counter-proof: under DSH's real semver evaluation the old ranges do **not** satisfy `0.2.0` or `0.2.1`, so the empty-lookup risk on the `0.2.0` release is real rather than assumed.
|
|
17
|
+
|
|
18
|
+
## [0.4.0] - 2026-09-25
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **Online version detection in 设置 → 通知.** The settings page now shows the running version against the newest one published on npm, next to **检查更新**, GitHub, 更新日志 and 反馈 Issue — the same row the reference settings page offers. The host reads the registry through the authenticated, read-only `GET /plugins/dsh-notify/update` (six-hour cache; `?force=1` is what the button uses), compares versions with its own ~30 lines of semver arithmetic instead of adding a dependency, and never installs anything or restarts DSH: when a newer version exists the page reveals a copyable `dsh plugin --profile web add @idoall/dsh-notify@<version>` command and states that the restart is the operator's to do. An unreachable or malformed registry renders as `v<current> · 检查失败` — it never presents the running version as the newest, and a failed lookup is cached so an offline host is not asked on every page load.
|
|
23
|
+
|
|
24
|
+
### Verified
|
|
25
|
+
|
|
26
|
+
- Version ordering is covered for releases, prereleases (`rc.1` < `rc.2` < `rc.10` < release), build metadata, and an unparsable string that must compare as equal rather than claim an update.
|
|
27
|
+
- The route reports the version read from the shipped manifest, reuses the cache on a plain reload, bypasses it on `force=1`, stays behind the auth gate (a refused request never reaches the registry), and answers `registry_unavailable` instead of failing when the registry is down.
|
|
28
|
+
- The settings row is covered in jsdom: the chip wording and tone for newest/available/failed, the three repository links, the upgrade panel appearing only when there is something to install, and a clipboard-less browser reporting 复制失败 rather than claiming 已复制.
|
|
29
|
+
- Full verification passed: static source checks, **108 automated tests**, build, and package precondition checks.
|
|
30
|
+
- **Real-machine verification** in an isolated `DSH_HOME` under `/tmp` (the user's profile is never touched), with the plugin installed as `link:` and DSH `0.1.7-rc.2` booted: `/plugins/dsh-notify/health` answered `guiAvailable: true`, `/plugins/dsh-notify/update` returned `{"current":"0.4.0","latest":"0.3.4","hasUpdate":false,"error":null}` from the real npm registry — an older publish is correctly *not* an update, and `?force=1` produced a second real lookup — and the settings page rendered `v0.4.0 ✓ 最新` with the three repository links and no upgrade panel.
|
|
6
31
|
|
|
7
32
|
## [0.3.4] - 2026-09-24
|
|
8
33
|
|
|
@@ -214,6 +239,10 @@ First public release. Verified against DeepSeek Harness `0.1.5-rc.1`.
|
|
|
214
239
|
|
|
215
240
|
- Browser system notifications (channel B), host OS notifications (channel C) and web push / service worker (channel D), along with the `web-push` and `ipaddr.js` dependencies. Those channels failed invisibly (submitted but never seen) and could not be made reliable across browsers and operating systems.
|
|
216
241
|
|
|
242
|
+
[0.4.1]: https://github.com/idoall/dsh-notify/releases/tag/v0.4.1
|
|
243
|
+
[0.4.0]: https://github.com/idoall/dsh-notify/releases/tag/v0.4.0
|
|
244
|
+
[0.3.4]: https://github.com/idoall/dsh-notify/releases/tag/v0.3.4
|
|
245
|
+
[0.3.3]: https://github.com/idoall/dsh-notify/releases/tag/v0.3.3
|
|
217
246
|
[0.3.2]: https://github.com/idoall/dsh-notify/releases/tag/v0.3.2
|
|
218
247
|
[0.3.1]: https://github.com/idoall/dsh-notify/releases/tag/v0.3.1
|
|
219
248
|
[0.3.0]: https://github.com/idoall/dsh-notify/releases/tag/v0.3.0
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<a href="https://github.com/idoall/dsh-notify/actions/workflows/ci.yml"><img src="https://github.com/idoall/dsh-notify/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/@idoall/dsh-notify"><img src="https://img.shields.io/npm/v/@idoall/dsh-notify?label=npm&color=CB3837" alt="npm version"></a>
|
|
8
8
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-0F172A" alt="MIT"></a>
|
|
9
|
-
<img src="https://img.shields.io/badge/DSH-0.
|
|
9
|
+
<img src="https://img.shields.io/badge/DSH-0.2.0--rc.1-4B6BFB" alt="DSH 0.2.0-rc.1">
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">English | <a href="README.zh.md">中文</a></p>
|
|
@@ -37,6 +37,7 @@ When a session really stops, fails, asks a question, or needs approval, a card a
|
|
|
37
37
|
- **Sound and background attention.** Built-in WebAudio cues and validated custom uploads play only after a card is admitted to an enabled visual Toast queue, including while the page is hidden. One polling batch produces one cue. A background tab with unseen notifications receives a temporary bell prefix and favicon attention marker.
|
|
38
38
|
- **Completion means native idle, once per task.** A green card waits until DSH reports the owning Agent as `idle`, matching the session-tree spinner instead of guessing from a rendered answer or an elapsed timer. A plan review and an execution approval are control gates, so their temporary idle pause does not create an extra completion card; the later work turn supplies the one card. An ordinary question is different: if its answer directly finishes the task, that same turn still produces one green card. If work resumes, the prior candidate is cancelled and only the final native-idle transition is announced.
|
|
39
39
|
- **Task-noise control.** Subtask, background-job, and workflow completion notifications are off by default.
|
|
40
|
+
- **Online version detection.** The settings page shows the running version against the newest one published on npm, with **Check for updates**, GitHub, Changelog and Issues links. The check is read-only: the host asks the registry, reports, and shows a copyable upgrade command — it never installs anything and never restarts DSH. An unreachable registry renders as a failed check instead of presenting the running version as the newest.
|
|
40
41
|
- **No history by design.** Notification records are held only in the open page's in-memory queue. Settled history is never replayed after a refresh or overlay remount; an interaction that is still open when the host can report it is restored silently.
|
|
41
42
|
|
|
42
43
|
## Quick start
|
|
@@ -45,7 +46,7 @@ Requirements:
|
|
|
45
46
|
|
|
46
47
|
- DeepSeek Harness with a Web profile
|
|
47
48
|
- Node.js 20 or newer
|
|
48
|
-
- Verified DeepSeek Harness version: `0.
|
|
49
|
+
- Verified DeepSeek Harness version: `0.2.0-rc.1`
|
|
49
50
|
|
|
50
51
|
Install from npm into your Web profile:
|
|
51
52
|
|
|
@@ -91,13 +92,21 @@ Reload the profile or restart DSH only when its plugin host has not hot-reloaded
|
|
|
91
92
|
|
|
92
93
|
Custom sounds are stored in `<dataDir>/sounds/` in the profile data directory, not the plugin installation. Uploads are limited to 1 MB and `mp3 / m4a / aac / wav / ogg / flac`; names must be a single path segment.
|
|
93
94
|
|
|
95
|
+
Above the cards, the page shows the running version against the newest one on npm: `v0.4.0 ✓ 最新`, `v0.4.0 ➔ v0.5.0`, or `v0.4.0 · 检查失败`. **检查更新** forces a fresh lookup (`GET /plugins/dsh-notify/update?force=1`, authenticated); a page load reuses the host's six-hour cache. When a newer version exists the row reveals `dsh plugin --profile web add @idoall/dsh-notify@<version>` with a copy button — installing it, and restarting DSH afterwards, stays your decision.
|
|
96
|
+
|
|
97
|
+
<p align="center">
|
|
98
|
+
<img src="./assets/version-check.png" width="60%" alt="DSH notification settings with the version row: v0.4.0 newest, Check for updates, GitHub, Changelog and Issues links">
|
|
99
|
+
</p>
|
|
100
|
+
|
|
94
101
|
## Compatibility
|
|
95
102
|
|
|
96
|
-
Current release: plugin **`0.
|
|
103
|
+
Current release: plugin **`0.4.1`** is verified against DeepSeek Harness **`0.2.0-rc.1`**.
|
|
97
104
|
|
|
98
105
|
| Plugin | Verified DeepSeek Harness | What that version is |
|
|
99
106
|
| --- | --- | --- |
|
|
100
|
-
| **`0.
|
|
107
|
+
| **`0.4.1`** | `0.2.0-rc.1` | Compatibility follow-up: declares the DSH `0.2.0` line (`>=0.1.7-rc.1 <0.3.0`), so the plugin is no longer dropped at profile load when `0.2.0` ships. No source change — every interface it binds is unchanged |
|
|
108
|
+
| `0.4.0` | `0.1.7-rc.2` | Online version detection in 设置 → 通知: the running version against npm's newest, a manual **检查更新** (`?force=1`), repository/changelog/issues links, and a copyable upgrade command — read-only, cached, and it never installs or restarts anything |
|
|
109
|
+
| `0.3.4` | `0.1.7-rc.1` | Trigger-timing fixes: a failure is delivered at `agent/error` (one card with `turn/end`), a same-stack `idle → running` flap no longer announces a finished task, and the client pulls at once on a session-state change or a visible-again tab (1.5 s interval kept as fallback) |
|
|
101
110
|
| `0.3.3` | `0.1.7-rc.1` | Adapts to DSH 0.1.7: job completions follow `jobs.events.subscribe`, tool results read the flattened tool-role message, in-toast answers read `uiSession.sessionStatus`, and `@deepseek-ai/schemastery` is a peer |
|
|
102
111
|
| `0.3.2` | `0.1.6-alpha.1` | Completion follows native `agent/status: idle`; one green card per continuous task |
|
|
103
112
|
| `0.3.1` | `0.1.6-alpha.1` | Sound matches visible delivery; open interactions recover after overlay remount |
|
|
@@ -108,8 +117,8 @@ Current release: plugin **`0.3.4`** is verified against DeepSeek Harness **`0.1.
|
|
|
108
117
|
| `0.1.2` | `0.1.6-alpha.1` | — |
|
|
109
118
|
|
|
110
119
|
- **`0.3.3` supports the DSH `0.1.7` line only.** DSH `0.1.7` removed `jobs.onJobDone`, flattened tool-result identity onto the tool-role message, and replaced `uiSession.pendingInteractions` with the unified `sessionStatus` snapshot. On an older DSH — including `0.1.6-alpha.1` — stay on plugin **`0.3.2`**.
|
|
111
|
-
- Two declarations
|
|
112
|
-
- `@deepseek-ai/schemastery` is a **peer**, not a plain dependency: DSH
|
|
120
|
+
- Two declarations decide whether the plugin loads at all: `dsh.engines.dsh` and every `@deepseek-ai/dsh-*` peer state the same requirement, `>=0.1.7-rc.1 <0.3.0` as of `0.4.1`. DSH refuses an incompatible bundle at profile load, so a range that excluded the running release would silently drop the plugin — which is exactly what the old `<0.2.0` ceiling would have done on the `0.2.0` release.
|
|
121
|
+
- `@deepseek-ai/schemastery` is a **peer**, not a plain dependency: DSH resolves only a linked plugin's peer dependencies from the running installation, so a `link:` install of this directory would otherwise fail to import the Host half.
|
|
113
122
|
|
|
114
123
|
The layout is also checked at a 390px mobile viewport: the settings controls reflow and the toast becomes full-width without falling behind the mobile sidebar.
|
|
115
124
|
|
|
@@ -140,8 +149,8 @@ npm run pack:check # publish preconditions + client registration check
|
|
|
140
149
|
Releases are tag-driven. Bump `package.json`, move the matching CHANGELOG section out of `Unreleased`, write `release-notes/v<version>.md`, then push the release commit and tag:
|
|
141
150
|
|
|
142
151
|
```sh
|
|
143
|
-
git tag v0.
|
|
144
|
-
git push origin v0.
|
|
152
|
+
git tag v0.4.1
|
|
153
|
+
git push origin v0.4.1
|
|
145
154
|
```
|
|
146
155
|
|
|
147
156
|
The release workflow runs `npm run verify`, packs the plugin, publishes through npm trusted publishing (OIDC), and creates a GitHub Release with the package tarball and sha256.
|
package/README.zh.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<a href="https://github.com/idoall/dsh-notify/actions/workflows/ci.yml"><img src="https://github.com/idoall/dsh-notify/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
7
7
|
<a href="https://www.npmjs.com/package/@idoall/dsh-notify"><img src="https://img.shields.io/npm/v/@idoall/dsh-notify?label=npm&color=CB3837" alt="npm 版本"></a>
|
|
8
8
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-0F172A" alt="MIT"></a>
|
|
9
|
-
<img src="https://img.shields.io/badge/DSH-0.
|
|
9
|
+
<img src="https://img.shields.io/badge/DSH-0.2.0--rc.1-4B6BFB" alt="DSH 0.2.0-rc.1">
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center"><a href="README.md">English</a> | 中文</p>
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
- **在卡片内回答**:待回复问题或审批会显示可兼容的输入框选项;执行审批与计划待审沿用 DSH 的橙色决策语义,普通需要回复保持蓝色;卡片内回答与输入框操作同一份宿主交互。
|
|
37
37
|
- **提示音与后台提醒**:通知成功进入已启用的可视 Toast 队列后,才会播放内置 WebAudio 或经过校验的自定义提示音;页面在后台时也适用。同一轮轮询的一批通知只播放一次。后台标签有未查看通知时,标题和 favicon 会短暂提示。
|
|
38
38
|
- **完成以原生 idle 为准,并且每项任务只通知一次**:绿色完成卡等待 DSH 报告所属 Agent 为 `idle` 才发送,和左侧会话树转圈停止一致;不再依据已渲染的回答或计时器猜测。计划待审和执行审批是控制门:它们短暂进入 idle 不会额外生成完成卡,批准后的后续工作轮才产生唯一一张。普通需要回复不同:如果你的回答直接结束任务,该轮仍会产生一张绿色完成卡;若之后又继续运行,旧候选会被取消,最终只通知真正结束的 native-idle 状态。
|
|
39
|
-
-
|
|
39
|
+
- **任务噪声控制**:子任务、后台任务与工作流完成通知默认关闭。
|
|
40
|
+
- **在线版本检测**:设置页会显示当前版本与 npm 上最新版本,并提供**检查更新**、GitHub、更新日志、反馈 Issue 入口。检测只读:宿主只查询 registry 并汇报,同时给出可复制的升级命令,绝不自动安装、也绝不重启 DSH。registry 不可达时显示「检查失败」,而不会把当前版本谎称为最新。
|
|
40
41
|
- **无历史设计**:通知仅保存在当前页面内存中;刷新或 Toast 浮层重新挂载后,不会回放已结算历史;若宿主仍能报告未处理交互,则会静默恢复。
|
|
41
42
|
|
|
42
43
|
## 快速开始
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
|
|
46
47
|
- 带 Web profile 的 DeepSeek Harness
|
|
47
48
|
- Node.js 20 或更新
|
|
48
|
-
- 已验证的 DeepSeek Harness:`0.
|
|
49
|
+
- 已验证的 DeepSeek Harness:`0.2.0-rc.1`
|
|
49
50
|
|
|
50
51
|
从 npm 安装:
|
|
51
52
|
|
|
@@ -91,13 +92,21 @@ dsh plugin --profile web add "link:$(pwd)"
|
|
|
91
92
|
|
|
92
93
|
自定义提示音保存在 profile 数据目录的 `<dataDir>/sounds/`,而非插件安装目录。上传限制 1 MB,支持 `mp3 / m4a / aac / wav / ogg / flac`,文件名必须是单段路径。
|
|
93
94
|
|
|
95
|
+
卡片上方是版本检测行:显示当前版本与 npm 上最新版本的关系——`v0.4.0 ✓ 最新`、`v0.4.0 ➔ v0.5.0` 或 `v0.4.0 · 检查失败`。**检查更新**会强制重新查询(`GET /plugins/dsh-notify/update?force=1`,需通过鉴权);页面加载则复用宿主 6 小时缓存。检测到新版本时,行下方会展开 `dsh plugin --profile web add @idoall/dsh-notify@<版本>` 与复制按钮——是否安装、以及随后是否重启 DSH,都由你决定。
|
|
96
|
+
|
|
97
|
+
<p align="center">
|
|
98
|
+
<img src="./assets/version-check.png" width="60%" alt="DSH 通知设置中的版本检测行:v0.4.0 已是最新、检查更新、GitHub、更新日志与反馈 Issue 入口">
|
|
99
|
+
</p>
|
|
100
|
+
|
|
94
101
|
## 兼容性
|
|
95
102
|
|
|
96
|
-
当前发布:插件 **`0.
|
|
103
|
+
当前发布:插件 **`0.4.1`** 已在 DeepSeek Harness **`0.2.0-rc.1`** 上验证。
|
|
97
104
|
|
|
98
105
|
| 插件 | 已验证的 DeepSeek Harness | 这一版是什么 |
|
|
99
106
|
| --- | --- | --- |
|
|
100
|
-
| **`0.
|
|
107
|
+
| **`0.4.1`** | `0.2.0-rc.1` | 兼容性跟进:声明支持 DSH `0.2.0` 线(`>=0.1.7-rc.1 <0.3.0`),`0.2.0` 正式版发布时插件不会再在 profile 加载阶段被丢弃。无源码改动——它绑定的接口都没有变化 |
|
|
108
|
+
| `0.4.0` | `0.1.7-rc.2` | 设置 → 通知新增在线版本检测:当前版本 vs npm 最新版、手动**检查更新**(`?force=1`)、仓库/更新日志/Issue 入口,以及可复制的升级命令——只读、带缓存,绝不自动安装、绝不重启 |
|
|
109
|
+
| `0.3.4` | `0.1.7-rc.1` | 触发时序修复:失败在 `agent/error` 时即投递(与 `turn/end` 共用同一张卡)、同栈 `idle → running` 抖动不再误报完成、客户端在会话状态变化与标签页重新可见时立即拉取(保留 1.5s 兜底) |
|
|
101
110
|
| `0.3.3` | `0.1.7-rc.1` | 适配 DSH 0.1.7:后台任务完成走 `jobs.events.subscribe`,工具结果读取扁平化后的 tool-role 消息,卡片内回答读取 `uiSession.sessionStatus`,`@deepseek-ai/schemastery` 改为 peer |
|
|
102
111
|
| `0.3.2` | `0.1.6-alpha.1` | 完成通知跟随原生 `agent/status: idle`;连续任务只发一张绿色卡 |
|
|
103
112
|
| `0.3.1` | `0.1.6-alpha.1` | 提示音与可见投递对齐;浮层重挂载后恢复未处理交互 |
|
|
@@ -108,8 +117,8 @@ dsh plugin --profile web add "link:$(pwd)"
|
|
|
108
117
|
| `0.1.2` | `0.1.6-alpha.1` | — |
|
|
109
118
|
|
|
110
119
|
- **`0.3.3` 只支持 DSH `0.1.7` 线。** DSH `0.1.7` 移除了 `jobs.onJobDone`,把工具结果身份扁平化到 tool-role 消息上,并用统一的 `sessionStatus` 快照替换了 `uiSession.pendingInteractions`。更早的 DSH(含 `0.1.6-alpha.1`)请继续用插件 **`0.3.2`**。
|
|
111
|
-
-
|
|
112
|
-
- `@deepseek-ai/schemastery` 是 **peer**,不是普通依赖:DSH
|
|
120
|
+
- 两处声明决定插件能否加载:`dsh.engines.dsh` 与每一个 `@deepseek-ai/dsh-*` peer 都写同一条要求,自 `0.4.1` 起为 `>=0.1.7-rc.1 <0.3.0`。DSH 会在 profile 加载时拒绝不兼容的 bundle,范围写错就会静默丢掉插件——旧的 `<0.2.0` 上限在 `0.2.0` 正式版上正是如此。
|
|
121
|
+
- `@deepseek-ai/schemastery` 是 **peer**,不是普通依赖:DSH 只会把 **link 形态**插件的 peer 解析到当前安装;若仍写成普通依赖,`link:` 安装的 Host 半会导入失败。
|
|
113
122
|
|
|
114
123
|
同时在 390px 手机视口检查:设置控件会重排,Toast 会满宽显示且不会被移动端侧栏遮挡。
|
|
115
124
|
|
|
@@ -140,8 +149,8 @@ npm run pack:check # 发布前置条件 + 客户端注册校验
|
|
|
140
149
|
发版由 tag 驱动。更新 `package.json`、将对应 CHANGELOG 段落移出 `Unreleased`、编写 `release-notes/v<版本>.md` 后,推送发版提交与 tag:
|
|
141
150
|
|
|
142
151
|
```sh
|
|
143
|
-
git tag v0.
|
|
144
|
-
git push origin v0.
|
|
152
|
+
git tag v0.4.1
|
|
153
|
+
git push origin v0.4.1
|
|
145
154
|
```
|
|
146
155
|
|
|
147
156
|
发版工作流会运行 `npm run verify`、打包插件、通过 npm trusted publishing(OIDC)发布,并创建附带 tarball 与 sha256 的 GitHub Release。
|
package/dist/client.js
CHANGED
|
@@ -51,6 +51,7 @@ window.__ModuleLoader__.load({
|
|
|
51
51
|
TOAST_STACK_VISIBLE: () => TOAST_STACK_VISIBLE,
|
|
52
52
|
TOAST_STACK_VISIBLE_NARROW: () => TOAST_STACK_VISIBLE_NARROW,
|
|
53
53
|
TOAST_SUCCESS_MS: () => TOAST_SUCCESS_MS,
|
|
54
|
+
UPDATE_REPO_URL: () => UPDATE_REPO_URL,
|
|
54
55
|
answerBatch: () => answerBatch,
|
|
55
56
|
apply: () => apply,
|
|
56
57
|
clearLocalSelfTests: () => clearLocalSelfTests,
|
|
@@ -84,6 +85,9 @@ window.__ModuleLoader__.load({
|
|
|
84
85
|
toastStackPlan: () => toastStackPlan,
|
|
85
86
|
toastTime: () => toastTime,
|
|
86
87
|
toastTone: () => toastTone,
|
|
88
|
+
updateChipText: () => updateChipText,
|
|
89
|
+
updateCommand: () => updateCommand,
|
|
90
|
+
updateTone: () => updateTone,
|
|
87
91
|
watchToastAnchor: () => watchToastAnchor
|
|
88
92
|
});
|
|
89
93
|
module.exports = __toCommonJS(client_exports);
|
|
@@ -119,6 +123,11 @@ window.__ModuleLoader__.load({
|
|
|
119
123
|
});
|
|
120
124
|
var SOUND_LABELS = Object.freeze({ chime: "\u53EE\u549A\uFF08\u9ED8\u8BA4\uFF09", ping: "\u8F7B\u63D0\u793A", alert: "\u53CC\u54CD\u63D0\u9192", none: "\u9759\u97F3" });
|
|
121
125
|
|
|
126
|
+
// src/update.js
|
|
127
|
+
var PACKAGE_NAME = "@idoall/dsh-notify";
|
|
128
|
+
var REGISTRY_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME.replace("/", "%2F")}/latest`;
|
|
129
|
+
var CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
130
|
+
|
|
122
131
|
// src/client.js
|
|
123
132
|
var BASE = "/plugins/dsh-notify";
|
|
124
133
|
var LOCAL_TEST_EVENT = "dsh-notify:self-test-local";
|
|
@@ -254,6 +263,15 @@ window.__ModuleLoader__.load({
|
|
|
254
263
|
.dsh-notify-result[data-tone=active]{color:var(--dsw-alias-state-business-primary)}
|
|
255
264
|
.dsh-notify-settings{gap:15px;max-width:790px}.dsh-notify-heading{font-size:26px;letter-spacing:-.4px;line-height:1.25}.dsh-notify-settings-head{align-items:flex-start;display:flex;gap:16px;justify-content:space-between}.dsh-notify-settings-intro{color:var(--dsw-alias-label-secondary);font-size:13px;line-height:1.55;margin:8px 0 0}.dsh-notify-settings-status{align-items:center;background:color-mix(in srgb,var(--dsw-alias-state-success-primary,#07865a) 10%,var(--dsw-alias-bg-layer-2));border:1px solid color-mix(in srgb,var(--dsw-alias-state-success-primary,#07865a) 40%,var(--dsw-alias-border-l2));border-radius:999px;color:var(--dsw-alias-state-success-primary,#07865a);display:flex;font-size:12px;gap:7px;line-height:1;padding:8px 10px;white-space:nowrap}.dsh-notify-settings-status::before{background:currentColor;border-radius:50%;content:"";height:7px;width:7px}.dsh-notify-card{border-radius:13px;box-shadow:0 2px 7px rgb(29 41 57 / 6%);padding:19px 20px}.dsh-notify-card-head{align-items:flex-start;display:flex;gap:12px;margin-bottom:17px}.dsh-notify-card-icon{align-items:center;background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#315ee8) 10%,var(--dsw-alias-bg-layer-2));border-radius:9px;color:var(--dsw-alias-state-business-primary,#315ee8);display:flex;flex:none;font-size:16px;height:31px;justify-content:center;width:31px}.dsh-notify-card-head .dsh-notify-card-title{font-size:15px}.dsh-notify-card-head .dsh-notify-hint{margin-top:4px}.dsh-notify-rows{border-top:1px solid var(--dsw-alias-border-l2)}.dsh-notify-setting-row{align-items:center;border-bottom:1px solid var(--dsw-alias-border-l2);display:flex;gap:16px;min-width:0;padding:15px 0}.dsh-notify-setting-row:last-child{border-bottom:0;padding-bottom:0}.dsh-notify-setting-copy{flex:1;min-width:0}.dsh-notify-setting-label{font-size:13px;font-weight:650}.dsh-notify-setting-help{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.55;margin:3px 0 0}.dsh-notify-setting-field{align-items:center;border-bottom:1px solid var(--dsw-alias-border-l2);display:grid;gap:20px;grid-template-columns:minmax(0,1fr) 210px;padding:15px 0}.dsh-notify-setting-field:last-child{border-bottom:0;padding-bottom:0}.dsh-notify-segmented{background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border:1px solid var(--dsw-alias-border-l2);border-radius:10px;display:flex;gap:4px;padding:4px}.dsh-notify-segmented button{background:transparent;border:0;border-radius:7px;color:var(--dsw-alias-label-secondary);cursor:pointer;flex:1;font:600 12px inherit;padding:8px 11px;white-space:nowrap}.dsh-notify-segmented button[data-active=true]{background:var(--dsw-alias-bg-layer-2);box-shadow:0 1px 3px rgb(0 0 0 / 10%);color:var(--dsw-alias-state-business-primary,#315ee8)}.dsh-notify-preview{align-items:center;background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border-radius:9px;color:var(--dsw-alias-label-secondary);display:flex;font-size:12px;gap:10px;margin-top:14px;padding:12px}.dsh-notify-preview::before{background:var(--dsw-alias-state-success-primary,#07865a);border-radius:50%;box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-state-success-primary,#07865a) 14%,transparent);content:"";flex:none;height:9px;width:9px}.dsh-notify-preview strong{color:var(--dsw-alias-label-primary);display:block;font-size:12px}.dsh-notify-settings .dsh-notify-toggle{align-items:center;cursor:default}.dsh-notify-settings .dsh-notify-toggle input{appearance:none;background:#aeb8c7;border:0;border-radius:999px;cursor:pointer;flex:0 0 42px;height:24px;margin:0;max-width:42px;min-height:24px;min-width:42px;position:relative;width:42px}.dsh-notify-settings .dsh-notify-toggle input::after{background:#fff;border-radius:50%;box-shadow:0 1px 2px rgb(0 0 0 / 22%);content:"";height:18px;left:3px;position:absolute;top:3px;transition:left .18s;width:18px}.dsh-notify-settings .dsh-notify-toggle input:checked{background:var(--dsw-alias-state-business-primary,#315ee8)}.dsh-notify-settings .dsh-notify-toggle input:checked::after{left:21px}.dsh-notify-settings .dsh-notify-toggle>span{display:none}.dsh-notify-settings .dsh-notify-card>*+*{margin-top:0}
|
|
256
265
|
.dsh-notify-test-panel{display:grid;gap:14px}.dsh-notify-test-caption{font-size:13px;font-weight:650;margin:0}.dsh-notify-test-grid{display:grid;gap:8px;grid-template-columns:repeat(4,minmax(0,1fr))}.dsh-notify-test-action{align-items:center;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:9px;color:var(--dsw-alias-label-primary);cursor:pointer;display:flex;font:600 13px inherit;gap:7px;justify-content:center;min-height:40px;padding:6px 8px;white-space:nowrap}.dsh-notify-test-action:hover{background:var(--dsw-alias-button-floating-hover)}.dsh-notify-test-action::before{background:var(--dsh-test-tone,var(--dsw-alias-label-tertiary));border-radius:50%;content:"";height:8px;width:8px}.dsh-notify-test-action[data-tone=success]{--dsh-test-tone:var(--dsw-alias-state-success-primary,#07865a)}.dsh-notify-test-action[data-tone=warning]{--dsh-test-tone:var(--dsw-alias-state-warn-primary,#bc6508)}.dsh-notify-test-action[data-tone=error]{--dsh-test-tone:var(--dsw-alias-state-error-primary,#cf3044)}.dsh-notify-test-action[data-tone=info]{--dsh-test-tone:var(--dsw-alias-state-business-primary,#2862db)}.dsh-notify-test-primary{background:var(--dsw-alias-state-business-primary,#315ee8);border:0;border-radius:9px;color:#fff;cursor:pointer;font:700 13px inherit;justify-self:start;min-height:40px;min-width:238px;padding:7px 14px;width:auto}.dsh-notify-test-primary:hover{filter:brightness(1.06)}.dsh-notify-test-secondary{background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l2);border-radius:9px;color:var(--dsw-alias-label-primary);cursor:pointer;font:600 13px inherit;justify-self:start;min-height:38px;min-width:205px;padding:6px 14px;width:auto}.dsh-notify-test-secondary:hover{background:var(--dsw-alias-button-floating-hover)}
|
|
266
|
+
.dsh-notify-update{align-items:center;display:flex;flex-wrap:wrap;gap:10px;min-width:0}
|
|
267
|
+
.dsh-notify-chip{background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border-radius:999px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1;padding:7px 11px;white-space:nowrap}
|
|
268
|
+
.dsh-notify-chip[data-tone=ok]{background:color-mix(in srgb,var(--dsw-alias-state-success-primary,#07865a) 12%,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-success-primary,#07865a)}
|
|
269
|
+
.dsh-notify-chip[data-tone=warn]{background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#bc6508) 14%,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-warn-primary,#bc6508)}
|
|
270
|
+
.dsh-notify-update-link{color:var(--dsw-alias-label-secondary);font-size:12px;text-decoration:none}
|
|
271
|
+
.dsh-notify-update-link:hover{color:var(--dsw-alias-label-primary);text-decoration:underline}
|
|
272
|
+
.dsh-notify-update-panel{background:var(--dsw-alias-bg-layer-3,var(--dsw-alias-bg-layer-2));border:1px solid var(--dsw-alias-border-l2);border-radius:10px;display:grid;gap:10px;padding:12px 14px}
|
|
273
|
+
.dsh-notify-update-title{font-size:13px;font-weight:650}
|
|
274
|
+
.dsh-notify-update-command{background:var(--dsw-alias-bg-layer-2);border-radius:8px;display:block;font-family:var(--ds-font-family-code,ui-monospace,SFMono-Regular,Menlo,monospace);font-size:12px;line-height:1.6;overflow-wrap:anywhere;padding:8px 10px}
|
|
257
275
|
@media (hover:none) and (pointer:coarse){.dsh-notify-action{line-height:42px;min-height:44px}.dsh-notify-select{min-height:44px}.dsh-notify-settings .dsh-notify-toggle input{flex:0 0 42px;height:24px;max-width:42px;min-height:24px;min-width:42px;width:42px}}@media(max-width:620px){.dsh-notify-settings-head{display:block}.dsh-notify-settings-status{display:inline-flex;margin-top:14px}.dsh-notify-setting-field{grid-template-columns:1fr;gap:11px}.dsh-notify-card{padding:16px}.dsh-notify-test-grid{gap:8px;grid-template-columns:repeat(2,minmax(0,1fr))}.dsh-notify-test-action{min-height:44px;padding:8px}.dsh-notify-test-primary,.dsh-notify-test-secondary{justify-self:stretch;min-width:0;width:100%}}`;
|
|
258
276
|
var TOAST_CSS = `.dsh-notify-frame{position:fixed;z-index:1100;transition:height 390ms cubic-bezier(.16,1,.3,1)}
|
|
259
277
|
.dsh-notify-stack{height:100%;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
|
|
@@ -1143,6 +1161,21 @@ window.__ModuleLoader__.load({
|
|
|
1143
1161
|
if (status === "running" || status === "submitted") return "active";
|
|
1144
1162
|
return "idle";
|
|
1145
1163
|
}
|
|
1164
|
+
var UPDATE_REPO_URL = "https://github.com/idoall/dsh-notify";
|
|
1165
|
+
function updateChipText(status) {
|
|
1166
|
+
if (!status) return "\u68C0\u67E5\u66F4\u65B0\u2026";
|
|
1167
|
+
const current = `v${typeof status.current === "string" && status.current !== "" ? status.current : "?"}`;
|
|
1168
|
+
if (status.error) return `${current} \xB7 \u68C0\u67E5\u5931\u8D25`;
|
|
1169
|
+
if (status.hasUpdate === true && typeof status.latest === "string") return `${current} \u2794 v${status.latest}`;
|
|
1170
|
+
return `${current} \u2713 \u6700\u65B0`;
|
|
1171
|
+
}
|
|
1172
|
+
function updateTone(status) {
|
|
1173
|
+
if (!status || status.error) return "idle";
|
|
1174
|
+
return status.hasUpdate === true ? "warn" : "ok";
|
|
1175
|
+
}
|
|
1176
|
+
function updateCommand(latest) {
|
|
1177
|
+
return `dsh plugin --profile web add ${PACKAGE_NAME}@${latest}`;
|
|
1178
|
+
}
|
|
1146
1179
|
var action = (label, onClick, extra = {}) => import_react.default.createElement("button", { className: "dsh-notify-action", type: "button", onClick, ...extra }, label);
|
|
1147
1180
|
var hint = (children) => import_react.default.createElement("p", { className: "dsh-notify-hint" }, children);
|
|
1148
1181
|
function NotificationSelfTests() {
|
|
@@ -1182,6 +1215,30 @@ window.__ModuleLoader__.load({
|
|
|
1182
1215
|
const [status, setStatus] = import_react.default.useState("\u6B63\u5728\u52A0\u8F7D\u2026");
|
|
1183
1216
|
const [customSounds, setCustomSounds] = import_react.default.useState([]);
|
|
1184
1217
|
const [soundNotice, setSoundNotice] = import_react.default.useState(null);
|
|
1218
|
+
const [updateInfo, setUpdateInfo] = import_react.default.useState(null);
|
|
1219
|
+
const [updateBusy, setUpdateBusy] = import_react.default.useState(false);
|
|
1220
|
+
const [copied, setCopied] = import_react.default.useState(null);
|
|
1221
|
+
const [updateNotice, setUpdateNotice] = import_react.default.useState(null);
|
|
1222
|
+
const loadUpdate = import_react.default.useCallback((force) => {
|
|
1223
|
+
setUpdateBusy(true);
|
|
1224
|
+
setUpdateNotice(null);
|
|
1225
|
+
return fetchJson(`/update${force ? "?force=1" : ""}`).then((value) => setUpdateInfo(value ?? null)).catch(() => setUpdateInfo({ current: "?", latest: null, hasUpdate: false, checkedAtMs: null, error: "unreachable" })).finally(() => setUpdateBusy(false));
|
|
1226
|
+
}, []);
|
|
1227
|
+
import_react.default.useEffect(() => {
|
|
1228
|
+
void loadUpdate(false);
|
|
1229
|
+
}, [loadUpdate]);
|
|
1230
|
+
const copyText = (value, label) => {
|
|
1231
|
+
const write = navigator.clipboard?.writeText?.bind(navigator.clipboard);
|
|
1232
|
+
if (typeof write !== "function") {
|
|
1233
|
+
setUpdateNotice("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9\u6587\u672C\u590D\u5236");
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
void Promise.resolve(write(value)).then(() => {
|
|
1237
|
+
setCopied(label);
|
|
1238
|
+
setUpdateNotice(null);
|
|
1239
|
+
setTimeout(() => setCopied(null), 1500);
|
|
1240
|
+
}).catch(() => setUpdateNotice("\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u9009\u62E9\u6587\u672C\u590D\u5236"));
|
|
1241
|
+
};
|
|
1185
1242
|
const loadSounds = () => fetchJson("/sounds").then((value) => setCustomSounds(Array.isArray(value?.custom) ? value.custom : [])).catch(() => setCustomSounds([]));
|
|
1186
1243
|
const uploadSound = async (file) => {
|
|
1187
1244
|
setSoundNotice(`\u6B63\u5728\u4E0A\u4F20 ${file.name}\u2026`);
|
|
@@ -1226,10 +1283,30 @@ window.__ModuleLoader__.load({
|
|
|
1226
1283
|
const toggle = (label, description, checked, onChange, ariaLabel) => import_react.default.createElement("div", { className: "dsh-notify-setting-row" }, copy(label, description), import_react.default.createElement("label", { className: "dsh-notify-toggle" }, import_react.default.createElement("input", { type: "checkbox", checked, onChange, "aria-label": ariaLabel }), import_react.default.createElement("span", null, label)));
|
|
1227
1284
|
const style = config?.notificationStyle === "soft" ? "soft" : "strong";
|
|
1228
1285
|
const collapsed = config?.stackCollapsed !== false;
|
|
1286
|
+
const updateRow = import_react.default.createElement(
|
|
1287
|
+
"div",
|
|
1288
|
+
{ className: "dsh-notify-update", "aria-label": "\u7248\u672C\u4E0E\u66F4\u65B0" },
|
|
1289
|
+
import_react.default.createElement("span", { className: "dsh-notify-chip", "data-tone": updateTone(updateInfo), role: "status" }, updateChipText(updateInfo)),
|
|
1290
|
+
import_react.default.createElement("button", { type: "button", className: "dsh-notify-action", disabled: updateBusy, onClick: () => void loadUpdate(true) }, updateBusy ? "\u68C0\u67E5\u4E2D\u2026" : "\u68C0\u67E5\u66F4\u65B0"),
|
|
1291
|
+
import_react.default.createElement("a", { className: "dsh-notify-update-link", href: UPDATE_REPO_URL, target: "_blank", rel: "noreferrer" }, "GitHub"),
|
|
1292
|
+
import_react.default.createElement("a", { className: "dsh-notify-update-link", href: `${UPDATE_REPO_URL}/blob/main/CHANGELOG.md`, target: "_blank", rel: "noreferrer" }, "\u66F4\u65B0\u65E5\u5FD7"),
|
|
1293
|
+
import_react.default.createElement("a", { className: "dsh-notify-update-link", href: `${UPDATE_REPO_URL}/issues`, target: "_blank", rel: "noreferrer" }, "\u53CD\u9988 Issue")
|
|
1294
|
+
);
|
|
1295
|
+
const updatePanel = updateInfo?.hasUpdate !== true ? null : import_react.default.createElement(
|
|
1296
|
+
"div",
|
|
1297
|
+
{ className: "dsh-notify-update-panel" },
|
|
1298
|
+
import_react.default.createElement("div", { className: "dsh-notify-update-title" }, `\u53D1\u73B0\u65B0\u7248\u672C v${updateInfo.latest}\uFF08\u5F53\u524D v${updateInfo.current}\uFF09`),
|
|
1299
|
+
import_react.default.createElement("code", { className: "dsh-notify-update-command" }, updateCommand(updateInfo.latest)),
|
|
1300
|
+
import_react.default.createElement("div", { className: "dsh-notify-actions" }, action(copied === "update" ? "\u5DF2\u590D\u5236" : "\u590D\u5236\u547D\u4EE4", () => copyText(updateCommand(updateInfo.latest), "update"))),
|
|
1301
|
+
hint("\u672C\u63D2\u4EF6\u4E0D\u4F1A\u81EA\u52A8\u5B89\u88C5\uFF0C\u4E5F\u4E0D\u4F1A\u91CD\u542F dsh\uFF1A\u6267\u884C\u4E0A\u9762\u7684\u547D\u4EE4\u540E\uFF0C\u9700\u8981\u4F60\u624B\u52A8\u91CD\u542F\u4E00\u6B21 dsh \u624D\u751F\u6548\u3002"),
|
|
1302
|
+
updateNotice ? import_react.default.createElement("p", { className: "dsh-notify-result", role: "status" }, updateNotice) : null
|
|
1303
|
+
);
|
|
1229
1304
|
return import_react.default.createElement(
|
|
1230
1305
|
"section",
|
|
1231
1306
|
{ className: "dsh-notify-settings", "aria-label": "\u901A\u77E5\u8BBE\u7F6E" },
|
|
1232
1307
|
import_react.default.createElement("div", { className: "dsh-notify-settings-head" }, import_react.default.createElement("div", null, import_react.default.createElement("div", { className: "dsh-notify-eyebrow" }, "NOTIFICATIONS"), import_react.default.createElement("h2", { className: "dsh-notify-heading" }, "\u901A\u77E5"), import_react.default.createElement("p", { className: "dsh-notify-settings-intro" }, "\u51B3\u5B9A\u4EC0\u4E48\u65F6\u5019\u63D0\u9192\u4F60\uFF0C\u4EE5\u53CA\u901A\u77E5\u5728\u9875\u9762\u4E2D\u5982\u4F55\u663E\u793A\u3002")), import_react.default.createElement("p", { className: "dsh-notify-settings-status", role: "status" }, status)),
|
|
1308
|
+
updateRow,
|
|
1309
|
+
updatePanel,
|
|
1233
1310
|
config && card("\u25C9", "\u901A\u77E5\u663E\u793A", "\u663E\u793A\u4F4D\u7F6E\u3001\u89C6\u89C9\u6837\u5F0F\u4E0E\u591A\u6761\u901A\u77E5\u7684\u5448\u73B0\u65B9\u5F0F\u3002", import_react.default.createElement(
|
|
1234
1311
|
import_react.default.Fragment,
|
|
1235
1312
|
null,
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import z from '@deepseek-ai/schemastery';
|
|
3
4
|
import { EventReducer, PLAN_REVIEW_FALLBACK, validateRequest } from './core.js';
|
|
4
5
|
import { createBuffer, createSettings } from './buffer.js';
|
|
5
6
|
import { createSoundLibrary } from './sounds.js';
|
|
6
7
|
import { BUILTIN_SOUNDS, SOUND_BYTES } from './sound-choices.js';
|
|
8
|
+
import { createUpdateChecker } from './update.js';
|
|
7
9
|
|
|
8
10
|
export const name = 'dsh-notify';
|
|
9
11
|
export const inject = [];
|
|
@@ -17,6 +19,7 @@ export { EventReducer, PLAN_REVIEW_FALLBACK, sanitizeBody, validateRequest } fro
|
|
|
17
19
|
export { createBuffer, createSettings, BUFFER_LIMIT } from './buffer.js';
|
|
18
20
|
export { createSoundLibrary } from './sounds.js';
|
|
19
21
|
export { BUILTIN_SOUNDS, SOUND_BYTES, parseSoundChoice, validSoundName } from './sound-choices.js';
|
|
22
|
+
export { createUpdateChecker, compareVersions, isNewer, parseVersion, PACKAGE_NAME, REGISTRY_LATEST_URL } from './update.js';
|
|
20
23
|
|
|
21
24
|
const BASE = '/plugins/dsh-notify';
|
|
22
25
|
const BODY_CAP = 16 * 1024;
|
|
@@ -163,6 +166,16 @@ function registerSensitive(ctx, webServer, connection, path, methods, handler) {
|
|
|
163
166
|
},
|
|
164
167
|
});
|
|
165
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Read this plugin's own version for the update check. A missing package.json only means the version
|
|
171
|
+
* chip cannot compare — it must never stop the plugin from loading.
|
|
172
|
+
*/
|
|
173
|
+
async function readPackageVersion() {
|
|
174
|
+
try {
|
|
175
|
+
const parsed = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
176
|
+
return typeof parsed?.version === 'string' && parsed.version !== '' ? parsed.version : '0.0.0';
|
|
177
|
+
} catch { return '0.0.0'; }
|
|
178
|
+
}
|
|
166
179
|
|
|
167
180
|
export async function apply(ctx, config = {}) {
|
|
168
181
|
// No store, no history: the buffer holds what has not been delivered yet, and preferences are the
|
|
@@ -173,6 +186,15 @@ export async function apply(ctx, config = {}) {
|
|
|
173
186
|
const reducer = new EventReducer(() => Date.now());
|
|
174
187
|
const diagnostics = { eventErrors: 0, services: {} };
|
|
175
188
|
const sounds = createSoundLibrary({ dataDir: config.dataDir });
|
|
189
|
+
// Online version detection: read-only and cached. `currentVersion`/`updateFetch`/`updateTtlMs` are
|
|
190
|
+
// test seams, exactly like `config.now` above — the shipped profile passes none of them.
|
|
191
|
+
const updates = createUpdateChecker({
|
|
192
|
+
currentVersion: typeof config.currentVersion === 'string' ? config.currentVersion : await readPackageVersion(),
|
|
193
|
+
fetchImpl: config.updateFetch,
|
|
194
|
+
now: config.now,
|
|
195
|
+
ttlMs: config.updateTtlMs,
|
|
196
|
+
log: (message) => { try { ctx?.logger?.debug?.(message); } catch { /* logging is never load-bearing */ } },
|
|
197
|
+
});
|
|
176
198
|
// Tool call IDs remain available for authoritative replay/result handling.
|
|
177
199
|
// A live user-questions/request has no source-proven causal callId, therefore
|
|
178
200
|
// this host must not infer one from an arrival queue or FIFO ordering.
|
|
@@ -570,6 +592,15 @@ export async function apply(ctx, config = {}) {
|
|
|
570
592
|
res.end(sound.bytes);
|
|
571
593
|
});
|
|
572
594
|
registerSensitive(lifecycleCtx, webServer, connection, '/health', 'GET', async (_req, res) => sendJson(res, 200, { storage: preferences.status, buffered: buffer.size, guiAvailable, diagnostics }));
|
|
595
|
+
/**
|
|
596
|
+
* Online version detection. Read-only: it reports what npm has, and the settings page offers a
|
|
597
|
+
* copyable command. This host never installs anything and never restarts dsh.
|
|
598
|
+
*/
|
|
599
|
+
registerSensitive(lifecycleCtx, webServer, connection, '/update', 'GET', async (req, res) => {
|
|
600
|
+
const url = new URL(String(req.url ?? ''), 'http://dsh.invalid');
|
|
601
|
+
const status = await updates.check({ force: url.searchParams.get('force') === '1' });
|
|
602
|
+
sendJson(res, 200, { ok: true, ...status });
|
|
603
|
+
});
|
|
573
604
|
return () => { guiAvailable = false; };
|
|
574
605
|
};
|
|
575
606
|
if (typeof ctx?.inject === 'function') {
|
|
@@ -583,5 +614,5 @@ export async function apply(ctx, config = {}) {
|
|
|
583
614
|
// to a disposer (or null), never an arbitrary runtime object. Keep the
|
|
584
615
|
// diagnostics surface on the callable disposer for controlled tests/tools.
|
|
585
616
|
const dispose = () => {};
|
|
586
|
-
return Object.assign(dispose, { buffer, preferences, reducer, diagnostics, guiAvailable, reason: guiAvailable ? undefined : 'authenticated web routes unavailable' });
|
|
617
|
+
return Object.assign(dispose, { buffer, preferences, reducer, diagnostics, updates, guiAvailable, reason: guiAvailable ? undefined : 'authenticated web routes unavailable' });
|
|
587
618
|
}
|
package/dist/update.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-notify — online version detection for the settings page.
|
|
3
|
+
*
|
|
4
|
+
* Asks the public npm registry for the newest published version and compares it with the version that
|
|
5
|
+
* is actually running. Read-only by design: this module NEVER installs anything and never restarts
|
|
6
|
+
* DSH. The settings page shows the result plus a copyable upgrade command, and the operator decides
|
|
7
|
+
* when to run it.
|
|
8
|
+
*
|
|
9
|
+
* The comparison lives here on purpose: `semver` would be a new runtime dependency for ~30 lines of
|
|
10
|
+
* arithmetic, and this plugin ships no runtime dependency beyond the DSH peers.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Package name on npm. The unscoped `dsh-notify` belongs to another author, so the scope is load-bearing. */
|
|
14
|
+
export const PACKAGE_NAME = '@idoall/dsh-notify';
|
|
15
|
+
/** Registry document that carries the `latest` tag. The slash stays percent-encoded: it is a path segment. */
|
|
16
|
+
export const REGISTRY_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME.replace('/', '%2F')}/latest`;
|
|
17
|
+
/** How long one lookup is reused before the registry is asked again. */
|
|
18
|
+
export const CACHE_TTL_MS = 6 * 60 * 60 * 1_000;
|
|
19
|
+
/** Network timeout for the lookup. */
|
|
20
|
+
export const FETCH_TIMEOUT_MS = 5_000;
|
|
21
|
+
/** The one failure code the page renders: offline is a normal state, not an error to shout about. */
|
|
22
|
+
export const REGISTRY_UNAVAILABLE = 'registry_unavailable';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Parse a version string.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} value - e.g. `0.3.4`, `0.4.0-rc.1`.
|
|
28
|
+
* @returns {{ major: number, minor: number, patch: number, prerelease: string[] } | undefined} the parsed
|
|
29
|
+
* version, or `undefined` when it is not a version.
|
|
30
|
+
*/
|
|
31
|
+
export function parseVersion(value) {
|
|
32
|
+
// `String.prototype.match`, not the RegExp method of the same purpose: this project's static source
|
|
33
|
+
// check refuses that method name anywhere in `src/` so that no module can compose a shell command,
|
|
34
|
+
// and it cannot tell a regex call apart from the shell one. The shell ban is worth the API choice.
|
|
35
|
+
const match = String(value ?? '').trim().match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
36
|
+
if (match === null) return undefined;
|
|
37
|
+
return {
|
|
38
|
+
major: Number(match[1]),
|
|
39
|
+
minor: Number(match[2]),
|
|
40
|
+
patch: Number(match[3]),
|
|
41
|
+
prerelease: match[4] === undefined ? [] : match[4].split('.'),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Compare two prerelease identifier lists per semver's precedence rules. */
|
|
46
|
+
function comparePrerelease(left, right) {
|
|
47
|
+
// A release outranks any prerelease of the same x.y.z.
|
|
48
|
+
if (left.length === 0 && right.length === 0) return 0;
|
|
49
|
+
if (left.length === 0) return 1;
|
|
50
|
+
if (right.length === 0) return -1;
|
|
51
|
+
const length = Math.max(left.length, right.length);
|
|
52
|
+
for (let index = 0; index < length; index += 1) {
|
|
53
|
+
const a = left[index]; const b = right[index];
|
|
54
|
+
if (a === undefined) return -1;
|
|
55
|
+
if (b === undefined) return 1;
|
|
56
|
+
const aNumber = /^\d+$/.test(a) ? Number(a) : undefined;
|
|
57
|
+
const bNumber = /^\d+$/.test(b) ? Number(b) : undefined;
|
|
58
|
+
if (aNumber !== undefined && bNumber !== undefined) {
|
|
59
|
+
if (aNumber !== bNumber) return aNumber < bNumber ? -1 : 1;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (aNumber !== undefined) return -1;
|
|
63
|
+
if (bNumber !== undefined) return 1;
|
|
64
|
+
if (a !== b) return a < b ? -1 : 1;
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Compare two versions.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} left - first version.
|
|
73
|
+
* @param {string} right - second version.
|
|
74
|
+
* @returns {number} `-1`, `0` or `1`; an unparsable version compares as equal, so a broken string can
|
|
75
|
+
* never claim an update is available.
|
|
76
|
+
*/
|
|
77
|
+
export function compareVersions(left, right) {
|
|
78
|
+
const a = parseVersion(left); const b = parseVersion(right);
|
|
79
|
+
if (a === undefined || b === undefined) return 0;
|
|
80
|
+
if (a.major !== b.major) return a.major < b.major ? -1 : 1;
|
|
81
|
+
if (a.minor !== b.minor) return a.minor < b.minor ? -1 : 1;
|
|
82
|
+
if (a.patch !== b.patch) return a.patch < b.patch ? -1 : 1;
|
|
83
|
+
return comparePrerelease(a.prerelease, b.prerelease);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Whether `latest` is newer than `current`.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} latest - the version published on npm.
|
|
90
|
+
* @param {string} current - the version this process runs.
|
|
91
|
+
* @returns {boolean} true only when `latest` is strictly newer.
|
|
92
|
+
*/
|
|
93
|
+
export function isNewer(latest, current) {
|
|
94
|
+
return compareVersions(latest, current) > 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The shape the settings page consumes. */
|
|
98
|
+
export function updateStatus(current, { latest = null, checkedAtMs = null, error = null } = {}) {
|
|
99
|
+
return {
|
|
100
|
+
current,
|
|
101
|
+
latest,
|
|
102
|
+
hasUpdate: latest !== null && isNewer(latest, current),
|
|
103
|
+
checkedAtMs,
|
|
104
|
+
error,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Build the checker the Host route uses.
|
|
110
|
+
*
|
|
111
|
+
* @param {object} options - checker options.
|
|
112
|
+
* @param {string} options.currentVersion - the version this process runs.
|
|
113
|
+
* @param {typeof fetch} [options.fetchImpl] - injected for tests; defaults to the global fetch.
|
|
114
|
+
* @param {() => number} [options.now] - injected clock.
|
|
115
|
+
* @param {number} [options.ttlMs] - cache lifetime; defaults to {@link CACHE_TTL_MS}.
|
|
116
|
+
* @param {(message: string) => void} [options.log] - optional diagnostics sink.
|
|
117
|
+
* @returns {{ currentVersion: string, check: (options?: { force?: boolean }) => Promise<object> }} the checker.
|
|
118
|
+
*/
|
|
119
|
+
export function createUpdateChecker({ currentVersion, fetchImpl, now = () => Date.now(), ttlMs = CACHE_TTL_MS, log } = {}) {
|
|
120
|
+
const version = typeof currentVersion === 'string' && currentVersion !== '' ? currentVersion : '0.0.0';
|
|
121
|
+
const doFetch = typeof fetchImpl === 'function' ? fetchImpl : globalThis.fetch;
|
|
122
|
+
let cached;
|
|
123
|
+
return {
|
|
124
|
+
currentVersion: version,
|
|
125
|
+
/**
|
|
126
|
+
* Look up the newest published version. A failure is reported in `error`, never thrown: the
|
|
127
|
+
* registry being unreachable must not break the settings page.
|
|
128
|
+
*
|
|
129
|
+
* @param {{ force?: boolean }} [options] - `force` bypasses the cache.
|
|
130
|
+
* @returns {Promise<object>} the status.
|
|
131
|
+
*/
|
|
132
|
+
async check({ force = false } = {}) {
|
|
133
|
+
if (!force && cached !== undefined) {
|
|
134
|
+
const age = now() - (cached.checkedAtMs ?? 0);
|
|
135
|
+
if (age < ttlMs) return cached;
|
|
136
|
+
}
|
|
137
|
+
let status;
|
|
138
|
+
try {
|
|
139
|
+
if (typeof doFetch !== 'function') throw new Error('fetch unavailable');
|
|
140
|
+
const response = await doFetch(REGISTRY_LATEST_URL, {
|
|
141
|
+
headers: { accept: 'application/json' },
|
|
142
|
+
signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
143
|
+
});
|
|
144
|
+
if (!response.ok) throw new Error(`registry ${String(response.status)}`);
|
|
145
|
+
const body = await response.json();
|
|
146
|
+
const latest = typeof body?.version === 'string' ? body.version : null;
|
|
147
|
+
if (latest === null) throw new Error('registry response had no version');
|
|
148
|
+
status = updateStatus(version, { latest, checkedAtMs: now() });
|
|
149
|
+
if (status.hasUpdate) log?.(`update available current=${version} latest=${latest}`);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
// Offline is a normal state: report it and keep notifying.
|
|
152
|
+
log?.(`update check failed name=${error?.name ?? 'Error'}`);
|
|
153
|
+
status = updateStatus(version, { checkedAtMs: now(), error: REGISTRY_UNAVAILABLE });
|
|
154
|
+
}
|
|
155
|
+
cached = status;
|
|
156
|
+
return status;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idoall/dsh-notify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH web plugin: in-page task notifications for DeepSeek Harness — enhanced or soft status toasts, a collapsible top-right stack, answer buttons, background-tab attention, and a WebAudio cue that also plays while the page is hidden. Live delivery only: no history, no service worker, no web push, no OS notification matrix.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dsh": {
|
|
21
21
|
"manifestVersion": 1,
|
|
22
22
|
"engines": {
|
|
23
|
-
"dsh": ">=0.1.7-rc.1 <0.
|
|
23
|
+
"dsh": ">=0.1.7-rc.1 <0.3.0"
|
|
24
24
|
},
|
|
25
25
|
"bundle": {
|
|
26
26
|
"patch": "./cordis.patch.yml"
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"compatibility": {
|
|
38
38
|
"dshReleases": {
|
|
39
|
-
"0.1.7-rc.1": "compatible"
|
|
39
|
+
"0.1.7-rc.1": "compatible",
|
|
40
|
+
"0.1.7-rc.2": "compatible",
|
|
41
|
+
"0.2.0-rc.1": "compatible"
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
},
|
|
@@ -54,10 +56,10 @@
|
|
|
54
56
|
},
|
|
55
57
|
"peerDependencies": {
|
|
56
58
|
"@deepseek-ai/cordis": "^4.0.4",
|
|
57
|
-
"@deepseek-ai/dsh-client-connection": ">=0.1.7-rc.1 <0.
|
|
58
|
-
"@deepseek-ai/dsh-client-ui-session": ">=0.1.7-rc.1 <0.
|
|
59
|
-
"@deepseek-ai/dsh-host-webserver": ">=0.1.7-rc.1 <0.
|
|
60
|
-
"@deepseek-ai/dsh-jobs": ">=0.1.7-rc.1 <0.
|
|
59
|
+
"@deepseek-ai/dsh-client-connection": ">=0.1.7-rc.1 <0.3.0",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-session": ">=0.1.7-rc.1 <0.3.0",
|
|
61
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.1.7-rc.1 <0.3.0",
|
|
62
|
+
"@deepseek-ai/dsh-jobs": ">=0.1.7-rc.1 <0.3.0",
|
|
61
63
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
62
64
|
"react": "^18.2.0"
|
|
63
65
|
},
|