dsh-remote-peers 0.3.63 → 0.3.165
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.md +7 -2
- package/README.zh-CN.md +20 -1
- package/index.mjs +1825 -179
- package/lib/client.js +4843 -2523
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -35,9 +35,12 @@ Both machines run this plugin. On the machine you want to reach, the panel shows
|
|
|
35
35
|
|
|
36
36
|
- **Sessions**: every session of the peer, grouped by the peer's workspaces, archived ones pushed to the bottom
|
|
37
37
|
- **Chat**: read history in pages, send a prompt, watch the reply stream in; thinking rows, code blocks, markdown and file cards follow the host app's look
|
|
38
|
+
- **Attachments**: paste files with Ctrl+V or pick them from `+ → 文件`; images arrive as 64×64 thumbnails, every other file as a 240×64 file card. Each draft uploads to the peer as soon as it is picked and is sent with the prompt as a `{ type: 'file', receiptId }` part
|
|
38
39
|
- **Approvals and questions**: approve or answer here; the decision is relayed to the peer
|
|
39
40
|
- **Files**: preview PDF / Word / Excel / PPT / images / text in the right pane; downloads land in one shared local copy, and *Open*, *Download* and *Show in folder* all reuse it
|
|
40
41
|
- **Run state**: a remote session that is still working keeps showing its running state, including after you reopen the panel
|
|
42
|
+
- **Cross-network link**: the *跨域网关* card at the top of the panel joins an EasyTier virtual network, so two machines on different networks can reach each other. Enable it on one machine and send its **connection code** to the other; pasting that code there brings it in, and pasting the other machine's code links back the other way. The core runs with `--no-tun` (no admin rights, no virtual adapter) and is a separate step: download it first (~33 MB into `<stateDir>/easytier/`), then enable — or paste the other side's code to join without creating your own network. Each machine then forwards through a local port derived from the peer's virtual address (`127.0.0.1:37500+` the address's last octet), and a peer joined this way is an ordinary peer record, so sessions, attachments, files and approvals behave exactly as on a LAN. The peer list has no hub and no announcements: every node reads the core's peer table for the network's virtual addresses, derives the plug-in port as `37000 + last octet`, and derives the token from the network secret, so all nodes reach the same answer without telling each other anything.
|
|
43
|
+
- **One link mode at a time**: LAN and cross-network each have their own enable switch, both off on first launch (nothing listens until one is enabled). Only one can be on; whichever is on decides which peers appear in the list, the sidebar, sessions and attachments. Switching turns the other off but keeps its peer records, so switching back restores them.
|
|
41
44
|
|
|
42
45
|
## Security
|
|
43
46
|
|
|
@@ -48,7 +51,7 @@ Two gates, both on the gateway:
|
|
|
48
51
|
| Source CIDR allow-list | private ranges only: `127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `::1/128` |
|
|
49
52
|
| Shared token | `x-dsh-lan-token` header or `Authorization: Bearer`, compared in fixed time |
|
|
50
53
|
|
|
51
|
-
The token is generated on first launch (43 chars) and can be **reset** from the panel; resetting invalidates the old token immediately, and peers that registered this machine elsewhere must be updated. The port is open on the LAN — on Windows, allow it on *Private* networks when the firewall asks.
|
|
54
|
+
The token is generated on first launch (43 chars) and can be **reset** from the panel; resetting invalidates the old token immediately, and peers that registered this machine elsewhere must be updated. Under the cross-network gateway the token is not local: it is derived from the network `secret`, so changing it means changing the secret and rebuilding the whole network — there is no reset there, only a new connection code. Anyone holding the code can derive every node's token: the code *is* the admission ticket. The port is open on the LAN — on Windows, allow it on *Private* networks when the firewall asks.
|
|
52
55
|
|
|
53
56
|
The gateway neither exposes DSH's source nor carries any local credential; the token stays inside the peer's Host process and is never handed to a browser.
|
|
54
57
|
|
|
@@ -63,6 +66,7 @@ Exposed through the gateway (token required):
|
|
|
63
66
|
Local-only routes (the browser talks to its own Host; peer tokens stay there):
|
|
64
67
|
|
|
65
68
|
- `/remote-peers` RPC: `status`, `token/reset`, `peers/list|upsert|remove|ping`, `proxy`, `file/size(s)`, `open-local`, `local/copy`, `download/status|save|cancel`, `diag`
|
|
69
|
+
- `POST /api/remote-peers/upload?id=<peer>&sessionId=<id>[&name=<name>][&mediaType=<type>]` → the raw request body is streamed to the peer's own `/api/session/uploadFileBinary`; returns that route's `{ ok, value: { receiptId, image | file } }`
|
|
66
70
|
- `GET|HEAD /api/remote-peers/file?id=<peer>&path=<absolute path>[&v=<version>][&download=1]`
|
|
67
71
|
- `GET /api/remote-peers/export|markdown|stream|call|diag|vendor|office|present-open|changes`
|
|
68
72
|
|
|
@@ -70,6 +74,7 @@ Local-only routes (the browser talks to its own Host; peer tokens stay there):
|
|
|
70
74
|
|
|
71
75
|
- **LAN only.** No NAT traversal or relay yet; both machines must reach each other directly (same subnet, or a VPN that keeps layer-3 reachability).
|
|
72
76
|
- **The sidebar cannot nest.** DSH's `sidebar.panellist` is a flat list, and `sidebar.workspaces` is a single slot already owned by the host. So the plugin registers one entry per peer and renders the workspace tree inside the session list page.
|
|
77
|
+
- **Attachments stream as bytes.** A picked file leaves the browser as the request body of the local `/api/remote-peers/upload` route and is piped to the peer without base64 expansion, the same path the desktop app takes. Footprint is one in-flight request per file; very large archives still belong to the file *download* path.
|
|
73
78
|
- **Preview only, no editing.** Formats mirror the host's renderers (PDF via pdf.js, Office via the peer's `officeKit`).
|
|
74
79
|
- **No `Trajectory` tab.** It needs event-level call trees, which this plugin does not reconstruct.
|
|
75
80
|
- **`Show in folder` takes about 2 seconds.** Explorer itself takes that long to raise a window, so the button shows a fixed 2-second "Opening…" state instead of polling for the window.
|
|
@@ -83,7 +88,7 @@ npm run probe # headless render smoke for the panel
|
|
|
83
88
|
npm run audit # dead declarations / duplicated blocks in src/client.js
|
|
84
89
|
```
|
|
85
90
|
|
|
86
|
-
Layout: `index.mjs` is the Host face (gateway, routes, local copies); `src/client.js` is the Client face (panel UI); `scripts/build.mjs` bundles the client; `probes/` holds smoke scripts; `vendor/pdfjs` carries the assets the preview serves. Deep implementation notes live in [`docs/internals.zh-CN.md`](docs/internals.zh-CN.md) (Chinese).
|
|
91
|
+
Layout: `index.mjs` is the Host face (gateway, routes, local copies); `src/client.js` is the Client face (panel UI: state, RPC, layout), with `src/theme.js` (style tokens), `src/icons.js` (inline SVG glyphs), `src/preview.js` (PDF/image/Excel preview) and `src/conversation.js` (model, usage and process-label helpers) split out; `scripts/build.mjs` bundles the client; `probes/` holds smoke scripts; `vendor/pdfjs` carries the assets the preview serves. Deep implementation notes live in [`docs/internals.zh-CN.md`](docs/internals.zh-CN.md) (Chinese).
|
|
87
92
|
|
|
88
93
|
## License
|
|
89
94
|
|
package/README.zh-CN.md
CHANGED
|
@@ -38,10 +38,23 @@ dsh plugin --profile desktop remove dsh-remote-peers
|
|
|
38
38
|
|
|
39
39
|
- **会话**:对端的全部会话,按对端工作区分组,已归档的置底
|
|
40
40
|
- **对话**:分页读历史、发消息、流式接收回复;思考行、代码块、Markdown、文件卡片都对齐宿主外观
|
|
41
|
+
- **附件**:`Ctrl+V` 直接粘贴,或从 `+ → 文件` 选;图片成 64×64 缩略图,其余文件成 240×64 文件卡。
|
|
42
|
+
选中即开始上传到对端,发送时随正文带一张 `{ type: 'file', receiptId }` 收据
|
|
41
43
|
- **审批 / 提问**:在本侧批准或作答,决定回传给对端
|
|
42
44
|
- **文件**:右侧预览 PDF / Word / Excel / PPT / 图片 / 文本;下载落进同一份本机副本,
|
|
43
45
|
**打开**、**下载**、**显示文件位置** 共用这份副本
|
|
44
46
|
- **运行态**:对端仍在跑的会话会一直显示运行状态,重开面板后也在
|
|
47
|
+
- **跨域连接**:面板顶部的「跨域网关」用 EasyTier 组一张虚拟网,两端不在同一个局域网也能互连。
|
|
48
|
+
本机启用后把**连接码**发给对端,对端粘贴即接入;对端给的连接码粘进来,则反过来由本机接入对方。
|
|
49
|
+
内核以 `--no-tun` 运行,免管理员、不建虚拟网卡;内核是独立的一步(先「下载内核」约 33MB 到
|
|
50
|
+
`<stateDir>/easytier/`,再「启用」或直接用对方的连接码加入),之后每台机器一个转发口
|
|
51
|
+
(`127.0.0.1:37500+` 虚拟地址末三位的数)直连对方网关,接入的节点就是一条普通对端记录,会话、附件、文件、审批的
|
|
52
|
+
行为与局域网完全一致。
|
|
53
|
+
节点清单没有中心也没有公告:每个节点直接读内核的 peer 表拿到全网虚拟地址,插件端口=
|
|
54
|
+
`37000 + 末段`,口令=`network secret` 派生的固定串,所有节点算出同一套结果,谁都不必通知谁。
|
|
55
|
+
- **连接方式二选一**:局域网与跨域网关各有一个启用开关,初始都不启用(本机不监听)。同一时刻
|
|
56
|
+
只能启用一种;启用哪种,节点清单、左栏入口、会话与附件就只走这种方式下的节点。切换会关掉
|
|
57
|
+
另一种,但它的节点记录保留,切回来即可恢复。
|
|
45
58
|
|
|
46
59
|
## 安全
|
|
47
60
|
|
|
@@ -53,6 +66,8 @@ dsh plugin --profile desktop remove dsh-remote-peers
|
|
|
53
66
|
| 共享密钥 | `x-dsh-lan-token` 头或 `Authorization: Bearer`,固定时间比较 |
|
|
54
67
|
|
|
55
68
|
密钥首次启动自动生成(43 字符),面板里可**重置**;重置后旧密钥立刻失效,别处登记过本机的他端需要重填。
|
|
69
|
+
跨域网关方式下口令不来自本机,而是由网络 `secret` 派生:换口令等于换 secret、等于整张网重来,
|
|
70
|
+
所以那里没有「重置」,只有重新发连接码。拿到连接码的人可以推出全网任何节点的口令——连接码本身就是进网权。
|
|
56
71
|
端口对局域网开放,Windows 弹防火墙提示时请允许**专用网络**。
|
|
57
72
|
|
|
58
73
|
网关不暴露 DSH 源码,也不携带本机任何凭证;密钥只留在对端 Host 进程内,从不下发给浏览器。
|
|
@@ -71,6 +86,8 @@ dsh plugin --profile desktop remove dsh-remote-peers
|
|
|
71
86
|
|
|
72
87
|
- `/remote-peers` RPC:`status`、`token/reset`、`peers/list|upsert|remove|ping`、`proxy`、`file/size(s)`、
|
|
73
88
|
`open-local`、`local/copy`、`download/status|save|cancel`、`diag`
|
|
89
|
+
- `POST /api/remote-peers/upload?id=<peer>&sessionId=<id>[&name=<名字>][&mediaType=<类型>]` →
|
|
90
|
+
请求体原样流给节点自己的 `/api/session/uploadFileBinary`,回那条路由的 `{ ok, value: { receiptId, image | file } }`
|
|
74
91
|
- `GET|HEAD /api/remote-peers/file?id=<peer>&path=<绝对路径>[&v=<版本>][&download=1]`
|
|
75
92
|
- `GET /api/remote-peers/export|markdown|stream|call|diag|vendor|office|present-open|changes`
|
|
76
93
|
|
|
@@ -80,6 +97,8 @@ dsh plugin --profile desktop remove dsh-remote-peers
|
|
|
80
97
|
- **侧栏做不成文件夹。** 宿主的 `sidebar.panellist` 是平铺列表,`sidebar.workspaces` 是单槽且已被宿主占用,
|
|
81
98
|
所以本插件给每个他端注册一条入口,把工作区树放在会话列表页里。
|
|
82
99
|
- **只做预览,不做编辑。** 各格式对齐宿主渲染链(PDF 走 pdf.js,Office 走对端 `officeKit`)。
|
|
100
|
+
- **附件按字节流过去。** 选中的文件直接作为本机 `/api/remote-peers/upload` 的请求体发出,网关原样转给节点,
|
|
101
|
+
不再做 base64 展开,与桌面端同一条路径;占用是每份文件一条在途请求,几百 MB 的大包仍建议走文件**下载**那条路。
|
|
83
102
|
- **没有「轨迹」tab。** 它需要事件级调用树,本插件不重建。
|
|
84
103
|
- **「显示文件位置」固定约 2 秒。** 资源管理器起窗本身就要这么久,按钮固定显示 2 秒「正在打开…」,不再轮询窗口。
|
|
85
104
|
|
|
@@ -92,7 +111,7 @@ npm run probe # 面板的无头渲染冒烟
|
|
|
92
111
|
npm run audit # src/client.js 的死声明 / 重复块检查
|
|
93
112
|
```
|
|
94
113
|
|
|
95
|
-
结构:`index.mjs` 是 Host 面(网关、路由、本机副本);`src/client.js` 是 Client
|
|
114
|
+
结构:`index.mjs` 是 Host 面(网关、路由、本机副本);`src/client.js` 是 Client 面入口(面板 UI 的状态、RPC 与布局),样式令牌、图标字形、预览与语义助手分别拆在 `src/theme.js`、`src/icons.js`、`src/preview.js`、`src/conversation.js`;
|
|
96
115
|
`scripts/build.mjs` 打客户端产物;`probes/` 是冒烟脚本;`vendor/pdfjs` 是预览要用的资源。
|
|
97
116
|
实现细节见 [`docs/internals.zh-CN.md`](docs/internals.zh-CN.md)。
|
|
98
117
|
|