@openagents-org/agent-launcher 0.2.31 → 0.2.33

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.31",
3
+ "version": "0.2.33",
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;
@@ -365,11 +376,17 @@ class OpenClawAdapter extends BaseAdapter {
365
376
  try {
366
377
  const data = JSON.parse(jsonStr);
367
378
  const payloads = data.payloads || [];
379
+ this._log(`CLI parsed: ${payloads.length} payloads, keys=${payloads.map(p=>Object.keys(p).join('/')).join(', ')}, text=${payloads.map(p=>(p.text||'').slice(0,50)).join('|')}`);
368
380
  if (payloads.length > 0) {
369
- resolve(payloads.filter(p => p.text).map(p => p.text).join('\n\n'));
370
- return;
381
+ const texts = payloads.filter(p => p.text).map(p => p.text);
382
+ if (texts.length > 0) {
383
+ resolve(texts.join('\n\n'));
384
+ return;
385
+ }
371
386
  }
372
- } catch {}
387
+ } catch (e) {
388
+ this._log(`CLI JSON parse error: ${e.message}`);
389
+ }
373
390
  }
374
391
 
375
392
  // Fallback: return non-diagnostic text