dsh-remote 0.8.80 → 0.8.82
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 +10 -5
- package/README.md +8 -4
- package/lib/client.js +45 -39
- package/lib/errors.js +1 -1
- package/lib/host-api.js +14 -0
- package/lib/http-transport.js +6 -1
- package/lib/index.js +199 -42
- package/lib/open-folder.js +56 -0
- package/lib/paths.js +42 -2
- package/lib/remote-shell-child.cjs +58 -2
- package/lib/remote-shell.js +118 -1
- package/lib/sync.js +100 -25
- package/lib/tui/i18n.js +6 -6
- package/lib/tui/scene.js +10 -20
- package/package.json +1 -1
package/lib/remote-shell.js
CHANGED
|
@@ -250,6 +250,10 @@ export function launcherSource(spec) {
|
|
|
250
250
|
'setlocal',
|
|
251
251
|
`set "DSH_CHILD=${child}"`,
|
|
252
252
|
`set "DSH_MACHINES=${machines}"`,
|
|
253
|
+
// Where the askpass helper + credential-bridge payload live (this .cmd's
|
|
254
|
+
// own directory); the child reads it to decide whether password auth can
|
|
255
|
+
// be bridged (see remote-shell-child.cjs askpassEnv).
|
|
256
|
+
'set "DSH_TERM_DIR=%~dp0"',
|
|
253
257
|
`set "DSH_NODE=${node}"`,
|
|
254
258
|
'if defined DSH_NODE if exist "%DSH_NODE%" goto :run',
|
|
255
259
|
'set "DSH_NODE="',
|
|
@@ -287,6 +291,8 @@ export function launcherSource(spec) {
|
|
|
287
291
|
'# Generated by dsh-remote - do not edit; rewritten on every load.',
|
|
288
292
|
`DSH_CHILD=${shqPosix(child)}`,
|
|
289
293
|
`DSH_MACHINES=${shqPosix(machines)}`,
|
|
294
|
+
// Physical directory of this script: the askpass helper + payload live here.
|
|
295
|
+
'DSH_TERM_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)',
|
|
290
296
|
node ? `DSH_NODE=${shqPosix(node)}` : 'DSH_NODE=',
|
|
291
297
|
'if [ -n "$DSH_NODE" ] && [ -x "$DSH_NODE" ]; then exec "$DSH_NODE" "$DSH_CHILD" --machines "$DSH_MACHINES"; fi',
|
|
292
298
|
'if command -v node >/dev/null 2>&1; then exec node "$DSH_CHILD" --machines "$DSH_MACHINES"; fi',
|
|
@@ -301,6 +307,114 @@ export function shqPosix(value) {
|
|
|
301
307
|
return "'" + String(value).replace(/'/g, "'\\''") + "'"
|
|
302
308
|
}
|
|
303
309
|
|
|
310
|
+
// ── the credential bridge helper (saved-password terminal auth) ─────────────
|
|
311
|
+
//
|
|
312
|
+
// The `remote ssh` terminal spawns the OS ssh, which knows keys and agents but
|
|
313
|
+
// has no way to receive the password the plugin saved (plaintext registry or OS
|
|
314
|
+
// keychain). The bridge: ssh (with SSH_ASKPASS_REQUIRE=force) calls this
|
|
315
|
+
// helper, the helper POSTs the machine identity to the RUNNING plugin's
|
|
316
|
+
// loopback route `/dsh-remote/term-secret` with a per-boot bearer token, and
|
|
317
|
+
// the host answers through the same credential chain a real connect uses.
|
|
318
|
+
// The token + URL live in `term-secret.json` next to the launcher (0600); the
|
|
319
|
+
// helper itself carries no secret.
|
|
320
|
+
|
|
321
|
+
/** Absolute path of the askpass wrapper for the platform. */
|
|
322
|
+
export function askpassWrapperPath(dir, platform = process.platform) {
|
|
323
|
+
return path.join(dir, platform === 'win32' ? 'term-askpass.cmd' : 'term-askpass')
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Body of term-askpass.cjs — plain CJS, no dependencies, no secrets. */
|
|
327
|
+
export function askpassHelperSource() {
|
|
328
|
+
return [
|
|
329
|
+
'#!/usr/bin/env node',
|
|
330
|
+
'// Generated by dsh-remote - do not edit; rewritten on every load.',
|
|
331
|
+
'// ssh askpass helper: fetch the saved password for DSH_TS_* (host/port/',
|
|
332
|
+
'// username) from the running dsh-remote host, print it on stdout.',
|
|
333
|
+
'// Exit nonzero without output when the bridge cannot answer - ssh then',
|
|
334
|
+
'// fails authentication (SSH_ASKPASS_REQUIRE=force trades the tty prompt',
|
|
335
|
+
'// for the bridge; the child only enables it when a credential exists).',
|
|
336
|
+
"'use strict'",
|
|
337
|
+
'const { readFileSync } = require("node:fs")',
|
|
338
|
+
'const { join } = require("node:path")',
|
|
339
|
+
'const http = require("node:http")',
|
|
340
|
+
'function main() {',
|
|
341
|
+
' let cfg',
|
|
342
|
+
' try { cfg = JSON.parse(readFileSync(join(__dirname, "term-secret.json"), "utf8")) } catch { process.exit(2) }',
|
|
343
|
+
' const body = JSON.stringify({',
|
|
344
|
+
' host: process.env.DSH_TS_HOST || "",',
|
|
345
|
+
' port: Number(process.env.DSH_TS_PORT) || 22,',
|
|
346
|
+
' username: process.env.DSH_TS_USERNAME || "",',
|
|
347
|
+
' alias: process.env.DSH_TS_ALIAS || "",',
|
|
348
|
+
' })',
|
|
349
|
+
' const base = String(cfg.url || "").replace(/\\/+$/, "")',
|
|
350
|
+
' if (!cfg.token || !base) process.exit(2)',
|
|
351
|
+
' const url = new URL(base + "/dsh-remote/term-secret")',
|
|
352
|
+
' const req = http.request({',
|
|
353
|
+
' method: "POST", host: url.hostname, port: url.port, path: url.pathname,',
|
|
354
|
+
' headers: {',
|
|
355
|
+
' "content-type": "application/json",',
|
|
356
|
+
' authorization: "Bearer " + cfg.token,',
|
|
357
|
+
' "content-length": Buffer.byteLength(body),',
|
|
358
|
+
' },',
|
|
359
|
+
' timeout: 5000,',
|
|
360
|
+
' }, (res) => {',
|
|
361
|
+
' let buf = ""',
|
|
362
|
+
' res.on("data", (chunk) => { buf += chunk })',
|
|
363
|
+
' res.on("end", () => {',
|
|
364
|
+
' try {',
|
|
365
|
+
' const parsed = JSON.parse(buf)',
|
|
366
|
+
' if (res.statusCode === 200 && parsed && parsed.ok && typeof parsed.password === "string" && parsed.password.length > 0) {',
|
|
367
|
+
' process.stdout.write(parsed.password + "\\n")',
|
|
368
|
+
' return',
|
|
369
|
+
' }',
|
|
370
|
+
' } catch { /* malformed answer */ }',
|
|
371
|
+
' process.exit(3)',
|
|
372
|
+
' })',
|
|
373
|
+
' })',
|
|
374
|
+
' req.on("timeout", () => { req.destroy(); process.exit(4) })',
|
|
375
|
+
' req.on("error", () => process.exit(5))',
|
|
376
|
+
' req.end(body)',
|
|
377
|
+
'}',
|
|
378
|
+
'main()',
|
|
379
|
+
'',
|
|
380
|
+
].join('\n')
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Write the askpass helper + its platform wrapper next to the launcher.
|
|
385
|
+
* Called from writeLauncher so an upgrade rewrites both in one place.
|
|
386
|
+
* Carries NO secret: URL + per-boot token land in term-secret.json, written by
|
|
387
|
+
* the host half once the webserver origin is known (and deleted on boot when
|
|
388
|
+
* the composition has no webserver, so a stale bridge can never hijack the
|
|
389
|
+
* prompt on Desktop).
|
|
390
|
+
*
|
|
391
|
+
* @param {{ dir: string, platform?: string, nodePath?: string, fs?: object }} spec
|
|
392
|
+
*/
|
|
393
|
+
export function writeTermSecretHelpers(spec) {
|
|
394
|
+
const platform = spec.platform || process.platform
|
|
395
|
+
const fs = spec.fs || { writeFileSync, chmodSync }
|
|
396
|
+
const node = spec.nodePath || 'node'
|
|
397
|
+
fs.writeFileSync(path.join(spec.dir, 'term-askpass.cjs'), askpassHelperSource(), 'utf8')
|
|
398
|
+
const wrapper = askpassWrapperPath(spec.dir, platform)
|
|
399
|
+
if (platform === 'win32') {
|
|
400
|
+
fs.writeFileSync(wrapper, [
|
|
401
|
+
'@echo off',
|
|
402
|
+
'rem Generated by dsh-remote - do not edit; rewritten on every load.',
|
|
403
|
+
`"${node}" "%~dp0term-askpass.cjs" %*`,
|
|
404
|
+
'',
|
|
405
|
+
].join('\r\n'), 'utf8')
|
|
406
|
+
} else {
|
|
407
|
+
fs.writeFileSync(wrapper, [
|
|
408
|
+
'#!/bin/sh',
|
|
409
|
+
'# Generated by dsh-remote - do not edit; rewritten on every load.',
|
|
410
|
+
`exec ${shqPosix(node)} "$(dirname -- "$0")/term-askpass.cjs" "$@"`,
|
|
411
|
+
'',
|
|
412
|
+
].join('\n'), 'utf8')
|
|
413
|
+
try { fs.chmodSync(wrapper, 0o755) } catch { /* mode-less fs */ }
|
|
414
|
+
}
|
|
415
|
+
return { wrapper, helper: path.join(spec.dir, 'term-askpass.cjs') }
|
|
416
|
+
}
|
|
417
|
+
|
|
304
418
|
/**
|
|
305
419
|
* Remove a launcher left on disk under another spelling of the same name.
|
|
306
420
|
*
|
|
@@ -353,7 +467,10 @@ export function writeLauncher(spec) {
|
|
|
353
467
|
if (platform !== 'win32') {
|
|
354
468
|
try { fs.chmodSync(file, 0o755) } catch { /* a no-op on filesystems without modes */ }
|
|
355
469
|
}
|
|
356
|
-
|
|
470
|
+
// The credential-bridge helper travels with the launcher (same rewrite
|
|
471
|
+
// cadence, same directory the launcher exports as DSH_TERM_DIR).
|
|
472
|
+
const helpers = writeTermSecretHelpers({ dir: spec.dir, platform, nodePath: spec.nodePath || '', fs })
|
|
473
|
+
return { path: file, source, askpass: helpers.wrapper }
|
|
357
474
|
}
|
|
358
475
|
|
|
359
476
|
/**
|
package/lib/sync.js
CHANGED
|
@@ -39,49 +39,94 @@ function mapLimit(items, limit, fn) {
|
|
|
39
39
|
const keyOf = (size, mtime) => `${size}:${Math.floor(mtime || 0)}`
|
|
40
40
|
const localKey = (st) => (st ? keyOf(st.size, st.mtimeMs / 1000) : null)
|
|
41
41
|
const remoteKey = (st) => (st ? keyOf(st.size, st.mtime) : null)
|
|
42
|
+
const isChannelError = (err) => /sftp (?:channel closed|operation timed out)/i.test(String((err && err.message) || err))
|
|
42
43
|
|
|
43
44
|
/** Recursively pull remote → local mirror (three-way, ignore-aware). */
|
|
44
45
|
export async function syncTree(sftp, remoteDir, localDir, opts = {}) {
|
|
45
46
|
const {
|
|
46
|
-
maxDepth = 8,
|
|
47
|
+
maxDepth = opts.depth ?? 8,
|
|
47
48
|
maxFiles = 2000,
|
|
48
49
|
maxFileBytes = 0,
|
|
49
50
|
isIgnored = () => false,
|
|
50
51
|
dryRun = false,
|
|
51
52
|
force = false,
|
|
52
53
|
state = {},
|
|
54
|
+
getSftp = null,
|
|
55
|
+
maxReconnects = 2,
|
|
53
56
|
} = opts
|
|
54
|
-
const stats = {
|
|
57
|
+
const stats = {
|
|
58
|
+
files: 0,
|
|
59
|
+
dirs: 0,
|
|
60
|
+
skippedUnchanged: 0,
|
|
61
|
+
skippedLarge: 0,
|
|
62
|
+
failed: 0,
|
|
63
|
+
abortedError: '',
|
|
64
|
+
conflicts: [],
|
|
65
|
+
staleRemote: 0,
|
|
66
|
+
touched: [],
|
|
67
|
+
truncated: false,
|
|
68
|
+
}
|
|
55
69
|
const nextState = { ...state }
|
|
70
|
+
let curSftp = sftp
|
|
71
|
+
let channelDead = false
|
|
72
|
+
let reconnects = 0
|
|
73
|
+
let reconnecting = null
|
|
56
74
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
const reconnectSftp = async (failedSurface) => {
|
|
76
|
+
if (typeof getSftp !== 'function' || reconnects >= maxReconnects) return null
|
|
77
|
+
if (curSftp && curSftp !== failedSurface) return curSftp
|
|
78
|
+
if (!reconnecting) {
|
|
79
|
+
reconnecting = (async () => {
|
|
80
|
+
reconnects++
|
|
81
|
+
const next = await getSftp()
|
|
82
|
+
if (next) curSftp = next
|
|
83
|
+
return next
|
|
84
|
+
})().finally(() => { reconnecting = null })
|
|
85
|
+
}
|
|
86
|
+
return reconnecting
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const callSftp = async (fn) => {
|
|
90
|
+
if (channelDead) throw new Error(stats.abortedError || 'sftp channel closed')
|
|
91
|
+
const surface = curSftp
|
|
92
|
+
try {
|
|
93
|
+
return await fn(surface)
|
|
94
|
+
} catch (err) {
|
|
95
|
+
if (isChannelError(err)) {
|
|
96
|
+
try {
|
|
97
|
+
const next = await reconnectSftp(surface)
|
|
98
|
+
if (next) return await fn(next)
|
|
99
|
+
} catch (retryErr) {
|
|
100
|
+
if (isChannelError(retryErr)) err = retryErr
|
|
101
|
+
else throw retryErr
|
|
102
|
+
}
|
|
103
|
+
channelDead = true
|
|
104
|
+
if (!stats.abortedError) stats.abortedError = String((err && err.message) || err)
|
|
68
105
|
}
|
|
69
|
-
|
|
70
|
-
const lp = path.join(lDir, name)
|
|
71
|
-
const rel = relPathUnder(remoteDir, rp) || name
|
|
72
|
-
if (isIgnored(rel, true)) continue
|
|
73
|
-
if (!existsSync(lp)) mkdirSync(lp, { recursive: true })
|
|
74
|
-
await walk(rp, lp, depth - 1)
|
|
75
|
-
stats.dirs++
|
|
76
|
-
if (stats.files >= maxFiles) break
|
|
106
|
+
throw err
|
|
77
107
|
}
|
|
78
|
-
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const walk = async (rDir, lDir, depth) => {
|
|
111
|
+
if (channelDead) return
|
|
112
|
+
let entries
|
|
113
|
+
try {
|
|
114
|
+
entries = (await callSftp((s) => s.readdir(rDir))) || []
|
|
115
|
+
} catch {
|
|
116
|
+
stats.failed++
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
if (!dryRun && !existsSync(lDir)) mkdirSync(lDir, { recursive: true })
|
|
79
120
|
|
|
121
|
+
// Sync files in the current directory BEFORE recursing into subdirectories,
|
|
122
|
+
// so shallow/root-level files are never starved when a deep subtree hits
|
|
123
|
+
// maxFiles or an SFTP timeout.
|
|
80
124
|
const files = entries.filter(
|
|
81
125
|
(e) => !(e.attrs && e.attrs.isDirectory && e.attrs.isDirectory()) &&
|
|
82
126
|
String(e.filename) !== '.' && String(e.filename) !== '..',
|
|
83
127
|
)
|
|
84
128
|
await mapLimit(files, 4, async (e) => {
|
|
129
|
+
if (channelDead) return
|
|
85
130
|
if (stats.files >= maxFiles) { stats.truncated = true; return }
|
|
86
131
|
const name = String(e.filename)
|
|
87
132
|
const rp = joinRemotePath(rDir, name)
|
|
@@ -89,7 +134,12 @@ export async function syncTree(sftp, remoteDir, localDir, opts = {}) {
|
|
|
89
134
|
const rel = relPathUnder(remoteDir, rp) || name
|
|
90
135
|
if (isIgnored(rel, false)) return
|
|
91
136
|
let r
|
|
92
|
-
try {
|
|
137
|
+
try {
|
|
138
|
+
r = await callSftp((s) => s.stat(rp))
|
|
139
|
+
} catch {
|
|
140
|
+
stats.failed++
|
|
141
|
+
return
|
|
142
|
+
}
|
|
93
143
|
if (maxFileBytes > 0 && r.size > maxFileBytes) { stats.skippedLarge++; return }
|
|
94
144
|
const rk = remoteKey(r)
|
|
95
145
|
const sk = state[rel] ? keyOf(state[rel].size, state[rel].mtime) : null
|
|
@@ -114,14 +164,39 @@ export async function syncTree(sftp, remoteDir, localDir, opts = {}) {
|
|
|
114
164
|
return
|
|
115
165
|
}
|
|
116
166
|
try {
|
|
117
|
-
const buf = await
|
|
167
|
+
const buf = await callSftp((s) => s.readFile(rp))
|
|
118
168
|
writeFileSync(lp, buf)
|
|
119
169
|
try { utimesSync(lp, new Date(r.mtime * 1000), new Date(r.mtime * 1000)) } catch {}
|
|
120
170
|
stats.files++
|
|
121
171
|
stats.touched.push(rp)
|
|
122
172
|
nextState[rel] = { size: r.size, mtime: r.mtime }
|
|
123
|
-
} catch {
|
|
173
|
+
} catch {
|
|
174
|
+
stats.failed++
|
|
175
|
+
}
|
|
124
176
|
})
|
|
177
|
+
if (channelDead) return
|
|
178
|
+
if (stats.files >= maxFiles) { stats.truncated = true; return }
|
|
179
|
+
|
|
180
|
+
// Subdirectories next (sequential, depth-bounded). Local directories are
|
|
181
|
+
// only created after their remote readdir succeeds, never when SFTP is dead.
|
|
182
|
+
for (const e of entries) {
|
|
183
|
+
if (channelDead) break
|
|
184
|
+
const name = String(e.filename)
|
|
185
|
+
if (name === '.' || name === '..') continue
|
|
186
|
+
const isDir = !!(e.attrs && e.attrs.isDirectory && e.attrs.isDirectory())
|
|
187
|
+
if (!isDir) continue
|
|
188
|
+
if (depth <= 0 || stats.files >= maxFiles) {
|
|
189
|
+
stats.truncated = true
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
const rp = joinRemotePath(rDir, name)
|
|
193
|
+
const lp = path.join(lDir, name)
|
|
194
|
+
const rel = relPathUnder(remoteDir, rp) || name
|
|
195
|
+
if (isIgnored(rel, true)) continue
|
|
196
|
+
await walk(rp, lp, depth - 1)
|
|
197
|
+
if (!channelDead) stats.dirs++
|
|
198
|
+
if (stats.files >= maxFiles) { stats.truncated = true; break }
|
|
199
|
+
}
|
|
125
200
|
}
|
|
126
201
|
|
|
127
202
|
await walk(remoteDir, localDir, maxDepth)
|
package/lib/tui/i18n.js
CHANGED
|
@@ -23,7 +23,7 @@ const DICT = {
|
|
|
23
23
|
'status.detailRemote': '远端 {path}',
|
|
24
24
|
|
|
25
25
|
// ── 机器列表 ──────────────────────────────────────────────────────────
|
|
26
|
-
'list.hints': '↑↓ 选择 ·
|
|
26
|
+
'list.hints': '↑↓ 选择 · Enter 动作 · a 新增 · c 连接 · t 探测 · b 浏览 · o 镜像 · e 编辑 · d 删除 · ←/Esc 关闭',
|
|
27
27
|
'list.empty': '还没有保存的远程机 —— 按 a 添加一台',
|
|
28
28
|
'list.count': '{count} 台机器',
|
|
29
29
|
'list.current': '当前',
|
|
@@ -32,7 +32,6 @@ const DICT = {
|
|
|
32
32
|
// ── 动作菜单 ──────────────────────────────────────────────────────────
|
|
33
33
|
'menu.title': '动作 · {name}',
|
|
34
34
|
'menu.connect': '连接',
|
|
35
|
-
'menu.workspace': '设为工作区',
|
|
36
35
|
'menu.workspaces': '工作区管理(删除/清理)',
|
|
37
36
|
'menu.edit': '编辑',
|
|
38
37
|
'menu.delete': '删除',
|
|
@@ -117,6 +116,7 @@ const DICT = {
|
|
|
117
116
|
'busy.saving': '正在保存',
|
|
118
117
|
'busy.deleting': '正在删除',
|
|
119
118
|
'busy.settingWorkspace': '正在建立工作区',
|
|
119
|
+
'busy.revealFolder': '正在打开镜像文件夹',
|
|
120
120
|
'busy.loading': '正在加载',
|
|
121
121
|
'busy.loadingMirrors': '正在读取本地镜像工作区',
|
|
122
122
|
'footer.error': '错误:{err}',
|
|
@@ -130,11 +130,11 @@ const DICT = {
|
|
|
130
130
|
'notify.probeFailed': '探测失败:{err}',
|
|
131
131
|
'notify.saved': '已保存 {name}',
|
|
132
132
|
'notify.deleted': '已删除 {name}',
|
|
133
|
+
'notify.revealed': '已在文件管理器中打开 {path}',
|
|
133
134
|
'notify.workspaceSet': '已采用工作区 {label}',
|
|
134
135
|
'notify.switchRefused': '宿主拒绝切换到 {label}',
|
|
135
136
|
'notify.switchFailed': '切换工作区失败:{err}',
|
|
136
137
|
'notify.pickFailed': '无法采用该目录:{err}',
|
|
137
|
-
'notify.noWorkspace': '该机器还没有记录的工作区,正在打开目录浏览',
|
|
138
138
|
'notify.warnings': '警告:{text}',
|
|
139
139
|
|
|
140
140
|
// ── 无场景时的对话框降级流程 ──────────────────────────────────────────
|
|
@@ -175,7 +175,7 @@ const DICT = {
|
|
|
175
175
|
'status.detailTarget': '{user}@{host}:{port}',
|
|
176
176
|
'status.detailRemote': 'remote {path}',
|
|
177
177
|
|
|
178
|
-
'list.hints': '↑↓ select ·
|
|
178
|
+
'list.hints': '↑↓ select · Enter actions · a add · c connect · t probe · b browse · o mirror · e edit · d delete · ←/Esc close',
|
|
179
179
|
'list.empty': 'no saved machines yet — press a to add one',
|
|
180
180
|
'list.count': '{count} machines',
|
|
181
181
|
'list.current': 'current',
|
|
@@ -183,7 +183,6 @@ const DICT = {
|
|
|
183
183
|
|
|
184
184
|
'menu.title': 'Actions · {name}',
|
|
185
185
|
'menu.connect': 'Connect',
|
|
186
|
-
'menu.workspace': 'Use as workspace',
|
|
187
186
|
'menu.workspaces': 'Manage workspaces (delete)',
|
|
188
187
|
'menu.edit': 'Edit',
|
|
189
188
|
'menu.delete': 'Delete',
|
|
@@ -262,6 +261,7 @@ const DICT = {
|
|
|
262
261
|
'busy.saving': 'saving',
|
|
263
262
|
'busy.deleting': 'deleting',
|
|
264
263
|
'busy.settingWorkspace': 'creating workspace',
|
|
264
|
+
'busy.revealFolder': 'opening mirror folder',
|
|
265
265
|
'busy.loading': 'loading',
|
|
266
266
|
'busy.loadingMirrors': 'loading local mirror workspaces',
|
|
267
267
|
'footer.error': 'error: {err}',
|
|
@@ -274,11 +274,11 @@ const DICT = {
|
|
|
274
274
|
'notify.probeFailed': 'probe failed: {err}',
|
|
275
275
|
'notify.saved': 'saved {name}',
|
|
276
276
|
'notify.deleted': 'deleted {name}',
|
|
277
|
+
'notify.revealed': 'opened {path} in the file manager',
|
|
277
278
|
'notify.workspaceSet': 'workspace adopted: {label}',
|
|
278
279
|
'notify.switchRefused': 'the host refused to switch to {label}',
|
|
279
280
|
'notify.switchFailed': 'workspace switch failed: {err}',
|
|
280
281
|
'notify.pickFailed': 'cannot adopt this directory: {err}',
|
|
281
|
-
'notify.noWorkspace': 'this machine has no recorded workspace yet — opening the directory browser',
|
|
282
282
|
'notify.warnings': 'warning: {text}',
|
|
283
283
|
|
|
284
284
|
'flow.add': '+ Add remote machine',
|
package/lib/tui/scene.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from './format.js'
|
|
23
23
|
|
|
24
24
|
/** 动作菜单项(顺序即渲染顺序)。 */
|
|
25
|
-
const MENU_ACTIONS = ['connect', '
|
|
25
|
+
const MENU_ACTIONS = ['connect', 'workspaces', 'edit', 'delete', 'probe', 'browse']
|
|
26
26
|
/** 表单里永远出现的字段。 */
|
|
27
27
|
const BASE_FORM_FIELDS = ['name', 'host', 'useSshConfig', 'port', 'username', 'auth']
|
|
28
28
|
|
|
@@ -294,6 +294,14 @@ export function createSceneComponent({ api, config, i18n, notify } = {}) {
|
|
|
294
294
|
await reload()
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
+
/** 在系统文件管理器里打开本机 dsh-remote 的镜像根目录(remote-workspaces)。 */
|
|
298
|
+
async function revealMirrorFolder() {
|
|
299
|
+
if (typeof api.revealMirrorFolder !== 'function') return
|
|
300
|
+
const result = await runOp(t('busy.revealFolder'), () => api.revealMirrorFolder())
|
|
301
|
+
if (!result) return
|
|
302
|
+
toast(t('notify.revealed', { path: result.path }), { color: 'success' })
|
|
303
|
+
}
|
|
304
|
+
|
|
297
305
|
async function probeMachine(machine) {
|
|
298
306
|
if (!machine || typeof api.probeMachine !== 'function') return
|
|
299
307
|
const patch = {
|
|
@@ -330,22 +338,6 @@ export function createSceneComponent({ api, config, i18n, notify } = {}) {
|
|
|
330
338
|
await reload()
|
|
331
339
|
}
|
|
332
340
|
|
|
333
|
-
async function ensureMachineWorkspace(machine) {
|
|
334
|
-
if (!machine) return
|
|
335
|
-
if (!machine.workspace) {
|
|
336
|
-
toast(t('notify.noWorkspace'), { color: 'warning' })
|
|
337
|
-
openBrowse(machine)
|
|
338
|
-
return
|
|
339
|
-
}
|
|
340
|
-
const workspace = await runOp(t('busy.settingWorkspace'), () => api.ensureRemoteWorkspace({
|
|
341
|
-
machineId: machine.id,
|
|
342
|
-
remotePath: machine.workspace,
|
|
343
|
-
register: true,
|
|
344
|
-
}))
|
|
345
|
-
if (!workspace) return
|
|
346
|
-
await adoptWorkspace(machine, workspace, machine.workspace)
|
|
347
|
-
}
|
|
348
|
-
|
|
349
341
|
async function pickBrowseWorkspace() {
|
|
350
342
|
const current = browse
|
|
351
343
|
if (!current) return
|
|
@@ -532,7 +524,6 @@ export function createSceneComponent({ api, config, i18n, notify } = {}) {
|
|
|
532
524
|
if (!machine) return
|
|
533
525
|
switch (action) {
|
|
534
526
|
case 'connect': void connectMachine(machine); break
|
|
535
|
-
case 'workspace': void ensureMachineWorkspace(machine); break
|
|
536
527
|
case 'workspaces': openWorkspaces(machine); break
|
|
537
528
|
case 'edit': openForm(machine); break
|
|
538
529
|
case 'delete': openConfirm(machine); break
|
|
@@ -582,7 +573,7 @@ export function createSceneComponent({ api, config, i18n, notify } = {}) {
|
|
|
582
573
|
case 'd': openConfirm(selectedMachine); break
|
|
583
574
|
case 't': void probeMachine(selectedMachine); break
|
|
584
575
|
case 'b': openBrowse(selectedMachine); break
|
|
585
|
-
case '
|
|
576
|
+
case 'o': void revealMirrorFolder(); break
|
|
586
577
|
default: break
|
|
587
578
|
}
|
|
588
579
|
}
|
|
@@ -611,7 +602,6 @@ export function createSceneComponent({ api, config, i18n, notify } = {}) {
|
|
|
611
602
|
else if (input === 'd') executeAction('delete', selectedMachine)
|
|
612
603
|
else if (input === 't') executeAction('probe', selectedMachine)
|
|
613
604
|
else if (input === 'b') executeAction('browse', selectedMachine)
|
|
614
|
-
else if (input === 'w') executeAction('workspace', selectedMachine)
|
|
615
605
|
else if (input === 'm') executeAction('workspaces', selectedMachine)
|
|
616
606
|
}
|
|
617
607
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.82",
|
|
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>",
|