agentgui 1.0.741 → 1.0.742
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/js/client.js +34 -30
package/package.json
CHANGED
package/static/js/client.js
CHANGED
|
@@ -90,14 +90,18 @@ class AgentGUIClient {
|
|
|
90
90
|
currentConversationId: null,
|
|
91
91
|
currentSessionId: null
|
|
92
92
|
};
|
|
93
|
+
|
|
94
|
+
this._debug = typeof localStorage !== 'undefined' && localStorage.getItem('debug') === '1';
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
_dbg(...args) { if (this._debug) this._dbg(...args); }
|
|
98
|
+
|
|
95
99
|
/**
|
|
96
100
|
* Initialize the client
|
|
97
101
|
*/
|
|
98
102
|
async init() {
|
|
99
103
|
try {
|
|
100
|
-
|
|
104
|
+
this._dbg('Initializing AgentGUI client');
|
|
101
105
|
|
|
102
106
|
// Initialize renderer
|
|
103
107
|
this.renderer.init(this.config.outputContainerId, this.config.scrollContainerId);
|
|
@@ -105,7 +109,7 @@ class AgentGUIClient {
|
|
|
105
109
|
// Initialize image loader
|
|
106
110
|
if (typeof ImageLoader !== 'undefined') {
|
|
107
111
|
window.imageLoader = new ImageLoader();
|
|
108
|
-
|
|
112
|
+
this._dbg('Image loader initialized');
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
// Setup event listeners
|
|
@@ -137,7 +141,7 @@ class AgentGUIClient {
|
|
|
137
141
|
this.emit('initialized');
|
|
138
142
|
this._setupDebugHooks();
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
this._dbg('AgentGUI client initialized');
|
|
141
145
|
return this;
|
|
142
146
|
} catch (error) {
|
|
143
147
|
console.error('Client initialization error:', error);
|
|
@@ -151,7 +155,7 @@ class AgentGUIClient {
|
|
|
151
155
|
*/
|
|
152
156
|
setupWebSocketListeners() {
|
|
153
157
|
this.wsManager.on('connected', () => {
|
|
154
|
-
|
|
158
|
+
this._dbg('WebSocket connected');
|
|
155
159
|
this.updateConnectionStatus('connected');
|
|
156
160
|
this._subscribeToConversationUpdates();
|
|
157
161
|
// On reconnect (not initial connect), invalidate current conversation's DOM
|
|
@@ -170,7 +174,7 @@ class AgentGUIClient {
|
|
|
170
174
|
if (window.__SERVER_VERSION) {
|
|
171
175
|
fetch((window.__BASE_URL || '') + '/api/version').then(r => r.json()).then(d => {
|
|
172
176
|
if (d.version && d.version !== window.__SERVER_VERSION) {
|
|
173
|
-
|
|
177
|
+
this._dbg(`Server updated ${window.__SERVER_VERSION} → ${d.version}, reloading`);
|
|
174
178
|
window.location.reload();
|
|
175
179
|
}
|
|
176
180
|
}).catch(() => {});
|
|
@@ -178,7 +182,7 @@ class AgentGUIClient {
|
|
|
178
182
|
});
|
|
179
183
|
|
|
180
184
|
this.wsManager.on('disconnected', () => {
|
|
181
|
-
|
|
185
|
+
this._dbg('WebSocket disconnected');
|
|
182
186
|
this.updateConnectionStatus('disconnected');
|
|
183
187
|
this.updateSendButtonState();
|
|
184
188
|
this.disablePromptArea();
|
|
@@ -186,7 +190,7 @@ class AgentGUIClient {
|
|
|
186
190
|
});
|
|
187
191
|
|
|
188
192
|
this.wsManager.on('reconnecting', (data) => {
|
|
189
|
-
|
|
193
|
+
this._dbg('WebSocket reconnecting:', data);
|
|
190
194
|
this.updateConnectionStatus('reconnecting');
|
|
191
195
|
});
|
|
192
196
|
|
|
@@ -266,7 +270,7 @@ class AgentGUIClient {
|
|
|
266
270
|
*/
|
|
267
271
|
setupRendererListeners() {
|
|
268
272
|
this.renderer.on('batch:complete', (data) => {
|
|
269
|
-
|
|
273
|
+
this._dbg('Batch rendered:', data);
|
|
270
274
|
this.updateMetrics(data.metrics);
|
|
271
275
|
});
|
|
272
276
|
|
|
@@ -293,7 +297,7 @@ class AgentGUIClient {
|
|
|
293
297
|
if (sessionId && this.isValidId(sessionId)) {
|
|
294
298
|
this.routerState.currentSessionId = sessionId;
|
|
295
299
|
}
|
|
296
|
-
|
|
300
|
+
this._dbg('Restoring conversation from URL:', conversationId);
|
|
297
301
|
this._isLoadingConversation = true;
|
|
298
302
|
if (window.conversationManager) {
|
|
299
303
|
window.conversationManager.select(conversationId);
|
|
@@ -303,7 +307,7 @@ class AgentGUIClient {
|
|
|
303
307
|
// If the URL conversation doesn't exist, try loading the most recent conversation
|
|
304
308
|
if (this.state.conversations && this.state.conversations.length > 0) {
|
|
305
309
|
const latestConv = this.state.conversations[0];
|
|
306
|
-
|
|
310
|
+
this._dbg('Loading latest conversation instead:', latestConv.id);
|
|
307
311
|
return this.loadConversationMessages(latestConv.id);
|
|
308
312
|
} else {
|
|
309
313
|
// No conversations available - show welcome screen
|
|
@@ -510,7 +514,7 @@ class AgentGUIClient {
|
|
|
510
514
|
if (!this.state.currentConversation) return;
|
|
511
515
|
try {
|
|
512
516
|
const data = await window.wsClient.rpc('conv.cancel', { id: this.state.currentConversation.id });
|
|
513
|
-
|
|
517
|
+
this._dbg('Stop response:', data);
|
|
514
518
|
} catch (err) {
|
|
515
519
|
console.error('Failed to stop:', err);
|
|
516
520
|
}
|
|
@@ -561,7 +565,7 @@ class AgentGUIClient {
|
|
|
561
565
|
try {
|
|
562
566
|
// Queue uses msg.send which will enqueue if streaming is active
|
|
563
567
|
const data = await window.wsClient.rpc('msg.send', { id: this.state.currentConversation.id, content: message });
|
|
564
|
-
|
|
568
|
+
this._dbg('Queue response:', data);
|
|
565
569
|
if (this.ui.messageInput) {
|
|
566
570
|
this.ui.messageInput.value = '';
|
|
567
571
|
this.ui.messageInput.style.height = 'auto';
|
|
@@ -788,7 +792,7 @@ class AgentGUIClient {
|
|
|
788
792
|
}
|
|
789
793
|
|
|
790
794
|
async handleStreamingStart(data) {
|
|
791
|
-
|
|
795
|
+
this._dbg('Streaming started:', data);
|
|
792
796
|
if (window.promptMachineAPI) window.promptMachineAPI.send({ type: 'STREAMING', conversationId: data.conversationId });
|
|
793
797
|
this._clearThinkingCountdown();
|
|
794
798
|
if (this._lastSendTime > 0) {
|
|
@@ -812,9 +816,9 @@ class AgentGUIClient {
|
|
|
812
816
|
// If this streaming event is for a different conversation than what we are viewing,
|
|
813
817
|
// just track the state but do not modify the DOM or start polling
|
|
814
818
|
if (this.state.currentConversation?.id !== data.conversationId) {
|
|
815
|
-
|
|
819
|
+
this._dbg('Streaming started for non-active conversation:', data.conversationId);
|
|
816
820
|
this._setConvStreaming(data.conversationId, true, data.sessionId, data.agentId);
|
|
817
|
-
|
|
821
|
+
this._dbg('[SYNC] streaming_start - non-active conv:', { convId: data.conversationId, sessionId: data.sessionId, streamingCount: this.state.streamingConversations.size });
|
|
818
822
|
this.updateBusyPromptArea(data.conversationId);
|
|
819
823
|
this.emit('streaming:start', data);
|
|
820
824
|
|
|
@@ -900,7 +904,7 @@ class AgentGUIClient {
|
|
|
900
904
|
}
|
|
901
905
|
|
|
902
906
|
async handleStreamingResumed(data) {
|
|
903
|
-
|
|
907
|
+
this._dbg('Streaming resumed:', data);
|
|
904
908
|
const conv = this.state.currentConversation || { id: data.conversationId };
|
|
905
909
|
await this.handleStreamingStart({
|
|
906
910
|
type: 'streaming_start',
|
|
@@ -1098,7 +1102,7 @@ class AgentGUIClient {
|
|
|
1098
1102
|
|
|
1099
1103
|
// If this event is for a conversation we are NOT currently viewing, just track state
|
|
1100
1104
|
if (conversationId && this.state.currentConversation?.id !== conversationId) {
|
|
1101
|
-
|
|
1105
|
+
this._dbg('Streaming error for non-active conversation:', conversationId);
|
|
1102
1106
|
this._setConvStreaming(conversationId, false);
|
|
1103
1107
|
this.updateBusyPromptArea(conversationId);
|
|
1104
1108
|
this.emit('streaming:error', data);
|
|
@@ -1163,7 +1167,7 @@ class AgentGUIClient {
|
|
|
1163
1167
|
}
|
|
1164
1168
|
|
|
1165
1169
|
handleStreamingComplete(data) {
|
|
1166
|
-
|
|
1170
|
+
this._dbg('Streaming completed:', data);
|
|
1167
1171
|
if (window.promptMachineAPI) window.promptMachineAPI.send({ type: 'READY' });
|
|
1168
1172
|
this._clearThinkingCountdown();
|
|
1169
1173
|
|
|
@@ -1171,16 +1175,16 @@ class AgentGUIClient {
|
|
|
1171
1175
|
if (conversationId) this.invalidateCache(conversationId);
|
|
1172
1176
|
|
|
1173
1177
|
if (conversationId && this.state.currentConversation?.id !== conversationId) {
|
|
1174
|
-
|
|
1178
|
+
this._dbg('Streaming completed for non-active conversation:', conversationId);
|
|
1175
1179
|
this._setConvStreaming(conversationId, false);
|
|
1176
|
-
|
|
1180
|
+
this._dbg('[SYNC] streaming_complete - non-active conv:', { convId: conversationId, streamingCount: this.state.streamingConversations.size });
|
|
1177
1181
|
this.updateBusyPromptArea(conversationId);
|
|
1178
1182
|
this.emit('streaming:complete', data);
|
|
1179
1183
|
return;
|
|
1180
1184
|
}
|
|
1181
1185
|
|
|
1182
1186
|
this._setConvStreaming(conversationId, false);
|
|
1183
|
-
|
|
1187
|
+
this._dbg('[SYNC] streaming_complete - active conv:', { convId: conversationId, streamingCount: this.state.streamingConversations.size, interrupted: data.interrupted });
|
|
1184
1188
|
this.updateBusyPromptArea(conversationId);
|
|
1185
1189
|
|
|
1186
1190
|
const sessionId = data.sessionId || this.state.currentSession?.id;
|
|
@@ -1268,7 +1272,7 @@ class AgentGUIClient {
|
|
|
1268
1272
|
return;
|
|
1269
1273
|
}
|
|
1270
1274
|
|
|
1271
|
-
|
|
1275
|
+
this._dbg('[SYNC] message_created:', { msgId: data.message.id, role: data.message.role, convId: data.conversationId });
|
|
1272
1276
|
|
|
1273
1277
|
// Update messageCount in current conversation state for user messages
|
|
1274
1278
|
if (data.message.role === 'user' && this.state.currentConversation) {
|
|
@@ -2082,7 +2086,7 @@ class AgentGUIClient {
|
|
|
2082
2086
|
}
|
|
2083
2087
|
|
|
2084
2088
|
if (result.queued) {
|
|
2085
|
-
|
|
2089
|
+
this._dbg('Message queued, position:', result.queuePosition);
|
|
2086
2090
|
this.enableControls();
|
|
2087
2091
|
return;
|
|
2088
2092
|
}
|
|
@@ -2260,13 +2264,13 @@ class AgentGUIClient {
|
|
|
2260
2264
|
.map(a => `<option value="${a.id}">${a.name.split(/[\s\-]+/)[0]}</option>`)
|
|
2261
2265
|
.join('');
|
|
2262
2266
|
this.ui.agentSelector.style.display = 'inline-block';
|
|
2263
|
-
|
|
2267
|
+
this._dbg(`[Agent Selector] Loaded ${subAgents.length} sub-agents for ${cliAgentId}`);
|
|
2264
2268
|
// Auto-select first sub-agent and load its models
|
|
2265
2269
|
const firstSubAgentId = subAgents[0].id;
|
|
2266
2270
|
this.ui.agentSelector.value = firstSubAgentId;
|
|
2267
2271
|
this.loadModelsForAgent(cliAgentId); // models keyed to parent agent
|
|
2268
2272
|
} else {
|
|
2269
|
-
|
|
2273
|
+
this._dbg(`[Agent Selector] No sub-agents found for ${cliAgentId}`);
|
|
2270
2274
|
// Load models for the CLI agent itself (fallback for agents without sub-agents)
|
|
2271
2275
|
const cliToAcpMap = {
|
|
2272
2276
|
'cli-opencode': 'opencode',
|
|
@@ -2508,7 +2512,7 @@ class AgentGUIClient {
|
|
|
2508
2512
|
}
|
|
2509
2513
|
if (progress.done || progress.status === 'completed') {
|
|
2510
2514
|
this._modelDownloadInProgress = false;
|
|
2511
|
-
|
|
2515
|
+
this._dbg('[Models] Download complete');
|
|
2512
2516
|
this._updateConnectionIndicator(this.wsManager?.latency?.quality || 'unknown');
|
|
2513
2517
|
return;
|
|
2514
2518
|
}
|
|
@@ -2520,7 +2524,7 @@ class AgentGUIClient {
|
|
|
2520
2524
|
|
|
2521
2525
|
_handleTTSSetupProgress(data) {
|
|
2522
2526
|
if (data.step && data.status) {
|
|
2523
|
-
|
|
2527
|
+
this._dbg('[TTS Setup]', data.step, ':', data.status, data.message || '');
|
|
2524
2528
|
}
|
|
2525
2529
|
}
|
|
2526
2530
|
|
|
@@ -2777,7 +2781,7 @@ class AgentGUIClient {
|
|
|
2777
2781
|
if (window.conversationManager) window.conversationManager.loadConversations();
|
|
2778
2782
|
const fallbackConv = prevConversationId ? prevConversationId : availableFallback?.id;
|
|
2779
2783
|
if (fallbackConv && fallbackConv !== conversationId) {
|
|
2780
|
-
|
|
2784
|
+
this._dbg('Resuming from fallback conversation:', fallbackConv);
|
|
2781
2785
|
this.showError('Conversation not found. Resuming previous conversation.');
|
|
2782
2786
|
await this.loadConversationMessages(fallbackConv);
|
|
2783
2787
|
} else {
|
|
@@ -2958,7 +2962,7 @@ class AgentGUIClient {
|
|
|
2958
2962
|
// Resume from last successful conversation if available, or fall back to any available conversation
|
|
2959
2963
|
const fallbackConv = prevConversationId ? prevConversationId : availableFallback?.id;
|
|
2960
2964
|
if (fallbackConv && fallbackConv !== conversationId) {
|
|
2961
|
-
|
|
2965
|
+
this._dbg('Resuming from fallback conversation due to error:', fallbackConv);
|
|
2962
2966
|
this.showError('Failed to load conversation. Resuming previous conversation.');
|
|
2963
2967
|
try {
|
|
2964
2968
|
await this.loadConversationMessages(fallbackConv);
|
|
@@ -3354,7 +3358,7 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
|
3354
3358
|
agentGUIClient = new AgentGUIClient();
|
|
3355
3359
|
window.agentGuiClient = agentGUIClient;
|
|
3356
3360
|
await agentGUIClient.init();
|
|
3357
|
-
|
|
3361
|
+
this._dbg('AgentGUI ready');
|
|
3358
3362
|
} catch (error) {
|
|
3359
3363
|
console.error('Failed to initialize AgentGUI:', error);
|
|
3360
3364
|
}
|