nikcli-remote 1.0.9 → 1.0.10
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/chunk-GI5RMYH6.js +37 -0
- package/dist/chunk-TIYMAVGV.js +1126 -0
- package/dist/index.cjs +4688 -6106
- package/dist/index.d.cts +89 -63
- package/dist/index.d.ts +89 -63
- package/dist/index.js +228 -7
- package/dist/{localtunnel-XT32JGNN.js → localtunnel-6DCQIYU6.js} +1 -1
- package/dist/server-O3KTQ4KJ.js +7 -0
- package/package.json +1 -1
- package/src/index.ts +57 -12
- package/src/server.ts +83 -110
- package/src/tunnel.ts +24 -0
- package/dist/chunk-3IFHAOGG.js +0 -2747
- package/dist/chunk-MCKGQKYU.js +0 -15
- package/dist/server-MBJQBTJF.js +0 -7
package/dist/index.d.cts
CHANGED
|
@@ -71,22 +71,6 @@ interface ClientMessage {
|
|
|
71
71
|
type: string;
|
|
72
72
|
[key: string]: unknown;
|
|
73
73
|
}
|
|
74
|
-
interface ServerMessage {
|
|
75
|
-
type: string;
|
|
76
|
-
payload?: unknown;
|
|
77
|
-
timestamp: number;
|
|
78
|
-
}
|
|
79
|
-
interface TerminalData {
|
|
80
|
-
data: string;
|
|
81
|
-
}
|
|
82
|
-
interface TerminalResize {
|
|
83
|
-
cols: number;
|
|
84
|
-
rows: number;
|
|
85
|
-
}
|
|
86
|
-
interface CommandMessage {
|
|
87
|
-
command: string;
|
|
88
|
-
args?: string[];
|
|
89
|
-
}
|
|
90
74
|
interface ClientConnection {
|
|
91
75
|
id: string;
|
|
92
76
|
authenticated: boolean;
|
|
@@ -118,8 +102,8 @@ declare const MessageTypes: {
|
|
|
118
102
|
};
|
|
119
103
|
|
|
120
104
|
/**
|
|
121
|
-
* @nikcli/remote -
|
|
122
|
-
* WebSocket
|
|
105
|
+
* @nikcli/remote - Direct Terminal Streaming Server
|
|
106
|
+
* Proxies NikCLI's stdin/stdout to WebSocket clients for true real-time terminal access
|
|
123
107
|
*/
|
|
124
108
|
|
|
125
109
|
interface RemoteServerEvents {
|
|
@@ -130,13 +114,9 @@ interface RemoteServerEvents {
|
|
|
130
114
|
'client:error': (clientId: string, error: Error) => void;
|
|
131
115
|
'tunnel:connected': (url: string) => void;
|
|
132
116
|
'tunnel:error': (error: Error) => void;
|
|
133
|
-
command: (cmd: {
|
|
134
|
-
clientId: string;
|
|
135
|
-
command: string;
|
|
136
|
-
args?: string[];
|
|
137
|
-
}) => void;
|
|
138
117
|
message: (client: ClientConnection, message: ClientMessage) => void;
|
|
139
118
|
error: (error: Error) => void;
|
|
119
|
+
'terminal:output': (data: string) => void;
|
|
140
120
|
}
|
|
141
121
|
declare class RemoteServer extends EventEmitter {
|
|
142
122
|
private config;
|
|
@@ -144,19 +124,31 @@ declare class RemoteServer extends EventEmitter {
|
|
|
144
124
|
private wss;
|
|
145
125
|
private clients;
|
|
146
126
|
private session;
|
|
147
|
-
private terminal;
|
|
148
|
-
private tunnel;
|
|
149
127
|
private heartbeatTimer;
|
|
150
128
|
private sessionTimeoutTimer;
|
|
151
129
|
private isRunning;
|
|
152
130
|
private sessionSecret;
|
|
131
|
+
private originalStdoutWrite;
|
|
132
|
+
private originalStdinOn;
|
|
153
133
|
constructor(config?: Partial<ServerConfig>);
|
|
154
134
|
/**
|
|
155
|
-
*
|
|
135
|
+
* Generate a random secret
|
|
136
|
+
*/
|
|
137
|
+
private generateSecret;
|
|
138
|
+
/**
|
|
139
|
+
* Start the remote server - creates WebSocket server that proxies stdin/stdout
|
|
156
140
|
*/
|
|
157
141
|
start(options?: {
|
|
158
142
|
name?: string;
|
|
143
|
+
processForStreaming?: {
|
|
144
|
+
stdout: NodeJS.WriteStream;
|
|
145
|
+
stdin: NodeJS.ReadStream;
|
|
146
|
+
};
|
|
159
147
|
}): Promise<RemoteSession>;
|
|
148
|
+
/**
|
|
149
|
+
* Setup stdin/stdout proxy to forward to WebSocket clients
|
|
150
|
+
*/
|
|
151
|
+
private setupStdioProxy;
|
|
160
152
|
/**
|
|
161
153
|
* Stop the server
|
|
162
154
|
*/
|
|
@@ -164,7 +156,7 @@ declare class RemoteServer extends EventEmitter {
|
|
|
164
156
|
/**
|
|
165
157
|
* Broadcast message to all authenticated clients
|
|
166
158
|
*/
|
|
167
|
-
|
|
159
|
+
private broadcastToAll;
|
|
168
160
|
/**
|
|
169
161
|
* Send notification to clients
|
|
170
162
|
*/
|
|
@@ -182,13 +174,13 @@ declare class RemoteServer extends EventEmitter {
|
|
|
182
174
|
*/
|
|
183
175
|
getConnectedCount(): number;
|
|
184
176
|
/**
|
|
185
|
-
* Write to
|
|
177
|
+
* Write data to all connected clients (for manual output streaming)
|
|
186
178
|
*/
|
|
187
|
-
|
|
179
|
+
writeToClients(data: string): void;
|
|
188
180
|
/**
|
|
189
|
-
*
|
|
181
|
+
* Alias for writeToClients - for compatibility
|
|
190
182
|
*/
|
|
191
|
-
|
|
183
|
+
writeToTerminal(data: string): void;
|
|
192
184
|
/**
|
|
193
185
|
* Setup WebSocket handlers
|
|
194
186
|
*/
|
|
@@ -229,59 +221,65 @@ declare class RemoteServer extends EventEmitter {
|
|
|
229
221
|
* Generate client ID
|
|
230
222
|
*/
|
|
231
223
|
private generateClientId;
|
|
232
|
-
/**
|
|
233
|
-
* Generate secret
|
|
234
|
-
*/
|
|
235
|
-
private generateSecret;
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/**
|
|
239
|
-
* @nikcli/remote -
|
|
240
|
-
*
|
|
227
|
+
* @nikcli/remote - Tunnel Manager
|
|
228
|
+
* Provides public URL access via various tunnel providers
|
|
241
229
|
*/
|
|
242
230
|
|
|
243
|
-
interface
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
cwd?: string;
|
|
248
|
-
env?: Record<string, string>;
|
|
231
|
+
interface TunnelResult {
|
|
232
|
+
url: string;
|
|
233
|
+
provider: TunnelProvider;
|
|
234
|
+
close: () => Promise<void>;
|
|
249
235
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Create a tunnel for the given port using the specified provider
|
|
238
|
+
*/
|
|
239
|
+
declare function createTunnel(port: number, provider?: TunnelProvider): Promise<TunnelResult>;
|
|
240
|
+
declare class TunnelManager {
|
|
241
|
+
private provider;
|
|
253
242
|
private process;
|
|
254
|
-
private
|
|
255
|
-
|
|
243
|
+
private url;
|
|
244
|
+
private tunnelInstance;
|
|
245
|
+
constructor(provider: TunnelProvider);
|
|
256
246
|
/**
|
|
257
|
-
*
|
|
247
|
+
* Create tunnel and return public URL
|
|
258
248
|
*/
|
|
259
|
-
|
|
249
|
+
create(port: number): Promise<string>;
|
|
260
250
|
/**
|
|
261
|
-
*
|
|
251
|
+
* Close tunnel
|
|
262
252
|
*/
|
|
263
|
-
|
|
253
|
+
close(): Promise<void>;
|
|
264
254
|
/**
|
|
265
|
-
*
|
|
255
|
+
* Get tunnel URL
|
|
266
256
|
*/
|
|
267
|
-
|
|
257
|
+
getUrl(): string | null;
|
|
268
258
|
/**
|
|
269
|
-
*
|
|
259
|
+
* Create localtunnel
|
|
270
260
|
*/
|
|
271
|
-
|
|
261
|
+
private createLocaltunnel;
|
|
272
262
|
/**
|
|
273
|
-
*
|
|
263
|
+
* Create localtunnel via CLI
|
|
274
264
|
*/
|
|
275
|
-
|
|
265
|
+
private createLocaltunnelCli;
|
|
276
266
|
/**
|
|
277
|
-
*
|
|
267
|
+
* Create cloudflared tunnel
|
|
278
268
|
*/
|
|
279
|
-
|
|
269
|
+
private createCloudflared;
|
|
280
270
|
/**
|
|
281
|
-
*
|
|
271
|
+
* Create ngrok tunnel
|
|
282
272
|
*/
|
|
283
|
-
|
|
273
|
+
private createNgrok;
|
|
284
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Check if a tunnel provider is available
|
|
277
|
+
*/
|
|
278
|
+
declare function checkTunnelAvailability(provider: TunnelProvider): Promise<boolean>;
|
|
279
|
+
/**
|
|
280
|
+
* Find best available tunnel provider
|
|
281
|
+
*/
|
|
282
|
+
declare function findAvailableTunnel(): Promise<TunnelProvider | null>;
|
|
285
283
|
|
|
286
284
|
/**
|
|
287
285
|
* @nikcli/remote - Mobile Web Client
|
|
@@ -289,9 +287,37 @@ declare class TerminalManager extends EventEmitter {
|
|
|
289
287
|
*/
|
|
290
288
|
declare function getWebClient(): string;
|
|
291
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @nikcli/remote - Enterprise Terminal Streaming
|
|
292
|
+
*
|
|
293
|
+
* Direct stdin/stdout streaming for true real-time terminal access.
|
|
294
|
+
* No fake PTY - mobile sees your actual NikCLI terminal.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* import { RemoteServer, createTunnel } from '@nikcli/remote'
|
|
299
|
+
*
|
|
300
|
+
* const server = new RemoteServer()
|
|
301
|
+
* const session = await server.start({
|
|
302
|
+
* name: 'my-terminal',
|
|
303
|
+
* processForStreaming: {
|
|
304
|
+
* stdout: process.stdout,
|
|
305
|
+
* stdin: process.stdin,
|
|
306
|
+
* },
|
|
307
|
+
* })
|
|
308
|
+
*
|
|
309
|
+
* // Create public tunnel
|
|
310
|
+
* const tunnelUrl = await createTunnel(session.port, 'cloudflared')
|
|
311
|
+
* console.log('Access your terminal:', tunnelUrl)
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Create a remote server with streaming in one call
|
|
317
|
+
*/
|
|
292
318
|
declare function createRemoteServer(config?: Partial<ServerConfig>): Promise<{
|
|
293
319
|
server: RemoteServer;
|
|
294
320
|
session: RemoteSession;
|
|
295
321
|
}>;
|
|
296
322
|
|
|
297
|
-
export { type BroadcastMessage, type ClientMessage,
|
|
323
|
+
export { type BroadcastMessage, type ClientMessage, DEFAULT_CONFIG, type DeviceInfo, MessageTypes, type RemoteNotification, RemoteServer, type RemoteServerEvents, type RemoteSession, type ServerConfig, type SessionStatus, TunnelManager, type TunnelProvider, type TunnelResult, checkTunnelAvailability, createRemoteServer, createTunnel, findAvailableTunnel, getWebClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -71,22 +71,6 @@ interface ClientMessage {
|
|
|
71
71
|
type: string;
|
|
72
72
|
[key: string]: unknown;
|
|
73
73
|
}
|
|
74
|
-
interface ServerMessage {
|
|
75
|
-
type: string;
|
|
76
|
-
payload?: unknown;
|
|
77
|
-
timestamp: number;
|
|
78
|
-
}
|
|
79
|
-
interface TerminalData {
|
|
80
|
-
data: string;
|
|
81
|
-
}
|
|
82
|
-
interface TerminalResize {
|
|
83
|
-
cols: number;
|
|
84
|
-
rows: number;
|
|
85
|
-
}
|
|
86
|
-
interface CommandMessage {
|
|
87
|
-
command: string;
|
|
88
|
-
args?: string[];
|
|
89
|
-
}
|
|
90
74
|
interface ClientConnection {
|
|
91
75
|
id: string;
|
|
92
76
|
authenticated: boolean;
|
|
@@ -118,8 +102,8 @@ declare const MessageTypes: {
|
|
|
118
102
|
};
|
|
119
103
|
|
|
120
104
|
/**
|
|
121
|
-
* @nikcli/remote -
|
|
122
|
-
* WebSocket
|
|
105
|
+
* @nikcli/remote - Direct Terminal Streaming Server
|
|
106
|
+
* Proxies NikCLI's stdin/stdout to WebSocket clients for true real-time terminal access
|
|
123
107
|
*/
|
|
124
108
|
|
|
125
109
|
interface RemoteServerEvents {
|
|
@@ -130,13 +114,9 @@ interface RemoteServerEvents {
|
|
|
130
114
|
'client:error': (clientId: string, error: Error) => void;
|
|
131
115
|
'tunnel:connected': (url: string) => void;
|
|
132
116
|
'tunnel:error': (error: Error) => void;
|
|
133
|
-
command: (cmd: {
|
|
134
|
-
clientId: string;
|
|
135
|
-
command: string;
|
|
136
|
-
args?: string[];
|
|
137
|
-
}) => void;
|
|
138
117
|
message: (client: ClientConnection, message: ClientMessage) => void;
|
|
139
118
|
error: (error: Error) => void;
|
|
119
|
+
'terminal:output': (data: string) => void;
|
|
140
120
|
}
|
|
141
121
|
declare class RemoteServer extends EventEmitter {
|
|
142
122
|
private config;
|
|
@@ -144,19 +124,31 @@ declare class RemoteServer extends EventEmitter {
|
|
|
144
124
|
private wss;
|
|
145
125
|
private clients;
|
|
146
126
|
private session;
|
|
147
|
-
private terminal;
|
|
148
|
-
private tunnel;
|
|
149
127
|
private heartbeatTimer;
|
|
150
128
|
private sessionTimeoutTimer;
|
|
151
129
|
private isRunning;
|
|
152
130
|
private sessionSecret;
|
|
131
|
+
private originalStdoutWrite;
|
|
132
|
+
private originalStdinOn;
|
|
153
133
|
constructor(config?: Partial<ServerConfig>);
|
|
154
134
|
/**
|
|
155
|
-
*
|
|
135
|
+
* Generate a random secret
|
|
136
|
+
*/
|
|
137
|
+
private generateSecret;
|
|
138
|
+
/**
|
|
139
|
+
* Start the remote server - creates WebSocket server that proxies stdin/stdout
|
|
156
140
|
*/
|
|
157
141
|
start(options?: {
|
|
158
142
|
name?: string;
|
|
143
|
+
processForStreaming?: {
|
|
144
|
+
stdout: NodeJS.WriteStream;
|
|
145
|
+
stdin: NodeJS.ReadStream;
|
|
146
|
+
};
|
|
159
147
|
}): Promise<RemoteSession>;
|
|
148
|
+
/**
|
|
149
|
+
* Setup stdin/stdout proxy to forward to WebSocket clients
|
|
150
|
+
*/
|
|
151
|
+
private setupStdioProxy;
|
|
160
152
|
/**
|
|
161
153
|
* Stop the server
|
|
162
154
|
*/
|
|
@@ -164,7 +156,7 @@ declare class RemoteServer extends EventEmitter {
|
|
|
164
156
|
/**
|
|
165
157
|
* Broadcast message to all authenticated clients
|
|
166
158
|
*/
|
|
167
|
-
|
|
159
|
+
private broadcastToAll;
|
|
168
160
|
/**
|
|
169
161
|
* Send notification to clients
|
|
170
162
|
*/
|
|
@@ -182,13 +174,13 @@ declare class RemoteServer extends EventEmitter {
|
|
|
182
174
|
*/
|
|
183
175
|
getConnectedCount(): number;
|
|
184
176
|
/**
|
|
185
|
-
* Write to
|
|
177
|
+
* Write data to all connected clients (for manual output streaming)
|
|
186
178
|
*/
|
|
187
|
-
|
|
179
|
+
writeToClients(data: string): void;
|
|
188
180
|
/**
|
|
189
|
-
*
|
|
181
|
+
* Alias for writeToClients - for compatibility
|
|
190
182
|
*/
|
|
191
|
-
|
|
183
|
+
writeToTerminal(data: string): void;
|
|
192
184
|
/**
|
|
193
185
|
* Setup WebSocket handlers
|
|
194
186
|
*/
|
|
@@ -229,59 +221,65 @@ declare class RemoteServer extends EventEmitter {
|
|
|
229
221
|
* Generate client ID
|
|
230
222
|
*/
|
|
231
223
|
private generateClientId;
|
|
232
|
-
/**
|
|
233
|
-
* Generate secret
|
|
234
|
-
*/
|
|
235
|
-
private generateSecret;
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/**
|
|
239
|
-
* @nikcli/remote -
|
|
240
|
-
*
|
|
227
|
+
* @nikcli/remote - Tunnel Manager
|
|
228
|
+
* Provides public URL access via various tunnel providers
|
|
241
229
|
*/
|
|
242
230
|
|
|
243
|
-
interface
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
cwd?: string;
|
|
248
|
-
env?: Record<string, string>;
|
|
231
|
+
interface TunnelResult {
|
|
232
|
+
url: string;
|
|
233
|
+
provider: TunnelProvider;
|
|
234
|
+
close: () => Promise<void>;
|
|
249
235
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Create a tunnel for the given port using the specified provider
|
|
238
|
+
*/
|
|
239
|
+
declare function createTunnel(port: number, provider?: TunnelProvider): Promise<TunnelResult>;
|
|
240
|
+
declare class TunnelManager {
|
|
241
|
+
private provider;
|
|
253
242
|
private process;
|
|
254
|
-
private
|
|
255
|
-
|
|
243
|
+
private url;
|
|
244
|
+
private tunnelInstance;
|
|
245
|
+
constructor(provider: TunnelProvider);
|
|
256
246
|
/**
|
|
257
|
-
*
|
|
247
|
+
* Create tunnel and return public URL
|
|
258
248
|
*/
|
|
259
|
-
|
|
249
|
+
create(port: number): Promise<string>;
|
|
260
250
|
/**
|
|
261
|
-
*
|
|
251
|
+
* Close tunnel
|
|
262
252
|
*/
|
|
263
|
-
|
|
253
|
+
close(): Promise<void>;
|
|
264
254
|
/**
|
|
265
|
-
*
|
|
255
|
+
* Get tunnel URL
|
|
266
256
|
*/
|
|
267
|
-
|
|
257
|
+
getUrl(): string | null;
|
|
268
258
|
/**
|
|
269
|
-
*
|
|
259
|
+
* Create localtunnel
|
|
270
260
|
*/
|
|
271
|
-
|
|
261
|
+
private createLocaltunnel;
|
|
272
262
|
/**
|
|
273
|
-
*
|
|
263
|
+
* Create localtunnel via CLI
|
|
274
264
|
*/
|
|
275
|
-
|
|
265
|
+
private createLocaltunnelCli;
|
|
276
266
|
/**
|
|
277
|
-
*
|
|
267
|
+
* Create cloudflared tunnel
|
|
278
268
|
*/
|
|
279
|
-
|
|
269
|
+
private createCloudflared;
|
|
280
270
|
/**
|
|
281
|
-
*
|
|
271
|
+
* Create ngrok tunnel
|
|
282
272
|
*/
|
|
283
|
-
|
|
273
|
+
private createNgrok;
|
|
284
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Check if a tunnel provider is available
|
|
277
|
+
*/
|
|
278
|
+
declare function checkTunnelAvailability(provider: TunnelProvider): Promise<boolean>;
|
|
279
|
+
/**
|
|
280
|
+
* Find best available tunnel provider
|
|
281
|
+
*/
|
|
282
|
+
declare function findAvailableTunnel(): Promise<TunnelProvider | null>;
|
|
285
283
|
|
|
286
284
|
/**
|
|
287
285
|
* @nikcli/remote - Mobile Web Client
|
|
@@ -289,9 +287,37 @@ declare class TerminalManager extends EventEmitter {
|
|
|
289
287
|
*/
|
|
290
288
|
declare function getWebClient(): string;
|
|
291
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @nikcli/remote - Enterprise Terminal Streaming
|
|
292
|
+
*
|
|
293
|
+
* Direct stdin/stdout streaming for true real-time terminal access.
|
|
294
|
+
* No fake PTY - mobile sees your actual NikCLI terminal.
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* import { RemoteServer, createTunnel } from '@nikcli/remote'
|
|
299
|
+
*
|
|
300
|
+
* const server = new RemoteServer()
|
|
301
|
+
* const session = await server.start({
|
|
302
|
+
* name: 'my-terminal',
|
|
303
|
+
* processForStreaming: {
|
|
304
|
+
* stdout: process.stdout,
|
|
305
|
+
* stdin: process.stdin,
|
|
306
|
+
* },
|
|
307
|
+
* })
|
|
308
|
+
*
|
|
309
|
+
* // Create public tunnel
|
|
310
|
+
* const tunnelUrl = await createTunnel(session.port, 'cloudflared')
|
|
311
|
+
* console.log('Access your terminal:', tunnelUrl)
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Create a remote server with streaming in one call
|
|
317
|
+
*/
|
|
292
318
|
declare function createRemoteServer(config?: Partial<ServerConfig>): Promise<{
|
|
293
319
|
server: RemoteServer;
|
|
294
320
|
session: RemoteSession;
|
|
295
321
|
}>;
|
|
296
322
|
|
|
297
|
-
export { type BroadcastMessage, type ClientMessage,
|
|
323
|
+
export { type BroadcastMessage, type ClientMessage, DEFAULT_CONFIG, type DeviceInfo, MessageTypes, type RemoteNotification, RemoteServer, type RemoteServerEvents, type RemoteSession, type ServerConfig, type SessionStatus, TunnelManager, type TunnelProvider, type TunnelResult, checkTunnelAvailability, createRemoteServer, createTunnel, findAvailableTunnel, getWebClient };
|