@twinsearth/w2m-dsh-plugin 1.4.2 → 1.4.4

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.
@@ -5,14 +5,14 @@
5
5
  },
6
6
  "metadata": {
7
7
  "description": "The w2m fleet plugins: one account, many machines, any of Windows, macOS or Linux.",
8
- "version": "1.4.2"
8
+ "version": "1.4.4"
9
9
  },
10
10
  "plugins": [
11
11
  {
12
12
  "name": "w2m-fleet",
13
13
  "source": "./",
14
14
  "description": "Read fleet state and dispatch commands across the machines registered to one account. Read-only MCP surface: the five exposed tools cannot change anything.",
15
- "version": "1.4.2",
15
+ "version": "1.4.4",
16
16
  "author": {
17
17
  "name": "TwinsEarth"
18
18
  },
@@ -26,5 +26,5 @@
26
26
  ]
27
27
  }
28
28
  ],
29
- "version": "1.4.2"
29
+ "version": "1.4.4"
30
30
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "w2m-fleet",
3
3
  "description": "Drive the same project on online Windows, macOS and Linux machines from one account: read fleet state, dispatch commands and read results. The MCP surface is deliberately read-only.",
4
- "version": "1.4.2",
4
+ "version": "1.4.4",
5
5
  "author": {
6
6
  "name": "TwinsEarth"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -7,6 +7,38 @@
7
7
 
8
8
  All notable changes to this project are documented here.
9
9
 
10
+ ## [1.4.4] — 2026-10-23
11
+
12
+ **relay 重启不再丢失编队归属(devices.json 持久化 fleet_id)。**
13
+
14
+ - 持久化修复:`devices.json` 快照新增 `fleet_id` / `fleet_source`,`restore()` 同步恢复。
15
+ 在此之前,relay 重启后设备全在、token 仍有效,但每台设备的 fleet 归属全变成 null——
16
+ 编队"静默消失"且没有任何错误可看(本次在共享 relay 上实测复现)。
17
+ - 桥接 getupdates 看门狗:空闲时每 10 分钟输出 `polling ... connection live`;
18
+ 40s 长轮询超时明确记录 `poll timeout after 40s -- reconnecting`;
19
+ 连续 5 分钟没有一次成功轮询则退出(exit 3),由 launchd KeepAlive / systemd Restart= 拉起新连接,
20
+ 避免"进程活着但没人知道它是否还在轮询"的静默状态。
21
+ - 测试:relay 新增 fleet 重启往返用例(pair by fleet_key → 重启 → fleet_id/fleet_source 保留);
22
+ bridge 套件 36/36;门禁 GREEN ×2。
23
+ - 证据:docs/acceptance/1.4.4/FLEET-PERSISTENCE.json(真实 fleet task `01M5FLEETPERSIST0000000002`)。
24
+
25
+ ## [1.4.3] — 2026-10-22
26
+
27
+ **微信编队桥接:回复可靠性修复(不回复/静默问题)。**
28
+
29
+ - 每条消息独立 try/catch:任何处理异常不再让进程退出,改为回复
30
+ `处理失败(阶段,错误码):原因 + /help 提示`(新增 `renderBridgeError`)。
31
+ - 桥接启动调用 `ilink/bot/msg/notifystart`:修复"token 有效、进程在跑、但 iLink 不推送消息"的静默状态;
32
+ 日志记录 `notifystart : ok`,失败也记录原因。
33
+ - 非文本、空消息、未以 `/run` 开头、权限不足、派发失败/超时等路径均保证有回复与下一步提示。
34
+ - 运行方式支持 launchd 常驻(KeepAlive 自动拉起;macOS plist 由运维部署,不进入安装包)。
35
+
36
+ - **授权优先级修复**:exec-capability 只在任务未携带 grant 时兜底;grant 被拒(replay / 过期 / 机器不符)
37
+ 原样上报,不再被能力分支覆盖成路径匹配错误,`GRANT_REPLAY` 语义恢复。
38
+
39
+ 真机验收(macmini):`notifystart ok`、错误回复代码在位、launchd state=running、bridge 进程存活;
40
+ 证据 `docs/acceptance/1.4.3/BRIDGE-LIVE.json`。测试:chatops-ilink-fleet-bridge 36/36。
41
+
10
42
  ## [1.4.2] — 2026-10-22
11
43
 
12
44
  **Node 代码执行权限成为 UI 可激活的子插件能力(命中真机验收)。**
@@ -12,6 +12,6 @@
12
12
 
13
13
  [mcp_servers.w2m-fleet]
14
14
  command = "npx"
15
- args = ["-y", "-p", "@twinsearth/w2m-dsh-plugin@1.4.2", "w2m-mcp"]
15
+ args = ["-y", "-p", "@twinsearth/w2m-dsh-plugin@1.4.4", "w2m-mcp"]
16
16
  startup_timeout_sec = 20
17
17
  tool_timeout_sec = 60
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": "1.4.3",
3
+ "case": "BRIDGE-LIVE",
4
+ "kind": "positive",
5
+ "machines": [
6
+ "71f0dd07-e957-4889-bf82-319a0d6b434a"
7
+ ],
8
+ "executed_at": "2026-10-22T07:08:13.838Z",
9
+ "executor": "lead",
10
+ "requirement": "the deployed WeChat bridge enables iLink message push (notifystart ok), answers failures through the renderBridgeError path, and runs under launchd KeepAlive",
11
+ "task_id": "01M5BRIDGEACCMVJ78GU0",
12
+ "result": {
13
+ "outcome": "ok",
14
+ "assertions": {
15
+ "notifystart": true,
16
+ "error_reply_code": true,
17
+ "launchd_state": "state = running",
18
+ "bridge_processes": 3
19
+ }
20
+ },
21
+ "note": "hotfixed bridge files were verified live on macmini before packaging; the same files are what v1.4.3 ships"
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "version": "1.4.4",
3
+ "case": "FLEET-PERSISTENCE",
4
+ "kind": "positive",
5
+ "machines": [
6
+ "d89d5817-953d-4571-883d-23800e67d20c"
7
+ ],
8
+ "executed_at": "2026-10-22T16:32:38.180Z",
9
+ "executor": "lead",
10
+ "requirement": "a relay restart keeps every device in the fleet it was paired into: devices.json persists fleet_id/fleet_source and restore rebuilds them",
11
+ "task_id": "01M5FLEETPERSIST0000000002",
12
+ "result": {
13
+ "outcome": "ok",
14
+ "assertions": {
15
+ "fleet_roundtrip_test": "pass",
16
+ "node_test_exit": 0
17
+ }
18
+ },
19
+ "note": "executed as a real fleet task (node --test, fleet round-trip case) on the local machine before packaging"
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/w2m-dsh-plugin",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Run one project across your own Windows and macOS machines from a single DeepSeek account, through 11 w2m_* tools. Four coordination modes (replicate, split, broadcast, pipeline) and six aggregate verdicts (consistent, divergent, divergent-platform, failed, partial, unverifiable). P2P hole punching by default, with a bundled relay, STUN responder and ledger fallback, so the fleet needs no third-party service. Joining needs a pairing code plus autoStartAgent: true; installing alone does not join.",
5
5
  "type": "module",
6
6
  "exports": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "twinsearth-w2m-dsh",
4
- "version": "1.4.2",
4
+ "version": "1.4.4",
5
5
  "description": "Run one project across your own Windows and macOS machines from a single DeepSeek account, through 12 w2m_* tools. Four coordination modes (replicate, split, broadcast, pipeline) and six aggregate verdicts (consistent, divergent, divergent-platform, failed, partial, unverifiable). P2P hole punching by default, with a bundled relay, STUN responder and ledger fallback, so the fleet needs no third-party service. Joining needs a pairing code plus autoStartAgent: true; installing alone does not join.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -2988,8 +2988,10 @@ export function createAgent(options) {
2988
2988
  let allowed = matchAllowedCommand(commandArgv, allowedCommands);
2989
2989
  let grantAuthorized = false;
2990
2990
  let capabilityAuthorized = false;
2991
+ let grantAttempted = false;
2991
2992
  const capabilityStatus = readExecCapability(execCapabilityFile);
2992
2993
  if (allowed.allowed !== true && offer && typeof offer.grant === 'object' && offer.grant !== null) {
2994
+ grantAttempted = true;
2993
2995
  const gatePaths = maintenancePaths();
2994
2996
  const gate = await authorizeWithGrant({
2995
2997
  offer,
@@ -3000,7 +3002,10 @@ export function createAgent(options) {
3000
3002
  if (gate.ok === true) { allowed = { allowed: true, ok: true, grant_id: gate.grantId }; grantAuthorized = true; }
3001
3003
  else allowed = { ok: false, reason_code: gate.code ?? 'GRANT_REJECTED', detail: gate.message };
3002
3004
  }
3003
- if (allowed.allowed !== true && capabilityStatus.effective === true) {
3005
+ // A capability is a machine-local standing authorization, so it may rescue an allow-list miss -- but never an
3006
+ // explicit grant refusal (replay, expiry, wrong machine). Masking GRANT_REPLAY with a capability would execute a
3007
+ // token the operator already spent, and the envelope would report a reason that names neither decision.
3008
+ if (allowed.allowed !== true && grantAttempted !== true && capabilityStatus.effective === true) {
3004
3009
  allowed = matchAllowedCommand(commandArgv, effectiveExecCapabilityPrefixes(execCapabilityFile));
3005
3010
  if (allowed.allowed === true) { capabilityAuthorized = true; warnings.push('EXEC_CAPABILITY: ' + EXEC_CAPABILITY_WARNING); }
3006
3011
  }
@@ -372,6 +372,25 @@ export function renderTaskOutcome({ taskId, body }) {
372
372
  return `${renderVerdict({ taskId, verdict, machines: rows }).text}`;
373
373
  }
374
374
 
375
+ /**
376
+ * Render a per-message handling failure as something the operator can act on.
377
+ *
378
+ * The rule this exists for: **every message gets an answer, including the ones that broke something.**
379
+ * Before this, an exception anywhere in the per-message path escaped the loop, killed the process, and the
380
+ * chat window went silent with no indication why. A failure is now a reply with the phase, a stable code and
381
+ * the next step, and the loop continues.
382
+ *
383
+ * @param {unknown} error
384
+ * @param {string} [phase] where it failed: message | parse | reply | dispatch
385
+ * @returns {string}
386
+ */
387
+ export function renderBridgeError(error, phase = 'message') {
388
+ const code = error?.code ?? error?.name ?? 'ERR_UNKNOWN';
389
+ const message = error?.message ?? String(error ?? '未知错误');
390
+ return `处理失败(${phase},${code}):${String(message).slice(0, 300)}\n`
391
+ + '可以发送 /help 查看用法,或稍后重试这条指令。';
392
+ }
393
+
375
394
  /** Render a dispatch that never became a task. */
376
395
  export function renderFailure(error) {
377
396
  return renderDispatchFailure({
@@ -276,7 +276,7 @@ const MAX_STAGES = 16;
276
276
  * `package.json` during `scripts/pack.mjs` rather than hand-maintained, and `W2M_PLUGIN_VERSION`
277
277
  * overrides it at runtime for tests and packagers.
278
278
  */
279
- const PLUGIN_VERSION = '1.4.2';
279
+ const PLUGIN_VERSION = '1.4.4';
280
280
 
281
281
  /** How long any single HTTP call may take before it is aborted, in milliseconds. */
282
282
  const DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
@@ -213,6 +213,18 @@ export class Persistence {
213
213
  device_token: d.device_token ?? null,
214
214
  paired_at: rfc3339(d.paired_at_ms ?? this._now()),
215
215
  re_paired: d.re_paired === true,
216
+ /**
217
+ * v1.4.4: **the fleet binding is part of the device, so it must survive a restart.**
218
+ *
219
+ * Measured on the shared relay (2026-10-23): a relay restart came back with every device
220
+ * present and every fleet assignment gone, because this snapshot did not carry the two
221
+ * fields the pairing decision had produced. The devices were still authorised, so nothing
222
+ * looked broken -- they simply stopped being in a fleet, which is the one thing the fleet
223
+ * key had been bought to guarantee. `fleet_id` is a derived hash (not a secret) and
224
+ * `fleet_source` is the provenance that makes a wrong binding visible.
225
+ */
226
+ fleet_id: d.fleet_id ?? null,
227
+ fleet_source: d.fleet_source ?? null,
216
228
  };
217
229
  }
218
230
  const body = JSON.stringify(out, null, 2);
@@ -750,6 +750,11 @@ export class RabbitState {
750
750
  device_token: typeof d.device_token === 'string' ? d.device_token : null,
751
751
  paired_at_ms: Number.isFinite(pairedAt) ? pairedAt : this.nowMs(),
752
752
  re_paired: d.re_paired === true,
753
+ // v1.4.4: restore the fleet binding with the device. Without this the snapshot brought the
754
+ // device back but dropped the fleet it was paired into, so a restart silently un-joined
755
+ // every machine while leaving it fully authorised (measured 2026-10-23 on the shared relay).
756
+ fleet_id: typeof d.fleet_id === 'string' && d.fleet_id !== '' ? d.fleet_id : null,
757
+ fleet_source: typeof d.fleet_source === 'string' && d.fleet_source !== '' ? d.fleet_source : null,
753
758
  last_seen_at_ms: this.nowMs(),
754
759
  // a snapshot proves the device exists, not that it is connected
755
760
  online: false,