dsh-plugin-mesh 0.5.10 → 0.5.11
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 +12 -0
- package/README.md +12 -0
- package/lib/discovery.js +45 -1
- package/lib/index.js +43 -11
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -123,4 +123,16 @@ The full key list with defaults is in [`llms.txt`](llms.txt#configuration).
|
|
|
123
123
|
| Issues | https://github.com/peng456/dsh-plugin-mesh/issues |
|
|
124
124
|
| Contact | geekstartup@163.com |
|
|
125
125
|
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Sponsors
|
|
129
|
+
|
|
130
|
+
<a href="https://omdsh.dev/"><img src="https://omdsh.dev/assets/logo-orca.png" width="22" height="22" alt="Oh My DSH"></a> **[OMDSH](https://omdsh.dev/)** (Oh My DSH) · *Beyond the default.* · DeepSeek Harness developer community
|
|
131
|
+
|
|
132
|
+
Independent and unofficial; it sponsors the model tokens (compute) for this project. Website <https://omdsh.dev/>
|
|
133
|
+
|
|
134
|
+
Thanks, OMDSH. Sponsorship is support, not a purchase: everything here is free, and sponsorship unlocks no features.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
126
138
|
MIT licensed. Not affiliated with DeepSeek.
|
package/README.md
CHANGED
|
@@ -137,4 +137,16 @@ npm test
|
|
|
137
137
|
|
|
138
138
|
有问题或想提需求:<https://github.com/peng456/dsh-plugin-mesh/issues> · 邮箱 `geekstartup@163.com`
|
|
139
139
|
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 赞助方
|
|
143
|
+
|
|
144
|
+
<a href="https://omdsh.dev/"><img src="https://omdsh.dev/assets/logo-orca.png" width="22" height="22" alt="Oh My DSH"></a> **[OMDSH](https://omdsh.dev/)**(Oh My DSH)· *Beyond the default.* · DeepSeek Harness 开发者社区
|
|
145
|
+
|
|
146
|
+
独立、非官方,为本项目赞助模型 token(算力)。官网 <https://omdsh.dev/>
|
|
147
|
+
|
|
148
|
+
感谢 OMDSH 的支持。赞助是支持,不是购买——本项目全部功能免费,赞助不解锁任何能力。
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
140
152
|
MIT · 与 DeepSeek 官方无隶属关系
|
package/lib/discovery.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* 安全:发现是完全公开的(局域网内谁都能看见谁),这是有意设计 ——
|
|
14
14
|
* 先让你看见机器,再决定要不要和它配对。真正的操作要过 token。
|
|
15
15
|
*/
|
|
16
|
-
import dgram from "node:dgram";
|
|
17
16
|
import { EventEmitter } from "node:events";
|
|
18
17
|
import os from "node:os";
|
|
19
18
|
import { sanitizeCapabilities, isCapabilityStale, summarizeCapabilities, currentCapabilities } from "./capabilities.js";
|
|
@@ -205,6 +204,25 @@ export function peerOnline(peer, now = Date.now(), ttlMs = 20000) {
|
|
|
205
204
|
* "change" —— 对端列表有任何变化(新增/离线/恢复/信息更新)
|
|
206
205
|
* "diagnostic" —— 网络层问题(非致命),参数为字符串
|
|
207
206
|
*/
|
|
207
|
+
/**
|
|
208
|
+
* `node:dgram`, resolved on demand.
|
|
209
|
+
*
|
|
210
|
+
* Multicast announce/listen is this module's only consumer of datagram sockets.
|
|
211
|
+
* The sweep timer, the record table and everything active scan writes all work
|
|
212
|
+
* without it, so a host — or a browser page — that has no `dgram` loses passive
|
|
213
|
+
* discovery and nothing else. The specifier is assembled at runtime so a bundler
|
|
214
|
+
* cannot resolve it ahead of time: in a page it must fail at the call, not at the
|
|
215
|
+
* module loader, or the whole plugin never loads.
|
|
216
|
+
* @returns the module namespace.
|
|
217
|
+
*/
|
|
218
|
+
async function loadDgramModule() {
|
|
219
|
+
const specifier = "node:" + "dgram";
|
|
220
|
+
return await import(/* @vite-ignore */ specifier);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The resolved `node:dgram`, once a host that has it asked for multicast. */
|
|
224
|
+
let dgram;
|
|
225
|
+
|
|
208
226
|
export class MeshDiscovery extends EventEmitter {
|
|
209
227
|
#id;
|
|
210
228
|
#port;
|
|
@@ -369,6 +387,32 @@ export class MeshDiscovery extends EventEmitter {
|
|
|
369
387
|
|
|
370
388
|
if (!multicast) return this;
|
|
371
389
|
|
|
390
|
+
// A page has no datagram sockets, and asking for the module would throw
|
|
391
|
+
// from the loader rather than from here. Say so once and keep the rest of
|
|
392
|
+
// discovery — the sweep, and every record active scan writes — running.
|
|
393
|
+
if (typeof window !== "undefined") {
|
|
394
|
+
this.emit("diagnostic", "multicast discovery is unavailable in a browser page; sweep and active scan still run");
|
|
395
|
+
return this;
|
|
396
|
+
}
|
|
397
|
+
if (dgram !== undefined) {
|
|
398
|
+
this.#startMulticast();
|
|
399
|
+
return this;
|
|
400
|
+
}
|
|
401
|
+
void (async () => {
|
|
402
|
+
try {
|
|
403
|
+
dgram = await loadDgramModule();
|
|
404
|
+
} catch (error) {
|
|
405
|
+
this.emit("diagnostic", `no datagram sockets on this host; passive discovery is off (${error?.message ?? error})`);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
// Between the caller asking and the module arriving, stop() may have run.
|
|
409
|
+
if (this.#started && this.#multicast && this.#socket === null) this.#startMulticast();
|
|
410
|
+
})();
|
|
411
|
+
return this;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Bind the multicast socket and start announcing. */
|
|
415
|
+
#startMulticast() {
|
|
372
416
|
const socket = dgram.createSocket({ type: "udp4", reuseAddr: true });
|
|
373
417
|
this.#socket = socket;
|
|
374
418
|
|
package/lib/index.js
CHANGED
|
@@ -35,7 +35,18 @@ import {
|
|
|
35
35
|
import z from "@deepseek-ai/schemastery";
|
|
36
36
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
37
37
|
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* A compile-time brand: the value it returns is the value it was given.
|
|
40
|
+
*
|
|
41
|
+
* It used to be imported from `@deepseek-ai/dsh-brand`, which is the right place
|
|
42
|
+
* for the *type*. At runtime it is an identity function, and not every dsh line
|
|
43
|
+
* ships it to every target — the browser build pins an older release whose
|
|
44
|
+
* module is empty — so importing it turns a type-level nicety into a hard
|
|
45
|
+
* dependency on a version this plugin does not otherwise care about.
|
|
46
|
+
* @param {string} value - the string.
|
|
47
|
+
* @returns the same string.
|
|
48
|
+
*/
|
|
49
|
+
const brandString = (value) => value;
|
|
39
50
|
import { MeshDiscovery, preferredAddress, lanIPv4Addresses, macForAddress, orderedEndpoints } from "./discovery.js";
|
|
40
51
|
import { candidateAddresses, scanForPeers } from "./scan.js";
|
|
41
52
|
import { machineFingerprint } from "./identity.js";
|
|
@@ -96,7 +107,6 @@ import { resolveTailnetChannels } from "./tsnet/channels.js";
|
|
|
96
107
|
import { tailnetFetch, tailnetOrigin } from "./tsnet/bridge.js";
|
|
97
108
|
import { createWebProxy } from "./web-proxy.js";
|
|
98
109
|
import { createSecretReader } from "./desktop-auth.js";
|
|
99
|
-
import { createSshManager } from "./ssh-host.js";
|
|
100
110
|
import { acceptUpgrade } from "./ws-mini.js";
|
|
101
111
|
import {
|
|
102
112
|
createDesktopWebForwarder,
|
|
@@ -108,7 +118,7 @@ import {
|
|
|
108
118
|
export const name = "dsh-plugin-mesh";
|
|
109
119
|
export const inject = ["tools", "webServer"];
|
|
110
120
|
|
|
111
|
-
const VERSION = "0.5.
|
|
121
|
+
const VERSION = "0.5.11";
|
|
112
122
|
// 诊断用:进程启动时间 + 入口真实路径。磁盘上的版本**不在这里缓存** ——
|
|
113
123
|
// 升级之后进程还跑旧代码,版本号必须现读磁盘才能立刻反映出来(真踩过:
|
|
114
124
|
// 磁盘升到 0.5.1,进程还在 0.5.0,界面显示 0.5.0)。
|
|
@@ -4478,26 +4488,48 @@ function registerUiRoutes(ctx, { discovery, config, identity, inbound, outbound,
|
|
|
4478
4488
|
//
|
|
4479
4489
|
// 入口在设备行(与「访问 DSH Web」同一位置)。会话由本机发起,凭据只存本机;
|
|
4480
4490
|
// 传输走同源 WebSocket(/mesh/api/ssh/ws),所以不需要经过上面对端的 web 转发。
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4491
|
+
// The SSH terminal is the one part of this plugin that cannot exist in a
|
|
4492
|
+
// browser: it needs `crypto.generateKeyPairSync` and a raw socket. Ask for it
|
|
4493
|
+
// by a runtime-visible name so a page gets `undefined` here instead of a
|
|
4494
|
+
// module-loader failure that takes the whole plugin down with it.
|
|
4495
|
+
let ssh;
|
|
4496
|
+
{
|
|
4497
|
+
// Loaded on demand for the same reason the module no longer sits at the top
|
|
4498
|
+
// of this file: RSA key generation and raw sockets do not exist in a page,
|
|
4499
|
+
// and a static import would take the whole plugin down over a feature the
|
|
4500
|
+
// page cannot have anyway. Routes registered below check `ssh` when they
|
|
4501
|
+
// run, so settling a moment later is fine.
|
|
4502
|
+
const specifier = "./ssh-host.js";
|
|
4503
|
+
import(/* @vite-ignore */ specifier).then((module) => {
|
|
4504
|
+
ssh = module.createSshManager({
|
|
4505
|
+
stateDir: stateDir(),
|
|
4506
|
+
credentialsPath: join(stateDir(), "ssh-credentials.json"),
|
|
4507
|
+
log,
|
|
4508
|
+
warn,
|
|
4509
|
+
});
|
|
4510
|
+
ctx.effect(() => () => ssh?.closeAll());
|
|
4511
|
+
}).catch((error) => {
|
|
4512
|
+
warn(`SSH 终端不可用(${error?.message ?? error});其余 mesh 功能不受影响`);
|
|
4513
|
+
});
|
|
4514
|
+
}
|
|
4488
4515
|
|
|
4489
4516
|
post("/mesh/api/ssh/known", async (req, res) => {
|
|
4490
4517
|
const body = await readJson(req);
|
|
4491
4518
|
const machine = String(body?.machine ?? "").trim();
|
|
4492
4519
|
// 只回用户名与"是否已部署密钥",不回密码:密码没有再穿过一次网络的理由
|
|
4520
|
+
if (ssh === undefined) return send(res, 503, { ok: false, error: "SSH 终端在这个环境里不可用" });
|
|
4493
4521
|
const info = ssh.describe(machine);
|
|
4494
4522
|
return send(res, 200, { ok: true, username: info.username, hasKey: info.hasKey, saved: !!info.username });
|
|
4495
4523
|
});
|
|
4496
4524
|
|
|
4497
|
-
post("/mesh/api/ssh/sessions", (_req, res) => send(res, 200, { ok: true, sessions: ssh
|
|
4525
|
+
post("/mesh/api/ssh/sessions", (_req, res) => send(res, 200, { ok: true, sessions: ssh?.list() ?? [] }));
|
|
4498
4526
|
|
|
4499
4527
|
// 一条 upgrade 路由承载所有终端(按会话 id 多路复用)
|
|
4500
4528
|
const sshUpgrade = (req, socket, head) => {
|
|
4529
|
+
if (ssh === undefined) {
|
|
4530
|
+
try { socket.end("HTTP/1.1 503 Service Unavailable\r\nconnection: close\r\n\r\n"); } catch { /* 已断 */ }
|
|
4531
|
+
return;
|
|
4532
|
+
}
|
|
4501
4533
|
const chan = acceptUpgrade(req, socket, head, {
|
|
4502
4534
|
onMessage: async (raw) => {
|
|
4503
4535
|
let msg;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-mesh",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "把跑不完的活交给另一台电脑;跑完,结果回到你面前。两台装了 DSH 的电脑各装一次,自动互相发现,任务派过去由对端的 agent 执行,结果派回来。Hand a long task to another machine: your DSH instances find each other, the peer runs it, and the result comes back. No pairing codes, no IPs, no Tailscale client.",
|
|
6
6
|
"license": "MIT",
|