@openagents-org/agent-connector 0.3.0 → 0.3.1

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 +25 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-connector",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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
@@ -366,40 +366,48 @@ class Installer {
366
366
  }
367
367
 
368
368
  /**
369
- * Resolve the npm CLI path. Prefers system npm, falls back to Electron's
370
- * bundled node + npm-cli.js so installs work on machines without Node.js.
369
+ * Resolve the npm CLI path. Prefers system npm, falls back to bundled
370
+ * npm module run via Electron's node. Works on machines without Node.js.
371
371
  */
372
372
  _resolveNpmCommand(args) {
373
373
  // 1. Try system npm
374
374
  const { whichBinary } = require('./paths');
375
375
  const systemNpm = whichBinary('npm');
376
- if (systemNpm) return `npm ${args}`;
376
+ if (systemNpm) return `"${systemNpm}" ${args}`;
377
377
 
378
- // 2. Use Electron's bundled node to run npm-cli.js
378
+ // 2. Find bundled npm-cli.js (npm is a dependency of the Launcher)
379
379
  const nodeExe = process.execPath;
380
- // Look for npm-cli.js relative to the node binary
381
- const candidates = [
382
- // Electron on Windows: resources/app/node_modules/npm/bin/npm-cli.js
383
- path.join(path.dirname(nodeExe), 'resources', 'app', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
384
- // npm installed alongside node
385
- path.join(path.dirname(nodeExe), '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
386
- path.join(path.dirname(nodeExe), 'node_modules', 'npm', 'bin', 'npm-cli.js'),
387
- ];
388
- // Also check if npm is available as a module from the current process
380
+ const candidates = [];
381
+
382
+ // Try require.resolve first — works when npm is in node_modules
389
383
  try {
390
- const npmCliPath = require.resolve('npm/bin/npm-cli.js');
391
- if (npmCliPath) candidates.unshift(npmCliPath);
384
+ candidates.push(require.resolve('npm/bin/npm-cli.js'));
392
385
  } catch {}
393
386
 
387
+ // Search common locations relative to the app
388
+ const searchRoots = [
389
+ path.join(path.dirname(nodeExe), 'resources', 'app'), // packaged Electron
390
+ path.join(path.dirname(nodeExe), 'resources', 'app.asar.unpacked'), // asar unpacked
391
+ path.join(path.dirname(nodeExe), '..'), // portable exe temp dir
392
+ process.cwd(), // dev mode
393
+ ];
394
+ for (const root of searchRoots) {
395
+ candidates.push(path.join(root, 'node_modules', 'npm', 'bin', 'npm-cli.js'));
396
+ }
397
+
398
+ // Also check system node_modules
399
+ candidates.push(path.join(path.dirname(nodeExe), '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'));
400
+ candidates.push(path.join(path.dirname(nodeExe), 'node_modules', 'npm', 'bin', 'npm-cli.js'));
401
+
394
402
  for (const p of candidates) {
395
403
  try {
396
- if (fs.existsSync(p)) {
404
+ if (p && fs.existsSync(p)) {
397
405
  return `"${nodeExe}" "${p}" ${args}`;
398
406
  }
399
407
  } catch {}
400
408
  }
401
409
 
402
- // 3. Last resort: just try npm and hope for the best
410
+ // 3. Last resort
403
411
  return `npm ${args}`;
404
412
  }
405
413