@openagents-org/agent-launcher 0.2.203 → 0.2.204

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.203",
3
+ "version": "0.2.204",
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": {
@@ -470,7 +470,7 @@ class AiderAdapter extends BaseAdapter {
470
470
  result = await this._runAider(content, msgChannel);
471
471
  } catch (e) {
472
472
  this._log(`Error handling message: ${e.message}`);
473
- await this.sendError(msgChannel, `Error processing message: ${e.message}`);
473
+ await this.sendError(msgChannel, `Error processing message: ${this._redact(e.message)}`);
474
474
  return;
475
475
  }
476
476
 
@@ -606,8 +606,10 @@ class AiderAdapter extends BaseAdapter {
606
606
  if (code !== 0) {
607
607
  let diagnostic = classifyError(stderrText, stdoutText);
608
608
  if (!diagnostic) {
609
+ // Aider's own last line, which on a provider failure quotes the
610
+ // request it made — redacted before it is posted.
609
611
  const tail = (stderrText || stdoutText).split('\n');
610
- const detail = tail.length ? tail[tail.length - 1] : '';
612
+ const detail = this._redact(tail.length ? tail[tail.length - 1] : '');
611
613
  diagnostic = `Aider exited with code ${code}.${detail ? ` ${detail}` : ''}`;
612
614
  }
613
615
  resolve({ text: '', error: diagnostic });
@@ -32,11 +32,27 @@ const { execSync } = require('child_process');
32
32
  const { spawn, resolveWslBinary } = require('../wsl');
33
33
 
34
34
  const BaseAdapter = require('./base');
35
+ const { classifyRunFailure, classifiedError, isClassifiedError } = require('./run-failure');
35
36
  const { buildOpenclawSystemPrompt } = require('./workspace-prompt');
36
37
  const { whichBinary, getEnhancedEnv } = require('../paths');
37
38
  const { REASON, classifySpawnError, redactDiagnostic, shouldUseShellForBinary } = require('./health-status');
38
39
 
39
40
  const IS_WINDOWS = process.platform === 'win32';
41
+ // What a failed `amp -x` run should tell the channel, per cause. The
42
+ // classifier appends the CLI's own words, redacted; see run-failure.js.
43
+ const AMP_GUIDANCE = {
44
+ auth:
45
+ 'Amp could not authenticate. Set AMP_API_KEY for this agent, or run `amp ' +
46
+ 'login` on the device. A self-hosted deployment also needs AMP_URL.',
47
+ quota:
48
+ 'Amp is rate-limited, or the account is out of credit. Wait and try again, ' +
49
+ 'or check the balance on the Amp account.',
50
+ network:
51
+ "Amp could not reach its server from this device. Check the device's " +
52
+ 'network, or its proxy, and AMP_URL if a self-hosted deployment is set.',
53
+ timeout: 'Amp timed out before producing a response.',
54
+ };
55
+
40
56
  // Terminate the subprocess if it produces no output for this long (a wedged
41
57
  // turn) — guards the daemon against a hung Amp process without arbitrary sleeps.
42
58
  const IDLE_TIMEOUT_MS = 5 * 60 * 1000;
@@ -267,6 +283,10 @@ class AmpAdapter extends BaseAdapter {
267
283
  this._log(message);
268
284
  this._reportStatus(reason, message);
269
285
  await this.sendError(msgChannel, message);
286
+ } else if (isClassifiedError(e)) {
287
+ // Already the sentence the user should read, secrets stripped, and
288
+ // logged where it was thrown.
289
+ await this.sendError(msgChannel, e.message);
270
290
  } else {
271
291
  this._log(`Error handling message: ${redactDiagnostic(e.message)}`);
272
292
  await this.sendError(
@@ -324,7 +344,7 @@ class AmpAdapter extends BaseAdapter {
324
344
  prompt = `${context}\n\n---\n\n${content}`;
325
345
  }
326
346
 
327
- const { text, stale } = await this._spawnAmp(cmd, prompt, msgChannel);
347
+ const { text, stale, exitCode, stderr } = await this._spawnAmp(cmd, prompt, msgChannel);
328
348
 
329
349
  if (this._stoppingChannels.has(msgChannel)) return '';
330
350
  if (text) return text;
@@ -334,6 +354,17 @@ class AmpAdapter extends BaseAdapter {
334
354
  this._saveSessions();
335
355
  continue;
336
356
  }
357
+ // Nothing to post and the CLI failed: say why instead of "No response
358
+ // generated". A clean exit with no text is a different case — it falls
359
+ // through to the caller's generic wording.
360
+ if (exitCode !== 0) {
361
+ const failure = classifyRunFailure({
362
+ code: exitCode, stderr, cli: 'Amp', guidance: AMP_GUIDANCE, skip: ['session'],
363
+ secrets: this._knownSecrets(),
364
+ });
365
+ this._log(`Amp run failed (${failure.kind}, exit ${exitCode})`, 'error');
366
+ throw classifiedError(failure.message);
367
+ }
337
368
  return '';
338
369
  }
339
370
  return '';
@@ -461,7 +492,7 @@ class AmpAdapter extends BaseAdapter {
461
492
 
462
493
  const text = lastTurnText.filter(Boolean).join('\n').trim() || resultText.trim();
463
494
  const stale = code !== 0 && !text;
464
- resolve({ text, exitCode: code, stale });
495
+ resolve({ text, exitCode: code, stale, stderr: stderrBuf });
465
496
  });
466
497
 
467
498
  proc.on('error', (err) => {
@@ -13,6 +13,8 @@
13
13
  * rather than a tweak to the gemini adapter.
14
14
  */
15
15
 
16
+ const { redactSecrets } = require('./utils');
17
+
16
18
  /** Build the argv tail (everything after the binary) for one headless run. */
17
19
  function buildAgyArgv({ prompt, model, conversationId, skipResume = false } = {}) {
18
20
  const args = [
@@ -183,7 +185,7 @@ const TIMEOUT_RE = /print-timeout|timed? ?out/i;
183
185
  * "No response generated. Please try again." dead end: the real reason was in
184
186
  * stderr all along, so surface it.
185
187
  */
186
- function classifyAgyFailure({ code, stderr, error } = {}) {
188
+ function classifyAgyFailure({ code, stderr, error, secrets = [] } = {}) {
187
189
  // The docs describe `result.error` as {type, message}; agy 1.1.17 actually
188
190
  // emits a plain string ("authentication failed or timed out"). Take both.
189
191
  const err = error && typeof error === 'object' ? error : {};
@@ -231,7 +233,9 @@ function classifyAgyFailure({ code, stderr, error } = {}) {
231
233
  if (TIMEOUT_RE.test(text)) {
232
234
  return { kind: 'timeout', message: 'Antigravity CLI timed out before producing a response.' };
233
235
  }
234
- const detail = errText || stderrTail(stderr);
236
+ // Quoted into the channel, so stripped of secrets first: the agent's own
237
+ // (`secrets`, by value) and anything shaped like one.
238
+ const detail = redactSecrets(errText || stderrTail(stderr), secrets);
235
239
  if (!detail) {
236
240
  return {
237
241
  kind: 'unknown',
@@ -341,8 +341,10 @@ class AntigravityAdapter extends BaseAdapter {
341
341
  // Surface the real reason (auth, provider config, bad model)
342
342
  // instead of a generic retry prompt — the gemini adapter's
343
343
  // silent-stderr dead end is what this branch fixes.
344
- const { kind, message } = classifyAgyFailure({ code, stderr: stderrBuf, error: run.error });
345
- this._log(`run failed (${kind})`);
344
+ const { kind, message } = classifyAgyFailure({
345
+ code, stderr: stderrBuf, error: run.error, secrets: this._knownSecrets(),
346
+ });
347
+ this._log(`run failed (${kind})`, 'error');
346
348
  try { await this.sendError(msgChannel, message); } catch {}
347
349
  resolve(false);
348
350
  } else {
@@ -370,7 +372,7 @@ class AntigravityAdapter extends BaseAdapter {
370
372
  });
371
373
  } catch (e) {
372
374
  this._log(`Error handling message: ${e.message}`);
373
- await this.sendError(msgChannel, `Error processing message: ${e.message}`);
375
+ await this.sendError(msgChannel, `Error processing message: ${this._redact(e.message)}`);
374
376
  break;
375
377
  }
376
378
  if (!_shouldRetry) break;
@@ -18,7 +18,7 @@
18
18
  'use strict';
19
19
 
20
20
  const { WorkspaceClient, SessionRevokedError } = require('../workspace-client');
21
- const { generateSessionTitle, SESSION_DEFAULT_RE } = require('./utils');
21
+ const { generateSessionTitle, SESSION_DEFAULT_RE, redactSecrets, secretValues } = require('./utils');
22
22
  const { defaultAgentWorkdir } = require('../paths');
23
23
  const { buildThreadHistory } = require('./thread-history');
24
24
  const { publishResponseArtifacts } = require('./response-artifacts');
@@ -301,6 +301,30 @@ class BaseAdapter {
301
301
  this._controlFailures = new FailureStreak();
302
302
  }
303
303
 
304
+ // ------------------------------------------------------------------
305
+ // Redaction of text quoted into the channel
306
+ // ------------------------------------------------------------------
307
+
308
+ /**
309
+ * The exact values this agent must never quote back: the credentials in the
310
+ * environment its CLI runs with, and its own workspace token. A CLI that
311
+ * fails on auth tends to echo the key it was handed, in whatever format the
312
+ * provider issues — matching by value catches it where no pattern would.
313
+ */
314
+ _knownSecrets() {
315
+ return secretValues(this.agentEnv, [this.token]);
316
+ }
317
+
318
+ /**
319
+ * Redact CLI or exception text on its way to the channel: this agent's own
320
+ * secrets by value first, then anything shaped like a credential. For quoted
321
+ * text only — authored guidance names variables ("set GEMINI_API_KEY") that
322
+ * the shape rules would rewrite.
323
+ */
324
+ _redact(text) {
325
+ return redactSecrets(text, this._knownSecrets());
326
+ }
327
+
304
328
  // ------------------------------------------------------------------
305
329
  // Runtime status reporting (daemon surfaces this in daemon.status.json)
306
330
  // ------------------------------------------------------------------
@@ -1095,8 +1119,8 @@ class BaseAdapter {
1095
1119
  }
1096
1120
 
1097
1121
  /**
1098
- * Post a markdown table of the agent's active routines back to the
1099
- * requesting channel. Used by the `/routines` slash command. Each agent
1122
+ * Post a markdown table of the agent's routines (active and paused) back
1123
+ * to the requesting channel. Used by the `/routines` slash command. Each agent
1100
1124
  * reports only routines it owns (created_by === openagents:<agentName>)
1101
1125
  * so the user sees a clear "my routines" view per agent, mirroring how
1102
1126
  * /status reports per-agent uptime.
@@ -1130,15 +1154,18 @@ class BaseAdapter {
1130
1154
 
1131
1155
  let content;
1132
1156
  if (!routines.length) {
1133
- content = `**Routines for \`${this.agentName}\`**\n\n_No active routines._`;
1157
+ content = `**Routines for \`${this.agentName}\`**\n\n_No routines._`;
1134
1158
  } else {
1135
1159
  const rows = routines.map((r) => {
1136
1160
  const schedule = (r.schedule_interval_minutes != null)
1137
1161
  ? `every ${r.schedule_interval_minutes} min`
1138
1162
  : `${String(r.schedule_hour ?? 0).padStart(2, '0')}:${String(r.schedule_minute ?? 0).padStart(2, '0')} UTC` +
1139
1163
  (r.schedule_days ? ` (days [${r.schedule_days.join(',')}])` : ' daily');
1140
- const next = r.next_fires_at || '—';
1141
- const name = String(r.name || '').replace(/\|/g, '\\|');
1164
+ // A paused routine keeps its last next_fires_at, which is stale (often
1165
+ // in the past) — show that it's paused instead of a time it won't fire.
1166
+ const paused = r.status && r.status !== 'active';
1167
+ const next = paused ? '—' : (r.next_fires_at || '—');
1168
+ const name = String(r.name || '').replace(/\|/g, '\\|') + (paused ? ` [${r.status}]` : '');
1142
1169
  const id = String(r.id || '').slice(0, 8);
1143
1170
  return `| \`${id}\` | ${name} | ${schedule} | ${next} |`;
1144
1171
  });
@@ -1446,7 +1473,7 @@ class BaseAdapter {
1446
1473
  }
1447
1474
  } catch (e) {
1448
1475
  this._log(`Error ${first ? 'in channel worker' : 'processing queued message'} for ${channel}: ${e.message}`, 'error');
1449
- try { await this.sendError(channel, `Agent error: ${e.message}`); } catch {}
1476
+ try { await this.sendError(channel, `Agent error: ${this._redact(e.message)}`); } catch {}
1450
1477
  }
1451
1478
  delete this._channelRunGeneration[channel];
1452
1479
  delete this._channelRequestContent[channel];
@@ -21,7 +21,7 @@ const { execSync } = require('child_process');
21
21
  const { spawn } = require('../wsl');
22
22
 
23
23
  const BaseAdapter = require('./base');
24
- const { formatAttachmentsForPrompt, SESSION_DEFAULT_RE, generateSessionTitle, redactSecrets, stripCliNoise } = require('./utils');
24
+ const { formatAttachmentsForPrompt, SESSION_DEFAULT_RE, generateSessionTitle, stripCliNoise } = require('./utils');
25
25
  const { buildClaudeSystemPrompt, buildClaudeSkillMd, buildPinnedSections, workspaceSkillName } = require('./workspace-prompt');
26
26
  const { pinnedFingerprint, sampleRecap } = require('./decision-log');
27
27
  const { defaultAgentWorkdir, whichBinary, whereBinary } = require('../paths');
@@ -589,7 +589,7 @@ class ClaudeAdapter extends BaseAdapter {
589
589
 
590
590
  // Todos, Timers & Routines (always enabled)
591
591
  mcpTools.push(`${pfx}workspace_get_todos`, `${pfx}workspace_list_timers`, `${pfx}workspace_list_routines`);
592
- mcpWriteTools.push(`${pfx}workspace_put_todos`, `${pfx}workspace_create_timer`, `${pfx}workspace_cancel_timer`, `${pfx}workspace_create_routine`, `${pfx}workspace_cancel_routine`);
592
+ mcpWriteTools.push(`${pfx}workspace_put_todos`, `${pfx}workspace_create_timer`, `${pfx}workspace_cancel_timer`, `${pfx}workspace_create_routine`, `${pfx}workspace_update_routine`, `${pfx}workspace_cancel_routine`);
593
593
 
594
594
  if (this._mode === 'plan') {
595
595
  cmd.push('--permission-mode', 'plan');
@@ -1054,7 +1054,7 @@ class ClaudeAdapter extends BaseAdapter {
1054
1054
  // Without Claude Code's harmless notices (an unknown relay model, the
1055
1055
  // disabled connectors): posted as "the" error, they hid the real one.
1056
1056
  const tail = stripCliNoise((pp && pp.stderrBuf) || '').trim();
1057
- return tail ? redactSecrets(tail).slice(-800) : '';
1057
+ return tail ? this._redact(tail).slice(-800) : '';
1058
1058
  }
1059
1059
 
1060
1060
  /**
@@ -1063,8 +1063,12 @@ class ClaudeAdapter extends BaseAdapter {
1063
1063
  * invisible — add a concrete hint about which env vars to check.
1064
1064
  */
1065
1065
  _formatClaudeError(text) {
1066
- const msg = String(text || '').trim() || 'Claude returned an error.';
1067
- if (/401|403|authenticate|invalid.*(token|key|api)|无效的?\s*(令牌|密钥|key)/i.test(msg)) {
1066
+ const raw = String(text || '').trim() || 'Claude returned an error.';
1067
+ // Matched on the raw text — redaction rewrites the very words the pattern
1068
+ // below keys on — but only the redacted text is quoted: a `result` error
1069
+ // is the provider's own message, and providers echo the key they rejected.
1070
+ const msg = this._redact(raw);
1071
+ if (/401|403|authenticate|invalid.*(token|key|api)|无效的?\s*(令牌|密钥|key)/i.test(raw)) {
1068
1072
  return `Claude authentication failed: ${msg}\n\n` +
1069
1073
  'Check this agent\'s API key and Base URL in the launcher — the key may be invalid or expired.';
1070
1074
  }
@@ -1498,7 +1502,7 @@ class ClaudeAdapter extends BaseAdapter {
1498
1502
  break;
1499
1503
  } catch (e) {
1500
1504
  this._log(`Error handling message: ${e.message}`);
1501
- await this.sendError(msgChannel, `Error processing message: ${e.message}`);
1505
+ await this.sendError(msgChannel, `Error processing message: ${this._redact(e.message)}`);
1502
1506
  break;
1503
1507
  }
1504
1508
  }
@@ -45,6 +45,7 @@ const { execSync, execFileSync } = require('child_process');
45
45
  const { spawn } = require('../wsl');
46
46
 
47
47
  const BaseAdapter = require('./base');
48
+ const { failureDetail } = require('./run-failure');
48
49
  const { buildOpenclawSystemPrompt } = require('./workspace-prompt');
49
50
  const { whichBinary, whereBinary, getEnhancedEnv, defaultAgentWorkdir } = require('../paths');
50
51
  const { compareVersions } = require('../installer');
@@ -436,7 +437,7 @@ class CopilotAdapter extends BaseAdapter {
436
437
  try {
437
438
  result = await this._runTurn(channel, args);
438
439
  } catch (e) {
439
- await this.sendError(channel, `Error: ${redactSensitive(e.message)}`);
440
+ await this.sendError(channel, `Error: ${this._redact(e.message)}`);
440
441
  return;
441
442
  }
442
443
 
@@ -535,7 +536,7 @@ class CopilotAdapter extends BaseAdapter {
535
536
  windowsHide: true,
536
537
  });
537
538
  } catch (e) {
538
- return resolve({ errorMessage: `Failed to launch Copilot CLI: ${redactSensitive(e.message)}` });
539
+ return resolve({ errorMessage: `Failed to launch Copilot CLI: ${this._redact(e.message)}` });
539
540
  }
540
541
  this._channelProcesses[channel] = proc;
541
542
 
@@ -675,7 +676,7 @@ class CopilotAdapter extends BaseAdapter {
675
676
  }
676
677
 
677
678
  proc.on('error', (err) => {
678
- finish({ errorMessage: `Copilot CLI failed to start: ${redactSensitive(err.message)}` });
679
+ finish({ errorMessage: `Copilot CLI failed to start: ${this._redact(err.message)}` });
679
680
  });
680
681
 
681
682
  proc.on('exit', async (code) => {
@@ -786,10 +787,20 @@ class CopilotAdapter extends BaseAdapter {
786
787
  return { hard: true, message: 'Copilot was denied a required permission (path/tool). The task may need access outside the working directory.' };
787
788
  }
788
789
  if (errorEvent && errorEvent.message) {
789
- return { hard: true, message: `Copilot error: ${redactSensitive(errorEvent.message).slice(0, 300)}` };
790
+ return { hard: true, message: `Copilot error: ${this._redact(errorEvent.message).slice(0, 300)}` };
790
791
  }
791
792
  if (exitCode && exitCode !== 0) {
792
- return { hard: false, message: `Copilot CLI exited with code ${exitCode}.` };
793
+ // Nothing above matched, so quote what the CLI actually said (redacted,
794
+ // chatter dropped) — a bare exit code tells the user nothing.
795
+ const detail = failureDetail({
796
+ stderr, error: errorEvent && errorEvent.message, secrets: this._knownSecrets(),
797
+ });
798
+ return {
799
+ hard: false,
800
+ message: detail
801
+ ? `Copilot CLI exited with code ${exitCode}: ${detail}`
802
+ : `Copilot CLI exited with code ${exitCode}.`,
803
+ };
793
804
  }
794
805
  return null;
795
806
  }
@@ -19,6 +19,7 @@ const { execSync } = require('child_process');
19
19
  const { spawn } = require('../wsl');
20
20
 
21
21
  const BaseAdapter = require('./base');
22
+ const { classifyRunFailure } = require('./run-failure');
22
23
  const { formatAttachmentsForPrompt, SESSION_DEFAULT_RE, generateSessionTitle } = require('./utils');
23
24
  const { buildCursorSkillMd, workspaceSkillName } = require('./workspace-prompt');
24
25
  const { defaultAgentWorkdir, whichBinary, whereBinary } = require('../paths');
@@ -28,6 +29,23 @@ const IS_WINDOWS = process.platform === 'win32';
28
29
  // How long cursor-agent gets to exit by itself after emitting its `result`.
29
30
  const RESULT_EXIT_GRACE_MS = 3000;
30
31
 
32
+ // What a failed `cursor-agent` run should tell the channel, per cause. The
33
+ // classifier appends the CLI's own words, redacted; see run-failure.js.
34
+ const CURSOR_GUIDANCE = {
35
+ auth:
36
+ 'Cursor CLI could not authenticate. Set CURSOR_API_KEY for this agent, or ' +
37
+ 'run `cursor-agent login` on the device.',
38
+ quota:
39
+ 'Cursor is rate-limiting this agent, or the plan is out of requests. Wait ' +
40
+ 'and try again, or check the usage on the Cursor account.',
41
+ network:
42
+ "Cursor CLI could not reach Cursor's API from this device. Check the " +
43
+ "device's network, or its proxy.",
44
+ model:
45
+ 'Cursor rejected the requested model. Check CURSOR_MODEL for this agent, or ' +
46
+ 'clear it to use the CLI default.',
47
+ };
48
+
31
49
  class CursorAdapter extends BaseAdapter {
32
50
  constructor(opts) {
33
51
  super(opts);
@@ -494,6 +512,8 @@ class CursorAdapter extends BaseAdapter {
494
512
  let postedThinking = false;
495
513
  let everPostedAnything = false;
496
514
  let stderrBuf = '';
515
+ // Set from a result event with is_error — see the exit handler.
516
+ let resultError = null;
497
517
  let lineBuffer = '';
498
518
  let _pendingLines = Promise.resolve();
499
519
 
@@ -574,7 +594,10 @@ class CursorAdapter extends BaseAdapter {
574
594
  this._saveSessions();
575
595
  }
576
596
  if (event.is_error) {
577
- this._log(`Cursor error: ${String(event.result || '').slice(0, 200)}`);
597
+ // Kept for the exit handler: an errored result is the only place
598
+ // Cursor says WHY, and it used to be logged and dropped.
599
+ resultError = String(event.result || '') || 'Cursor reported an error';
600
+ this._log(`Cursor error: ${resultError.slice(0, 200)}`);
578
601
  }
579
602
  // `result` ends the turn, but cursor-agent -p does not always exit
580
603
  // after it. The reply is sent from the exit handler, so a CLI left
@@ -645,6 +668,25 @@ class CursorAdapter extends BaseAdapter {
645
668
  this._log(`stderr: ${stderrBuf.trim().slice(0, 500)}`);
646
669
  }
647
670
 
671
+ // Why the run failed, if it did — from the errored result event, or
672
+ // from stderr and the exit code when the CLI died before one.
673
+ const failure = (code !== 0 || resultError)
674
+ ? classifyRunFailure({
675
+ code,
676
+ stderr: stderrBuf,
677
+ error: resultError,
678
+ cli: 'Cursor CLI',
679
+ guidance: CURSOR_GUIDANCE,
680
+ skip: ['session'],
681
+ secrets: this._knownSecrets(),
682
+ })
683
+ : null;
684
+ if (failure) this._log(`Run failed (${failure.kind})`, 'error');
685
+ // Only a failure nothing explains is worth a fresh session. Clearing
686
+ // it for a bad key or an exhausted quota throws the channel's history
687
+ // away and buys a second helping of the same error.
688
+ const worthRetrying = !failure || failure.kind === 'unknown';
689
+
648
690
  if (lastResponseText.length > 0) {
649
691
  const fullResponse = lastResponseText.join('\n').trim();
650
692
  if (/prompt is too long/i.test(fullResponse) && this._channelSessions[msgChannel]) {
@@ -658,11 +700,14 @@ class CursorAdapter extends BaseAdapter {
658
700
  } else {
659
701
  resolve(false);
660
702
  }
661
- } else if (this._channelSessions[msgChannel] && !everPostedAnything) {
703
+ } else if (this._channelSessions[msgChannel] && !everPostedAnything && worthRetrying) {
662
704
  this._log(`Stale session detected for ${msgChannel}, clearing and retrying without resume`);
663
705
  delete this._channelSessions[msgChannel];
664
706
  this._saveSessions();
665
707
  resolve(true);
708
+ } else if (failure) {
709
+ try { await this.sendError(msgChannel, failure.message); } catch {}
710
+ resolve(false);
666
711
  } else {
667
712
  if (!everPostedAnything) {
668
713
  try { await this.sendResponse(msgChannel, 'No response generated. Please try again.'); } catch {}
@@ -689,7 +734,7 @@ class CursorAdapter extends BaseAdapter {
689
734
  });
690
735
  } catch (e) {
691
736
  this._log(`Error handling message: ${e.message}`);
692
- await this.sendError(msgChannel, `Error processing message: ${e.message}`);
737
+ await this.sendError(msgChannel, `Error processing message: ${this._redact(e.message)}`);
693
738
  break;
694
739
  }
695
740
  if (!_shouldRetry) break;
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Gemini-specific failure rules for GeminiAdapter. The matching and the
5
+ * "guidance + Details:" shape are shared with every other adapter in
6
+ * run-failure.js; what lives here is what only Gemini knows — the wording of
7
+ * its guidance, and which failures earn a retry from a fresh session.
8
+ *
9
+ * Gemini CLI (checked against @google/gemini-cli 0.59.0) reports a failed
10
+ * `-o stream-json` run in three places, and the adapter used to read none of
11
+ * them — every failure reached the user as "No response generated":
12
+ * - a `result` event with status "error" and `error: {type, message}`, for
13
+ * API failures once the CLI's own retries are spent (bad key, quota,
14
+ * network, model);
15
+ * - `error` events with severity "error" (blocked response, turn limit);
16
+ * - stderr plus the exit code, for what fails before the run starts: no
17
+ * usable auth method (exit 41), or a --resume id the CLI cannot find
18
+ * (exit 42, "Error resuming session: ...").
19
+ */
20
+
21
+ const { isFailedRun, failureDetail, classifyRunFailure } = require('./run-failure');
22
+
23
+ const CLI = 'Gemini CLI';
24
+
25
+ const GUIDANCE = {
26
+ session: "Gemini CLI could not resume this channel's previous session.",
27
+ auth:
28
+ 'Gemini CLI could not authenticate on this device. Set GEMINI_API_KEY for ' +
29
+ 'this agent (Google ended Gemini CLI access for individual Google accounts ' +
30
+ 'in June 2026), or switch to the Antigravity CLI agent. With a Gemini Code ' +
31
+ 'Assist license, run `gemini` on the device to sign in again.',
32
+ quota:
33
+ 'Gemini API quota or rate limit reached. Wait and try again, or use an API ' +
34
+ 'key or project with more quota.',
35
+ network:
36
+ "Gemini CLI could not reach Google's API from this device, even after " +
37
+ "retrying. Check that the device's network, or its proxy, can reach Google.",
38
+ model:
39
+ 'Gemini rejected the requested model. Check GEMINI_MODEL for this agent, or ' +
40
+ 'clear it to use the CLI default.',
41
+ };
42
+
43
+ /**
44
+ * Turn a failed run into { kind, message }, where message is what the channel
45
+ * should read: guidance for the failures a user can act on, followed by the
46
+ * CLI's own words.
47
+ */
48
+ function classifyGeminiFailure({ code, stderr, error, errorMessages = [], secrets = [] } = {}) {
49
+ return classifyRunFailure({
50
+ code, stderr, error, errorMessages, secrets, cli: CLI, guidance: GUIDANCE,
51
+ });
52
+ }
53
+
54
+ /**
55
+ * Whether a failed resumed run earns one retry from a fresh session: only when
56
+ * the resume itself failed, or when nothing says why. Retrying an auth, quota,
57
+ * network or model failure repeats the same wait for the same error, and
58
+ * throws away the channel's conversation history on the way.
59
+ */
60
+ function retriesWithoutResume(kind) {
61
+ return kind === 'session' || kind === 'unknown';
62
+ }
63
+
64
+ module.exports = {
65
+ isFailedRun,
66
+ failureDetail,
67
+ classifyGeminiFailure,
68
+ retriesWithoutResume,
69
+ };