agentgui 1.0.829 → 1.0.830
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/CHANGELOG.md +1 -0
- package/package.json +1 -1
- package/static/index.html +21 -0
- package/static/js/client-agents.js +155 -0
- package/static/js/client-cache.js +172 -0
- package/static/js/client-conv.js +198 -0
- package/static/js/client-events.js +164 -0
- package/static/js/client-exec.js +160 -0
- package/static/js/client-helpers.js +164 -0
- package/static/js/client-load.js +175 -0
- package/static/js/client-render.js +132 -0
- package/static/js/client-scroll.js +178 -0
- package/static/js/client-status.js +167 -0
- package/static/js/client-streaming.js +117 -0
- package/static/js/client-streaming2.js +116 -0
- package/static/js/client-streaming3.js +153 -0
- package/static/js/client-streaming4.js +194 -0
- package/static/js/client-ui-controls.js +170 -0
- package/static/js/client-ui.js +128 -0
- package/static/js/client-ui2.js +159 -0
- package/static/js/client-url.js +93 -0
- package/static/js/client-utils.js +175 -0
- package/static/js/client-ws-msg.js +88 -0
- package/static/js/client-ws.js +161 -0
- package/static/js/client.js +145 -3211
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Object.assign(AgentGUIClient.prototype, {
|
|
2
|
+
setupWebSocketListeners() {
|
|
3
|
+
this.wsManager.on('connected', () => {
|
|
4
|
+
this._dbg('WebSocket connected');
|
|
5
|
+
this.updateConnectionStatus('connected');
|
|
6
|
+
this._subscribeToConversationUpdates();
|
|
7
|
+
if (this.wsManager.stats.totalReconnects > 0 && this.state.currentConversation?.id) {
|
|
8
|
+
this.invalidateCache(this.state.currentConversation.id);
|
|
9
|
+
}
|
|
10
|
+
this._recoverMissedChunks();
|
|
11
|
+
this.updateSendButtonState();
|
|
12
|
+
this.enablePromptArea();
|
|
13
|
+
if (this.state.currentConversation?.id) {
|
|
14
|
+
this.updateBusyPromptArea(this.state.currentConversation.id);
|
|
15
|
+
}
|
|
16
|
+
this.emit('ws:connected');
|
|
17
|
+
if (window.__SERVER_VERSION) {
|
|
18
|
+
fetch((window.__BASE_URL || '') + '/api/version').then(r => r.json()).then(d => {
|
|
19
|
+
if (d.version && d.version !== window.__SERVER_VERSION) {
|
|
20
|
+
this._dbg(`Server updated ${window.__SERVER_VERSION} → ${d.version}, reloading`);
|
|
21
|
+
window.location.reload();
|
|
22
|
+
}
|
|
23
|
+
}).catch(() => {});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.wsManager.on('disconnected', () => {
|
|
28
|
+
this._dbg('WebSocket disconnected');
|
|
29
|
+
this.updateConnectionStatus('disconnected');
|
|
30
|
+
this.updateSendButtonState();
|
|
31
|
+
this.disablePromptArea();
|
|
32
|
+
this.emit('ws:disconnected');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.wsManager.on('reconnecting', (data) => {
|
|
36
|
+
this._dbg('WebSocket reconnecting:', data);
|
|
37
|
+
this.updateConnectionStatus('reconnecting');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
this.wsManager.on('message', (data) => {
|
|
41
|
+
this.handleWebSocketMessage(data);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this.wsManager.on('error', (data) => {
|
|
45
|
+
console.error('WebSocket error:', data);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.wsManager.on('latency_update', (data) => {
|
|
49
|
+
this._updateConnectionIndicator(data.quality);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.wsManager.on('connection_degrading', () => {
|
|
53
|
+
const dot = document.querySelector('.connection-dot');
|
|
54
|
+
if (dot) dot.classList.add('degrading');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.wsManager.on('connection_recovering', () => {
|
|
58
|
+
const dot = document.querySelector('.connection-dot');
|
|
59
|
+
if (dot) dot.classList.remove('degrading');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
window.addEventListener('conversation-selected', (e) => {
|
|
63
|
+
const convId = e.detail.conversationId;
|
|
64
|
+
this.saveDraftPrompt();
|
|
65
|
+
|
|
66
|
+
const isStreaming = this._convIsStreaming(convId);
|
|
67
|
+
if (!isStreaming && window.switchView) {
|
|
68
|
+
window.switchView('chat');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.restoreDraftPrompt(convId);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
window.addEventListener('view-switched', (e) => {
|
|
75
|
+
const view = e.detail.view;
|
|
76
|
+
if (view === 'chat') {
|
|
77
|
+
const convId = this.state.currentConversation?.id;
|
|
78
|
+
const isStreaming = this._convIsStreaming(convId);
|
|
79
|
+
if (isStreaming) {
|
|
80
|
+
this.disableControls();
|
|
81
|
+
} else {
|
|
82
|
+
this.enableControls();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
_convIsStreaming(convId) {
|
|
90
|
+
if (!convId) return false;
|
|
91
|
+
if (typeof convMachineAPI !== 'undefined') return convMachineAPI.isStreaming(convId);
|
|
92
|
+
return this.state.streamingConversations.has(convId);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
_setConvStreaming(convId, streaming, sessionId, agentId) {
|
|
97
|
+
if (!convId) return;
|
|
98
|
+
if (streaming) {
|
|
99
|
+
this.state.streamingConversations.set(convId, true);
|
|
100
|
+
if (typeof convMachineAPI !== 'undefined') convMachineAPI.send(convId, { type: 'STREAM_START', sessionId, agentId });
|
|
101
|
+
} else {
|
|
102
|
+
this.state.streamingConversations.delete(convId);
|
|
103
|
+
if (typeof convMachineAPI !== 'undefined') convMachineAPI.send(convId, { type: 'COMPLETE' });
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
setupRendererListeners() {
|
|
109
|
+
this.renderer.on('batch:complete', (data) => {
|
|
110
|
+
this._dbg('Batch rendered:', data);
|
|
111
|
+
this.updateMetrics(data.metrics);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
this.renderer.on('error:render', (data) => {
|
|
115
|
+
console.error('Render error:', data.error);
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
restoreStateFromUrl() {
|
|
121
|
+
const pathMatch = window.location.pathname.match(/\/conversations\/([^\/]+)$/);
|
|
122
|
+
const conversationId = pathMatch ? pathMatch[1] : null;
|
|
123
|
+
|
|
124
|
+
const params = new URLSearchParams(window.location.search);
|
|
125
|
+
const sessionId = params.get('session');
|
|
126
|
+
|
|
127
|
+
if (conversationId && this.isValidId(conversationId)) {
|
|
128
|
+
this.routerState.currentConversationId = conversationId;
|
|
129
|
+
if (sessionId && this.isValidId(sessionId)) {
|
|
130
|
+
this.routerState.currentSessionId = sessionId;
|
|
131
|
+
}
|
|
132
|
+
this._dbg('Restoring conversation from URL:', conversationId);
|
|
133
|
+
this._isLoadingConversation = true;
|
|
134
|
+
if (window.conversationManager) {
|
|
135
|
+
window.conversationManager.select(conversationId);
|
|
136
|
+
} else {
|
|
137
|
+
this.loadConversationMessages(conversationId).catch((err) => {
|
|
138
|
+
console.warn('Failed to restore conversation from URL, loading latest instead:', err);
|
|
139
|
+
if (this.state.conversations && this.state.conversations.length > 0) {
|
|
140
|
+
const latestConv = this.state.conversations[0];
|
|
141
|
+
this._dbg('Loading latest conversation instead:', latestConv.id);
|
|
142
|
+
return this.loadConversationMessages(latestConv.id);
|
|
143
|
+
} else {
|
|
144
|
+
this._showWelcomeScreen();
|
|
145
|
+
}
|
|
146
|
+
}).finally(() => {
|
|
147
|
+
this._isLoadingConversation = false;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
this._showWelcomeScreen();
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
isValidId(id) {
|
|
157
|
+
if (!id || typeof id !== 'string') return false;
|
|
158
|
+
return /^[a-zA-Z0-9_-]+$/.test(id) && id.length < 256;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
});
|