@openagents-org/agent-launcher 0.2.197 → 0.2.198

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.198",
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": {
@@ -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
  }