@seflless/ghosttown 1.7.0 → 1.10.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/package.json +3 -2
- package/src/cli.js +216 -57
- package/src/session/history-replay.d.ts +118 -0
- package/src/session/history-replay.js +174 -0
- package/src/session/history-replay.js.map +1 -0
- package/src/session/index.d.ts +10 -0
- package/src/session/index.js +11 -0
- package/src/session/index.js.map +1 -0
- package/src/session/output-recorder.d.ts +131 -0
- package/src/session/output-recorder.js +247 -0
- package/src/session/output-recorder.js.map +1 -0
- package/src/session/session-manager.d.ts +147 -0
- package/src/session/session-manager.js +489 -0
- package/src/session/session-manager.js.map +1 -0
- package/src/session/types.d.ts +221 -0
- package/src/session/types.js +8 -0
- package/src/session/types.js.map +1 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Management Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the custom PTY session management system that replaces tmux.
|
|
5
|
+
* Sessions persist across reconnections and server restarts.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier for a session (UUID v4).
|
|
9
|
+
* This ID is stable and survives renames, reconnections, and server restarts.
|
|
10
|
+
*/
|
|
11
|
+
export type SessionId = string;
|
|
12
|
+
/**
|
|
13
|
+
* Share permission level for a session connection.
|
|
14
|
+
*/
|
|
15
|
+
export type SharePermission = 'read-only' | 'read-write';
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for sharing a session with others.
|
|
18
|
+
*/
|
|
19
|
+
export interface SharingConfig {
|
|
20
|
+
/** Whether sharing is currently enabled */
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** Secure token for share access (32-byte random, base64url) */
|
|
23
|
+
token: string;
|
|
24
|
+
/** Permission level for shared access */
|
|
25
|
+
permissions: SharePermission;
|
|
26
|
+
/** Unix timestamp when share expires, null for never */
|
|
27
|
+
expiresAt: number | null;
|
|
28
|
+
/** Maximum number of concurrent viewers, null for unlimited */
|
|
29
|
+
maxViewers: number | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Process state for a session.
|
|
33
|
+
* The pid is null after server restart (process was killed).
|
|
34
|
+
*/
|
|
35
|
+
export interface ProcessState {
|
|
36
|
+
/** Process ID, null if process is not running */
|
|
37
|
+
pid: number | null;
|
|
38
|
+
/** Shell executable path (e.g., '/bin/zsh') */
|
|
39
|
+
shell: string;
|
|
40
|
+
/** Shell arguments */
|
|
41
|
+
args: string[];
|
|
42
|
+
/** Current working directory */
|
|
43
|
+
cwd: string;
|
|
44
|
+
/** Environment variables */
|
|
45
|
+
env: Record<string, string>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Terminal state for a session.
|
|
49
|
+
*/
|
|
50
|
+
export interface TerminalState {
|
|
51
|
+
/** Number of columns */
|
|
52
|
+
cols: number;
|
|
53
|
+
/** Number of rows */
|
|
54
|
+
rows: number;
|
|
55
|
+
/** Cursor X position */
|
|
56
|
+
cursorX: number;
|
|
57
|
+
/** Cursor Y position */
|
|
58
|
+
cursorY: number;
|
|
59
|
+
/** Cursor style */
|
|
60
|
+
cursorStyle: 'block' | 'underline' | 'bar';
|
|
61
|
+
/** Whether cursor is visible */
|
|
62
|
+
cursorVisible: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Core session state that survives server restarts.
|
|
66
|
+
* Persisted to disk as JSON.
|
|
67
|
+
*/
|
|
68
|
+
export interface Session {
|
|
69
|
+
/** Unique identifier (UUID v4) */
|
|
70
|
+
id: SessionId;
|
|
71
|
+
/** User-facing display name */
|
|
72
|
+
displayName: string;
|
|
73
|
+
/** Unix timestamp when session was created */
|
|
74
|
+
createdAt: number;
|
|
75
|
+
/** Unix timestamp of last activity */
|
|
76
|
+
lastActivity: number;
|
|
77
|
+
/** Process state */
|
|
78
|
+
process: ProcessState;
|
|
79
|
+
/** Terminal state */
|
|
80
|
+
terminal: TerminalState;
|
|
81
|
+
/** Path to scrollback file (relative to session directory) */
|
|
82
|
+
scrollbackFile: string;
|
|
83
|
+
/** Total number of lines in scrollback history */
|
|
84
|
+
scrollbackLength: number;
|
|
85
|
+
/** Sharing configuration, null if not shared */
|
|
86
|
+
sharing: SharingConfig | null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Connection to a session (in-memory, not persisted).
|
|
90
|
+
*/
|
|
91
|
+
export interface Connection {
|
|
92
|
+
/** Unique connection ID */
|
|
93
|
+
id: string;
|
|
94
|
+
/** Session being connected to */
|
|
95
|
+
sessionId: SessionId;
|
|
96
|
+
/** User identifier */
|
|
97
|
+
userId: string;
|
|
98
|
+
/** Connection type */
|
|
99
|
+
type: 'owner' | 'viewer';
|
|
100
|
+
/** Permission level */
|
|
101
|
+
permissions: SharePermission;
|
|
102
|
+
/** Unix timestamp when connected */
|
|
103
|
+
connectedAt: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Options for creating a new session.
|
|
107
|
+
*/
|
|
108
|
+
export interface CreateSessionOptions {
|
|
109
|
+
/** Display name (auto-generated if not provided) */
|
|
110
|
+
name?: string;
|
|
111
|
+
/** Shell executable (defaults to user's shell) */
|
|
112
|
+
shell?: string;
|
|
113
|
+
/** Shell arguments */
|
|
114
|
+
args?: string[];
|
|
115
|
+
/** Working directory (defaults to home directory) */
|
|
116
|
+
cwd?: string;
|
|
117
|
+
/** Environment variables to add/override */
|
|
118
|
+
env?: Record<string, string>;
|
|
119
|
+
/** Terminal columns (default: 80) */
|
|
120
|
+
cols?: number;
|
|
121
|
+
/** Terminal rows (default: 24) */
|
|
122
|
+
rows?: number;
|
|
123
|
+
/**
|
|
124
|
+
* Whether to start the PTY process immediately (default: true).
|
|
125
|
+
* Set to false for web sessions where output should wait for client connection.
|
|
126
|
+
*/
|
|
127
|
+
startProcess?: boolean;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Options for connecting to a session.
|
|
131
|
+
*/
|
|
132
|
+
export interface ConnectOptions {
|
|
133
|
+
/** Session ID to connect to */
|
|
134
|
+
sessionId: SessionId;
|
|
135
|
+
/** Share token (required for viewer access) */
|
|
136
|
+
shareToken?: string;
|
|
137
|
+
/** User identifier */
|
|
138
|
+
userId: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Session info returned from list operations.
|
|
142
|
+
*/
|
|
143
|
+
export interface SessionInfo {
|
|
144
|
+
/** Session ID */
|
|
145
|
+
id: SessionId;
|
|
146
|
+
/** Display name */
|
|
147
|
+
displayName: string;
|
|
148
|
+
/** Unix timestamp of last activity */
|
|
149
|
+
lastActivity: number;
|
|
150
|
+
/** Whether a process is currently running */
|
|
151
|
+
isRunning: boolean;
|
|
152
|
+
/** Number of active connections */
|
|
153
|
+
connectionCount: number;
|
|
154
|
+
/** Whether session is being shared */
|
|
155
|
+
isShared: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Result of creating a share link.
|
|
159
|
+
*/
|
|
160
|
+
export interface ShareLink {
|
|
161
|
+
/** Local URL for LAN access */
|
|
162
|
+
localUrl: string;
|
|
163
|
+
/** Public URL for internet access (if tunneling enabled) */
|
|
164
|
+
publicUrl?: string;
|
|
165
|
+
/** Share token */
|
|
166
|
+
token: string;
|
|
167
|
+
/** Unix timestamp when share expires */
|
|
168
|
+
expiresAt: number | null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Options for creating a share link.
|
|
172
|
+
*/
|
|
173
|
+
export interface CreateShareOptions {
|
|
174
|
+
/** Permission level (default: 'read-only') */
|
|
175
|
+
permissions?: SharePermission;
|
|
176
|
+
/** Expiration time in milliseconds from now */
|
|
177
|
+
expiresIn?: number;
|
|
178
|
+
/** Maximum concurrent viewers */
|
|
179
|
+
maxViewers?: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Events emitted by SessionManager.
|
|
183
|
+
*/
|
|
184
|
+
export interface SessionManagerEvents {
|
|
185
|
+
/** Emitted when a new session is created */
|
|
186
|
+
'session:created': (session: Session) => void;
|
|
187
|
+
/** Emitted when a session is deleted */
|
|
188
|
+
'session:deleted': (sessionId: SessionId) => void;
|
|
189
|
+
/** Emitted when a session's process exits */
|
|
190
|
+
'session:exit': (sessionId: SessionId, exitCode: number) => void;
|
|
191
|
+
/** Emitted when a connection is established */
|
|
192
|
+
'connection:open': (connection: Connection) => void;
|
|
193
|
+
/** Emitted when a connection is closed */
|
|
194
|
+
'connection:close': (connectionId: string) => void;
|
|
195
|
+
/** Emitted when session output is received */
|
|
196
|
+
'session:output': (sessionId: SessionId, data: string) => void;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Storage paths for session data.
|
|
200
|
+
*/
|
|
201
|
+
export interface SessionPaths {
|
|
202
|
+
/** Base directory for all session data */
|
|
203
|
+
baseDir: string;
|
|
204
|
+
/** Directory for a specific session */
|
|
205
|
+
sessionDir: (sessionId: SessionId) => string;
|
|
206
|
+
/** Path to session metadata file */
|
|
207
|
+
metadataFile: (sessionId: SessionId) => string;
|
|
208
|
+
/** Path to scrollback file */
|
|
209
|
+
scrollbackFile: (sessionId: SessionId) => string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Configuration for SessionManager.
|
|
213
|
+
*/
|
|
214
|
+
export interface SessionManagerConfig {
|
|
215
|
+
/** Base directory for session storage (default: ~/.config/ghosttown/sessions) */
|
|
216
|
+
storageDir?: string;
|
|
217
|
+
/** Maximum scrollback lines per session (default: 10000) */
|
|
218
|
+
scrollbackLimit?: number;
|
|
219
|
+
/** Default shell (default: $SHELL or /bin/sh) */
|
|
220
|
+
defaultShell?: string;
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|