agentgui 1.0.605 → 1.0.606
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 +1 -1
- package/server.js +1 -1
- package/static/js/terminal.js +20 -20
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -4340,7 +4340,7 @@ wsRouter.onLegacy((data, ws) => {
|
|
|
4340
4340
|
ws.terminalProc = proc;
|
|
4341
4341
|
ws.terminalPty = true;
|
|
4342
4342
|
proc.on('data', (chunk) => {
|
|
4343
|
-
if (ws.readyState === 1) ws.send(JSON.stringify({ type: 'terminal_output', data: chunk.toString('base64'), encoding: 'base64' }));
|
|
4343
|
+
if (ws.readyState === 1) ws.send(JSON.stringify({ type: 'terminal_output', data: Buffer.from(chunk).toString('base64'), encoding: 'base64' }));
|
|
4344
4344
|
});
|
|
4345
4345
|
proc.on('exit', (code) => {
|
|
4346
4346
|
if (ws.readyState === 1) ws.send(JSON.stringify({ type: 'terminal_exit', code }));
|
package/static/js/terminal.js
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
return proto + '//' + location.host + BASE + '/sync';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function getCwd() {
|
|
14
|
+
try {
|
|
15
|
+
if (window.conversationManager) {
|
|
16
|
+
var mgr = window.conversationManager;
|
|
17
|
+
var id = mgr.activeId;
|
|
18
|
+
if (id && mgr.conversations) {
|
|
19
|
+
var conv = mgr.conversations.find(function(c) { return c.id === id; });
|
|
20
|
+
if (conv && conv.workingDirectory) return conv.workingDirectory;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} catch (_) {}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
function ensureTerm() {
|
|
14
28
|
var output = document.getElementById('terminalOutput');
|
|
15
29
|
if (!output) return false;
|
|
@@ -69,24 +83,21 @@
|
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
function connectAndStart() {
|
|
72
|
-
|
|
86
|
+
var cwd = getCwd();
|
|
73
87
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
74
|
-
console.log('Terminal: Sending terminal_start command');
|
|
75
88
|
var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
|
|
76
|
-
ws.send(JSON.stringify({ type: 'terminal_start', cwd:
|
|
89
|
+
ws.send(JSON.stringify({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows }));
|
|
77
90
|
setTimeout(function() { if (term && term.focus) term.focus(); }, 100);
|
|
78
91
|
return;
|
|
79
92
|
}
|
|
80
93
|
if (ws && ws.readyState === WebSocket.CONNECTING) {
|
|
81
|
-
console.log('Terminal: WebSocket already connecting');
|
|
82
94
|
return;
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
ws = new WebSocket(getWsUrl());
|
|
86
98
|
ws.onopen = function() {
|
|
87
|
-
console.log('Terminal: WebSocket connected, starting terminal');
|
|
88
99
|
var dims = term ? { cols: term.cols, rows: term.rows } : { cols: 80, rows: 24 };
|
|
89
|
-
ws.send(JSON.stringify({ type: 'terminal_start', cwd:
|
|
100
|
+
ws.send(JSON.stringify({ type: 'terminal_start', cwd: cwd, cols: dims.cols, rows: dims.rows }));
|
|
90
101
|
setTimeout(function() { if (term && term.focus) term.focus(); }, 100);
|
|
91
102
|
};
|
|
92
103
|
ws.onmessage = function(e) {
|
|
@@ -100,25 +111,18 @@
|
|
|
100
111
|
} else if (msg.type === 'terminal_exit' && term) {
|
|
101
112
|
term.write('\r\n[Process exited with code ' + msg.code + ']\r\n');
|
|
102
113
|
if (termActive) setTimeout(connectAndStart, 2000);
|
|
103
|
-
} else if (msg.type === 'terminal_started') {
|
|
104
|
-
console.log('Terminal: Started successfully');
|
|
105
114
|
}
|
|
106
115
|
} catch(_) {}
|
|
107
116
|
};
|
|
108
117
|
ws.onclose = function() {
|
|
109
|
-
console.log('Terminal: WebSocket closed');
|
|
110
118
|
ws = null;
|
|
111
119
|
if (termActive) setTimeout(connectAndStart, 2000);
|
|
112
120
|
};
|
|
113
|
-
ws.onerror = function(
|
|
114
|
-
console.error('Terminal: WebSocket error:', error);
|
|
115
|
-
};
|
|
121
|
+
ws.onerror = function() {};
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
function startTerminal() {
|
|
119
|
-
console.log('Terminal: Starting terminal module');
|
|
120
125
|
if (!ensureTerm()) {
|
|
121
|
-
console.log('Terminal: Terminal not ready, retrying');
|
|
122
126
|
setTimeout(startTerminal, 200);
|
|
123
127
|
return;
|
|
124
128
|
}
|
|
@@ -128,7 +132,6 @@
|
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
function stopTerminal() {
|
|
131
|
-
console.log('Terminal: Stopping terminal module');
|
|
132
135
|
termActive = false;
|
|
133
136
|
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
134
137
|
ws.send(JSON.stringify({ type: 'terminal_stop' }));
|
|
@@ -140,13 +143,10 @@
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
function initTerminalEarly() {
|
|
143
|
-
console.log('Terminal: Initializing terminal early (not yet active)');
|
|
144
146
|
if (!ensureTerm()) {
|
|
145
|
-
console.log('Terminal: Waiting for xterm.js to load');
|
|
146
147
|
setTimeout(initTerminalEarly, 200);
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
|
-
console.log('Terminal: Terminal UI initialized and ready for interaction');
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
if (document.readyState === 'loading') {
|
|
@@ -167,8 +167,8 @@
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
|
|
170
|
-
window.terminalModule = {
|
|
171
|
-
start: startTerminal,
|
|
170
|
+
window.terminalModule = {
|
|
171
|
+
start: startTerminal,
|
|
172
172
|
stop: stopTerminal,
|
|
173
173
|
getTerminal: function() { return term; },
|
|
174
174
|
isActive: function() { return termActive; }
|