agentgui 1.0.492 → 1.0.494
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 +46 -2
- package/package.json +1 -1
- package/server.js +1 -1
package/lib/tool-manager.js
CHANGED
|
@@ -35,6 +35,45 @@ const getInstalledVersion = (pkg) => {
|
|
|
35
35
|
return null;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
const getCliToolVersion = async (pkg) => {
|
|
39
|
+
try {
|
|
40
|
+
const cliName = pkg.split('/').pop();
|
|
41
|
+
const nodeModulesPath = getNodeModulesPath();
|
|
42
|
+
const cliBinPath = path.join(nodeModulesPath, '.bin', cliName);
|
|
43
|
+
|
|
44
|
+
if (fs.existsSync(cliBinPath)) {
|
|
45
|
+
const result = await new Promise((resolve) => {
|
|
46
|
+
const proc = spawn(cliBinPath, ['--version'], {
|
|
47
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
48
|
+
timeout: 5000,
|
|
49
|
+
shell: isWindows
|
|
50
|
+
});
|
|
51
|
+
let stdout = '';
|
|
52
|
+
proc.stdout.on('data', (d) => { stdout += d.toString(); });
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
try { proc.kill('SIGKILL'); } catch (_) {}
|
|
55
|
+
resolve(null);
|
|
56
|
+
}, 5000);
|
|
57
|
+
proc.on('close', (code) => {
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
if (code === 0) {
|
|
60
|
+
const version = stdout.trim().split(/[\s\(]/)[0];
|
|
61
|
+
resolve(version && version.match(/^\d+\.\d+/) ? version : null);
|
|
62
|
+
} else {
|
|
63
|
+
resolve(null);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
proc.on('error', () => {
|
|
67
|
+
clearTimeout(timer);
|
|
68
|
+
resolve(null);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
} catch (_) {}
|
|
74
|
+
return null;
|
|
75
|
+
};
|
|
76
|
+
|
|
38
77
|
const getPublishedVersion = async (pkg) => {
|
|
39
78
|
try {
|
|
40
79
|
const cacheKey = `published-${pkg}`;
|
|
@@ -120,6 +159,11 @@ const checkToolViaBunx = async (pkg) => {
|
|
|
120
159
|
});
|
|
121
160
|
});
|
|
122
161
|
|
|
162
|
+
let finalInstalledVersion = checkResult.installedVersion;
|
|
163
|
+
if (!finalInstalledVersion && checkResult.installed) {
|
|
164
|
+
finalInstalledVersion = await getCliToolVersion(pkg);
|
|
165
|
+
}
|
|
166
|
+
|
|
123
167
|
const publishedVersion = await getPublishedVersion(pkg);
|
|
124
168
|
const compareVersions = (v1, v2) => {
|
|
125
169
|
if (!v1 || !v2) return false;
|
|
@@ -134,8 +178,8 @@ const checkToolViaBunx = async (pkg) => {
|
|
|
134
178
|
return false;
|
|
135
179
|
};
|
|
136
180
|
|
|
137
|
-
const needsUpdate = checkResult.installed && publishedVersion && compareVersions(
|
|
138
|
-
return { ...checkResult, publishedVersion, upgradeNeeded: needsUpdate };
|
|
181
|
+
const needsUpdate = checkResult.installed && publishedVersion && compareVersions(finalInstalledVersion, publishedVersion);
|
|
182
|
+
return { ...checkResult, installedVersion: finalInstalledVersion, publishedVersion, upgradeNeeded: needsUpdate };
|
|
139
183
|
} catch (_) {
|
|
140
184
|
const installedVersion = getInstalledVersion(pkg);
|
|
141
185
|
return { installed: checkToolInstalled(pkg), isUpToDate: false, upgradeNeeded: false, output: '', installedVersion, publishedVersion: null };
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1786,7 +1786,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1786
1786
|
const tools = await toolManager.getAllToolsAsync();
|
|
1787
1787
|
const result = tools.map((t) => ({
|
|
1788
1788
|
id: t.id,
|
|
1789
|
-
name: t.
|
|
1789
|
+
name: t.id,
|
|
1790
1790
|
pkg: t.pkg,
|
|
1791
1791
|
installed: t.installed,
|
|
1792
1792
|
status: t.installed ? (t.isUpToDate ? 'installed' : 'needs_update') : 'not_installed',
|