@openagents-org/agent-launcher 0.2.32 → 0.2.34

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.32",
3
+ "version": "0.2.34",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -232,7 +232,11 @@ class BaseAdapter {
232
232
  // ------------------------------------------------------------------
233
233
 
234
234
  async _dispatchMessage(msg) {
235
- const channel = msg.sessionId || this.channelName;
235
+ // Use sessionId only if it looks like a channel, not an agent target
236
+ let channel = this.channelName || 'general';
237
+ if (msg.sessionId && !msg.sessionId.startsWith('openagents:') && !msg.sessionId.startsWith('agent:')) {
238
+ channel = msg.sessionId;
239
+ }
236
240
 
237
241
  if (this._channelBusy.has(channel)) {
238
242
  if (!this._channelQueues[channel]) this._channelQueues[channel] = [];
@@ -144,7 +144,12 @@ class OpenClawAdapter extends BaseAdapter {
144
144
 
145
145
  if (!content) return;
146
146
 
147
- const msgChannel = msg.sessionId || this.channelName;
147
+ // msg.sessionId may be a channel name (from workspace UI) or an agent target
148
+ // (from API). Only use it if it looks like a channel, otherwise use channelName.
149
+ let msgChannel = this.channelName || 'general';
150
+ if (msg.sessionId && !msg.sessionId.startsWith('openagents:') && !msg.sessionId.startsWith('agent:')) {
151
+ msgChannel = msg.sessionId;
152
+ }
148
153
  const sender = msg.senderName || msg.senderType || 'user';
149
154
  this._log(`Processing message from ${sender} in ${msgChannel}: ${content.slice(0, 80)}...`);
150
155
 
@@ -177,7 +182,8 @@ class OpenClawAdapter extends BaseAdapter {
177
182
  return;
178
183
  }
179
184
 
180
- const sessionKey = `openagents-${this.workspaceId.slice(0, 8)}-${channel.slice(-8)}`;
185
+ const channelSuffix = (channel || 'general').replace(/[^a-zA-Z0-9-]/g, '').slice(-8) || 'general';
186
+ const sessionKey = `openagents-${this.workspaceId.slice(0, 8)}-${channelSuffix}`;
181
187
 
182
188
  const args = [
183
189
  '--log-level', 'trace',
@@ -324,8 +330,13 @@ class OpenClawAdapter extends BaseAdapter {
324
330
  // Find the JSON by looking for '{"payloads"' or the last complete JSON object.
325
331
  let jsonStr = null;
326
332
 
327
- // Strategy 1: find {"payloads" directly
328
- const payloadsIdx = text.indexOf('{"payloads"');
333
+ // Strategy 1: find {"payloads" or { "payloads" (with whitespace)
334
+ let payloadsIdx = text.indexOf('{"payloads"');
335
+ if (payloadsIdx < 0) {
336
+ // Try with whitespace after {
337
+ const match = text.match(/\{\s*"payloads"/);
338
+ if (match) payloadsIdx = match.index;
339
+ }
329
340
  if (payloadsIdx >= 0) {
330
341
  // Find the matching closing brace by counting braces
331
342
  let depth = 0;
package/src/daemon.js CHANGED
@@ -124,6 +124,12 @@ class Daemon {
124
124
  * Restart a single agent by name.
125
125
  */
126
126
  async restartAgent(agentName) {
127
+ // Set state to 'starting' immediately so UI never sees 'stopped' during restart
128
+ if (this._processes[agentName]) {
129
+ this._processes[agentName].state = 'starting';
130
+ this._writeStatus();
131
+ }
132
+
127
133
  await this.stopAgent(agentName);
128
134
  this._stoppedAgents.delete(agentName);
129
135
 
package/src/installer.js CHANGED
@@ -91,7 +91,34 @@ class Installer {
91
91
  version = match ? match[1] : raw.split('\n')[0];
92
92
  } catch {}
93
93
 
94
- return { installed: true, binary, version };
94
+ // Check login/ready status if check_ready is defined
95
+ let ready = true;
96
+ const checkReady = entry?.check_ready;
97
+ if (checkReady) {
98
+ ready = false;
99
+ // Check env vars
100
+ if (checkReady.env_vars) {
101
+ for (const v of checkReady.env_vars) {
102
+ if (process.env[v]) { ready = true; break; }
103
+ }
104
+ }
105
+ // Check credentials file
106
+ if (!ready && checkReady.creds_file) {
107
+ try {
108
+ const credsPath = checkReady.creds_file.replace('~', os.homedir());
109
+ if (fs.existsSync(credsPath)) {
110
+ const creds = JSON.parse(fs.readFileSync(credsPath, 'utf-8'));
111
+ if (checkReady.creds_key) {
112
+ ready = !!creds[checkReady.creds_key];
113
+ } else {
114
+ ready = true;
115
+ }
116
+ }
117
+ } catch {}
118
+ }
119
+ }
120
+
121
+ return { installed: true, binary, version, ready };
95
122
  }
96
123
 
97
124
  /**