nexrall-code 0.5.52 → 0.5.53

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.
Files changed (2) hide show
  1. package/dist/index.js +60 -26
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -15765,6 +15765,7 @@ var require_loop = __commonJS({
15765
15765
  Object.defineProperty(exports, "__esModule", { value: true });
15766
15766
  exports.VERIFY_CMD_RE = exports.WRITE_TOOL_NAMES = exports.ToolNotAllowedError = exports._stallLimits = void 0;
15767
15767
  exports.errorRoundSignature = errorRoundSignature;
15768
+ exports.stopReasonNotice = stopReasonNotice;
15768
15769
  exports.resolveMaxIterations = resolveMaxIterations;
15769
15770
  exports.createLimiter = createLimiter;
15770
15771
  exports.extractSubTaskText = extractSubTaskText;
@@ -15902,6 +15903,41 @@ var require_loop = __commonJS({
15902
15903
  return errored.map(({ name, error }) => `${name}:${String(error).slice(0, 200)}`).sort().join("|");
15903
15904
  }
15904
15905
  exports._stallLimits = { STALL_LIMIT, REPEAT_STALL_LIMIT };
15906
+ function stopReasonNotice(reason, ctx = {}) {
15907
+ switch (reason) {
15908
+ case "clean":
15909
+ case "aborted":
15910
+ case "reported-elsewhere":
15911
+ return null;
15912
+ case "empty-response":
15913
+ return `
15914
+ \u26A0\uFE0F The model returned an empty response, so nothing was done. This is usually a transient upstream hiccup \u2014 send "continue" to retry.
15915
+ `;
15916
+ case "no-balance":
15917
+ return `
15918
+ \u{1F4B3} Stopped: your balance is empty, so the request was rejected before it started. Top up and send "continue" \u2014 no tokens were used for this turn.
15919
+ `;
15920
+ case "stalled":
15921
+ return `
15922
+ \u{1F6D1} Stopped: the last ${STALL_LIMIT} tool rounds all failed, so the agent looked stuck. Fix the underlying error (or grant the needed permission) and send "continue".
15923
+ `;
15924
+ case "stalled-repeat":
15925
+ return `
15926
+ \u{1F6D1} Stopped: the same tool error repeated ${REPEAT_STALL_LIMIT} rounds in a row, so the agent was looping without making progress.` + (ctx.repeatError ? ` The recurring error was:
15927
+ ${ctx.repeatError}
15928
+ ` : "\n") + `Fix that underlying cause (or grant the needed permission) and send "continue".
15929
+ `;
15930
+ case "budget":
15931
+ return `
15932
+ \u23F8\uFE0F Stopped at the ${ctx.budget}-step safety limit \u2014 the task may be incomplete. Send "continue" to resume, or raise the limit via "maxIterations" in .nexrall/settings.json (or the NEXRALL_MAX_ITERATIONS env var). Auto-continue can be disabled with "autoContinue": false.
15933
+ `;
15934
+ case "unknown":
15935
+ default:
15936
+ return `
15937
+ \u26A0\uFE0F The run ended unexpectedly without completing. Your work so far is preserved \u2014 send "continue" to resume.
15938
+ `;
15939
+ }
15940
+ }
15905
15941
  function resolveMaxIterations(optionValue, settingsRaw) {
15906
15942
  const fromEnv = Number(process.env.NEXRALL_MAX_ITERATIONS);
15907
15943
  const fromSettings = Number(settingsRaw.maxIterations);
@@ -16651,9 +16687,8 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
16651
16687
  let lastPromptTokens = 0;
16652
16688
  let compacting = false;
16653
16689
  const hardCap = autoContinue ? Math.max(maxIterations, MAX_ITERATIONS_CEILING) : maxIterations;
16654
- let completedCleanly = false;
16690
+ let stopReason = "unknown";
16655
16691
  let completedRounds = 0;
16656
- let stalledOut = false;
16657
16692
  let consecutiveErrorRounds = 0;
16658
16693
  let repeatedErrorRounds = 0;
16659
16694
  let lastErrorSignature = "";
@@ -16671,8 +16706,10 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
16671
16706
  let compactDisabled = false;
16672
16707
  try {
16673
16708
  for (; iteration < budget; iteration++) {
16674
- if (options.abortSignal?.aborted)
16709
+ if (options.abortSignal?.aborted) {
16710
+ stopReason = "aborted";
16675
16711
  break;
16712
+ }
16676
16713
  let bodyBytes = estimateBodyBytes2(messages);
16677
16714
  const prunePressure = lastPromptTokens > contextWindow * AUTO_PRUNE_THRESHOLD;
16678
16715
  const tokenPressure = lastPromptTokens > contextWindow * AUTO_COMPACT_THRESHOLD;
@@ -16778,19 +16815,24 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
16778
16815
  allowRestartAfterRender: !!options.onStreamRestart
16779
16816
  }, onEvent);
16780
16817
  } catch (err) {
16781
- if (options.abortSignal?.aborted || err.name === "AbortError")
16818
+ if (options.abortSignal?.aborted || err.name === "AbortError") {
16819
+ stopReason = "aborted";
16782
16820
  break;
16821
+ }
16783
16822
  const status = err.status;
16784
16823
  if (status === 402) {
16785
16824
  const balance = err.balance ?? 0;
16786
16825
  options.onBalanceStatus?.(balance, true);
16826
+ stopReason = options.onBalanceStatus ? "reported-elsewhere" : "no-balance";
16787
16827
  break;
16788
16828
  }
16789
16829
  runSimpleHooks(hooks.OnError, options.workDir);
16790
16830
  throw new types_1.AgentTurnError(`Stream failed: ${err.message}`, trimToResumableBoundary(messages), completedRounds, err);
16791
16831
  }
16792
- if (options.abortSignal?.aborted)
16832
+ if (options.abortSignal?.aborted) {
16833
+ stopReason = "aborted";
16793
16834
  break;
16835
+ }
16794
16836
  assistantMessage.content = assistantMessage.content.filter((b) => b.type !== "thinking" && b.type !== "redacted_thinking");
16795
16837
  if (assistantMessage.content.length === 0) {
16796
16838
  const queued = options.takePendingInput?.() ?? [];
@@ -16801,7 +16843,7 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
16801
16843
  continue;
16802
16844
  }
16803
16845
  runSimpleHooks(hooks.PostMessageComplete, options.workDir);
16804
- completedCleanly = true;
16846
+ stopReason = "empty-response";
16805
16847
  break;
16806
16848
  }
16807
16849
  const { stopReason: _stopReason, ...historyMessage } = assistantMessage;
@@ -16872,7 +16914,7 @@ ${options.nexrallMd}` : "") : options.nexrallMd;
16872
16914
  }
16873
16915
  }
16874
16916
  runSimpleHooks(hooks.PostMessageComplete, options.workDir);
16875
- completedCleanly = true;
16917
+ stopReason = "clean";
16876
16918
  break;
16877
16919
  }
16878
16920
  const toolResults = await Promise.all(toolUseBlocks.map(async (block) => {
@@ -17006,7 +17048,7 @@ ${result.output}` : `Error: ${result.error}` : result.output ?? "",
17006
17048
  const allErrored = toolResults.length > 0 && errored.length === toolResults.length;
17007
17049
  consecutiveErrorRounds = allErrored ? consecutiveErrorRounds + 1 : 0;
17008
17050
  if (consecutiveErrorRounds >= STALL_LIMIT) {
17009
- stalledOut = true;
17051
+ stopReason = "stalled";
17010
17052
  break;
17011
17053
  }
17012
17054
  const errSignature = errorRoundSignature(errored.map(({ block, result }) => ({ name: block.name, error: String(result.error) })));
@@ -17017,7 +17059,7 @@ ${result.output}` : `Error: ${result.error}` : result.output ?? "",
17017
17059
  lastErrorSignature = errSignature;
17018
17060
  }
17019
17061
  if (repeatedErrorRounds >= REPEAT_STALL_LIMIT) {
17020
- stalledOut = true;
17062
+ stopReason = "stalled-repeat";
17021
17063
  stalledRepeatError = errored[0] ? String(errored[0].result.error).slice(0, 300) : null;
17022
17064
  break;
17023
17065
  }
@@ -17028,21 +17070,13 @@ ${result.output}` : `Error: ${result.error}` : result.output ?? "",
17028
17070
  `);
17029
17071
  }
17030
17072
  }
17031
- if (!options.abortSignal?.aborted && !completedCleanly) {
17032
- if (stalledOut) {
17033
- (options.onNotice ?? options.onText)(stalledRepeatError ? `
17034
- \u{1F6D1} Stopped: the same tool error repeated ${REPEAT_STALL_LIMIT} rounds in a row, so the agent was looping without making progress. The recurring error was:
17035
- ${stalledRepeatError}
17036
- Fix that underlying cause (or grant the needed permission) and send "continue".
17037
- ` : `
17038
- \u{1F6D1} Stopped: the last ${STALL_LIMIT} tool rounds all failed, so the agent looked stuck. Fix the underlying error (or grant the needed permission) and send "continue".
17039
- `);
17040
- } else if (iteration >= budget) {
17041
- (options.onNotice ?? options.onText)(`
17042
- \u23F8\uFE0F Stopped at the ${budget}-step safety limit \u2014 the task may be incomplete. Send "continue" to resume, or raise the limit via "maxIterations" in .nexrall/settings.json (or the NEXRALL_MAX_ITERATIONS env var). Auto-continue can be disabled with "autoContinue": false.
17043
- `);
17044
- }
17045
- }
17073
+ if (stopReason === "unknown" && iteration >= budget)
17074
+ stopReason = "budget";
17075
+ if (options.abortSignal?.aborted)
17076
+ stopReason = "aborted";
17077
+ const notice = stopReasonNotice(stopReason, { budget, repeatError: stalledRepeatError });
17078
+ if (notice)
17079
+ (options.onNotice ?? options.onText)(notice);
17046
17080
  } catch (err) {
17047
17081
  if (err instanceof types_1.AgentTurnError)
17048
17082
  throw err;
@@ -64004,7 +64038,7 @@ var InkReadlineAdapter = class extends EventEmitter3 {
64004
64038
  };
64005
64039
 
64006
64040
  // src/commands/chat.ts
64007
- var CLI_VERSION = "0.5.52";
64041
+ var CLI_VERSION = "0.5.53";
64008
64042
  var MODEL_LABELS = {
64009
64043
  turbo: "Nexrall Turbo",
64010
64044
  pro: "Nexrall Pro",
@@ -65671,7 +65705,7 @@ function pluginSourceRemoveCommand(name, opts) {
65671
65705
 
65672
65706
  // src/index.ts
65673
65707
  var program2 = new Command();
65674
- program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.52").enablePositionalOptions();
65708
+ program2.name("nex").description("Nexrall Code \u2014 AI coding assistant (powered by Nexrall)").version("0.5.53").enablePositionalOptions();
65675
65709
  program2.command("auth").description("Login to your Nexrall account").action(authCommand);
65676
65710
  program2.command("logout").description("Log out of your Nexrall account").action(logoutCommand);
65677
65711
  program2.command("update").description("Update nex to the latest version").option("-c, --check", "Check for updates without installing").option("-y, --yes", "Skip confirmation prompt").action(async (opts) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexrall-code",
3
- "version": "0.5.52",
3
+ "version": "0.5.53",
4
4
  "description": "Nexrall Code — AI coding assistant for your terminal (headless agent for scripts, CI and automation)",
5
5
  "keywords": [
6
6
  "ai",
@@ -41,7 +41,7 @@
41
41
  "react": "^19.2.8",
42
42
  "readline": "^1.3.0",
43
43
  "string-width": "^7.2.0",
44
- "@nexrall/code-core": "1.4.27"
44
+ "@nexrall/code-core": "1.4.28"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@aws-sdk/client-s3": "^3.600.0",