@openagents-org/agent-launcher 0.2.215 → 0.2.217

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.
@@ -159,7 +159,10 @@ class OpenCodeAdapter extends BaseAdapter {
159
159
  // opencode hangs waiting for interactive provider/model selection.
160
160
  // Connected agents run unattended: let the CLI resolve permission prompts
161
161
  // automatically instead of rejecting tools outside the working directory.
162
- const args = ['run', '--format', 'json', '--dangerously-skip-permissions', '--dir', runCwd, '--model', model];
162
+ // --thinking adds the model's reasoning to the JSON stream as `reasoning`
163
+ // events, shown live as thinking (like Claude and Codex). Available since
164
+ // the minimum supported 1.17.0.
165
+ const args = ['run', '--format', 'json', '--thinking', '--dangerously-skip-permissions', '--dir', runCwd, '--model', model];
163
166
  if (sessionId) args.push('--session', sessionId);
164
167
  return args;
165
168
  }
@@ -504,6 +507,7 @@ class OpenCodeAdapter extends BaseAdapter {
504
507
  const eventType = String(event.type || '').toLowerCase();
505
508
  if (['step_start', 'step-start', 'step_finish', 'step-finish', 'tool_use', 'tool'].includes(eventType)) return null;
506
509
  if (OpenCodeAdapter._isToolEvent(event)) return null;
510
+ if (OpenCodeAdapter._isReasoningEvent(event)) return null;
507
511
  if (eventType.includes('error')) return null;
508
512
 
509
513
  const part = event.part;
@@ -574,6 +578,13 @@ class OpenCodeAdapter extends BaseAdapter {
574
578
  }
575
579
 
576
580
  async _handleStreamEvent(event, msgChannel, responseState = null) {
581
+ // Reasoning is a live thinking trace only: it never counts toward the reply.
582
+ const reasoning = OpenCodeAdapter._reasoningFromEvent(event);
583
+ if (reasoning !== null) {
584
+ if (reasoning.trim()) await this.sendThinking(msgChannel, reasoning.trim());
585
+ return;
586
+ }
587
+
577
588
  const status = OpenCodeAdapter._toolStatusFromEvent(event);
578
589
  if (status) {
579
590
  // A tool call resets `finalText` (the "text since the last tool"), so the
@@ -1262,6 +1273,24 @@ class OpenCodeAdapter extends BaseAdapter {
1262
1273
  // ------------------------------------------------------------------
1263
1274
 
1264
1275
  /** True when an event is a tool call, across opencode's version-varying shapes. */
1276
+ /** A `--thinking` reasoning event (`{type:"reasoning", part:{type:"reasoning", text}}`). */
1277
+ static _isReasoningEvent(event) {
1278
+ if (!event || typeof event !== 'object') return false;
1279
+ if (String(event.type || '').toLowerCase() === 'reasoning') return true;
1280
+ const part = event.part;
1281
+ return !!(part && typeof part === 'object' && String(part.type || '').toLowerCase() === 'reasoning');
1282
+ }
1283
+
1284
+ /** Reasoning text from a reasoning event ('' when empty), or null for any other event. */
1285
+ static _reasoningFromEvent(event) {
1286
+ if (!OpenCodeAdapter._isReasoningEvent(event)) return null;
1287
+ const part = (event.part && typeof event.part === 'object') ? event.part : event;
1288
+ const text = part.text || part.content || '';
1289
+ // Summaries of several reasoning steps arrive glued together
1290
+ // ("**Checking A****Testing B**"); give each heading its own paragraph.
1291
+ return typeof text === 'string' ? text.replace(/\*\*\*\*(?=\S)/g, '**\n\n**') : '';
1292
+ }
1293
+
1265
1294
  static _isToolEvent(event) {
1266
1295
  if (!event || typeof event !== 'object') return false;
1267
1296
  const t = String(event.type || '').toLowerCase();
@@ -1339,6 +1368,13 @@ class OpenCodeAdapter extends BaseAdapter {
1339
1368
  let category;
1340
1369
  if (isPostinstallStubOutput(hay)) {
1341
1370
  category = 'install_incomplete';
1371
+ } else if (has(/(?:unrecognized|unknown) (?:flag|option|argument)s?:?\s*['"`]?--?[a-z]/)) {
1372
+ // The CLI refused a flag this adapter always passes, so it is not a
1373
+ // build we support (one whose version string we could not read gets
1374
+ // through the preflight). It printed its usage too, and that came out
1375
+ // as "produced output this version could not parse", which said nothing
1376
+ // about reinstalling.
1377
+ category = 'unsupported_version';
1342
1378
  } else if (has(/\b(401|403)\b/) || has(/unauthor|invalid api key|invalid_api_key|authentication|auth(entication)? failed|forbidden|invalid token|no api key|missing api key|permission denied/)) {
1343
1379
  category = 'auth_failed';
1344
1380
  } else if (has(/\b429\b/) || has(/rate.?limit|too many requests|quota|overloaded/)) {
package/src/daemon.js CHANGED
@@ -22,9 +22,10 @@ const { LogWriter } = require('./log-writer');
22
22
  const { redactDiagnostic } = require('./adapters/health-status');
23
23
  const { installCommandFor } = require('./probe');
24
24
 
25
- /** Types whose endpoint is one device-wide config file of their own. OpenClaw
26
- * left it: each keyed agent gets a private store (adapters/openclaw.js). */
27
- const SHARED_NATIVE_CONFIG = new Set(['hermes']);
25
+ /** Types whose endpoint is one device-wide config file of their own. None
26
+ * left: OpenClaw gives each keyed agent a private store (adapters/openclaw.js)
27
+ * and Hermes a provider of its own in its config.yaml (adapters/hermes.js). */
28
+ const SHARED_NATIVE_CONFIG = new Set();
28
29
 
29
30
  // A signed-in agent's model list is asked for again after this long. What a
30
31
  // CLI is offered changes when the CLI is upgraded (a vendor holds new models
@@ -751,11 +752,9 @@ class Daemon {
751
752
  * set up in the launcher onto another one's key, endpoint and model: add a
752
753
  * second DeepSeek or CodeArts agent from the workspace, and the first one
753
754
  * ran on the new one's settings from its next restart.
754
- * Hermes keeps sharing: its endpoint lives in one config file of its own
755
- * for the whole device, which only a save to <type>.env updates (index.js
756
- * _configureNativeAuth), so a key kept on the agent would never reach it.
757
- * OpenClaw writes each keyed agent's private openclaw.json from the agent's
758
- * own env when it starts, so it keeps its key on the agent like the rest.
755
+ * OpenClaw writes each keyed agent's private openclaw.json, and Hermes each
756
+ * keyed agent's own provider, from the agent's own env when it runs, so
757
+ * both keep their keys on the agent like the rest.
759
758
  */
760
759
  _keepsKeysPerAgent(type) {
761
760
  return !SHARED_NATIVE_CONFIG.has(type);
package/src/index.js CHANGED
@@ -115,10 +115,9 @@ class AgentConnector {
115
115
  const agentType = type || 'openclaw';
116
116
  this.config.addAgent({ name, type: agentType, role: role || 'worker', path, env });
117
117
  // A key entered while ADDING the agent needs the same native side effects
118
- // as one saved later: OpenClaw and Hermes read a custom endpoint only from
119
- // their own config. Without this a new agent's test passed on the form's
120
- // key while the run used a stale one ("401 Invalid token") or none at all
121
- // (Hermes falling back to OpenRouter: "401 Missing Authentication header").
118
+ // as one saved later: OpenClaw reads a custom endpoint only from its own
119
+ // config. Without this a new agent's test passed on the form's key while
120
+ // the run used a stale one ("401 Invalid token").
122
121
  if (env && Object.keys(env).length) {
123
122
  this._configureAgentNativeAuth(agentType, env, name);
124
123
  }
@@ -129,14 +128,15 @@ class AgentConnector {
129
128
  * _configureNativeAuth for one agent, on the env it actually runs with: the
130
129
  * type's keys and endpoint only when it has none of its own and does not
131
130
  * sign in through its CLI (typeEnvFor). Merging all of <type>.env pushed a
132
- * key saved there earlier into Hermes's config.yaml for an agent created on
133
- * the sign-in tab, which then ran on that key (401).
131
+ * key saved there earlier into the CLI's config for an agent created on the
132
+ * sign-in tab, which then ran on that key (401).
134
133
  */
135
134
  _configureAgentNativeAuth(agentType, agentEnv, agentName) {
136
135
  const typeEnv = typeEnvFor(agentType, this.env.load(agentType), this.registry, agentEnv);
137
136
  this._configureNativeAuth(agentType, { ...typeEnv, ...agentEnv }, agentName);
138
137
  // A Hermes agent moved to the `hermes setup` sign-in gets back the
139
- // provider the custom endpoint replaced.
138
+ // provider an earlier version's custom endpoint replaced. (A keyed Hermes
139
+ // agent writes its own provider when it runs: HermesAdapter._endpoint.)
140
140
  if (agentType === 'hermes' && isCliLogin(agentEnv)) {
141
141
  try { require('./adapters/hermes').restoreNativeAuth(); } catch {}
142
142
  }
@@ -151,12 +151,6 @@ class AgentConnector {
151
151
  ? OpenClawAdapter.instanceEnv(agentName, env, this._configDir)
152
152
  : env);
153
153
  }
154
- // Hermes reads a custom endpoint only from its own config.yaml, so the
155
- // saved LLM_* values must be pushed through `hermes config set` — the
156
- // env file alone leaves it "No inference provider configured".
157
- if (agentType === 'hermes') {
158
- require('./adapters/hermes').configureNativeAuth(env);
159
- }
160
154
  } catch {}
161
155
  }
162
156
 
@@ -255,16 +255,35 @@ const PROBES = {
255
255
  uv: { probe: probeUv, remedy: uvRemedy },
256
256
  };
257
257
 
258
+ /** Registry platform names, as the `install` commands are keyed. */
259
+ const REGISTRY_PLATFORM = { darwin: 'macos', linux: 'linux', win32: 'windows' };
260
+
261
+ /**
262
+ * Whether `install.requires_on` limits a dependency to other platforms.
263
+ * Claude Code needs git only on Windows (it runs its shell through Git Bash);
264
+ * the npm install on macOS and Linux never touches git, yet a mac without the
265
+ * Command Line Tools was told to install them before it could get Claude.
266
+ * A separate field rather than a suffix inside `requires`, so an older core
267
+ * reading the same catalog keeps checking git everywhere instead of nowhere.
268
+ */
269
+ function requiredHere(entry, name, platform) {
270
+ const only = entry.install.requires_on && entry.install.requires_on[name];
271
+ if (!Array.isArray(only)) return true;
272
+ return only.includes(REGISTRY_PLATFORM[platform] || platform);
273
+ }
274
+
258
275
  /**
259
276
  * Check a registry entry's `install.requires` against the machine.
277
+ * @param {string} [platform] - seam for tests; production passes nothing.
260
278
  * @returns {{ ok: boolean, missing: Array<{name: string, action: string|null, summary: string, command: string, alternative: string|null}> }}
261
279
  */
262
- function checkInstallPrereqs(entry) {
280
+ function checkInstallPrereqs(entry, platform = process.platform) {
263
281
  const requires = entry && entry.install ? entry.install.requires : null;
264
282
  if (!Array.isArray(requires) || requires.length === 0) return { ok: true, missing: [] };
265
283
 
266
284
  const missing = [];
267
285
  for (const name of requires) {
286
+ if (!requiredHere(entry, name, platform)) continue;
268
287
  const spec = PROBES[String(name || '').toLowerCase()];
269
288
  if (!spec) continue; // no probe → the installer's problem, not ours
270
289
  let result;
package/src/paths.js CHANGED
@@ -869,6 +869,12 @@ function _addWindowsPaths(dirs) {
869
869
  // Node.js install
870
870
  _push(dirs, path.join(programFiles, 'nodejs'));
871
871
 
872
+ // Kiro CLI — install.ps1 runs an MSI that installs kiro-cli.exe into
873
+ // %ProgramFiles%\Kiro-Cli and edits the machine PATH, which an
874
+ // already-running daemon never sees. (install.sh uses ~/.local/bin, or
875
+ // /usr/local/bin for a system-wide install — both searched already.)
876
+ _push(dirs, path.join(programFiles, 'Kiro-Cli'));
877
+
872
878
  // nvm for Windows
873
879
  const nvmHome = process.env.NVM_HOME;
874
880
  if (nvmHome) {
package/src/utils.js CHANGED
@@ -82,10 +82,22 @@ async function servedModels(apiBase, headers) {
82
82
  }
83
83
  }
84
84
 
85
+ /**
86
+ * The test asks for a few tokens to stay cheap. A reasoning model can spend
87
+ * them all thinking, and OpenAI then refuses with "Could not finish the message
88
+ * because max_tokens or model output limit was reached". The key and the model
89
+ * were both accepted, which is everything this test checks, and reporting it as
90
+ * a failure marked an agent that works as broken.
91
+ */
92
+ const OUTPUT_LIMIT_REACHED = /max_tokens or model output limit was reached/i;
93
+
85
94
  /** Read one completion response into the result shape. */
86
95
  function completionResult(res, { isAnthropic, model }) {
87
96
  if (res.error) return { success: false, error: res.error };
88
97
  const { status, data } = res;
98
+ if (status >= 400 && OUTPUT_LIMIT_REACHED.test(data || '')) {
99
+ return { success: true, model: model || '?', response: '' };
100
+ }
89
101
  try {
90
102
  const parsed = JSON.parse(data);
91
103
  let text, usedModel;