@openagents-org/agent-connector 0.3.3 → 0.3.5

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/src/installer.js +18 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-connector",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Agent management CLI and library for OpenAgents — install, configure, and run AI coding agents",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/installer.js CHANGED
@@ -459,44 +459,24 @@ class Installer {
459
459
  process.env.PATH = npmGlobal + sep + process.env.PATH;
460
460
  }
461
461
 
462
- } else if (plat === 'macos') {
463
- // Download pkg and install
464
- const url = `https://nodejs.org/dist/${nodeVersion}/node-${nodeVersion}.pkg`;
465
- const pkgPath = path.join(os.tmpdir(), `node-${nodeVersion}.pkg`);
466
-
467
- if (onData) onData(`Downloading ${url}...\n`);
468
- await this._downloadFile(url, pkgPath, onData);
469
-
470
- if (onData) onData(`\nInstalling Node.js...\n`);
471
- await new Promise((resolve, reject) => {
472
- const proc = spawnProc('sudo', ['installer', '-pkg', pkgPath, '-target', '/'], {
473
- stdio: ['ignore', 'pipe', 'pipe'],
474
- });
475
- if (proc.stdout) proc.stdout.on('data', (d) => { if (onData) onData(d.toString()); });
476
- if (proc.stderr) proc.stderr.on('data', (d) => { if (onData) onData(d.toString()); });
477
- proc.on('error', reject);
478
- proc.on('close', (code) => {
479
- if (code === 0) resolve();
480
- else reject(new Error(`Installer exited with code ${code}`));
481
- });
482
- });
483
-
484
- // Add to PATH
485
- if (!(process.env.PATH || '').includes('/usr/local/bin')) {
486
- process.env.PATH = '/usr/local/bin:' + (process.env.PATH || '');
487
- }
488
-
489
462
  } else {
490
- // Linux: use NodeSource setup script
491
- const url = `https://nodejs.org/dist/${nodeVersion}/node-${nodeVersion}-linux-x64.tar.xz`;
492
- const tarPath = path.join(os.tmpdir(), `node-${nodeVersion}.tar.xz`);
463
+ // macOS / Linux: download portable tar.gz/tar.xz, extract to ~/.openagents/nodejs/
464
+ const arch = process.arch === 'arm64' ? 'arm64' : 'x64';
465
+ const ext = plat === 'macos' ? 'tar.gz' : 'tar.xz';
466
+ const platName = plat === 'macos' ? 'darwin' : 'linux';
467
+ const url = `https://nodejs.org/dist/${nodeVersion}/node-${nodeVersion}-${platName}-${arch}.${ext}`;
468
+ const tarPath = path.join(os.tmpdir(), `node-${nodeVersion}.${ext}`);
493
469
 
494
470
  if (onData) onData(`Downloading ${url}...\n`);
495
471
  await this._downloadFile(url, tarPath, onData);
496
472
 
497
- if (onData) onData(`\nExtracting to /usr/local...\n`);
473
+ const nodeDir = path.join(this.config.configDir, 'nodejs');
474
+ fs.mkdirSync(nodeDir, { recursive: true });
475
+
476
+ if (onData) onData(`\nExtracting to ${nodeDir}...\n`);
477
+ const tarFlag = ext === 'tar.gz' ? '-xzf' : '-xJf';
498
478
  await new Promise((resolve, reject) => {
499
- const proc = spawnProc('sudo', ['tar', '-xJf', tarPath, '-C', '/usr/local', '--strip-components=1'], {
479
+ const proc = spawnProc('tar', [tarFlag, tarPath, '-C', nodeDir, '--strip-components=1'], {
500
480
  stdio: ['ignore', 'pipe', 'pipe'],
501
481
  });
502
482
  if (proc.stdout) proc.stdout.on('data', (d) => { if (onData) onData(d.toString()); });
@@ -507,6 +487,12 @@ class Installer {
507
487
  else reject(new Error(`Extraction failed with code ${code}`));
508
488
  });
509
489
  });
490
+
491
+ // Add portable node bin to PATH
492
+ const nodeBin = path.join(nodeDir, 'bin');
493
+ if (!(process.env.PATH || '').includes(nodeBin)) {
494
+ process.env.PATH = nodeBin + ':' + (process.env.PATH || '');
495
+ }
510
496
  }
511
497
 
512
498
  if (onData) onData(`\nNode.js ${nodeVersion} installed successfully.\n\n`);