@corbat-tech/coco 2.20.1 → 2.21.1

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/dist/cli/index.js CHANGED
@@ -10461,8 +10461,9 @@ function isNonRetryableProviderError(error) {
10461
10461
  if (error instanceof ProviderError) {
10462
10462
  const code = error.statusCode;
10463
10463
  if (code === 401 || code === 403) return true;
10464
+ if (code === 400) return true;
10464
10465
  const msg = error.message.toLowerCase();
10465
- if (msg.includes("exceeded your current quota") || msg.includes("usage limit") || msg.includes("insufficient_quota") || msg.includes("billing") || msg.includes("payment") || msg.includes("invalid_api_key") || msg.includes("incorrect api key") || msg.includes("bad credentials") || msg.includes("not authorized")) {
10466
+ if (msg.includes("exceeded your current quota") || msg.includes("usage limit") || msg.includes("insufficient_quota") || msg.includes("billing") || msg.includes("payment") || msg.includes("invalid_api_key") || msg.includes("incorrect api key") || msg.includes("bad credentials") || msg.includes("not authorized") || msg.includes("unsupported parameter")) {
10466
10467
  return true;
10467
10468
  }
10468
10469
  }
@@ -11148,9 +11149,7 @@ function renderFileBlock(file, opts) {
11148
11149
  content = wordHighlights.get(delIdx).styledAdd;
11149
11150
  } else {
11150
11151
  content = line.content;
11151
- }
11152
- if (lang) {
11153
- content = highlightLine(content, lang);
11152
+ if (lang) content = highlightLine(content, lang);
11154
11153
  }
11155
11154
  const lineStr = `${lineNo}${prefix} ${content}`;
11156
11155
  console.log(bgAddLine(lineStr));
@@ -11161,9 +11160,7 @@ function renderFileBlock(file, opts) {
11161
11160
  content = wordHighlights.get(li).styledDelete;
11162
11161
  } else {
11163
11162
  content = line.content;
11164
- }
11165
- if (lang) {
11166
- content = highlightLine(content, lang);
11163
+ if (lang) content = highlightLine(content, lang);
11167
11164
  }
11168
11165
  const lineStr = `${lineNo}${prefix} ${content}`;
11169
11166
  console.log(bgDeleteLine(lineStr));
@@ -11177,12 +11174,12 @@ function renderFileBlock(file, opts) {
11177
11174
  }
11178
11175
  }
11179
11176
  }
11180
- console.log();
11181
11177
  }
11182
11178
  function formatLineNo(line, show) {
11183
11179
  if (!show) return "";
11184
- const lineNo = line.type === "delete" ? line.oldLineNo : line.newLineNo;
11185
- return chalk2.dim(`${String(lineNo ?? "").padStart(5)} `);
11180
+ const oldStr = line.oldLineNo !== void 0 ? String(line.oldLineNo) : "";
11181
+ const newStr = line.newLineNo !== void 0 ? String(line.newLineNo) : "";
11182
+ return chalk2.dim(`${oldStr.padStart(4)} | ${newStr.padStart(4)} `);
11186
11183
  }
11187
11184
  function getChangedLines(diff) {
11188
11185
  const result = /* @__PURE__ */ new Map();
@@ -47698,7 +47695,7 @@ function wordLevelHighlight(deletedContent, addedContent) {
47698
47695
  return { styledDelete, styledAdd };
47699
47696
  }
47700
47697
  function printEditDiff(oldStr, newStr) {
47701
- const termWidth = Math.max(getTerminalWidth2() - 14, 30);
47698
+ const termWidth = Math.max(getTerminalWidth2() - 15, 30);
47702
47699
  const MAX_SHOWN = 30;
47703
47700
  if (!oldStr.trim()) {
47704
47701
  const lines = newStr.split("\n").filter((l) => l.trim().length > 0).slice(0, 6);
@@ -50080,6 +50077,9 @@ ${tail}`;
50080
50077
  if (isAbortError(streamError, options.signal)) {
50081
50078
  return abortReturn();
50082
50079
  }
50080
+ if (isNonRetryableProviderError(streamError)) {
50081
+ throw streamError;
50082
+ }
50083
50083
  const errorMsg = streamError instanceof Error ? streamError.message : String(streamError);
50084
50084
  addMessage(session, {
50085
50085
  role: "assistant",
@@ -51780,6 +51780,8 @@ ${imagePrompts}`.trim() : imagePrompts;
51780
51780
  console.log(chalk2.dim(" Recovery failed after multiple attempts. Returning to prompt."));
51781
51781
  continue;
51782
51782
  }
51783
+ session.messages.length = preCallMessageLength;
51784
+ consecutiveErrors = 0;
51783
51785
  renderError(errorMsg);
51784
51786
  } finally {
51785
51787
  clearSpinner();