@openagents-org/agent-launcher 0.2.198 → 0.2.199

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-launcher",
3
- "version": "0.2.198",
3
+ "version": "0.2.199",
4
4
  "description": "OpenAgents Launcher \u2014 install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -25,6 +25,8 @@ const { defaultAgentWorkdir, whichBinary, whereBinary } = require('../paths');
25
25
  const { resolveCursorNodeEntry } = require('./cursor-node-entry');
26
26
 
27
27
  const IS_WINDOWS = process.platform === 'win32';
28
+ // How long cursor-agent gets to exit by itself after emitting its `result`.
29
+ const RESULT_EXIT_GRACE_MS = 3000;
28
30
 
29
31
  class CursorAdapter extends BaseAdapter {
30
32
  constructor(opts) {
@@ -503,6 +505,7 @@ class CursorAdapter extends BaseAdapter {
503
505
  let consecutiveTimeouts = 0;
504
506
  let lastDataTime = Date.now();
505
507
  let timeoutTimer = null;
508
+ let resultTimer = null;
506
509
 
507
510
  const resetTimeout = () => {
508
511
  consecutiveTimeouts = 0;
@@ -573,6 +576,17 @@ class CursorAdapter extends BaseAdapter {
573
576
  if (event.is_error) {
574
577
  this._log(`Cursor error: ${String(event.result || '').slice(0, 200)}`);
575
578
  }
579
+ // `result` ends the turn, but cursor-agent -p does not always exit
580
+ // after it. The reply is sent from the exit handler, so a CLI left
581
+ // hanging held it back until the 300s idle kill — the minutes-long
582
+ // first message. Give it a moment to exit on its own, then end it.
583
+ if (!resultTimer) {
584
+ resultTimer = setTimeout(() => {
585
+ if (proc.exitCode !== null || proc.signalCode !== null) return;
586
+ this._log(`CLI still running ${RESULT_EXIT_GRACE_MS}ms after its result, stopping it`);
587
+ void this._stopProcess(proc);
588
+ }, RESULT_EXIT_GRACE_MS);
589
+ }
576
590
  } else if (eventType === 'system') {
577
591
  const sessionId = event.session_id;
578
592
  if (sessionId && !this._channelSessions[msgChannel]) {
@@ -584,6 +598,7 @@ class CursorAdapter extends BaseAdapter {
584
598
 
585
599
  proc.on('exit', async (code) => {
586
600
  if (timeoutTimer) clearInterval(timeoutTimer);
601
+ if (resultTimer) clearTimeout(resultTimer);
587
602
 
588
603
  try { await _pendingLines; } catch {}
589
604
 
@@ -658,6 +673,7 @@ class CursorAdapter extends BaseAdapter {
658
673
 
659
674
  proc.on('error', (err) => {
660
675
  if (timeoutTimer) clearInterval(timeoutTimer);
676
+ if (resultTimer) clearTimeout(resultTimer);
661
677
  reject(err);
662
678
  });
663
679
 
package/src/installer.js CHANGED
@@ -90,6 +90,14 @@ const INSTALL_STALL_MS = (() => {
90
90
  */
91
91
  const STALL_POLL_MS = Math.max(50, Math.min(15000, Math.floor(INSTALL_STALL_MS / 2) || 15000));
92
92
 
93
+ /**
94
+ * Flags a runtime `npm install` takes for speed: --no-audit and --no-fund skip
95
+ * two registry round trips that only print advice. Not --prefer-offline: a
96
+ * cached packument can predate the release asked for, and npm then fails with
97
+ * ETARGET instead of fetching it.
98
+ */
99
+ const NPM_INSTALL_SPEED_FLAGS = ['--no-audit', '--no-fund'];
100
+
93
101
  // Version detection is comparatively expensive (spawns `<bin> --version`), so
94
102
  // results are cached briefly and invalidated on install/uninstall.
95
103
  const VERSION_CACHE_TTL_MS = 60000;
@@ -1457,8 +1465,10 @@ class Installer {
1457
1465
  // on next install). --registry is added only when we'd be helping — see
1458
1466
  // installRegistry(); a user's own registry choice is never overridden.
1459
1467
  const registry = installRegistry();
1468
+ // The verbose log stays: it is the install's progress, and the output the
1469
+ // stall watchdog below waits on.
1460
1470
  const npmArgs = [
1461
- 'install', '--loglevel=verbose', '--save', '--prefix', prefixDir,
1471
+ 'install', '--loglevel=verbose', ...NPM_INSTALL_SPEED_FLAGS, '--save', '--prefix', prefixDir,
1462
1472
  ...(registry ? ['--registry', registry] : []),
1463
1473
  ...pkgArgs,
1464
1474
  ];
@@ -1479,7 +1489,7 @@ class Installer {
1479
1489
  } else {
1480
1490
  // Legacy fallback: quoted prefix inside a shell string.
1481
1491
  const registryArg = registry ? `--registry ${registry} ` : '';
1482
- const args = `install --loglevel=verbose --save --prefix "${prefixDir}" ${registryArg}${pkgArgs.join(' ')}`;
1492
+ const args = `install --loglevel=verbose ${NPM_INSTALL_SPEED_FLAGS.join(' ')} --save --prefix "${prefixDir}" ${registryArg}${pkgArgs.join(' ')}`;
1483
1493
  spawnFile = this._wrapForWindowsShell(this._resolveNpmCommand(args));
1484
1494
  useShell = isWin ? (env.ComSpec || 'C:\\Windows\\System32\\cmd.exe') : true;
1485
1495
  displayCmd = spawnFile;