@openagents-org/agent-launcher 0.2.18 → 0.2.20

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.18",
3
+ "version": "0.2.20",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -220,9 +220,37 @@ class OpenClawAdapter extends BaseAdapter {
220
220
  let stdout = '';
221
221
  let stderr = '';
222
222
 
223
- // OpenClaw writes --json output to stderr, so capture both
223
+ // Tool name human-readable status
224
+ const toolLabels = {
225
+ exec: 'Running command...',
226
+ read: 'Reading file...',
227
+ write: 'Writing file...',
228
+ edit: 'Editing file...',
229
+ browser: 'Using browser...',
230
+ web_search: 'Searching the web...',
231
+ web_fetch: 'Fetching webpage...',
232
+ process: 'Running process...',
233
+ image_generate: 'Generating image...',
234
+ memory_search: 'Searching memory...',
235
+ };
236
+
237
+ // Stream stderr in real-time to detect tool usage
224
238
  if (proc.stdout) proc.stdout.on('data', (d) => { stdout += d; });
225
- if (proc.stderr) proc.stderr.on('data', (d) => { stderr += d; stdout += d; });
239
+ if (proc.stderr) proc.stderr.on('data', (d) => {
240
+ const chunk = d.toString();
241
+ stderr += chunk;
242
+ stdout += chunk;
243
+
244
+ // Parse diagnostic lines for tool start/end events
245
+ for (const line of chunk.split('\n')) {
246
+ const toolStart = line.match(/embedded run tool start:.*tool=(\w+)/);
247
+ if (toolStart) {
248
+ const toolName = toolStart[1];
249
+ const label = toolLabels[toolName] || `Using ${toolName}...`;
250
+ try { this.sendStatus(channel, label); } catch {}
251
+ }
252
+ }
253
+ });
226
254
 
227
255
  proc.on('error', (err) => reject(err));
228
256
  proc.on('exit', (code) => {
package/src/daemon.js CHANGED
@@ -107,7 +107,16 @@ class Daemon {
107
107
  */
108
108
  async stopAgent(agentName) {
109
109
  this._stoppedAgents.add(agentName);
110
+ // Stop the adapter directly if running
111
+ if (this._adapters && this._adapters[agentName]) {
112
+ this._adapters[agentName].stop();
113
+ }
110
114
  await this._killAgent(agentName, 5000);
115
+ // Wait for adapter loop to actually exit
116
+ for (let i = 0; i < 10; i++) {
117
+ if (!this._adapters || !this._adapters[agentName]) break;
118
+ await new Promise(r => setTimeout(r, 500));
119
+ }
111
120
  this._writeStatus();
112
121
  }
113
122
 
@@ -118,6 +127,9 @@ class Daemon {
118
127
  await this.stopAgent(agentName);
119
128
  this._stoppedAgents.delete(agentName);
120
129
 
130
+ // Reload config in case it changed
131
+ this.config.load();
132
+
121
133
  const agent = this.config.getAgent(agentName);
122
134
  if (agent) {
123
135
  this._launchAgent(agent);
@@ -598,11 +610,12 @@ class Daemon {
598
610
  } catch {}
599
611
  }
600
612
 
601
- _reload() {
613
+ async _reload() {
602
614
  this._log('Reloading config...');
603
615
  const oldNames = this._cachedAgentNames || new Set();
604
616
  const oldConfigs = this._cachedAgentConfigs || {};
605
617
  // Re-read config from disk
618
+ this.config.load();
606
619
  const newAgents = this.config.getAgents();
607
620
  const newNames = new Set(newAgents.map(a => a.name));
608
621
  const newConfigs = {};
@@ -611,7 +624,7 @@ class Daemon {
611
624
  // Stop removed agents
612
625
  for (const name of oldNames) {
613
626
  if (!newNames.has(name)) {
614
- this.stopAgent(name);
627
+ await this.stopAgent(name);
615
628
  this._log(`Reload: stopped removed agent '${name}'`);
616
629
  }
617
630
  }
@@ -623,7 +636,8 @@ class Daemon {
623
636
  this._log(`Reload: started new agent '${agent.name}'`);
624
637
  } else if ((oldConfigs[agent.name] || '') !== (agent.network || '')) {
625
638
  // Network config changed — restart agent
626
- this.stopAgent(agent.name);
639
+ await this.stopAgent(agent.name);
640
+ this._stoppedAgents.delete(agent.name);
627
641
  this._launchAgent(agent);
628
642
  this._log(`Reload: restarted '${agent.name}' (network changed)`);
629
643
  }
@@ -652,7 +666,9 @@ class Daemon {
652
666
  fs.appendFileSync(this.config.logFile, line + '\n', 'utf-8');
653
667
  this._maybeRotateLog();
654
668
  } catch {}
655
- if (!this._shuttingDown) {
669
+ // Only log to console if stdout is a TTY (not redirected to log file)
670
+ // to avoid duplicate lines when daemonized
671
+ if (!this._shuttingDown && process.stdout.isTTY) {
656
672
  console.log(line);
657
673
  }
658
674
  }