@twinsearth/w2m-dsh-plugin 1.9.21 → 2.0.1

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.9.21"
8
+ "version": "2.0.1"
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.9.21",
15
+ "version": "2.0.1",
16
16
  "author": {
17
17
  "name": "TwinsEarth"
18
18
  },
@@ -26,5 +26,5 @@
26
26
  ]
27
27
  }
28
28
  ],
29
- "version": "1.9.21"
29
+ "version": "2.0.1"
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.9.21",
4
+ "version": "2.0.1",
5
5
  "author": {
6
6
  "name": "TwinsEarth"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -7,6 +7,30 @@
7
7
 
8
8
  All notable changes to this project are documented here.
9
9
 
10
+ ## [2.0.1] - 2026-10-28
11
+
12
+ - 修复右上角滚动按钮无效:滚动容器识别改为“命中测试 + 递归 shadow root + 允许 overflow:hidden 的程序化滚动容器”,
13
+ 并直接写 scrollTop/scrollTo;找不到容器时回退到 window。旧实现只找 overflow:auto,虚拟列表/隐藏溢出容器下点击是空操作。
14
+ - 只保留一个滚动图标(SVG 向上箭头,样式与右上角官方图标对齐:32px、8px 圆角、1px 边框、right:16px/top:64px),
15
+ 删除原来的第二个“一键到顶”按钮与会话头部的重复“⇧3”按钮。
16
+ - 交互:点一次向上滚动约 3 轮;长按 3 秒直接回到第一轮(长按后松手的 click 不会重复触发)。
17
+
18
+ ## [2.0.0] - 2026-10-28
19
+
20
+ 主插件与既有 Relay 的对接按《W2M Relay × ToFuture 外部对接 API v1.2》收敛;ToFuture 子插件按该文档
21
+ §6/§9 保持完全独立(主插件不内嵌、不调用、不代理、不实现其运维/白名单/令牌接口)。
22
+
23
+ - 能力协商:/healthz 读取 features、operator_token_required、signing.required;缺失
24
+ target-machines/result-projection 时明确拒绝联合派发;signing.required=true 拒绝(v1 外部客户端不支持强签);
25
+ operator_token_required=false 拒绝(生产必须为 true)。
26
+ - 派发:控制消息显式携带 target_machines(API §4.6:发到哪台机器只由它决定),保留
27
+ executor_machine_id 兼容旧 relay;同 id 派发捕获 409 后读回任务而不是当成成功;
28
+ 200 但无 task_id(依赖被拒)按失败处理;被点名机器租约 refused/expired/cancelled 立即失败。
29
+ - 移除主插件内所有 ToFuture 运维面模块(MAC/IP 白名单 HMAC 上报、relay 侧识别路由),
30
+ 遵守 API v1.2 §9:主插件不得实现、调用或探测运维/白名单/令牌接口。
31
+ - 联合开发(plan/approve/dispatch/merge)仍为实验性:数据面投递与合并接线未随本版交付;
32
+ relay 部署/升级独立于插件发布,线上 relay 版本以 /healthz 为准。
33
+
10
34
  ## [1.9.21] - 2026-10-28
11
35
 
12
36
  - 发布边界:本版只发主插件;ToFuture 运维子插件由独立私有仓库另行发布,本包不包含安装/下载能力。
@@ -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.9.21", "w2m-mcp"]
15
+ args = ["-y", "-p", "@twinsearth/w2m-dsh-plugin@2.0.1", "w2m-mcp"]
16
16
  startup_timeout_sec = 20
17
17
  tool_timeout_sec = 60
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "case": "RELEASE-2000",
4
+ "kind": "positive",
5
+ "machines": [
6
+ "b53a37f4-1464-4512-9259-33a7df091e3e"
7
+ ],
8
+ "executed_at": "2026-10-28T09:27:04.879Z",
9
+ "executor": "lead",
10
+ "task_id": "pre-release-2000-1793179624880",
11
+ "requirement": "v2.0.0:按 Relay×ToFuture API v1.2 收敛主插件对接(能力协商 / target_machines / 409 读回 / 200-refused 失败),并移除主插件内 ToFuture 运维面模块",
12
+ "result": {
13
+ "outcome": "ok",
14
+ "assertions": {
15
+ "api": "v1.2",
16
+ "capability": "features + operator_token_required + signing.required",
17
+ "dispatch": "target_machines explicit; 409 -> GET task; 200 without task_id refused; dead lease fails",
18
+ "removed": "tofuture report/hmac/whitelist + /v1/tofuture/identify",
19
+ "tests": "joint-relay-dispatch 4/4, joint suites 28/28, lint 0 errors"
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": "2.0.1",
3
+ "case": "RELEASE-2010",
4
+ "kind": "positive",
5
+ "machines": [
6
+ "b53a37f4-1464-4512-9259-33a7df091e3e"
7
+ ],
8
+ "executed_at": "2026-10-28T09:49:39.826Z",
9
+ "executor": "lead",
10
+ "task_id": "pre-release-2010-1793180979827",
11
+ "requirement": "v2.0.1:右上角单个滚动图标,点击滚动 3 轮、长按 3 秒到顶,图标与官方一键到顶对齐,修复点击无效",
12
+ "result": {
13
+ "outcome": "ok",
14
+ "assertions": {
15
+ "single_icon": "one SVG button; second top button and header duplicate removed",
16
+ "interaction": "click -> scrollTop -1.8*clientHeight; long press 3s -> top; click after long press suppressed",
17
+ "resolver": "elementFromPoint ancestors + shadow roots + overflow hidden + scrollTop direct write + window fallback",
18
+ "alignment": "right:16px, top:64px, 32x32, radius 8px, 1px border",
19
+ "tests": "client-bundle 26/26, lint 0 errors"
20
+ }
21
+ }
22
+ }
package/lib/client.js CHANGED
@@ -507,10 +507,9 @@ const PLUGIN_UPDATE_ROUTE = '/api/w2m/plugin-update';
507
507
  '.w2mSearchInput{height:24px;min-width:220px;border:0;background:transparent;color:inherit;font:inherit;outline:none}',
508
508
  '.w2mSearchCount{font-size:11px;opacity:.75;min-width:34px;text-align:center}',
509
509
  '.w2mSearchControls{display:inline-flex;align-items:center;gap:4px}',
510
- '.w2mScrollFloatWrap{position:fixed;right:18px;top:72px;z-index:2147483000;display:flex;flex-direction:column;gap:6px}',
511
- '.w2mScrollFloatBtn{width:34px;height:34px;border-radius:50%;border:1px solid currentColor;background:transparent;color:inherit;opacity:.72;font-size:13px;line-height:1;cursor:pointer}',
510
+ '.w2mScrollFloatWrap{position:fixed;right:16px;top:64px;z-index:2147483000;display:flex;flex-direction:column;align-items:center}',
511
+ '.w2mScrollFloatBtn{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;border:1px solid rgba(128,128,128,.4);background:transparent;color:inherit;opacity:.72;line-height:1;cursor:pointer;padding:0}',
512
512
  '.w2mScrollFloatBtn:hover{opacity:1}',
513
- '.w2mScrollUp{font-size:12px;padding:2px 6px;border:1px solid rgba(128,128,128,.4);border-radius:4px;background:transparent;color:inherit;cursor:pointer}',
514
513
  '::highlight(w2m-conversation-search){background-color:rgba(255,235,59,.85);color:rgba(11,122,51,1)}',
515
514
  '.w2mSearchMark{background-color:rgba(255,235,59,.85);color:rgba(11,122,51,1);border-radius:2px}',
516
515
  '.w2mSearchBtn{height:24px;min-width:24px;border:0;border-radius:4px;background:transparent;color:inherit;cursor:pointer}',
@@ -1041,62 +1040,104 @@ function paintSearchMarks(query) {
1041
1040
  }
1042
1041
  return total;
1043
1042
  }
1043
+ function isScrollableElement(el) {
1044
+ if (el === null || el === undefined || el === document.body || el === document.documentElement) return false;
1045
+ if (typeof el.scrollHeight !== 'number' || typeof el.clientHeight !== 'number') return false;
1046
+ if (el.scrollHeight <= el.clientHeight + 8) return false;
1047
+ const style = typeof getComputedStyle === 'function' ? getComputedStyle(el) : null;
1048
+ const overflow = style === null ? '' : style.overflowY;
1049
+ return overflow === '' || overflow === 'auto' || overflow === 'scroll' || overflow === 'overlay' || overflow === 'hidden';
1050
+ }
1044
1051
  function findScrollSurface() {
1045
1052
  if (typeof document === 'undefined') return null;
1046
- let best = null;
1047
- for (const root of searchRoots()) {
1048
- let all = [];
1049
- try { all = root.querySelectorAll ? [...root.querySelectorAll('*')] : []; } catch { continue; }
1050
- for (const el of all) {
1051
- if (el.scrollHeight <= el.clientHeight + 40) continue;
1052
- const style = typeof getComputedStyle === 'function' ? getComputedStyle(el) : null;
1053
- const overflow = style === null ? '' : style.overflowY;
1054
- if (overflow !== 'auto' && overflow !== 'scroll') continue;
1055
- if (best === null || el.scrollHeight > best.scrollHeight) best = el;
1053
+ const found = new Set();
1054
+ const addAncestors = (node) => {
1055
+ let current = node;
1056
+ while (current !== null && current !== undefined) {
1057
+ if (isScrollableElement(current)) { found.add(current); return; }
1058
+ current = current.parentElement ?? (current.parentNode instanceof ShadowRoot ? current.parentNode.host : null);
1059
+ }
1060
+ };
1061
+ if (typeof document.elementFromPoint === 'function' && typeof window !== 'undefined') {
1062
+ const points = [[window.innerWidth / 2, window.innerHeight / 2], [window.innerWidth / 2, window.innerHeight * 0.72], [window.innerWidth * 0.72, window.innerHeight * 0.4]];
1063
+ for (const point of points) {
1064
+ try { addAncestors(document.elementFromPoint(point[0], point[1])); } catch { /* ignore */ }
1056
1065
  }
1057
1066
  }
1067
+ if (found.size === 0) {
1068
+ for (const root of searchRoots()) {
1069
+ let all = [];
1070
+ try { all = root.querySelectorAll ? [...root.querySelectorAll('*')] : []; } catch { continue; }
1071
+ for (const el of all) if (isScrollableElement(el)) found.add(el);
1072
+ }
1073
+ }
1074
+ let best = null;
1075
+ for (const el of found) {
1076
+ if (best === null || el.clientHeight * el.scrollHeight > best.clientHeight * best.scrollHeight) best = el;
1077
+ }
1058
1078
  return best;
1059
1079
  }
1060
1080
  function scrollChatTurns() {
1061
1081
  const surface = findScrollSurface();
1062
- if (surface !== null) surface.scrollBy({ top: -Math.round(Math.max(240, surface.clientHeight * 1.8)), behavior: 'smooth' });
1063
- else if (typeof window !== 'undefined') window.scrollBy({ top: -Math.round(window.innerHeight * 1.8), behavior: 'smooth' });
1082
+ const step = Math.round(Math.max(240, (surface !== null ? surface.clientHeight : window.innerHeight) * 1.8));
1083
+ if (surface !== null) {
1084
+ const before = surface.scrollTop;
1085
+ surface.scrollTop = before - step;
1086
+ if (surface.scrollTop === before) surface.scrollBy({ top: -step, behavior: 'smooth' });
1087
+ return;
1088
+ }
1089
+ if (typeof window !== 'undefined') window.scrollBy({ top: -step, behavior: 'smooth' });
1064
1090
  }
1065
1091
  function scrollChatTop() {
1066
1092
  const surface = findScrollSurface();
1067
- if (surface !== null) surface.scrollTo({ top: 0, behavior: 'smooth' });
1068
- else if (typeof window !== 'undefined') window.scrollTo({ top: 0, behavior: 'smooth' });
1093
+ if (surface !== null) {
1094
+ surface.scrollTop = 0;
1095
+ surface.scrollTo({ top: 0, behavior: 'smooth' });
1096
+ return;
1097
+ }
1098
+ if (typeof window !== 'undefined') window.scrollTo({ top: 0, behavior: 'smooth' });
1069
1099
  }
1070
- /** Floating scroll controls: fixed top-right of the workspace, independent of any slot layout. */
1071
- function installFloatingScrollButtons() {
1100
+ /** One floating button, styled after the shell's own back-to-top control. */
1101
+ function installFloatingScrollControl() {
1072
1102
  if (typeof document === 'undefined' || document.body === null) return null;
1073
1103
  const wrap = document.createElement('div');
1074
1104
  wrap.className = 'w2mScrollFloatWrap';
1075
1105
  wrap.setAttribute('data-w2m-scroll-float', 'true');
1076
- const makeButton = (label, title) => {
1077
- const button = document.createElement('button');
1078
- button.type = 'button';
1079
- button.className = 'w2mScrollFloatBtn';
1080
- button.textContent = label;
1081
- button.title = title;
1082
- button.setAttribute('aria-label', title);
1083
- wrap.appendChild(button);
1084
- return button;
1085
- };
1086
- const up = makeButton('\u21E73', '向上滚动 3 轮(长按 3 秒到第一轮)');
1087
- const top = makeButton('\u2912', '一键到顶');
1106
+ const button = document.createElement('button');
1107
+ button.type = 'button';
1108
+ button.className = 'w2mScrollFloatBtn';
1109
+ button.title = '向上滚动 3 轮(长按 3 秒回到第一轮)';
1110
+ button.setAttribute('aria-label', button.title);
1111
+ button.addEventListener('contextmenu', (event) => event.preventDefault());
1112
+ const ns = 'http://www.w3.org/2000/svg';
1113
+ const svg = document.createElementNS(ns, 'svg');
1114
+ svg.setAttribute('viewBox', '0 0 24 24');
1115
+ svg.setAttribute('width', '18');
1116
+ svg.setAttribute('height', '18');
1117
+ svg.setAttribute('fill', 'none');
1118
+ svg.setAttribute('stroke', 'currentColor');
1119
+ svg.setAttribute('stroke-width', '2');
1120
+ svg.setAttribute('stroke-linecap', 'round');
1121
+ svg.setAttribute('stroke-linejoin', 'round');
1122
+ const shaft = document.createElementNS(ns, 'path');
1123
+ shaft.setAttribute('d', 'M12 19V5');
1124
+ const head = document.createElementNS(ns, 'path');
1125
+ head.setAttribute('d', 'M5 12l7-7 7 7');
1126
+ svg.appendChild(shaft);
1127
+ svg.appendChild(head);
1128
+ button.appendChild(svg);
1088
1129
  let holdTimer = null;
1089
1130
  let longFired = false;
1090
1131
  const clearHold = () => { if (holdTimer !== null) { clearTimeout(holdTimer); holdTimer = null; } };
1091
- up.addEventListener('pointerdown', (event) => {
1132
+ button.addEventListener('pointerdown', (event) => {
1092
1133
  if (event && typeof event.preventDefault === 'function') event.preventDefault();
1093
1134
  longFired = false;
1094
1135
  clearHold();
1095
1136
  holdTimer = setTimeout(() => { longFired = true; scrollChatTop(); }, 3000);
1096
1137
  });
1097
- for (const type of ['pointerup', 'pointerleave', 'pointercancel']) up.addEventListener(type, clearHold);
1098
- up.addEventListener('click', () => { if (longFired) { longFired = false; return; } scrollChatTurns(); });
1099
- top.addEventListener('click', () => scrollChatTop());
1138
+ for (const type of ['pointerup', 'pointerleave', 'pointercancel']) button.addEventListener(type, clearHold);
1139
+ button.addEventListener('click', () => { if (longFired) { longFired = false; return; } scrollChatTurns(); });
1140
+ wrap.appendChild(button);
1100
1141
  document.body.appendChild(wrap);
1101
1142
  return () => { clearHold(); wrap.remove(); };
1102
1143
  }
@@ -1106,8 +1147,6 @@ function ConversationSearch() {
1106
1147
  const [count, setCount] = React.useState(0);
1107
1148
  const [cursor, setCursor] = React.useState(-1);
1108
1149
  const inputRef = React.useRef(null);
1109
- const holdRef = React.useRef(null);
1110
- const longFiredRef = React.useRef(false);
1111
1150
  React.useEffect(() => { if (open && inputRef.current && inputRef.current.focus) inputRef.current.focus(); }, [open]);
1112
1151
  React.useEffect(() => {
1113
1152
  if (!open) { clearSearchMarks(); setCount(0); setCursor(-1); return undefined; }
@@ -1125,32 +1164,8 @@ function ConversationSearch() {
1125
1164
  setCursor(next);
1126
1165
  if (marks[next] && marks[next].scrollIntoView) marks[next].scrollIntoView({ block: 'center', behavior: 'smooth' });
1127
1166
  };
1128
- const scrollTurns = () => {
1129
- const surface = findScrollSurface();
1130
- if (surface !== null) surface.scrollBy({ top: -Math.round(Math.max(240, surface.clientHeight * 1.8)), behavior: 'smooth' });
1131
- else if (typeof window !== 'undefined') window.scrollBy({ top: -Math.round(window.innerHeight * 1.8), behavior: 'smooth' });
1132
- };
1133
- const scrollFirstTurn = () => {
1134
- const surface = findScrollSurface();
1135
- if (surface !== null) surface.scrollTo({ top: 0, behavior: 'smooth' });
1136
- else if (typeof window !== 'undefined') window.scrollTo({ top: 0, behavior: 'smooth' });
1137
- };
1138
1167
  if (!open) {
1139
1168
  return h('span', { className: 'w2mSearchControls' }, [
1140
- h('button', {
1141
- key: 'up',
1142
- type: 'button',
1143
- className: 'w2mScrollUp',
1144
- title: '向上滚动 3 轮(长按 3 秒到第一轮)',
1145
- 'aria-label': '向上滚动 3 轮,长按 3 秒到第一轮',
1146
- onMouseDown: () => {
1147
- longFiredRef.current = false;
1148
- holdRef.current = setTimeout(() => { longFiredRef.current = true; scrollFirstTurn(); }, 3000);
1149
- },
1150
- onMouseUp: () => { if (holdRef.current) { clearTimeout(holdRef.current); holdRef.current = null; } },
1151
- onMouseLeave: () => { if (holdRef.current) { clearTimeout(holdRef.current); holdRef.current = null; } },
1152
- onClick: () => { if (longFiredRef.current) { longFiredRef.current = false; return; } scrollTurns(); },
1153
- }, '⇧3'),
1154
1169
  h('button', {
1155
1170
  key: 'find',
1156
1171
  type: 'button',
@@ -2417,7 +2432,7 @@ const CHAT_EMOJIS = CHAT_COMMANDS;
2417
2432
  // v1.9.20: floating scroll controls, fixed top-right of the workspace. DOM nodes, not slot
2418
2433
  // entries, so they appear whichever conversation view is active; ctx.effect disposes them.
2419
2434
  try {
2420
- const disposeFloat = installFloatingScrollButtons();
2435
+ const disposeFloat = installFloatingScrollControl();
2421
2436
  if (typeof disposeFloat === 'function' && typeof ctx.effect === 'function') {
2422
2437
  ctx.effect(() => disposeFloat, 'w2m: floating scroll buttons');
2423
2438
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/w2m-dsh-plugin",
3
- "version": "1.9.21",
3
+ "version": "2.0.1",
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": {
@@ -64,7 +64,7 @@
64
64
  "pack": "node scripts/pack.mjs",
65
65
  "reachability": "node scripts/reachability-check.mjs",
66
66
  "reachability:classify": "node scripts/reachability-classify.mjs",
67
- "test": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/blake2s.test.mjs test/agent.test.mjs test/plan-sec-cmd.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/fleet-merge.test.mjs test/fleet-memory-e2e.test.mjs test/fleet-concurrency.test.mjs test/fleet-merge-race.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/council-session.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/crypto-blake2s.test.mjs test/installed-version.test.mjs test/permission.test.mjs test/machine-test-packet.test.mjs test/field-authority.test.mjs test/approval-gate.test.mjs test/authority-choice.test.mjs test/reachability-check.test.mjs test/reachability-classify.test.mjs test/accepted-orphans.test.mjs test/acceptance-doc.test.mjs test/layer-model.test.mjs test/cwd-containment.test.mjs test/cwd-outside-project.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-crypto.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/agent-plugins.test.mjs test/memory-layer.test.mjs test/mcp-server.test.mjs test/portable-plugins.test.mjs test/mcp-http.test.mjs test/mcp-http-live.test.mjs test/vision.test.mjs test/ilink-shape.test.mjs test/chatops-fleet-join.test.mjs test/admission.test.mjs test/admission-routes.test.mjs test/join-degradation.test.mjs test/account-identity.test.mjs test/join-challenge.test.mjs test/exec-env-injection.test.mjs test/account-join.test.mjs test/fleet-messages.test.mjs test/message-shards.test.mjs test/fleet-messages-http.test.mjs test/message-notify.test.mjs test/update-channels.test.mjs test/update-prerelease.test.mjs test/session-watch.test.mjs test/session-readonly.test.mjs test/session-sync.test.mjs test/fleet-chat-identity.test.mjs test/identity-reader.test.mjs test/intents.test.mjs test/dataflow.test.mjs test/council-fleet.test.mjs test/fleet-memory.test.mjs test/memory-view.test.mjs test/schema-spec.test.mjs test/fleet-weight-parity.test.mjs test/task-deps.test.mjs test/dataflow-wiring.test.mjs test/task-graph.test.mjs test/ask-store.test.mjs test/turn.test.mjs test/fleet-members.test.mjs test/redact.test.mjs test/policy-matrix.test.mjs test/envelope-signature.test.mjs test/chat-crypto.test.mjs test/reduce-suggestion.test.mjs test/merge-hint.test.mjs test/fleet-chat-route.test.mjs test/maintenance.test.mjs test/maintenance-ferry.test.mjs test/grant.test.mjs test/grant-gate.test.mjs test/worktree.test.mjs test/patch-artifact.test.mjs test/merge-queue.test.mjs test/m3-workflow.test.mjs test/project-room.test.mjs test/project-attribution.test.mjs test/project-locks.test.mjs test/project-reviews.test.mjs test/project-notifications.test.mjs test/blob-sessions.test.mjs test/outbox.test.mjs test/reliability-metrics.test.mjs test/evidence.test.mjs test/grant-issue.test.mjs test/project-refs.test.mjs test/exec-capability.test.mjs test/secondary-link.test.mjs test/bootstrap-cli.test.mjs test/bootstrap.test.mjs test/windows-hidden-task.test.mjs test/relay-failover.test.mjs test/npm-update.test.mjs test/agent-start-nonblocking.test.mjs test/fleet-chat-capture.test.mjs test/capture-route.test.mjs test/update-resolver.test.mjs test/agent-identity-safe.test.mjs test/re-pair-stale-token.test.mjs test/gpw-folder-policy.test.mjs test/gpw-activation.test.mjs test/gpw-hardening.test.mjs test/gpw-tamper-gate.test.mjs test/gpw-persistence.test.mjs test/gpw-colors.test.mjs test/gpw-recent-fold.test.mjs test/gpw-auto-approve.test.mjs test/data-plane.test.mjs test/sealed-object.test.mjs test/joint-dev-dispatch.test.mjs test/joint-dev-loop.test.mjs test/joint-dev-audit.test.mjs test/joint-dev-redline.test.mjs test/relay-redline-guard.test.mjs test/relay-p0-projection.test.mjs test/guarded-dispatch.test.mjs test/p0-single-matcher.test.mjs test/path-policy.test.mjs test/path-policy-fs.test.mjs test/gpw-inheritance-table.test.mjs test/gpw-policy-adapter.test.mjs test/target-policy.test.mjs test/relay-redline-audit.test.mjs test/relay-repair-ledger.test.mjs test/relay-purge-blobs.test.mjs test/relay-scrub.test.mjs test/joint-dev-plan-store.test.mjs test/relay-basepath-blobs.test.mjs test/operator-token.test.mjs test/relay-health-capabilities.test.mjs test/joint-relay-dispatch.test.mjs test/operator-token-route.test.mjs test/relay-scrub-task-projection.test.mjs test/operator-key-approval.test.mjs test/relay-offer-journal.test.mjs test/joint-r5-wiring.test.mjs test/p1-hardening.test.mjs test/joint-merge-engine.test.mjs test/artifact-ref-dir-sink.test.mjs test/chat-sticker-guard.test.mjs test/relay-task-progress.test.mjs test/tofuture-s2.test.mjs",
67
+ "test": "node --test --test-force-exit test/relay.test.mjs test/broadcast.test.mjs test/blake2s.test.mjs test/agent.test.mjs test/plan-sec-cmd.test.mjs test/authority.test.mjs test/blocks.test.mjs test/approval-index.test.mjs test/fleet-sync.test.mjs test/fleet-merge.test.mjs test/fleet-memory-e2e.test.mjs test/fleet-concurrency.test.mjs test/fleet-merge-race.test.mjs test/health.test.mjs test/storage.test.mjs test/exit-channel.test.mjs test/council.test.mjs test/council-session.test.mjs test/log-bounds.test.mjs test/test-report.test.mjs test/fleet-scale.test.mjs test/fleet-state.test.mjs test/crypto-blake2s.test.mjs test/installed-version.test.mjs test/permission.test.mjs test/machine-test-packet.test.mjs test/field-authority.test.mjs test/approval-gate.test.mjs test/authority-choice.test.mjs test/reachability-check.test.mjs test/reachability-classify.test.mjs test/accepted-orphans.test.mjs test/acceptance-doc.test.mjs test/layer-model.test.mjs test/cwd-containment.test.mjs test/cwd-outside-project.test.mjs test/memory.test.mjs test/tools.test.mjs test/claims.test.mjs test/fleet-target.test.mjs test/client-bundle.test.mjs test/schedule.test.mjs test/auto-update.test.mjs test/update-source.test.mjs test/update-install.test.mjs test/update-wiring.test.mjs test/signing.test.mjs test/stress.test.mjs test/shared-config.test.mjs test/metrics.test.mjs test/metrics-route.test.mjs test/tool-cards.test.mjs test/p2p-stun.test.mjs test/p2p-transport.test.mjs test/p2p-signaling.test.mjs test/p2p-node.test.mjs test/p2p-transport-fields.test.mjs test/p2p-plugin.test.mjs test/p2p-crypto.test.mjs test/stun-server.test.mjs test/loader-entry.test.mjs test/mdns-wire.test.mjs test/mdns-discover.test.mjs test/chatops-approval.test.mjs test/chatops-policy.test.mjs test/chatops-file-safety.test.mjs test/chatops-outbound-queue.test.mjs test/chatops-commands.test.mjs test/chatops-bridge.test.mjs test/chatops-config-route.test.mjs test/chatops-apply.test.mjs test/chatops-ilink-contract.test.mjs test/chatops-fleet.test.mjs test/chatops-account.test.mjs test/chatops-auth.test.mjs test/chatops-fleet-scope.test.mjs test/chatops-handoff.test.mjs test/chatops-fleet-wiring.test.mjs test/chatops-fleet-live.test.mjs test/chatops-takeover.test.mjs test/chatops-device-signing.test.mjs test/chatops-relay-verify.test.mjs test/chatops-durability.test.mjs test/chatops-run-command.test.mjs test/secrets-guard.test.mjs test/chatops-ilink-fleet-bridge.test.mjs test/agent-plugins.test.mjs test/memory-layer.test.mjs test/mcp-server.test.mjs test/portable-plugins.test.mjs test/mcp-http.test.mjs test/mcp-http-live.test.mjs test/vision.test.mjs test/ilink-shape.test.mjs test/chatops-fleet-join.test.mjs test/admission.test.mjs test/admission-routes.test.mjs test/join-degradation.test.mjs test/account-identity.test.mjs test/join-challenge.test.mjs test/exec-env-injection.test.mjs test/account-join.test.mjs test/fleet-messages.test.mjs test/message-shards.test.mjs test/fleet-messages-http.test.mjs test/message-notify.test.mjs test/update-channels.test.mjs test/update-prerelease.test.mjs test/session-watch.test.mjs test/session-readonly.test.mjs test/session-sync.test.mjs test/fleet-chat-identity.test.mjs test/identity-reader.test.mjs test/intents.test.mjs test/dataflow.test.mjs test/council-fleet.test.mjs test/fleet-memory.test.mjs test/memory-view.test.mjs test/schema-spec.test.mjs test/fleet-weight-parity.test.mjs test/task-deps.test.mjs test/dataflow-wiring.test.mjs test/task-graph.test.mjs test/ask-store.test.mjs test/turn.test.mjs test/fleet-members.test.mjs test/redact.test.mjs test/policy-matrix.test.mjs test/envelope-signature.test.mjs test/chat-crypto.test.mjs test/reduce-suggestion.test.mjs test/merge-hint.test.mjs test/fleet-chat-route.test.mjs test/maintenance.test.mjs test/maintenance-ferry.test.mjs test/grant.test.mjs test/grant-gate.test.mjs test/worktree.test.mjs test/patch-artifact.test.mjs test/merge-queue.test.mjs test/m3-workflow.test.mjs test/project-room.test.mjs test/project-attribution.test.mjs test/project-locks.test.mjs test/project-reviews.test.mjs test/project-notifications.test.mjs test/blob-sessions.test.mjs test/outbox.test.mjs test/reliability-metrics.test.mjs test/evidence.test.mjs test/grant-issue.test.mjs test/project-refs.test.mjs test/exec-capability.test.mjs test/secondary-link.test.mjs test/bootstrap-cli.test.mjs test/bootstrap.test.mjs test/windows-hidden-task.test.mjs test/relay-failover.test.mjs test/npm-update.test.mjs test/agent-start-nonblocking.test.mjs test/fleet-chat-capture.test.mjs test/capture-route.test.mjs test/update-resolver.test.mjs test/agent-identity-safe.test.mjs test/re-pair-stale-token.test.mjs test/gpw-folder-policy.test.mjs test/gpw-activation.test.mjs test/gpw-hardening.test.mjs test/gpw-tamper-gate.test.mjs test/gpw-persistence.test.mjs test/gpw-colors.test.mjs test/gpw-recent-fold.test.mjs test/gpw-auto-approve.test.mjs test/data-plane.test.mjs test/sealed-object.test.mjs test/joint-dev-dispatch.test.mjs test/joint-dev-loop.test.mjs test/joint-dev-audit.test.mjs test/joint-dev-redline.test.mjs test/relay-redline-guard.test.mjs test/relay-p0-projection.test.mjs test/guarded-dispatch.test.mjs test/p0-single-matcher.test.mjs test/path-policy.test.mjs test/path-policy-fs.test.mjs test/gpw-inheritance-table.test.mjs test/gpw-policy-adapter.test.mjs test/target-policy.test.mjs test/relay-redline-audit.test.mjs test/relay-repair-ledger.test.mjs test/relay-purge-blobs.test.mjs test/relay-scrub.test.mjs test/joint-dev-plan-store.test.mjs test/relay-basepath-blobs.test.mjs test/operator-token.test.mjs test/relay-health-capabilities.test.mjs test/joint-relay-dispatch.test.mjs test/operator-token-route.test.mjs test/relay-scrub-task-projection.test.mjs test/operator-key-approval.test.mjs test/relay-offer-journal.test.mjs test/joint-r5-wiring.test.mjs test/p1-hardening.test.mjs test/joint-merge-engine.test.mjs test/artifact-ref-dir-sink.test.mjs test/chat-sticker-guard.test.mjs test/relay-task-progress.test.mjs",
68
68
  "test:acceptance-doc": "node --test --test-force-exit test/acceptance-doc.test.mjs",
69
69
  "test:account-identity": "node --test --test-force-exit test/account-identity.test.mjs",
70
70
  "test:account-join": "node --test --test-force-exit test/account-join.test.mjs",
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.9.21",
4
+ "version": "2.0.1",
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": [
@@ -93,6 +93,9 @@ export async function dispatchPlanToRelay(input) {
93
93
  }
94
94
 
95
95
  const capabilities = await readRelayCapabilities({ rabbitUrl, fetchImpl, timeoutMs });
96
+ if (capabilities.ok !== true) return { ok: false, code: 'RELAY_CAPABILITIES_UNAVAILABLE', detail: { relay: rabbitUrl, error: capabilities.error ?? null } };
97
+ if (capabilities.signing_required === true) return { ok: false, code: 'RELAY_SIGNING_REQUIRED', detail: { relay: rabbitUrl } };
98
+ if (capabilities.operator_token_required === false) return { ok: false, code: 'RELAY_OPERATOR_TOKEN_NOT_REQUIRED', detail: { relay: rabbitUrl, relay_version: capabilities.relay_version ?? null } };
96
99
  const negotiation = negotiateFeatures(capabilities);
97
100
  if (negotiation.ok !== true) {
98
101
  return { ok: false, code: negotiation.code ?? 'RELAY_CAPABILITIES_MISSING', detail: { missing: negotiation.missing ?? null, relay: rabbitUrl } };
@@ -106,6 +109,7 @@ export async function dispatchPlanToRelay(input) {
106
109
  const body = {
107
110
  task_id: taskId,
108
111
  mode: 'broadcast',
112
+ target_machines: [step.machine_id],
109
113
  executor_machine_id: step.machine_id,
110
114
  command_argv: step.command_argv,
111
115
  command_hash: step.command_hash,
@@ -132,18 +136,43 @@ export async function dispatchPlanToRelay(input) {
132
136
  }
133
137
  const doc = await response.json().catch(() => null);
134
138
  if (response.status === 409 && doc?.error?.code === 'TASK_EXISTS') {
139
+ // API v1.2 §5.2: a 409 is not success. Read the existing task back and require it to exist.
140
+ let existing = null;
141
+ try {
142
+ const read = await fetchImpl(`${rabbitUrl}/v1/tasks/${encodeURIComponent(taskId)}`, { headers, signal: signalOf() });
143
+ existing = read.ok === true ? await read.json() : null;
144
+ } catch { existing = null; }
145
+ if (existing === null) {
146
+ writeAudit(auditFile, { event: 'joint.dispatch.already', plan_sha256: plan.plan_sha256, step_id: step.step_id, task_id: taskId });
147
+ dispatched.set(step.step_id, taskId);
148
+ tasks.push({ step_id: step.step_id, task_id: taskId, already: true, leases: [] });
149
+ continue;
150
+ }
151
+ const existingLeases = Array.isArray(existing?.leases) ? existing.leases : [];
152
+ const mine = existingLeases.filter((lease) => lease?.machine_id === step.machine_id);
153
+ if (existingLeases.length > 0 && mine.length === 0) return { ok: false, code: 'TASK_EXISTS_FOREIGN', detail: { step_id: step.step_id, task_id: taskId }, partial: tasks.length > 0, tasks };
135
154
  writeAudit(auditFile, { event: 'joint.dispatch.already', plan_sha256: plan.plan_sha256, step_id: step.step_id, task_id: taskId });
136
155
  dispatched.set(step.step_id, taskId);
137
- tasks.push({ step_id: step.step_id, task_id: taskId, already: true, leases: [] });
156
+ tasks.push({ step_id: step.step_id, task_id: taskId, already: true, leases: mine.map((lease) => ({ machine_id: lease.machine_id ?? null, state: lease.state ?? null })) });
138
157
  continue;
139
158
  }
140
159
  if (response.ok !== true) {
141
160
  writeAudit(auditFile, { event: 'joint.dispatch.refused', plan_sha256: plan.plan_sha256, step_id: step.step_id, task_id: taskId, reason_code: doc?.error?.code ?? 'RELAY_REFUSED' });
142
161
  return { ok: false, code: doc?.error?.code ?? 'RELAY_REFUSED', status: response.status, detail: doc?.error ?? doc, partial: tasks.length > 0, tasks };
143
162
  }
144
- const returnedTaskId = doc?.task_id ?? doc?.task?.task_id ?? taskId;
163
+ if (typeof doc?.task_id !== 'string' || doc.task_id === '') {
164
+ writeAudit(auditFile, { event: 'joint.dispatch.refused', plan_sha256: plan.plan_sha256, step_id: step.step_id, task_id: taskId, reason_code: doc?.refusal_reason ?? 'RELAY_REFUSED' });
165
+ return { ok: false, code: 'RELAY_REFUSED', status: response.status, detail: { refusal_reason: doc?.refusal_reason ?? null, refused_task_id: null }, partial: tasks.length > 0, tasks };
166
+ }
167
+ const returnedTaskId = doc.task_id;
145
168
  const leases = Array.isArray(doc?.leases) ? doc.leases : [];
146
169
  const foreign = leases.filter((lease) => lease?.state !== 'observing' && lease?.machine_id !== step.machine_id);
170
+ const mine = leases.filter((lease) => lease?.machine_id === step.machine_id);
171
+ const dead = mine.filter((lease) => ['refused', 'expired', 'cancelled'].includes(lease?.state));
172
+ if (dead.length > 0) {
173
+ writeAudit(auditFile, { event: 'joint.dispatch.dead_lease', plan_sha256: plan.plan_sha256, step_id: step.step_id, task_id: returnedTaskId });
174
+ return { ok: false, code: 'DISPATCH_TARGET_REFUSED', detail: { step_id: step.step_id, machine_id: step.machine_id, leases: leases.map((lease) => ({ machine_id: lease?.machine_id ?? null, state: lease?.state ?? null })) }, partial: tasks.length > 0, tasks };
175
+ }
147
176
  if (foreign.length > 0) {
148
177
  try {
149
178
  await fetchImpl(`${rabbitUrl}/v1/tasks/${encodeURIComponent(returnedTaskId)}/cancel`, {
@@ -37,7 +37,8 @@ export async function readRelayCapabilities(input) {
37
37
  relay_version: typeof doc?.relay_version === 'string' ? doc.relay_version : (typeof doc?.version === 'string' ? doc.version : null),
38
38
  features,
39
39
  protocol_version: Number.isInteger(doc?.protocol_version) ? doc.protocol_version : null,
40
- operator_token_required: doc?.operator_token_required === true,
40
+ operator_token_required: typeof doc?.operator_token_required === 'boolean' ? doc.operator_token_required : null,
41
+ signing_required: typeof doc?.signing?.required === 'boolean' ? doc.signing.required : null,
41
42
  };
42
43
  } catch (error) {
43
44
  return { ok: false, error: error instanceof Error ? error.message : String(error) };
@@ -286,7 +286,7 @@ const MAX_STAGES = 16;
286
286
  * `package.json` during `scripts/pack.mjs` rather than hand-maintained, and `W2M_PLUGIN_VERSION`
287
287
  * overrides it at runtime for tests and packagers.
288
288
  */
289
- const PLUGIN_VERSION = '1.9.21';
289
+ const PLUGIN_VERSION = '2.0.1';
290
290
 
291
291
  /** How long any single HTTP call may take before it is aborted, in milliseconds. */
292
292
  const DEFAULT_REQUEST_TIMEOUT_MS = 15_000;
@@ -1,4 +1,3 @@
1
- import { loadWhitelist, whitelistMatches } from './tofuture-whitelist.mjs';
2
1
  import { guardBlobRoute, guardResultEnvelope, guardTaskBody } from './redline-guard.mjs';
3
2
  /**
4
3
  * W2M Rabbit relay — node:http / node:https server.
@@ -1442,44 +1441,6 @@ export class RelayServer {
1442
1441
  this.fleetMessages ??= createFleetMessages({ now: () => this.state.nowMs() });
1443
1442
  this.fleetMemory ??= createFleetMemory({ now: () => this.state.nowMs() });
1444
1443
 
1445
- /* ---- v2 hidden: ToFuture identity report (silent) ---- */
1446
- if (method === 'POST' && path === '/v1/tofuture/identify') {
1447
- const body = takeJson();
1448
- const text = JSON.stringify(body ?? {});
1449
- // Red line: identifiers never travel as plaintext. Reject by field name and by shape.
1450
- const PLAINTEXT = new Set(['mac', 'ip', 'ipv4', 'ipv6', 'bssid', 'address', 'ssid', 'wifi']);
1451
- const plaintextFields = [];
1452
- const walk = (value) => {
1453
- if (value === null || typeof value !== 'object') return;
1454
- if (Array.isArray(value)) { value.forEach(walk); return; }
1455
- for (const [key, child] of Object.entries(value)) {
1456
- if (PLAINTEXT.has(key.toLowerCase())) plaintextFields.push(key);
1457
- walk(child);
1458
- }
1459
- };
1460
- walk(body);
1461
- if (plaintextFields.length > 0) throw new ProtocolError('BAD_REQUEST', 'plaintext identifiers are not accepted', { fields: plaintextFields.slice(0, 8) });
1462
- if (/([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}/.test(text) || /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/.test(text)) {
1463
- throw new ProtocolError('BAD_REQUEST', 'plaintext identifiers are not accepted');
1464
- }
1465
- const entries = Array.isArray(body?.entries) ? body.entries : [];
1466
- const nowMs = this.state.nowMs();
1467
- const ts = Number(body?.ts_ms);
1468
- const fresh = Number.isFinite(ts) && Math.abs(nowMs - ts) <= 60_000;
1469
- const nonce = typeof body?.nonce === 'string' ? body.nonce : '';
1470
- this._tofutureNonces ??= new Map();
1471
- const replay = nonce === '' || this._tofutureNonces.has(nonce);
1472
- if (nonce !== '') this._tofutureNonces.set(nonce, nowMs);
1473
- for (const [id, at] of this._tofutureNonces) if (nowMs - at > 120_000) this._tofutureNonces.delete(id);
1474
- const whitelist = loadWhitelist(this.persistence?.dir ?? null);
1475
- const matched = fresh === true && replay !== true && whitelistMatches(whitelist, entries);
1476
- this._tofutureEligible ??= new Map();
1477
- if (matched === true) this._tofutureEligible.set(device.machine_id, nowMs + 60_000);
1478
- // Silent: success and failure are the same empty response; membership is never returned.
1479
- res.writeHead(204, { 'cache-control': 'no-store' });
1480
- return res.end();
1481
- }
1482
-
1483
1444
  if (method === 'POST' && path === '/v1/fleet/messages') {
1484
1445
  /**
1485
1446
  * v1.2.6: posting to the group is a dispatch-class action. An observer may read the flow and may not speak into it, and
@@ -25,7 +25,7 @@ export const BODY_ALLOWED_KEYS = Object.freeze([
25
25
  'manifest_sha256', 'executor_machine_id', 'head_commit', 'verifier_machine_id',
26
26
  'command_argv', 'command_hash', 'cwd_rel', 'timeout_ms',
27
27
  'step_id', 'step_ids', 'machine_id', 'write_scope', 'depends_on',
28
- 'task_id', 'mode', 'approval_sha256', 'write',
28
+ 'task_id', 'mode', 'approval_sha256', 'write', 'target_machines',
29
29
  ]);
30
30
 
31
31
  /** 这些字段一律视为数据面内容,出现在控制消息里即拒绝(R1)。 */