agentgui 1.0.496 → 1.0.498
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 +47 -0
- package/static/css/tools-popup.css +22 -0
- package/static/index.html +8 -7
- package/static/js/tools-manager.js +48 -2
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1898,6 +1898,53 @@ const server = http.createServer(async (req, res) => {
|
|
|
1898
1898
|
return;
|
|
1899
1899
|
}
|
|
1900
1900
|
|
|
1901
|
+
if (pathOnly === '/api/tools/update' && req.method === 'POST') {
|
|
1902
|
+
sendJSON(req, res, 200, { updating: true, toolCount: 4 });
|
|
1903
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1904
|
+
wsOptimizer.broadcast({ type: 'tools_update_started', tools: ['gm-cc', 'gm-oc', 'gm-gc', 'gm-kilo'] });
|
|
1905
|
+
}
|
|
1906
|
+
setImmediate(async () => {
|
|
1907
|
+
const toolIds = ['gm-cc', 'gm-oc', 'gm-gc', 'gm-kilo'];
|
|
1908
|
+
const results = {};
|
|
1909
|
+
for (const toolId of toolIds) {
|
|
1910
|
+
try {
|
|
1911
|
+
const result = await toolManager.update(toolId, (msg) => {
|
|
1912
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1913
|
+
wsOptimizer.broadcast({ type: 'tool_update_progress', toolId, data: msg });
|
|
1914
|
+
}
|
|
1915
|
+
});
|
|
1916
|
+
results[toolId] = result;
|
|
1917
|
+
if (result.success) {
|
|
1918
|
+
queries.updateToolStatus(toolId, { status: 'installed', installed_at: Date.now() });
|
|
1919
|
+
queries.addToolInstallHistory(toolId, 'update', 'success', null);
|
|
1920
|
+
await toolManager.checkToolStatusAsync(toolId);
|
|
1921
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1922
|
+
wsOptimizer.broadcast({ type: 'tool_update_complete', toolId, data: result });
|
|
1923
|
+
}
|
|
1924
|
+
} else {
|
|
1925
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: result.error });
|
|
1926
|
+
queries.addToolInstallHistory(toolId, 'update', 'failed', result.error);
|
|
1927
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1928
|
+
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: result });
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
} catch (err) {
|
|
1932
|
+
const error = err.message || 'Unknown error';
|
|
1933
|
+
results[toolId] = { success: false, error };
|
|
1934
|
+
queries.updateToolStatus(toolId, { status: 'failed', error_message: error });
|
|
1935
|
+
queries.addToolInstallHistory(toolId, 'update', 'failed', error);
|
|
1936
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1937
|
+
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: { error } });
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
1942
|
+
wsOptimizer.broadcast({ type: 'tools_update_complete', data: results });
|
|
1943
|
+
}
|
|
1944
|
+
});
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1901
1948
|
if (pathOnly === '/api/tools/refresh-all' && req.method === 'POST') {
|
|
1902
1949
|
sendJSON(req, res, 200, { refreshing: true, toolCount: 4 });
|
|
1903
1950
|
if (wsOptimizer && wsOptimizer.broadcast) {
|
|
@@ -336,3 +336,25 @@
|
|
|
336
336
|
color: var(--color-text-primary);
|
|
337
337
|
font-weight: 600;
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
.tools-popup-update-btn {
|
|
341
|
+
padding: 0.625rem 1rem;
|
|
342
|
+
background: var(--color-success);
|
|
343
|
+
color: white;
|
|
344
|
+
border: none;
|
|
345
|
+
border-radius: 0.375rem;
|
|
346
|
+
cursor: pointer;
|
|
347
|
+
font-size: 0.8rem;
|
|
348
|
+
font-weight: 600;
|
|
349
|
+
transition: all 0.2s;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.tools-popup-update-btn:hover:not(:disabled) {
|
|
353
|
+
background: #059669;
|
|
354
|
+
transform: translateY(-0.0625rem);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.tools-popup-update-btn:disabled {
|
|
358
|
+
opacity: 0.6;
|
|
359
|
+
cursor: not-allowed;
|
|
360
|
+
}
|
package/static/index.html
CHANGED
|
@@ -522,13 +522,13 @@
|
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
.view-toggle-btn:hover { color: var(--color-text-primary); }
|
|
525
|
-
.view-toggle-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
|
|
526
|
-
|
|
527
|
-
.view-toggle-btn svg {
|
|
528
|
-
width: 1.2rem;
|
|
529
|
-
height: 1.2rem;
|
|
530
|
-
display: block;
|
|
531
|
-
margin: 0 auto;
|
|
525
|
+
.view-toggle-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
|
|
526
|
+
|
|
527
|
+
.view-toggle-btn svg {
|
|
528
|
+
width: 1.2rem;
|
|
529
|
+
height: 1.2rem;
|
|
530
|
+
display: block;
|
|
531
|
+
margin: 0 auto;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
/* --- Messages scroll area --- */
|
|
@@ -3123,6 +3123,7 @@
|
|
|
3123
3123
|
<div class="tools-popup-scroll"></div>
|
|
3124
3124
|
<div class="tools-popup-footer">
|
|
3125
3125
|
<button class="tools-popup-refresh-btn" onclick="window.toolsManager.refresh()">Refresh All</button>
|
|
3126
|
+
<button class="tools-popup-update-btn" onclick="window.toolsManager.updateAll()" id="toolsUpdateAllBtn">Update All</button>
|
|
3126
3127
|
</div>
|
|
3127
3128
|
</div>
|
|
3128
3129
|
</div>
|
|
@@ -117,7 +117,17 @@
|
|
|
117
117
|
var data = e.detail;
|
|
118
118
|
if (!data) return;
|
|
119
119
|
|
|
120
|
-
if (data.type === '
|
|
120
|
+
if (data.type === 'tools_update_started') {
|
|
121
|
+
var updateTools = data.tools || [];
|
|
122
|
+
updateTools.forEach(function(toolId) {
|
|
123
|
+
var tool = tools.find(t => t.id === toolId);
|
|
124
|
+
if (tool) {
|
|
125
|
+
tool.status = 'updating';
|
|
126
|
+
tool.progress = 5;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
render();
|
|
130
|
+
} else if (data.type === 'tool_install_started' || data.type === 'tool_update_progress') {
|
|
121
131
|
var tool = tools.find(t => t.id === data.toolId);
|
|
122
132
|
if (tool) {
|
|
123
133
|
tool.status = data.type === 'tool_install_started' ? 'installing' : 'updating';
|
|
@@ -132,6 +142,7 @@
|
|
|
132
142
|
tool.version = data.data?.version || tool.version;
|
|
133
143
|
tool.hasUpdate = false;
|
|
134
144
|
tool.progress = 100;
|
|
145
|
+
operationInProgress.delete(data.toolId);
|
|
135
146
|
setTimeout(fetchTools, 1000);
|
|
136
147
|
}
|
|
137
148
|
} else if (data.type === 'tool_install_failed' || data.type === 'tool_update_failed') {
|
|
@@ -143,6 +154,8 @@
|
|
|
143
154
|
operationInProgress.delete(data.toolId);
|
|
144
155
|
render();
|
|
145
156
|
}
|
|
157
|
+
} else if (data.type === 'tools_update_complete') {
|
|
158
|
+
fetchTools();
|
|
146
159
|
} else if (data.type === 'tools_refresh_complete') {
|
|
147
160
|
isRefreshing = false;
|
|
148
161
|
fetchTools();
|
|
@@ -213,6 +226,38 @@
|
|
|
213
226
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
|
|
214
227
|
else init();
|
|
215
228
|
|
|
229
|
+
function updateAll() {
|
|
230
|
+
var toolsWithUpdates = tools.filter(function(t) {
|
|
231
|
+
return t.hasUpdate || t.status === 'needs_update' || t.status === 'failed';
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
if (toolsWithUpdates.length === 0) {
|
|
235
|
+
alert('All tools are up-to-date');
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (var i = 0; i < toolsWithUpdates.length; i++) {
|
|
240
|
+
operationInProgress.add(toolsWithUpdates[i].id);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
fetch('/gm/api/tools/update', { method: 'POST' })
|
|
244
|
+
.then(function(r) { return r.json(); })
|
|
245
|
+
.then(function(d) {
|
|
246
|
+
if (!d.updating) {
|
|
247
|
+
alert('Update started, but response unexpected');
|
|
248
|
+
for (var i = 0; i < toolsWithUpdates.length; i++) {
|
|
249
|
+
operationInProgress.delete(toolsWithUpdates[i].id);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
.catch(function(e) {
|
|
254
|
+
alert('Update failed: ' + e.message);
|
|
255
|
+
for (var i = 0; i < toolsWithUpdates.length; i++) {
|
|
256
|
+
operationInProgress.delete(toolsWithUpdates[i].id);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
216
261
|
window.toolsManager = {
|
|
217
262
|
refresh: function() {
|
|
218
263
|
isRefreshing = true;
|
|
@@ -221,6 +266,7 @@
|
|
|
221
266
|
.catch(function(e) { console.error('[TOOLS-MGR]', e.message); });
|
|
222
267
|
},
|
|
223
268
|
install: function(toolId) { install(toolId); },
|
|
224
|
-
update: function(toolId) { update(toolId); }
|
|
269
|
+
update: function(toolId) { update(toolId); },
|
|
270
|
+
updateAll: function() { updateAll(); }
|
|
225
271
|
};
|
|
226
272
|
})();
|