agent-yes 1.65.0 → 1.66.0

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.
@@ -1059,7 +1059,7 @@ function tryCatch(catchFn, fn) {
1059
1059
  //#endregion
1060
1060
  //#region package.json
1061
1061
  var name = "agent-yes";
1062
- var version = "1.65.0";
1062
+ var version = "1.66.0";
1063
1063
 
1064
1064
  //#endregion
1065
1065
  //#region ts/pty-fix.ts
@@ -1305,6 +1305,7 @@ var AgentContext = class {
1305
1305
  isFatal = false;
1306
1306
  shouldRestartWithoutContinue = false;
1307
1307
  autoYesEnabled = true;
1308
+ restartCount = 0;
1308
1309
  constructor(params) {
1309
1310
  this.shell = params.shell;
1310
1311
  this.pidStore = params.pidStore;
@@ -1705,6 +1706,14 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
1705
1706
  }
1706
1707
  ctx.shouldRestartWithoutContinue = false;
1707
1708
  ctx.isFatal = false;
1709
+ if (ctx.restartCount >= 10) {
1710
+ logger.error(`${cli} reached max restarts (10), giving up.`);
1711
+ return pendingExitCode.resolve(exitCode);
1712
+ }
1713
+ const backoffMs = 1e3 * Math.pow(2, ctx.restartCount);
1714
+ logger.info(`Restart ${ctx.restartCount + 1}/10, waiting ${backoffMs}ms before restart...`);
1715
+ await sleep(backoffMs);
1716
+ ctx.restartCount++;
1708
1717
  let [bin, ...args] = [...parseCommandString(cliConf?.binary || cli), ...cliArgs.filter((arg) => !["--continue", "--resume"].includes(arg))];
1709
1718
  logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
1710
1719
  const restartPtyOptions = {
@@ -1764,6 +1773,15 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
1764
1773
  notifyWebhook("EXIT", `fatal exitCode=${exitCode ?? "?"}`, workingDir).catch(() => null);
1765
1774
  return pendingExitCode.resolve(exitCode);
1766
1775
  }
1776
+ if (ctx.restartCount >= 10) {
1777
+ logger.error(`${cli} reached max restarts (10), giving up.`);
1778
+ notifyWebhook("EXIT", `max-restarts exitCode=${exitCode ?? "?"}`, workingDir).catch(() => null);
1779
+ return pendingExitCode.resolve(exitCode);
1780
+ }
1781
+ const backoffMs = 1e3 * Math.pow(2, ctx.restartCount);
1782
+ logger.info(`${cli} crashed (exit code: ${exitCode}), restart ${ctx.restartCount + 1}/10 in ${backoffMs}ms...`);
1783
+ await sleep(backoffMs);
1784
+ ctx.restartCount++;
1767
1785
  try {
1768
1786
  await pidStore.updateStatus(exitedPid, "exited", {
1769
1787
  exitReason: "restarted",
@@ -1772,7 +1790,6 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
1772
1790
  } catch (error) {
1773
1791
  logger.warn(`[pidStore] Failed to update status for PID ${exitedPid}:`, error);
1774
1792
  }
1775
- logger.info(`${cli} crashed (exit code: ${exitCode}), restarting...`);
1776
1793
  let restoreArgs = conf.restoreArgs;
1777
1794
  if (cli === "codex") {
1778
1795
  const storedSessionId = await getSessionForCwd(workingDir);
@@ -2112,4 +2129,4 @@ const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
2112
2129
 
2113
2130
  //#endregion
2114
2131
  export { AgentContext as a, PidStore as c, config as i, removeControlCharacters as l, CLIS_CONFIG as n, name as o, agentYes as r, version as s, SUPPORTED_CLIS as t };
2115
- //# sourceMappingURL=SUPPORTED_CLIS-CWEfLDO6.js.map
2132
+ //# sourceMappingURL=SUPPORTED_CLIS-DbTReaSd.js.map
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CWEfLDO6.js";
2
+ import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-DbTReaSd.js";
3
3
  import { t as logger } from "./logger-CX77vJDA.js";
4
4
  import { argv } from "process";
5
5
  import { spawn } from "child_process";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-CWEfLDO6.js";
1
+ import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-DbTReaSd.js";
2
2
  import "./logger-CX77vJDA.js";
3
3
 
4
4
  export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-yes",
3
- "version": "1.65.0",
3
+ "version": "1.66.0",
4
4
  "description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "ai",
package/ts/index.ts CHANGED
@@ -420,6 +420,16 @@ export default async function agentYes({
420
420
  ctx.shouldRestartWithoutContinue = false; // reset flag
421
421
  ctx.isFatal = false; // reset fatal flag to allow restart
422
422
 
423
+ // Enforce restart limit with exponential backoff
424
+ if (ctx.restartCount >= 10) {
425
+ logger.error(`${cli} reached max restarts (10), giving up.`);
426
+ return pendingExitCode.resolve(exitCode);
427
+ }
428
+ const backoffMs = 1000 * Math.pow(2, ctx.restartCount);
429
+ logger.info(`Restart ${ctx.restartCount + 1}/10, waiting ${backoffMs}ms before restart...`);
430
+ await sleep(backoffMs);
431
+ ctx.restartCount++;
432
+
423
433
  // Restart without continue args - use original cliArgs without restoreArgs
424
434
  const cliCommand = cliConf?.binary || cli;
425
435
  let [bin, ...args] = [
@@ -491,6 +501,21 @@ export default async function agentYes({
491
501
  return pendingExitCode.resolve(exitCode);
492
502
  }
493
503
 
504
+ // Enforce restart limit with exponential backoff
505
+ if (ctx.restartCount >= 10) {
506
+ logger.error(`${cli} reached max restarts (10), giving up.`);
507
+ notifyWebhook("EXIT", `max-restarts exitCode=${exitCode ?? "?"}`, workingDir).catch(
508
+ () => null,
509
+ );
510
+ return pendingExitCode.resolve(exitCode);
511
+ }
512
+ const backoffMs = 1000 * Math.pow(2, ctx.restartCount);
513
+ logger.info(
514
+ `${cli} crashed (exit code: ${exitCode}), restart ${ctx.restartCount + 1}/10 in ${backoffMs}ms...`,
515
+ );
516
+ await sleep(backoffMs);
517
+ ctx.restartCount++;
518
+
494
519
  // Update status (non-blocking)
495
520
  try {
496
521
  await pidStore.updateStatus(exitedPid, "exited", {
@@ -500,7 +525,6 @@ export default async function agentYes({
500
525
  } catch (error) {
501
526
  logger.warn(`[pidStore] Failed to update status for PID ${exitedPid}:`, error);
502
527
  }
503
- logger.info(`${cli} crashed (exit code: ${exitCode}), restarting...`);
504
528
 
505
529
  // For codex, try to use stored session ID for this directory
506
530
  let restoreArgs = conf.restoreArgs;