agentgui 1.0.511 → 1.0.513
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/lib/tool-manager.js +17 -15
- package/package.json +1 -1
- package/server.js +28 -35
package/lib/tool-manager.js
CHANGED
|
@@ -6,10 +6,10 @@ import path from 'path';
|
|
|
6
6
|
|
|
7
7
|
const isWindows = os.platform() === 'win32';
|
|
8
8
|
const TOOLS = [
|
|
9
|
-
{ id: 'gm-oc', name: 'OpenCode', pkg: 'opencode-ai' },
|
|
10
|
-
{ id: 'gm-gc', name: 'Gemini CLI', pkg: '@google/gemini-cli' },
|
|
11
|
-
{ id: 'gm-kilo', name: 'Kilo', pkg: '@kilocode/cli' },
|
|
12
|
-
{ id: 'gm-cc', name: 'Claude Code', pkg: '@anthropic-ai/claude-code' },
|
|
9
|
+
{ id: 'gm-oc', name: 'OpenCode', pkg: 'opencode-ai', pluginId: 'opencode-ai' },
|
|
10
|
+
{ id: 'gm-gc', name: 'Gemini CLI', pkg: '@google/gemini-cli', pluginId: 'gm' },
|
|
11
|
+
{ id: 'gm-kilo', name: 'Kilo', pkg: '@kilocode/cli', pluginId: '@kilocode/cli' },
|
|
12
|
+
{ id: 'gm-cc', name: 'Claude Code', pkg: '@anthropic-ai/claude-code', pluginId: 'gm' },
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
const statusCache = new Map();
|
|
@@ -23,12 +23,14 @@ const getNodeModulesPath = () => {
|
|
|
23
23
|
return path.join(__dirname, '..', 'node_modules');
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const getInstalledVersion = (pkg) => {
|
|
26
|
+
const getInstalledVersion = (pkg, pluginId = null) => {
|
|
27
27
|
try {
|
|
28
28
|
const homeDir = os.homedir();
|
|
29
|
+
const tool = pluginId ? TOOLS.find(t => t.pkg === pkg) : null;
|
|
30
|
+
const actualPluginId = pluginId || (tool?.pluginId) || pkg;
|
|
29
31
|
|
|
30
|
-
// Check Claude Code plugins
|
|
31
|
-
const claudePath = path.join(homeDir, '.claude', 'plugins',
|
|
32
|
+
// Check Claude Code plugins using correct pluginId
|
|
33
|
+
const claudePath = path.join(homeDir, '.claude', 'plugins', actualPluginId, 'plugin.json');
|
|
32
34
|
if (fs.existsSync(claudePath)) {
|
|
33
35
|
try {
|
|
34
36
|
const pluginJson = JSON.parse(fs.readFileSync(claudePath, 'utf-8'));
|
|
@@ -38,8 +40,8 @@ const getInstalledVersion = (pkg) => {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
// Check OpenCode agents
|
|
42
|
-
const opencodePath = path.join(homeDir, '.config', 'opencode', 'agents',
|
|
43
|
+
// Check OpenCode agents using correct pluginId
|
|
44
|
+
const opencodePath = path.join(homeDir, '.config', 'opencode', 'agents', actualPluginId, 'plugin.json');
|
|
43
45
|
if (fs.existsSync(opencodePath)) {
|
|
44
46
|
try {
|
|
45
47
|
const pluginJson = JSON.parse(fs.readFileSync(opencodePath, 'utf-8'));
|
|
@@ -50,7 +52,7 @@ const getInstalledVersion = (pkg) => {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
// Check Gemini CLI agents (stored as 'gm' directory)
|
|
53
|
-
const geminiPath = path.join(homeDir, '.gemini', 'extensions',
|
|
55
|
+
const geminiPath = path.join(homeDir, '.gemini', 'extensions', actualPluginId, 'plugin.json');
|
|
54
56
|
if (fs.existsSync(geminiPath)) {
|
|
55
57
|
try {
|
|
56
58
|
const pluginJson = JSON.parse(fs.readFileSync(geminiPath, 'utf-8'));
|
|
@@ -60,7 +62,7 @@ const getInstalledVersion = (pkg) => {
|
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
// Try gemini-extension.json as fallback
|
|
63
|
-
const geminiExtPath = path.join(homeDir, '.gemini', 'extensions',
|
|
65
|
+
const geminiExtPath = path.join(homeDir, '.gemini', 'extensions', actualPluginId, 'gemini-extension.json');
|
|
64
66
|
if (fs.existsSync(geminiExtPath)) {
|
|
65
67
|
try {
|
|
66
68
|
const extJson = JSON.parse(fs.readFileSync(geminiExtPath, 'utf-8'));
|
|
@@ -70,8 +72,8 @@ const getInstalledVersion = (pkg) => {
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
// Check Kilo agents
|
|
74
|
-
const kiloPath = path.join(homeDir, '.config', 'kilo', 'agents',
|
|
75
|
+
// Check Kilo agents using correct pluginId
|
|
76
|
+
const kiloPath = path.join(homeDir, '.config', 'kilo', 'agents', actualPluginId, 'plugin.json');
|
|
75
77
|
if (fs.existsSync(kiloPath)) {
|
|
76
78
|
try {
|
|
77
79
|
const pluginJson = JSON.parse(fs.readFileSync(kiloPath, 'utf-8'));
|
|
@@ -379,7 +381,7 @@ export async function install(toolId, onProgress) {
|
|
|
379
381
|
statusCache.delete(toolId);
|
|
380
382
|
versionCache.clear();
|
|
381
383
|
|
|
382
|
-
const version = getInstalledVersion(tool.pkg);
|
|
384
|
+
const version = getInstalledVersion(tool.pkg, tool.pluginId);
|
|
383
385
|
if (!version) {
|
|
384
386
|
console.warn(`[tool-manager] Install succeeded but version detection failed for ${toolId}. Attempting CLI check...`);
|
|
385
387
|
const cliVersion = await getCliToolVersion(tool.pkg);
|
|
@@ -413,7 +415,7 @@ export async function update(toolId, onProgress) {
|
|
|
413
415
|
statusCache.delete(toolId);
|
|
414
416
|
versionCache.clear();
|
|
415
417
|
|
|
416
|
-
const version = getInstalledVersion(tool.pkg);
|
|
418
|
+
const version = getInstalledVersion(tool.pkg, tool.pluginId);
|
|
417
419
|
if (!version) {
|
|
418
420
|
console.warn(`[tool-manager] Update succeeded but version detection failed for ${toolId}. Attempting CLI check...`);
|
|
419
421
|
const cliVersion = await getCliToolVersion(tool.pkg);
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1817,15 +1817,28 @@ const server = http.createServer(async (req, res) => {
|
|
|
1817
1817
|
|
|
1818
1818
|
if (pathOnly.match(/^\/api\/tools\/([^/]+)\/status$/)) {
|
|
1819
1819
|
const toolId = pathOnly.match(/^\/api\/tools\/([^/]+)\/status$/)[1];
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1820
|
+
const dbStatus = queries.getToolStatus(toolId);
|
|
1821
|
+
const tmStatus = toolManager.checkToolStatus(toolId);
|
|
1822
|
+
if (!tmStatus && !dbStatus) {
|
|
1822
1823
|
sendJSON(req, res, 404, { error: 'Tool not found' });
|
|
1823
1824
|
return;
|
|
1824
1825
|
}
|
|
1826
|
+
|
|
1827
|
+
// Merge database status with tool manager status
|
|
1828
|
+
const status = {
|
|
1829
|
+
toolId,
|
|
1830
|
+
installed: tmStatus?.installed || (dbStatus?.status === 'installed'),
|
|
1831
|
+
isUpToDate: tmStatus?.isUpToDate || false,
|
|
1832
|
+
upgradeNeeded: tmStatus?.upgradeNeeded || false,
|
|
1833
|
+
status: dbStatus?.status || (tmStatus?.installed ? 'installed' : 'not_installed'),
|
|
1834
|
+
installedVersion: dbStatus?.version || tmStatus?.installedVersion || null,
|
|
1835
|
+
timestamp: Date.now(),
|
|
1836
|
+
error_message: dbStatus?.error_message || null
|
|
1837
|
+
};
|
|
1838
|
+
|
|
1825
1839
|
if (status.installed) {
|
|
1826
|
-
const updates = await toolManager.checkForUpdates(toolId
|
|
1827
|
-
status.hasUpdate = updates.
|
|
1828
|
-
status.latestVersion = updates.latestVersion;
|
|
1840
|
+
const updates = await toolManager.checkForUpdates(toolId);
|
|
1841
|
+
status.hasUpdate = updates.needsUpdate || false;
|
|
1829
1842
|
}
|
|
1830
1843
|
sendJSON(req, res, 200, status);
|
|
1831
1844
|
return;
|
|
@@ -1850,17 +1863,13 @@ const server = http.createServer(async (req, res) => {
|
|
|
1850
1863
|
if (!installCompleted) {
|
|
1851
1864
|
installCompleted = true;
|
|
1852
1865
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: 'Install timeout after 6 minutes' });
|
|
1853
|
-
|
|
1854
|
-
wsOptimizer.broadcast({ type: 'tool_install_failed', toolId, data: { success: false, error: 'Install timeout after 6 minutes' } });
|
|
1855
|
-
}
|
|
1866
|
+
broadcastSync({ type: 'tool_install_failed', toolId, data: { success: false, error: 'Install timeout after 6 minutes' } });
|
|
1856
1867
|
queries.addToolInstallHistory(toolId, 'install', 'failed', 'Install timeout after 6 minutes');
|
|
1857
1868
|
}
|
|
1858
1869
|
}, 360000);
|
|
1859
1870
|
|
|
1860
1871
|
toolManager.install(toolId, (msg) => {
|
|
1861
|
-
|
|
1862
|
-
wsOptimizer.broadcast({ type: 'tool_install_progress', toolId, data: msg });
|
|
1863
|
-
}
|
|
1872
|
+
broadcastSync({ type: 'tool_install_progress', toolId, data: msg });
|
|
1864
1873
|
}).then(async (result) => {
|
|
1865
1874
|
clearTimeout(installTimeout);
|
|
1866
1875
|
if (installCompleted) return;
|
|
@@ -1871,16 +1880,12 @@ const server = http.createServer(async (req, res) => {
|
|
|
1871
1880
|
queries.updateToolStatus(toolId, { status: 'installed', version, installed_at: Date.now() });
|
|
1872
1881
|
const freshStatus = await toolManager.checkToolStatusAsync(toolId);
|
|
1873
1882
|
console.log(`[TOOLS-API] Fresh status after install for ${toolId}:`, JSON.stringify(freshStatus));
|
|
1874
|
-
|
|
1875
|
-
wsOptimizer.broadcast({ type: 'tool_install_complete', toolId, data: { success: true, ...freshStatus } });
|
|
1876
|
-
}
|
|
1883
|
+
broadcastSync({ type: 'tool_install_complete', toolId, data: { success: true, ...freshStatus } });
|
|
1877
1884
|
queries.addToolInstallHistory(toolId, 'install', 'success', null);
|
|
1878
1885
|
} else {
|
|
1879
1886
|
console.error(`[TOOLS-API] Install failed for ${toolId}:`, result.error);
|
|
1880
1887
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: result.error });
|
|
1881
|
-
|
|
1882
|
-
wsOptimizer.broadcast({ type: 'tool_install_failed', toolId, data: result });
|
|
1883
|
-
}
|
|
1888
|
+
broadcastSync({ type: 'tool_install_failed', toolId, data: result });
|
|
1884
1889
|
queries.addToolInstallHistory(toolId, 'install', 'failed', result.error);
|
|
1885
1890
|
}
|
|
1886
1891
|
}).catch((err) => {
|
|
@@ -1890,9 +1895,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1890
1895
|
const error = err?.message || 'Unknown error';
|
|
1891
1896
|
console.error(`[TOOLS-API] Install error for ${toolId}:`, error);
|
|
1892
1897
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: error });
|
|
1893
|
-
|
|
1894
|
-
wsOptimizer.broadcast({ type: 'tool_install_failed', toolId, data: { success: false, error } });
|
|
1895
|
-
}
|
|
1898
|
+
broadcastSync({ type: 'tool_install_failed', toolId, data: { success: false, error } });
|
|
1896
1899
|
queries.addToolInstallHistory(toolId, 'install', 'failed', error);
|
|
1897
1900
|
});
|
|
1898
1901
|
return;
|
|
@@ -1919,17 +1922,13 @@ const server = http.createServer(async (req, res) => {
|
|
|
1919
1922
|
if (!updateCompleted) {
|
|
1920
1923
|
updateCompleted = true;
|
|
1921
1924
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: 'Update timeout after 6 minutes' });
|
|
1922
|
-
|
|
1923
|
-
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: { success: false, error: 'Update timeout after 6 minutes' } });
|
|
1924
|
-
}
|
|
1925
|
+
broadcastSync({ type: 'tool_update_failed', toolId, data: { success: false, error: 'Update timeout after 6 minutes' } });
|
|
1925
1926
|
queries.addToolInstallHistory(toolId, 'update', 'failed', 'Update timeout after 6 minutes');
|
|
1926
1927
|
}
|
|
1927
1928
|
}, 360000);
|
|
1928
1929
|
|
|
1929
1930
|
toolManager.update(toolId, (msg) => {
|
|
1930
|
-
|
|
1931
|
-
wsOptimizer.broadcast({ type: 'tool_update_progress', toolId, data: msg });
|
|
1932
|
-
}
|
|
1931
|
+
broadcastSync({ type: 'tool_update_progress', toolId, data: msg });
|
|
1933
1932
|
}).then(async (result) => {
|
|
1934
1933
|
clearTimeout(updateTimeout);
|
|
1935
1934
|
if (updateCompleted) return;
|
|
@@ -1940,16 +1939,12 @@ const server = http.createServer(async (req, res) => {
|
|
|
1940
1939
|
queries.updateToolStatus(toolId, { status: 'installed', version, installed_at: Date.now() });
|
|
1941
1940
|
const freshStatus = await toolManager.checkToolStatusAsync(toolId);
|
|
1942
1941
|
console.log(`[TOOLS-API] Fresh status after update for ${toolId}:`, JSON.stringify(freshStatus));
|
|
1943
|
-
|
|
1944
|
-
wsOptimizer.broadcast({ type: 'tool_update_complete', toolId, data: { success: true, ...freshStatus } });
|
|
1945
|
-
}
|
|
1942
|
+
broadcastSync({ type: 'tool_update_complete', toolId, data: { success: true, ...freshStatus } });
|
|
1946
1943
|
queries.addToolInstallHistory(toolId, 'update', 'success', null);
|
|
1947
1944
|
} else {
|
|
1948
1945
|
console.error(`[TOOLS-API] Update failed for ${toolId}:`, result.error);
|
|
1949
1946
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: result.error });
|
|
1950
|
-
|
|
1951
|
-
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: result });
|
|
1952
|
-
}
|
|
1947
|
+
broadcastSync({ type: 'tool_update_failed', toolId, data: result });
|
|
1953
1948
|
queries.addToolInstallHistory(toolId, 'update', 'failed', result.error);
|
|
1954
1949
|
}
|
|
1955
1950
|
}).catch((err) => {
|
|
@@ -1959,9 +1954,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1959
1954
|
const error = err?.message || 'Unknown error';
|
|
1960
1955
|
console.error(`[TOOLS-API] Update error for ${toolId}:`, error);
|
|
1961
1956
|
queries.updateToolStatus(toolId, { status: 'failed', error_message: error });
|
|
1962
|
-
|
|
1963
|
-
wsOptimizer.broadcast({ type: 'tool_update_failed', toolId, data: { success: false, error } });
|
|
1964
|
-
}
|
|
1957
|
+
broadcastSync({ type: 'tool_update_failed', toolId, data: { success: false, error } });
|
|
1965
1958
|
queries.addToolInstallHistory(toolId, 'update', 'failed', error);
|
|
1966
1959
|
});
|
|
1967
1960
|
return;
|