agentgui 1.0.400 → 1.0.401
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/static/index.html +16 -16
- package/static/js/script-runner.js +211 -219
- package/static/js/terminal.js +7 -2
package/package.json
CHANGED
package/static/index.html
CHANGED
|
@@ -3217,22 +3217,22 @@
|
|
|
3217
3217
|
window._escHtml = function(t) { return t.replace(_escHtmlRe, function(c) { return _escHtmlMap[c]; }); };
|
|
3218
3218
|
</script>
|
|
3219
3219
|
<script defer src="/gm/js/event-processor.js"></script>
|
|
3220
|
-
<script defer src="/gm/js/streaming-renderer.js"></script>
|
|
3221
|
-
<script defer src="/gm/js/kalman-filter.js"></script>
|
|
3222
|
-
<script defer src="/gm/js/event-consolidator.js"></script>
|
|
3223
|
-
<script defer src="/gm/js/websocket-manager.js"></script>
|
|
3224
|
-
<script defer src="/gm/js/ws-client.js"></script>
|
|
3225
|
-
<script defer src="/gm/js/event-filter.js"></script>
|
|
3226
|
-
<script defer src="/gm/js/syntax-highlighter.js"></script>
|
|
3227
|
-
<script defer src="/gm/js/dialogs.js"></script>
|
|
3228
|
-
<script defer src="/gm/js/ui-components.js"></script>
|
|
3229
|
-
<script defer src="/gm/js/conversations.js"></script>
|
|
3230
|
-
<script defer src="/gm/js/
|
|
3231
|
-
<script
|
|
3232
|
-
<script defer src="/gm/js/
|
|
3233
|
-
<script
|
|
3234
|
-
<script defer src="/gm/js/
|
|
3235
|
-
<script defer src="/gm/js/agent-auth.js"></script>
|
|
3220
|
+
<script defer src="/gm/js/streaming-renderer.js"></script>
|
|
3221
|
+
<script defer src="/gm/js/kalman-filter.js"></script>
|
|
3222
|
+
<script defer src="/gm/js/event-consolidator.js"></script>
|
|
3223
|
+
<script defer src="/gm/js/websocket-manager.js"></script>
|
|
3224
|
+
<script defer src="/gm/js/ws-client.js"></script>
|
|
3225
|
+
<script defer src="/gm/js/event-filter.js"></script>
|
|
3226
|
+
<script defer src="/gm/js/syntax-highlighter.js"></script>
|
|
3227
|
+
<script defer src="/gm/js/dialogs.js"></script>
|
|
3228
|
+
<script defer src="/gm/js/ui-components.js"></script>
|
|
3229
|
+
<script defer src="/gm/js/conversations.js"></script>
|
|
3230
|
+
<script defer src="/gm/js/terminal.js"></script>
|
|
3231
|
+
<script defer src="/gm/js/script-runner.js"></script>
|
|
3232
|
+
<script defer src="/gm/js/client.js"></script>
|
|
3233
|
+
<script type="module" src="/gm/js/voice.js"></script>
|
|
3234
|
+
<script defer src="/gm/js/features.js"></script>
|
|
3235
|
+
<script defer src="/gm/js/agent-auth.js"></script>
|
|
3236
3236
|
|
|
3237
3237
|
<script>
|
|
3238
3238
|
const savedTheme = localStorage.getItem('theme') || 'light';
|
|
@@ -1,219 +1,211 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
const BASE = window.__BASE_URL || '';
|
|
3
|
-
let currentConversationId = null;
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
scriptState.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
fetch(BASE + '/api/conversations/' + currentConversationId
|
|
64
|
-
.then(function(r) { return r.json(); })
|
|
65
|
-
.then(function(data) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
init();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
window.scriptRunner = {
|
|
216
|
-
getState: function() { return scriptState; },
|
|
217
|
-
getTerminal: function() { return terminal; }
|
|
218
|
-
};
|
|
219
|
-
})();
|
|
1
|
+
(function() {
|
|
2
|
+
const BASE = window.__BASE_URL || '';
|
|
3
|
+
let currentConversationId = null;
|
|
4
|
+
let currentWorkingDirectory = null;
|
|
5
|
+
let scriptState = { running: false, script: null, hasStart: false, hasDev: false };
|
|
6
|
+
let hasTerminalContent = false;
|
|
7
|
+
|
|
8
|
+
function init() {
|
|
9
|
+
setupListeners();
|
|
10
|
+
setupButtons();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function setupListeners() {
|
|
14
|
+
window.addEventListener('conversation-selected', function(e) {
|
|
15
|
+
currentConversationId = e.detail.conversationId;
|
|
16
|
+
hasTerminalContent = false;
|
|
17
|
+
hideTerminalTab();
|
|
18
|
+
fetchConversationAndCheckScripts();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
window.addEventListener('ws-message', function(e) {
|
|
22
|
+
const data = e.detail;
|
|
23
|
+
if (!data || !currentConversationId) return;
|
|
24
|
+
if (data.conversationId !== currentConversationId) return;
|
|
25
|
+
|
|
26
|
+
const term = getTerminal();
|
|
27
|
+
|
|
28
|
+
if (data.type === 'script_started') {
|
|
29
|
+
scriptState.running = true;
|
|
30
|
+
scriptState.script = data.script;
|
|
31
|
+
hasTerminalContent = false;
|
|
32
|
+
if (term) term.clear();
|
|
33
|
+
updateButtons();
|
|
34
|
+
showTerminalTab();
|
|
35
|
+
} else if (data.type === 'script_stopped') {
|
|
36
|
+
scriptState.running = false;
|
|
37
|
+
const msg = data.error ? data.error : ('exited with code ' + (data.code || 0));
|
|
38
|
+
if (term) term.writeln('\r\n\x1b[90m[process ' + msg + ']\x1b[0m');
|
|
39
|
+
updateButtons();
|
|
40
|
+
} else if (data.type === 'script_output') {
|
|
41
|
+
hasTerminalContent = true;
|
|
42
|
+
showTerminalTab();
|
|
43
|
+
if (term) term.write(data.data);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
window.addEventListener('resize', debounce(fitTerminal, 200));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function setupButtons() {
|
|
51
|
+
var startBtn = document.getElementById('scriptStartBtn');
|
|
52
|
+
var devBtn = document.getElementById('scriptDevBtn');
|
|
53
|
+
var stopBtn = document.getElementById('scriptStopBtn');
|
|
54
|
+
|
|
55
|
+
if (startBtn) startBtn.addEventListener('click', function() { runScript('start'); });
|
|
56
|
+
if (devBtn) devBtn.addEventListener('click', function() { runScript('dev'); });
|
|
57
|
+
if (stopBtn) stopBtn.addEventListener('click', function() { stopScript(); });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function fetchConversationAndCheckScripts() {
|
|
61
|
+
if (!currentConversationId) return;
|
|
62
|
+
|
|
63
|
+
fetch(BASE + '/api/conversations/' + currentConversationId)
|
|
64
|
+
.then(function(r) { return r.json(); })
|
|
65
|
+
.then(function(data) {
|
|
66
|
+
currentWorkingDirectory = data.conversation?.workingDirectory || null;
|
|
67
|
+
if (currentWorkingDirectory) {
|
|
68
|
+
showTerminalTab();
|
|
69
|
+
}
|
|
70
|
+
checkScripts();
|
|
71
|
+
})
|
|
72
|
+
.catch(function() {
|
|
73
|
+
checkScripts();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function checkScripts() {
|
|
78
|
+
if (!currentConversationId) return;
|
|
79
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/scripts')
|
|
80
|
+
.then(function(r) { return r.json(); })
|
|
81
|
+
.then(function(data) {
|
|
82
|
+
scriptState.hasStart = data.hasStart;
|
|
83
|
+
scriptState.hasDev = data.hasDev;
|
|
84
|
+
scriptState.running = data.running;
|
|
85
|
+
scriptState.script = data.runningScript;
|
|
86
|
+
updateButtons();
|
|
87
|
+
if (data.running || hasTerminalContent) showTerminalTab();
|
|
88
|
+
})
|
|
89
|
+
.catch(function() {
|
|
90
|
+
scriptState.hasStart = false;
|
|
91
|
+
scriptState.hasDev = false;
|
|
92
|
+
updateButtons();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function updateButtons() {
|
|
97
|
+
var container = document.getElementById('scriptButtons');
|
|
98
|
+
var startBtn = document.getElementById('scriptStartBtn');
|
|
99
|
+
var devBtn = document.getElementById('scriptDevBtn');
|
|
100
|
+
var stopBtn = document.getElementById('scriptStopBtn');
|
|
101
|
+
|
|
102
|
+
var showAny = scriptState.hasStart || scriptState.hasDev || scriptState.running;
|
|
103
|
+
if (container) container.style.display = showAny ? 'flex' : 'none';
|
|
104
|
+
|
|
105
|
+
if (scriptState.running) {
|
|
106
|
+
if (startBtn) startBtn.style.display = 'none';
|
|
107
|
+
if (devBtn) devBtn.style.display = 'none';
|
|
108
|
+
if (stopBtn) stopBtn.style.display = 'flex';
|
|
109
|
+
} else {
|
|
110
|
+
if (startBtn) startBtn.style.display = scriptState.hasStart ? 'flex' : 'none';
|
|
111
|
+
if (devBtn) devBtn.style.display = scriptState.hasDev ? 'flex' : 'none';
|
|
112
|
+
if (stopBtn) stopBtn.style.display = 'none';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function runScript(script) {
|
|
117
|
+
if (!currentConversationId || scriptState.running) return;
|
|
118
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/run-script', {
|
|
119
|
+
method: 'POST',
|
|
120
|
+
headers: { 'Content-Type': 'application/json' },
|
|
121
|
+
body: JSON.stringify({ script: script })
|
|
122
|
+
})
|
|
123
|
+
.then(function(r) { return r.json(); })
|
|
124
|
+
.then(function(data) {
|
|
125
|
+
if (data.ok) {
|
|
126
|
+
scriptState.running = true;
|
|
127
|
+
scriptState.script = script;
|
|
128
|
+
hasTerminalContent = false;
|
|
129
|
+
updateButtons();
|
|
130
|
+
showTerminalTab();
|
|
131
|
+
switchToTerminalView();
|
|
132
|
+
|
|
133
|
+
var term = getTerminal();
|
|
134
|
+
if (term) {
|
|
135
|
+
term.clear();
|
|
136
|
+
term.writeln('\x1b[36m[running npm run ' + script + ']\x1b[0m\r\n');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
.catch(function(err) {
|
|
141
|
+
console.error('Failed to start script:', err);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function stopScript() {
|
|
146
|
+
if (!currentConversationId) return;
|
|
147
|
+
fetch(BASE + '/api/conversations/' + currentConversationId + '/stop-script', {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
headers: { 'Content-Type': 'application/json' },
|
|
150
|
+
body: '{}'
|
|
151
|
+
}).catch(function(err) {
|
|
152
|
+
console.error('Failed to stop script:', err);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function showTerminalTab() {
|
|
157
|
+
var btn = document.getElementById('terminalTabBtn');
|
|
158
|
+
if (btn) btn.style.display = '';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function hideTerminalTab() {
|
|
162
|
+
var btn = document.getElementById('terminalTabBtn');
|
|
163
|
+
if (btn) btn.style.display = 'none';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function switchToTerminalView() {
|
|
167
|
+
var bar = document.getElementById('viewToggleBar');
|
|
168
|
+
if (!bar) return;
|
|
169
|
+
var termBtn = bar.querySelector('[data-view="terminal"]');
|
|
170
|
+
if (termBtn) termBtn.click();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function getTerminal() {
|
|
174
|
+
if (window.terminalModule && window.terminalModule.getTerminal) {
|
|
175
|
+
return window.terminalModule.getTerminal();
|
|
176
|
+
}
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function fitTerminal() {
|
|
181
|
+
var term = getTerminal();
|
|
182
|
+
if (term && term._core && term._core._renderService) {
|
|
183
|
+
try { term.fit(); } catch {}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function debounce(fn, ms) {
|
|
188
|
+
var timer;
|
|
189
|
+
return function() {
|
|
190
|
+
clearTimeout(timer);
|
|
191
|
+
timer = setTimeout(fn, ms);
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
window.addEventListener('view-switched', function(e) {
|
|
196
|
+
if (e.detail && e.detail.view === 'terminal') {
|
|
197
|
+
setTimeout(fitTerminal, 100);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
if (document.readyState === 'loading') {
|
|
202
|
+
document.addEventListener('DOMContentLoaded', init);
|
|
203
|
+
} else {
|
|
204
|
+
init();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
window.scriptRunner = {
|
|
208
|
+
getState: function() { return scriptState; },
|
|
209
|
+
getTerminal: getTerminal
|
|
210
|
+
};
|
|
211
|
+
})();
|
package/static/js/terminal.js
CHANGED
|
@@ -101,5 +101,10 @@
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
window.terminalModule = {
|
|
105
|
-
|
|
104
|
+
window.terminalModule = {
|
|
105
|
+
start: startTerminal,
|
|
106
|
+
stop: stopTerminal,
|
|
107
|
+
getTerminal: function() { return term; },
|
|
108
|
+
isActive: function() { return termActive; }
|
|
109
|
+
};
|
|
110
|
+
})();
|