@pyrokine/mcp-ssh 2.4.2 → 3.0.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/README.md +137 -26
- package/README_zh.md +121 -28
- package/dist/command-risk.d.ts +2 -1
- package/dist/command-risk.js +238 -87
- package/dist/directory-verification.d.ts +5 -3
- package/dist/directory-verification.js +187 -222
- package/dist/file-mode.d.ts +6 -0
- package/dist/file-mode.js +71 -0
- package/dist/file-ops.d.ts +30 -6
- package/dist/file-ops.js +618 -207
- package/dist/forward-manager.d.ts +2 -0
- package/dist/forward-manager.js +19 -10
- package/dist/operation-manager.d.ts +2 -1
- package/dist/operation-manager.js +8 -2
- package/dist/pty-manager.d.ts +5 -13
- package/dist/pty-manager.js +47 -15
- package/dist/remote-platform.d.ts +13 -0
- package/dist/remote-platform.js +132 -0
- package/dist/security.js +12 -2
- package/dist/session-manager.d.ts +13 -13
- package/dist/session-manager.js +320 -90
- package/dist/ssh-config.d.ts +3 -0
- package/dist/ssh-config.js +48 -20
- package/dist/tools/connection.js +59 -0
- package/dist/tools/exec.d.ts +1 -0
- package/dist/tools/exec.js +100 -31
- package/dist/tools/file.js +166 -85
- package/dist/tools/operation.js +1 -1
- package/dist/tools/pty.js +5 -3
- package/dist/tools/utils.js +2 -2
- package/dist/types.d.ts +37 -0
- package/dist/utf8.d.ts +1 -0
- package/dist/utf8.js +10 -0
- package/dist/windows-acl.d.ts +4 -0
- package/dist/windows-acl.js +109 -0
- package/package.json +4 -4
package/dist/file-ops.d.ts
CHANGED
|
@@ -16,6 +16,17 @@ type RsyncProbeResult = {
|
|
|
16
16
|
};
|
|
17
17
|
/** 由 SessionManager.disconnect 调用,防止 alias 重连后读到旧主机的判断 */
|
|
18
18
|
export declare function clearRsyncCache(alias?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* 校验本地路径是否在 SSH_MCP_FILE_OPS_ALLOW_DIRS 白名单内
|
|
21
|
+
*
|
|
22
|
+
* 默认未设置环境变量时不限制(保留灵活性)
|
|
23
|
+
* 设置后,所有 upload/download/sync 的本地路径必须在白名单目录之一内,否则抛出错误
|
|
24
|
+
*
|
|
25
|
+
* 格式:path.delimiter 分隔的绝对路径列表(POSIX `:`,Windows `;`),如 `/tmp:/home/user/work`
|
|
26
|
+
* 安全性:路径会通过 fs.realpathSync 解析 symlink,防止 symlink 逃出白名单
|
|
27
|
+
*/
|
|
28
|
+
export declare function convertRsyncPath(value: string, profile: 'posix' | 'native-win32' | 'msys2' | 'cygwin'): string;
|
|
29
|
+
export declare function quoteRsyncSshArg(value: string | number, profile?: 'posix' | 'native-win32' | 'msys2' | 'cygwin'): string;
|
|
19
30
|
export declare function validateLocalPathPolicy(localPath: string): void;
|
|
20
31
|
type ValidatedLocalUploadSource = {
|
|
21
32
|
expandedPath: string;
|
|
@@ -35,6 +46,7 @@ export declare function probeLocalPath(localPath: string, followSymlinks?: boole
|
|
|
35
46
|
};
|
|
36
47
|
size?: undefined;
|
|
37
48
|
mode?: undefined;
|
|
49
|
+
modeValue?: undefined;
|
|
38
50
|
mtimeMs?: undefined;
|
|
39
51
|
isSymlink?: undefined;
|
|
40
52
|
isDirectory?: undefined;
|
|
@@ -46,6 +58,7 @@ export declare function probeLocalPath(localPath: string, followSymlinks?: boole
|
|
|
46
58
|
resolvedPath: string;
|
|
47
59
|
size: number;
|
|
48
60
|
mode: string;
|
|
61
|
+
modeValue: number;
|
|
49
62
|
mtimeMs: number;
|
|
50
63
|
isSymlink: boolean;
|
|
51
64
|
isDirectory: boolean;
|
|
@@ -56,11 +69,15 @@ export declare function probeLocalPath(localPath: string, followSymlinks?: boole
|
|
|
56
69
|
};
|
|
57
70
|
};
|
|
58
71
|
export declare function hashRemoteFileDigest(alias: string, remotePath: string, algorithm: 'md5' | 'sha256'): Promise<string>;
|
|
72
|
+
export declare function atomicReplaceCapability(alias: string, timeout?: number): Promise<{
|
|
73
|
+
atomicReplaceSupported: boolean;
|
|
74
|
+
reason?: string;
|
|
75
|
+
}>;
|
|
59
76
|
export declare class RemoteRenameNotStartedError extends Error {
|
|
60
77
|
constructor(message: string);
|
|
61
78
|
}
|
|
62
79
|
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>;
|
|
80
|
+
export declare function removeRemoteFile(alias: string, remotePath: string, timeout?: number): Promise<void>;
|
|
64
81
|
export declare class UploadFileError extends Error {
|
|
65
82
|
readonly remoteCreated: boolean;
|
|
66
83
|
readonly details?: Record<string, unknown>;
|
|
@@ -85,7 +102,10 @@ export declare function downloadFile(alias: string, remotePath: string, localPat
|
|
|
85
102
|
export declare const DEFAULT_READ_FILE_MAX_BYTES: number;
|
|
86
103
|
export declare const HARD_READ_FILE_MAX_BYTES: number;
|
|
87
104
|
type ReadFileSampleKind = 'full' | 'head' | 'tail' | 'range' | 'line_range';
|
|
105
|
+
export type ReadEncoding = 'auto' | 'utf8' | 'utf16le' | 'utf16be' | 'gbk';
|
|
88
106
|
type ReadFileOptions = {
|
|
107
|
+
encoding?: ReadEncoding;
|
|
108
|
+
binary?: boolean;
|
|
89
109
|
maxBytes?: number;
|
|
90
110
|
offset?: number;
|
|
91
111
|
tail?: boolean;
|
|
@@ -94,6 +114,8 @@ type ReadFileOptions = {
|
|
|
94
114
|
};
|
|
95
115
|
type ReadFileResult = {
|
|
96
116
|
content: string;
|
|
117
|
+
encoding?: ReadEncoding | 'base64';
|
|
118
|
+
content_base64?: string;
|
|
97
119
|
size: number;
|
|
98
120
|
total_size: number;
|
|
99
121
|
read_offset: number;
|
|
@@ -110,11 +132,12 @@ type ReadFileResult = {
|
|
|
110
132
|
byte_limit_reached?: boolean;
|
|
111
133
|
final_line_terminated?: boolean;
|
|
112
134
|
};
|
|
113
|
-
export declare function buildLineRangeAwkProgram(start: number, end: number): string;
|
|
114
135
|
/**
|
|
115
136
|
* 读取远程文件内容
|
|
116
137
|
*/
|
|
117
138
|
export declare function readFile(alias: string, remotePath: string, options?: number | ReadFileOptions): Promise<ReadFileResult>;
|
|
139
|
+
export declare function createEmptyRemoteFile(alias: string, remotePath: string, timeout?: number): Promise<void>;
|
|
140
|
+
export declare function prepareWindowsRemotePrivateFile(alias: string, remotePath: string, timeout?: number, shellPath?: string): Promise<void>;
|
|
118
141
|
/**
|
|
119
142
|
* 写入远程文件
|
|
120
143
|
*/
|
|
@@ -125,19 +148,19 @@ export declare function writeFile(alias: string, remotePath: string, content: st
|
|
|
125
148
|
/**
|
|
126
149
|
* 列出目录内容
|
|
127
150
|
*/
|
|
128
|
-
export declare function listDir(alias: string, remotePath: string, showHidden?: boolean, sharedSftp?: SFTPWrapper, timeout?: number): Promise<FileInfo[]>;
|
|
151
|
+
export declare function listDir(alias: string, remotePath: string, showHidden?: boolean, sharedSftp?: SFTPWrapper, timeout?: number, style?: 'posix' | 'win32' | 'sftp-posix'): Promise<FileInfo[]>;
|
|
129
152
|
/**
|
|
130
153
|
* 获取文件信息
|
|
131
154
|
*/
|
|
132
|
-
export declare function getFileInfo(alias: string, remotePath: string, timeout?: number): Promise<FileInfo>;
|
|
155
|
+
export declare function getFileInfo(alias: string, remotePath: string, timeout?: number, style?: 'posix' | 'win32' | 'sftp-posix'): Promise<FileInfo>;
|
|
133
156
|
/**
|
|
134
157
|
* 创建目录
|
|
135
158
|
*/
|
|
136
|
-
export declare function mkdir(alias: string, remotePath: string, recursive?: boolean, sharedSftp?: SFTPWrapper, timeout?: number): Promise<boolean>;
|
|
159
|
+
export declare function mkdir(alias: string, remotePath: string, recursive?: boolean, sharedSftp?: SFTPWrapper, timeout?: number, style?: 'posix' | 'win32' | 'sftp-posix'): Promise<boolean>;
|
|
137
160
|
/**
|
|
138
161
|
* 检查远程是否安装 rsync
|
|
139
162
|
*/
|
|
140
|
-
export declare function checkRsync(alias: string, timeout?: number): Promise<RsyncProbeResult>;
|
|
163
|
+
export declare function checkRsync(alias: string, timeout?: number, executable?: string, shell?: 'posix' | 'cmd' | 'powershell'): Promise<RsyncProbeResult>;
|
|
141
164
|
type SyncOptions = {
|
|
142
165
|
delete?: boolean;
|
|
143
166
|
dryRun?: boolean;
|
|
@@ -149,6 +172,7 @@ type SyncOptions = {
|
|
|
149
172
|
operationTimeout?: number;
|
|
150
173
|
sourceIsDirectory?: boolean;
|
|
151
174
|
signal?: AbortSignal;
|
|
175
|
+
remotePathStyle?: 'posix' | 'win32' | 'sftp-posix';
|
|
152
176
|
};
|
|
153
177
|
/**
|
|
154
178
|
* 智能文件同步(根据连接能力选择 rsync 或 SFTP)
|