remote-cli-agent 0.5.0 → 0.6.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/dist/connection.js +15 -5
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebSocket from 'ws';
|
|
2
|
-
import { getSessionList, writeToSession, resizeSession, attachSession, spawnSession, setOutputHandler, setSessionsChangeHandler } from './terminal.js';
|
|
2
|
+
import { getSessionList, writeToSession, resizeSession, attachSession, spawnSession, createTmuxSession, attachTmuxSession, setOutputHandler, setSessionsChangeHandler } from './terminal.js';
|
|
3
3
|
let ws = null;
|
|
4
4
|
let reconnectTimer = null;
|
|
5
5
|
let reconnectAttempts = 0;
|
|
@@ -78,10 +78,20 @@ function handleMessage(msg) {
|
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
case 'spawn': {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
const name = msg.name || `session-${Date.now()}`;
|
|
82
|
+
// Create a tmux session so it can be shared locally
|
|
83
|
+
const tmuxName = createTmuxSession(name);
|
|
84
|
+
if (tmuxName) {
|
|
85
|
+
const session = attachTmuxSession(tmuxName);
|
|
86
|
+
if (session) {
|
|
87
|
+
console.log(`Created tmux session: ${tmuxName} (${session.id})`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Fallback to PTY
|
|
92
|
+
const session = spawnSession(msg.command);
|
|
93
|
+
console.log(`Spawned session: ${session.name} (${session.id})`);
|
|
94
|
+
}
|
|
85
95
|
sendMessage({ type: 'sessions_update', sessions: getSessionList() });
|
|
86
96
|
break;
|
|
87
97
|
}
|