dsh-remote 0.8.77 → 0.8.78

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 CHANGED
@@ -333,6 +333,7 @@ Deploying to a product profile is a separate, explicit action (`./sync.sh`) for
333
333
  | `webAttachDshHome` | string | `''` | `DSH_HOME` exported on the remote when attaching; empty reuses the remote user's own harness home |
334
334
  | `webAttachWaitSeconds` | int | `45` | how long to wait for a freshly started remote `dsh web` to print its launch token |
335
335
  | `localTools` | string | `bootstrap` | which `rw_*` tools a LOCAL session (cwd outside every remote mirror) sees (issue #63): `bootstrap` keeps only the configuration loop `rw_machines`/`rw_connect`/`rw_pick_workspace` (the other 19 refuse a local session with "this session is LOCAL", so exposing them just wastes schema budget); `none` hides all `rw_*` (remote setup happens via the settings page only); `all` restores the legacy full surface. REMOTE sessions (cwd inside a mirror) always see everything; an invalid value degrades to `bootstrap` |
336
+ | `telemetry` | bool | `true` | anonymous install heartbeat (daily-active statistics, at most once a day; the payload is a plugin-specific HMAC pseudonym + version, no machine info). `false` disables it; users also get a settings-page checkbox (persisted in `$DSH_HOME`, winning over this config) |
336
337
  | `remoteTerminalDefault` | bool | `true` | make the shell menu's "remote ssh" launcher the terminal's DEFAULT shell when neither the host (`config.shell`) nor the user (a remembered menu choice) has picked one: a session rooted in a remote mirror opens a terminal already sshed into the remote workspace, any other session transparently falls back to a local shell (issue #55); `false` keeps it menu-only |
337
338
  | `tui` | bool | `true` | master switch for the TUI (dsh-tui) layer; `false` registers no `/dsh-remote` page, workspace provider or status field |
338
339
  | `tuiProviderListRecent` | bool | `true` | list each machine's recent remote projects in the TUI workspace picker |
package/README.md CHANGED
@@ -308,6 +308,7 @@ scripts/dev-run.sh --status # 是否在运行
308
308
  | `webAttachDshHome` | string | `''` | 远端启动时导出的 `DSH_HOME`;留空则复用远端用户自己的 harness home |
309
309
  | `webAttachWaitSeconds` | int | `45` | 等待远端 `dsh web` 打印启动令牌的秒数 |
310
310
  | `localTools` | string | `bootstrap` | 本地 session(cwd 不在远程镜像里)暴露哪些 `rw_*` 工具(issue #63):`bootstrap`=只暴露配置闭环 `rw_machines`/`rw_connect`/`rw_pick_workspace`(其余 19 个在本地 session 必然报 "this session is LOCAL",暴露只是白占 schema);`none`=完全不暴露 `rw_*`(远程配置只能走设置页);`all`=旧的 full 暴露。远程 session(cwd 在镜像里)不受影响,始终全量;非法值按 `bootstrap` 处理 |
311
+ | `telemetry` | bool | `true` | 匿名安装心跳(日活统计,每天至多一次;内容为插件专属 HMAC 伪名+版本号,不含机器信息)。`false` 关闭;用户也可在设置页用复选框关闭(持久化在 `$DSH_HOME`,优先于此配置) |
311
312
  | `remoteTerminalDefault` | bool | `true` | 让 shell 菜单里的「remote ssh」启动器成为终端**默认 shell**(宿主未配置、用户未手动选择时):远程会话开终端即落到远端工作目录,本地会话自动回落本地 shell(issue #55);`false` 则只保留菜单项 |
312
313
  | `tui` | bool | `true` | TUI 适配层(dsh-tui)总开关;`false` 时不注册 `/dsh-remote` 页面、工作区 provider 与状态行字段 |
313
314
  | `tuiProviderListRecent` | bool | `true` | TUI 工作区选择器里是否列出每台机器最近的远程项目 |
package/lib/client.js CHANGED
@@ -241,6 +241,8 @@ window.__ModuleLoader__.load({
241
241
  'settings.updateNow': '立即更新',
242
242
  'settings.updateMode': '更新模式:',
243
243
  'settings.explorerAutoOpen': '打开远程工作区时,自动在侧边栏展开「远程文件」(需安装 better-sidebar)',
244
+ 'settings.telemetry': '匿名使用统计(每日一次的安装心跳;不含任何机器信息,可随时关闭)',
245
+ 'settings.telemetryHint': '上报内容只有插件专属的 HMAC 伪名与版本号;关闭后立即不再发送',
244
246
  'settings.updateManual': '手动',
245
247
  'settings.updateAuto': '自动',
246
248
  'settings.updateOff': '关闭',
@@ -547,6 +549,8 @@ window.__ModuleLoader__.load({
547
549
  'settings.updateNow': 'Update now',
548
550
  'settings.updateMode': 'Update mode:',
549
551
  'settings.explorerAutoOpen': 'Auto-open the Remote Files sidebar tab for remote workspaces (via better-sidebar)',
552
+ 'settings.telemetry': 'Anonymous usage statistics (one install heartbeat per day; no machine info; can be turned off anytime)',
553
+ 'settings.telemetryHint': 'Only a plugin-specific HMAC pseudonym and the version number are sent; takes effect immediately',
550
554
  'settings.updateManual': 'Manual',
551
555
  'settings.updateAuto': 'Auto',
552
556
  'settings.updateOff': 'Off',
@@ -1252,6 +1256,12 @@ window.__ModuleLoader__.load({
1252
1256
  // Issue #78: initial value comes from localStorage, so a user's choice
1253
1257
  // survives restarts (the bug was: the panel popped again every restart).
1254
1258
  const [explorerAuto, setExplorerAuto] = React.useState(() => explorerAutoOpenEnabled())
1259
+ // Anonymous-heartbeat toggle: null = not loaded yet (checkbox disabled).
1260
+ // Effective value is host-side (user override > profile config).
1261
+ const [telemetryOn, setTelemetryOn] = React.useState(null)
1262
+ React.useEffect(() => {
1263
+ api('GET', '/dsh-remote/telemetry').then((r) => setTelemetryOn(!(r && r.enabled === false))).catch(() => {})
1264
+ }, [])
1255
1265
  const checkUpdate = (quiet) => {
1256
1266
  if (updBusy) return
1257
1267
  setUpdBusy(true); setUpdMsg('')
@@ -1977,6 +1987,19 @@ window.__ModuleLoader__.load({
1977
1987
  }),
1978
1988
  tr('settings.explorerAutoOpen'),
1979
1989
  ),
1990
+ React.createElement('label', { style: { display: 'flex', gap: 6, alignItems: 'center', cursor: telemetryOn === null ? 'default' : 'pointer', opacity: 0.85 }, title: tr('settings.telemetryHint') },
1991
+ React.createElement('input', {
1992
+ type: 'checkbox', checked: telemetryOn === true, disabled: telemetryOn === null, 'data-testid': 'telemetry-toggle',
1993
+ onChange: (e) => {
1994
+ const on = !!(e && e.target && e.target.checked)
1995
+ setTelemetryOn(on) // optimistic; the host answer re-syncs below
1996
+ api('POST', '/dsh-remote/telemetry', { enabled: on })
1997
+ .then((r) => setTelemetryOn(!(r && r.enabled === false)))
1998
+ .catch(() => setTelemetryOn(null))
1999
+ },
2000
+ }),
2001
+ tr('settings.telemetry'),
2002
+ ),
1980
2003
  ),
1981
2004
  upd && upd.pendingReload
1982
2005
  ? React.createElement('div', { style: { marginTop: 6, fontSize: 12, color: T.warn } },
package/lib/index.js CHANGED
@@ -53,7 +53,7 @@ import { WebAttach } from './web-attach.js'
53
53
  import { formatAuditLine, readAuditLines } from './audit.js'
54
54
 
55
55
  import { selfDir, diskVersion, LOADED_VERSION, gtVersion, fetchLatestVersion, applyUpdate, persistUpdateMode, readUpdateMode, reloadSelf, scheduleSelfReload, lastSelfReload, isInstalledCopy } from './update.js'
56
- import { sendHeartbeat, pseudonym, heartbeatUrl, hasPersistedId, installIdPath } from './telemetry.js'
56
+ import { sendHeartbeat, pseudonym, heartbeatUrl, hasPersistedId, installIdPath, telemetryAllowed, persistTelemetryOpt } from './telemetry.js'
57
57
  import { loadMachines as _loadMachines, saveMachines as _saveMachines, sanitizeMachine as _sanitizeMachine, applyMachine as _applyMachine, machineId as _machineId, normalizeMachineGroup, filterMachinesByGroup, resolveProbeCredentials } from './registry.js'
58
58
  import { registerHttpTransports } from './http-transport.js'
59
59
  import { createHostApi } from './host-api.js'
@@ -284,6 +284,11 @@ export const Config = z.object({
284
284
  * plaintext is the one outcome you did not ask for.
285
285
  * `plain`: the pre-0.8.54 fallback (write it and warn). */
286
286
  credentialFallback: z.string().default('refuse'),
287
+ /** Anonymous install heartbeat (daily-active statistics). The payload is a
288
+ * plugin-specific HMAC pseudonym — no machine info leaves the box. Admins
289
+ * can turn it off here; users get a settings-page checkbox whose persisted
290
+ * choice (in $DSH_HOME) wins over this config value. */
291
+ telemetry: z.boolean().default(true),
287
292
  /** Make the "remote ssh" launcher the terminal's DEFAULT shell when neither
288
293
  * the host admin (config.shell) nor the user (remembered menu choice) has
289
294
  * picked one. The launcher is cwd-aware: a session rooted in a remote mirror
@@ -463,9 +468,10 @@ export async function apply(ctx, config) {
463
468
 
464
469
  // ── 安装心跳(日活统计)─────────────────────────────────────────────────
465
470
  // 旁路:不 await、不阻塞加载、失败静默(见 lib/telemetry.js 的隐私与失败策略)。
466
- // 无配置开关(按作者要求默认开启);上报的是本插件专属 HMAC 伪名,
467
- // 原始安装 id 与任何机器信息都不离开本机。
468
- void sendHeartbeat(dshBase(), LOADED_VERSION)
471
+ // 默认开启,但可以被关:profile 配置 `telemetry: false`(管理员)或设置页
472
+ // 复选框(用户,持久化在 $DSH_HOME,优先于配置)。上报的是本插件专属 HMAC
473
+ // 伪名,原始安装 id 与任何机器信息都不离开本机。
474
+ if (telemetryAllowed(dshBase(), config.telemetry)) void sendHeartbeat(dshBase(), LOADED_VERSION)
469
475
 
470
476
  // The update marker means "a newer version landed on disk but is not the code
471
477
  // running yet". Reaching apply() with a marker naming the version we just
@@ -4797,6 +4803,28 @@ export async function apply(ctx, config) {
4797
4803
  }
4798
4804
  },
4799
4805
  },
4806
+ {
4807
+ kind: 'exact',
4808
+ path: '/dsh-remote/telemetry',
4809
+ handler: async (req, res) => {
4810
+ // The anonymous-heartbeat toggle (settings page). GET reads the
4811
+ // EFFECTIVE value (user override > profile config > default true);
4812
+ // POST persists the user's choice under $DSH_HOME so it survives
4813
+ // plugin upgrades (the install dir gets overwritten).
4814
+ if (req.method === 'GET') {
4815
+ return sendJson(res, 200, { ok: true, enabled: telemetryAllowed(dshBase(), config.telemetry), configurable: heartbeatEnabled() })
4816
+ }
4817
+ if (req.method !== 'POST') return sendJson(res, 405, { ok: false, error: 'method not allowed' })
4818
+ try {
4819
+ const body = JSON.parse((await readBody(req)) || '{}')
4820
+ if (typeof body.enabled !== 'boolean') return sendJson(res, 400, { ok: false, error: 'enabled must be boolean' })
4821
+ if (!persistTelemetryOpt(dshBase(), body.enabled)) return sendJson(res, 500, { ok: false, error: 'cannot persist the setting (read-only home?)' })
4822
+ return sendJson(res, 200, { ok: true, enabled: telemetryAllowed(dshBase(), config.telemetry) })
4823
+ } catch (err) {
4824
+ return sendJson(res, 500, { ok: false, error: String((err && err.message) || err) })
4825
+ }
4826
+ },
4827
+ },
4800
4828
  ]
4801
4829
 
4802
4830
  registerHttpTransports(ctx, routes)
package/lib/telemetry.js CHANGED
@@ -188,6 +188,40 @@ export function heartbeatEnabled() {
188
188
  return heartbeatUrl().startsWith('https://')
189
189
  }
190
190
 
191
+ // ── 用户开关(0.8.78+)────────────────────────────────────────────────────
192
+ // 双层:profile 配置 `telemetry: false` 是管理员路径;设置页复选框写
193
+ // `$DSH_HOME/.dsh-remote-telemetry`('0'/'1')是用户路径。与 updateMode 同一
194
+ // 约定:用户覆盖优先于配置默认。文件放 DSH_HOME 而非插件目录——升级覆写插件
195
+ // 目录时用户的选择不丢。
196
+ const OPT_FILE = '.dsh-remote-telemetry'
197
+
198
+ /** 读取用户持久化的开关:'1'/'0'/null(未设置或不可读)。 */
199
+ export function readTelemetryOpt(home) {
200
+ try {
201
+ const v = readFileSync(path.join(home, OPT_FILE), 'utf8').trim()
202
+ return v === '1' || v === '0' ? v : null
203
+ } catch {
204
+ return null
205
+ }
206
+ }
207
+
208
+ /** 持久化用户选择;返回是否写成功(只读 HOME 时静默 false)。 */
209
+ export function persistTelemetryOpt(home, enabled) {
210
+ try {
211
+ writeFileSync(path.join(home, OPT_FILE), enabled ? '1' : '0')
212
+ return true
213
+ } catch {
214
+ return false
215
+ }
216
+ }
217
+
218
+ /** 当前生效值:用户覆盖 > 配置值(默认 true)。 */
219
+ export function telemetryAllowed(home, configValue) {
220
+ const opt = readTelemetryOpt(home)
221
+ if (opt !== null) return opt === '1'
222
+ return configValue !== false
223
+ }
224
+
191
225
  /** 身份文件是否已存在(自检用,不创建)。 */
192
226
  export function hasPersistedId(home) {
193
227
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote",
3
- "version": "0.8.77",
3
+ "version": "0.8.78",
4
4
  "description": "Remote-work assistant for DeepSeek Harness: connect SSH (password/key/agent/keyboard-interactive, multi-hop ProxyJump), list hosts from ~/.ssh/config, pick a remote workspace, operate on it with 21 rw_* tools, conflict-aware mirror sync, an embedded PTY terminal, remote DSH web UI attach, port forwarding, host grouping, remote sandbox fencing, audit log, keychain passwords.",
5
5
  "license": "MIT",
6
6
  "author": "flymysql <flyphp@outlook.com>",