@ebowwa/terminal 0.3.3 → 0.3.5
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/dist/api.d.ts +7 -0
- package/dist/client.d.ts +14 -0
- package/dist/config.d.ts +85 -0
- package/dist/error.d.ts +7 -0
- package/dist/exec.d.ts +46 -0
- package/dist/files.d.ts +123 -0
- package/dist/fingerprint.d.ts +66 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +3280 -6649
- package/dist/manager.d.ts +102 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.js +2257 -6757
- package/dist/mcp/stdio.d.ts +8 -0
- package/dist/network-error-detector.d.ts +18 -0
- package/dist/pool.d.ts +142 -0
- package/dist/pty.d.ts +58 -0
- package/dist/resources.d.ts +62 -0
- package/dist/scp.d.ts +29 -0
- package/dist/sessions.d.ts +100 -0
- package/dist/tmux-exec.d.ts +49 -0
- package/dist/tmux-local.d.ts +272 -0
- package/dist/tmux-manager.d.ts +327 -0
- package/dist/tmux.d.ts +212 -0
- package/dist/types.d.ts +17 -0
- package/package.json +15 -8
package/dist/tmux.d.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tmux-based Terminal Sessions
|
|
3
|
+
* Provides persistent terminal sessions using tmux on remote servers
|
|
4
|
+
* Includes automatic tmux installation and session management
|
|
5
|
+
*/
|
|
6
|
+
import type { SSHOptions } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* tmux session configuration
|
|
9
|
+
*/
|
|
10
|
+
interface TmuxConfig {
|
|
11
|
+
/** Session name prefix for codespaces sessions */
|
|
12
|
+
sessionPrefix: string;
|
|
13
|
+
/** Default shell to use in tmux */
|
|
14
|
+
defaultShell: string;
|
|
15
|
+
/** Terminal type */
|
|
16
|
+
term: string;
|
|
17
|
+
/** Timeout for SSH commands (seconds) */
|
|
18
|
+
timeout: number;
|
|
19
|
+
/** Scrollback limit (lines) */
|
|
20
|
+
historyLimit: number;
|
|
21
|
+
/** Session age limit for cleanup (milliseconds) */
|
|
22
|
+
sessionAgeLimit: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate a tmux session name for a host
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateSessionName(host: string, user?: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Check if tmux is installed on the remote server
|
|
30
|
+
*/
|
|
31
|
+
export declare function isTmuxInstalled(options: SSHOptions): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Install tmux on the remote server
|
|
34
|
+
*
|
|
35
|
+
* FALLBACK MECHANISM: This should NOT be the primary installation method.
|
|
36
|
+
* tmux should be installed via cloud-init during initial node provisioning.
|
|
37
|
+
*
|
|
38
|
+
* This function exists for:
|
|
39
|
+
* - Legacy nodes provisioned before cloud-init included tmux
|
|
40
|
+
* - Manual node provisioning outside cheapspaces
|
|
41
|
+
* - Recovery scenarios where cloud-init failed
|
|
42
|
+
*
|
|
43
|
+
* @see workspace/docs/design/node-agent/TMUX-INSTALLATION.md
|
|
44
|
+
* @see workspace/src/lib/bootstrap/cloud-init.ts - where tmux should be added to packages
|
|
45
|
+
*
|
|
46
|
+
* Supports Debian/Ubuntu (apt) and CentOS/RHEL (yum/dnf)
|
|
47
|
+
*/
|
|
48
|
+
export declare function installTmux(options: SSHOptions): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Ensure tmux is available, installing if necessary
|
|
54
|
+
*/
|
|
55
|
+
export declare function ensureTmux(options: SSHOptions): Promise<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
message: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* List existing tmux sessions on the remote server
|
|
61
|
+
*/
|
|
62
|
+
export declare function listTmuxSessions(options: SSHOptions): Promise<string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if a specific tmux session exists
|
|
65
|
+
*/
|
|
66
|
+
export declare function hasTmuxSession(sessionName: string, options: SSHOptions): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Create or attach to a tmux session
|
|
69
|
+
* Returns the SSH command arguments to connect to the tmux session
|
|
70
|
+
*/
|
|
71
|
+
export declare function createOrAttachTmuxSession(host: string, user?: string, keyPath?: string, config?: Partial<TmuxConfig>): Promise<{
|
|
72
|
+
sshArgs: string[];
|
|
73
|
+
sessionName: string;
|
|
74
|
+
newlyCreated: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Kill a tmux session on the remote server
|
|
78
|
+
*/
|
|
79
|
+
export declare function killTmuxSession(sessionName: string, options: SSHOptions): Promise<boolean>;
|
|
80
|
+
/**
|
|
81
|
+
* Get tmux session information
|
|
82
|
+
*/
|
|
83
|
+
export declare function getTmuxSessionInfo(sessionName: string, options: SSHOptions): Promise<{
|
|
84
|
+
exists: boolean;
|
|
85
|
+
windows?: number;
|
|
86
|
+
panes?: number;
|
|
87
|
+
} | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Cleanup old tmux sessions on a remote server
|
|
90
|
+
* Kills sessions with matching prefix that are older than specified age limit
|
|
91
|
+
* @param options SSH connection options
|
|
92
|
+
* @param config Optional configuration (uses default age limit if not provided)
|
|
93
|
+
* @returns Object with cleaned count and errors
|
|
94
|
+
*/
|
|
95
|
+
export declare function cleanupOldTmuxSessions(options: SSHOptions, config?: Partial<TmuxConfig>): Promise<{
|
|
96
|
+
cleaned: number;
|
|
97
|
+
errors: string[];
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Get resource usage information for tmux sessions on a remote server
|
|
101
|
+
* @param options SSH connection options
|
|
102
|
+
* @returns Resource usage summary
|
|
103
|
+
*/
|
|
104
|
+
export declare function getTmuxResourceUsage(options: SSHOptions): Promise<{
|
|
105
|
+
totalSessions: number;
|
|
106
|
+
codespacesSessions: number;
|
|
107
|
+
estimatedMemoryMB: number;
|
|
108
|
+
} | null>;
|
|
109
|
+
/**
|
|
110
|
+
* Send a command to a specific pane in a tmux session
|
|
111
|
+
* @param sessionName Target tmux session name
|
|
112
|
+
* @param paneIndex Pane index (default: 0 for first pane)
|
|
113
|
+
* @param command Command to execute (sent as keystrokes)
|
|
114
|
+
* @param options SSH connection options
|
|
115
|
+
*/
|
|
116
|
+
export declare function sendCommandToPane(sessionName: string, command: string, paneIndex: string, options: SSHOptions): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Split a pane horizontally or vertically in a tmux session
|
|
119
|
+
* @param sessionName Target tmux session name
|
|
120
|
+
* @param windowIndex Window index (default: 0)
|
|
121
|
+
* @param direction Split direction: "h" (horizontal) or "v" (vertical)
|
|
122
|
+
* @param command Optional command to run in the new pane
|
|
123
|
+
* @param options SSH connection options
|
|
124
|
+
* @returns The new pane index
|
|
125
|
+
*/
|
|
126
|
+
export declare function splitPane(sessionName: string, direction: "h" | "v", command: string | null, options: SSHOptions): Promise<string | null>;
|
|
127
|
+
/**
|
|
128
|
+
* List all windows in a tmux session
|
|
129
|
+
* @param sessionName Target tmux session name
|
|
130
|
+
* @param options SSH connection options
|
|
131
|
+
*/
|
|
132
|
+
export declare function listSessionWindows(sessionName: string, options: SSHOptions): Promise<Array<{
|
|
133
|
+
index: string;
|
|
134
|
+
name: string;
|
|
135
|
+
active: boolean;
|
|
136
|
+
}>>;
|
|
137
|
+
/**
|
|
138
|
+
* List all panes in a tmux session window
|
|
139
|
+
* @param sessionName Target tmux session name
|
|
140
|
+
* @param windowIndex Window index (default: 0)
|
|
141
|
+
* @param options SSH connection options
|
|
142
|
+
*/
|
|
143
|
+
export declare function listWindowPanes(sessionName: string, windowIndex: string, options: SSHOptions): Promise<Array<{
|
|
144
|
+
index: string;
|
|
145
|
+
currentPath: string;
|
|
146
|
+
pid: string;
|
|
147
|
+
active: boolean;
|
|
148
|
+
}>>;
|
|
149
|
+
/**
|
|
150
|
+
* Capture the current output of a pane
|
|
151
|
+
* @param sessionName Target tmux session name
|
|
152
|
+
* @param paneIndex Pane index (default: 0)
|
|
153
|
+
* @param options SSH connection options
|
|
154
|
+
*/
|
|
155
|
+
export declare function capturePane(sessionName: string, paneIndex: string, options: SSHOptions): Promise<string | null>;
|
|
156
|
+
/**
|
|
157
|
+
* Get scrollback/history from a pane
|
|
158
|
+
* @param sessionName Target tmux session name
|
|
159
|
+
* @param paneIndex Pane index (default: 0)
|
|
160
|
+
* @param lines Number of lines to retrieve (default: all)
|
|
161
|
+
* @param options SSH connection options
|
|
162
|
+
*/
|
|
163
|
+
export declare function getPaneHistory(sessionName: string, paneIndex: string, lines: number, options: SSHOptions): Promise<string | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Switch to a specific window in a tmux session
|
|
166
|
+
* @param sessionName Target tmux session name
|
|
167
|
+
* @param windowIndex Target window index
|
|
168
|
+
* @param options SSH connection options
|
|
169
|
+
*/
|
|
170
|
+
export declare function switchWindow(sessionName: string, windowIndex: string, options: SSHOptions): Promise<boolean>;
|
|
171
|
+
/**
|
|
172
|
+
* Switch to a specific pane in a tmux session window
|
|
173
|
+
* @param sessionName Target tmux session name
|
|
174
|
+
* @param paneIndex Target pane index (e.g., "0", "1", "0.1" for window.pane)
|
|
175
|
+
* @param options SSH connection options
|
|
176
|
+
*/
|
|
177
|
+
export declare function switchPane(sessionName: string, paneIndex: string, options: SSHOptions): Promise<boolean>;
|
|
178
|
+
/**
|
|
179
|
+
* Rename a window in a tmux session
|
|
180
|
+
* @param sessionName Target tmux session name
|
|
181
|
+
* @param windowIndex Window index (default: 0)
|
|
182
|
+
* @param newName New window name
|
|
183
|
+
* @param options SSH connection options
|
|
184
|
+
*/
|
|
185
|
+
export declare function renameWindow(sessionName: string, windowIndex: string, newName: string, options: SSHOptions): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Kill a specific pane in a tmux session
|
|
188
|
+
* @param sessionName Target tmux session name
|
|
189
|
+
* @param paneIndex Pane index to kill
|
|
190
|
+
* @param options SSH connection options
|
|
191
|
+
*/
|
|
192
|
+
export declare function killPane(sessionName: string, paneIndex: string, options: SSHOptions): Promise<boolean>;
|
|
193
|
+
/**
|
|
194
|
+
* Get detailed information about all panes in a session
|
|
195
|
+
* @param sessionName Target tmux session name
|
|
196
|
+
* @param options SSH connection options
|
|
197
|
+
*/
|
|
198
|
+
export declare function getDetailedSessionInfo(sessionName: string, options: SSHOptions): Promise<{
|
|
199
|
+
exists: boolean;
|
|
200
|
+
windows: Array<{
|
|
201
|
+
index: string;
|
|
202
|
+
name: string;
|
|
203
|
+
active: boolean;
|
|
204
|
+
panes: Array<{
|
|
205
|
+
index: string;
|
|
206
|
+
currentPath: string;
|
|
207
|
+
pid: string;
|
|
208
|
+
active: boolean;
|
|
209
|
+
}>;
|
|
210
|
+
}>;
|
|
211
|
+
} | null>;
|
|
212
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSH type definitions
|
|
3
|
+
*/
|
|
4
|
+
export interface SSHOptions {
|
|
5
|
+
host: string;
|
|
6
|
+
user?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
port?: number;
|
|
9
|
+
keyPath?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SCPOptions extends SSHOptions {
|
|
13
|
+
source: string;
|
|
14
|
+
destination: string;
|
|
15
|
+
recursive?: boolean;
|
|
16
|
+
preserve?: boolean;
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ebowwa/terminal",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Terminal session management with tmux integration, SSH client, WebSocket support, and MCP interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./mcp": {
|
|
14
|
+
"types": "./dist/mcp/index.d.ts",
|
|
15
|
+
"default": "./dist/mcp/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"types": "./dist/types.d.ts",
|
|
19
|
+
"default": "./dist/types.d.ts"
|
|
20
|
+
}
|
|
16
21
|
},
|
|
22
|
+
"scripts": {},
|
|
17
23
|
"files": [
|
|
18
24
|
"dist"
|
|
19
25
|
],
|
|
@@ -44,6 +50,7 @@
|
|
|
44
50
|
},
|
|
45
51
|
"dependencies": {
|
|
46
52
|
"@ebowwa/codespaces-types": "^1.4.0",
|
|
53
|
+
"@ebowwa/ssh": "^0.2.1",
|
|
47
54
|
"node-ssh": "^13.2.1",
|
|
48
55
|
"hono": "^4.11.3",
|
|
49
56
|
"zod": "^3.24.1"
|