@agent-webui/ai-desk 1.0.59 → 1.0.60

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.
Files changed (2) hide show
  1. package/bin/aidesk.js +32 -5
  2. package/package.json +3 -3
package/bin/aidesk.js CHANGED
@@ -7,6 +7,7 @@ const { spawnSync } = require('child_process');
7
7
  const PACKAGE_NAME = '@agent-webui/ai-desk';
8
8
  const SKIP_UPDATE_ENV = 'AI_DESK_SKIP_SELF_UPDATE';
9
9
  const UPDATE_COMMANDS = new Set(['start', 'restart']);
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 = runNpm(['view', PACKAGE_NAME, 'version'], {
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 = `${result.stderr || ''}${result.stdout || ''}`.trim();
78
- throw new Error(output || 'Unable to check npm registry');
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 runNpm(['install', installTarget, '--include=optional'], {
163
+ return runNpmWithRegistryFallback(['install', installTarget, '--include=optional'], {
137
164
  cwd: projectRoot,
138
165
  stdio: 'inherit',
139
166
  });
140
167
  }
141
168
 
142
- return runNpm(['install', '-g', installTarget, '--include=optional'], {
169
+ return runNpmWithRegistryFallback(['install', '-g', installTarget, '--include=optional'], {
143
170
  stdio: 'inherit',
144
171
  });
145
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-webui/ai-desk",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
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.59",
18
- "@agent-webui/ai-desk-harness-gimp": "1.0.59"
17
+ "@agent-webui/ai-desk-daemon": "1.0.60",
18
+ "@agent-webui/ai-desk-harness-gimp": "1.0.60"
19
19
  },
20
20
  "license": "MIT"
21
21
  }