@pyrokine/mcp-ssh 2.4.0 → 2.4.2
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 +193 -109
- package/README_zh.md +238 -130
- package/dist/directory-verification.js +29 -4
- package/dist/file-ops.d.ts +31 -6
- package/dist/file-ops.js +493 -169
- package/dist/forward-manager.d.ts +17 -1
- package/dist/forward-manager.js +397 -89
- package/dist/operation-manager.d.ts +13 -6
- package/dist/operation-manager.js +200 -99
- package/dist/pty-manager.d.ts +3 -3
- package/dist/pty-manager.js +61 -15
- package/dist/session-manager.d.ts +29 -4
- package/dist/session-manager.js +288 -67
- package/dist/sftp-timeout.d.ts +9 -0
- package/dist/sftp-timeout.js +49 -0
- package/dist/tools/connection.js +85 -38
- package/dist/tools/exec.js +16 -6
- package/dist/tools/file.d.ts +1 -0
- package/dist/tools/file.js +276 -148
- package/dist/tools/forward.js +11 -8
- package/dist/tools/operation.js +12 -3
- package/dist/tools/pty.js +17 -13
- package/dist/tools/schema.d.ts +4 -0
- package/dist/tools/schema.js +9 -0
- package/dist/types.d.ts +16 -0
- package/dist/utf8.d.ts +3 -0
- package/dist/utf8.js +44 -0
- package/package.json +6 -6
package/dist/file-ops.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SSH File Operations - 文件操作
|
|
3
3
|
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
4
5
|
import { SFTPWrapper } from 'ssh2';
|
|
5
6
|
import { FileInfo, TransferProgress } from './types.js';
|
|
6
7
|
type RsyncProbeResult = {
|
|
@@ -15,6 +16,14 @@ type RsyncProbeResult = {
|
|
|
15
16
|
};
|
|
16
17
|
/** 由 SessionManager.disconnect 调用,防止 alias 重连后读到旧主机的判断 */
|
|
17
18
|
export declare function clearRsyncCache(alias?: string): void;
|
|
19
|
+
export declare function validateLocalPathPolicy(localPath: string): void;
|
|
20
|
+
type ValidatedLocalUploadSource = {
|
|
21
|
+
expandedPath: string;
|
|
22
|
+
linkStats: fs.Stats;
|
|
23
|
+
stats: fs.Stats;
|
|
24
|
+
};
|
|
25
|
+
export declare function validateUploadFileSource(localPath: string): ValidatedLocalUploadSource;
|
|
26
|
+
export declare function validateSyncUploadSource(localPath: string, followSymlinks?: boolean): ValidatedLocalUploadSource;
|
|
18
27
|
export declare function probeLocalPath(localPath: string, followSymlinks?: boolean): {
|
|
19
28
|
exists: boolean;
|
|
20
29
|
inputPath: string;
|
|
@@ -46,10 +55,21 @@ export declare function probeLocalPath(localPath: string, followSymlinks?: boole
|
|
|
46
55
|
matched?: boolean;
|
|
47
56
|
};
|
|
48
57
|
};
|
|
58
|
+
export declare function hashRemoteFileDigest(alias: string, remotePath: string, algorithm: 'md5' | 'sha256'): Promise<string>;
|
|
59
|
+
export declare class RemoteRenameNotStartedError extends Error {
|
|
60
|
+
constructor(message: string);
|
|
61
|
+
}
|
|
62
|
+
export declare function renameRemoteFile(alias: string, sourcePath: string, targetPath: string, replaceExisting?: boolean, timeout?: number): Promise<void>;
|
|
63
|
+
export declare function removeRemoteFile(alias: string, remotePath: string): Promise<void>;
|
|
64
|
+
export declare class UploadFileError extends Error {
|
|
65
|
+
readonly remoteCreated: boolean;
|
|
66
|
+
readonly details?: Record<string, unknown>;
|
|
67
|
+
constructor(message: string, remoteCreated: boolean, options?: ErrorOptions);
|
|
68
|
+
}
|
|
49
69
|
/**
|
|
50
70
|
* 上传文件
|
|
51
71
|
*/
|
|
52
|
-
export declare function uploadFile(alias: string, localPath: string, remotePath: string, onProgress?: (progress: TransferProgress) => void, sharedSftp?: SFTPWrapper, createMode?: number, signal?: AbortSignal): Promise<{
|
|
72
|
+
export declare function uploadFile(alias: string, localPath: string, remotePath: string, onProgress?: (progress: TransferProgress) => void, sharedSftp?: SFTPWrapper, createMode?: number, signal?: AbortSignal, followSymlinks?: boolean, exclusive?: boolean, timeout?: number): Promise<{
|
|
53
73
|
success: boolean;
|
|
54
74
|
size: number;
|
|
55
75
|
createMode: string;
|
|
@@ -57,9 +77,10 @@ export declare function uploadFile(alias: string, localPath: string, remotePath:
|
|
|
57
77
|
/**
|
|
58
78
|
* 下载文件
|
|
59
79
|
*/
|
|
60
|
-
export declare function downloadFile(alias: string, remotePath: string, localPath: string, onProgress?: (progress: TransferProgress) => void, sharedSftp?: SFTPWrapper, signal?: AbortSignal): Promise<{
|
|
80
|
+
export declare function downloadFile(alias: string, remotePath: string, localPath: string, onProgress?: (progress: TransferProgress) => void, sharedSftp?: SFTPWrapper, signal?: AbortSignal, timeout?: number): Promise<{
|
|
61
81
|
success: boolean;
|
|
62
82
|
size: number;
|
|
83
|
+
atomic: true;
|
|
63
84
|
}>;
|
|
64
85
|
export declare const DEFAULT_READ_FILE_MAX_BYTES: number;
|
|
65
86
|
export declare const HARD_READ_FILE_MAX_BYTES: number;
|
|
@@ -69,13 +90,17 @@ type ReadFileOptions = {
|
|
|
69
90
|
offset?: number;
|
|
70
91
|
tail?: boolean;
|
|
71
92
|
lineRange?: string;
|
|
93
|
+
timeout?: number;
|
|
72
94
|
};
|
|
73
95
|
type ReadFileResult = {
|
|
74
96
|
content: string;
|
|
75
97
|
size: number;
|
|
76
98
|
total_size: number;
|
|
77
99
|
read_offset: number;
|
|
100
|
+
requested_offset?: number;
|
|
78
101
|
read_bytes: number;
|
|
102
|
+
read_end?: number;
|
|
103
|
+
next_offset?: number;
|
|
79
104
|
remaining_bytes?: number;
|
|
80
105
|
sample_kind: ReadFileSampleKind;
|
|
81
106
|
truncated: boolean;
|
|
@@ -93,22 +118,22 @@ export declare function readFile(alias: string, remotePath: string, options?: nu
|
|
|
93
118
|
/**
|
|
94
119
|
* 写入远程文件
|
|
95
120
|
*/
|
|
96
|
-
export declare function writeFile(alias: string, remotePath: string, content: string, append?: boolean): Promise<{
|
|
121
|
+
export declare function writeFile(alias: string, remotePath: string, content: string, append?: boolean, timeout?: number): Promise<{
|
|
97
122
|
success: boolean;
|
|
98
123
|
size: number;
|
|
99
124
|
}>;
|
|
100
125
|
/**
|
|
101
126
|
* 列出目录内容
|
|
102
127
|
*/
|
|
103
|
-
export declare function listDir(alias: string, remotePath: string, showHidden?: boolean, sharedSftp?: SFTPWrapper): Promise<FileInfo[]>;
|
|
128
|
+
export declare function listDir(alias: string, remotePath: string, showHidden?: boolean, sharedSftp?: SFTPWrapper, timeout?: number): Promise<FileInfo[]>;
|
|
104
129
|
/**
|
|
105
130
|
* 获取文件信息
|
|
106
131
|
*/
|
|
107
|
-
export declare function getFileInfo(alias: string, remotePath: string): Promise<FileInfo>;
|
|
132
|
+
export declare function getFileInfo(alias: string, remotePath: string, timeout?: number): Promise<FileInfo>;
|
|
108
133
|
/**
|
|
109
134
|
* 创建目录
|
|
110
135
|
*/
|
|
111
|
-
export declare function mkdir(alias: string, remotePath: string, recursive?: boolean): Promise<boolean>;
|
|
136
|
+
export declare function mkdir(alias: string, remotePath: string, recursive?: boolean, sharedSftp?: SFTPWrapper, timeout?: number): Promise<boolean>;
|
|
112
137
|
/**
|
|
113
138
|
* 检查远程是否安装 rsync
|
|
114
139
|
*/
|