dsh-notify-tray 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,19 +27,19 @@ A notification + status-bar plugin for DeepSeek Harness (DSH). Works on macOS, W
27
27
 
28
28
  The plugin is published on npm as [`dsh-notify-tray`](https://www.npmjs.com/package/dsh-notify-tray). Installing from npm needs nothing beyond DSH itself — no Git required.
29
29
 
30
- > **⚠️ To get the latest release, include the version number**, e.g. `dsh-notify-tray@0.1.4` (the latest version is listed on [npm](https://www.npmjs.com/package/dsh-notify-tray)).
30
+ > **⚠️ To get the latest release, include the version number**, e.g. `dsh-notify-tray@0.1.6` (the latest version is listed on [npm](https://www.npmjs.com/package/dsh-notify-tray)).
31
31
  > DSH installs plugins with pnpm, whose supply-chain policy (`minimumReleaseAge`) won't auto-install a release that is still inside its waiting period. With a bare `dsh-notify-tray` you may get an older version (e.g. 0.1.0). If an older version is already installed, remove it first, then install with the version number.
32
32
 
33
33
  **Option 1 — from inside DSH (recommended)**
34
- Open DSH **Plugins → Add plugin**, type `dsh-notify-tray@0.1.4` (with the version number) into the input box and click **Install**.
34
+ Open DSH **Plugins → Add plugin**, type `dsh-notify-tray@0.1.6` (with the version number) into the input box and click **Install**.
35
35
 
36
36
  **Option 2 — command line**
37
37
 
38
38
  ```sh
39
39
  # Desktop app (the dsh command bundled with the app); include the version to get the latest
40
- dsh plugin --profile desktop add dsh-notify-tray@0.1.4
40
+ dsh plugin --profile desktop add dsh-notify-tray@0.1.6
41
41
  # Or the web / CLI profile
42
- dsh plugin --profile web add dsh-notify-tray@0.1.4
42
+ dsh plugin --profile web add dsh-notify-tray@0.1.6
43
43
  ```
44
44
 
45
45
  **Option 3 — from the Git repository** (latest unreleased code)
@@ -54,7 +54,7 @@ Restart DSH after installing. The version on the plugin page is the one installe
54
54
  >
55
55
  > ```sh
56
56
  > dsh plugin --profile desktop remove dsh-notify-tray
57
- > dsh plugin --profile desktop add dsh-notify-tray@0.1.4
57
+ > dsh plugin --profile desktop add dsh-notify-tray@0.1.6
58
58
  > ```
59
59
  >
60
60
  > Also, when the official npm registry is unreachable, DSH falls back to the npmmirror registry, which syncs a little later, so a just-published release may take a few minutes to appear there.
@@ -63,7 +63,7 @@ To update: include the version here too — `dsh plugin --profile desktop remove
63
63
 
64
64
  ## Configuration
65
65
 
66
- Every option can be changed under DSH **Plugins → Whale Notify Station → Configure**, or written into the profile's `cordis.patch.yml`:
66
+ Every option can be changed on DSH's **Plugins → Whale Notify Station** page, or written into the profile's `cordis.patch.yml`. The page's first screen holds only the everyday options (which events notify, sound, the status-bar whale, a today's-spend card, your plan and its quota lookup); notification channel, spend method, custom prices, exchange rate and refresh intervals sit under a folded **Advanced** section at the bottom, tagged with how many of them you have changed.
67
67
 
68
68
  ```yaml
69
69
  - id: notify-tray
@@ -104,7 +104,7 @@ Every option can be changed under DSH **Plugins → Whale Notify Station → Con
104
104
  | `exchangeRate` | `7.2` | 1 USD = ? CNY; catalog prices are in USD and converted when displaying CNY |
105
105
  | `prices` | `{}` | Per-model price table, highest priority |
106
106
 
107
- The **Current API price** section shows the model you're using (provider / model) and its catalog price. DSH's pi-ai adapter ships a model catalog (Claude, GPT, Gemini, Grok, Groq, Kimi, GLM, MiMo, MiniMax, OpenCode Go, DeepSeek, …); the plugin reads it directly and falls back to its built-in prices or your custom price when a model is missing. It is found automatically for the desktop app and for `dsh web` (including global npm installs such as `~/.npm-global`); if the settings page says it wasn't found, set the `DSH_NOTIFY_TRAY_PI_AI` environment variable to the DSH install directory (e.g. `~/.npm-global/lib/node_modules/@deepseek-ai/dsh`) and restart. A one-click **Copy catalog price into custom price** lets you tweak from the catalog value.
107
+ The **Current API price** section shows the model you're using (provider / model) and its catalog price. DSH's pi-ai adapter ships a model catalog (Claude, GPT, Gemini, Grok, Groq, Kimi, GLM, MiMo, MiniMax, OpenCode Go, DeepSeek, …); the plugin reads it directly and falls back to its built-in prices or your custom price when a model is missing. It is found automatically for the desktop app and for `dsh web` (global npm installs such as `~/.npm-global` or `%APPDATA%\npm` on Windows, pnpm, and nodes installed by nvm / fnm / volta; as a last resort the plugin asks `npm root -g`). If it isn't there at startup, the plugin looks again every 10 minutes. If the settings page still says it wasn't found, set the `DSH_NOTIFY_TRAY_PI_AI` environment variable to the DSH install directory (e.g. `~/.npm-global/lib/node_modules/@deepseek-ai/dsh`) and restart. A one-click **Copy catalog price into custom price** lets you tweak from the catalog value.
108
108
 
109
109
  ### Plans
110
110
 
@@ -136,13 +136,17 @@ Built-in plan presets (prices are the list prices at the time of writing and may
136
136
  | GPT | ChatGPT Go / Plus / Pro 5x / Pro 20x / Business, API pay-as-you-go | No endpoint for regular keys |
137
137
  | MiniMax | M Plan Go / Explore / Build (CN ¥49 / 119 / 469, intl. $22 / 55 / 132), legacy Coding Plan | 5-hour window remaining `GET /v1/coding_plan/remains` |
138
138
 
139
- Anything that can't be fetched can be typed in by hand; empty fields are simply hidden. On macOS / Linux the status-bar menu gains a **Plan · name · price · remaining** row whose submenu shows balance, remaining quota, reset time, the raw details returned by the endpoint, a **Refresh quota** action and links to the usage / pricing pages.
139
+ Anything that can't be fetched can be typed in by hand; empty fields are simply hidden. On macOS / Linux the status-bar menu shows balance and plan on one row (**余额 ¥… · provider 剩 …**); its submenu lists the DeepSeek balance, plan name and price, remaining quota and reset time, a **Refresh quota** action and the usage page. The full details returned by the endpoint are on the settings page. The menu has one level of submenus, at most 6 rows each and 24 characters per row, so Windows / Linux trays no longer cut it off at the screen edge.
140
140
 
141
141
  ## Notes
142
142
 
143
143
  - **When notifications fire** — a task that runs to completion counts as *completed*; an error, hitting the token limit or being blocked counts as *failed*; stopping a task yourself doesn't notify. For `ask_user_question`, questions with options and plan approvals count as *needs a choice*, questions without options as *needs input*; tool approvals count as *needs approval*. Only top-level sessions are tracked — sub-agents don't get their own notifications.
144
- - **How spend is computed** — when signed in with a DeepSeek account, today's spend is accumulated from drops in the account balance (top-ups don't count as negative spend; the platform bills with a delay, so in `auto` the estimate stands in until the balance catches up). In parallel, it's estimated from each `provider/model` route's tokens × unit price (price sources described under `priceSource` above); the **Today's usage** submenu breaks it down per model. The ledger lives in `~/.dsh/storages/dsh-notify-tray/ledger.json` and keeps 31 days.
144
+ - **How spend is computed** — when signed in with a DeepSeek account, today's spend is accumulated from drops in the account balance (top-ups don't count as negative spend; the platform bills with a delay, so in `auto` the estimate stands in until the balance catches up). In parallel, it's estimated from each `provider/model` route's tokens × unit price (price sources described under `priceSource` above); the **Today** submenu breaks it down per model (top 3). The ledger lives in `~/.dsh/storages/dsh-notify-tray/ledger.json` and keeps 31 days.
145
+ - **DeepSeek off-peak prices** — DeepSeek's listed prices are peak prices (Beijing time, weekdays 9–12 and 14–18). Tokens used outside those hours are estimated at half price; prices you type yourself (price table or custom price) are used as they are.
145
146
  - **Clicking a notification / the status-bar icon / "Open DeepSeek Harness" in the menu** — brings up the desktop app when there is one, otherwise (`dsh web`) opens the web UI in the browser. Browser notifications require granting notification permission first.
147
+ - With the default `channel: auto` and a DSH window open, notifications come from the window, and clicking one jumps to its session on every OS.
148
+ - **macOS system notifications** (`dsh web`, or `channel: system`) are sent with `osascript`, which can't tell DSH which session was clicked. Install [terminal-notifier](https://github.com/julienXX/terminal-notifier) (`brew install terminal-notifier`) and the plugin uses it automatically: clicking the notification opens the session.
149
+ - **Windows toasts** can only launch the app, so the window that comes forward within a minute of a toast opens that toast's session. Windows won't let a background process pull a *visible* window that is behind another one to the front (see [#4](https://github.com/ROYLeXJ/dsh-notify-tray/issues/4)); a minimized window is restored.
146
150
 
147
151
  ## Development
148
152
 
package/README.zh-CN.md CHANGED
@@ -27,19 +27,19 @@ DeepSeek Harness(DSH)的通知 + 状态栏插件,支持 macOS、Windows、
27
27
 
28
28
  插件已发布到 npm:[`dsh-notify-tray`](https://www.npmjs.com/package/dsh-notify-tray)。从 npm 安装只需要 DSH 本身,**不需要装 Git**。
29
29
 
30
- > **⚠️ 想装最新版,请带上版本号**,例如 `dsh-notify-tray@0.1.4`(最新版本号见 [npm](https://www.npmjs.com/package/dsh-notify-tray))。
30
+ > **⚠️ 想装最新版,请带上版本号**,例如 `dsh-notify-tray@0.1.6`(最新版本号见 [npm](https://www.npmjs.com/package/dsh-notify-tray))。
31
31
  > DSH 用 pnpm 安装插件,pnpm 的供应链安全策略(`minimumReleaseAge`)不会自动安装刚发布、还没过观察期的版本,只写 `dsh-notify-tray` 时会退回装一个旧版本(例如 0.1.0)。已经装了旧版的,先卸载,再带版本号安装。
32
32
 
33
33
  **方式一:在 DSH 里装(推荐)**
34
- 打开 DSH「插件 → 添加插件」,输入框里填 `dsh-notify-tray@0.1.4`(带上版本号),点「安装」。
34
+ 打开 DSH「插件 → 添加插件」,输入框里填 `dsh-notify-tray@0.1.6`(带上版本号),点「安装」。
35
35
 
36
36
  **方式二:命令行**
37
37
 
38
38
  ```sh
39
39
  # 桌面版(App 内置的 dsh 命令),带上版本号才能装到最新版
40
- dsh plugin --profile desktop add dsh-notify-tray@0.1.4
40
+ dsh plugin --profile desktop add dsh-notify-tray@0.1.6
41
41
  # 或者 Web / 命令行 profile
42
- dsh plugin --profile web add dsh-notify-tray@0.1.4
42
+ dsh plugin --profile web add dsh-notify-tray@0.1.6
43
43
  ```
44
44
 
45
45
  **方式三:从 Git 仓库装**(想用还没发版的最新代码时)
@@ -54,7 +54,7 @@ dsh plugin --profile web add dsh-notify-tray@0.1.4
54
54
  >
55
55
  > ```sh
56
56
  > dsh plugin --profile desktop remove dsh-notify-tray
57
- > dsh plugin --profile desktop add dsh-notify-tray@0.1.4
57
+ > dsh plugin --profile desktop add dsh-notify-tray@0.1.6
58
58
  > ```
59
59
  >
60
60
  > 另外,官方 npm 源连不上时 DSH 会退到 npmmirror(淘宝镜像),镜像比官方源晚一点同步,刚发的新版可能要等几分钟才到。
@@ -63,7 +63,7 @@ dsh plugin --profile web add dsh-notify-tray@0.1.4
63
63
 
64
64
  ## 设置
65
65
 
66
- 所有选项都可以在 DSH「插件 → 小鲸鱼通知站 → 配置」里修改,也可以写在 profile 的 `cordis.patch.yml` 里:
66
+ 所有选项都可以在 DSH「插件 → 小鲸鱼通知站」页里修改,也可以写在 profile 的 `cordis.patch.yml` 里。设置页首屏只有常用的几项(通知勾选、提示音、状态栏小鲸鱼、今日花费卡片、我的套餐和额度查询);通知通道、花费算法、自定义单价、汇率、各种刷新间隔都在页面底部的「高级设置」里,默认折叠,改过的项会标「已改 n 项」。
67
67
 
68
68
  ```yaml
69
69
  - id: notify-tray
@@ -104,7 +104,7 @@ dsh plugin --profile web add dsh-notify-tray@0.1.4
104
104
  | `exchangeRate` | `7.2` | 1 美元 = ? 人民币;目录价是美元,显示人民币时按它换算 |
105
105
  | `prices` | `{}` | 按模型的价格表,优先级最高 |
106
106
 
107
- 「当前 API 价格」区域会显示你正在用的模型(provider / model)和它的目录价:DSH 的 pi-ai 适配器自带一份模型目录(Claude、GPT、Gemini、Grok、Groq、Kimi、GLM、MiMo、MiniMax、OpenCode Go、DeepSeek 等),插件直接读它,拿不到的再用内置价或你填的自定义价。桌面版和 `dsh web`(含 `~/.npm-global` 等全局 npm 安装)都会自动找到这份目录;如果设置页提示没找到,可以设置环境变量 `DSH_NOTIFY_TRAY_PI_AI` 指向 DSH 的安装目录(例如 `~/.npm-global/lib/node_modules/@deepseek-ai/dsh`)后重启。一键「把目录价填进自定义价」可以在目录价的基础上改。
107
+ 「当前 API 价格」区域会显示你正在用的模型(provider / model)和它的目录价:DSH 的 pi-ai 适配器自带一份模型目录(Claude、GPT、Gemini、Grok、Groq、Kimi、GLM、MiMo、MiniMax、OpenCode Go、DeepSeek 等),插件直接读它,拿不到的再用内置价或你填的自定义价。桌面版和 `dsh web` 都会自动找到这份目录(全局 npm 安装如 `~/.npm-global`、Windows 的 `%APPDATA%\npm`,pnpm,以及 nvm / fnm / volta 装的 node;实在找不到时会问一次 `npm root -g`)。启动时没找到的话,插件每 10 分钟再找一次。如果设置页仍提示没找到,可以设置环境变量 `DSH_NOTIFY_TRAY_PI_AI` 指向 DSH 的安装目录(例如 `~/.npm-global/lib/node_modules/@deepseek-ai/dsh`)后重启。一键「把目录价填进自定义价」可以在目录价的基础上改。
108
108
 
109
109
  ### 套餐
110
110
 
@@ -136,13 +136,17 @@ dsh plugin --profile web add dsh-notify-tray@0.1.4
136
136
  | GPT | ChatGPT Go / Plus / Pro 5x / Pro 20x / Business、API 按量 | 普通 Key 无接口 |
137
137
  | MiniMax | M Plan Go / Explore / Build(国内 ¥49 / 119 / 469,国际 $22 / 55 / 132)、旧版 Coding Plan | 5 小时窗口剩余 `GET /v1/coding_plan/remains` |
138
138
 
139
- 拿不到的信息就手填;留空也可以,留空的项不显示。macOS / Linux 的状态栏菜单里会多一行「套餐 · 名称 · 价格 · 剩余」,子菜单里有余额、剩余额度、重置时间、接口返回的明细、「刷新额度」和用量页 / 价格页链接。
139
+ 拿不到的信息就手填;留空也可以,留空的项不显示。macOS / Linux 的状态栏菜单里,余额和套餐合在一行「余额 ¥… · 平台 剩 …」,子菜单里有 DeepSeek 余额、套餐名和价格、剩余额度和重置时间、「刷新额度」和用量页链接;接口返回的完整明细在设置页里看。状态栏菜单只有一层子菜单,每个最多 6 行、每行不超过 24 个字,在 Windows / Linux 托盘里也不会被屏幕边缘截断。
140
140
 
141
141
  ## 说明
142
142
 
143
143
  - **通知的触发时机**:任务跑完算「完成」;出错、超出 Token 上限、被拦截算「失败」;你自己点停止不弹通知。调用 `ask_user_question` 时,带选项的问题和计划审批算「需要选择」,不带选项的算「需要输入」;工具审批算「需要批准」。只跟踪顶层会话,子 agent 不单独弹通知。
144
- - **花费怎么算**:用 DeepSeek 账户登录时,按账户余额的下降累计当天花费(充值不算负花费;平台扣费有延迟,`auto` 下余额没跟上时先按估算显示);同时按当天各「provider/model」的 Token 乘以单价估算(单价来源见上面的 `priceSource`),「今日用量」子菜单里按模型分行显示。账本存在 `~/.dsh/storages/dsh-notify-tray/ledger.json`,保留 31 天。
144
+ - **花费怎么算**:用 DeepSeek 账户登录时,按账户余额的下降累计当天花费(充值不算负花费;平台扣费有延迟,`auto` 下余额没跟上时先按估算显示);同时按当天各「provider/model」的 Token 乘以单价估算(单价来源见上面的 `priceSource`),「今日」子菜单里按模型分行显示(最多 3 个模型)。账本存在 `~/.dsh/storages/dsh-notify-tray/ledger.json`,保留 31 天。
145
+ - **DeepSeek 空闲时段价格**:DeepSeek 的标价是高峰价(北京时间工作日 9–12、14–18 点),其余时间用的 token 按半价估算;你自己填的价(价格表或自定义价)按原样算。
145
146
  - **点击通知 / 状态栏图标 / 菜单里的「打开 DeepSeek Harness」**:有桌面版时唤起桌面版,没有时(`dsh web`)在浏览器里打开 Web 界面。浏览器里的通知需要先允许通知权限。
147
+ - 默认的 `channel: auto` 下,只要开着 DSH 窗口,通知就由窗口弹,三个系统上点击都能跳到对应会话。
148
+ - **macOS 系统通知**(`dsh web` 或 `channel: system`)用 `osascript` 发,点击时没法告诉 DSH 是哪个会话。装上 [terminal-notifier](https://github.com/julienXX/terminal-notifier)(`brew install terminal-notifier`)后插件会自动改用它,点通知就能打开对应会话。
149
+ - **Windows 系统通知**只能唤起应用,所以通知弹出后一分钟内被拉到前面的窗口,会打开这条通知对应的会话。Windows 不允许后台进程把被别的窗口挡住的*可见*窗口拉到最前(见 [#4](https://github.com/ROYLeXJ/dsh-notify-tray/issues/4));最小化的窗口会被恢复。
146
150
 
147
151
  ## 已知限制
148
152
 
package/lib/catalog.js CHANGED
@@ -293,6 +293,21 @@ export const PROVIDERS = [
293
293
  },
294
294
  ]
295
295
 
296
+ /**
297
+ * DeepSeek's list prices are peak prices (Beijing time, weekdays 9–12 and
298
+ * 14–18); outside those hours the API bills `factor` of them.
299
+ */
300
+ export const DEEPSEEK_OFF_PEAK = { factor: 0.5, peakHours: [[9, 12], [14, 18]], utcOffsetHours: 8 }
301
+
302
+ /** Is `time` in DeepSeek's off-peak window (weekends count as off-peak; public holidays are not known)? */
303
+ export function isDeepseekOffPeak(time = Date.now()) {
304
+ const beijing = new Date(time + DEEPSEEK_OFF_PEAK.utcOffsetHours * 3_600_000)
305
+ const weekday = beijing.getUTCDay()
306
+ if (weekday === 0 || weekday === 6) return true
307
+ const hour = beijing.getUTCHours() + beijing.getUTCMinutes() / 60
308
+ return !DEEPSEEK_OFF_PEAK.peakHours.some(([from, to]) => hour >= from && hour < to)
309
+ }
310
+
296
311
  /** Catalog provider for an id (`custom` and `none` have no catalog entry). */
297
312
  export function providerOf(id) {
298
313
  return PROVIDERS.find(p => p.id === id)