dsh-remote 0.8.86 → 0.8.87

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 CHANGED
@@ -229,6 +229,21 @@ window.__ModuleLoader__.load({
229
229
  'settings.fwdTargetPort': '目标端口',
230
230
  'settings.fwdAuto': '自动重连',
231
231
  'settings.fwdAdd': '添加转发',
232
+ 'settings.cleanup': '工作区清理(本地镜像与对话)',
233
+ 'settings.cleanupRefresh': '刷新',
234
+ 'settings.cleanupEmpty': '没有本地镜像。选定一个远程工作区后它会出现在这里。',
235
+ 'settings.cleanupChats': ' 个对话',
236
+ 'settings.cleanupLive': '有会话在用',
237
+ 'settings.cleanupSessions': '删对话',
238
+ 'settings.cleanupSessionsHint': '只删该工作区的全部对话(保留镜像与登记);被占用的会话会跳过',
239
+ 'settings.cleanupRecent': '移出最近',
240
+ 'settings.cleanupRecentHint': '把工作区从「最近列表/当前工作区」移出,不删镜像(止住自动重建)',
241
+ 'settings.cleanupAll': '彻底删除',
242
+ 'settings.cleanupAllHint': '对话 + 登记 + 最近记录 + 本地镜像全部删除(远端目录不动),不可恢复',
243
+ 'settings.cleanupConfirmAll': '彻底删除工作区「{path}」?它的全部对话、工作区登记、最近记录和本地镜像都会被删除(远端目录不动)。此操作不可恢复。',
244
+ 'settings.cleanupConfirmSessions': '删除工作区「{path}」的全部对话?镜像与登记保留。',
245
+ 'settings.cleanupDone': '已删除',
246
+ 'settings.cleanupFailed': '操作失败:{msg}',
232
247
  'settings.audit': '最近执行的远程命令(审计日志)',
233
248
  'settings.auditEmpty': '暂无记录(在远端执行的命令会记录到 $DSH_HOME/remote-workspaces/audit.log)',
234
249
  'settings.auditRefresh': '刷新日志',
@@ -543,6 +558,21 @@ window.__ModuleLoader__.load({
543
558
  'settings.fwdTargetPort': 'Target port',
544
559
  'settings.fwdAuto': 'Auto reconnect',
545
560
  'settings.fwdAdd': 'Add forward',
561
+ 'settings.cleanup': 'Workspace cleanup (local mirrors & chats)',
562
+ 'settings.cleanupRefresh': 'Refresh',
563
+ 'settings.cleanupEmpty': 'No local mirrors yet. Pick a remote workspace and it shows up here.',
564
+ 'settings.cleanupChats': ' chats',
565
+ 'settings.cleanupLive': 'in use',
566
+ 'settings.cleanupSessions': 'Delete chats',
567
+ 'settings.cleanupSessionsHint': 'Delete only this workspace\'s chats (mirror and registration stay); occupied sessions are skipped',
568
+ 'settings.cleanupRecent': 'Forget',
569
+ 'settings.cleanupRecentHint': 'Remove the workspace from the recent/current lists without deleting the mirror (stops auto-recreation)',
570
+ 'settings.cleanupAll': 'Delete forever',
571
+ 'settings.cleanupAllHint': 'Chats + registration + recent entry + the local mirror all go (the REMOTE directory is untouched). Irreversible',
572
+ 'settings.cleanupConfirmAll': 'Permanently delete workspace "{path}"? All its chats, the registration, the recent entry and the local mirror are removed (the remote directory stays). This cannot be undone.',
573
+ 'settings.cleanupConfirmSessions': 'Delete all chats of workspace "{path}"? The mirror and registration stay.',
574
+ 'settings.cleanupDone': 'Deleted',
575
+ 'settings.cleanupFailed': 'Failed: {msg}',
546
576
  'settings.audit': 'Recent remote commands (audit log)',
547
577
  'settings.auditEmpty': 'No records yet (commands run remotely are logged to $DSH_HOME/remote-workspaces/audit.log)',
548
578
  'settings.auditRefresh': 'Refresh log',
@@ -1167,6 +1197,34 @@ window.__ModuleLoader__.load({
1167
1197
  // never touch.
1168
1198
  const [fwdOpen, setFwdOpen] = React.useState(false)
1169
1199
  const [auditOpen, setAuditOpen] = React.useState(false)
1200
+ // Issue #96: workspace cleanup on Web/Desktop (the TUI's machine-menu
1201
+ // cleanup page has an in-process API; here it is these two routes).
1202
+ const [cleanupOpen, setCleanupOpen] = React.useState(false)
1203
+ const [cleanupRows, setCleanupRows] = React.useState([])
1204
+ const [cleanupBusy, setCleanupBusy] = React.useState('')
1205
+ const [cleanupMsg, setCleanupMsg] = React.useState('')
1206
+ const loadCleanup = () => api('GET', '/dsh-remote/workspace-mirrors')
1207
+ .then((r) => { if (r && r.ok) setCleanupRows(r.mirrors || []) })
1208
+ .catch(() => {})
1209
+ // Opening the section loads the list: a wrapped setter, not an effect —
1210
+ // the effect would refire on every cleanupOpen-keyed re-render.
1211
+ const openCleanupSection = (v) => { setCleanupOpen(v); if (v) loadCleanup() }
1212
+ const cleanupAct = async (row, mode) => {
1213
+ const label = row.remotePath || row.localMirror
1214
+ if (mode === 'all' && !(await confirmUi.ask(tr('settings.cleanupConfirmAll', { path: label })))) return
1215
+ if (mode === 'sessions' && !(await confirmUi.ask(tr('settings.cleanupConfirmSessions', { path: label })))) return
1216
+ setCleanupBusy(row.localMirror + ':' + mode)
1217
+ setCleanupMsg('')
1218
+ try {
1219
+ const r = await api('POST', '/dsh-remote/workspace-cleanup', { localMirror: row.localMirror, mode })
1220
+ if (r && r.ok) { setCleanupMsg(tr('settings.cleanupDone')); await loadCleanup() }
1221
+ else setCleanupMsg(tr('settings.cleanupFailed', { msg: (r && r.error) || 'unknown' }))
1222
+ } catch (e) {
1223
+ // api() throws with the host's user-facing message (incl. WORKSPACE_BUSY).
1224
+ setCleanupMsg(tr('settings.cleanupFailed', { msg: String((e && e.message) || e) }))
1225
+ }
1226
+ setCleanupBusy('')
1227
+ }
1170
1228
  // Issue #46: attach a REMOTE machine's DSH Web UI as a local page. One
1171
1229
  // session per machine; `webAttach` holds the machineId currently opening.
1172
1230
  const [webAttaches, setWebAttaches] = React.useState([])
@@ -1998,6 +2056,46 @@ window.__ModuleLoader__.load({
1998
2056
  : React.createElement('div', { style: { opacity: 0.6, fontSize: 12 } }, tr('settings.auditEmpty')))
1999
2057
  : React.createElement('div', { style: { fontSize: 11, opacity: 0.55 } }, String(auditLines.length)),
2000
2058
  ),
2059
+ // 工作区清理(issue #96):TUI 的机器菜单清理页在 Web/Desktop 的同义词。
2060
+ React.createElement('div', { style: boxS },
2061
+ sectionToggle(cleanupOpen, openCleanupSection, tr('settings.cleanup'),
2062
+ React.createElement('button', {
2063
+ type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px', fontSize: 12, marginLeft: 'auto' },
2064
+ onClick: (e) => { e.stopPropagation(); loadCleanup() },
2065
+ }, tr('settings.cleanupRefresh'))),
2066
+ cleanupOpen
2067
+ ? (cleanupRows.length
2068
+ ? React.createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: 4 } },
2069
+ cleanupRows.map((row) => React.createElement('div', {
2070
+ key: row.localMirror,
2071
+ style: { display: 'flex', alignItems: 'center', gap: 8, padding: '5px 6px', borderRadius: 6, border: '1px solid ' + T.border, fontSize: 12 },
2072
+ },
2073
+ React.createElement('div', { style: { flex: 1, minWidth: 0 } },
2074
+ React.createElement('div', { style: { fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, row.title || row.machineName || row.host),
2075
+ React.createElement('code', { style: { fontSize: 11, opacity: 0.7, wordBreak: 'break-all' } }, row.remotePath)),
2076
+ React.createElement('span', { style: { fontSize: 11, opacity: 0.65, flexShrink: 0, whiteSpace: 'nowrap' } },
2077
+ humanSize(row.mirrorBytes) + (row.mirrorSizeTruncated ? '+' : '') + ' · ' + row.sessionCount + tr('settings.cleanupChats') + (row.liveSessionCount > 0 ? ' · ' + tr('settings.cleanupLive') : '')),
2078
+ React.createElement('button', {
2079
+ type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px', fontSize: 11 },
2080
+ disabled: cleanupBusy !== '', title: tr('settings.cleanupSessionsHint'),
2081
+ onClick: () => cleanupAct(row, 'sessions'),
2082
+ }, tr('settings.cleanupSessions')),
2083
+ React.createElement('button', {
2084
+ type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px', fontSize: 11 },
2085
+ disabled: cleanupBusy !== '', title: tr('settings.cleanupRecentHint'),
2086
+ onClick: () => cleanupAct(row, 'recent'),
2087
+ }, tr('settings.cleanupRecent')),
2088
+ React.createElement('button', {
2089
+ type: 'button', className: 'dsh-rw-btn', style: { ...buttonS, padding: '2px 8px', fontSize: 11, color: T.dangerText },
2090
+ disabled: cleanupBusy !== '', title: tr('settings.cleanupAllHint'),
2091
+ onClick: () => cleanupAct(row, 'all'),
2092
+ }, tr('settings.cleanupAll')))))
2093
+ : React.createElement('div', { style: { opacity: 0.6, fontSize: 12 } }, tr('settings.cleanupEmpty')))
2094
+ : null,
2095
+ cleanupOpen && cleanupMsg
2096
+ ? React.createElement('div', { style: { fontSize: 11, marginTop: 6, lineHeight: 1.5, wordBreak: 'break-all', color: /失败|failed|拒绝|busy/i.test(cleanupMsg) ? T.warn : T.ok } }, cleanupMsg)
2097
+ : null,
2098
+ ),
2001
2099
  // Panel-level messages. They used to live ONLY inside the manual form, which is
2002
2100
  // collapsed by default now — so "已打开远程工作区 …" and a failed 连接 were
2003
2101
  // invisible after clicking something in the list.
package/lib/index.js CHANGED
@@ -4864,6 +4864,55 @@ export async function apply(ctx, config) {
4864
4864
  return sendJson(res, 200, { ok: true, password })
4865
4865
  },
4866
4866
  },
4867
+ {
4868
+ kind: 'exact',
4869
+ path: '/dsh-remote/workspace-mirrors',
4870
+ handler: async (req, res) => {
4871
+ if (req.method !== 'GET') return sendJson(res, 405, { ok: false, error: 'method not allowed' })
4872
+ // The settings page's cleanup section: every local mirror with its
4873
+ // sessions, sizes and occupancy, straight off the in-process API (same
4874
+ // object the TUI consumes — one implementation, two faces).
4875
+ if (!hostApi) return sendJson(res, 503, { ok: false, error: 'in-process API unavailable' })
4876
+ try {
4877
+ return sendJson(res, 200, { ok: true, mirrors: await hostApi.listWorkspaceMirrors({}) })
4878
+ } catch (err) {
4879
+ return sendJson(res, 500, { ok: false, error: String((err && err.message) || err) })
4880
+ }
4881
+ },
4882
+ },
4883
+ {
4884
+ kind: 'exact',
4885
+ path: '/dsh-remote/workspace-cleanup',
4886
+ handler: async (req, res) => {
4887
+ if (req.method !== 'POST') return sendJson(res, 405, { ok: false, error: 'method not allowed' })
4888
+ if (!hostApi) return sendJson(res, 503, { ok: false, error: 'in-process API unavailable' })
4889
+ try {
4890
+ const body = JSON.parse((await readBody(req)) || '{}')
4891
+ const localMirror = String(body.localMirror || '')
4892
+ const mode = String(body.mode || '')
4893
+ if (!localMirror) return sendJson(res, 400, { ok: false, error: 'localMirror is required' })
4894
+ let result
4895
+ if (mode === 'all') {
4896
+ result = await hostApi.deleteRemoteWorkspace({ localMirror, force: body.force === true })
4897
+ } else if (mode === 'sessions') {
4898
+ result = await hostApi.deleteWorkspaceSessions({ localMirror, force: body.force === true })
4899
+ } else if (mode === 'recent') {
4900
+ result = await hostApi.forgetWorkspaceRecent({ localMirror })
4901
+ } else {
4902
+ return sendJson(res, 400, { ok: false, error: 'mode must be all | sessions | recent' })
4903
+ }
4904
+ return sendJson(res, 200, { ok: true, ...result })
4905
+ } catch (err) {
4906
+ // Coded errors carry user-facing messages; WORKSPACE_BUSY must reach
4907
+ // the UI as 409 so the page can say WHICH sessions hold the workspace.
4908
+ const status = (err && err.code === 'WORKSPACE_BUSY') ? 409 : (err && err.code === 'VALIDATION') ? 400 : 500
4909
+ const out = { ok: false, error: String((err && err.message) || err) }
4910
+ if (err && err.code) out.code = err.code
4911
+ if (err && Array.isArray(err.liveSessions)) out.liveSessions = err.liveSessions
4912
+ return sendJson(res, status, out)
4913
+ }
4914
+ },
4915
+ },
4867
4916
  ]
4868
4917
 
4869
4918
  registerHttpTransports(ctx, routes)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-remote",
3
- "version": "0.8.86",
3
+ "version": "0.8.87",
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>",