dsh-macos-notifier 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-11-11
4
+
5
+ First public release.
6
+
7
+ > Version note: earlier iterations used internal sequence numbers (the sections below). The public series restarts here at 0.1.0; internal numbers are not carried over.
8
+
9
+
10
+ 本项目遵循 [Keep a Changelog](https://keepachangelog.com/) 与 [语义化版本](https://semver.org/)。
11
+
12
+ ## [Unreleased]
13
+
14
+ 无。
15
+
16
+ ## [3.0.0] - 2026-11-10
17
+
18
+ 首个公开版本。全部通知逻辑在 `client.js`(DSH 渲染层),`index.js` 是空的 no-op 插件。
19
+
20
+ ### Added
21
+
22
+ - 会话「运行中 → 已停止」边沿触发 macOS 系统通知:订阅 `remote.$on('api-session/status')`,
23
+ `onStatus()` 只在 `prev === true && isRunning === false` 时继续。
24
+ - 通知标题取会话名(`sessions` 快照 `byId[id].title`,回退 `label`,再回退 `DSH`)。
25
+ - 点击通知回到该会话:`uiWorkspace.openSession(sessionId)`。
26
+ - 点击兜底:发通知时把目标 `sessionId` 写进 `localStorage`(键 `dsh.macos-notifier.pending`,
27
+ `PENDING_TTL_MS = 90000`),`window` 的 `focus` 事件里补跳一次。
28
+ - `tag` 固定为 `dsh-session-<sessionId>`,同一会话的通知互相替换;`THROTTLE_MS = 2000` 节流。
29
+ - 应用内提示通道:命令式 DOM 在 `document.body` 上挂 `[data-mn-layer]` 容器,同屏最多 3 张,
30
+ 前台 9000 ms / 后台 60000 ms 自动消失。
31
+ - 会话头部工具区的小铃铛测试按钮:`conversation.session.header.utilities` 插槽,
32
+ `id: 'macos-notifier-action'`,`order: 90`。
33
+ - `shell.overlay` 插槽只注册一段 `<style>`,`id: 'macos-notifier-style'`,`order: 200`,
34
+ 随插件卸载移除。
35
+ - 会话过滤:`origin === 'subagent'`、带 `parentSessionId`、`blank === true` 的会话不发通知。
36
+ - `remote.$on` 不可用时退化为每 800 ms 轮询 `sessions` 快照。
37
+ - `locale/zh.json`、`locale/en.json` 提供插件名与描述。
38
+
39
+ ### Changed
40
+
41
+ - 公开包名统一为 `dsh-macos-notifier`:`package.json` 的 `name`、`index.js` 的 `name` 导出、
42
+ `client.js` 的模块 id、`cordis.patch.yml` 的 `insert.name` 四项逐字一致。
43
+ - 补齐开源元数据:`license`、`author`、`keywords`、`repository`、`homepage`、`bugs`、
44
+ `publishConfig`、`engines`。
45
+ - 依赖全部由宿主提供:`client.js` 只 `require('react')`,`index.js` 无 import,
46
+ 仓库不再带 `node_modules`。
47
+
48
+ ### Notes
49
+
50
+ - 不调用 osascript、不起子进程、不写状态文件;通知的应用身份就是 DSH 本体。
51
+ - 系统通知权限未授予时不会有横幅,此时只有应用内提示。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 veritaswiki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,130 @@
1
+ # dsh-macos-notifier — macOS notifications when a session finishes
2
+
3
+ ![License: MIT](https://img.shields.io/badge/license-MIT-blue)
4
+ ![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)
5
+ ![DSH](https://img.shields.io/badge/dsh-%3E%3D0.2.2--rc.1-lightgrey)
6
+
7
+ > Posts a macOS notification titled with the session name when that session finishes its turn; clicking it returns to that session. The notification is posted by the DSH renderer itself: no child process, no osascript, no state file.
8
+
9
+ ## What it does
10
+
11
+ - Fires one macOS notification when a session goes from **running** to **stopped** — `onStatus()` only lets through the `prev === true && isRunning === false` edge, so mid-turn status flapping does not notify.
12
+ - The notification title is the **session name**: `byId[id].title` from the `sessions` snapshot, falling back to `label`, then to `DSH`.
13
+ - **Clicking the notification returns to that session**: `uiWorkspace.openSession(sessionId)`.
14
+ - Notifications for the same session replace each other instead of stacking: `tag` is always `dsh-session-<sessionId>`, and the same session is throttled for 2 seconds (`THROTTLE_MS = 2000`).
15
+ - Besides the system notification, an **in-app notice** is always posted (both channels fire on the same event): it disappears after 9 seconds in the foreground and 60 seconds in the background, with at most 3 on screen.
16
+ - A **small bell** in the session header utilities posts a test notification, to confirm the channel works.
17
+ - Subagent sessions, sessions with a parent session, and blank sessions are skipped (`isNotifiable()`).
18
+
19
+ ## How it works
20
+
21
+ All the logic lives in `client.js` and runs inside the DSH renderer; `index.js` is an empty no-op plugin.
22
+
23
+ | Step | Implementation (`client.js`) |
24
+ | --- | --- |
25
+ | Trigger | `ctx.get('remote').$on('api-session/status', (sessionId, isRunning) => …)`, then `onStatus()` decides the edge |
26
+ | Poll fallback | When `remote.$on` is unavailable it degrades to `setInterval(…, 800)` comparing the `running` field of the snapshot |
27
+ | Session filter | `isNotifiable()` skips `origin === 'subagent'`, entries with `parentSessionId`, and `blank === true` |
28
+ | Title | `ctx.get('sessions')` snapshot `byId[sessionId].title` → fallback `label` → fallback `'DSH'` |
29
+ | System notification | `new Notification(title, { body, tag: 'dsh-session-' + sessionId, silent: false })` |
30
+ | Throttle | `THROTTLE_MS = 2000`, keyed by `sessionId`; inside the window it returns `false` |
31
+ | Click (main) | `n.onclick` → `ctx.get('uiWorkspace').openSession(sessionId)` |
32
+ | Click (fallback) | The target `sessionId` is written to `localStorage['dsh.macos-notifier.pending']` (`PENDING_TTL_MS = 90000`); `takePending()` runs on the `window` `focus` event |
33
+ | In-app notice | Imperative DOM: a `[data-mn-layer]` container on `document.body`, not routed through a React slot, at most 3 at a time |
34
+ | Bell | `slots.inject('conversation.session.header.utilities', …)`, `id: 'macos-notifier-action'`, `order: 90` |
35
+ | Style host | `slots.inject('shell.overlay', …)` registers only a `<style>` block, `id: 'macos-notifier-style'`, `order: 200`, removed on uninstall |
36
+ | Host side | `apply()` in `index.js` is empty; it only provides a loader entry that can be toggled |
37
+
38
+ Because the notification and the jump happen in the same renderer, the click handler already holds the `sessionId`:
39
+
40
+ - no child process: `index.js` has no imports, and `client.js` only uses the host-provided `require('react')` plus the browser `Notification` / DOM APIs;
41
+ - no osascript, so the notification is not attributed to another app;
42
+ - no state file and no custom URL scheme.
43
+
44
+ ## Install
45
+
46
+ This is a DSH (Cordis) bundle; three ways to install it.
47
+
48
+ ### A. Through `plugin_manager`
49
+
50
+ Ask the agent in DSH to install `dsh-macos-notifier`; it calls `plugin_manager`:
51
+
52
+ - `action: "install_bundle"`, `target` = an install spec:
53
+ - local clone: `file:/abs/path/to/dsh-macos-notifier`
54
+ - or the repository: `github:veritaswiki/dsh-macos-notifier`
55
+ - then `action: "set_bundle"` to enable it.
56
+
57
+ ### B. Manually attach to a profile
58
+
59
+ 1. Put the repository anywhere (referred to as `/abs/path/to/dsh-macos-notifier`).
60
+ 2. Edit the profile's `package.json` (`~/.dsh/profiles/<profile>/package.json`):
61
+ - add `"dsh-macos-notifier": "link:/abs/path/to/dsh-macos-notifier"` to `dependencies`
62
+ - add `"dsh-macos-notifier"` to the `dsh.profile.bundles` array
63
+ 3. Install dependencies in the profile directory (DSH also does this on its next start), then restart DSH.
64
+
65
+ ### C. From source
66
+
67
+ 1. `git clone https://github.com/veritaswiki/dsh-macos-notifier.git` anywhere.
68
+ 2. Same as B, but write the dependency as `"dsh-macos-notifier": "file:/abs/path/to/dsh-macos-notifier"`.
69
+ 3. Restart DSH.
70
+
71
+ ### Dependencies
72
+
73
+ `client.js` only requires `react` (supplied by the host), and `index.js` has no imports at all. There is therefore nothing to install separately and no `@deepseek-ai/*` package is needed; the repository ships no `node_modules`.
74
+
75
+ ### Allow notifications after installing
76
+
77
+ System Settings → Notifications → DeepSeek Harness → turn on **Allow Notifications**, style **Banners** or **Alerts**. Until that is on, no system banner is shown and only the in-app notice is visible.
78
+
79
+ ## Configuration
80
+
81
+ There is **no settings page**: `apply()` in `index.js` is empty and there is no Config schema, so nothing is configurable from the UI. What exists are the code constants and the system permission below:
82
+
83
+ | Key | Location | Type | Default | Meaning |
84
+ | --- | --- | --- | --- | --- |
85
+ | `THROTTLE_MS` | `client.js` | number | `2000` | Minimum gap between two system notifications for one session (ms) |
86
+ | `PENDING_TTL_MS` | `client.js` | number | `90000` | Lifetime of the pending `sessionId` in `localStorage` (ms) |
87
+ | `PENDING_KEY` | `client.js` | string | `'dsh.macos-notifier.pending'` | `localStorage` key holding the pending target |
88
+ | Notice lifetime | `client.js` | number | `9000` (focused) / `60000` (unfocused) | Milliseconds before an in-app notice disappears |
89
+ | Notices on screen | `client.js` | number | `3` | Beyond that the oldest one is removed |
90
+ | `dsh.client.immediately` | `package.json` | boolean | `true` | The client module loads with the host |
91
+ | `dsh.bundle.patch` | `package.json` | string | `./cordis.patch.yml` | Bundle patch entry |
92
+ | Notification permission | System Settings → Notifications → DeepSeek Harness | enum | not granted | When not granted `systemNotify()` returns `false` and no banner is posted |
93
+
94
+ ## Known limitations
95
+
96
+ - **macOS only, in practice**: this uses the renderer's web `Notification`. Opening the same web GUI in a normal browser sends notifications through that browser with its own permission, and this plugin does not take over.
97
+ - **No banner without permission**: `systemNotify()` returns `false` straight away when `Notification.permission !== 'granted'`, leaving only the in-app notice.
98
+ - **The user has to grant permission once**: it is requested only from the bell's click gesture (a request on page load is rejected by the system). When the state is `denied` or `default`, clicking the bell opens the system notification settings rather than a permission dialog.
99
+ - **Two host contracts**: the event name `api-session/status`, and the `sessions` snapshot fields (`byId[].title` / `label` / `running` / `origin` / `parentSessionId` / `blank`). If the host renames the event, the plugin degrades to polling every 800 ms; if the snapshot shape changes, it stops notifying. Everything is wrapped in try/catch: it does not throw and does not block the UI.
100
+ - **The click fallback expires after 90 seconds**: if clicking the banner only brings the window forward without firing `onclick`, the `focus` handler jumps once; past `PENDING_TTL_MS` it does not.
101
+ - **Not a notification centre**: no history, no grouping, nothing adjustable from the UI; the in-app notice is fixed to the bottom-right of the page (`z-index: 2147483000`).
102
+ - **Throttle is hard-coded**: `THROTTLE_MS = 2000` lives in `client.js`; a second turn ending within 2 seconds for the same session does not notify again.
103
+
104
+ ## Files
105
+
106
+ | File | Purpose |
107
+ | --- | --- |
108
+ | `package.json` | bundle manifest: `dsh.bundle.patch` + `dsh.client` (web, immediate) |
109
+ | `cordis.patch.yml` | inserts the `macos-notifier` loader row (`insert.name` must equal the package name) |
110
+ | `index.js` | host side: empty plugin, only provides a togglable loader entry |
111
+ | `client.js` | all client logic: status edge, system notification, in-app notice, bell |
112
+ | `locale/zh.json`, `locale/en.json` | title and description for the plugin manager |
113
+ | `icon.svg` | plugin icon (used inside DSH) |
114
+ | `assets/icon-180.png` | 180×180 bitmap icon |
115
+
116
+ ## Development
117
+
118
+ ```bash
119
+ node --check index.js
120
+ node --check client.js
121
+ node scripts/sanitize-check.mjs
122
+ ```
123
+
124
+ There is no automated test suite (no `test/` directory, no `test` script in `package.json`); CI runs only the syntax check and the sanitization gate.
125
+
126
+ `scripts/sanitize-check.mjs` is the sanitization gate: absolute home paths, private package scope, loopback addresses, private key material, internal address ranges, internal host names and token prefixes are all rejected; any hit exits with code 1.
127
+
128
+ ## License
129
+
130
+ MIT © 2026 veritaswiki
package/README.md CHANGED
@@ -1,3 +1,130 @@
1
- # Temporary Holding Version
1
+ # dsh-macos-notifier — 会话结束时的 macOS 通知
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ![License: MIT](https://img.shields.io/badge/license-MIT-blue)
4
+ ![Node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)
5
+ ![DSH](https://img.shields.io/badge/dsh-%3E%3D0.2.2--rc.1-lightgrey)
6
+
7
+ > 会话干完这一轮时给你一条标题为会话名的 macOS 通知,点一下回到那个会话。通知由 DSH 自己的渲染层发出:不起子进程、不调用 osascript、不写状态文件。
8
+
9
+ ## 它做什么
10
+
11
+ - 会话从「运行中」变成「已停止」时发一条 macOS 系统通知——`onStatus()` 只放行 `prev === true && isRunning === false` 这一条边沿,运行中途的状态抖动不弹。
12
+ - 通知标题是**会话名**:取 `sessions` 快照里的 `byId[id].title`,读不到时回退 `label`,再读不到用 `DSH`。
13
+ - **点通知回到那个会话**:`uiWorkspace.openSession(sessionId)`。
14
+ - 同一会话的通知互相替换,不堆成一列:`tag` 固定为 `dsh-session-<sessionId>`;同一会话 2 秒内不重复发(`THROTTLE_MS = 2000`)。
15
+ - 系统通知之外**必定**再发一张应用内提示(同一个事件两路都发):前台 9 秒、后台 60 秒后自动消失,同屏最多 3 张。
16
+ - 会话头部工具区有一个**小铃铛**:点一下发一条测试通知,用来确认通道通不通。
17
+ - 子代理会话、带父会话的会话、空白会话不发通知(`isNotifiable()` 过滤)。
18
+
19
+ ## 它怎么做
20
+
21
+ 全部逻辑在 `client.js`,跑在 DSH 的渲染层里;`index.js` 是一个空的 no-op 插件。
22
+
23
+ | 环节 | 实现(`client.js`) |
24
+ | --- | --- |
25
+ | 触发 | `ctx.get('remote').$on('api-session/status', (sessionId, isRunning) => …)`,交给 `onStatus()` 判断边沿 |
26
+ | 兜底轮询 | `remote.$on` 不可用时退化为 `setInterval(…, 800)`,比对快照里的 `running` 字段 |
27
+ | 会话过滤 | `isNotifiable()` 跳过 `origin === 'subagent'`、带 `parentSessionId`、`blank === true` 的会话 |
28
+ | 标题 | `ctx.get('sessions')` 快照的 `byId[sessionId].title` → 回退 `label` → 回退 `'DSH'` |
29
+ | 系统通知 | `new Notification(title, { body, tag: 'dsh-session-' + sessionId, silent: false })` |
30
+ | 节流 | `THROTTLE_MS = 2000`,按 `sessionId` 记时,窗口内直接返回 `false` |
31
+ | 点击(主路径) | `n.onclick` → `ctx.get('uiWorkspace').openSession(sessionId)` |
32
+ | 点击(兜底) | 发通知时把 `sessionId` 写进 `localStorage['dsh.macos-notifier.pending']`(`PENDING_TTL_MS = 90000`),`window` 的 `focus` 事件里 `takePending()` 补跳一次 |
33
+ | 应用内提示 | 命令式 DOM:`document.body` 上挂 `[data-mn-layer]` 容器,不经过 React 插槽,同屏最多 3 张 |
34
+ | 小铃铛 | `slots.inject('conversation.session.header.utilities', …)`,`id: 'macos-notifier-action'`,`order: 90` |
35
+ | 样式宿主 | `slots.inject('shell.overlay', …)` 只注册一段 `<style>`,`id: 'macos-notifier-style'`,`order: 200`,随插件卸载移除 |
36
+ | 宿主侧 | `index.js` 的 `apply()` 是空函数,只提供一行可启停的 Loader entry |
37
+
38
+ 因为通知和跳转在同一个渲染层里,点击时手里直接握着 `sessionId`:
39
+
40
+ - 不起子进程:`index.js` 无 import,`client.js` 只用宿主提供的 `require('react')` 和浏览器的 `Notification` / DOM API;
41
+ - 不调用 osascript,也就不会把通知归属到别的 App;
42
+ - 不写状态文件,也不需要自定义 URL 协议。
43
+
44
+ ## 安装
45
+
46
+ 本插件是 DSH(Cordis)bundle,三种装法。
47
+
48
+ ### 方式 A:让 Agent 用 `plugin_manager` 安装
49
+
50
+ 在 DSH 里对 Agent 说「装 `dsh-macos-notifier`」,它会调 `plugin_manager`:
51
+
52
+ - `action: "install_bundle"`,`target` 填安装 spec:
53
+ - 已 clone 到本地:`file:/abs/path/to/dsh-macos-notifier`
54
+ - 或仓库:`github:veritaswiki/dsh-macos-notifier`
55
+ - 装完 `action: "set_bundle"` 启用。
56
+
57
+ ### 方式 B:手动挂到 profile
58
+
59
+ 1. 把仓库放在任意目录(下面记作 `/abs/path/to/dsh-macos-notifier`)。
60
+ 2. 编辑 profile 的 `package.json`(`~/.dsh/profiles/<profile>/package.json`):
61
+ - `dependencies` 里加 `"dsh-macos-notifier": "link:/abs/path/to/dsh-macos-notifier"`
62
+ - `dsh.profile.bundles` 数组里加 `"dsh-macos-notifier"`
63
+ 3. 在 profile 目录安装依赖(DSH 下次启动时也会自行安装),然后重启 DSH。
64
+
65
+ ### 方式 C:从源码
66
+
67
+ 1. `git clone https://github.com/veritaswiki/dsh-macos-notifier.git` 到任意目录。
68
+ 2. 同方式 B,只把依赖写成 `"dsh-macos-notifier": "file:/abs/path/to/dsh-macos-notifier"`。
69
+ 3. 重启 DSH。
70
+
71
+ ### 依赖说明
72
+
73
+ `client.js` 只 `require('react')`(宿主提供),`index.js` 没有任何 import。因此本包没有需要单独安装的依赖,也不需要任何 `@deepseek-ai/*` 包;仓库不带 `node_modules`。
74
+
75
+ ### 装完先开系统通知
76
+
77
+ 系统设置 → 通知 → DeepSeek Harness → 打开「允许通知」,样式选「横幅」或「提醒」。没开之前系统横幅不会出现,此时只有应用内提示可见。
78
+
79
+ ## 配置
80
+
81
+ 本插件**没有设置页**:`index.js` 的 `apply()` 是空函数,没有 Config schema,所以没有任何能在 UI 里改的配置项。可调的东西只有下面这些代码常量与系统权限:
82
+
83
+ | 键 | 位置 | 类型 | 默认值 | 说明 |
84
+ | --- | --- | --- | --- | --- |
85
+ | `THROTTLE_MS` | `client.js` | number | `2000` | 同一会话两条系统通知的最小间隔(毫秒) |
86
+ | `PENDING_TTL_MS` | `client.js` | number | `90000` | 待跳转 `sessionId` 在 `localStorage` 里的有效期(毫秒) |
87
+ | `PENDING_KEY` | `client.js` | string | `'dsh.macos-notifier.pending'` | 待跳转目标的 `localStorage` 键名 |
88
+ | 提示卡存活时间 | `client.js` | number | `9000`(前台)/ `60000`(后台) | 应用内提示自动消失的毫秒数 |
89
+ | 同屏提示卡上限 | `client.js` | number | `3` | 超过就移除最早的一张 |
90
+ | `dsh.client.immediately` | `package.json` | boolean | `true` | client 模块随宿主立即加载 |
91
+ | `dsh.bundle.patch` | `package.json` | string | `./cordis.patch.yml` | bundle 补丁入口 |
92
+ | 系统通知权限 | 系统设置 → 通知 → DeepSeek Harness | 枚举 | 未授权 | 未授权时 `systemNotify()` 直接返回 `false`,不发横幅 |
93
+
94
+ ## 已知限制
95
+
96
+ - **仅 macOS 有意义**:用的是渲染层的 Web `Notification`。在普通浏览器里打开同一个 Web GUI 时,通知由浏览器自己发、权限另算,插件不接管。
97
+ - **系统通知未授权时没有横幅**:`systemNotify()` 在 `Notification.permission !== 'granted'` 时直接返回 `false`,此时只剩应用内提示。
98
+ - **首次授权要用户动手**:权限只在点击小铃铛的手势里请求(页面加载时自动请求会被系统拒绝)。`denied` / `default` 时点铃铛打开的是系统通知设置,不是权限对话框。
99
+ - **依赖宿主两个契约**:事件名 `api-session/status`,以及 `sessions` 快照字段(`byId[].title` / `label` / `running` / `origin` / `parentSessionId` / `blank`)。宿主改事件名则退化为每 800 ms 轮询;改快照结构则不再触发。全程 try/catch,不抛错、不挡界面。
100
+ - **补跳只有 90 秒窗口**:点横幅若只把窗口拉到前台、没触发 `onclick`,靠 `window` 的 `focus` 事件补跳;超过 `PENDING_TTL_MS` 不再跳。
101
+ - **不是通知中心**:不保存历史、不分组、UI 里不可调;应用内提示固定盖在页面右下角(`z-index: 2147483000`)。
102
+ - **节流写死**:`THROTTLE_MS = 2000` 硬编码在 `client.js`,同一会话 2 秒内的第二次结束不会重复弹。
103
+
104
+ ## 文件
105
+
106
+ | 文件 | 作用 |
107
+ | --- | --- |
108
+ | `package.json` | bundle 清单:`dsh.bundle.patch` + `dsh.client`(web,立即加载) |
109
+ | `cordis.patch.yml` | 插入 `macos-notifier` Loader 行(`insert.name` 必须等于包名) |
110
+ | `index.js` | Host 侧:空插件,只提供一行可启停的 Loader entry |
111
+ | `client.js` | 客户端全部逻辑:状态边沿、系统通知、应用内提示、小铃铛 |
112
+ | `locale/zh.json`、`locale/en.json` | 插件管理页标题与描述 |
113
+ | `icon.svg` | 插件图标(DSH 内部用) |
114
+ | `assets/icon-180.png` | 180×180 位图图标 |
115
+
116
+ ## 开发
117
+
118
+ ```bash
119
+ node --check index.js
120
+ node --check client.js
121
+ node scripts/sanitize-check.mjs
122
+ ```
123
+
124
+ 本仓库没有自动化测试(没有 `test/` 目录,`package.json` 里也没有 `test` 脚本);CI 只跑语法检查与脱敏门禁两步。
125
+
126
+ `scripts/sanitize-check.mjs` 是脱敏门禁:本机绝对路径、私有包前缀、回环地址、私钥材料、内网地址段、内部主机名、token 前缀一律不许出现,命中即退出码 1。
127
+
128
+ ## License
129
+
130
+ MIT © 2026 veritaswiki
Binary file
package/client.js ADDED
@@ -0,0 +1,544 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-macos-notifier',
3
+ factory(require) {
4
+ const React = require('react');
5
+ const h = React.createElement;
6
+
7
+ /** 本插件的 locale 命名空间 */
8
+ const NS = 'macos-notifier';
9
+ /** 同一会话的通知节流 */
10
+ const THROTTLE_MS = 2000;
11
+
12
+ const zh = {
13
+ 'action.label': '通知',
14
+ 'action.on': 'macOS 通知已开启 · 点击测试',
15
+ 'action.off': 'macOS 通知未开启 · 点击申请',
16
+ 'toast.done': '这一轮已经结束。',
17
+ 'toast.back': '点击回到该会话',
18
+ 'toast.test': '通知通道工作正常,点击回到该会话。',
19
+ 'toast.blocked': '系统通知未授权,仅显示应用内提示。',
20
+ 'toast.openSettings': '已打开系统通知设置,请把 DeepSeek Harness 设为「横幅」。',
21
+ 'toast.close': '关闭',
22
+ };
23
+
24
+ const en = {
25
+ 'action.label': 'Notifications',
26
+ 'action.on': 'macOS notifications are on — click to test',
27
+ 'action.off': 'macOS notifications are off — click to allow',
28
+ 'toast.done': 'This turn has finished.',
29
+ 'toast.back': 'Click to return to this session',
30
+ 'toast.test': 'Channel works. Click to return to this session.',
31
+ 'toast.blocked': 'System notifications are not allowed; showing the in-app notice only.',
32
+ 'toast.openSettings': 'Opened Notifications settings — set DeepSeek Harness to Banners.',
33
+ 'toast.close': 'Dismiss',
34
+ };
35
+
36
+ // 铃铛:内联 SVG,用 currentColor 描边,和宿主其它图标同一视觉重量
37
+ function BellIcon() {
38
+ return h(
39
+ 'svg',
40
+ {
41
+ width: 14,
42
+ height: 14,
43
+ viewBox: '0 0 16 16',
44
+ fill: 'none',
45
+ 'aria-hidden': 'true',
46
+ focusable: 'false',
47
+ style: { display: 'block' },
48
+ },
49
+ h('path', {
50
+ d: 'M8 2.4c-2.05 0-3.5 1.55-3.5 3.7v2.55L3.4 10.5h9.2l-1.1-1.85V6.1c0-2.15-1.45-3.7-3.5-3.7Z',
51
+ stroke: 'currentColor',
52
+ strokeWidth: 1.3,
53
+ strokeLinejoin: 'round',
54
+ }),
55
+ h('path', {
56
+ d: 'M6.75 12.1a1.35 1.35 0 0 0 2.5 0',
57
+ stroke: 'currentColor',
58
+ strokeWidth: 1.3,
59
+ strokeLinecap: 'round',
60
+ })
61
+ );
62
+ }
63
+
64
+ // 只跟随宿主主题 token:字号阶梯、分割线、圆角、阴影都对齐 DSH 自己的控件与设置页。
65
+ const CSS = `
66
+ .mn-btn{
67
+ -webkit-app-region:no-drag;
68
+ appearance:none;-webkit-appearance:none;background:transparent;border:0;padding:0;margin:0;
69
+ display:inline-flex;align-items:center;justify-content:center;
70
+ width:24px;height:24px;flex:none;
71
+ border-radius:var(--dsw-radius-sm,6px);
72
+ color:var(--dsw-alias-label-secondary);
73
+ cursor:pointer;
74
+ transition:background-color .12s ease,color .12s ease;
75
+ }
76
+ .mn-btn:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-1));color:var(--dsw-alias-label-primary)}
77
+ .mn-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color);outline-offset:1px}
78
+ .mn-btn[data-off="true"]{opacity:.45}
79
+
80
+ .mn-host{
81
+ position:fixed;right:16px;bottom:16px;z-index:2147483000;
82
+ display:flex;flex-direction:column;gap:6px;pointer-events:none;
83
+ }
84
+ .mn-toast{
85
+ pointer-events:auto;box-sizing:border-box;
86
+ width:252px;
87
+ display:flex;align-items:flex-start;gap:8px;
88
+ padding:9px 10px;
89
+ font-family:var(--dsw-font-family);
90
+ background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));
91
+ border:.5px solid var(--dsw-alias-border-l1);
92
+ border-radius:var(--dsw-radius-md,8px);
93
+ box-shadow:var(--dsw-elevation-prominent);
94
+ cursor:pointer;
95
+ transition:background-color .12s ease;
96
+ }
97
+ .mn-toast:hover{background:var(--dsw-alias-bg-layer-1)}
98
+ .mn-dot{
99
+ flex:none;width:6px;height:6px;margin-top:5px;border-radius:50%;
100
+ background:var(--dsw-alias-brand-primary);
101
+ }
102
+ .mn-text{min-width:0;flex:1}
103
+ .mn-title{
104
+ font-size:13px;line-height:18px;color:var(--dsw-alias-label-primary);
105
+ overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
106
+ }
107
+ .mn-desc{margin-top:1px;font-size:12px;line-height:16px;color:var(--dsw-alias-label-secondary)}
108
+ .mn-close{
109
+ appearance:none;-webkit-appearance:none;flex:none;
110
+ background:transparent;border:0;padding:0;margin:0;
111
+ width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;
112
+ font:inherit;font-size:12px;line-height:16px;
113
+ color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));
114
+ border-radius:var(--dsw-radius-xs,4px);cursor:pointer;
115
+ }
116
+ .mn-close:hover{color:var(--dsw-alias-label-primary)}
117
+ .mn-close:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color);outline-offset:1px}
118
+ `;
119
+
120
+ /** 常驻 shell.overlay 的样式宿主:只渲染 <style>,插件卸载即随组件一起清除。 */
121
+ function makeStyleHost() {
122
+ return function StyleHost() {
123
+ return h('style', null, CSS);
124
+ };
125
+ }
126
+
127
+ // ---------------------------------------------------------------- 状态 ----
128
+ const running = new Map();
129
+ const lastNotified = new Map();
130
+ let toastSeq = 0;
131
+ /** 模块级翻译,供命令式渲染使用(apply 时绑定) */
132
+ let translate = (key) => key;
133
+ /** 模块级 ctx,供命令式渲染使用(apply 时绑定) */
134
+ let boundCtx = null;
135
+ /** 系统通知的待跳转目标:横幅被点击或窗口重新获得焦点时任一路径都能补跳 */
136
+ const PENDING_KEY = 'dsh.macos-notifier.pending';
137
+ const PENDING_TTL_MS = 90000;
138
+
139
+ function setPending(sessionId) {
140
+ try {
141
+ localStorage.setItem(PENDING_KEY, JSON.stringify({ sessionId, at: Date.now() }));
142
+ } catch (err) {
143
+ /* localStorage 不可用时只靠 onclick */
144
+ }
145
+ }
146
+
147
+ function takePending() {
148
+ try {
149
+ const raw = localStorage.getItem(PENDING_KEY);
150
+ if (!raw) return null;
151
+ localStorage.removeItem(PENDING_KEY);
152
+ const parsed = JSON.parse(raw);
153
+ if (!parsed || !parsed.sessionId) return null;
154
+ if (Date.now() - Number(parsed.at || 0) > PENDING_TTL_MS) return null;
155
+ return parsed.sessionId;
156
+ } catch (err) {
157
+ return null;
158
+ }
159
+ }
160
+ /** 提示层容器(懒创建,挂在 body 上,不依赖任何 React 插槽) */
161
+ let layerEl = null;
162
+
163
+ function ensureLayer() {
164
+ if (layerEl && layerEl.isConnected) return layerEl;
165
+ try {
166
+ const el = document.createElement('div');
167
+ el.setAttribute('data-mn-layer', '');
168
+ el.style.cssText =
169
+ 'position:fixed;right:16px;bottom:16px;z-index:2147483000;' +
170
+ 'display:flex;flex-direction:column;gap:6px;pointer-events:none;';
171
+ document.body.appendChild(el);
172
+ layerEl = el;
173
+ return el;
174
+ } catch (err) {
175
+ console.warn('[macos-notifier] layer create failed', err);
176
+ return null;
177
+ }
178
+ }
179
+
180
+ function permission() {
181
+ try {
182
+ return typeof Notification === 'undefined' ? 'unsupported' : Notification.permission;
183
+ } catch (err) {
184
+ return 'unsupported';
185
+ }
186
+ }
187
+
188
+ function askPermission() {
189
+ if (typeof Notification === 'undefined') return Promise.resolve('unsupported');
190
+ if (Notification.permission !== 'default') return Promise.resolve(Notification.permission);
191
+ try {
192
+ return Notification.requestPermission();
193
+ } catch (err) {
194
+ return Promise.resolve('denied');
195
+ }
196
+ }
197
+
198
+ // ---------------------------------------------------------- 会话目录 ----
199
+ function readSessions(ctx) {
200
+ try {
201
+ const svc = ctx.get('sessions');
202
+ const list = svc && svc.list;
203
+ if (!list) return null;
204
+ if (typeof list.getSnapshot === 'function') return list.getSnapshot();
205
+ if (typeof list.get === 'function') return list.get();
206
+ if (typeof list === 'object' && 'byId' in list) return list;
207
+ } catch (err) {
208
+ /* 快照暂不可读 */
209
+ }
210
+ return null;
211
+ }
212
+
213
+ function titleOf(ctx, sessionId) {
214
+ try {
215
+ const snap = readSessions(ctx);
216
+ const row = snap && snap.byId && snap.byId[sessionId];
217
+ const title = row && (row.title || row.label);
218
+ return typeof title === 'string' && title.trim() ? title.trim() : null;
219
+ } catch (err) {
220
+ return null;
221
+ }
222
+ }
223
+
224
+ function isNotifiable(ctx, sessionId) {
225
+ try {
226
+ const snap = readSessions(ctx);
227
+ const row = snap && snap.byId && snap.byId[sessionId];
228
+ if (!row) return true;
229
+ if (row.origin === 'subagent' || row.parentSessionId) return false;
230
+ if (row.blank === true) return false;
231
+ return true;
232
+ } catch (err) {
233
+ return true;
234
+ }
235
+ }
236
+
237
+ // ------------------------------------------------------------ 跳转 ----
238
+ function jumpTo(ctx, sessionId) {
239
+ try {
240
+ window.focus();
241
+ } catch (err) {
242
+ /* ignore */
243
+ }
244
+ if (!sessionId) return false;
245
+ const workspace = ctx.get('uiWorkspace');
246
+ if (!workspace || typeof workspace.openSession !== 'function') return false;
247
+ try {
248
+ workspace.openSession(sessionId);
249
+ return true;
250
+ } catch (err) {
251
+ console.warn('[macos-notifier] jump failed', err);
252
+ return false;
253
+ }
254
+ }
255
+
256
+ /** 打开 macOS 通知设置,让用户把 DSH 的横幅打开。 */
257
+ function openNotificationSettings() {
258
+ const url = 'x-apple.systempreferences:com.apple.Notifications-Settings.extension';
259
+ try {
260
+ window.open(url, '_self');
261
+ return true;
262
+ } catch (err) {
263
+ return false;
264
+ }
265
+ }
266
+
267
+ // -------------------------------------------------- 应用内提示总线 ----
268
+ function publishToast(payload) {
269
+ const toast = {
270
+ id: ++toastSeq,
271
+ title: payload.title || 'DSH',
272
+ text: payload.text || '',
273
+ sessionId: payload.sessionId || null,
274
+ ttl: payload.ttl || 9000,
275
+ };
276
+ renderToast(toast);
277
+ }
278
+
279
+ /** 命令式渲染一张提示卡:不经过 React、不经过插槽,任何实例都能弹。 */
280
+ function renderToast(toast) {
281
+ const layer = ensureLayer();
282
+ if (!layer) return;
283
+ try {
284
+ const card = document.createElement('div');
285
+ card.className = 'mn-toast';
286
+ card.setAttribute('role', 'status');
287
+
288
+ const dot = document.createElement('span');
289
+ dot.className = 'mn-dot';
290
+
291
+ const text = document.createElement('div');
292
+ text.className = 'mn-text';
293
+
294
+ const title = document.createElement('div');
295
+ title.className = 'mn-title';
296
+ title.textContent = toast.title;
297
+
298
+ const desc = document.createElement('div');
299
+ desc.className = 'mn-desc';
300
+ desc.textContent = toast.text || translate('toast.back');
301
+
302
+ text.appendChild(title);
303
+ text.appendChild(desc);
304
+
305
+ const close = document.createElement('button');
306
+ close.type = 'button';
307
+ close.className = 'mn-close';
308
+ close.setAttribute('aria-label', translate('toast.close'));
309
+ close.textContent = '\u00d7';
310
+ close.addEventListener('click', (event) => {
311
+ event.stopPropagation();
312
+ card.remove();
313
+ });
314
+
315
+ card.appendChild(dot);
316
+ card.appendChild(text);
317
+ card.appendChild(close);
318
+ card.style.pointerEvents = 'auto';
319
+ card.addEventListener('click', () => {
320
+ jumpTo(boundCtx, toast.sessionId);
321
+ card.remove();
322
+ });
323
+
324
+ layer.appendChild(card);
325
+ // 最多同时三张,旧的先退场
326
+ while (layer.children.length > 3) layer.removeChild(layer.firstChild);
327
+ setTimeout(() => card.remove(), toast.ttl);
328
+ } catch (err) {
329
+ console.warn('[macos-notifier] toast render failed', err);
330
+ }
331
+ }
332
+
333
+ // 应用在前台时 macOS 会把自身通知压成 as none,
334
+ // 这一路负责保证「你正看着 DSH」时也一定能看到。
335
+ function windowFocused() {
336
+ try {
337
+ if (document.visibilityState === 'hidden') return false;
338
+ if (typeof document.hasFocus === 'function') return document.hasFocus();
339
+ return true;
340
+ } catch (err) {
341
+ return true;
342
+ }
343
+ }
344
+
345
+ // -------------------------------------------------------- 系统通知 ----
346
+ function systemNotify(ctx, { title, body, sessionId }) {
347
+ if (typeof Notification === 'undefined') return false;
348
+ if (Notification.permission !== 'granted') return false;
349
+
350
+ const key = sessionId || title;
351
+ const now = Date.now();
352
+ if (now - (lastNotified.get(key) || 0) < THROTTLE_MS) return false;
353
+ lastNotified.set(key, now);
354
+
355
+ try {
356
+ const n = new Notification(title, {
357
+ body,
358
+ tag: sessionId ? `dsh-session-${sessionId}` : undefined,
359
+ silent: false,
360
+ });
361
+ setPending(sessionId);
362
+ n.onclick = () => {
363
+ takePending();
364
+ jumpTo(ctx, sessionId);
365
+ try {
366
+ n.close();
367
+ } catch (err) {
368
+ /* ignore */
369
+ }
370
+ };
371
+ return true;
372
+ } catch (err) {
373
+ console.warn('[macos-notifier] system notify failed', err);
374
+ return false;
375
+ }
376
+ }
377
+
378
+ /** 一个事件同时喂给两条通道:系统通知 + 前台时的应用内提示。 */
379
+ function announce(ctx, { title, sessionId, text }) {
380
+ systemNotify(ctx, { title, body: text, sessionId });
381
+ // macOS 目前把 DSH 的横幅静音(usernoted 记录 as none),
382
+ // 所以应用内提示是唯一可靠通道:不在前台时留久一点,回来还能看见。
383
+ const focused = windowFocused();
384
+ publishToast({ title, text, sessionId, ttl: focused ? 9000 : 60000 });
385
+ }
386
+
387
+ // ------------------------------------------------------------ 边沿 ----
388
+ function onStatus(ctx, sessionId, isRunning, t) {
389
+ if (!sessionId) return;
390
+ const prev = running.get(sessionId);
391
+ running.set(sessionId, isRunning);
392
+ if (prev !== true || isRunning !== false) return;
393
+ if (!isNotifiable(ctx, sessionId)) return;
394
+ announce(ctx, {
395
+ title: titleOf(ctx, sessionId) || 'DSH',
396
+ sessionId,
397
+ text: t('toast.done'),
398
+ });
399
+ }
400
+
401
+ function seed(ctx) {
402
+ const snap = readSessions(ctx);
403
+ if (!snap || !snap.byId) return;
404
+ for (const id of Object.keys(snap.byId)) {
405
+ const row = snap.byId[id];
406
+ if (row && typeof row.running === 'boolean') running.set(id, row.running);
407
+ }
408
+ }
409
+
410
+ function startWatch(ctx, t) {
411
+ seed(ctx);
412
+ const remote = ctx.get('remote');
413
+ if (remote && typeof remote.$on === 'function') {
414
+ try {
415
+ const off = remote.$on('api-session/status', (sessionId, isRunning) => {
416
+ onStatus(ctx, sessionId, Boolean(isRunning), t);
417
+ });
418
+ if (typeof off === 'function') return off;
419
+ } catch (err) {
420
+ console.warn('[macos-notifier] remote status unavailable, fallback to poll', err);
421
+ }
422
+ }
423
+ const timer = setInterval(() => {
424
+ const snap = readSessions(ctx);
425
+ if (!snap || !snap.byId) return;
426
+ for (const id of Object.keys(snap.byId)) {
427
+ const row = snap.byId[id];
428
+ if (!row || typeof row.running !== 'boolean') continue;
429
+ const prev = running.get(id);
430
+ if (prev === undefined) {
431
+ running.set(id, row.running);
432
+ continue;
433
+ }
434
+ if (prev !== row.running) onStatus(ctx, id, row.running, t);
435
+ }
436
+ }, 800);
437
+ return () => clearInterval(timer);
438
+ }
439
+
440
+ // ------------------------------------------------------ 头部小铃铛 ----
441
+ function makeAction(ctx, t) {
442
+ return function NotifierAction(props) {
443
+ const [state, setState] = React.useState(permission());
444
+
445
+ const sessionId =
446
+ (props && props.session && (props.session.sessionId || props.session.id)) ||
447
+ (props && props.sessionId) ||
448
+ null;
449
+ const granted = state === 'granted';
450
+
451
+ const fire = () => {
452
+ // 只有在用户手势里请求权限,macOS 才认(spec 第 3 步)
453
+ askPermission().then((next) => {
454
+ setState(next);
455
+ const title = titleOf(ctx, sessionId) || 'DSH';
456
+ if (next === 'granted') {
457
+ systemNotify(ctx, { title, body: t('toast.test'), sessionId });
458
+ publishToast({ title, text: t('toast.test'), sessionId });
459
+ return;
460
+ }
461
+ if (next === 'unsupported') {
462
+ publishToast({ title, text: t('toast.blocked'), sessionId });
463
+ return;
464
+ }
465
+ // denied / default(系统层面没开):直接把人送到通知设置
466
+ openNotificationSettings();
467
+ publishToast({ title, text: t('toast.openSettings'), sessionId });
468
+ });
469
+ };
470
+
471
+ return h(
472
+ 'button',
473
+ {
474
+ type: 'button',
475
+ className: 'mn-btn',
476
+ 'data-off': granted ? 'false' : 'true',
477
+ title: granted ? t('action.on') : t('action.off'),
478
+ 'aria-label': granted ? t('action.on') : t('action.off'),
479
+ onClick: fire,
480
+ },
481
+ h(BellIcon, null)
482
+ );
483
+ };
484
+ }
485
+
486
+ // ------------------------------------------------------------ 注册 ----
487
+ return {
488
+ inject: ['slots', 'locale'],
489
+ apply(ctx) {
490
+ const locale = ctx.get('locale');
491
+ if (locale && typeof locale.register === 'function') {
492
+ ctx.effect(() => locale.register(NS, { zh, en }), 'macos-notifier: dictionaries');
493
+ }
494
+ const t =
495
+ locale && typeof locale.bind === 'function'
496
+ ? locale.bind(NS)
497
+ : (key) => (zh[key] !== undefined ? zh[key] : key);
498
+
499
+ translate = t;
500
+ boundCtx = ctx;
501
+
502
+ // 模块热替换不整页刷新,会留下上一代的提示图层;启动时先清干净
503
+ try {
504
+ for (const stale of document.querySelectorAll('[data-mn-layer]')) stale.remove();
505
+ } catch (err) {
506
+ /* ignore */
507
+ }
508
+ ctx.effect(() => startWatch(ctx, t), 'macos-notifier: session status watch');
509
+
510
+ // 点横幅若只把窗口拉到前台、没触发 onclick,这里补跳一次
511
+ const onFocus = () => {
512
+ const pending = takePending();
513
+ if (pending) jumpTo(ctx, pending);
514
+ };
515
+ window.addEventListener('focus', onFocus);
516
+ ctx.effect(() => () => window.removeEventListener('focus', onFocus), 'macos-notifier: focus fallback');
517
+
518
+ const slots = ctx.get('slots');
519
+ if (!slots || typeof slots.inject !== 'function') return;
520
+
521
+ slots.inject('shell.overlay', () =>
522
+ slots.register(
523
+ { name: 'shell.overlay', id: 'macos-notifier-style', order: 200, label: () => t('action.label') },
524
+ makeStyleHost()
525
+ )
526
+ );
527
+
528
+ slots.inject('conversation.session.header.utilities', () =>
529
+ slots.register(
530
+ {
531
+ name: 'conversation.session.header.utilities',
532
+ id: 'macos-notifier-action',
533
+ order: 90,
534
+ label: () => t('action.label'),
535
+ },
536
+ makeAction(ctx, t)
537
+ )
538
+ );
539
+
540
+
541
+ },
542
+ };
543
+ },
544
+ });
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: macos-notifier
3
+ name: 'dsh-macos-notifier'
package/icon.svg ADDED
@@ -0,0 +1,13 @@
1
+ <svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <!-- 与内置插件同一套图标语言:36 网格、蓝色渐变、白色细笔画 -->
3
+ <rect x="5" y="5" width="26" height="26" rx="7" fill="url(#notifier-tile)" />
4
+ <path d="M18 9.8c-3.15 0-5.35 2.35-5.35 5.55v4.05L11.1 21.9h13.8l-1.55-2.5v-4.05c0-3.2-2.2-5.55-5.35-5.55Z"
5
+ stroke="#FFFFFF" stroke-width="1.7" stroke-linejoin="round" />
6
+ <path d="M16.2 24.1a1.9 1.9 0 0 0 3.6 0" stroke="#FFFFFF" stroke-width="1.7" stroke-linecap="round" />
7
+ <defs>
8
+ <linearGradient id="notifier-tile" x1="18" y1="5" x2="18" y2="31" gradientUnits="userSpaceOnUse">
9
+ <stop stop-color="#7AC2FF" />
10
+ <stop offset="1" stop-color="#4A65E8" />
11
+ </linearGradient>
12
+ </defs>
13
+ </svg>
package/index.js ADDED
@@ -0,0 +1,16 @@
1
+ export const name = 'dsh-macos-notifier';
2
+
3
+ /**
4
+ * macOS 原生通知(客户端驱动版)
5
+ *
6
+ * 这个插件的能力全部在 client.js 里:DSH 的渲染层就是 DeepSeek Harness.app 本体,
7
+ * 在那里 `new Notification()` 弹出来的系统通知,应用身份就是 DSH 自己;
8
+ * 点击回调直接在同一个渲染层里调用 `uiWorkspace.openSession(sessionId)` 跳回会话。
9
+ *
10
+ * 宿主侧因此不需要做任何事——不 spawn osascript、不写状态文件、不跨进程通信。
11
+ * 保留这个 no-op 插件是为了让 bundle 在 profile 里有一行可启停的 Loader entry,
12
+ * client 模块扫描依赖这一行存在。
13
+ */
14
+ export function apply() {}
15
+
16
+ export default { name, apply };
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "macOS Notifier",
4
+ "description": "Posts a native macOS notification when a session finishes its turn, titled with the session name; clicking it returns to that session."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "macOS 原生通知 (macOS Notifier)",
4
+ "description": "会话这一轮结束时由 DSH 自己弹出系统通知,标题是会话名,点击直接回到对应会话。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "dsh-macos-notifier",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Posts a macOS notification titled with the session name when that session finishes a turn; clicking the notification returns to the session.",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "veritaswiki",
9
+ "url": "https://github.com/veritaswiki"
10
+ },
11
+ "keywords": [
12
+ "dsh-plugin",
13
+ "deepseek-harness",
14
+ "dsh",
15
+ "cordis",
16
+ "macos",
17
+ "notification"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/veritaswiki/dsh-macos-notifier.git"
22
+ },
23
+ "homepage": "https://github.com/veritaswiki/dsh-macos-notifier#readme",
24
+ "bugs": {
25
+ "url": "https://github.com/veritaswiki/dsh-macos-notifier/issues"
26
+ },
27
+ "engines": {
28
+ "node": ">=20",
29
+ "dsh": ">=0.2.2-rc.1"
30
+ },
31
+ "icon": "./icon.svg",
32
+ "exports": {
33
+ ".": "./index.js",
34
+ "./client": "./client.js",
35
+ "./locale/*.json": "./locale/*.json",
36
+ "./icon": "./icon.svg"
37
+ },
38
+ "files": [
39
+ "index.js",
40
+ "client.js",
41
+ "cordis.patch.yml",
42
+ "locale/*.json",
43
+ "icon.svg",
44
+ "assets/icon-180.png",
45
+ "README.md",
46
+ "README.en.md",
47
+ "CHANGELOG.md",
48
+ "LICENSE"
49
+ ],
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "provenance": true
53
+ },
54
+ "dsh": {
55
+ "bundle": {
56
+ "patch": "./cordis.patch.yml"
57
+ },
58
+ "client": {
59
+ "platform": "web",
60
+ "immediately": true
61
+ }
62
+ }
63
+ }