dsh-remote 0.4.1 → 0.4.3
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/lib/client.js +23 -14
- package/lib/index.js +16 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -66,6 +66,7 @@ window.__ModuleLoader__.load({
|
|
|
66
66
|
}).then((r) => { refresh(); setForm({ name: '', host: '', port: '22', username: 'root', password: '', privateKeyPath: '', id: '' }); setMsg(form.id ? '已保存更新' : '已添加 — 可设为当前') }).catch((e) => setErr(String((e && e.message) || e))).finally(() => setBusy(false))
|
|
67
67
|
}
|
|
68
68
|
const useNow = (id) => { setBusy(true); api('POST', '/dsh-remote/current', { id }).then((r) => { setCurrentId(r.currentId); setMsg('已切换为当前远程机') }).catch((e) => setErr(String((e && e.message) || e))).finally(() => setBusy(false)) }
|
|
69
|
+
const del = (id) => { if (window.confirm('确定删除这台机器?')) { api('POST', '/dsh-remote/machines', { action: 'delete', id }).then(refresh).then(() => setMsg('已删除')).catch((e) => setErr(String((e && e.message) || e))) } }
|
|
69
70
|
|
|
70
71
|
const row = (label, ctrl, k) => React.createElement('div', { key: k, style: { display: 'flex', gap: 6, alignItems: 'center' } },
|
|
71
72
|
React.createElement('label', { style: { width: 76, fontSize: 12, opacity: 0.8 } }, label), ctrl)
|
|
@@ -84,6 +85,7 @@ window.__ModuleLoader__.load({
|
|
|
84
85
|
m.passwordSet ? ' 🔒' : '',
|
|
85
86
|
m.id === currentId ? React.createElement('span', { style: { color: T.ok, fontSize: 12 } }, ' · 当前') : null),
|
|
86
87
|
React.createElement('button', { style: buttonS, onClick: () => startEdit(m) }, '编辑'),
|
|
88
|
+
React.createElement('button', { style: buttonS, onClick: () => del(m.id) }, '删除'),
|
|
87
89
|
React.createElement('button', { style: buttonS, onClick: () => useNow(m.id), disabled: m.id === currentId }, '设为当前')))
|
|
88
90
|
: React.createElement('div', { style: { opacity: 0.6, fontSize: 12 } }, '还没有机器。在下方添加。'),
|
|
89
91
|
),
|
|
@@ -110,11 +112,16 @@ window.__ModuleLoader__.load({
|
|
|
110
112
|
function parseLs(text) {
|
|
111
113
|
const out = []
|
|
112
114
|
for (const ln of String(text || '').split('\n')) {
|
|
113
|
-
const
|
|
114
|
-
if (!
|
|
115
|
-
|
|
115
|
+
const t = ln.trim()
|
|
116
|
+
if (!t || !t.length || /^total\b/i.test(t)) continue
|
|
117
|
+
const parts = t.split(/\s+/).filter(Boolean)
|
|
118
|
+
if (parts.length < 2) continue
|
|
119
|
+
const mode = parts[0]
|
|
120
|
+
const name = parts[parts.length - 1]
|
|
121
|
+
if (name === '.' || name === '..') continue
|
|
122
|
+
const isDirL = mode.charAt(0) === 'd'
|
|
123
|
+
out.push((isDirL ? '📁' : '📄') + name)
|
|
116
124
|
}
|
|
117
|
-
if (!out.length && String(text || '').trim()) out.push(...String(text).trim().split('\n').slice(1).map((l) => '📄 ' + l.trim()).filter(Boolean))
|
|
118
125
|
return out
|
|
119
126
|
}
|
|
120
127
|
|
|
@@ -131,14 +138,15 @@ window.__ModuleLoader__.load({
|
|
|
131
138
|
React.useEffect(() => { if (open) { api('GET', '/dsh-remote/machines').then((r) => { setMachines(r.machines || []); setMachineId(r.currentId || (r.machines && r.machines[0] && r.machines[0].id) || '') }) } }, [open])
|
|
132
139
|
|
|
133
140
|
const chooseLocal = () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
setLoading(true); setErr('')
|
|
142
|
+
api('POST', '/dsh-remote/local-pick')
|
|
143
|
+
.then((r) => {
|
|
144
|
+
if (r && r.path) onPicked(String(r.path))
|
|
145
|
+
else if (r && r.cancelled) setErr('已取消选择')
|
|
146
|
+
else setErr((r && r.error) || '无法打开系统文件夹选择器,可直接在输入框填本地路径')
|
|
147
|
+
})
|
|
148
|
+
.catch((e) => setErr(String((e && e.message) || e) + ' — 可直接在输入框填本地路径'))
|
|
149
|
+
.finally(() => setLoading(false))
|
|
142
150
|
}
|
|
143
151
|
|
|
144
152
|
const switchTab = (t) => { setTab(t); setErr(''); if (t === 'remote' && machineId) loadRemote(machineId, '') }
|
|
@@ -180,7 +188,8 @@ window.__ModuleLoader__.load({
|
|
|
180
188
|
React.createElement('input', { value: path, onChange: (e) => setPath(e.target.value), placeholder: '本机目录,如 C:\\Users\\you\\project', style: inputS }),
|
|
181
189
|
React.createElement('button', { style: buttonS, onClick: () => (path.trim() ? onPicked(path) : undefined), disabled: !path.trim() }, '选用此本地路径'),
|
|
182
190
|
),
|
|
183
|
-
React.createElement('button', { style: buttonS, onClick: chooseLocal, disabled: loading }, '打开系统文件夹选择器'),
|
|
191
|
+
React.createElement('button', { style: { ...buttonS, alignSelf: 'flex-start' }, onClick: chooseLocal, disabled: loading }, loading ? '打开中…' : '打开系统文件夹选择器'),
|
|
192
|
+
err ? React.createElement('div', { style: { color: T.danger, fontSize: 12 } }, err) : null,
|
|
184
193
|
)
|
|
185
194
|
: React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 8 } },
|
|
186
195
|
React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center' } },
|
|
@@ -212,7 +221,7 @@ window.__ModuleLoader__.load({
|
|
|
212
221
|
function apply(ctx) {
|
|
213
222
|
const slots = ctx.get('slots')
|
|
214
223
|
if (slots === undefined) return
|
|
215
|
-
WORKSPACES = (ctx && ctx.get && ctx.get('workspaces')) || null
|
|
224
|
+
WORKSPACES = (ctx && ((ctx.get && ctx.get('workspaces')) || ctx.workspaces)) || null
|
|
216
225
|
slots.inject('settings.section', () =>
|
|
217
226
|
slots.register({ name: 'settings.section', id: 'dsh-remote', priority: 40, label: () => '远程工作区' }, () => React.createElement(RemoteWorkspacePage, null)),
|
|
218
227
|
)
|
package/lib/index.js
CHANGED
|
@@ -824,6 +824,22 @@ export async function apply(ctx, config) {
|
|
|
824
824
|
}
|
|
825
825
|
},
|
|
826
826
|
},
|
|
827
|
+
{
|
|
828
|
+
kind: 'exact',
|
|
829
|
+
path: '/dsh-remote/local-pick',
|
|
830
|
+
handler: async (req, res) => {
|
|
831
|
+
if (req.method !== 'POST') return sendJson(res, 405, { ok: false, error: 'method not allowed' })
|
|
832
|
+
try {
|
|
833
|
+
const dp = (ctx && ctx.get && ctx.get('directoryPicker')) || (ctx && ctx.directoryPicker) || null
|
|
834
|
+
if (!dp || typeof dp.pick !== 'function') return sendJson(res, 400, { ok: false, error: '本地目录选择器不可用(本机需 DSH 原生 directory-picker backend)' })
|
|
835
|
+
const picked = await Promise.resolve(dp.pick())
|
|
836
|
+
if (!picked || typeof picked !== 'string') return sendJson(res, 200, { ok: true, cancelled: true })
|
|
837
|
+
return sendJson(res, 200, { ok: true, path: picked })
|
|
838
|
+
} catch (err) {
|
|
839
|
+
return sendJson(res, 500, { ok: false, error: String((err && err.message) || err) })
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
},
|
|
827
843
|
{
|
|
828
844
|
kind: 'exact',
|
|
829
845
|
path: '/dsh-remote/machines',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Remote-work assistant for DeepSeek Harness: connect SSH (password or key), pick a remote workspace, operate on it with rw_pick_workspace / rw_list_dir / rw_read_file / rw_exec / rw_sync tools, and mirror it to a real local directory (SFTP) so the DSH native workspace can adopt it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|