@openagents-org/agent-launcher 0.2.41 → 0.2.43
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/package.json +1 -1
- package/src/daemon.js +8 -1
- package/src/installer.js +25 -4
- package/src/paths.js +4 -0
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -369,8 +369,15 @@ class Daemon {
|
|
|
369
369
|
info.state = 'error';
|
|
370
370
|
info.lastError = (err.message || String(err)).slice(0, 200);
|
|
371
371
|
this._writeStatus();
|
|
372
|
-
this._log(`${name} crashed: ${info.lastError}, restarting in ${info._backoff}s (attempt ${info.restarts})`);
|
|
373
372
|
|
|
373
|
+
if (info.restarts >= 10) {
|
|
374
|
+
this._log(`${name} crashed ${info.restarts} times, giving up. Fix the issue and restart manually.`);
|
|
375
|
+
info.state = 'stopped';
|
|
376
|
+
this._writeStatus();
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
this._log(`${name} crashed: ${info.lastError}, restarting in ${info._backoff}s (attempt ${info.restarts})`);
|
|
374
381
|
await this._sleep(info._backoff * 1000);
|
|
375
382
|
info._backoff = Math.min(info._backoff * 2, 60);
|
|
376
383
|
}
|
package/src/installer.js
CHANGED
|
@@ -500,13 +500,34 @@ class Installer {
|
|
|
500
500
|
});
|
|
501
501
|
});
|
|
502
502
|
|
|
503
|
-
// The zip extracts to node-vX.X.X-win-x64/ subfolder
|
|
503
|
+
// The zip extracts to node-vX.X.X-win-x64/ subfolder — flatten it
|
|
504
504
|
const extractedDir = path.join(nodejsDir, `node-${nodeVersion}-win-${arch}`);
|
|
505
|
+
if (fs.existsSync(extractedDir)) {
|
|
506
|
+
if (onData) onData('Flattening Node.js directory...\n');
|
|
507
|
+
const entries = fs.readdirSync(extractedDir);
|
|
508
|
+
for (const entry of entries) {
|
|
509
|
+
const src = path.join(extractedDir, entry);
|
|
510
|
+
const dest = path.join(nodejsDir, entry);
|
|
511
|
+
if (!fs.existsSync(dest)) {
|
|
512
|
+
fs.renameSync(src, dest);
|
|
513
|
+
} else if (fs.statSync(src).isDirectory() && fs.statSync(dest).isDirectory()) {
|
|
514
|
+
// Merge directories (e.g. node_modules)
|
|
515
|
+
const subEntries = fs.readdirSync(src);
|
|
516
|
+
for (const sub of subEntries) {
|
|
517
|
+
const subSrc = path.join(src, sub);
|
|
518
|
+
const subDest = path.join(dest, sub);
|
|
519
|
+
if (!fs.existsSync(subDest)) fs.renameSync(subSrc, subDest);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
// Remove empty nested dir
|
|
524
|
+
try { fs.rmdirSync(extractedDir, { recursive: true }); } catch {}
|
|
525
|
+
}
|
|
505
526
|
const sep = ';';
|
|
506
527
|
|
|
507
|
-
// Add
|
|
508
|
-
if (!(process.env.PATH || '').includes(
|
|
509
|
-
process.env.PATH =
|
|
528
|
+
// Add nodejs dir to PATH for this session
|
|
529
|
+
if (!(process.env.PATH || '').includes(nodejsDir)) {
|
|
530
|
+
process.env.PATH = nodejsDir + sep + (process.env.PATH || '');
|
|
510
531
|
}
|
|
511
532
|
// npm global installs go to %APPDATA%\npm
|
|
512
533
|
const npmGlobal = path.join(process.env.APPDATA || '', 'npm');
|
package/src/paths.js
CHANGED
|
@@ -42,6 +42,10 @@ function getExtraBinDirs() {
|
|
|
42
42
|
if (nodeDir) _push(dirs, nodeDir);
|
|
43
43
|
} catch {}
|
|
44
44
|
|
|
45
|
+
// Add portable Node.js directory (~/.openagents/nodejs/)
|
|
46
|
+
const portableNode = path.join(HOME, '.openagents', 'nodejs');
|
|
47
|
+
_push(dirs, portableNode);
|
|
48
|
+
|
|
45
49
|
// Filter to existing directories only, deduplicate
|
|
46
50
|
const seen = new Set();
|
|
47
51
|
const currentPATH = process.env.PATH || '';
|