@openagents-org/agent-launcher 0.2.197 → 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.197",
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
 
@@ -680,6 +680,13 @@ class OpenClawAdapter extends BaseAdapter {
680
680
  config.models.providers.custom = {
681
681
  baseUrl: baseUrl.replace(/\/+$/, ''),
682
682
  apiKey,
683
+ // Without it OpenClaw tries its stored auth profiles BEFORE this
684
+ // apiKey (model-auth-provider-config: shouldPreferExplicitConfig-
685
+ // ApiKeyAuth). A `custom` token profile an older launcher wrote, and
686
+ // `openclaw doctor --fix` copied into SQLite, then outranks every key
687
+ // saved since: the test passes on the new key, the run sends the old
688
+ // one, and the relay answers "Invalid token".
689
+ auth: 'api-key',
683
690
  api: 'openai-completions',
684
691
  models: [{ id: model, name: model }],
685
692
  };
package/src/index.js CHANGED
@@ -100,10 +100,34 @@ class AgentConnector {
100
100
  }
101
101
 
102
102
  addAgent({ name, type, role, path, env }) {
103
- this.config.addAgent({ name, type: type || 'openclaw', role: role || 'worker', path, env });
103
+ const agentType = type || 'openclaw';
104
+ this.config.addAgent({ name, type: agentType, role: role || 'worker', path, env });
105
+ // A key entered while ADDING the agent needs the same native side effects
106
+ // as one saved later: OpenClaw and Hermes read a custom endpoint only from
107
+ // their own config. Without this a new agent's test passed on the form's
108
+ // key while the run used a stale one ("401 Invalid token") or none at all
109
+ // (Hermes falling back to OpenRouter: "401 Missing Authentication header").
110
+ if (env && Object.keys(env).length) {
111
+ this._configureNativeAuth(agentType, { ...this.env.load(agentType), ...env });
112
+ }
104
113
  return { success: true };
105
114
  }
106
115
 
116
+ /** Push an agent's endpoint and key into the CLI's own config, for the types that need it. */
117
+ _configureNativeAuth(agentType, env) {
118
+ try {
119
+ if (agentType === 'openclaw') {
120
+ require('./adapters/openclaw').configureNativeAuth(env);
121
+ }
122
+ // Hermes reads a custom endpoint only from its own config.yaml, so the
123
+ // saved LLM_* values must be pushed through `hermes config set` — the
124
+ // env file alone leaves it "No inference provider configured".
125
+ if (agentType === 'hermes') {
126
+ require('./adapters/hermes').configureNativeAuth(env);
127
+ }
128
+ } catch {}
129
+ }
130
+
107
131
  /**
108
132
  * The workspace an agent is bound to, as a ready-to-use client — or null
109
133
  * when it is local-only or its network is no longer configured.
@@ -212,22 +236,7 @@ class AgentConnector {
212
236
 
213
237
  saveAgentEnv(agentType, env) {
214
238
  this.env.save(agentType, env);
215
- // Configure native auth for agents that need it (e.g. OpenClaw auth-profiles.json)
216
- try {
217
- if (agentType === 'openclaw') {
218
- const OpenClawAdapter = require('./adapters/openclaw');
219
- const saved = this.env.load(agentType);
220
- OpenClawAdapter.configureNativeAuth(saved);
221
- }
222
- // Hermes reads a custom endpoint only from its own config.yaml, so the
223
- // saved LLM_* values must be pushed through `hermes config set` — the
224
- // env file alone leaves it "No inference provider configured".
225
- if (agentType === 'hermes') {
226
- const HermesAdapter = require('./adapters/hermes');
227
- const saved = this.env.load(agentType);
228
- HermesAdapter.configureNativeAuth(saved);
229
- }
230
- } catch {}
239
+ this._configureNativeAuth(agentType, this.env.load(agentType));
231
240
  return { success: true };
232
241
  }
233
242
 
@@ -249,18 +258,8 @@ class AgentConnector {
249
258
 
250
259
  // Preserve native auth side effects for agents that need them while
251
260
  // keeping the model choice scoped to this individual agent.
252
- try {
253
- if ((agent.type || 'openclaw') === 'openclaw') {
254
- const OpenClawAdapter = require('./adapters/openclaw');
255
- const typeEnv = this.env.load(agent.type || 'openclaw');
256
- OpenClawAdapter.configureNativeAuth({ ...typeEnv, ...saved });
257
- }
258
- if (agent.type === 'hermes') {
259
- const HermesAdapter = require('./adapters/hermes');
260
- const typeEnv = this.env.load('hermes');
261
- HermesAdapter.configureNativeAuth({ ...typeEnv, ...saved });
262
- }
263
- } catch {}
261
+ const agentType = agent.type || 'openclaw';
262
+ this._configureNativeAuth(agentType, { ...this.env.load(agentType), ...saved });
264
263
 
265
264
  return { success: true };
266
265
  }
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;