ssh-agent-workspace 1.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.
Files changed (188) hide show
  1. package/README.md +319 -0
  2. package/dist/__tests__/SSHManager.test.d.ts +2 -0
  3. package/dist/__tests__/SSHManager.test.d.ts.map +1 -0
  4. package/dist/__tests__/SSHManager.test.js +134 -0
  5. package/dist/__tests__/SSHManager.test.js.map +1 -0
  6. package/dist/__tests__/SessionManager.test.d.ts +2 -0
  7. package/dist/__tests__/SessionManager.test.d.ts.map +1 -0
  8. package/dist/__tests__/SessionManager.test.js +141 -0
  9. package/dist/__tests__/SessionManager.test.js.map +1 -0
  10. package/dist/__tests__/StorageManager.test.d.ts +2 -0
  11. package/dist/__tests__/StorageManager.test.d.ts.map +1 -0
  12. package/dist/__tests__/StorageManager.test.js +171 -0
  13. package/dist/__tests__/StorageManager.test.js.map +1 -0
  14. package/dist/__tests__/ansi.test.d.ts +2 -0
  15. package/dist/__tests__/ansi.test.d.ts.map +1 -0
  16. package/dist/__tests__/ansi.test.js +41 -0
  17. package/dist/__tests__/ansi.test.js.map +1 -0
  18. package/dist/__tests__/security.test.d.ts +2 -0
  19. package/dist/__tests__/security.test.d.ts.map +1 -0
  20. package/dist/__tests__/security.test.js +87 -0
  21. package/dist/__tests__/security.test.js.map +1 -0
  22. package/dist/__tests__/validation.test.d.ts +2 -0
  23. package/dist/__tests__/validation.test.d.ts.map +1 -0
  24. package/dist/__tests__/validation.test.js +23 -0
  25. package/dist/__tests__/validation.test.js.map +1 -0
  26. package/dist/core/HostSecurityManager.d.ts +25 -0
  27. package/dist/core/HostSecurityManager.d.ts.map +1 -0
  28. package/dist/core/HostSecurityManager.js +76 -0
  29. package/dist/core/HostSecurityManager.js.map +1 -0
  30. package/dist/core/SSHManager.d.ts +48 -0
  31. package/dist/core/SSHManager.d.ts.map +1 -0
  32. package/dist/core/SSHManager.js +288 -0
  33. package/dist/core/SSHManager.js.map +1 -0
  34. package/dist/core/SessionManager.d.ts +15 -0
  35. package/dist/core/SessionManager.d.ts.map +1 -0
  36. package/dist/core/SessionManager.js +96 -0
  37. package/dist/core/SessionManager.js.map +1 -0
  38. package/dist/core/StorageManager.d.ts +27 -0
  39. package/dist/core/StorageManager.d.ts.map +1 -0
  40. package/dist/core/StorageManager.js +87 -0
  41. package/dist/core/StorageManager.js.map +1 -0
  42. package/dist/core/TmuxManager.d.ts +21 -0
  43. package/dist/core/TmuxManager.d.ts.map +1 -0
  44. package/dist/core/TmuxManager.js +110 -0
  45. package/dist/core/TmuxManager.js.map +1 -0
  46. package/dist/core/ToolConfigManager.d.ts +15 -0
  47. package/dist/core/ToolConfigManager.d.ts.map +1 -0
  48. package/dist/core/ToolConfigManager.js +57 -0
  49. package/dist/core/ToolConfigManager.js.map +1 -0
  50. package/dist/index.d.ts +3 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +169 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/server.d.ts +44 -0
  55. package/dist/server.d.ts.map +1 -0
  56. package/dist/server.js +152 -0
  57. package/dist/server.js.map +1 -0
  58. package/dist/tools/backup.d.ts +74 -0
  59. package/dist/tools/backup.d.ts.map +1 -0
  60. package/dist/tools/backup.js +152 -0
  61. package/dist/tools/backup.js.map +1 -0
  62. package/dist/tools/connect.d.ts +46 -0
  63. package/dist/tools/connect.d.ts.map +1 -0
  64. package/dist/tools/connect.js +235 -0
  65. package/dist/tools/connect.js.map +1 -0
  66. package/dist/tools/connection_status.d.ts +39 -0
  67. package/dist/tools/connection_status.d.ts.map +1 -0
  68. package/dist/tools/connection_status.js +67 -0
  69. package/dist/tools/connection_status.js.map +1 -0
  70. package/dist/tools/db_query.d.ts +103 -0
  71. package/dist/tools/db_query.d.ts.map +1 -0
  72. package/dist/tools/db_query.js +194 -0
  73. package/dist/tools/db_query.js.map +1 -0
  74. package/dist/tools/deploy.d.ts +127 -0
  75. package/dist/tools/deploy.d.ts.map +1 -0
  76. package/dist/tools/deploy.js +201 -0
  77. package/dist/tools/deploy.js.map +1 -0
  78. package/dist/tools/disconnect.d.ts +46 -0
  79. package/dist/tools/disconnect.d.ts.map +1 -0
  80. package/dist/tools/disconnect.js +77 -0
  81. package/dist/tools/disconnect.js.map +1 -0
  82. package/dist/tools/exec.d.ts +69 -0
  83. package/dist/tools/exec.d.ts.map +1 -0
  84. package/dist/tools/exec.js +188 -0
  85. package/dist/tools/exec.js.map +1 -0
  86. package/dist/tools/group_exec.d.ts +80 -0
  87. package/dist/tools/group_exec.d.ts.map +1 -0
  88. package/dist/tools/group_exec.js +150 -0
  89. package/dist/tools/group_exec.js.map +1 -0
  90. package/dist/tools/health_check.d.ts +38 -0
  91. package/dist/tools/health_check.d.ts.map +1 -0
  92. package/dist/tools/health_check.js +161 -0
  93. package/dist/tools/health_check.js.map +1 -0
  94. package/dist/tools/host_security.d.ts +52 -0
  95. package/dist/tools/host_security.d.ts.map +1 -0
  96. package/dist/tools/host_security.js +127 -0
  97. package/dist/tools/host_security.js.map +1 -0
  98. package/dist/tools/index.d.ts +24 -0
  99. package/dist/tools/index.d.ts.map +1 -0
  100. package/dist/tools/index.js +24 -0
  101. package/dist/tools/index.js.map +1 -0
  102. package/dist/tools/interrupt.d.ts +47 -0
  103. package/dist/tools/interrupt.d.ts.map +1 -0
  104. package/dist/tools/interrupt.js +77 -0
  105. package/dist/tools/interrupt.js.map +1 -0
  106. package/dist/tools/list_hosts.d.ts +15 -0
  107. package/dist/tools/list_hosts.d.ts.map +1 -0
  108. package/dist/tools/list_hosts.js +18 -0
  109. package/dist/tools/list_hosts.js.map +1 -0
  110. package/dist/tools/list_sessions.d.ts +16 -0
  111. package/dist/tools/list_sessions.d.ts.map +1 -0
  112. package/dist/tools/list_sessions.js +20 -0
  113. package/dist/tools/list_sessions.js.map +1 -0
  114. package/dist/tools/read_output.d.ts +46 -0
  115. package/dist/tools/read_output.d.ts.map +1 -0
  116. package/dist/tools/read_output.js +73 -0
  117. package/dist/tools/read_output.js.map +1 -0
  118. package/dist/tools/reconnect_to_tmux.d.ts +53 -0
  119. package/dist/tools/reconnect_to_tmux.d.ts.map +1 -0
  120. package/dist/tools/reconnect_to_tmux.js +199 -0
  121. package/dist/tools/reconnect_to_tmux.js.map +1 -0
  122. package/dist/tools/send_input.d.ts +45 -0
  123. package/dist/tools/send_input.d.ts.map +1 -0
  124. package/dist/tools/send_input.js +83 -0
  125. package/dist/tools/send_input.js.map +1 -0
  126. package/dist/tools/sftp_download.d.ts +52 -0
  127. package/dist/tools/sftp_download.d.ts.map +1 -0
  128. package/dist/tools/sftp_download.js +90 -0
  129. package/dist/tools/sftp_download.js.map +1 -0
  130. package/dist/tools/sftp_list.d.ts +46 -0
  131. package/dist/tools/sftp_list.d.ts.map +1 -0
  132. package/dist/tools/sftp_list.js +93 -0
  133. package/dist/tools/sftp_list.js.map +1 -0
  134. package/dist/tools/sftp_upload.d.ts +52 -0
  135. package/dist/tools/sftp_upload.d.ts.map +1 -0
  136. package/dist/tools/sftp_upload.js +98 -0
  137. package/dist/tools/sftp_upload.js.map +1 -0
  138. package/dist/tools/ssh_tunnel.d.ts +116 -0
  139. package/dist/tools/ssh_tunnel.d.ts.map +1 -0
  140. package/dist/tools/ssh_tunnel.js +282 -0
  141. package/dist/tools/ssh_tunnel.js.map +1 -0
  142. package/dist/tools/sync.d.ts +71 -0
  143. package/dist/tools/sync.d.ts.map +1 -0
  144. package/dist/tools/sync.js +310 -0
  145. package/dist/tools/sync.js.map +1 -0
  146. package/dist/tools/tail_log.d.ts +61 -0
  147. package/dist/tools/tail_log.d.ts.map +1 -0
  148. package/dist/tools/tail_log.js +111 -0
  149. package/dist/tools/tail_log.js.map +1 -0
  150. package/dist/tools/tools_config.d.ts +34 -0
  151. package/dist/tools/tools_config.d.ts.map +1 -0
  152. package/dist/tools/tools_config.js +98 -0
  153. package/dist/tools/tools_config.js.map +1 -0
  154. package/dist/types/index.d.ts +21 -0
  155. package/dist/types/index.d.ts.map +1 -0
  156. package/dist/types/index.js +2 -0
  157. package/dist/types/index.js.map +1 -0
  158. package/dist/utils/ansi.d.ts +2 -0
  159. package/dist/utils/ansi.d.ts.map +1 -0
  160. package/dist/utils/ansi.js +7 -0
  161. package/dist/utils/ansi.js.map +1 -0
  162. package/dist/utils/logger.d.ts +3 -0
  163. package/dist/utils/logger.d.ts.map +1 -0
  164. package/dist/utils/logger.js +8 -0
  165. package/dist/utils/logger.js.map +1 -0
  166. package/dist/utils/security.d.ts +7 -0
  167. package/dist/utils/security.d.ts.map +1 -0
  168. package/dist/utils/security.js +58 -0
  169. package/dist/utils/security.js.map +1 -0
  170. package/dist/utils/ssh.d.ts +4 -0
  171. package/dist/utils/ssh.d.ts.map +1 -0
  172. package/dist/utils/ssh.js +29 -0
  173. package/dist/utils/ssh.js.map +1 -0
  174. package/dist/utils/sshConfig.d.ts +4 -0
  175. package/dist/utils/sshConfig.d.ts.map +1 -0
  176. package/dist/utils/sshConfig.js +85 -0
  177. package/dist/utils/sshConfig.js.map +1 -0
  178. package/dist/utils/validation.d.ts +4 -0
  179. package/dist/utils/validation.d.ts.map +1 -0
  180. package/dist/utils/validation.js +12 -0
  181. package/dist/utils/validation.js.map +1 -0
  182. package/docs/SECURITY.md +213 -0
  183. package/docs/TOOLS.md +425 -0
  184. package/keygen.bat +325 -0
  185. package/package.json +48 -0
  186. package/test_check.bat +9 -0
  187. package/test_delayed.bat +12 -0
  188. package/vitest.config.ts +14 -0
@@ -0,0 +1,18 @@
1
+ import { listHostAliases } from '../utils/sshConfig.js';
2
+ export const listHostsTool = {
3
+ name: 'list_hosts',
4
+ description: 'List all available SSH host aliases from ~/.ssh/config. Only these aliases can be used with the connect tool.',
5
+ inputSchema: {
6
+ type: 'object',
7
+ properties: {},
8
+ },
9
+ };
10
+ export async function handleListHosts() {
11
+ const hosts = listHostAliases();
12
+ return {
13
+ content: [
14
+ { type: 'text', text: JSON.stringify({ hosts }, null, 2) },
15
+ ],
16
+ };
17
+ }
18
+ //# sourceMappingURL=list_hosts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list_hosts.js","sourceRoot":"","sources":["../../src/tools/list_hosts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,+GAA+G;IACjH,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,OAAO;QACL,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;SACpE;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { SessionManager } from '../core/SessionManager.js';
2
+ export declare const listSessionsTool: {
3
+ name: string;
4
+ description: string;
5
+ inputSchema: {
6
+ type: "object";
7
+ properties: {};
8
+ };
9
+ };
10
+ export declare function handleListSessions(sessionManager: SessionManager): Promise<{
11
+ content: {
12
+ type: "text";
13
+ text: string;
14
+ }[];
15
+ }>;
16
+ //# sourceMappingURL=list_sessions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list_sessions.d.ts","sourceRoot":"","sources":["../../src/tools/list_sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,eAAO,MAAM,gBAAgB;;;;;;;CAQ5B,CAAC;AAEF,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,cAAc;;;;;GAUtE"}
@@ -0,0 +1,20 @@
1
+ export const listSessionsTool = {
2
+ name: 'list_sessions',
3
+ description: 'List all active MCP SSH sessions with their host, connection time, last activity, and tmux session name',
4
+ inputSchema: {
5
+ type: 'object',
6
+ properties: {},
7
+ },
8
+ };
9
+ export async function handleListSessions(sessionManager) {
10
+ const sessions = sessionManager.list();
11
+ return {
12
+ content: [
13
+ {
14
+ type: 'text',
15
+ text: JSON.stringify({ sessions }, null, 2),
16
+ },
17
+ ],
18
+ };
19
+ }
20
+ //# sourceMappingURL=list_sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list_sessions.js","sourceRoot":"","sources":["../../src/tools/list_sessions.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,yGAAyG;IAC3G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,cAA8B;IACrE,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;aAC5C;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { SessionManager } from '../core/SessionManager.js';
3
+ import { TmuxManager } from '../core/TmuxManager.js';
4
+ export declare const readOutputSchema: z.ZodObject<{
5
+ session_id: z.ZodString;
6
+ lines: z.ZodDefault<z.ZodNumber>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ session_id: string;
9
+ lines: number;
10
+ }, {
11
+ session_id: string;
12
+ lines?: number | undefined;
13
+ }>;
14
+ export declare const readOutputTool: {
15
+ name: string;
16
+ description: string;
17
+ inputSchema: {
18
+ type: "object";
19
+ properties: {
20
+ session_id: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ lines: {
25
+ type: string;
26
+ description: string;
27
+ default: number;
28
+ };
29
+ };
30
+ required: string[];
31
+ };
32
+ };
33
+ export declare function handleReadOutput(args: unknown, sessionManager: SessionManager, tmuxManager: TmuxManager): Promise<{
34
+ content: {
35
+ type: "text";
36
+ text: string;
37
+ }[];
38
+ isError: boolean;
39
+ } | {
40
+ content: {
41
+ type: "text";
42
+ text: string;
43
+ }[];
44
+ isError?: undefined;
45
+ }>;
46
+ //# sourceMappingURL=read_output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read_output.d.ts","sourceRoot":"","sources":["../../src/tools/read_output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;CAmB1B,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW;;;;;;;;;;;;GA0DzB"}
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ import { logger } from '../utils/logger.js';
3
+ import { stripAnsi } from '../utils/ansi.js';
4
+ export const readOutputSchema = z.object({
5
+ session_id: z.string().min(1),
6
+ lines: z.number().min(1).max(10000).default(200),
7
+ });
8
+ export const readOutputTool = {
9
+ name: 'read_output',
10
+ description: 'Capture the latest output from a tmux session pane. Returns recent terminal contents.',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {
14
+ session_id: {
15
+ type: 'string',
16
+ description: 'Session ID returned by connect',
17
+ },
18
+ lines: {
19
+ type: 'number',
20
+ description: 'Number of lines to capture from the end (default: 200, max: 10000)',
21
+ default: 200,
22
+ },
23
+ },
24
+ required: ['session_id'],
25
+ },
26
+ };
27
+ export async function handleReadOutput(args, sessionManager, tmuxManager) {
28
+ const parsed = readOutputSchema.safeParse(args);
29
+ if (!parsed.success) {
30
+ return {
31
+ content: [
32
+ {
33
+ type: 'text',
34
+ text: `Invalid arguments: ${parsed.error.message}`,
35
+ },
36
+ ],
37
+ isError: true,
38
+ };
39
+ }
40
+ const { session_id, lines } = parsed.data;
41
+ const session = sessionManager.get(session_id);
42
+ if (!session) {
43
+ return {
44
+ content: [
45
+ {
46
+ type: 'text',
47
+ text: `Error: Session '${session_id}' not found or has been disconnected`,
48
+ },
49
+ ],
50
+ isError: true,
51
+ };
52
+ }
53
+ try {
54
+ const output = await tmuxManager.capturePane(session.ssh, session.tmuxSession, lines);
55
+ logger.info({ sessionId: session_id, lines, outputLength: output.length }, 'Output captured');
56
+ return {
57
+ content: [{ type: 'text', text: stripAnsi(output) }],
58
+ };
59
+ }
60
+ catch (err) {
61
+ logger.error({ sessionId: session_id, error: err.message }, 'Failed to read output');
62
+ return {
63
+ content: [
64
+ {
65
+ type: 'text',
66
+ text: `Error: Failed to read output: ${err.message}`,
67
+ },
68
+ ],
69
+ isError: true,
70
+ };
71
+ }
72
+ }
73
+ //# sourceMappingURL=read_output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read_output.js","sourceRoot":"","sources":["../../src/tools/read_output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,C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K,CACN,CAAC;QACF,MAAM,CAAC,IAAI,CACT,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,EAC7D,iBAAiB,CAClB,CAAC;QACF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;SAC9D,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CACV,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAG,GAAa,CAAC,OAAO,EAAE,EACxD,uBAAuB,CACxB,CAAC;QACF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,iCAAkC,GAAa,CAAC,OAAO,EAAE;iBAChE;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ import { SessionManager } from '../core/SessionManager.js';
3
+ import { SSHManager } from '../core/SSHManager.js';
4
+ import { TmuxManager } from '../core/TmuxManager.js';
5
+ export declare const reconnectSchema: z.ZodObject<{
6
+ host: z.ZodString;
7
+ tmux_session: z.ZodString;
8
+ proxy_jump: z.ZodOptional<z.ZodString>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ host: string;
11
+ tmux_session: string;
12
+ proxy_jump?: string | undefined;
13
+ }, {
14
+ host: string;
15
+ tmux_session: string;
16
+ proxy_jump?: string | undefined;
17
+ }>;
18
+ export declare const reconnectTool: {
19
+ name: string;
20
+ description: string;
21
+ inputSchema: {
22
+ type: "object";
23
+ properties: {
24
+ host: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ tmux_session: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ proxy_jump: {
33
+ type: string;
34
+ description: string;
35
+ };
36
+ };
37
+ required: string[];
38
+ };
39
+ };
40
+ export declare function handleReconnect(args: unknown, sessionManager: SessionManager, sshManager: SSHManager, tmuxManager: TmuxManager): Promise<{
41
+ content: {
42
+ type: "text";
43
+ text: string;
44
+ }[];
45
+ isError: boolean;
46
+ } | {
47
+ content: {
48
+ type: "text";
49
+ text: string;
50
+ }[];
51
+ isError?: undefined;
52
+ }>;
53
+ //# sourceMappingURL=reconnect_to_tmux.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconnect_to_tmux.d.ts","sourceRoot":"","sources":["../../src/tools/reconnect_to_tmux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAc,MAAM,wBAAwB,CAAC;AAOjE,eAAO,MAAM,eAAe;;;;;;;;;;;;EAI1B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;CAsBzB,CAAC;AAEF,wBAAsB,eAAe,CACnC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW;;;;;;;;;;;;GAkLzB"}
@@ -0,0 +1,199 @@
1
+ import { z } from 'zod';
2
+ import { MCP_PROMPT } from '../core/TmuxManager.js';
3
+ import { listHostAliases, getHostConfig } from '../utils/sshConfig.js';
4
+ import { buildSshConfig } from '../utils/ssh.js';
5
+ import { isHostAllowed } from '../utils/security.js';
6
+ import { logger } from '../utils/logger.js';
7
+ export const reconnectSchema = z.object({
8
+ host: z.string().min(1).describe('SSH host alias from ~/.ssh/config'),
9
+ tmux_session: z.string().min(1).describe('Name of the existing tmux session on the remote host'),
10
+ proxy_jump: z.string().min(1).optional().describe('SSH host alias of the bastion/jump host'),
11
+ });
12
+ export const reconnectTool = {
13
+ name: 'reconnect_to_tmux',
14
+ description: 'Reconnect to an existing tmux session on a remote host. Useful for recovery after MCP restarts or SSH disconnections.',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ host: {
19
+ type: 'string',
20
+ description: 'SSH host alias from ~/.ssh/config',
21
+ },
22
+ tmux_session: {
23
+ type: 'string',
24
+ description: 'Name of the existing tmux session on the remote host',
25
+ },
26
+ proxy_jump: {
27
+ type: 'string',
28
+ description: 'Optional SSH host alias of a bastion/jump host',
29
+ },
30
+ },
31
+ required: ['host', 'tmux_session'],
32
+ },
33
+ };
34
+ export async function handleReconnect(args, sessionManager, sshManager, tmuxManager) {
35
+ const parsed = reconnectSchema.safeParse(args);
36
+ if (!parsed.success) {
37
+ return {
38
+ content: [
39
+ {
40
+ type: 'text',
41
+ text: `Invalid arguments: ${parsed.error.message}`,
42
+ },
43
+ ],
44
+ isError: true,
45
+ };
46
+ }
47
+ const { host, tmux_session } = parsed.data;
48
+ if (!isHostAllowed(host)) {
49
+ logger.warn({ host }, 'Host rejected by allowlist');
50
+ return {
51
+ content: [
52
+ {
53
+ type: 'text',
54
+ text: `Error: Host '${host}' is not in the allowed hosts list`,
55
+ },
56
+ ],
57
+ isError: true,
58
+ };
59
+ }
60
+ const aliases = listHostAliases();
61
+ if (!aliases.includes(host)) {
62
+ return {
63
+ content: [
64
+ {
65
+ type: 'text',
66
+ text: `Error: Host alias '${host}' not found in SSH config.\nAvailable aliases: ${aliases.join(', ') || '(none)'}`,
67
+ },
68
+ ],
69
+ isError: true,
70
+ };
71
+ }
72
+ const hostConfig = getHostConfig(host);
73
+ if (!hostConfig) {
74
+ return {
75
+ content: [
76
+ {
77
+ type: 'text',
78
+ text: `Error: Failed to resolve SSH configuration for '${host}'`,
79
+ },
80
+ ],
81
+ isError: true,
82
+ };
83
+ }
84
+ const proxyJumpAlias = parsed.data.proxy_jump || hostConfig.proxyJump;
85
+ const sshConfig = buildSshConfig(hostConfig);
86
+ if (!sshConfig) {
87
+ return {
88
+ content: [
89
+ {
90
+ type: 'text',
91
+ text: `Error: Failed to read SSH private key for '${host}'`,
92
+ },
93
+ ],
94
+ isError: true,
95
+ };
96
+ }
97
+ let ssh;
98
+ try {
99
+ if (proxyJumpAlias) {
100
+ if (!isHostAllowed(proxyJumpAlias)) {
101
+ return {
102
+ content: [{ type: 'text', text: `Error: Proxy host '${proxyJumpAlias}' is not allowed` }],
103
+ isError: true,
104
+ };
105
+ }
106
+ const proxyConfig = getHostConfig(proxyJumpAlias);
107
+ if (!proxyConfig) {
108
+ return {
109
+ content: [{ type: 'text', text: `Error: Failed to resolve SSH config for proxy '${proxyJumpAlias}'` }],
110
+ isError: true,
111
+ };
112
+ }
113
+ const proxySshConfig = buildSshConfig(proxyConfig);
114
+ if (!proxySshConfig) {
115
+ return {
116
+ content: [{ type: 'text', text: `Error: Failed to read SSH key for proxy '${proxyJumpAlias}'` }],
117
+ isError: true,
118
+ };
119
+ }
120
+ ssh = await sshManager.connectWithProxy(proxySshConfig, sshConfig);
121
+ }
122
+ else {
123
+ ssh = await sshManager.connect(sshConfig);
124
+ }
125
+ }
126
+ catch (err) {
127
+ logger.error({ host, proxyJump: proxyJumpAlias, error: err.message }, 'SSH connection failed');
128
+ return {
129
+ content: [
130
+ {
131
+ type: 'text',
132
+ text: `Error: SSH connection failed: ${err.message}`,
133
+ },
134
+ ],
135
+ isError: true,
136
+ };
137
+ }
138
+ const tmuxInstalled = await tmuxManager.isInstalled(ssh);
139
+ if (!tmuxInstalled) {
140
+ sshManager.disconnect(ssh);
141
+ return {
142
+ content: [
143
+ {
144
+ type: 'text',
145
+ text: `Error: tmux is not installed on host '${host}'.`,
146
+ },
147
+ ],
148
+ isError: true,
149
+ };
150
+ }
151
+ const exists = await tmuxManager.hasSession(ssh, tmux_session);
152
+ if (!exists) {
153
+ sshManager.disconnect(ssh);
154
+ return {
155
+ content: [
156
+ {
157
+ type: 'text',
158
+ text: `Error: tmux session '${tmux_session}' does not exist on host '${host}'.`,
159
+ },
160
+ ],
161
+ isError: true,
162
+ };
163
+ }
164
+ // Inject deterministic prompt with retry + verification
165
+ let promptInjected = false;
166
+ for (let attempt = 0; attempt < 5; attempt++) {
167
+ try {
168
+ await new Promise((r) => setTimeout(r, 300));
169
+ await tmuxManager.injectPrompt(ssh, tmux_session);
170
+ await new Promise((r) => setTimeout(r, 300));
171
+ const output = await tmuxManager.capturePane(ssh, tmux_session, 10);
172
+ if (output.includes(MCP_PROMPT)) {
173
+ promptInjected = true;
174
+ break;
175
+ }
176
+ }
177
+ catch {
178
+ logger.warn({ host, tmux_session, attempt }, 'Prompt injection retry');
179
+ }
180
+ }
181
+ if (!promptInjected) {
182
+ logger.warn({ host, tmux_session }, 'Failed to inject prompt after retries, continuing');
183
+ }
184
+ const session = sessionManager.create(host, ssh, tmux_session);
185
+ return {
186
+ content: [
187
+ {
188
+ type: 'text',
189
+ text: JSON.stringify({
190
+ session_id: session.id,
191
+ host: session.host,
192
+ tmux_session: session.tmuxSession,
193
+ status: 'reconnected',
194
+ }, null, 2),
195
+ },
196
+ ],
197
+ };
198
+ }
199
+ //# sourceMappingURL=reconnect_to_tmux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reconnect_to_tmux.js","sourceRoot":"","sources":["../../src/tools/reconnect_to_tmux.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CA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,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChC,cAAc,GAAG,IAAI,CAAC;gBACtB,MAAM;YACR,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,wBAAwB,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,mDAAmD,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAE/D,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,UAAU,EAAE,OAAO,CAAC,EAAE;oBACtB,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,YAAY,EAAE,OAAO,CAAC,WAAW;oBACjC,MAAM,EAAE,aAAa;iBACtB,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import { SessionManager } from '../core/SessionManager.js';
3
+ import { TmuxManager } from '../core/TmuxManager.js';
4
+ export declare const sendInputSchema: z.ZodObject<{
5
+ session_id: z.ZodString;
6
+ input: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ session_id: string;
9
+ input: string;
10
+ }, {
11
+ session_id: string;
12
+ input: string;
13
+ }>;
14
+ export declare const sendInputTool: {
15
+ name: string;
16
+ description: string;
17
+ inputSchema: {
18
+ type: "object";
19
+ properties: {
20
+ session_id: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ input: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ };
29
+ required: string[];
30
+ };
31
+ };
32
+ export declare function handleSendInput(args: unknown, sessionManager: SessionManager, tmuxManager: TmuxManager): Promise<{
33
+ content: {
34
+ type: "text";
35
+ text: string;
36
+ }[];
37
+ isError: boolean;
38
+ } | {
39
+ content: {
40
+ type: "text";
41
+ text: string;
42
+ }[];
43
+ isError?: undefined;
44
+ }>;
45
+ //# sourceMappingURL=send_input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send_input.d.ts","sourceRoot":"","sources":["../../src/tools/send_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,eAAO,MAAM,eAAe;;;;;;;;;EAG1B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAkBzB,CAAC;AAEF,wBAAsB,eAAe,CACnC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW;;;;;;;;;;;;GA+DzB"}
@@ -0,0 +1,83 @@
1
+ import { z } from 'zod';
2
+ import { isReadOnlyMode } from '../utils/security.js';
3
+ import { logger } from '../utils/logger.js';
4
+ export const sendInputSchema = z.object({
5
+ session_id: z.string().min(1),
6
+ input: z.string(),
7
+ });
8
+ export const sendInputTool = {
9
+ name: 'send_input',
10
+ description: 'Send raw input into a persistent tmux session. Preserves shell state (cwd, env, history). Non-blocking.',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {
14
+ session_id: {
15
+ type: 'string',
16
+ description: 'Session ID returned by connect',
17
+ },
18
+ input: {
19
+ type: 'string',
20
+ description: 'Raw input text to send to the tmux pane',
21
+ },
22
+ },
23
+ required: ['session_id', 'input'],
24
+ },
25
+ };
26
+ export async function handleSendInput(args, sessionManager, tmuxManager) {
27
+ const parsed = sendInputSchema.safeParse(args);
28
+ if (!parsed.success) {
29
+ return {
30
+ content: [
31
+ {
32
+ type: 'text',
33
+ text: `Invalid arguments: ${parsed.error.message}`,
34
+ },
35
+ ],
36
+ isError: true,
37
+ };
38
+ }
39
+ const { session_id, input } = parsed.data;
40
+ const session = sessionManager.get(session_id);
41
+ if (!session) {
42
+ return {
43
+ content: [
44
+ {
45
+ type: 'text',
46
+ text: `Error: Session '${session_id}' not found or has been disconnected`,
47
+ },
48
+ ],
49
+ isError: true,
50
+ };
51
+ }
52
+ if (isReadOnlyMode(session.host)) {
53
+ return {
54
+ content: [
55
+ {
56
+ type: 'text',
57
+ text: `Error: Host '${session.host}' is in read-only mode. Input sending is disabled.`,
58
+ },
59
+ ],
60
+ isError: true,
61
+ };
62
+ }
63
+ try {
64
+ await tmuxManager.sendInput(session.ssh, session.tmuxSession, input);
65
+ logger.info({ sessionId: session_id, inputLength: input.length }, 'Input sent');
66
+ return {
67
+ content: [{ type: 'text', text: 'Input sent successfully' }],
68
+ };
69
+ }
70
+ catch (err) {
71
+ logger.error({ sessionId: session_id, error: err.message }, 'Failed to send input');
72
+ return {
73
+ content: [
74
+ {
75
+ type: 'text',
76
+ text: `Error: Failed to send input: ${err.message}`,
77
+ },
78
+ ],
79
+ isError: true,
80
+ };
81
+ }
82
+ }
83
+ //# sourceMappingURL=send_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send_input.js","sourceRoot":"","sources":["../../src/tools/send_input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAEH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oDAAoD;iBACvF;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC;QAChF,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC;SACtE,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CACV,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAG,GAAa,CAAC,OAAO,EAAE,EACxD,sBAAsB,CACvB,CAAC;QACF,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,gCAAiC,GAAa,CAAC,OAAO,EAAE;iBAC/D;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { SessionManager } from '../core/SessionManager.js';
3
+ import { SSHManager } from '../core/SSHManager.js';
4
+ export declare const sftpDownloadSchema: z.ZodObject<{
5
+ session_id: z.ZodString;
6
+ remote_path: z.ZodString;
7
+ local_path: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ session_id: string;
10
+ local_path: string;
11
+ remote_path: string;
12
+ }, {
13
+ session_id: string;
14
+ local_path: string;
15
+ remote_path: string;
16
+ }>;
17
+ export declare const sftpDownloadTool: {
18
+ name: string;
19
+ description: string;
20
+ inputSchema: {
21
+ type: "object";
22
+ properties: {
23
+ session_id: {
24
+ type: string;
25
+ description: string;
26
+ };
27
+ remote_path: {
28
+ type: string;
29
+ description: string;
30
+ };
31
+ local_path: {
32
+ type: string;
33
+ description: string;
34
+ };
35
+ };
36
+ required: string[];
37
+ };
38
+ };
39
+ export declare function handleSftpDownload(args: unknown, sessionManager: SessionManager, sshManager: SSHManager): Promise<{
40
+ content: {
41
+ type: "text";
42
+ text: string;
43
+ }[];
44
+ isError: boolean;
45
+ } | {
46
+ content: {
47
+ type: "text";
48
+ text: string;
49
+ }[];
50
+ isError?: undefined;
51
+ }>;
52
+ //# sourceMappingURL=sftp_download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sftp_download.d.ts","sourceRoot":"","sources":["../../src/tools/sftp_download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;CAsB5B,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EACb,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU;;;;;;;;;;;;GA8DvB"}