@openagents-org/agent-launcher 0.2.8 → 0.2.9

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.8",
3
+ "version": "0.2.9",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -255,6 +255,68 @@ class OpenClawAdapter extends BaseAdapter {
255
255
  });
256
256
  });
257
257
  }
258
+ // ------------------------------------------------------------------
259
+ // Static: configure OpenClaw's native auth from LLM env vars
260
+ // ------------------------------------------------------------------
261
+
262
+ /**
263
+ * Write OpenClaw's auth-profiles.json and openclaw.json from the
264
+ * user-provided LLM_API_KEY / LLM_BASE_URL / LLM_MODEL values.
265
+ * Called by the Launcher's saveAgentEnv when type === 'openclaw'.
266
+ */
267
+ static configureNativeAuth(env) {
268
+ const apiKey = env.LLM_API_KEY;
269
+ const baseUrl = env.LLM_BASE_URL || 'https://api.openai.com/v1';
270
+ const model = env.LLM_MODEL || 'gpt-4o';
271
+ if (!apiKey) return;
272
+
273
+ // Determine provider: if baseUrl is openai.com, use 'openai'; otherwise 'openai-compatible'
274
+ const isOpenAI = baseUrl.includes('api.openai.com');
275
+ const isAnthropic = baseUrl.includes('api.anthropic.com');
276
+ let provider = 'openai';
277
+ if (isAnthropic) provider = 'anthropic';
278
+ else if (!isOpenAI) provider = 'openai'; // custom endpoints use openai provider with baseUrl override
279
+
280
+ const profileId = `${provider}:manual`;
281
+ const agentDir = path.join(OPENCLAW_STATE_DIR, 'agents', 'main', 'agent');
282
+
283
+ // Write auth-profiles.json
284
+ try {
285
+ fs.mkdirSync(agentDir, { recursive: true });
286
+ const authFile = path.join(agentDir, 'auth-profiles.json');
287
+ let authData = { version: 1, profiles: {} };
288
+ try { authData = JSON.parse(fs.readFileSync(authFile, 'utf-8')); } catch {}
289
+ authData.profiles = authData.profiles || {};
290
+ const profile = { type: 'token', provider, token: apiKey };
291
+ if (!isOpenAI && !isAnthropic) profile.baseUrl = baseUrl;
292
+ authData.profiles[profileId] = profile;
293
+ authData.lastGood = authData.lastGood || {};
294
+ authData.lastGood[provider] = profileId;
295
+ fs.writeFileSync(authFile, JSON.stringify(authData, null, 2), 'utf-8');
296
+ } catch {}
297
+
298
+ // Write model config in openclaw.json
299
+ try {
300
+ const configFile = path.join(OPENCLAW_STATE_DIR, 'openclaw.json');
301
+ let config = {};
302
+ try { config = JSON.parse(fs.readFileSync(configFile, 'utf-8')); } catch {}
303
+ config.agents = config.agents || {};
304
+ config.agents.defaults = config.agents.defaults || {};
305
+ config.agents.defaults.model = config.agents.defaults.model || {};
306
+
307
+ const modelId = isAnthropic ? `anthropic/${model}` : `openai/${model}`;
308
+ config.agents.defaults.model.primary = modelId;
309
+ config.agents.defaults.models = config.agents.defaults.models || {};
310
+ config.agents.defaults.models[modelId] = {};
311
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2), 'utf-8');
312
+ } catch {}
313
+
314
+ // Set OPENAI_BASE_URL env var for non-standard endpoints
315
+ if (!isOpenAI && !isAnthropic) {
316
+ env.OPENAI_BASE_URL = baseUrl;
317
+ env.OPENAI_API_KEY = apiKey;
318
+ }
319
+ }
258
320
  }
259
321
 
260
322
  module.exports = OpenClawAdapter;
package/src/index.js CHANGED
@@ -113,6 +113,7 @@ class AgentConnector {
113
113
  slug: n.slug,
114
114
  name: n.name || n.slug,
115
115
  endpoint: n.endpoint || '',
116
+ token: n.token || '',
116
117
  }));
117
118
  }
118
119
 
@@ -430,7 +430,7 @@ class WorkspaceClient {
430
430
  sessionId: target.startsWith('channel/') ? target.replace('channel/', '') : target,
431
431
  senderType: isHuman ? 'human' : 'agent',
432
432
  senderName,
433
- content: (payload.content || ''),
433
+ content: (payload.content || event.content || ''),
434
434
  mentions: payload.mentions || [],
435
435
  messageType: payload.message_type || 'chat',
436
436
  metadata: event.metadata || {},