@pyrokine/mcp-ssh 2.3.2 → 2.4.1

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.
@@ -8,7 +8,7 @@
8
8
  * - 会话持久化
9
9
  */
10
10
  import { Client, SFTPWrapper } from 'ssh2';
11
- import { ExecOptions, ExecResult, PortForwardInfo, PtyOptions, PtySessionInfo, SSHConnectionConfig, SSHSessionInfo } from './types.js';
11
+ import { ExecOptions, ExecResult, ExternalTransferCapability, ForwardCloseOptions, ForwardCloseResult, OperationCancelResult, OperationInfo, OperationReadResult, OperationStartOptions, PortForwardInfo, PtyOptions, PtySessionInfo, SSHConnectionConfig, SSHSessionBrief, SSHSessionDetail } from './types.js';
12
12
  interface SSHSession {
13
13
  client: Client;
14
14
  config: SSHConnectionConfig;
@@ -20,12 +20,26 @@ interface SSHSession {
20
20
  /** 当前正在等待的重连定时器,disconnect 时需要清除以防 zombie 重连 */
21
21
  reconnectTimer?: NodeJS.Timeout;
22
22
  }
23
+ interface SessionConnectionInfo {
24
+ alias: string;
25
+ identity: string;
26
+ loginUser: string;
27
+ runAs?: string;
28
+ host: string;
29
+ port: number;
30
+ defaultEnvKeys: string[];
31
+ envKeys: string[];
32
+ hasJumpHost: boolean;
33
+ }
23
34
  export declare class SessionManager {
24
35
  private sessions;
25
36
  /** per-alias connect 进行中的 Promise,防止并发 connect 同一 alias 时重复建连 */
26
37
  private connectInFlight;
38
+ private pendingConnections;
39
+ private connectionGenerations;
27
40
  private readonly ptyManager;
28
41
  private readonly forwardManager;
42
+ private readonly operationManager;
29
43
  private readonly persistPath;
30
44
  private defaultKeepaliveInterval;
31
45
  private defaultKeepaliveCountMax;
@@ -52,14 +66,23 @@ export declare class SessionManager {
52
66
  * 获取会话
53
67
  */
54
68
  getSession(alias: string): SSHSession;
55
- /**
56
- * 列出所有会话
57
- */
58
- listSessions(): SSHSessionInfo[];
69
+ listSessions(): SSHSessionBrief[];
70
+ listSessionDetails(): SSHSessionDetail[];
71
+ getSessionConnectionInfo(alias: string): SessionConnectionInfo;
72
+ getExternalTransferCapability(alias: string): ExternalTransferCapability;
59
73
  /**
60
74
  * 执行命令
61
75
  */
62
76
  exec(alias: string, command: string, options?: ExecOptions): Promise<ExecResult>;
77
+ operationStart(alias: string, command: string, options?: OperationStartOptions): Promise<OperationInfo>;
78
+ operationStatus(operationId: string): OperationInfo;
79
+ operationRead(operationId: string, options?: {
80
+ stdoutOffset?: number;
81
+ stderrOffset?: number;
82
+ maxBytes?: number;
83
+ }): OperationReadResult;
84
+ operationCancel(operationId: string): Promise<OperationCancelResult>;
85
+ operationList(alias?: string): OperationInfo[];
63
86
  /**
64
87
  * 以其他用户身份执行命令
65
88
  *
@@ -105,17 +128,25 @@ export declare class SessionManager {
105
128
  forwardId: string;
106
129
  localPort: number;
107
130
  }>;
108
- forwardRemote(alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<string>;
109
- forwardClose(forwardId: string): boolean;
131
+ forwardRemote(alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<{
132
+ forwardId: string;
133
+ remotePort: number;
134
+ }>;
135
+ forwardClose(forwardId: string, options?: ForwardCloseOptions): Promise<ForwardCloseResult>;
110
136
  forwardList(): PortForwardInfo[];
137
+ private isSshAgentAvailable;
138
+ private isOpenSshKeyPathUsable;
111
139
  private sessionIdentity;
112
140
  private configIdentity;
141
+ private connectionFingerprint;
113
142
  private resultMetadata;
114
143
  private appendOutputTail;
115
144
  private recommendedReadCommand;
116
145
  private emptyOutputFailureMetadata;
117
146
  private outputMetadata;
118
147
  private normalizeMaxOutputSize;
148
+ private openOperationStream;
149
+ private cancelRemoteOperation;
119
150
  private execDirect;
120
151
  private connectInternal;
121
152
  /**
@@ -131,19 +162,24 @@ export declare class SessionManager {
131
162
  * 通过跳板机转发连接
132
163
  */
133
164
  private forwardConnection;
165
+ private getConnectionGeneration;
166
+ private isCurrentPendingConnection;
167
+ private cancelPendingConnection;
168
+ private invalidateAliasResources;
134
169
  /**
135
170
  * 检查连接是否存活
136
171
  */
137
172
  private isAlive;
173
+ private isCurrentSession;
174
+ private closeClientChannel;
175
+ private destroySftp;
138
176
  /**
139
177
  * 调度自动重连(支持多次重试)
140
178
  */
141
179
  private scheduleReconnect;
142
180
  private createCommandTimeoutError;
143
- /**
144
- * 根据错误类型生成排查建议
145
- */
146
- private diagnoseConnectionError;
181
+ private createConnectionError;
182
+ private classifyConnectionError;
147
183
  /**
148
184
  * 转义 shell 参数(使用单引号方式,防止命令注入)
149
185
  * 委托给 tools/utils.ts 的共享实现