dsh-wake-relay 0.1.1 → 0.1.3

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.en.md CHANGED
@@ -50,12 +50,42 @@ No UI is a deliberate choice: this plugin's user is a script.
50
50
 
51
51
  ## Install
52
52
 
53
+ **The `desktop` profile is owned by the Electron app — the CLI refuses to touch it:**
54
+
55
+ ```
56
+ error: profile "desktop" is managed exclusively by the Electron application
57
+ ```
58
+
59
+ Two paths, then.
60
+
61
+ **① Let the agent install it (works on desktop and web, recommended)**
62
+
63
+ Paste this into your DSH:
64
+
65
+ ````text
66
+ Install dsh-wake-relay — the external wake bridge on npm. Follow the Install section of its README; do not invent steps.
67
+
68
+ When done, reply with exactly three lines: profile name / actual port / the raw GET /health response.
69
+
70
+ The only proof it installed is a new `listening` line in $DSH_HOME/wake-bridge.log. `install_bundle` returning `applied` is not proof — it says that even when nothing loaded.
71
+ ````
72
+
73
+ **② Command line (profiles not owned by Electron, e.g. `dsh web`)**
74
+
75
+ ```bash
76
+ dsh plugin --profile web add dsh-wake-relay
77
+ ```
78
+
79
+ From a local clone:
80
+
53
81
  ```bash
54
- dsh plugin --profile desktop add dsh-wake-relay # from npm
55
- dsh plugin --profile <your-profile> add ./dsh-wake-relay # from a local clone
82
+ git clone https://github.com/tendayst/dsh-wake-relay
83
+ dsh plugin --profile web add ./dsh-wake-relay
56
84
  ```
57
85
 
58
- Restart DSH afterwards — the plugin tree is composed at process start.
86
+ Installing usually takes effect **immediately** (`plugin_manager` applies it live; no restart needed). The only reliable check is whether `wake-bridge.log` gained a new `listening` line — if not, restart DSH once.
87
+
88
+ > **Do not install a second wake plugin alongside this one.** They all publish to the same `$DSH_HOME/wake-endpoint.json`. Two of them fight over the port (the loser falls back to an ephemeral one), and the one that stops can erase the other's discovery file. Since 0.1.2 this plugin only clears that file when it still points at itself, but the port contention remains.
59
89
 
60
90
  ### Two traps you only hit while installing
61
91
 
package/README.md CHANGED
@@ -46,16 +46,42 @@ UI 是有意的取舍:这个插件的读者是**脚本**,不是人的眼睛
46
46
 
47
47
  ## 安装
48
48
 
49
+ **桌面版的 `desktop` profile 由 Electron 独占,命令行装不了**——`dsh plugin --profile desktop add …` 会直接报错:
50
+
51
+ ```
52
+ error: profile "desktop" is managed exclusively by the Electron application
53
+ ```
54
+
55
+ 所以分两种路径。
56
+
57
+ **① 让 AI 装(桌面版 / Web 版都适用,推荐)**
58
+
59
+ 把这段粘给你的 DSH,它会自己装好并验证:
60
+
61
+ ````text
62
+ 帮我装 dsh-wake-relay —— npm 上的 DSH 外部唤醒桥。照它 README 的「安装」那节来,别自己发明步骤。
63
+
64
+ 装好只回三行:profile 名 / 实际端口 / GET /health 的返回。
65
+
66
+ 判据只有一条:$DSH_HOME/wake-bridge.log 里多了一行 listening 才算装上。install_bundle 返回 applied 不算——它没加载也这么说。
67
+ ````
68
+
69
+ **② 命令行(`dsh web` 这类非 Electron 管理的 profile)**
70
+
49
71
  ```bash
50
- # 从 npm(发布后)
51
- dsh plugin --profile desktop add dsh-wake-relay
72
+ dsh plugin --profile web add dsh-wake-relay
73
+ ```
52
74
 
53
- # 从本地目录
54
- git clone <repo> dsh-wake-relay
55
- dsh plugin --profile <你的 profile> add ./dsh-wake-relay
75
+ 从本地目录装:
76
+
77
+ ```bash
78
+ git clone https://github.com/tendayst/dsh-wake-relay
79
+ dsh plugin --profile web add ./dsh-wake-relay
56
80
  ```
57
81
 
58
- 装完**重启 DSH** 生效(插件树在进程启动时组合)。
82
+ 装完通常**即时生效**(`plugin_manager` 会动态 apply,不用重启)。判断标准只有一条:`wake-bridge.log` 里有没有新的 `listening` 行。没有就重启一次 DSH。
83
+
84
+ > **不要同时装第二个唤醒插件。** 所有实现都写同一个 `$DSH_HOME/wake-endpoint.json`。两个同时跑会抢端口(后启动的那个退到随机端口),而停止时写的 `port: null` 会让另一个的发现文件失效——0.1.2 起本插件只在文件仍指向自己时才清空,但端口之争依然存在。
59
85
 
60
86
  ### 两个装的时候才会遇到的陷阱
61
87
 
package/index.js CHANGED
@@ -533,6 +533,18 @@ export function apply(ctx, config) {
533
533
  } catch {
534
534
  /* ignore */
535
535
  }
536
+ // Two wake plugins can share one $DSH_HOME, and they all publish to the
537
+ // same endpoint path. Only erase the discovery file if it still describes
538
+ // this instance — otherwise the one that stops last blinds the other.
539
+ try {
540
+ const current = JSON.parse(readFileSync(ENDPOINT_PATH, "utf8"));
541
+ if (Number(current.port) !== Number(listenPort)) {
542
+ log(`stopped; left the endpoint file alone (it belongs to port ${current.port})`);
543
+ return;
544
+ }
545
+ } catch {
546
+ /* no endpoint file: nothing to guard */
547
+ }
536
548
  try {
537
549
  writeFileSync(ENDPOINT_PATH, JSON.stringify({ port: null, stoppedAt: new Date().toISOString() }), "utf8");
538
550
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-wake-relay",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Let any external process wake a DeepSeek Harness session — with synchronous delivery semantics, so the caller can own the retry loop and fire events that happened while the host was down.",
5
5
  "type": "module",
6
6
  "main": "./index.js",