dsh-ssh-file 1.0.1 → 1.2.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/README.md CHANGED
@@ -24,6 +24,8 @@
24
24
  - `remote_exec` — 执行远程命令(stdout/stderr/退出码,64KB/流上限,超时控制)
25
25
  - `remote_bindings` — 列出当前所有绑定
26
26
  - **自动感知** — 绑定的工作区内,Agent 每轮对话都会被告知当前绑定的服务器与远程根目录,自动使用 remote_* 工具;本地镜像文件夹只是锚点,不含远程文件副本,无同步、无卡顿
27
+ - **远程文件面板(v1.1.0)** — 右侧边栏新增「🌐 远程文件」标签页:浏览远程目录树、点击文件在线预览、编辑并保存回远程主机(绑定会话无需离开 DSH)
28
+ - **远程终端(v1.1.0)** — 绑定远程的工作区里,点「新建终端」直接打开远程主机的 SSH shell,并自动 cd 到绑定的远程目录(或会话子目录);未绑定的会话终端行为完全不变(本地)
27
29
  - **安全** — 密码/私钥通过 DSH 凭据服务存储;远程路径越界防护(所有操作锁定在绑定的远程根目录内)
28
30
 
29
31
  ### 使用
@@ -59,6 +61,8 @@ dsh plugin install dsh-ssh-file
59
61
  - **One-click bind** — picking a remote directory creates a local anchor workspace, registers it with DSH, opens a new session, and binds it to the remote path (sidebar title gets a 🌐 marker)
60
62
  - **Agent tools** — `remote_list`, `remote_read` (256 KB cap + truncation flag), `remote_write`, `remote_mkdir`, `remote_exec` (64 KB/stream cap, timeout, exit code), `remote_bindings`
61
63
  - **Automatic awareness** — sessions in a bound workspace are told which server and remote root they target, so the agent uses the remote tools without being told twice; the local anchor folder holds no copy of remote files — no syncing, no lag
64
+ - **Remote files panel (v1.1.0)** — a "🌐 Remote Files" tab in the right sidebar: browse the remote tree, click a file to preview it, edit and save back to the server without leaving DSH
65
+ - **Remote terminal (v1.1.0)** — in a bound workspace, "New terminal" opens an SSH shell on the remote host, automatically `cd`-ed into the bound remote directory (or the session's subdirectory); unbound sessions keep the local terminal unchanged
62
66
  - **Safety** — path-escape protection locks every operation inside the bound remote root
63
67
 
64
68
  ### Privacy
package/lib/client.js CHANGED
@@ -170,6 +170,15 @@ window.__ModuleLoader__.load({
170
170
  resultSchema(z.object({ binding: bindingSchema }))],
171
171
  bindingDelete: [z.object({ workspacePath: z.string() }), resultSchema(z.object({ removed: z.boolean() }))],
172
172
  ensureLocalMirrorFolder: [z.object({ name: z.string() }), resultSchema(z.object({ path: z.string() }))],
173
+ fileRead: [z.object({ connectionId: z.string(), path: z.string() }),
174
+ resultSchema(z.object({ path: z.string(), data: z.string(), bytes: z.number(), truncated: z.boolean() }))],
175
+ fileWrite: [z.object({ connectionId: z.string(), path: z.string(), data: z.string() }),
176
+ resultSchema(z.object({ path: z.string(), bytes: z.number() }))],
177
+ sessionBinding: [z.object({ sessionId: z.string() }), resultSchema(z.object({
178
+ bindings: z.array(bindingSchema),
179
+ matchWorkspacePath: z.string().nullable(),
180
+ cwd: z.string().nullable(),
181
+ }))],
173
182
  };
174
183
 
175
184
  // ── descriptors (mirror lib/descriptors.js) ─────────────────────────────
@@ -212,6 +221,9 @@ window.__ModuleLoader__.load({
212
221
  def('bindingSave', S.bindingSave[0], 'BindingSaveRequest', S.bindingSave[1], 'BindingSaveResult'),
213
222
  def('bindingDelete', S.bindingDelete[0], 'BindingDeleteRequest', S.bindingDelete[1], 'BindingDeleteResult'),
214
223
  def('ensureLocalMirrorFolder', S.ensureLocalMirrorFolder[0], 'EnsureLocalMirrorFolderRequest', S.ensureLocalMirrorFolder[1], 'EnsureLocalMirrorFolderResult'),
224
+ def('fileRead', S.fileRead[0], 'FileReadRequest', S.fileRead[1], 'FileReadResult'),
225
+ def('fileWrite', S.fileWrite[0], 'FileWriteRequest', S.fileWrite[1], 'FileWriteResult'),
226
+ def('sessionBinding', S.sessionBinding[0], 'SessionBindingRequest', S.sessionBinding[1], 'SessionBindingResult'),
215
227
  ],
216
228
  };
217
229
 
@@ -256,6 +268,10 @@ window.__ModuleLoader__.load({
256
268
  bindingList: () => call('bindingList', {}),
257
269
  bindingSave: (input) => call('bindingSave', input),
258
270
  ensureLocalMirrorFolder: (name) => call('ensureLocalMirrorFolder', { name }),
271
+ fileRead: (connectionId, path) => call('fileRead', { connectionId, path }),
272
+ fileWrite: (connectionId, path, data) => call('fileWrite', { connectionId, path, data }),
273
+ sessionBinding: (sessionId) => call('sessionBinding', { sessionId }),
274
+ sftpMkdir: (connectionId, path) => call('sftpMkdir', { connectionId, path }),
259
275
  renameWorkspace: async (workspaceId, title) => {
260
276
  const ws = ctx.remote?.workspace;
261
277
  if (!ws || typeof ws.rename !== 'function') return false;
@@ -874,7 +890,7 @@ window.__ModuleLoader__.load({
874
890
 
875
891
  // ── composer dock chip: current workspace state ─────────────────────────
876
892
 
877
- function DockChip({ api }) {
893
+ function DockChip({ api, sessionId }) {
878
894
  const [open, setOpen] = useState(false);
879
895
  const [state, setState] = useState(null); // { remotePath, profileName } | 'local' | null
880
896
 
@@ -882,10 +898,12 @@ window.__ModuleLoader__.load({
882
898
  let alive = true;
883
899
  const load = async () => {
884
900
  try {
885
- const ws = await api.bindingList();
901
+ if (!sessionId) { if (alive) setState('local'); return; }
902
+ const r = await api.sessionBinding(sessionId);
886
903
  if (!alive) return;
887
- const bound = Array.isArray(ws?.bindings) ? ws.bindings.find((b) => b.connected || b.autoConnect) : null;
888
- setState(bound ? { remotePath: bound.remotePath, profileName: bound.profileName ?? '' } : 'local');
904
+ const matchPath = r?.matchWorkspacePath ?? null;
905
+ const match = matchPath ? (r.bindings || []).find((b) => b.workspacePath === matchPath) : null;
906
+ setState(match ? { remotePath: match.remotePath, profileName: match.profileName ?? '' } : 'local');
889
907
  } catch {
890
908
  if (alive) setState(null);
891
909
  }
@@ -893,7 +911,7 @@ window.__ModuleLoader__.load({
893
911
  void load();
894
912
  const timer = setInterval(load, 8000);
895
913
  return () => { alive = false; clearInterval(timer); };
896
- }, []);
914
+ }, [api, sessionId]);
897
915
 
898
916
  const label = state && state !== 'local'
899
917
  ? `🗂 ${state.profileName ? state.profileName + ':' : '远程'}${state.remotePath}`
@@ -967,6 +985,300 @@ window.__ModuleLoader__.load({
967
985
  );
968
986
  }
969
987
 
988
+ // ── right-sidebar remote files panel (feature ①) ─────────────────────────
989
+
990
+ function RemoteFilesPanel({ api, sessionId }) {
991
+ const [bindings, setBindings] = useState([]);
992
+ const [activeIdx, setActiveIdx] = useState(0);
993
+ const [connectionId, setConnectionId] = useState(null);
994
+ const [path, setPath] = useState('/');
995
+ const [entries, setEntries] = useState(null);
996
+ const [error, setError] = useState(null);
997
+ const [busy, setBusy] = useState(false);
998
+ const [jump, setJump] = useState('');
999
+ const [editor, setEditor] = useState(null); // { path, data, bytes, truncated, busy, error }
1000
+ const loadRef = useRef(0);
1001
+
1002
+ const activeBinding = bindings[activeIdx] ?? null;
1003
+ const sessionMatched = useRef(false);
1004
+
1005
+ // refresh bindings periodically; default-select the binding that matches
1006
+ // THIS session's working directory (per-session remote workspace awareness)
1007
+ useEffect(() => {
1008
+ let alive = true;
1009
+ const load = async () => {
1010
+ try {
1011
+ const value = sessionId
1012
+ ? await api.sessionBinding(sessionId)
1013
+ : await api.bindingList();
1014
+ if (!alive) return;
1015
+ const list = Array.isArray(value?.bindings) ? value.bindings : [];
1016
+ setBindings(list);
1017
+ if (!sessionMatched.current && sessionId) {
1018
+ const matchPath = value?.matchWorkspacePath ?? null;
1019
+ if (matchPath) {
1020
+ const idx = list.findIndex((b) => b.workspacePath === matchPath);
1021
+ if (idx >= 0) { setActiveIdx(idx); sessionMatched.current = true; }
1022
+ } else if (list.length > 0) {
1023
+ // no match for this session: keep manual selector but mark checked
1024
+ sessionMatched.current = true;
1025
+ }
1026
+ }
1027
+ setActiveIdx((idx) => (idx < list.length ? idx : 0));
1028
+ } catch { /* namespace not ready yet */ }
1029
+ };
1030
+ void load();
1031
+ const timer = setInterval(load, 8000);
1032
+ return () => { alive = false; clearInterval(timer); };
1033
+ }, [api, sessionId]);
1034
+
1035
+ const list = useCallback(async (connection, dir) => {
1036
+ const token = ++loadRef.current;
1037
+ setBusy(true); setError(null);
1038
+ try {
1039
+ const value = await api.sftpList(connection, dir);
1040
+ if (token !== loadRef.current) return;
1041
+ const sorted = (Array.isArray(value?.entries) ? value.entries : [])
1042
+ .sort((a, b) => (a.isDirectory === b.isDirectory ? a.name.localeCompare(b.name) : a.isDirectory ? -1 : 1));
1043
+ setEntries(sorted);
1044
+ setPath(dir);
1045
+ } catch (cause) {
1046
+ if (token !== loadRef.current) return;
1047
+ setError(cause?.message ?? String(cause));
1048
+ setEntries([]);
1049
+ } finally {
1050
+ if (token === loadRef.current) setBusy(false);
1051
+ }
1052
+ }, [api]);
1053
+
1054
+ // (re)connect when the selected binding changes
1055
+ useEffect(() => {
1056
+ if (!activeBinding) { setConnectionId(null); setEntries(null); return; }
1057
+ let alive = true;
1058
+ (async () => {
1059
+ setBusy(true); setError(null); setEntries(null);
1060
+ try {
1061
+ const value = await api.profileConnect({ profileId: activeBinding.profileId, reuseExisting: true });
1062
+ if (!alive) return;
1063
+ setConnectionId(value.connectionId);
1064
+ const start = (activeBinding.remotePath || '/').startsWith('/') ? activeBinding.remotePath : '/';
1065
+ await list(value.connectionId, start);
1066
+ } catch (cause) {
1067
+ if (!alive) return;
1068
+ setError(cause?.message ?? String(cause));
1069
+ setConnectionId(null);
1070
+ } finally {
1071
+ if (alive) setBusy(false);
1072
+ }
1073
+ })();
1074
+ return () => { alive = false; };
1075
+ }, [activeBinding?.profileId]); // eslint-disable-line react-hooks/exhaustive-deps
1076
+
1077
+ if (!bindings.length) {
1078
+ return h('div', { style: { padding: 14, color: 'var(--dsw-alias-label-secondary, #9aa3b0)', fontSize: 12, lineHeight: 1.7 } },
1079
+ '当前没有任何远程工作区绑定。',
1080
+ h('div', { style: { marginTop: 6 } }, '通过侧栏「+」添加工作区时选择「远程 SSH 目录」即可创建绑定,绑定后这里会显示远程主机的文件树。'),
1081
+ );
1082
+ }
1083
+
1084
+ const openFile = async (entry) => {
1085
+ if (!connectionId) return;
1086
+ const filePath = joinPath(path, entry.name);
1087
+ setEditor({ path: filePath, data: '', busy: true, error: null, truncated: false, dirty: false });
1088
+ try {
1089
+ const value = await api.fileRead(connectionId, filePath);
1090
+ setEditor({ path: filePath, data: value.data ?? '', bytes: value.bytes ?? 0, truncated: value.truncated === true, busy: false, error: null, dirty: false });
1091
+ } catch (cause) {
1092
+ setEditor({ path: filePath, data: '', busy: false, error: cause?.message ?? String(cause), truncated: false, dirty: false });
1093
+ }
1094
+ };
1095
+
1096
+ const saveFile = async () => {
1097
+ if (!editor || !connectionId) return;
1098
+ setEditor({ ...editor, busy: true, error: null });
1099
+ try {
1100
+ await api.fileWrite(connectionId, editor.path, editor.data);
1101
+ setEditor({ ...editor, busy: false, dirty: false });
1102
+ } catch (cause) {
1103
+ setEditor({ ...editor, busy: false, error: cause?.message ?? String(cause) });
1104
+ }
1105
+ };
1106
+
1107
+ const mkdir = async () => {
1108
+ const name = window.prompt('新文件夹名称(在当前目录下创建):');
1109
+ if (!name || !connectionId) return;
1110
+ try {
1111
+ await api.sftpMkdir(connectionId, joinPath(path, name));
1112
+ await list(connectionId, path);
1113
+ } catch (cause) {
1114
+ setError(cause?.message ?? String(cause));
1115
+ }
1116
+ };
1117
+
1118
+ const crumbs = path === '/' ? [] : path.split('/').filter(Boolean);
1119
+
1120
+ return h('div', { style: { display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0, fontSize: 12, color: 'var(--dsw-alias-label-primary, #d7dbe2)' } },
1121
+ h('select', {
1122
+ value: String(activeIdx), onChange: (e) => setActiveIdx(Number(e.target.value)),
1123
+ style: { margin: '8px 10px 0', height: 28, borderRadius: 8, fontSize: 12, background: 'var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06))', color: 'inherit', border: '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.2))' },
1124
+ },
1125
+ bindings.map((b, i) => h('option', { key: b.workspacePath, value: String(i) },
1126
+ `${b.profileName || b.host} → ${b.remotePath}${b.connected ? '(已连接)' : ''}`)),
1127
+ ),
1128
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 4, flexWrap: 'wrap', padding: '8px 10px 0' } },
1129
+ h('button', { style: css.ghostBtn, disabled: !connectionId, onClick: () => list(connectionId, parentOf(path)) }, '↑ 上级'),
1130
+ h('button', { style: css.ghostBtn, disabled: !connectionId, onClick: () => list(connectionId, homeGuess(activeBinding?.username)) }, '主目录'),
1131
+ h('button', { style: css.ghostBtn, disabled: !connectionId, onClick: () => list(connectionId, '/') }, '根目录'),
1132
+ h('button', { style: css.ghostBtn, disabled: !connectionId, onClick: mkdir }, '+ 文件夹'),
1133
+ h('button', { style: css.ghostBtn, disabled: !connectionId, onClick: () => list(connectionId, path) }, '刷新'),
1134
+ ),
1135
+ h('div', { style: { display: 'flex', gap: 4, padding: '6px 10px 0' } },
1136
+ h('input', {
1137
+ style: { ...css.pathInput, flex: 1 }, value: jump, placeholder: '绝对路径跳转',
1138
+ onChange: (e) => setJump(e.target.value),
1139
+ onKeyDown: (e) => { if (e.key === 'Enter' && jump.trim().startsWith('/')) list(connectionId, jump.trim().replace(/\/+$/, '') || '/'); },
1140
+ }),
1141
+ ),
1142
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 3, flexWrap: 'wrap', padding: '6px 10px 2px', fontFamily: 'ui-monospace, Menlo, monospace', color: 'var(--dsw-alias-label-secondary, #9aa3b0)' } },
1143
+ h('button', { style: css.crumb, onClick: () => list(connectionId, '/') }, '/'),
1144
+ ...crumbs.map((part, i) => h(React.Fragment, { key: `${i}-${part}` }, [
1145
+ h('button', { style: i === crumbs.length - 1 ? css.crumbHere : css.crumb, onClick: () => list(connectionId, '/' + crumbs.slice(0, i + 1).join('/')) }, part),
1146
+ i < crumbs.length - 1 ? h('span', null, '›') : null,
1147
+ ])),
1148
+ ),
1149
+ error ? h('div', { style: { ...css.error, margin: '0 10px' } }, error) : null,
1150
+ busy && entries === null ? h('div', { style: css.empty }, '加载中…') : null,
1151
+ !busy && entries !== null && entries.length === 0 ? h('div', { style: css.empty }, '(空目录)') : null,
1152
+ h('div', { style: { flex: 1, minHeight: 0, overflowY: 'auto', padding: '0 6px 8px' } },
1153
+ (entries ?? []).map((entry) => h('button', {
1154
+ key: entry.name,
1155
+ style: { ...css.dirRow, fontSize: 12 },
1156
+ onDoubleClick: () => { if (!entry.isDirectory) openFile(entry); },
1157
+ onClick: () => { if (entry.isDirectory) list(connectionId, joinPath(path, entry.name)); else openFile(entry); },
1158
+ },
1159
+ h('span', { style: { flex: 'none', width: 16, textAlign: 'center' } }, entry.isDirectory ? '📁' : '📄'),
1160
+ h('span', { style: css.dirName, title: entry.name }, entry.name),
1161
+ !entry.isDirectory ? h('span', { style: { ...css.serverMeta, marginLeft: 'auto', flex: 'none' } }, formatSize(entry.size)) : null,
1162
+ )),
1163
+ ),
1164
+ editor ? h(EditorOverlay, { editor, setEditor, saveFile, onClose: () => setEditor(null) }) : null,
1165
+ );
1166
+ }
1167
+
1168
+ function parentOf(path) {
1169
+ if (path === '/') return '/';
1170
+ const idx = path.lastIndexOf('/');
1171
+ return idx <= 0 ? '/' : path.slice(0, idx);
1172
+ }
1173
+
1174
+ function formatSize(size) {
1175
+ if (!Number.isFinite(size)) return '';
1176
+ if (size < 1024) return `${size}B`;
1177
+ if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)}KB`;
1178
+ return `${(size / 1024 / 1024).toFixed(1)}MB`;
1179
+ }
1180
+
1181
+ function EditorOverlay({ editor, setEditor, saveFile, onClose }) {
1182
+ return h(Overlay, { onClose },
1183
+ h('div', { style: { ...css.modal, width: 720 }, onMouseDown: (e) => e.stopPropagation() },
1184
+ h('div', { style: css.head },
1185
+ h('span', { style: { ...css.headTitle, fontFamily: 'ui-monospace, Menlo, monospace', overflow: 'hidden', textOverflow: 'ellipsis' } }, editor.path),
1186
+ editor.truncated ? h('span', { style: css.badge }, '已截断(>1MB,保存会覆盖截断部分)') : null,
1187
+ h('button', { style: css.closeBtn, onClick: onClose, title: '关闭' }, '✕'),
1188
+ ),
1189
+ editor.busy ? h('div', { style: css.empty }, '加载中…') : null,
1190
+ editor.error ? h('div', { style: { ...css.error, margin: 10 } }, editor.error) : null,
1191
+ !editor.busy ? h('textarea', {
1192
+ value: editor.data,
1193
+ onChange: (e) => setEditor({ ...editor, data: e.target.value, dirty: true }),
1194
+ spellCheck: false,
1195
+ style: {
1196
+ flex: 1, minHeight: 0, margin: 10, borderRadius: 8, padding: 10, resize: 'none',
1197
+ fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 12, lineHeight: 1.5,
1198
+ background: 'var(--dsw-alias-bg-layer-2, rgba(127,127,127,.06))', color: 'var(--dsw-alias-label-primary, #d7dbe2)',
1199
+ border: '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.2))',
1200
+ },
1201
+ }) : null,
1202
+ h('div', { style: css.foot },
1203
+ h('span', { style: { ...css.info, flex: 1 } }, editor.dirty ? '有未保存修改' : ''),
1204
+ h('button', { style: css.primaryBtn, disabled: editor.busy, onClick: saveFile }, editor.busy ? '保存中…' : '保存(覆盖远程文件)'),
1205
+ ),
1206
+ ),
1207
+ );
1208
+ }
1209
+
1210
+ // Right-sidebar tab registrations (mirror the official ui-sidebar-terminal pattern).
1211
+
1212
+ function RemoteFilesGuide(props) {
1213
+ const { api, sessionId, kind, title, description, actions, useTabInfo } = props;
1214
+ const [bound, setBound] = useState(null); // null = checking
1215
+ // Hooks must run during render: resolve the tab once, click handlers use the result.
1216
+ const tabInfo = typeof useTabInfo === 'function' ? useTabInfo() : null;
1217
+ const openActions = actions ?? tabInfo?.tab?.actions;
1218
+ useEffect(() => {
1219
+ if (!sessionId) return;
1220
+ let alive = true;
1221
+ (async () => {
1222
+ try {
1223
+ const r = await api.sessionBinding(sessionId);
1224
+ if (alive) setBound(!!r?.matchWorkspacePath);
1225
+ } catch { if (alive) setBound(false); }
1226
+ })();
1227
+ return () => { alive = false; };
1228
+ }, [sessionId, api]);
1229
+ const open = () => {
1230
+ try {
1231
+ const target = openActions ?? tabInfo?.tab?.actions;
1232
+ if (target?.openTab) target.openTab(kind ?? 'remote-files');
1233
+ else console.error('[remote-workspace] guide open: no tab actions available');
1234
+ } catch (cause) { console.error('[remote-workspace] guide open failed', cause); }
1235
+ };
1236
+ // Fail-closed: the 🌐 entry shows ONLY in sessions confirmed remote-bound.
1237
+ if (bound !== true) return null;
1238
+ return h('button', {
1239
+ onClick: open,
1240
+ 'data-sidebar-right-guide-entry': 'remote-files',
1241
+ title: typeof description === 'string' ? description : '浏览并编辑绑定远程目录中的文件',
1242
+ style: {
1243
+ all: 'unset', boxSizing: 'border-box', cursor: 'pointer',
1244
+ display: 'flex', alignItems: 'center', gap: 10, width: '100%',
1245
+ padding: '12px 16px', borderRadius: 10, textAlign: 'left',
1246
+ border: '1px solid var(--dsw-alias-border-l3, rgba(127,127,127,.20))',
1247
+ background: 'var(--dsw-alias-bg-layer-1, rgba(127,127,127,.05))',
1248
+ },
1249
+ },
1250
+ h('span', {
1251
+ style: {
1252
+ flex: 'none', width: 26, height: 26, display: 'inline-flex',
1253
+ alignItems: 'center', justifyContent: 'center',
1254
+ fontSize: 17, lineHeight: 1, borderRadius: 8,
1255
+ background: 'rgba(59,130,246,.12)',
1256
+ },
1257
+ }, '🌐'),
1258
+ h('span', { style: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 } },
1259
+ h('span', { style: { fontSize: 13, fontWeight: 600, color: 'var(--dsw-alias-label-primary, #d7dbe2)' } },
1260
+ typeof title === 'string' ? title : '打开远程文件'),
1261
+ h('span', { style: { fontSize: 11, color: 'var(--dsw-alias-label-secondary, #9aa3b0)' } },
1262
+ typeof description === 'string' ? description : '浏览并编辑绑定远程目录中的文件'),
1263
+ ),
1264
+ );
1265
+ }
1266
+
1267
+ function RemoteFilesTitle() {
1268
+ return h('span', null, '🌐 远程文件');
1269
+ }
1270
+
1271
+ /** Best-effort locale namespace so the tab shell can translate if it wants to. */
1272
+ function tryRegisterLocale(ctx) {
1273
+ try {
1274
+ ctx.locale?.register?.('ssh-file-panel', {
1275
+ zh: { panelTitle: '远程文件' },
1276
+ en: { panelTitle: 'Remote Files' },
1277
+ });
1278
+ } catch { /* locale service unavailable */ }
1279
+ return () => {};
1280
+ }
1281
+
970
1282
  // ── module face ──────────────────────────────────────────────────────────
971
1283
 
972
1284
  return {
@@ -994,8 +1306,55 @@ window.__ModuleLoader__.load({
994
1306
  registerFlowSlot('conversation.hero.workspace.directoryFlow'),
995
1307
  registerFlowSlot('workspace.picker.directoryFlow'),
996
1308
  ctx.slots.inject('conversation.composer.dock', () => ctx.slots.register(
997
- { name: 'conversation.composer.dock', id: 'ssh-file', order: 5 },
998
- function RemoteWorkspaceChip() { return h(DockChip, { api }); },
1309
+ { name: 'conversation.composer.dock', id: 'ssh-file', order: 5, inject: (sessionId) => ({ sessionId }) },
1310
+ function RemoteWorkspaceChip(props) { return h(DockChip, { api, sessionId: props?.sessionId }); },
1311
+ )),
1312
+ // Declare the tab TYPE so the right-sidebar guide lists our entry —
1313
+ // without this the guide entry / pane / title slots never render.
1314
+ // NOTE: guide icon must be a COMPONENT (rendered as <Icon/>), not an element.
1315
+ ctx.inject(['sidebarRightTabs'], (tabsCtx) => {
1316
+ tabsCtx.effect(() => {
1317
+ function RemoteFilesIcon() {
1318
+ return h('span', { style: { fontSize: 16 } }, '🌐');
1319
+ }
1320
+ try {
1321
+ // Return the register() disposer so the tab type unregisters when
1322
+ // this module generation unloads (remove/disable/reinstall). The
1323
+ // registration otherwise outlives us and the next generation's
1324
+ // register() throws "tab type id is already registered".
1325
+ return tabsCtx.sidebarRightTabs.register({
1326
+ id: 'dsh-ssh-file',
1327
+ kind: 'remote-files',
1328
+ multiple: true,
1329
+ priority: 'extension',
1330
+ title: () => '🌐 远程文件',
1331
+ guide: [{
1332
+ id: 'open',
1333
+ order: 20,
1334
+ title: () => '打开远程文件',
1335
+ description: () => '浏览并编辑绑定远程目录中的文件',
1336
+ icon: RemoteFilesIcon,
1337
+ }],
1338
+ });
1339
+ } catch (e) { console.error('[remote-workspace] sidebarRightTabs.register failed', e); }
1340
+ }, 'dsh-ssh-file: tab type');
1341
+ }),
1342
+ // right-sidebar "远程文件" panel tab (guide entry + pane body + title)
1343
+ tryRegisterLocale(ctx),
1344
+ ctx.slots.inject('sidebar.right.tab.guide.entry', () => ctx.slots.register(
1345
+ // key MUST equal the sidebarRightTabs registration id — the guide
1346
+ // dispatches occupants by entry.providerId, falling back to a
1347
+ // generic EntryBox (no per-session hiding) when no occupant matches.
1348
+ { name: 'sidebar.right.tab.guide.entry', key: 'dsh-ssh-file', locale: 'ssh-file-panel', inject: (sessionId) => ({ sessionId }) },
1349
+ function SshFileGuideEntry(props) { return h(RemoteFilesGuide, { api, sessionId: props?.sessionId, ...props }); },
1350
+ )),
1351
+ ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register(
1352
+ { name: 'sidebar.right.pane.tab', key: 'dsh-ssh-file', locale: 'ssh-file-panel', inject: (sessionId) => ({ sessionId }) },
1353
+ function SshFilePaneTab(props) { return h(RemoteFilesPanel, { api, sessionId: props?.sessionId }); },
1354
+ )),
1355
+ ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register(
1356
+ { name: 'sidebar.right.pane.tab.title', key: 'dsh-ssh-file', locale: 'ssh-file-panel' },
1357
+ function SshFilePaneTabTitle() { return h(RemoteFilesTitle); },
999
1358
  )),
1000
1359
  ];
1001
1360
 
@@ -11,6 +11,9 @@ import {
11
11
  bindingSaveRequestSchema, bindingSaveResultSchema,
12
12
  bindingDeleteRequestSchema, bindingDeleteResultSchema,
13
13
  ensureLocalMirrorFolderRequestSchema, ensureLocalMirrorFolderResultSchema,
14
+ fileReadRequestSchema, fileReadResultSchema,
15
+ fileWriteRequestSchema, fileWriteResultSchema,
16
+ sessionBindingRequestSchema, sessionBindingResultSchema,
14
17
  } from './schemas.js';
15
18
 
16
19
  export const PACKAGE = 'dsh-ssh-file';
@@ -54,4 +57,7 @@ export const DESCRIPTORS = [
54
57
  def('bindingSave', bindingSaveRequestSchema, 'BindingSaveRequest', bindingSaveResultSchema, 'BindingSaveResult'),
55
58
  def('bindingDelete', bindingDeleteRequestSchema, 'BindingDeleteRequest', bindingDeleteResultSchema, 'BindingDeleteResult'),
56
59
  def('ensureLocalMirrorFolder', ensureLocalMirrorFolderRequestSchema, 'EnsureLocalMirrorFolderRequest', ensureLocalMirrorFolderResultSchema, 'EnsureLocalMirrorFolderResult'),
60
+ def('fileRead', fileReadRequestSchema, 'FileReadRequest', fileReadResultSchema, 'FileReadResult'),
61
+ def('fileWrite', fileWriteRequestSchema, 'FileWriteRequest', fileWriteResultSchema, 'FileWriteResult'),
62
+ def('sessionBinding', sessionBindingRequestSchema, 'SessionBindingRequest', sessionBindingResultSchema, 'SessionBindingResult'),
57
63
  ];
package/lib/index.js CHANGED
@@ -13,6 +13,7 @@ import { randomUUID } from 'node:crypto';
13
13
  import { appendFileSync, mkdirSync } from 'node:fs';
14
14
  import { mkdir as fsMkdir } from 'node:fs/promises';
15
15
  import { homedir as osHomedir } from 'node:os';
16
+ import { PassThrough } from 'node:stream';
16
17
  import { isAbsolute, posix, relative as hostRelative, join, sep } from 'node:path';
17
18
  import { Service } from '@deepseek-ai/cordis';
18
19
  import { credentialRef } from '@deepseek-ai/dsh-credentials';
@@ -29,6 +30,87 @@ const MAX_COMMAND_OUTPUT_BYTES = 64 * 1024;
29
30
  const MAX_FILE_READ_BYTES = 256 * 1024;
30
31
  const EXEC_DEFAULT_TIMEOUT_MS = 30000;
31
32
  const EXEC_MAX_TIMEOUT_MS = 10 * 60 * 1000;
33
+ const MAX_EDITOR_READ_BYTES = 1024 * 1024;
34
+
35
+ /** Monotonic stand-in pid for SSH-backed terminal handles (display/telemetry only). */
36
+ let SSH_TERMINAL_FAKE_PID = 400000;
37
+
38
+ /**
39
+ * Terminal handle that satisfies the `subprocess.spawnTerminal` contract using
40
+ * an ssh2 shell channel. Consumed members of LocalTerminalHandle (verified
41
+ * against dsh-api-terminal-controller's BrowserTerminal): pid, running, done,
42
+ * output (async-iterable byte stream), write, resize, terminate,
43
+ * inspectActivity, inspectForeground, signalForeground.
44
+ */
45
+ class SshTerminalHandle {
46
+ constructor(stream, onQuiescence) {
47
+ this.stream = stream;
48
+ this.pid = ++SSH_TERMINAL_FAKE_PID;
49
+ this.exited = false;
50
+ this.exitCode = undefined;
51
+ this.output = new PassThrough();
52
+ this.outcome = Promise.withResolvers();
53
+ this.done = this.outcome.promise;
54
+ this.cleanupDone = undefined;
55
+ this._onQuiescence = onQuiescence;
56
+ stream.on('data', (data) => {
57
+ try { this.output.write(Buffer.isBuffer(data) ? data : Buffer.from(String(data), 'utf8')); } catch { /* consumer gone */ }
58
+ });
59
+ stream.on('exit', (code) => { this.exitCode = typeof code === 'number' ? code : 0; });
60
+ const finish = () => {
61
+ if (this.exited) return;
62
+ this.exited = true;
63
+ try { this.output.end(); } catch { /* ignore */ }
64
+ this.outcome.resolve({ exitCode: this.exitCode ?? 0, signal: null });
65
+ try { this._onQuiescence?.(); } catch { /* ignore */ }
66
+ };
67
+ stream.on('close', finish);
68
+ stream.on('error', () => { if (this.exitCode === undefined) this.exitCode = 1; finish(); });
69
+ this.output.on('close', () => { try { stream.end(); } catch { /* ignore */ } });
70
+ }
71
+
72
+ get running() {
73
+ return !this.exited;
74
+ }
75
+
76
+ async write(data) {
77
+ if (this.exited) throw new Error('terminal process has exited');
78
+ this.stream.write(data);
79
+ }
80
+
81
+ async resize(cols, rows) {
82
+ if (this.exited) throw new Error('terminal process has exited');
83
+ try { this.stream.setWindow(rows, cols, 0, 0); } catch { /* older ssh2 without setWindow */ }
84
+ }
85
+
86
+ /** No local process tree exists for an SSH channel; activity stays "unknown". */
87
+ async inspectForeground() {
88
+ return undefined;
89
+ }
90
+
91
+ async inspectActivity() {
92
+ return { state: this.exited ? 'idle' : 'unknown', revision: 0 };
93
+ }
94
+
95
+ async signalForeground(signalName) {
96
+ if (signalName === 'SIGINT') {
97
+ await this.write('\x03');
98
+ return this.pid;
99
+ }
100
+ throw new Error(`remote terminal does not support signal ${signalName}; close the terminal instead`);
101
+ }
102
+
103
+ async terminate() {
104
+ if (this.cleanupDone !== undefined) return this.cleanupDone;
105
+ this.cleanupDone = (async () => {
106
+ try { this.stream.signal?.('KILL'); } catch { /* ignore */ }
107
+ try { this.stream.end(); } catch { /* ignore */ }
108
+ if (!this.exited) await Promise.race([this.done, new Promise((resolve) => setTimeout(resolve, 3000))]);
109
+ try { this.output.end(); } catch { /* ignore */ }
110
+ })();
111
+ return this.cleanupDone;
112
+ }
113
+ }
32
114
 
33
115
  function fail(code, message) {
34
116
  return { code, message };
@@ -136,12 +218,14 @@ function profileCredentialRefs(profileId) { // credentialRef() requires a POSIX
136
218
  // ── service ─────────────────────────────────────────────────────────────────
137
219
 
138
220
  const RemoteWorkspaceService = class extends TypertRemoteService {
139
- static inject = ['tools', 'storageDomain', 'credentials', 'systemPrompt'];
221
+ static inject = ['tools', 'storageDomain', 'credentials', 'systemPrompt', 'agents'];
140
222
 
141
223
  /** connectionId -> live ssh2 connection record */
142
224
  connections = new Map();
143
225
  profileTable = null;
144
226
  bindingTable = null;
227
+ /** Live SSH-backed terminal handles created by the spawnTerminal reroute. */
228
+ sshTerminalHandles = new Set();
145
229
 
146
230
  constructor(ctx) {
147
231
  super(ctx, NS);
@@ -154,6 +238,7 @@ const RemoteWorkspaceService = class extends TypertRemoteService {
154
238
  }, 'dsh-remote-workspace: cleanup');
155
239
  this.registerTools(ctx);
156
240
  this.registerPromptHint(ctx);
241
+ this.installTerminalReroute(ctx);
157
242
  }
158
243
 
159
244
  /** Tell each bound session's agent that file/command work belongs on the server. */
@@ -576,6 +661,32 @@ const RemoteWorkspaceService = class extends TypertRemoteService {
576
661
  }
577
662
  }
578
663
 
664
+ /**
665
+ * All bindings plus the one matching the given session's working directory
666
+ * (so the files panel can default-select the right binding per session).
667
+ */
668
+ async sessionBinding(request) {
669
+ try {
670
+ const agents = this.ctx.get('agents');
671
+ const agent = typeof agents?.get === 'function' ? agents.get(request.sessionId) : undefined;
672
+ const session = agent?.session ?? agent;
673
+ const directory = this.sessionDirectory(session);
674
+ const bindings = this.listBindings().map((record) => this.bindingPublic(record));
675
+ const match = typeof directory === 'string' ? this.bindingFor(directory) : undefined;
676
+ debugLog(`sessionBinding: sessionId=${request.sessionId} cwd=${String(directory)} match=${match ? match.record.workspacePath : 'none'}`);
677
+ return {
678
+ ok: true,
679
+ value: {
680
+ bindings,
681
+ matchWorkspacePath: match ? match.record.workspacePath : null,
682
+ cwd: typeof directory === 'string' ? directory : null,
683
+ },
684
+ };
685
+ } catch (error) {
686
+ return { ok: false, error: fail('session-binding-failed', error.message) };
687
+ }
688
+ }
689
+
579
690
  async bindingSave(request) {
580
691
  try {
581
692
  const profile = this.requireProfileTable().get(request.profileId);
@@ -641,6 +752,133 @@ const RemoteWorkspaceService = class extends TypertRemoteService {
641
752
  }
642
753
  }
643
754
 
755
+ // ── remote terminal: reroute official new-terminal spawns ───────────────
756
+
757
+ /**
758
+ * Wrap `subprocess.spawnTerminal` so a session whose working directory is
759
+ * bound to a remote workspace gets an SSH shell (cwd = the bound remote
760
+ * directory, or the session subdirectory of it) instead of a local PTY.
761
+ * Unbound sessions fall through to the original local spawn, unchanged.
762
+ */
763
+ installTerminalReroute(ctx) {
764
+ const subprocess = this.ctx.get('subprocess');
765
+ if (subprocess === undefined || typeof subprocess.spawnTerminal !== 'function') {
766
+ debugLog('terminal reroute: subprocess service unavailable; remote terminals disabled');
767
+ return;
768
+ }
769
+ if (subprocess.spawnTerminal.__dshSshFilePatched === true) {
770
+ debugLog('terminal reroute: already patched; skipping');
771
+ return;
772
+ }
773
+ const service = this;
774
+ const original = subprocess.spawnTerminal;
775
+ const patched = function spawnTerminal(spec) {
776
+ let binding;
777
+ try {
778
+ binding = service.bindingFor(spec?.cwd);
779
+ } catch {
780
+ binding = undefined; // storage not ready -> local shell, never block boot paths
781
+ }
782
+ if (binding === undefined) return original.call(this, spec);
783
+ return service.spawnSshTerminal(binding, spec);
784
+ };
785
+ patched.__dshSshFilePatched = true;
786
+ subprocess.spawnTerminal = patched;
787
+ ctx.effect(() => () => {
788
+ try {
789
+ if (subprocess.spawnTerminal === patched) subprocess.spawnTerminal = original;
790
+ } catch { /* ignore */ }
791
+ for (const handle of this.sshTerminalHandles) {
792
+ try { handle.terminate(); } catch { /* ignore */ }
793
+ }
794
+ this.sshTerminalHandles.clear();
795
+ }, 'dsh-ssh-file: terminal reroute restore');
796
+ debugLog('terminal reroute: installed');
797
+ }
798
+
799
+ /** Open an SSH shell for a bound spawn request (cwd-keyed). */
800
+ async spawnSshTerminal(binding, spec) {
801
+ const record = binding.record;
802
+ const connection = await this.ensureBindingConnection(record);
803
+ const subdirectory = binding.relative === undefined
804
+ ? (workspaceRelativePart(record.workspacePath, spec?.cwd) ?? '')
805
+ : binding.relative;
806
+ const base = subdirectory === '' ? record.remotePath : `${record.remotePath}/${subdirectory}`;
807
+ const remoteDir = normalizeRemoteRoot(base);
808
+ const shellStream = await new Promise((resolve, reject) => {
809
+ const timer = setTimeout(() => reject(new Error('SSH shell handshake timed out')), CONNECT_TIMEOUT_MS);
810
+ try {
811
+ connection.client.shell({
812
+ term: typeof spec?.terminalType === 'string' && spec.terminalType !== '' ? spec.terminalType : 'xterm-256color',
813
+ cols: Number.isSafeInteger(spec?.cols) ? spec.cols : 80,
814
+ rows: Number.isSafeInteger(spec?.rows) ? spec.rows : 24,
815
+ }, (error, stream) => {
816
+ clearTimeout(timer);
817
+ if (error) reject(error);
818
+ else resolve(stream);
819
+ });
820
+ } catch (error) {
821
+ clearTimeout(timer);
822
+ reject(error);
823
+ }
824
+ });
825
+ const handle = new SshTerminalHandle(shellStream, () => this.sshTerminalHandles.delete(handle));
826
+ this.sshTerminalHandles.add(handle);
827
+ // Land in the bound remote directory once the shell is up.
828
+ setTimeout(() => {
829
+ try { shellStream.write(`cd ${shellSingleQuote(remoteDir)}; clear\n`); } catch { /* stream closed */ }
830
+ }, 150);
831
+ debugLog(`terminal reroute: ${spec?.cwd} -> ${remoteDir} (${connection.host})`);
832
+ return handle;
833
+ }
834
+
835
+ // ── wire methods: remote file panel editor ──────────────────────────────
836
+
837
+ async fileRead(request) {
838
+ const selected = this.resolveConnection(request.connectionId);
839
+ if (!selected.ok) return selected;
840
+ let remotePath;
841
+ try {
842
+ remotePath = normalizeRemoteRoot(request.path);
843
+ } catch (error) {
844
+ return { ok: false, error: fail('bad-remote-path', error.message) };
845
+ }
846
+ try {
847
+ const read = await this.readFileBounded(selected.connection, remotePath, MAX_EDITOR_READ_BYTES);
848
+ return {
849
+ ok: true,
850
+ value: { path: remotePath, data: read.buffer.toString('utf8'), bytes: read.buffer.length, truncated: read.truncated },
851
+ };
852
+ } catch (error) {
853
+ return { ok: false, error: fail('file-read-failed', `${remotePath}: ${error.message}`) };
854
+ }
855
+ }
856
+
857
+ async fileWrite(request) {
858
+ const selected = this.resolveConnection(request.connectionId);
859
+ if (!selected.ok) return selected;
860
+ let remotePath;
861
+ try {
862
+ remotePath = normalizeRemoteRoot(request.path);
863
+ } catch (error) {
864
+ return { ok: false, error: fail('bad-remote-path', error.message) };
865
+ }
866
+ const sftp = await this.requireSftp(selected.connection);
867
+ if (!sftp.ok) return sftp;
868
+ try {
869
+ const data = Buffer.from(String(request.data ?? ''), 'utf8');
870
+ await new Promise((resolve, reject) => {
871
+ const stream = sftp.sftp.createWriteStream(remotePath);
872
+ stream.on('error', reject);
873
+ stream.on('close', resolve);
874
+ stream.end(data);
875
+ });
876
+ return { ok: true, value: { path: remotePath, bytes: data.length } };
877
+ } catch (error) {
878
+ return { ok: false, error: fail('file-write-failed', `${remotePath}: ${error.message}`) };
879
+ }
880
+ }
881
+
644
882
  // ── agent-tool plumbing ─────────────────────────────────────────────────
645
883
 
646
884
  /**
@@ -715,12 +953,20 @@ const RemoteWorkspaceService = class extends TypertRemoteService {
715
953
  clearTimeout(timer);
716
954
  resolve(value);
717
955
  };
718
- const timer = setTimeout(() => finish({ stdout, stderr, exitCode: null, truncated: true, timedOut: true, stdoutBytes, stderrBytes }), timeoutMs);
719
956
  const stdoutParts = [];
720
957
  const stderrParts = [];
721
958
  let stdoutBytes = 0;
722
959
  let stderrBytes = 0;
723
960
  let exitCode = null;
961
+ const timer = setTimeout(() => finish({
962
+ stdout: Buffer.concat(stdoutParts).toString('utf8'),
963
+ stderr: Buffer.concat(stderrParts).toString('utf8'),
964
+ exitCode: null,
965
+ truncated: true,
966
+ timedOut: true,
967
+ stdoutBytes,
968
+ stderrBytes,
969
+ }), timeoutMs);
724
970
  try {
725
971
  connection.client.exec(command, (error, stream) => {
726
972
  if (error) {
package/lib/schemas.js CHANGED
@@ -1,4 +1,4 @@
1
- // Shared zod v4 schemas for the dsh-remote-workspace host face.
1
+ // Shared zod v4 schemas for the dsh-ssh-file host face.
2
2
  import { z } from 'zod';
3
3
 
4
4
  export function resultSchema(obj) {
@@ -108,3 +108,23 @@ export const bindingDeleteResultSchema = resultSchema(z.object({ removed: z.bool
108
108
 
109
109
  export const ensureLocalMirrorFolderRequestSchema = z.object({ name: z.string() });
110
110
  export const ensureLocalMirrorFolderResultSchema = resultSchema(z.object({ path: z.string() }));
111
+
112
+ export const sessionBindingRequestSchema = z.object({ sessionId: z.string() });
113
+ export const sessionBindingResultSchema = resultSchema(z.object({
114
+ bindings: z.array(bindingSchema),
115
+ matchWorkspacePath: z.string().nullable(),
116
+ cwd: z.string().nullable(),
117
+ }));
118
+
119
+ // ── remote file panel (editor read/write) ───────────────────────────────────
120
+
121
+ export const fileReadRequestSchema = z.object({ connectionId: z.string(), path: z.string() });
122
+ export const fileReadResultSchema = resultSchema(z.object({
123
+ path: z.string(),
124
+ data: z.string(),
125
+ bytes: z.number(),
126
+ truncated: z.boolean(),
127
+ }));
128
+
129
+ export const fileWriteRequestSchema = z.object({ connectionId: z.string(), path: z.string(), data: z.string() });
130
+ export const fileWriteResultSchema = resultSchema(z.object({ path: z.string(), bytes: z.number() }));
package/lib/typert.js CHANGED
@@ -34,6 +34,10 @@ const TYPERT = {
34
34
  { kind: 'method', name: 'bindingList', signature: 'async bindingList(request: BindingListRequest): Promise<BindingListResult>' },
35
35
  { kind: 'method', name: 'bindingSave', signature: 'async bindingSave(request: BindingSaveRequest): Promise<BindingSaveResult>' },
36
36
  { kind: 'method', name: 'bindingDelete', signature: 'async bindingDelete(request: BindingDeleteRequest): Promise<BindingDeleteResult>' },
37
+ { kind: 'method', name: 'ensureLocalMirrorFolder', signature: 'async ensureLocalMirrorFolder(request: EnsureLocalMirrorFolderRequest): Promise<EnsureLocalMirrorFolderResult>' },
38
+ { kind: 'method', name: 'fileRead', signature: 'async fileRead(request: FileReadRequest): Promise<FileReadResult>' },
39
+ { kind: 'method', name: 'fileWrite', signature: 'async fileWrite(request: FileWriteRequest): Promise<FileWriteResult>' },
40
+ { kind: 'method', name: 'sessionBinding', signature: 'async sessionBinding(request: SessionBindingRequest): Promise<SessionBindingResult>' },
37
41
  ],
38
42
  types: [
39
43
  { name: 'SshResult', declaration: 'export type SshResult<T> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } };' },
@@ -60,6 +64,14 @@ const TYPERT = {
60
64
  { name: 'BindingSaveResult', declaration: 'export type BindingSaveResult = SshResult<{ binding: Binding }>;' },
61
65
  { name: 'BindingDeleteRequest', declaration: 'export interface BindingDeleteRequest { readonly workspacePath: string; }' },
62
66
  { name: 'BindingDeleteResult', declaration: 'export type BindingDeleteResult = SshResult<{ removed: boolean }>;' },
67
+ { name: 'SessionBindingRequest', declaration: 'export interface SessionBindingRequest { readonly sessionId: string; }' },
68
+ { name: 'SessionBindingResult', declaration: 'export type SessionBindingResult = SshResult<{ bindings: Binding[]; matchWorkspacePath: string | null; cwd: string | null }>;' },
69
+ { name: 'EnsureLocalMirrorFolderRequest', declaration: 'export interface EnsureLocalMirrorFolderRequest { readonly name: string; }' },
70
+ { name: 'EnsureLocalMirrorFolderResult', declaration: 'export type EnsureLocalMirrorFolderResult = SshResult<{ path: string }>;' },
71
+ { name: 'FileReadRequest', declaration: 'export interface FileReadRequest { readonly connectionId: string; readonly path: string; }' },
72
+ { name: 'FileReadResult', declaration: 'export type FileReadResult = SshResult<{ path: string; data: string; bytes: number; truncated: boolean }>;' },
73
+ { name: 'FileWriteRequest', declaration: 'export interface FileWriteRequest { readonly connectionId: string; readonly path: string; readonly data: string; }' },
74
+ { name: 'FileWriteResult', declaration: 'export type FileWriteResult = SshResult<{ path: string; bytes: number }>;' },
63
75
  ],
64
76
  },
65
77
  ],
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-ssh-file",
3
3
  "description": "SSH file workspace for DeepSeek Harness: bind DSH workspaces to remote server directories and let the agent read/write remote files and run remote commands via SFTP/SSH. Standalone — no dsh-ssh-ops required.",
4
4
  "icon": "./icon.svg",
5
- "version": "1.0.1",
5
+ "version": "1.2.3",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",