dsh-plugin-mesh 0.5.3 → 0.5.5
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/AGENTS.md +7 -4
- package/README.md +98 -2
- package/client/client.js +685 -122
- package/lib/_selftest-reply-route.mjs +80 -2
- package/lib/_selftest-switch.mjs +142 -0
- package/lib/_selftest-tsnet.mjs +258 -1
- package/lib/_selftest-workbench.mjs +289 -0
- package/lib/discovery.js +89 -18
- package/lib/index.js +1128 -253
- package/lib/switch.js +110 -0
- package/lib/tsnet/channels.js +72 -0
- package/lib/tsnet/manager.js +316 -51
- package/llms.txt +56 -10
- package/package.json +5 -4
- package/scripts/check-tarball.mjs +1 -0
package/llms.txt
CHANGED
|
@@ -26,7 +26,7 @@ Verify after restart: `GET http://127.0.0.1:45917/mesh/v1/health` returns JSON c
|
|
|
26
26
|
|
|
27
27
|
- Sends a JSON heartbeat to UDP multicast `239.255.42.99:45892` every `announceIntervalMs` (default 5000 ms) and listens on the same group.
|
|
28
28
|
- Serves a small HTTP peer API on TCP port 45917 (configurable via `port`).
|
|
29
|
-
- Optionally starts
|
|
29
|
+
- Optionally starts bundled Go sidecars, each running a userspace Tailscale node (tsnet) for one tailnet channel. Multiple channels can run at once: one machine identity, several reachability paths. No TUN device is created, so the host cannot route to `100.x.y.z`; all tailnet traffic is proxied through the matching sidecar. The binary is downloaded per-platform on first use and verified against checksums pinned in the plugin source.
|
|
30
30
|
- Auto-creates an agent session on the receiving machine when a task arrives, then routes that task to a new or reused session.
|
|
31
31
|
- Reports a structured `osInfo` card entry (host) and a `systems[]` array: host first, then environments such as WSL distros on Windows (`kind: "wsl"`, Linux `platform`, distro name/version). Older peers only send `os`, and the UI falls back to parsing it; purely display data, at most 4 systems.
|
|
32
32
|
- On Windows, probes runtimes inside **running** WSL distros (`wsl.exe -d <name> -e sh -lc …`) and reports them as `capabilities.wsl[]`; stopped distros are never started just to probe. Host and WSL runtimes are displayed separately.
|
|
@@ -39,6 +39,7 @@ Verify after restart: `GET http://127.0.0.1:45917/mesh/v1/health` returns JSON c
|
|
|
39
39
|
| `mesh_scan` | none | Actively scan the local subnet for mesh peers. Use when multicast is blocked. |
|
|
40
40
|
| `mesh_run` | `peer: string` (required), `task: string` (required), `thread?: string`, `noWake?: boolean`, `newSession?: boolean`, `workspace?: string` | Dispatch a task to another machine. Asynchronous — a successful call means "accepted", not "done". |
|
|
41
41
|
| `mesh_tasks` | none | Show recently received and sent mesh tasks. |
|
|
42
|
+
| `mesh_switch` | `scope: "all" \| "lan" \| "internet"` (required), `action?: "off" \| "on"` | One-click kill switch. `off` is the default action. |
|
|
42
43
|
|
|
43
44
|
`peer` accepts a machine name, an instance id, or `ip:port`. **Do not pass `machine/user`** — `from` fields look like `machine/user`, but the peer key is the machine name only.
|
|
44
45
|
|
|
@@ -46,6 +47,44 @@ Reuse the same `thread` value for the same piece of work: the receiving side reu
|
|
|
46
47
|
|
|
47
48
|
`newSession: true` forces a fresh session while keeping the same conversation key (i.e. it is still the same conversation, with a clean context).
|
|
48
49
|
|
|
50
|
+
## Kill switch (one-click shutdown)
|
|
51
|
+
|
|
52
|
+
Three scopes, available as the **一键关闭** pills on the home overview card, as the
|
|
53
|
+
detailed **连接 → 一键关闭** section of the Mesh panel, and as the `mesh_switch` tool
|
|
54
|
+
(`POST /mesh/api/switch` with `{scope, off}`):
|
|
55
|
+
|
|
56
|
+
| Scope | Effect |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `all` | LAN and internet both off: no multicast, no subnet scan, no inbound tasks, all tailnet sidecars stopped |
|
|
59
|
+
| `lan` | Stops multicast announcements, subnet scan and keepalive pings; the peer HTTP port is rebound from `0.0.0.0` to `127.0.0.1` so nothing on the LAN can connect. Internet channels keep working |
|
|
60
|
+
| `internet` | Stops every tailnet sidecar. Channel config and auth keys are kept and resume on reopen |
|
|
61
|
+
|
|
62
|
+
- **Immediate, and it survives a restart.** The desired state lives in
|
|
63
|
+
`<profile>/mesh/state.json` under `shutdown` (`{lan, internet, at, by}`, `true` = off),
|
|
64
|
+
not in the plugin config. `enabled: false` in config is a different thing: it removes
|
|
65
|
+
the plugin at load time, including the panel, so it cannot be undone from the UI.
|
|
66
|
+
- The Mesh panel and `/mesh/api/*` stay available while everything is off — otherwise
|
|
67
|
+
"one-click off" would lock you out of turning it back on.
|
|
68
|
+
- `/mesh/api/state` reports `switch.lan|internet.{off, active, bind, port, note}`:
|
|
69
|
+
`off` is the requested state, `active` the real one. A failed rebind shows up as a
|
|
70
|
+
non-empty `note` instead of silently looking closed.
|
|
71
|
+
- While closed, outbound dispatch, `mesh_scan`, and the peer HTTP API (including
|
|
72
|
+
`/mesh/v1/health`) answer with an explicit "closed" error (HTTP 503/409), never with
|
|
73
|
+
a generic "unreachable" — "no answer" must not be mistaken for "not there".
|
|
74
|
+
|
|
75
|
+
## Tailnet stalls are reported, not hidden
|
|
76
|
+
|
|
77
|
+
A sidecar that cannot reach the control plane keeps retrying, and `srv.Up()` never
|
|
78
|
+
returns. Rather than showing "starting" forever, the host marks the channel as
|
|
79
|
+
**启动受阻** (`node.stalled`, `node.stalledReason`, `node.stalledHint`) once
|
|
80
|
+
`TSNET_STALL_MS` (75 s) passes with no tailnet address and no auth URL, taking the
|
|
81
|
+
reason from the sidecar's own `health(warnable=login-state)` / `Received error`
|
|
82
|
+
diagnostics. The panel shows the reason plus an actionable hint and turns the
|
|
83
|
+
button into 重试连接; `switch.internet.stalled` and a `note` carry the same fact to
|
|
84
|
+
the kill-switch section. Most common cause on a machine with a local proxy: the
|
|
85
|
+
sidecar dials raw TCP/UDP, so an "HTTP clients only" proxy setting does not cover
|
|
86
|
+
it (`register request: … context deadline exceeded`).
|
|
87
|
+
|
|
49
88
|
## Configuration
|
|
50
89
|
|
|
51
90
|
Override by id in the profile's `cordis.patch.yml`:
|
|
@@ -77,10 +116,11 @@ Override by id in the profile's `cordis.patch.yml`:
|
|
|
77
116
|
| `agentPreset` | string | `"standard"` | Agent preset for auto-created sessions |
|
|
78
117
|
| `permissionPreset` | string | `"workspace-write"` | Permission preset for auto-created sessions |
|
|
79
118
|
| `workspaceRoot` | string | `""` | |
|
|
80
|
-
| `
|
|
81
|
-
| `
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
119
|
+
| `tsnetChannels` | array | `[]` | Multi-tailnet channels: `{id, label, authKey, controlUrl, hostname, enabled}`. A non-empty list pins the channel set (UI read-only) and wins over the legacy single-channel fields. `id` is the stable sidecar directory / tailnet device identity — always give it explicitly when hand-editing; renaming `label` alone derives a new id and therefore registers a new device |
|
|
120
|
+
| `tsnetEnabled` | boolean | `false` | Legacy single-channel switch; only used when `tsnetChannels` is empty |
|
|
121
|
+
| `tsnetAuthKey` | string | `""` | Legacy single channel. Tailscale auth key; must be reusable |
|
|
122
|
+
| `tsnetControlUrl` | string | `""` | Legacy single channel |
|
|
123
|
+
| `tsnetHostname` | string | `""` | Legacy single channel. The plugin prefixes `dsh-`; do not include it yourself |
|
|
84
124
|
| `tsnetPermissionPreset` | string | `""` | Empty = same as `permissionPreset` |
|
|
85
125
|
| `maxWakesPerThread` | natural | `30` | Per-thread wake cap per window |
|
|
86
126
|
| `threadWindowMs` | natural | `3600000` | Window for the cap above |
|
|
@@ -95,10 +135,16 @@ if you are not signed in yet. The key **must be Reusable**; single-use keys fail
|
|
|
95
135
|
with `invalid key` on the next start. If device approval is enabled in the tailnet,
|
|
96
136
|
tick Pre-approved as well.
|
|
97
137
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
never
|
|
101
|
-
to hunt for it.
|
|
138
|
+
Add a channel in the Mesh panel (name + key, optionally a Headscale control URL), or
|
|
139
|
+
set `tsnetChannels` in config. Keys pasted in the UI are stored in
|
|
140
|
+
`~/.dsh/mesh/state.json` (mode 0600) and never need re-entry. The plugin's UI links to
|
|
141
|
+
the key page directly; do not tell users to hunt for it.
|
|
142
|
+
|
|
143
|
+
One machine can join several tailnets at once. Each channel gets its own sidecar and
|
|
144
|
+
its own state directory; the mesh device identity stays the same, so peers see one
|
|
145
|
+
machine with several tailnet endpoints. Endpoint health is tracked per channel: one
|
|
146
|
+
tailnet going down neither takes the device offline nor affects the other channels.
|
|
147
|
+
Outbound dispatch tries LAN first, then each tailnet channel in order.
|
|
102
148
|
|
|
103
149
|
## Network and security facts
|
|
104
150
|
|
|
@@ -119,7 +165,7 @@ to hunt for it.
|
|
|
119
165
|
|
|
120
166
|
```bash
|
|
121
167
|
npm run check # version consistency + TDZ scan + syntax + loadability
|
|
122
|
-
npm test # = check +
|
|
168
|
+
npm test # = check + regression suites (~310 assertions, network-free)
|
|
123
169
|
npm run selftest:caps # capability collection: sanitising, GPU parsing, retries, claim rules
|
|
124
170
|
npm run selftest:client # client bundle rendering without a browser
|
|
125
171
|
npm run selftest:prompt # task prompt generation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-mesh",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "DSH Mesh:局域网自动发现同网段的 DSH 实例、显示每台机器上报的能力,并双向派发任务;可用内置的用户态 Tailscale 节点跨互联网组网。Discovers other DSH instances on the LAN, shows the capabilities each one reports, and dispatches tasks between machines in both directions, with an optional userspace Tailscale node for links across networks.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"selftest:layout": "node lib/_selftest-layout.mjs",
|
|
67
67
|
"selftest:diagnostics": "node lib/_selftest-diagnostics.mjs",
|
|
68
68
|
"selftest:osinfo": "node lib/_selftest-osinfo.mjs",
|
|
69
|
-
"test": "npm run check && npm run selftest && npm run selftest:prompt && npm run selftest:pairing && npm run selftest:client && npm run selftest:caps && npm run selftest:release && npm run selftest:reply && npm run selftest:reasoning && npm run selftest:resume && npm run selftest:persist && npm run selftest:layout && npm run selftest:diagnostics && npm run selftest:osinfo",
|
|
70
|
-
"check": "node scripts/check-version.mjs && node scripts/check-tdz.mjs && node --check lib/index.js && node --check lib/layout.js && node --check lib/discovery.js && node --check lib/conversation.js && node --check lib/identity.js && node --check lib/capabilities.js && node --check lib/prompt.js && node --check lib/pairing.js && node --check lib/scan.js && node --check lib/tsnet/download.js && node --check lib/tsnet/manager.js && node --check lib/tsnet/bridge.js && node --check client/client.js && node --check scripts/release-plan.mjs && npm run check:loadable && npm run check:docs",
|
|
69
|
+
"test": "npm run check && npm run selftest && npm run selftest:prompt && npm run selftest:pairing && npm run selftest:switch && npm run selftest:client && npm run selftest:caps && npm run selftest:release && npm run selftest:reply && npm run selftest:reasoning && npm run selftest:resume && npm run selftest:persist && npm run selftest:layout && npm run selftest:diagnostics && npm run selftest:osinfo",
|
|
70
|
+
"check": "node scripts/check-version.mjs && node scripts/check-tdz.mjs && node --check lib/index.js && node --check lib/layout.js && node --check lib/discovery.js && node --check lib/conversation.js && node --check lib/identity.js && node --check lib/capabilities.js && node --check lib/prompt.js && node --check lib/pairing.js && node --check lib/switch.js && node --check lib/scan.js && node --check lib/tsnet/download.js && node --check lib/tsnet/manager.js && node --check lib/tsnet/bridge.js && node --check lib/tsnet/channels.js && node --check client/client.js && node --check scripts/release-plan.mjs && npm run check:loadable && npm run check:docs",
|
|
71
71
|
"build:sidecar": "bash scripts/build-sidecar.sh",
|
|
72
72
|
"verify:mirror": "node scripts/verify-lan-mirror.mjs",
|
|
73
73
|
"release:plan": "node scripts/release-plan.mjs",
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
"check:scope": "python3 tools/scopecheck.py lib/index.js",
|
|
78
78
|
"prepublishOnly": "npm test && node scripts/check-tarball.mjs",
|
|
79
79
|
"check:docs": "node scripts/sync-llms.mjs",
|
|
80
|
-
"selftest:pairing": "node lib/_selftest-pairing.mjs"
|
|
80
|
+
"selftest:pairing": "node lib/_selftest-pairing.mjs",
|
|
81
|
+
"selftest:switch": "node lib/_selftest-switch.mjs"
|
|
81
82
|
},
|
|
82
83
|
"publishConfig": {
|
|
83
84
|
"registry": "https://registry.npmjs.org/",
|