@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.
@@ -8,7 +8,7 @@
8
8
  * - 会话持久化
9
9
  */
10
10
  import { Client, SFTPWrapper } from 'ssh2';
11
- import { ExecOptions, ExecResult, ExternalTransferCapability, ForwardCloseOptions, ForwardCloseResult, OperationCancelResult, OperationInfo, OperationReadResult, OperationStartOptions, PortForwardInfo, PtyOptions, PtySessionInfo, SSHConnectionConfig, SSHSessionBrief, SSHSessionDetail } from './types.js';
11
+ import { ExecOptions, ExecResult, ExternalTransferCapability, ForwardCloseOptions, ForwardCloseResult, OperationCancelResult, OperationInfo, OperationReadResult, OperationStartOptions, PortForwardInfo, PtyCloseResult, PtyOptions, PtySessionInfo, PtyWriteResult, SSHConnectionConfig, SSHSessionBrief, SSHSessionDetail } from './types.js';
12
12
  interface SSHSession {
13
13
  client: Client;
14
14
  config: SSHConnectionConfig;
@@ -20,10 +20,23 @@ 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;
29
42
  private readonly operationManager;
@@ -55,6 +68,7 @@ export declare class SessionManager {
55
68
  getSession(alias: string): SSHSession;
56
69
  listSessions(): SSHSessionBrief[];
57
70
  listSessionDetails(): SSHSessionDetail[];
71
+ getSessionConnectionInfo(alias: string): SessionConnectionInfo;
58
72
  getExternalTransferCapability(alias: string): ExternalTransferCapability;
59
73
  /**
60
74
  * 执行命令
@@ -91,7 +105,7 @@ export declare class SessionManager {
91
105
  */
92
106
  getSftp(alias: string): Promise<SFTPWrapper>;
93
107
  ptyStart(alias: string, command: string, options?: PtyOptions): Promise<string>;
94
- ptyWrite(ptyId: string, data: string): boolean;
108
+ ptyWrite(ptyId: string, data: string): PtyWriteResult;
95
109
  ptyRead(ptyId: string, options?: {
96
110
  mode?: 'screen' | 'raw';
97
111
  clear?: boolean;
@@ -108,19 +122,23 @@ export declare class SessionManager {
108
122
  foregroundProcess: string;
109
123
  };
110
124
  ptyResize(ptyId: string, rows: number, cols: number): boolean;
111
- ptyClose(ptyId: string): boolean;
125
+ ptyClose(ptyId: string): PtyCloseResult;
112
126
  ptyList(): PtySessionInfo[];
113
127
  forwardLocal(alias: string, localPort: number, remoteHost: string, remotePort: number, localHost?: string): Promise<{
114
128
  forwardId: string;
115
129
  localPort: number;
116
130
  }>;
117
- forwardRemote(alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<string>;
131
+ forwardRemote(alias: string, remotePort: number, localHost: string, localPort: number, remoteHost?: string): Promise<{
132
+ forwardId: string;
133
+ remotePort: number;
134
+ }>;
118
135
  forwardClose(forwardId: string, options?: ForwardCloseOptions): Promise<ForwardCloseResult>;
119
136
  forwardList(): PortForwardInfo[];
120
137
  private isSshAgentAvailable;
121
138
  private isOpenSshKeyPathUsable;
122
139
  private sessionIdentity;
123
140
  private configIdentity;
141
+ private connectionFingerprint;
124
142
  private resultMetadata;
125
143
  private appendOutputTail;
126
144
  private recommendedReadCommand;
@@ -144,10 +162,17 @@ export declare class SessionManager {
144
162
  * 通过跳板机转发连接
145
163
  */
146
164
  private forwardConnection;
165
+ private getConnectionGeneration;
166
+ private isCurrentPendingConnection;
167
+ private cancelPendingConnection;
168
+ private invalidateAliasResources;
147
169
  /**
148
170
  * 检查连接是否存活
149
171
  */
150
172
  private isAlive;
173
+ private isCurrentSession;
174
+ private closeClientChannel;
175
+ private destroySftp;
151
176
  /**
152
177
  * 调度自动重连(支持多次重试)
153
178
  */