agent-yes 1.64.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.64.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-DXou-_yV.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-DXou-_yV.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";
@@ -83,6 +83,11 @@ function parseCliArgs(argv) {
83
83
  description: "Control auto-yes mode: 'yes' to auto-approve prompts (default), 'no' to start in manual mode. Press Ctrl+Y during the session to toggle at any time.",
84
84
  choices: ["yes", "no"],
85
85
  default: "yes"
86
+ }).option("yes", {
87
+ type: "boolean",
88
+ description: "Pass --dangerously-skip-permissions to the CLI (claude shortcut)",
89
+ default: false,
90
+ alias: "y"
86
91
  }).option("rust", {
87
92
  type: "boolean",
88
93
  description: "Use the Rust implementation (enabled by default, use --no-rust for TypeScript)",
@@ -140,6 +145,7 @@ function parseCliArgs(argv) {
140
145
  if (key === "robust") yargsConsumed.add("-r");
141
146
  if (key === "idle") yargsConsumed.add("-i");
142
147
  if (key === "exitOnIdle") yargsConsumed.add("-e");
148
+ if (key === "yes") yargsConsumed.add("-y");
143
149
  if (key === "continue") yargsConsumed.add("-c");
144
150
  }
145
151
  });
@@ -169,7 +175,7 @@ function parseCliArgs(argv) {
169
175
  cwd: process.cwd(),
170
176
  env: process.env,
171
177
  cli: cliName || parsedArgv.cli || (dashIndex !== 0 ? parsedArgv._[0]?.toString()?.replace?.(/-yes$/, "") : void 0),
172
- cliArgs: cliArgsForSpawn,
178
+ cliArgs: [...cliArgsForSpawn, ...parsedArgv.yes ? ["--dangerously-skip-permissions"] : []],
173
179
  prompt: [parsedArgv.prompt, dashPrompt].filter(Boolean).join(" ") || void 0,
174
180
  install: parsedArgv.install,
175
181
  exitOnIdle: Number((parsedArgv.timeout || parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String(ms(e))) || 0),
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-DXou-_yV.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.64.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;
@@ -119,6 +119,12 @@ export function parseCliArgs(argv: string[]) {
119
119
  choices: ["yes", "no"] as const,
120
120
  default: "yes",
121
121
  })
122
+ .option("yes", {
123
+ type: "boolean",
124
+ description: "Pass --dangerously-skip-permissions to the CLI (claude shortcut)",
125
+ default: false,
126
+ alias: "y",
127
+ })
122
128
  .option("rust", {
123
129
  type: "boolean",
124
130
  description: "Use the Rust implementation (enabled by default, use --no-rust for TypeScript)",
@@ -194,6 +200,7 @@ export function parseCliArgs(argv: string[]) {
194
200
  if (key === "robust") yargsConsumed.add("-r");
195
201
  if (key === "idle") yargsConsumed.add("-i");
196
202
  if (key === "exitOnIdle") yargsConsumed.add("-e");
203
+ if (key === "yes") yargsConsumed.add("-y");
197
204
  if (key === "continue") yargsConsumed.add("-c");
198
205
  }
199
206
  });
@@ -248,7 +255,7 @@ export function parseCliArgs(argv: string[]) {
248
255
  (dashIndex !== 0
249
256
  ? parsedArgv._[0]?.toString()?.replace?.(/-yes$/, "")
250
257
  : undefined)) as (typeof SUPPORTED_CLIS)[number],
251
- cliArgs: cliArgsForSpawn,
258
+ cliArgs: [...cliArgsForSpawn, ...(parsedArgv.yes ? ["--dangerously-skip-permissions"] : [])],
252
259
  prompt: [parsedArgv.prompt, dashPrompt].filter(Boolean).join(" ") || undefined,
253
260
  install: parsedArgv.install,
254
261
  exitOnIdle: Number(