dsh-linked-workspace 0.16.0 → 0.17.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  English · [简体中文](CHANGELOG.zh.md)
4
4
 
5
+ ## 0.17.0 — 2026-11-19
6
+
7
+ - New `hosts.exec`: let the model run **one** non-interactive command on the remote host (builds, tests, logs) instead of composing `ssh`. Off by default and gated three ways: the `execEnabled` switch, the host allow-list `execHostIds`, and the optional workspace allow-list `execWorkspaceIds` (empty means no restriction). Refusals are audited too.
8
+ - Every attempt is written to `$DSH_HOME/linked-workspace/exec-audit.jsonl`: command, `cwd`, exit code, duration, the first 4 KB of output and any refusal reason; rotated to `.1` past 5 MB. `meta.info` returns that path and the settings block can open it.
9
+ - Output and time are bounded: each stream is clipped to `execMaxOutputChars` (200000 by default, head+tail, flagged `truncated`), timeouts follow `execTimeoutMs` (60 s by default, 600 s per call at most) and surface as `EXEC_TIMEOUT`; `cwd` may not escape the workspace root.
10
+ - `linked_workspace` gained an `exec` action (`command` up to 8000 characters, optional `cwd` and `timeout_ms`) and its prompt now prefers it over hand-written `ssh`. The settings page has a “Remote command execution” block (switch, both allow-lists, timeout/output caps, open audit log).
11
+ - Host API revision is now `apiRevision: 3`: a Host still running older code shows the “restart DSH” banner above the tree.
12
+
13
+ ## 0.16.1 — 2026-11-19
14
+
15
+ - The hover card's connection state now follows reality in both directions: the
16
+ page polls the new `hosts.status` (memory only, no dialling) every 6 seconds
17
+ and repaints just that one line, even while the card is open, so a host that
18
+ drops shows "connection lost" within seconds and one that recovers goes back
19
+ to "connected" without a reload.
20
+ - A missing remote folder is no longer reported as a dead connection: `remote_workspaces.test`
21
+ returns `exists: false` and leaves the host alone, so checking a workspace
22
+ whose directory was renamed elsewhere no longer turns every other workspace on
23
+ that host red.
24
+ - A recorded failure decays after 60 seconds (`STATUS_TTL_MS`) instead of
25
+ sticking forever: an error nobody has re-checked reads as "not connected",
26
+ and the next successful call sets the state again.
27
+ - HTML preview is no longer blocked by the editor's 2 MB ceiling: it reads with `preview`, which raises the cap to the 8 MB read cap, so a 7 MB plotly page opens; only files above 8 MB show "download it to the default folder and open it in a browser", and the doubled "无法预览网页:无法预览网页" wording is gone.
28
+ - HTML preview now uses `sandbox="allow-scripts"`: the page's own scripts run in a separate opaque origin (charts are no longer blank) and still cannot reach the DSH UI, host storage or tabs; the status chip reads "Sandboxed preview (scripts run, no access to the DSH UI)".
29
+
5
30
  ## 0.16.0 — 2026-11-16
6
31
 
7
32
  - The workspace root no longer offers “Change permissions”, and the Host rejects it too: a stray 644 on the root makes the whole workspace look empty.
package/README.en.md CHANGED
@@ -57,6 +57,8 @@ The plugin takes over the DSH sidebar/hero directory-selection hole; the dialog
57
57
  3. **Remote workspace**: SSH host + remote directory + workspace name; the placeholder directory becomes a DSH workspace and sessions run on the server.
58
58
 
59
59
  > Linked workspace rows no longer carry a `⇄` title prefix: a scoped stylesheet keyed on `data-row-key` swaps the host folder glyph for the workspace's own icon — two interlocking links for a linked workspace, a display with an outbound arrow for a remote workspace (normal local workspaces are untouched). When the SSH connection drops the row icon turns red, and the host's hover card gains one line under the name combining the SSH host with its live state (`RTX-PRO-6000-1 · Connected`, turning red with “Connection lost” once the link drops); a remote workspace shows the remote directory, a linked one shows both the remote and local directories. This is the only DOM-level adaptation of the host row; if DSH changes the row structure the selector stops matching and the original folder icon returns, with no other breakage.
60
+ >
61
+ > That state follows the real connection in both directions: the page asks the host for every host's state once every 6 seconds (memory only, it never dials), and only repaints that one line when the value actually changed — so a host that drops shows “Connection lost” within seconds while the card stays open, and one that recovers goes back to “Connected” without a reload. A single failure only describes that moment: an error nobody has re-checked decays to “Not connected” after 60 seconds, and “Test connection” finding a missing remote directory is no longer treated as a dead link, so it cannot paint the other workspaces on the same host red.
60
62
 
61
63
  ### Sidebar: “Linked Workspace Directory”
62
64
 
@@ -77,7 +79,7 @@ hover it for the total size and the used percentage.
77
79
  - Coloured file-type icons (JS/TS/Python/JSON/Markdown/Shell/YAML/images/archives/config files…).
78
80
  - **Tabs and editor**: up to 12 tabs, local and remote files share the same editor; line numbers, syntax highlighting (overlay), theme colours, `Ctrl/Cmd+S`, conflict prompt (reload / force save), read-only protection for binary and >2 MB files; the status bar shows encoding, line endings, line count and file size.
79
81
  - **Find and replace**: `Ctrl/Cmd + F` opens an in-editor bar with a case-sensitive toggle, previous/next, a match counter, replace and replace all. Above 5000 matches the counter shows `5000+` while replace-all still edits the whole document; `Esc` closes it from the replace field too. The Markdown document panel has its own read-only find (`Ctrl+F`, counter, next/previous).
80
- - **Image, CSV and HTML previews**: PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG render in the content panel (up to 24 MB) with zoom buttons, `Ctrl/Cmd + wheel`, fit-to-window and 1:1; CSV/TSV open as a table with a Table/Source toggle (the source view stays editable), capped at 1000 rows × 80 columns. HTML/HTM render in a sandboxed iframe with scripts disabled; Markdown previews strip scripts, event attributes and dangerous links.
82
+ - **Image, CSV and HTML previews**: PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG render in the content panel (up to 24 MB) with zoom buttons, `Ctrl/Cmd + wheel`, fit-to-window and 1:1; CSV/TSV open as a table with a Table/Source toggle (the source view stays editable), capped at 1000 rows × 80 columns. HTML/HTM render in a sandboxed iframe whose scripts run in an opaque origin (charts draw, but the frame cannot reach the DSH UI or its storage); the cap is 8 MB, and beyond that the panel tells you to download the file and open it in a browser. Markdown previews strip scripts, event attributes and dangerous links.
81
83
  - **Shortcuts**: `Ctrl/Cmd+S` save, `Ctrl/Cmd+W` close tab (prompting when dirty), `Ctrl+Tab` / `Shift+Ctrl+Tab` cycle tabs, `Ctrl/Cmd+B` toggle the directory panel, `Ctrl/Cmd+Shift+F` file search.
82
84
  - **Auto save**: Settings → Linked workspaces → “Editor behaviour”; saves about one second after typing stops. With it off, use `Ctrl/Cmd+S`; unsaved changes trigger a confirmation before the page unloads.
83
85
 
@@ -110,11 +112,21 @@ Appears automatically for sessions that belong to a remote workspace (and can be
110
112
 
111
113
  | Tool | Purpose |
112
114
  | --- | --- |
113
- | `linked_workspace` | `list`, `info`, `list_dir`, `read`, `write`, `replace`, `stat`, `mkdir`, `rename`, `delete`, `sync`; paths are relative to the remote root, writes are atomic, `if_modified_since` provides optimistic concurrency. Works for both linked and remote workspaces (`sync` only applies to a linked workspace with the mirror on) |
115
+ | `linked_workspace` | `list`, `info`, `list_dir`, `read`, `write`, `replace`, `stat`, `mkdir`, `rename`, `delete`, `sync`, `exec`; paths are relative to the remote root, writes are atomic, `if_modified_since` provides optimistic concurrency. Works for both linked and remote workspaces (`sync` only applies to a linked workspace with the mirror on) |
114
116
  | `linked_skills` | `list` / `read` local skills (`~/.dsh/skills`, `~/.agents/skills`, `<local>/.dsh/skills`, `<local>/.agents/skills`) |
115
117
 
116
118
  The workspace resolves automatically when the session cwd falls inside a linked workspace or a remote workspace placeholder; use the `workspace` argument (id, local/placeholder path or name) across workspaces. The remote server only needs SSH — no plugin or Python installation.
117
119
 
120
+ ### Remote command execution (0.17.0, off by default)
121
+
122
+ `exec` lets the model run **one non-interactive command** on the remote host (builds, tests, logs) instead of composing `ssh` itself. It is off unless three things line up:
123
+
124
+ 1. the `execEnabled` switch under Settings → Linked workspaces → “Remote command execution”;
125
+ 2. the host is in the **host allow-list** `execHostIds`;
126
+ 3. if the optional **workspace allow-list** `execWorkspaceIds` is filled in, the current workspace must be listed (an empty list means “no restriction”).
127
+
128
+ Every attempt — including refused ones — appends a line to `$DSH_HOME/linked-workspace/exec-audit.jsonl` (command, exit code, duration, first 4 KB of output, refusal reason), rotated to `.1` past 5 MB; the settings block has an “Open audit log” button. Output is clipped per stream to `execMaxOutputChars` (200000 by default), timeouts come from `execTimeoutMs` (60 s by default, 600 s per call at most), and `cwd` may not escape the workspace root.
129
+
118
130
  ### Running icon / local skills
119
131
 
120
132
  - While a linked workspace has a running session, its link icon turns **blue** (refreshed about every 5 seconds).
@@ -188,7 +200,8 @@ The npm package is `dsh-linked-workspace`; released versions can also be install
188
200
  - Remote workspaces and direct file APIs are confined to the configured remote root; linked-workspace tools are confined to the remote root, and local writes to the local root.
189
201
  - Single-file saves are capped at 8 MB; mirror sync runs in the background (500 files / 50 MB by default, skipping oversized files), excludes `.git`/`node_modules`/caches, uses a 30 s per-file timeout and never blocks an HTTP request. “Transfer” and “Download to default folder” handle at most 150 files / 15 MB per run and report partial transfers.
190
202
  - The page HTTP API accepts loopback same-origin requests only (remote deployments fall back to the DSH `connection` service's Host/Origin authentication).
191
- - Previews do not execute scripts: HTML uses a `sandbox=""` iframe; Markdown/document previews strip scripts, inline styles, event attributes and `javascript:`/`vbscript:` links, keeping safe links and image `data:` URLs.
203
+ - HTML previews run inside a `sandbox="allow-scripts"` iframe: the page's own scripts execute (so plotly-style charts actually draw) but in a separate opaque origin that cannot reach the DSH UI, host storage or tabs. Markdown/document previews still strip scripts, inline styles, event attributes and `javascript:`/`vbscript:` links, keeping safe links and image `data:` URLs.
204
+ - Remote command execution is off by default and, once enabled, still limited by the host allow-list (plus the optional workspace allow-list). Every attempt is audited, output is length-capped, commands have a timeout, and `cwd` cannot escape the workspace root.
192
205
 
193
206
  ## FAQ
194
207
 
package/README.md CHANGED
@@ -57,6 +57,8 @@
57
57
  3. **远程工作区**:SSH 主机 + 远端目录 + 工作区名称,创建后占位目录成为 DSH 工作区,会话直接跑在远端。
58
58
 
59
59
  > 左侧工作区行不再带 `⇄` 标题前缀:插件用一份按 `data-row-key` 定位的样式表,把宿主文件夹图标换成工作区自己的图标——联动工作区是**双链环**,远程工作区是**显示器 + 出链箭头**,普通本地工作区不受影响。SSH 连接断开时该行的图标会变红;把鼠标停在行上,宿主那张悬停信息卡里名字下面会多出一行「SSH 主机 · 连接状态」(形如 `RTX-PRO-6000-1 · 已连接`,掉线后变红并显示「连接已断开」);远程工作区显示远端目录、联动工作区同时显示远端与本地目录。这是对宿主行结构的唯一 DOM 级适配;如果 DSH 以后更改行结构,选择器会自然失配并回退到原来的文件夹图标,不破坏其他功能。
60
+ >
61
+ > 这一行状态是**跟着实际连通性走的**:页面每 6 秒向宿主取一次各主机的连接状态(只读内存、不发起新连接),只有状态真的变了才重绘那一行,卡片开着时也会即时更新——主机掉线几秒内变「连接已断开」,恢复后自动回到「已连接」,不用刷新页面。一次失败只代表当时:没人再验证的旧错误 60 秒后降级为「未连接」;「测试连接」发现远端目录不存在也不会被当成断连,不会把同一台主机上的其它工作区一起标红。
60
62
 
61
63
  ### 右侧栏「联动工作区目录」
62
64
 
@@ -76,7 +78,7 @@
76
78
  - 不同文件类型使用不同彩色图标(JS/TS/Python/JSON/Markdown/Shell/YAML/图片/压缩包/配置文件等)。
77
79
  - **标签与编辑器**:最多同时打开 12 个标签,本地与远端文件共用内部编辑器;行号、语法高亮(叠层渲染)、主题配色、`Ctrl/Cmd+S` 保存、冲突提示(重新加载/强制保存)、二进制与 >2 MB 文件只读保护;状态栏显示编码、换行符、行数与文件大小。
78
80
  - **查找/替换**:编辑器内 `Ctrl/Cmd + F` 打开查找条,支持区分大小写、上一个/下一个、命中计数、替换与全部替换;命中超过 5000 处时计数显示 `5000+`,全部替换仍作用于全文。替换框内按 `Esc` 也能关闭查找条。Markdown 文档面板另有只读查找(同样 `Ctrl+F`,支持计数与上下跳转)。
79
- - **图片、CSV 与网页预览**:PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG 直接在内容面板按图片显示(最大 24 MB),支持按钮缩放、`Ctrl/Cmd + 滚轮` 缩放、适应窗口和 1:1 原始大小;CSV/TSV 默认按表格显示,可在「表格 / 源码」间切换,源码视图仍可编辑保存,超过 1000 行或 80 列时只展示截断后的表格。HTML/HTM 以沙箱 iframe 渲染(脚本禁用),Markdown 预览会移除脚本、事件属性与危险链接。
81
+ - **图片、CSV 与网页预览**:PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG 直接在内容面板按图片显示(最大 24 MB),支持按钮缩放、`Ctrl/Cmd + 滚轮` 缩放、适应窗口和 1:1 原始大小;CSV/TSV 默认按表格显示,可在「表格 / 源码」间切换,源码视图仍可编辑保存,超过 1000 行或 80 列时只展示截断后的表格。HTML/HTM 以沙箱 iframe 渲染(脚本在独立源里运行,图表能画出来,但拿不到 DSH 界面与存储;上限 8 MB,超过时提示改下载后用浏览器打开),Markdown 预览会移除脚本、事件属性与危险链接。
80
82
  - **快捷键**:`Ctrl/Cmd+S` 保存当前文件;`Ctrl/Cmd+W` 关闭当前标签(未保存时提示保存/放弃/取消);`Ctrl+Tab` / `Shift+Ctrl+Tab` 切换标签;`Ctrl/Cmd+B` 显示/隐藏目录面板;`Ctrl/Cmd+Shift+F` 打开文件搜索。
81
83
  - **自动保存**:设置 → 联动工作区 →「编辑器行为」中开启;停止输入约 1 秒后自动保存。关闭时使用 `Ctrl+S` 手动保存;有未保存文件时刷新/关闭页面会弹确认。
82
84
 
@@ -109,11 +111,22 @@
109
111
 
110
112
  | 工具 | 用途 |
111
113
  | --- | --- |
112
- | `linked_workspace` | `list`、`info`、`list_dir`、`read`、`write`、`replace`、`stat`、`mkdir`、`rename`、`delete`、`sync`;路径相对远端根目录,写入原子化,`if_modified_since` 做乐观并发控制。联动工作区与远程工作区都适用(远程工作区没有本地副本,`sync` 只用于开启镜像的联动工作区) |
114
+ | `linked_workspace` | `list`、`info`、`list_dir`、`read`、`write`、`replace`、`stat`、`mkdir`、`rename`、`delete`、`sync`、`exec`;路径相对远端根目录,写入原子化,`if_modified_since` 做乐观并发控制。联动工作区与远程工作区都适用(远程工作区没有本地副本,`sync` 只用于开启镜像的联动工作区) |
113
115
  | `linked_skills` | `list`、`read` 本地技能(`~/.dsh/skills`、`~/.agents/skills`、`<local>/.dsh/skills`、`<local>/.agents/skills`) |
114
116
 
115
117
  会话工作目录落在某个联动工作区或远程工作区的占位目录时会自动解析;跨工作区可用 `workspace` 参数指定(支持 id、本地/占位路径或名称)。远端服务器只需要 SSH,不需要安装插件或 Python。
116
118
 
119
+ ### 远端命令执行(0.17.0,默认关闭)
120
+
121
+ `exec` 让模型在远端跑**一条非交互命令**(编译、跑测试、看日志),不用再自己拼 `ssh`。它默认是关的,要同时满足三件事才会执行:
122
+
123
+ 1. 设置 → 联动工作区 → 「远端命令执行」里的总开关 `execEnabled`;
124
+ 2. 该主机在**主机白名单** `execHostIds` 里;
125
+ 3. 若填了**工作区白名单** `execWorkspaceIds`,当前工作区必须在其中(留空表示不限制)。
126
+
127
+ 每次尝试——包括被拒绝的——都会写一行到 `$DSH_HOME/linked-workspace/exec-audit.jsonl`(含命令、退出码、耗时、输出的前 4 KB、拒绝原因),超过 5 MB 自动轮转为 `.1`;设置页有「打开审计日志」按钮。输出按 `execMaxOutputChars`(默认 200000 字符/流)截断,超时由 `execTimeoutMs`(默认 60 秒,单次最多 600 秒)控制,`cwd` 不能跑出工作区根目录。
128
+
129
+
117
130
  ### 运行中图标 / 本地技能
118
131
 
119
132
  - 联动工作区下若有正在运行的会话(本地会话 turn 进行中),左侧工作区的链环图标会变成**蓝色**;刷新间隔约 5 秒。
@@ -187,7 +200,8 @@ npm 包名为 `dsh-linked-workspace`,也可以从 npm 安装已发布版本(
187
200
  - 直接远程工作区的读写限制在该目录内;联动工作区的工具限制在远端根目录内,本地写入限制在本地根目录内。
188
201
  - 单文件保存上限 8 MB;镜像同步在后台执行,默认最多 500 文件 / 50 MB(跳过超大文件),默认排除 `.git`/`node_modules`/各类缓存目录,单文件读取 30 s 超时,不再阻塞 HTTP 请求。右键「传输」与「下载到默认文件夹」单次最多 150 文件 / 15 MB(超限会提示未全部传输)。
189
202
  - 页面 HTTP API 只接受本机回环同源请求(远程部署时回落到 DSH `connection` 服务的 Host/Origin 鉴权)。
190
- - 预览默认不可执行脚本:HTML 走 `sandbox=""` 的 iframe;Markdown/文档预览会移除脚本、内联样式、事件属性与 `javascript:`/`vbscript:` 等危险链接,只保留安全链接与图片 `data:` URL。
203
+ - HTML 预览跑在 `sandbox="allow-scripts"` 的 iframe 里:脚本能执行(plotly 这类图表才有内容),但处于独立的不透明源,访问不到 DSH 界面、宿主存储与标签页;Markdown/文档预览仍会移除脚本、内联样式、事件属性与 `javascript:`/`vbscript:` 等危险链接,只保留安全链接与图片 `data:` URL。
204
+ - 远端命令执行默认关闭,开启后仍受主机白名单(以及可选的工作区白名单)限制;每次执行(含被拒绝的尝试)都写审计日志,输出有长度上限、命令有超时,`cwd` 不能跑出工作区根目录。
191
205
 
192
206
  ## 常见问题
193
207
 
package/docs/API.md CHANGED
@@ -55,13 +55,15 @@ scope root, or absolute inside it.
55
55
  | `hosts.credentials` | `{ hostId, password?, passphrase?, privateKey?, clear? }` | `{ hostId, authType, hasCredential, hasStoredPassword }` (stores the secret in the plugin's own `ssh-credentials.json`; `clear: true` deletes it) |
56
56
  | `hosts.browse` | `{ hostId, path? }` | `{ path, parent, home, entries }` (dirs + files) |
57
57
  | `hosts.df` | `{ hostId, path? }` | `{ disk: { path, size, used, avail, percent } \| null }` (free space of the volume holding `path`; defaults to the login home) |
58
+ | `hosts.status` | `{ hostIds? }` | `{ statuses: { [hostId]: { state, reason?, message?, latencyMs?, checkedAt? } } }` (in-memory snapshot of the pool, never dials; an `error` older than 60 s is reported as `idle`; defaults to every known host of the host list plus every workspace's host id) |
58
59
  | `hosts.mkdir` | `{ hostId, path?, name }` | `{ path }` (creates `name` inside `path`; defaults to the login home; `409`/`FS_EXISTS` when it already exists) |
60
+ | `hosts.exec` | `{ hostId?/linkedId?/remoteId?, command, cwd?, timeoutMs? }` | `{ hostId, hostName, workspaceId, kind, command, cwd, exitCode, stdout, stderr, stdoutBytes, stderrBytes, truncated, durationMs, startedAt, auditId }` — runs **one** non-interactive command on the remote host. Three gates: `settings.execEnabled` must be `true`, the host must be in `settings.execHostIds`, and — when `settings.execWorkspaceIds` is non-empty — the workspace must be in it. Refusals are audited too and answer `403` (`EXEC_DISABLED` / `EXEC_HOST_NOT_ALLOWED` / `EXEC_WORKSPACE_NOT_ALLOWED`); a timeout answers `504` `EXEC_TIMEOUT`, other failures `502` `EXEC_FAILED`. Output is clipped to `settings.execMaxOutputChars` per stream (default 200000, head+tail). `cwd` is resolved inside the workspace root and may not escape it. |
59
61
  | `remote_workspaces.list` | `{}` | `{ workspaces: RemoteWorkspaceInfo[] }` |
60
62
  | `remote_workspaces.create` | `{ hostId, remotePath, name? }` | `{ workspace }` |
61
63
  | `remote_workspaces.get` | `{ id }` | `{ workspace }` |
62
64
  | `remote_workspaces.update` | `{ id, name? }` | `{ workspace }` |
63
65
  | `remote_workspaces.remove` | `{ id }` | `{ removedWorkspace, removedPlaceholder }` |
64
- | `remote_workspaces.test` | `{ id }` | `{ ok, latencyMs?, exists?, type?, error? }` |
66
+ | `remote_workspaces.test` | `{ id }` | `{ ok, latencyMs?, exists?, type?, error? }` (a missing directory comes back as `exists: false` and leaves the host's connection state untouched) |
65
67
  | `fs.list` | `{ linkedId?/remoteId?, path, limit?, offset? }` | `{ path, entries: RemoteEntry[], total, offset, limit, hasMore }` (default 500, max 5000). Listings are cached for 5 s for `offset > 0`; writes, mkdir, rename, move, delete, copy and transfers invalidate the cache. |
66
68
  | `fs.read` | `{ linkedId?/remoteId?, path, maxBytes? }` | `FileRead` |
67
69
  | `media.read` | `{ linkedId?/remoteId?, path }` | `{ path, size, mtime, mime, base64 }` (PNG/JPG/GIF/WebP/BMP/ICO/AVIF/SVG, max 24 MB) |
@@ -129,7 +131,17 @@ Under `$DSH_HOME/linked-workspace/`:
129
131
 
130
132
  - `linked.json` — linked workspaces (no credentials).
131
133
  - `remote-workspaces.json` — remote workspaces (no credentials).
132
- - `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave }`.
134
+ - `settings.json` — `{ editorTheme, editorThemeFamily, editorThemeMode, fileOpenMode, autoSave, execEnabled, execHostIds, execWorkspaceIds, execTimeoutMs, execMaxOutputChars, execShell }`.
135
+ The exec keys are off unless you turn them on: `execEnabled` defaults to
136
+ `false`, `execHostIds` (host allow-list) starts empty, and
137
+ `execWorkspaceIds` is an optional second layer where an empty list means
138
+ "every workspace on an allowed host".
139
+ - `exec-audit.jsonl` — one JSON line per `hosts.exec` attempt (accepted or
140
+ refused): `{ ts, auditId, hostId, hostName, workspaceId, kind, command, cwd?,
141
+ exitCode?, durationMs?, stdoutBytes?, stderrBytes?, truncated?, stdoutHead?,
142
+ stderrHead?, refusal?, message? }`. Rotated to `exec-audit.jsonl.1` past 5 MB.
143
+ `meta.info` returns its absolute path as `execAuditFile` so the settings page
144
+ can open it.
133
145
  - `known_hosts.json` — trust-on-first-use host key fingerprints.
134
146
  - `ssh-credentials.json` — `{ version, byHostId: { <hostId>: { password?, privateKey?, passphrase? } } }`,
135
147
  written by `hosts.credentials` with mode `0600`. Hosts listed in `~/.ssh/config`
@@ -143,13 +155,15 @@ Under `$DSH_HOME/linked-workspace/`:
143
155
 
144
156
  `linked_workspace` (Host tool, JSON-Schema parameters) actions: `list`, `info`,
145
157
  `list_dir`, `read`, `write`, `replace`, `stat`, `mkdir`, `rename`, `delete`,
146
- `sync`. It resolves the workspace from the session working directory (a linked
158
+ `sync`, `exec`. It resolves the workspace from the session working directory (a linked
147
159
  local directory or a remote workspace placeholder) or from an explicit
148
160
  `workspace` reference (id, local/placeholder path, or name), confines paths to
149
161
  the remote root, and mirrors reads/writes into `.remote/` when a linked
150
162
  workspace mirrors. `list` shows both kinds, labelled `(linked)` and `(remote)`;
151
163
  `info` returns `kind: "linked" | "remote"` and `sync` is rejected for remote
152
- workspaces.
164
+ workspaces. `exec` takes `command` (≤ 8000 characters), an optional `cwd`
165
+ (inside the workspace root) and `timeout_ms`, and refuses unless the switches
166
+ described under `hosts.exec` are on.
153
167
 
154
168
  `linked_skills` (Host tool) actions: `list`, `read` — local skills
155
169
  (`~/.dsh/skills`, `~/.agents/skills`, `<local>/.dsh/skills`,
package/docs/VERIFY.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-workspace-ui`; client changes load with **应用 → 重新加载界面** (a full restart is only needed after re-installing the package). Then verify:
4
4
 
5
+ ## 远端命令执行(0.17.0)
6
+
7
+ > 注意:本机这套 DSH **Web** 构建里没有可见的设置入口(账号菜单只有「意见反馈 / 退出登录」,`Ctrl+K` 是会话搜索,插件详情页只有「卸载」),所以设置区块的渲染要在**桌面端**确认;Host 侧行为可以直接用下面的 API 命令验证。
8
+
9
+ 1. 设置 → 联动工作区 → 「远端命令执行」:默认总开关关闭、两个白名单为空、超时 60 秒、输出上限 200000;打开开关后才出现黄色警告行与两个白名单列表。
10
+ 2. 开关关闭时执行:`hosts.exec { linkedId, command: 'echo x' }` → `403 EXEC_DISABLED`,提示里指向设置页路径。
11
+ 3. 开关打开但主机白名单为空 → `403 EXEC_HOST_NOT_ALLOWED`;把该主机加进白名单 → `echo hi; pwd` 返回 `exitCode: 0`、`stdout` 含 `hi`、`cwd` 等于工作区远端根。
12
+ 4. 工作区白名单填一个不相干的值 → `403 EXEC_WORKSPACE_NOT_ALLOWED`;留空表示不限制。
13
+ 5. `command: ''` → `400 BAD_REQUEST`;`cwd: '../..'` → `400 BAD_REQUEST`;`timeoutMs: 1000` 配 `sleep 5` → `504 EXEC_TIMEOUT`。
14
+ 6. 审计:每次尝试(含被拒绝)都往 `$DSH_HOME/linked-workspace/exec-audit.jsonl` 追加一行 JSON,含 `auditId`、`hostId`、`command`、成功时的 `exitCode`/`durationMs`/`stdoutHead`、失败时的 `refusal`/`message`;文件超过 5 MB 时轮转为 `exec-audit.jsonl.1`;设置页「打开审计日志」用系统默认应用打开它。
15
+ 7. 模型侧:在联动/远程工作区的会话里让它「用 linked_workspace 的 exec 动作跑 uname -a」→ 工具卡片返回退出码与输出;开关关闭时模型会收到 `EXEC_DISABLED` 与开启指引。
16
+ 8. 旧 Host:`meta.info` 的 `apiRevision` < 3 时目录树顶部出现「DSH 的插件进程仍在运行旧版代码」横幅。
17
+
5
18
  ## 设置 → 联动工作区
6
19
 
7
20
  1. 左下角「账号菜单」→ 设置 →「联动工作区」。
@@ -75,6 +88,9 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
75
88
  3. **卡片里的目录**:远程工作区的卡片只显示**远端目录**绝对路径(例如 `/shared_data_ssd1/huangjh/code`,不显示本地占位目录);联动工作区的卡片显示两行——「远端 …」与「本地 …」两个绝对路径。
76
89
  4. **断线变红**:让主机断开 SSH(例如在服务器上执行 `pkill -u <user> sshd`,或在网络中断开)→ 左侧栏该工作区行的图标变红(`#f85149`),悬停卡片里的状态行同样变成红色的「连接已断开」。
77
90
  5. **自动恢复**:再次访问该工作区(打开目录树 / 刷新设置页)→ 连接重建后图标恢复常规颜色,悬停卡片里的状态回到「已连接」。
91
+ 5b. **状态跟着实际连通性走(0.16.1)**:把鼠标停在某行上让卡片保持打开,然后让该主机掉线(`hosts.credentials { hostId, clear: true }` 丢掉长连接,再把该主机从 `known_hosts.json` 的指纹改坏;或在服务器上 `pkill -u <user> sshd`)→ 最多 6 秒后卡片那一行变成红色的「连接已断开」,**全程不刷新页面**;恢复指纹/主机后随便访问一次该目录,再等 ≤6 秒,同一张还开着的卡片自动回到绿色的「已连接」。
92
+ 5c. **目录不存在不算断连**:在插件外用 `rm -rf` 删掉某个远程工作区指向的目录,再在设置页点它的「测试连接」→ 卡片给出「远端目录不存在」一类的提示,但 `hosts.status` 里该主机仍是 `connected`,同一台主机上的其它工作区**不会**被标红;对不存在的路径 `fs.stat` / `fs.list` 也只会返回 `FS_NOT_FOUND`,主机状态不变。
93
+ 5d. **旧错误会过期**:制造一次真实失败(`hosts.status` 里该主机为 `error`)后什么都不做,等 60 秒以上 → `hosts.status` 里它变成 `{ state: 'idle' }`,卡片显示「未连接」而不是一直红着;随后任意一次成功的目录访问会重新写回 `connected`。
78
94
  6. **命名**:设置左侧导航显示「联动工作区」,页面标题显示「联动&远程工作区」;「添加工作区」弹窗第三个页签显示「远程工作区」。
79
95
 
80
96
  ## 深色主题(0.11.0)
@@ -196,9 +212,10 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
196
212
  1. 打开 PNG/SVG:图片默认适应窗口;点「适应窗口」重新适配,「1:1」恢复原始像素。
197
213
  2. 点 `−` / `+` 时缩放比例按 20% 步进,状态栏百分比同步;`Ctrl/Cmd + 滚轮` 可连续缩放,最小 5%、最大 800%。
198
214
  3. 放大后图片区域出现滚动条,可查看四周;缩小后图片保持居中,不出现拉伸变形。
199
- 4. 本地与远端各打开一个 `.html`/`.htm`:内容面板以 iframe 渲染页面,状态栏显示 HTML、大小和「网页脚本已禁用」。
200
- 5. HTML 内联样式与静态标签正常显示;页面内脚本不执行,链接不会跳出 DSH 主界面。
201
- 6. 读取失败的 HTML(权限/过大/二进制)显示错误提示和重试按钮。
215
+ 4. 本地与远端各打开一个 `.html`/`.htm`:内容面板以 iframe 渲染页面,状态栏显示 HTML、大小和「沙箱预览(脚本可运行,无法访问 DSH 界面)」。
216
+ 5. 页面自带的脚本在沙箱里执行:打开一个 plotly 之类靠 JS 画图的页面,图表应正常绘制(沙箱是不透明源,拿不到 DSH 界面、宿主存储与标签页)。
217
+ 5b. 打开一个 2–8 MB 的 HTML(例如 7.1 MB 的趋势图):应正常预览整页;超过 8 MB 的页面显示「文件 X 超过预览上限 8.0 MB,请右键『下载到默认文件夹』后用浏览器打开」,不再出现重复的「无法预览网页:无法预览网页」。
218
+ 6. 读取失败的 HTML(权限/二进制)显示错误提示和重试按钮。
202
219
 
203
220
  ## 安全、分页与可访问性(0.8.2)
204
221
 
@@ -250,7 +267,7 @@ Host code (lib/) reloads live with `plugin_manager set_plugin include:linked-wor
250
267
  10. **悬停展开**:拖拽停在折叠目录行 700 ms:该目录应自动展开。
251
268
  11. **host-api**:`node test/host-api.mjs` 应为 33 步全部通过(0.15.0 起含 `meta.info`)。
252
269
 
253
- ## 提示、对话框与下载(Unreleased)
270
+ ## 提示、对话框与下载(0.16.1)
254
271
 
255
272
  1. 目录栏标题右侧出现可用空间(如「7983.64 GB」),悬停显示「可用 …(已用 17%)· 已用 / 总量」;换工作区后数字随之变化。
256
273
  2. 对含 150 个以上文件的远端目录右键「下载到默认文件夹」:提示里带文件数与体积,并以「达到上限,未全部下载」结尾;下载目录里确实是 150 个文件。