@ethanfly/sshx 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/README.md +427 -2
- package/bin/sshx.js +22 -0
- package/dist/cli/connect.d.ts +27 -0
- package/dist/cli/connect.d.ts.map +1 -0
- package/dist/cli/connect.js +182 -0
- package/dist/cli/connect.js.map +1 -0
- package/dist/cli/exec.d.ts +8 -0
- package/dist/cli/exec.d.ts.map +1 -0
- package/dist/cli/exec.js +53 -0
- package/dist/cli/exec.js.map +1 -0
- package/dist/cli/host.d.ts +35 -0
- package/dist/cli/host.d.ts.map +1 -0
- package/dist/cli/host.js +312 -0
- package/dist/cli/host.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +313 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/keygen.d.ts +9 -0
- package/dist/cli/keygen.d.ts.map +1 -0
- package/dist/cli/keygen.js +38 -0
- package/dist/cli/keygen.js.map +1 -0
- package/dist/cli/sftp.d.ts +9 -0
- package/dist/cli/sftp.d.ts.map +1 -0
- package/dist/cli/sftp.js +105 -0
- package/dist/cli/sftp.js.map +1 -0
- package/dist/cli/sync.d.ts +15 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +220 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/tunnel.d.ts +8 -0
- package/dist/cli/tunnel.d.ts.map +1 -0
- package/dist/cli/tunnel.js +79 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/utils.d.ts +40 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +115 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/core/client.d.ts +49 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +269 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/config.d.ts +109 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +624 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/exec.d.ts +25 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +88 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/keygen.d.ts +45 -0
- package/dist/core/keygen.d.ts.map +1 -0
- package/dist/core/keygen.js +233 -0
- package/dist/core/keygen.js.map +1 -0
- package/dist/core/known-hosts.d.ts +30 -0
- package/dist/core/known-hosts.d.ts.map +1 -0
- package/dist/core/known-hosts.js +201 -0
- package/dist/core/known-hosts.js.map +1 -0
- package/dist/core/metrics.d.ts +62 -0
- package/dist/core/metrics.d.ts.map +1 -0
- package/dist/core/metrics.js +207 -0
- package/dist/core/metrics.js.map +1 -0
- package/dist/core/session.d.ts +44 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +160 -0
- package/dist/core/session.js.map +1 -0
- package/dist/core/sftp.d.ts +80 -0
- package/dist/core/sftp.d.ts.map +1 -0
- package/dist/core/sftp.js +368 -0
- package/dist/core/sftp.js.map +1 -0
- package/dist/core/split-session.d.ts +42 -0
- package/dist/core/split-session.d.ts.map +1 -0
- package/dist/core/split-session.js +223 -0
- package/dist/core/split-session.js.map +1 -0
- package/dist/core/tunnel.d.ts +86 -0
- package/dist/core/tunnel.d.ts.map +1 -0
- package/dist/core/tunnel.js +405 -0
- package/dist/core/tunnel.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/skill/mcp-server.d.ts +4 -0
- package/dist/skill/mcp-server.d.ts.map +1 -0
- package/dist/skill/mcp-server.js +284 -0
- package/dist/skill/mcp-server.js.map +1 -0
- package/dist/skill/runner.d.ts +2 -0
- package/dist/skill/runner.d.ts.map +1 -0
- package/dist/skill/runner.js +97 -0
- package/dist/skill/runner.js.map +1 -0
- package/dist/skill/tools.d.ts +106 -0
- package/dist/skill/tools.d.ts.map +1 -0
- package/dist/skill/tools.js +218 -0
- package/dist/skill/tools.js.map +1 -0
- package/dist/sync/crypto.d.ts +25 -0
- package/dist/sync/crypto.d.ts.map +1 -0
- package/dist/sync/crypto.js +69 -0
- package/dist/sync/crypto.js.map +1 -0
- package/dist/sync/manager.d.ts +54 -0
- package/dist/sync/manager.d.ts.map +1 -0
- package/dist/sync/manager.js +140 -0
- package/dist/sync/manager.js.map +1 -0
- package/dist/sync/provider.d.ts +63 -0
- package/dist/sync/provider.d.ts.map +1 -0
- package/dist/sync/provider.js +216 -0
- package/dist/sync/provider.js.map +1 -0
- package/dist/tui/app.d.ts +30 -0
- package/dist/tui/app.d.ts.map +1 -0
- package/dist/tui/app.js +356 -0
- package/dist/tui/app.js.map +1 -0
- package/dist/tui/form.d.ts +20 -0
- package/dist/tui/form.d.ts.map +1 -0
- package/dist/tui/form.js +132 -0
- package/dist/tui/form.js.map +1 -0
- package/dist/tui/index.d.ts +4 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +6 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/screen.d.ts +24 -0
- package/dist/tui/screen.d.ts.map +1 -0
- package/dist/tui/screen.js +144 -0
- package/dist/tui/screen.js.map +1 -0
- package/dist/tui/screens/hosts.d.ts +40 -0
- package/dist/tui/screens/hosts.d.ts.map +1 -0
- package/dist/tui/screens/hosts.js +272 -0
- package/dist/tui/screens/hosts.js.map +1 -0
- package/dist/tui/sidebar.d.ts +19 -0
- package/dist/tui/sidebar.d.ts.map +1 -0
- package/dist/tui/sidebar.js +122 -0
- package/dist/tui/sidebar.js.map +1 -0
- package/dist/tui/theme.d.ts +15 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +57 -0
- package/dist/tui/theme.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export class SFTPClient {
|
|
4
|
+
client;
|
|
5
|
+
sftpWrapper;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
async getWrapper() {
|
|
10
|
+
if (this.sftpWrapper)
|
|
11
|
+
return this.sftpWrapper;
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
this.client.sftp((err, sftp) => {
|
|
14
|
+
if (err)
|
|
15
|
+
return reject(err);
|
|
16
|
+
this.sftpWrapper = sftp;
|
|
17
|
+
resolve(sftp);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* List files in remote directory with rich metadata
|
|
23
|
+
*/
|
|
24
|
+
async list(remotePath = '.') {
|
|
25
|
+
const sftp = await this.getWrapper();
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
sftp.readdir(remotePath, (err, list) => {
|
|
28
|
+
if (err)
|
|
29
|
+
return reject(err);
|
|
30
|
+
const results = list.map((item) => {
|
|
31
|
+
const mode = item.attrs.mode || 0;
|
|
32
|
+
const isDir = (mode & 0o170000) === 0o040000;
|
|
33
|
+
const isSymlink = (mode & 0o170000) === 0o120000;
|
|
34
|
+
const isFile = (mode & 0o170000) === 0o100000 || (!isDir && !isSymlink);
|
|
35
|
+
return {
|
|
36
|
+
filename: item.filename,
|
|
37
|
+
path: path.posix.join(remotePath, item.filename),
|
|
38
|
+
isDirectory: isDir,
|
|
39
|
+
isFile,
|
|
40
|
+
isSymbolicLink: isSymlink,
|
|
41
|
+
size: item.attrs.size || 0,
|
|
42
|
+
modifyTime: new Date((item.attrs.mtime || 0) * 1000),
|
|
43
|
+
accessTime: new Date((item.attrs.atime || 0) * 1000),
|
|
44
|
+
permissions: mode & 0o777,
|
|
45
|
+
modeString: formatModeString(mode)
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
// Sort directories first, then alphabetical
|
|
49
|
+
results.sort((a, b) => {
|
|
50
|
+
if (a.isDirectory && !b.isDirectory)
|
|
51
|
+
return -1;
|
|
52
|
+
if (!a.isDirectory && b.isDirectory)
|
|
53
|
+
return 1;
|
|
54
|
+
return a.filename.localeCompare(b.filename);
|
|
55
|
+
});
|
|
56
|
+
resolve(results);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get file attributes (stat)
|
|
62
|
+
*/
|
|
63
|
+
async stat(remotePath) {
|
|
64
|
+
const sftp = await this.getWrapper();
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
sftp.stat(remotePath, (err, stats) => {
|
|
67
|
+
if (err)
|
|
68
|
+
return reject(err);
|
|
69
|
+
const mode = stats.mode || 0;
|
|
70
|
+
const isDir = (mode & 0o170000) === 0o040000;
|
|
71
|
+
const isSymlink = (mode & 0o170000) === 0o120000;
|
|
72
|
+
const isFile = (mode & 0o170000) === 0o100000 || (!isDir && !isSymlink);
|
|
73
|
+
resolve({
|
|
74
|
+
filename: path.posix.basename(remotePath),
|
|
75
|
+
path: remotePath,
|
|
76
|
+
isDirectory: isDir,
|
|
77
|
+
isFile,
|
|
78
|
+
isSymbolicLink: isSymlink,
|
|
79
|
+
size: stats.size || 0,
|
|
80
|
+
modifyTime: new Date((stats.mtime || 0) * 1000),
|
|
81
|
+
accessTime: new Date((stats.atime || 0) * 1000),
|
|
82
|
+
permissions: mode & 0o777,
|
|
83
|
+
modeString: formatModeString(mode)
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Check if remote path exists
|
|
90
|
+
*/
|
|
91
|
+
async exists(remotePath) {
|
|
92
|
+
try {
|
|
93
|
+
await this.stat(remotePath);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Read remote file content
|
|
102
|
+
*/
|
|
103
|
+
async readFile(remotePath, encoding = 'utf8') {
|
|
104
|
+
const sftp = await this.getWrapper();
|
|
105
|
+
return new Promise((resolve, reject) => {
|
|
106
|
+
const chunks = [];
|
|
107
|
+
const stream = sftp.createReadStream(remotePath);
|
|
108
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
109
|
+
stream.on('end', () => resolve(Buffer.concat(chunks).toString(encoding)));
|
|
110
|
+
stream.on('error', (err) => reject(err));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Write remote file content
|
|
115
|
+
*/
|
|
116
|
+
async writeFile(remotePath, content) {
|
|
117
|
+
const sftp = await this.getWrapper();
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
const stream = sftp.createWriteStream(remotePath);
|
|
120
|
+
let done = false;
|
|
121
|
+
const onDone = () => {
|
|
122
|
+
if (!done) {
|
|
123
|
+
done = true;
|
|
124
|
+
resolve();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
stream.once('finish', onDone);
|
|
128
|
+
stream.once('close', onDone);
|
|
129
|
+
stream.once('error', (err) => {
|
|
130
|
+
if (!done) {
|
|
131
|
+
done = true;
|
|
132
|
+
reject(err);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
stream.end(Buffer.isBuffer(content) ? content : Buffer.from(content, 'utf8'));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Upload single file from local to remote with progress tracking
|
|
140
|
+
*/
|
|
141
|
+
async uploadFile(localPath, remotePath, onProgress) {
|
|
142
|
+
const sftp = await this.getWrapper();
|
|
143
|
+
const stat = fs.statSync(localPath);
|
|
144
|
+
const totalBytes = stat.size;
|
|
145
|
+
let bytesTransferred = 0;
|
|
146
|
+
const startTime = Date.now();
|
|
147
|
+
return new Promise((resolve, reject) => {
|
|
148
|
+
const readStream = fs.createReadStream(localPath);
|
|
149
|
+
const writeStream = sftp.createWriteStream(remotePath);
|
|
150
|
+
readStream.on('data', (chunk) => {
|
|
151
|
+
bytesTransferred += chunk.length;
|
|
152
|
+
if (onProgress) {
|
|
153
|
+
const elapsedSec = (Date.now() - startTime) / 1000 || 0.001;
|
|
154
|
+
const speedBps = Math.round(bytesTransferred / elapsedSec);
|
|
155
|
+
const percent = totalBytes > 0 ? Math.min(100, Math.round((bytesTransferred / totalBytes) * 100)) : 100;
|
|
156
|
+
onProgress({
|
|
157
|
+
bytesTransferred,
|
|
158
|
+
totalBytes,
|
|
159
|
+
percent,
|
|
160
|
+
speedBps,
|
|
161
|
+
currentFile: path.basename(localPath)
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
writeStream.on('close', () => resolve());
|
|
166
|
+
writeStream.on('error', (err) => reject(err));
|
|
167
|
+
readStream.on('error', (err) => reject(err));
|
|
168
|
+
readStream.pipe(writeStream);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Download single file from remote to local with progress tracking
|
|
173
|
+
*/
|
|
174
|
+
async downloadFile(remotePath, localPath, onProgress) {
|
|
175
|
+
const sftp = await this.getWrapper();
|
|
176
|
+
const remoteStat = await this.stat(remotePath);
|
|
177
|
+
const totalBytes = remoteStat.size;
|
|
178
|
+
let bytesTransferred = 0;
|
|
179
|
+
const startTime = Date.now();
|
|
180
|
+
const localDir = path.dirname(path.resolve(localPath));
|
|
181
|
+
if (!fs.existsSync(localDir)) {
|
|
182
|
+
fs.mkdirSync(localDir, { recursive: true });
|
|
183
|
+
}
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const readStream = sftp.createReadStream(remotePath);
|
|
186
|
+
const writeStream = fs.createWriteStream(localPath);
|
|
187
|
+
readStream.on('data', (chunk) => {
|
|
188
|
+
bytesTransferred += chunk.length;
|
|
189
|
+
if (onProgress) {
|
|
190
|
+
const elapsedSec = (Date.now() - startTime) / 1000 || 0.001;
|
|
191
|
+
const speedBps = Math.round(bytesTransferred / elapsedSec);
|
|
192
|
+
const percent = totalBytes > 0 ? Math.min(100, Math.round((bytesTransferred / totalBytes) * 100)) : 100;
|
|
193
|
+
onProgress({
|
|
194
|
+
bytesTransferred,
|
|
195
|
+
totalBytes,
|
|
196
|
+
percent,
|
|
197
|
+
speedBps,
|
|
198
|
+
currentFile: path.posix.basename(remotePath)
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
writeStream.on('close', () => resolve());
|
|
203
|
+
writeStream.on('error', (err) => reject(err));
|
|
204
|
+
readStream.on('error', (err) => reject(err));
|
|
205
|
+
readStream.pipe(writeStream);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Create directory on remote host (supports recursive mkdir -p)
|
|
210
|
+
*/
|
|
211
|
+
async mkdir(remotePath, recursive = true) {
|
|
212
|
+
const sftp = await this.getWrapper();
|
|
213
|
+
if (!recursive) {
|
|
214
|
+
return new Promise((resolve, reject) => {
|
|
215
|
+
sftp.mkdir(remotePath, (err) => {
|
|
216
|
+
if (err)
|
|
217
|
+
return reject(err);
|
|
218
|
+
resolve();
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
const parts = remotePath.split('/').filter(Boolean);
|
|
223
|
+
let current = remotePath.startsWith('/') ? '/' : '';
|
|
224
|
+
for (const part of parts) {
|
|
225
|
+
current = path.posix.join(current, part);
|
|
226
|
+
const isPresent = await this.exists(current);
|
|
227
|
+
if (!isPresent) {
|
|
228
|
+
await new Promise((resolve, reject) => {
|
|
229
|
+
sftp.mkdir(current, (err) => {
|
|
230
|
+
if (err && err.code !== 4)
|
|
231
|
+
return reject(err); // code 4 = SSH_FX_FAILURE (often already exists)
|
|
232
|
+
resolve();
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Delete remote file or directory (supports recursive rm -rf)
|
|
240
|
+
*/
|
|
241
|
+
async rm(remotePath, recursive = true) {
|
|
242
|
+
const sftp = await this.getWrapper();
|
|
243
|
+
const stat = await this.stat(remotePath);
|
|
244
|
+
if (!stat.isDirectory) {
|
|
245
|
+
return new Promise((resolve, reject) => {
|
|
246
|
+
sftp.unlink(remotePath, (err) => {
|
|
247
|
+
if (err)
|
|
248
|
+
return reject(err);
|
|
249
|
+
resolve();
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (!recursive) {
|
|
254
|
+
return new Promise((resolve, reject) => {
|
|
255
|
+
sftp.rmdir(remotePath, (err) => {
|
|
256
|
+
if (err)
|
|
257
|
+
return reject(err);
|
|
258
|
+
resolve();
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// Recursive directory removal
|
|
263
|
+
const entries = await this.list(remotePath);
|
|
264
|
+
for (const entry of entries) {
|
|
265
|
+
if (entry.filename === '.' || entry.filename === '..')
|
|
266
|
+
continue;
|
|
267
|
+
await this.rm(entry.path, true);
|
|
268
|
+
}
|
|
269
|
+
return new Promise((resolve, reject) => {
|
|
270
|
+
sftp.rmdir(remotePath, (err) => {
|
|
271
|
+
if (err)
|
|
272
|
+
return reject(err);
|
|
273
|
+
resolve();
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Rename or move remote file
|
|
279
|
+
*/
|
|
280
|
+
async rename(oldPath, newPath) {
|
|
281
|
+
const sftp = await this.getWrapper();
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
sftp.rename(oldPath, newPath, (err) => {
|
|
284
|
+
if (err)
|
|
285
|
+
return reject(err);
|
|
286
|
+
resolve();
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Change permissions of remote file
|
|
292
|
+
*/
|
|
293
|
+
async chmod(remotePath, mode) {
|
|
294
|
+
const sftp = await this.getWrapper();
|
|
295
|
+
return new Promise((resolve, reject) => {
|
|
296
|
+
sftp.chmod(remotePath, mode, (err) => {
|
|
297
|
+
if (err)
|
|
298
|
+
return reject(err);
|
|
299
|
+
resolve();
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Recursive directory upload
|
|
305
|
+
*/
|
|
306
|
+
async uploadDir(localDir, remoteDir, onProgress) {
|
|
307
|
+
await this.mkdir(remoteDir, true);
|
|
308
|
+
const items = fs.readdirSync(localDir);
|
|
309
|
+
for (const item of items) {
|
|
310
|
+
const localItemPath = path.join(localDir, item);
|
|
311
|
+
const remoteItemPath = path.posix.join(remoteDir, item);
|
|
312
|
+
const stat = fs.statSync(localItemPath);
|
|
313
|
+
if (stat.isDirectory()) {
|
|
314
|
+
await this.uploadDir(localItemPath, remoteItemPath, onProgress);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
await this.uploadFile(localItemPath, remoteItemPath, onProgress);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Recursive directory download
|
|
323
|
+
*/
|
|
324
|
+
async downloadDir(remoteDir, localDir, onProgress) {
|
|
325
|
+
if (!fs.existsSync(localDir)) {
|
|
326
|
+
fs.mkdirSync(localDir, { recursive: true });
|
|
327
|
+
}
|
|
328
|
+
const items = await this.list(remoteDir);
|
|
329
|
+
for (const item of items) {
|
|
330
|
+
if (item.filename === '.' || item.filename === '..')
|
|
331
|
+
continue;
|
|
332
|
+
const localItemPath = path.join(localDir, item.filename);
|
|
333
|
+
if (item.isDirectory) {
|
|
334
|
+
await this.downloadDir(item.path, localItemPath, onProgress);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
await this.downloadFile(item.path, localItemPath, onProgress);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Converts numeric unix mode to standard string representation (e.g. drwxr-xr-x)
|
|
344
|
+
*/
|
|
345
|
+
function formatModeString(mode) {
|
|
346
|
+
let type = '-';
|
|
347
|
+
if ((mode & 0o170000) === 0o040000)
|
|
348
|
+
type = 'd';
|
|
349
|
+
else if ((mode & 0o170000) === 0o120000)
|
|
350
|
+
type = 'l';
|
|
351
|
+
else if ((mode & 0o170000) === 0o020000)
|
|
352
|
+
type = 'c';
|
|
353
|
+
else if ((mode & 0o170000) === 0o060000)
|
|
354
|
+
type = 'b';
|
|
355
|
+
const rwx = [
|
|
356
|
+
(mode & 0o400) ? 'r' : '-',
|
|
357
|
+
(mode & 0o200) ? 'w' : '-',
|
|
358
|
+
(mode & 0o100) ? 'x' : '-',
|
|
359
|
+
(mode & 0o040) ? 'r' : '-',
|
|
360
|
+
(mode & 0o020) ? 'w' : '-',
|
|
361
|
+
(mode & 0o010) ? 'x' : '-',
|
|
362
|
+
(mode & 0o004) ? 'r' : '-',
|
|
363
|
+
(mode & 0o002) ? 'w' : '-',
|
|
364
|
+
(mode & 0o001) ? 'x' : '-'
|
|
365
|
+
].join('');
|
|
366
|
+
return type + rwx;
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=sftp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sftp.js","sourceRoot":"","sources":["../../src/core/sftp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA0B7B,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IACf,WAAW,CAAe;IAElC,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC,WAAW,CAAC;QAE9C,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,IAAI,CAAC,MAAM,CAAC,IAAI,C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AAG;QAC1B,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAC1B,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAC1B,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAC1B,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;QAC1B,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;KAC3B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEX,OAAO,IAAI,GAAG,GAAG,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Client } from 'ssh2';
|
|
2
|
+
import { InteractiveSession, SessionOptions } from './session.js';
|
|
3
|
+
export interface SplitSessionOptions extends SessionOptions {
|
|
4
|
+
enableSidebar?: boolean;
|
|
5
|
+
sidebarWidth?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Manages an interactive split-pane SSH session:
|
|
9
|
+
* - Left pane: interactive remote PTY shell
|
|
10
|
+
* - Right pane: live server resource monitor (IP, user, CPU, RAM, Disk, Net, GPU)
|
|
11
|
+
* - Hotkeys: F2 or Ctrl+O to toggle sidebar expand/collapse
|
|
12
|
+
*/
|
|
13
|
+
export declare class SplitSession {
|
|
14
|
+
private session;
|
|
15
|
+
private collector?;
|
|
16
|
+
private client;
|
|
17
|
+
private options;
|
|
18
|
+
private sidebarVisible;
|
|
19
|
+
private sidebarWidth;
|
|
20
|
+
private lastMetrics?;
|
|
21
|
+
private isDestroyed;
|
|
22
|
+
private enteredAltScreen;
|
|
23
|
+
constructor(client: Client, options?: SplitSessionOptions);
|
|
24
|
+
getSession(): InteractiveSession;
|
|
25
|
+
private computeShellCols;
|
|
26
|
+
/**
|
|
27
|
+
* Start the interactive split session
|
|
28
|
+
*/
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Attach terminal stdin and stdout with split-pane multiplexing
|
|
32
|
+
*/
|
|
33
|
+
attachToLocalProcess(): void;
|
|
34
|
+
toggleSidebar(): void;
|
|
35
|
+
private enableTerminalMargins;
|
|
36
|
+
private disableTerminalMargins;
|
|
37
|
+
/**
|
|
38
|
+
* Draw the right-hand sidebar at its fixed column offset without moving the shell cursor
|
|
39
|
+
*/
|
|
40
|
+
drawSidebar(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=split-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-session.d.ts","sourceRoot":"","sources":["../../src/core/split-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIlE,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAmB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAsB;IAErC,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,EAmB5D;IAEM,UAAU,IAAI,kBAAkB,CAEtC;IAED,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBlC;IAED;;OAEG;IACI,oBAAoB,IAAI,IAAI,CA0FlC;IAEM,aAAa,IAAI,IAAI,CA4B3B;IAED,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,sBAAsB;IAM9B;;OAEG;IACI,WAAW,IAAI,IAAI,CAwCzB;CACF"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { InteractiveSession } from './session.js';
|
|
2
|
+
import { MetricsCollector } from './metrics.js';
|
|
3
|
+
import { SidebarRenderer, defaultSidebarTheme } from '../tui/sidebar.js';
|
|
4
|
+
/**
|
|
5
|
+
* Manages an interactive split-pane SSH session:
|
|
6
|
+
* - Left pane: interactive remote PTY shell
|
|
7
|
+
* - Right pane: live server resource monitor (IP, user, CPU, RAM, Disk, Net, GPU)
|
|
8
|
+
* - Hotkeys: F2 or Ctrl+O to toggle sidebar expand/collapse
|
|
9
|
+
*/
|
|
10
|
+
export class SplitSession {
|
|
11
|
+
session;
|
|
12
|
+
collector;
|
|
13
|
+
client;
|
|
14
|
+
options;
|
|
15
|
+
sidebarVisible;
|
|
16
|
+
sidebarWidth;
|
|
17
|
+
lastMetrics;
|
|
18
|
+
isDestroyed = false;
|
|
19
|
+
enteredAltScreen = false;
|
|
20
|
+
constructor(client, options = {}) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
const totalCols = process.stdout.columns || 80;
|
|
24
|
+
this.sidebarWidth = options.sidebarWidth || 34;
|
|
25
|
+
// Default to visible if terminal is wide enough (>= 90 cols)
|
|
26
|
+
const wantsSidebar = options.enableSidebar !== false;
|
|
27
|
+
this.sidebarVisible = wantsSidebar && totalCols >= 90;
|
|
28
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
29
|
+
const rows = process.stdout.rows || 24;
|
|
30
|
+
this.session = new InteractiveSession(client, {
|
|
31
|
+
...options,
|
|
32
|
+
cols: leftCols,
|
|
33
|
+
rows
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
getSession() {
|
|
37
|
+
return this.session;
|
|
38
|
+
}
|
|
39
|
+
computeShellCols(totalCols) {
|
|
40
|
+
if (!this.sidebarVisible) {
|
|
41
|
+
return totalCols;
|
|
42
|
+
}
|
|
43
|
+
// Shell takes remaining columns minus 1 for margin/separator
|
|
44
|
+
return Math.max(30, totalCols - this.sidebarWidth - 1);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Start the interactive split session
|
|
48
|
+
*/
|
|
49
|
+
async start() {
|
|
50
|
+
await this.session.start();
|
|
51
|
+
// Start background metrics collector over multiplexed SSH channel
|
|
52
|
+
try {
|
|
53
|
+
this.collector = new MetricsCollector(this.client, 2500);
|
|
54
|
+
this.collector.on('update', (metrics) => {
|
|
55
|
+
this.lastMetrics = metrics;
|
|
56
|
+
if (this.sidebarVisible && !this.isDestroyed) {
|
|
57
|
+
this.drawSidebar();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
this.collector.start();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Metrics collector is non-fatal; continue shell
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Attach terminal stdin and stdout with split-pane multiplexing
|
|
68
|
+
*/
|
|
69
|
+
attachToLocalProcess() {
|
|
70
|
+
const stdin = process.stdin;
|
|
71
|
+
const stdout = process.stdout;
|
|
72
|
+
const totalCols = stdout.columns || 80;
|
|
73
|
+
const totalRows = stdout.rows || 24;
|
|
74
|
+
if (this.sidebarVisible && stdout.isTTY) {
|
|
75
|
+
// Enter alternate screen buffer & clear to prevent previous terminal scrollback from showing
|
|
76
|
+
stdout.write('\x1b[?1049h\x1b[2J\x1b[H');
|
|
77
|
+
this.enteredAltScreen = true;
|
|
78
|
+
this.drawSidebar();
|
|
79
|
+
this.enableTerminalMargins();
|
|
80
|
+
}
|
|
81
|
+
// Set raw mode
|
|
82
|
+
if (stdin.isTTY) {
|
|
83
|
+
stdin.setRawMode(true);
|
|
84
|
+
stdin.resume();
|
|
85
|
+
}
|
|
86
|
+
// Handle terminal resize
|
|
87
|
+
const onResize = () => {
|
|
88
|
+
const cols = stdout.columns || 80;
|
|
89
|
+
const rows = stdout.rows || 24;
|
|
90
|
+
if (this.sidebarVisible && cols < 85) {
|
|
91
|
+
// Automatically hide sidebar on narrow terminals
|
|
92
|
+
this.sidebarVisible = false;
|
|
93
|
+
this.disableTerminalMargins();
|
|
94
|
+
}
|
|
95
|
+
const leftCols = this.computeShellCols(cols);
|
|
96
|
+
this.session.resize(leftCols, rows);
|
|
97
|
+
if (this.sidebarVisible) {
|
|
98
|
+
this.drawSidebar();
|
|
99
|
+
this.enableTerminalMargins();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.disableTerminalMargins();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
if (stdout.isTTY) {
|
|
106
|
+
stdout.on('resize', onResize);
|
|
107
|
+
}
|
|
108
|
+
// Stdin interceptor: listen for F2 or Ctrl+O to toggle sidebar
|
|
109
|
+
const onStdinData = (chunk) => {
|
|
110
|
+
const str = chunk.toString('utf8');
|
|
111
|
+
// F2: \x1bOQ or \x1b[12~ | Ctrl+O: \x0f
|
|
112
|
+
if (str === '\x1bOQ' || str === '\x1b[12~' || str === '\x0f') {
|
|
113
|
+
this.toggleSidebar();
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.session.write(chunk);
|
|
117
|
+
};
|
|
118
|
+
stdin.on('data', onStdinData);
|
|
119
|
+
// Shell output to stdout
|
|
120
|
+
this.session.on('data', (chunk) => {
|
|
121
|
+
stdout.write(chunk);
|
|
122
|
+
});
|
|
123
|
+
// Cleanup on session close
|
|
124
|
+
this.session.once('close', () => {
|
|
125
|
+
this.isDestroyed = true;
|
|
126
|
+
if (this.collector) {
|
|
127
|
+
this.collector.stop();
|
|
128
|
+
}
|
|
129
|
+
this.disableTerminalMargins();
|
|
130
|
+
if (this.enteredAltScreen && stdout.isTTY) {
|
|
131
|
+
// Exit alternate screen buffer, cleanly restoring user's original terminal
|
|
132
|
+
stdout.write('\x1b[?1049l');
|
|
133
|
+
this.enteredAltScreen = false;
|
|
134
|
+
}
|
|
135
|
+
if (stdin.isTTY) {
|
|
136
|
+
stdin.setRawMode(false);
|
|
137
|
+
stdin.pause();
|
|
138
|
+
}
|
|
139
|
+
stdin.removeListener('data', onStdinData);
|
|
140
|
+
if (stdout.isTTY) {
|
|
141
|
+
stdout.removeListener('resize', onResize);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
toggleSidebar() {
|
|
146
|
+
const stdout = process.stdout;
|
|
147
|
+
const totalCols = stdout.columns || 80;
|
|
148
|
+
const totalRows = stdout.rows || 24;
|
|
149
|
+
if (!this.sidebarVisible) {
|
|
150
|
+
// Cannot enable if terminal is too narrow
|
|
151
|
+
if (totalCols < 75) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.sidebarVisible = true;
|
|
155
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
156
|
+
if (!this.enteredAltScreen && stdout.isTTY) {
|
|
157
|
+
stdout.write('\x1b[?1049h');
|
|
158
|
+
this.enteredAltScreen = true;
|
|
159
|
+
}
|
|
160
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
161
|
+
this.drawSidebar();
|
|
162
|
+
this.enableTerminalMargins();
|
|
163
|
+
this.session.resize(leftCols, totalRows);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.sidebarVisible = false;
|
|
167
|
+
this.disableTerminalMargins();
|
|
168
|
+
// Clear screen and resize shell to 100%
|
|
169
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
170
|
+
this.session.resize(totalCols, totalRows);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
enableTerminalMargins() {
|
|
174
|
+
if (!process.stdout.isTTY)
|
|
175
|
+
return;
|
|
176
|
+
const totalCols = process.stdout.columns || 80;
|
|
177
|
+
const totalRows = process.stdout.rows || 24;
|
|
178
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
179
|
+
// DECLRMM enable (\x1b[?69h), set vertical margin (\x1b[1;{totalRows}r), set horizontal margin (\x1b[1;{leftCols}s)
|
|
180
|
+
process.stdout.write(`\x1b[?69h\x1b[1;${totalRows}r\x1b[1;${leftCols}s`);
|
|
181
|
+
}
|
|
182
|
+
disableTerminalMargins() {
|
|
183
|
+
if (!process.stdout.isTTY)
|
|
184
|
+
return;
|
|
185
|
+
// DECLRMM disable (\x1b[?69l), reset scrolling region (\x1b[r)
|
|
186
|
+
process.stdout.write(`\x1b[?69l\x1b[r`);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Draw the right-hand sidebar at its fixed column offset without moving the shell cursor
|
|
190
|
+
*/
|
|
191
|
+
drawSidebar() {
|
|
192
|
+
if (!this.sidebarVisible || this.isDestroyed || !process.stdout.isTTY)
|
|
193
|
+
return;
|
|
194
|
+
const stdout = process.stdout;
|
|
195
|
+
const totalCols = stdout.columns || 80;
|
|
196
|
+
const totalRows = stdout.rows || 24;
|
|
197
|
+
const leftCols = this.computeShellCols(totalCols);
|
|
198
|
+
const sideStartCol = leftCols + 2; // +1 separator, +2 content
|
|
199
|
+
if (sideStartCol > totalCols - 10)
|
|
200
|
+
return;
|
|
201
|
+
const lines = SidebarRenderer.render(this.lastMetrics, this.sidebarWidth, totalRows, defaultSidebarTheme);
|
|
202
|
+
let buf = '';
|
|
203
|
+
// 1. Save cursor & hide cursor while updating sidebar
|
|
204
|
+
buf += '\x1b7\x1b[?25l';
|
|
205
|
+
// 2. Temporarily disable horizontal margin so cursor can move outside leftCols
|
|
206
|
+
buf += '\x1b[?69l';
|
|
207
|
+
// 3. Temporarily disable auto-wrap mode (DECAWM) to guarantee zero wrap-around to column 1
|
|
208
|
+
buf += '\x1b[?7l';
|
|
209
|
+
for (let r = 1; r <= Math.min(lines.length, totalRows); r++) {
|
|
210
|
+
const line = lines[r - 1];
|
|
211
|
+
// Position cursor at row r, column sideStartCol
|
|
212
|
+
buf += `\x1b[${r};${sideStartCol}H${line}`;
|
|
213
|
+
}
|
|
214
|
+
// 4. Re-enable auto-wrap mode for shell
|
|
215
|
+
buf += '\x1b[?7h';
|
|
216
|
+
// 5. Re-enable horizontal margin for shell
|
|
217
|
+
buf += `\x1b[?69h\x1b[1;${totalRows}r\x1b[1;${leftCols}s`;
|
|
218
|
+
// 6. Restore cursor & show cursor
|
|
219
|
+
buf += '\x1b8\x1b[?25h';
|
|
220
|
+
stdout.write(buf);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=split-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-session.js","sourceRoot":"","sources":["../../src/core/split-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAOzE;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACf,OAAO,CAAqB;IAC5B,SAAS,CAAoB;IAC7B,MAAM,CAAS;IACf,OAAO,CAAsB;IAE7B,cAAc,CAAU;IACxB,YAAY,CAAS;IACrB,WAAW,CAAiB;IAC5B,WAAW,GAAG,KAAK,CAAC;IACpB,gBAAgB,GAAG,KAAK,CAAC;IAEjC,YAAY,MAAc,EAAE,OAAO,GAAwB,EAAE;QAC3D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;QAE/C,6DAA6D;Q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