@agent-webui/ai-desk 1.0.59 → 1.0.61
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/bin/aidesk.js +45 -8
- package/package.json +3 -3
package/bin/aidesk.js
CHANGED
|
@@ -6,7 +6,8 @@ const { spawnSync } = require('child_process');
|
|
|
6
6
|
|
|
7
7
|
const PACKAGE_NAME = '@agent-webui/ai-desk';
|
|
8
8
|
const SKIP_UPDATE_ENV = 'AI_DESK_SKIP_SELF_UPDATE';
|
|
9
|
-
const UPDATE_COMMANDS = new Set(['start', 'restart']);
|
|
9
|
+
const UPDATE_COMMANDS = new Set(['start', 'restart', 'upgrade']);
|
|
10
|
+
const OFFICIAL_NPM_REGISTRY = 'https://registry.npmjs.org/';
|
|
10
11
|
|
|
11
12
|
function readJSON(filePath) {
|
|
12
13
|
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
@@ -68,14 +69,40 @@ function runNpm(args, options = {}) {
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
function npmOutput(result) {
|
|
73
|
+
return `${result.stderr || ''}${result.stdout || ''}`.trim();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function withOfficialRegistry(args) {
|
|
77
|
+
return [...args, `--registry=${OFFICIAL_NPM_REGISTRY}`];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function runNpmWithRegistryFallback(args, options = {}) {
|
|
81
|
+
const primaryResult = runNpm(withOfficialRegistry(args), options);
|
|
82
|
+
if (primaryResult.status === 0) {
|
|
83
|
+
return primaryResult;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const fallbackResult = runNpm(args, options);
|
|
87
|
+
if (fallbackResult.status === 0) {
|
|
88
|
+
return fallbackResult;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fallbackResult.primaryError = npmOutput(primaryResult);
|
|
92
|
+
return fallbackResult;
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
function latestPublishedVersion() {
|
|
72
|
-
const result =
|
|
96
|
+
const result = runNpmWithRegistryFallback(['view', PACKAGE_NAME, 'version'], {
|
|
73
97
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
74
98
|
});
|
|
75
99
|
|
|
76
100
|
if (result.status !== 0) {
|
|
77
|
-
const output =
|
|
78
|
-
|
|
101
|
+
const output = npmOutput(result);
|
|
102
|
+
const primaryError = result.primaryError ? `Official registry error: ${result.primaryError}\n` : '';
|
|
103
|
+
const fallbackError = output ? `Fallback registry error: ${output}` : '';
|
|
104
|
+
const errorMessage = `${primaryError}${fallbackError}`.trim();
|
|
105
|
+
throw new Error(errorMessage || 'Unable to check npm registry');
|
|
79
106
|
}
|
|
80
107
|
|
|
81
108
|
return String(result.stdout || '').trim();
|
|
@@ -133,13 +160,13 @@ function installLatestVersion(latestVersion) {
|
|
|
133
160
|
const installTarget = `${PACKAGE_NAME}@${latestVersion}`;
|
|
134
161
|
|
|
135
162
|
if (projectRoot) {
|
|
136
|
-
return
|
|
163
|
+
return runNpmWithRegistryFallback(['install', installTarget, '--include=optional'], {
|
|
137
164
|
cwd: projectRoot,
|
|
138
165
|
stdio: 'inherit',
|
|
139
166
|
});
|
|
140
167
|
}
|
|
141
168
|
|
|
142
|
-
return
|
|
169
|
+
return runNpmWithRegistryFallback(['install', '-g', installTarget, '--include=optional'], {
|
|
143
170
|
stdio: 'inherit',
|
|
144
171
|
});
|
|
145
172
|
}
|
|
@@ -207,11 +234,18 @@ function updateBeforeCommand(args) {
|
|
|
207
234
|
}
|
|
208
235
|
|
|
209
236
|
const installedVersion = currentVersion();
|
|
210
|
-
|
|
237
|
+
const forceUpgrade = command === 'upgrade' && args.includes('--force');
|
|
238
|
+
const alreadyLatest = compareVersions(latestVersion, installedVersion) <= 0;
|
|
239
|
+
if (alreadyLatest && !forceUpgrade) {
|
|
240
|
+
if (command === 'upgrade') {
|
|
241
|
+
console.log(`AI Desk is already up to date (${installedVersion}).`);
|
|
242
|
+
process.exit(0);
|
|
243
|
+
}
|
|
211
244
|
return;
|
|
212
245
|
}
|
|
213
246
|
|
|
214
|
-
|
|
247
|
+
const verb = alreadyLatest ? 'Reinstalling' : 'Updating';
|
|
248
|
+
console.log(`${verb} AI Desk from ${installedVersion} to ${latestVersion}...`);
|
|
215
249
|
const result = installLatestVersion(latestVersion);
|
|
216
250
|
if (result.error) {
|
|
217
251
|
throw result.error;
|
|
@@ -222,6 +256,9 @@ function updateBeforeCommand(args) {
|
|
|
222
256
|
|
|
223
257
|
const updatedVersion = currentVersion();
|
|
224
258
|
console.log(`AI Desk updated to ${updatedVersion}.`);
|
|
259
|
+
if (command === 'upgrade') {
|
|
260
|
+
process.exit(0);
|
|
261
|
+
}
|
|
225
262
|
console.log(`Restarting aidesk ${command} with the updated CLI...`);
|
|
226
263
|
restartWithUpdatedCli(args);
|
|
227
264
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-webui/ai-desk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.61",
|
|
4
4
|
"description": "Single-install AI Desk package with daemon and default harnesses",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aidesk": "bin/aidesk.js"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@agent-webui/ai-desk-daemon": "1.0.
|
|
18
|
-
"@agent-webui/ai-desk-harness-gimp": "1.0.
|
|
17
|
+
"@agent-webui/ai-desk-daemon": "1.0.61",
|
|
18
|
+
"@agent-webui/ai-desk-harness-gimp": "1.0.61"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT"
|
|
21
21
|
}
|