4runr-os 2.1.33 → 2.1.34

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/package.json +1 -1
  2. package/scripts/setup.js +94 -102
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "4runr-os",
3
- "version": "2.1.33",
3
+ "version": "2.1.34",
4
4
  "type": "module",
5
5
  "description": "4Runr AI Agent OS - Interactive terminal for managing AI agents",
6
6
  "main": "dist/index.js",
package/scripts/setup.js CHANGED
@@ -17,6 +17,8 @@ const __dirname = dirname(__filename);
17
17
  const platform = process.platform;
18
18
  const isWindows = platform === 'win32';
19
19
 
20
+ // Main setup function (async for delays)
21
+ async function runSetup() {
20
22
  console.log('šŸ” Checking 4runr-os setup...\n');
21
23
 
22
24
  // Check Node.js
@@ -97,59 +99,65 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
97
99
  let mingwInstalled = false;
98
100
  let mingwPath = '';
99
101
 
100
- try {
101
- const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
102
- mingwInstalled = true;
103
- mingwPath = path.dirname(dlltoolPath);
104
- console.log('āœ… MinGW found at:', mingwPath);
105
- } catch {
106
- console.log('āš ļø MinGW not found in PATH - required for GNU toolchain');
107
- console.log(' Checking common installation locations...');
108
-
109
- // Check common MinGW locations
110
- const commonPaths = [
111
- 'C:\\mingw64\\bin',
112
- 'C:\\msys64\\mingw64\\bin',
113
- 'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
114
- ];
115
-
116
- // Check if MSYS2 exists and might have MinGW
117
- const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
118
- const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
119
-
120
- // First check if MSYS2 exists - if so, check/install MinGW automatically
121
- if (fs.existsSync(msys2Bash)) {
122
- console.log(' āœ… MSYS2 found - checking for MinGW...');
123
- if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
124
- mingwInstalled = true;
125
- mingwPath = msys2MingwPath;
126
- console.log(' āœ… MinGW found in MSYS2');
127
- } else {
128
- // MSYS2 exists but MinGW not installed - install it automatically
129
- console.log(' šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
130
- try {
131
- execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
132
- stdio: 'inherit',
133
- timeout: 300000 // 5 minutes
134
- });
135
-
136
- if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
137
- mingwInstalled = true;
138
- mingwPath = msys2MingwPath;
139
- console.log(' āœ… MinGW toolchain installed successfully');
140
- } else {
141
- console.warn(' āš ļø Installation completed but MinGW not found');
142
- console.warn(' Please restart terminal and run 4runr-setup again');
143
- }
144
- } catch (installError) {
145
- console.warn(' āš ļø Failed to install MinGW automatically');
146
- console.warn(' Please run manually in MSYS2 terminal: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
102
+ // PRIORITY 1: Check if MSYS2 exists FIRST (most reliable)
103
+ const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
104
+ const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
105
+
106
+ if (fs.existsSync(msys2Bash)) {
107
+ console.log(' āœ… MSYS2 found - checking for MinGW...');
108
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
109
+ mingwInstalled = true;
110
+ mingwPath = msys2MingwPath;
111
+ console.log(' āœ… MinGW found in MSYS2');
112
+ } else {
113
+ // MSYS2 exists but MinGW not installed - install it automatically
114
+ console.log(' šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
115
+ try {
116
+ execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
117
+ stdio: 'inherit',
118
+ timeout: 300000 // 5 minutes
119
+ });
120
+
121
+ if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
122
+ mingwInstalled = true;
123
+ mingwPath = msys2MingwPath;
124
+ console.log(' āœ… MinGW toolchain installed successfully');
125
+ } else {
126
+ console.warn(' āš ļø Installation completed but MinGW not found');
127
+ console.warn(' Please restart terminal and run 4runr-setup again');
128
+ process.exit(0);
147
129
  }
130
+ } catch (installError) {
131
+ console.error(' āŒ Failed to install MinGW automatically');
132
+ console.error(' Quick fix - run this command:');
133
+ console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
134
+ console.error(' Then restart terminal and run: 4runr-setup\n');
135
+ process.exit(1);
148
136
  }
149
137
  }
150
138
 
151
- // Check other common paths if MSYS2 didn't work
152
- if (!mingwInstalled) {
139
+ // Add to PATH for current session
140
+ if (mingwInstalled && mingwPath) {
141
+ console.log(` āœ… Adding ${mingwPath} to PATH for this session...`);
142
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
143
+ }
144
+ }
145
+
146
+ // PRIORITY 2: Check PATH if MSYS2 didn't work
147
+ if (!mingwInstalled) {
148
+ try {
149
+ const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
150
+ mingwInstalled = true;
151
+ mingwPath = path.dirname(dlltoolPath);
152
+ console.log(' āœ… MinGW found in PATH at:', mingwPath);
153
+ } catch {
154
+ // Check other common paths
155
+ console.log(' Checking common installation locations...');
156
+ const commonPaths = [
157
+ 'C:\\mingw64\\bin',
158
+ 'C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin',
159
+ ];
160
+
153
161
  for (const testPath of commonPaths) {
154
162
  if (fs.existsSync(testPath)) {
155
163
  const dlltoolPath = path.join(testPath, 'dlltool.exe');
@@ -157,29 +165,27 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
157
165
  mingwInstalled = true;
158
166
  mingwPath = testPath;
159
167
  console.log(' āœ… MinGW found at:', mingwPath);
168
+ process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
160
169
  break;
161
170
  }
162
171
  }
163
172
  }
164
173
  }
174
+ }
165
175
 
166
- if (mingwInstalled && mingwPath) {
167
- console.log(' Adding to PATH for this session...');
168
- process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
169
- }
176
+ // PRIORITY 3: Only if still not found, try winget installation
177
+ if (!mingwInstalled) {
178
+ console.log(' Installing MinGW-w64 via winget...');
170
179
 
171
- if (!mingwInstalled) {
172
- console.log(' Installing MinGW-w64...');
173
-
174
- // Try multiple installation methods
175
- let installed = false;
176
-
177
- // Try winget - MSYS2 is more reliable and includes MinGW
178
- const wingetPackages = [
179
- 'msys2.msys2', // MSYS2 (includes MinGW, most reliable)
180
- 'mingw-w64.mingw-w64', // Direct MinGW package
181
- 'mingw-w64', // Alternative MinGW package name
182
- ];
180
+ // Try multiple installation methods
181
+ let installed = false;
182
+
183
+ // Try winget - MSYS2 is more reliable and includes MinGW
184
+ const wingetPackages = [
185
+ 'msys2.msys2', // MSYS2 (includes MinGW, most reliable)
186
+ 'mingw-w64.mingw-w64', // Direct MinGW package
187
+ 'mingw-w64', // Alternative MinGW package name
188
+ ];
183
189
 
184
190
  for (const pkg of wingetPackages) {
185
191
  try {
@@ -191,19 +197,21 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
191
197
  installed = true;
192
198
  console.log(` āœ… Installed via winget: ${pkg}`);
193
199
 
194
- // If MSYS2 was installed, automatically install MinGW toolchain
200
+ // If MSYS2 was just installed via winget, install MinGW inside it
195
201
  if (pkg === 'msys2.msys2') {
196
- const msys2MingwPath = 'C:\\msys64\\mingw64\\bin';
197
- const msys2Bash = 'C:\\msys64\\usr\\bin\\bash.exe';
202
+ // Wait a moment for MSYS2 installation to complete
203
+ console.log(' Waiting for MSYS2 installation to complete...');
204
+ const { setTimeout } = await import('timers/promises');
205
+ await setTimeout(5000);
198
206
 
199
207
  // Check if MinGW is already installed
200
208
  if (fs.existsSync(path.join(msys2MingwPath, 'dlltool.exe'))) {
201
- console.log(`\n āœ… MinGW already installed in MSYS2`);
209
+ console.log(` āœ… MinGW already installed in MSYS2`);
202
210
  mingwInstalled = true;
203
211
  mingwPath = msys2MingwPath;
204
212
  } else {
205
213
  // Automatically install MinGW toolchain via MSYS2
206
- console.log('\n šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take a few minutes)...');
214
+ console.log(' šŸ”Ø Installing MinGW toolchain in MSYS2 (this may take 2-3 minutes)...');
207
215
  try {
208
216
  execSync(`"${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`, {
209
217
  stdio: 'inherit',
@@ -221,10 +229,9 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
221
229
  }
222
230
  } catch (installError) {
223
231
  console.error(' āŒ Failed to install MinGW automatically');
224
- console.error(' Please install manually:');
225
- console.error(' 1. Open MSYS2 terminal');
226
- console.error(' 2. Run: pacman -S mingw-w64-x86_64-toolchain --noconfirm');
227
- console.error(' 3. Restart terminal and run: 4runr-setup\n');
232
+ console.error(' Quick fix - run this command:');
233
+ console.error(` "${msys2Bash}" -lc "pacman -S mingw-w64-x86_64-toolchain --noconfirm"`);
234
+ console.error(' Then restart terminal and run: 4runr-setup\n');
228
235
  process.exit(1);
229
236
  }
230
237
  }
@@ -233,34 +240,18 @@ if (isWindows && rustInstalled && rustNeedsGNU) {
233
240
  if (mingwInstalled && mingwPath) {
234
241
  console.log(` āœ… Adding ${mingwPath} to PATH for this session...`);
235
242
  process.env.PATH = process.env.PATH ? `${mingwPath};${process.env.PATH}` : mingwPath;
236
-
237
- // Try to add to permanent PATH (may require admin)
238
- try {
239
- const currentPath = execSync('powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"', { encoding: 'utf-8' }).trim();
240
- if (!currentPath.includes(mingwPath)) {
241
- // Use synchronous readline for simpler flow
242
- process.stdout.write('\n Add MinGW to PATH permanently? (recommended) [Y/n]: ');
243
- const rl = readline.createInterface({
244
- input: process.stdin,
245
- output: process.stdout
246
- });
247
-
248
- rl.on('line', (answer) => {
249
- rl.close();
250
- if (!answer || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
251
- try {
252
- execSync(`powershell -Command "[Environment]::SetEnvironmentVariable('Path', [Environment]::GetEnvironmentVariable('Path', 'User') + ';${mingwPath}', 'User')"`, { stdio: 'pipe' });
253
- console.log(' āœ… Added to PATH permanently');
254
- } catch {
255
- console.log(' āš ļø Could not add to PATH permanently. Please add manually:');
256
- console.log(` ${mingwPath}`);
257
- }
258
- }
259
- });
260
- }
261
- } catch {
262
- // Ignore - PATH update failed, user can add manually
263
- }
243
+ }
244
+ } else {
245
+ // Direct MinGW package - wait and check PATH
246
+ const { setTimeout } = await import('timers/promises');
247
+ await setTimeout(2000);
248
+ try {
249
+ const dlltoolPath = execSync('where dlltool.exe', { encoding: 'utf-8', stdio: 'pipe' }).trim();
250
+ mingwInstalled = true;
251
+ mingwPath = path.dirname(dlltoolPath);
252
+ } catch {
253
+ // Not in PATH yet - user will need to restart terminal
254
+ console.warn(' āš ļø Installed but not in PATH - please restart terminal');
264
255
  }
265
256
  }
266
257
  break;
@@ -382,4 +373,5 @@ if (mk3Dir && fs.existsSync(mk3Dir)) {
382
373
  }
383
374
 
384
375
  console.log('\nāœ… Setup complete! You can now run: 4r\n');
376
+ })();
385
377