dsh-push-host 0.3.1 → 0.3.2

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.
Files changed (3) hide show
  1. package/README.md +11 -8
  2. package/lib/relay.js +10 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -158,14 +158,17 @@ timed 路径行为不变。插件侧修不了(`firstOf` 赢后够不着那条
158
158
 
159
159
  本包按可发布的 npm 包组织(`package.json` 带 `repository` / `homepage` / `bugs` / `author` /
160
160
  `publishConfig.access: public` / `engines` / `files` 白名单,MIT `LICENSE` 随包)。
161
- 发布由仓库维护者做(`npm publish`,本机没有 npm,见下),用户侧只需 `dsh plugin add`:
161
+ 用户侧只需 `dsh plugin add`:
162
+
163
+ **已发布到 npm:`dsh-push-host@0.3.1`(2026-10-27)** — https://registry.npmjs.org/dsh-push-host
164
+ (`latest` 即最新版;`repository.directory = host-plugin`,市场据此自动关联 npm 包)
162
165
 
163
166
  ```powershell
164
- # 从 npm 装(发布后)
167
+ # 从 npm 装(推荐,免 allowBuilds 构建授权)
165
168
  & $dsh plugin --profile <profile> add dsh-push-host
166
169
 
167
170
  # 从 tarball 装(离线/内网,等价路径,已实测)
168
- & $dsh plugin --profile <profile> add ./dsh-push-host-0.2.1.tgz
171
+ & $dsh plugin --profile <profile> add ./dsh-push-host-0.3.1.tgz
169
172
 
170
173
  # 从本地目录装(开发期,改完立即生效)
171
174
  & $dsh plugin --profile <profile> add "link:<仓库>/host-plugin"
@@ -174,12 +177,12 @@ timed 路径行为不变。插件侧修不了(`firstOf` 赢后够不着那条
174
177
  三种方式在 profile 里的落点完全相同:`package.json` 的 `dependencies` 多一项、`dsh.profile.bundles`
175
178
  多一项(DSH 读到本包的 `dsh.bundle.patch` 自动登记 bundle 层)。
176
179
 
177
- **打包**:有 npm 的机器直接 `npm pack`(`files` 白名单已配好);本机没装 npm(DSH 只带 pnpm),
178
- 所以仓库里配了等价工具,输出同样的 `npm notice` 清单与 sha1:
180
+ **打包**:有 npm 的机器直接 `npm pack`(`files` 白名单已配好)。
181
+ DSH 运行时只带 pnpm 的机器上,仓库里配了等价工具,输出同样的 `npm notice` 清单与 sha1:
179
182
 
180
183
  ```powershell
181
184
  & $node tools/pack-npm-tarball.mjs host-plugin --dry-run # 只看清单,不落盘
182
- & $node tools/pack-npm-tarball.mjs host-plugin # 落盘 host-plugin/dsh-push-host-0.2.1.tgz
185
+ & $node tools/pack-npm-tarball.mjs host-plugin # 落盘 host-plugin/dsh-push-host-0.3.1.tgz
183
186
  ```
184
187
 
185
188
  实测产物 9 个文件:`LICENSE`、`README.md`、`cordis.patch.yml`、`package.json`、
@@ -202,7 +205,7 @@ $dsh = '<DSH 安装目录>\resources\runtime\cli\bin\dsh.cmd' # 不在 PATH
202
205
  & $dsh --profile pushdist --from-default-profile headless --dump-config
203
206
 
204
207
  # 2. 把包(或 tarball)装进去
205
- & $dsh plugin --profile pushdist add ./dsh-push-host-0.2.1.tgz
208
+ & $dsh plugin --profile pushdist add ./dsh-push-host-0.3.1.tgz
206
209
 
207
210
  # 3. 验收挂载:看 dump-config 尾部
208
211
  & $dsh --profile pushdist --dump-config | Select-Object -Last 3
@@ -224,7 +227,7 @@ $dsh = '<DSH 安装目录>\resources\runtime\cli\bin\dsh.cmd' # 不在 PATH
224
227
  ```powershell
225
228
  & powershell -NoProfile -ExecutionPolicy Bypass -File deploy/windows/install-user.ps1 `
226
229
  -Profile <profile> -DshCli "<DSH 安装目录>\resources\runtime\cli\bin\dsh.cmd" `
227
- -Source .\dsh-push-host-0.2.1.tgz
230
+ -Source .\dsh-push-host-0.3.1.tgz
228
231
  # 成功后照打印的 next steps 走:重启 DSH(工具注册是冷的)→ 用新会话(变体钉在会话创建时)
229
232
  ```
230
233
 
package/lib/relay.js CHANGED
@@ -27,8 +27,16 @@ export class RelayClient {
27
27
  try { return JSON.parse(text); } catch { return { ok: false, raw: text.slice(0, 200) }; }
28
28
  }
29
29
 
30
- /** Publish a notification to the phone through ntfy (same JSON body shape the app expects). */
31
- async push({ title, body, click, priority = 'default', tags = [] }) {
30
+ /**
31
+ * Publish a notification to the phone through ntfy (same JSON body shape the app expects).
32
+ *
33
+ * `priority` MUST be an integer 1-5. ntfy's JSON body only accepts numbers here: passing the
34
+ * string 'default' (which is what ntfy's *header* form uses) makes the server answer
35
+ * 400 `invalid request: request body must be valid JSON` — a message that points nowhere near
36
+ * the real cause. Callers inside this plugin always pass 1/3/4; the default used to be the
37
+ * string 'default', which broke every caller that omitted it.
38
+ */
39
+ async push({ title, body, click, priority = 3, tags = [] }) {
32
40
  const r = await this.fetchImpl(this.base + '/', {
33
41
  method: 'POST',
34
42
  headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + this.ntfyToken },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-push-host",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "DSH host-side phone push: question events to ntfy + in-process answering via relay polling (replaces the external notifier + answer bridge)",
5
5
  "keywords": [
6
6
  "dsh",