open-agents-ai 0.184.45 → 0.184.47

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 +42 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28266,6 +28266,19 @@ ${transcript}`
28266
28266
  }
28267
28267
  if (kind === "content") {
28268
28268
  content += fragment;
28269
+ if (content.length > 400 && content.length % 200 < fragment.length) {
28270
+ const half = Math.floor(content.length / 2);
28271
+ const firstHalf = content.slice(half - 150, half);
28272
+ const secondHalf = content.slice(-150);
28273
+ if (firstHalf.length >= 100 && firstHalf === secondHalf) {
28274
+ this.emit({
28275
+ type: "status",
28276
+ content: "Aborting generation \u2014 intra-response repetition detected (model stuck in text loop)",
28277
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
28278
+ });
28279
+ break;
28280
+ }
28281
+ }
28269
28282
  }
28270
28283
  this.emit({
28271
28284
  type: "stream_token",
@@ -28459,8 +28472,9 @@ ${transcript}`
28459
28472
  continue;
28460
28473
  const delta = choice.delta;
28461
28474
  const finishReason = choice.finish_reason;
28462
- if (delta?.reasoning) {
28463
- yield { type: "content", content: delta.reasoning, thinking: true };
28475
+ const reasoningToken = delta?.reasoning ?? delta?.reasoning_content;
28476
+ if (reasoningToken) {
28477
+ yield { type: "content", content: reasoningToken, thinking: true };
28464
28478
  }
28465
28479
  if (delta?.content) {
28466
28480
  yield { type: "content", content: delta.content };
@@ -53583,16 +53597,17 @@ var init_stream_renderer = __esm({
53583
53597
  this.lineStarted = false;
53584
53598
  }
53585
53599
  if (this.thinkingTokenCount % 50 === 0) {
53586
- process.stdout.write(`\x1B[1A\x1B[2K${dimText(" \u23BF ")}${dimItalic(`thinking... (${this.thinkingTokenCount} tokens)`)}
53600
+ this.writeRaw(`\x1B[1A\x1B[2K${dimText(" \u23BF ")}${dimItalic(`thinking... (${this.thinkingTokenCount} tokens)`)}
53587
53601
  `);
53588
53602
  }
53589
53603
  return;
53590
53604
  }
53591
53605
  if (this.thinkingIndicatorShown && kind === "content") {
53592
53606
  this.thinkingIndicatorShown = false;
53593
- process.stdout.write(`\x1B[1A\x1B[2K${dimText(" \u23BF ")}${dimItalic(`thought for ${this.thinkingTokenCount} tokens`)}
53607
+ this.writeRaw(`\x1B[1A\x1B[2K${dimText(" \u23BF ")}${dimItalic(`thought for ${this.thinkingTokenCount} tokens`)}
53594
53608
  `);
53595
53609
  this.thinkingTokenCount = 0;
53610
+ this.lineStarted = false;
53596
53611
  }
53597
53612
  if (kind === "tool_args" && !this.inToolArgs) {
53598
53613
  this.flushPartial(kind);
@@ -53645,8 +53660,6 @@ var init_stream_renderer = __esm({
53645
53660
  if (this.lineStarted) {
53646
53661
  process.stdout.write("\n");
53647
53662
  this.lineStarted = false;
53648
- } else {
53649
- process.stdout.write("\n");
53650
53663
  }
53651
53664
  return;
53652
53665
  }
@@ -53734,17 +53747,18 @@ var init_stream_renderer = __esm({
53734
53747
  const cropped = raw.length > maxW ? raw.slice(0, maxW - 3) + "..." : raw;
53735
53748
  rendered = this.highlightJson(cropped, false);
53736
53749
  } else {
53737
- if (raw.length > maxW) {
53750
+ if (hasNewline && raw.length > maxW) {
53738
53751
  const wrapped = this.wordWrap(raw, maxW);
53739
53752
  for (let i = 0; i < wrapped.length; i++) {
53740
53753
  const lp = i === 0 ? prefix : " ";
53741
53754
  const isLast = i === wrapped.length - 1;
53742
- this.writeRaw(dimText(lp) + this.highlightMarkdown(wrapped[i]) + (isLast && !hasNewline ? "" : "\n"));
53755
+ this.writeRaw(dimText(lp) + this.highlightMarkdown(wrapped[i]) + (isLast ? "\n" : "\n"));
53743
53756
  }
53744
- this.lineStarted = !hasNewline;
53757
+ this.lineStarted = false;
53745
53758
  return;
53746
53759
  }
53747
- rendered = this.highlightMarkdown(raw);
53760
+ const cropped = raw.length > maxW ? raw.slice(0, maxW) : raw;
53761
+ rendered = this.highlightMarkdown(cropped);
53748
53762
  }
53749
53763
  break;
53750
53764
  }
@@ -53752,9 +53766,15 @@ var init_stream_renderer = __esm({
53752
53766
  this.writeRaw(dimText(prefix) + rendered + (hasNewline ? "\n" : ""));
53753
53767
  this.lineStarted = !hasNewline;
53754
53768
  }
53755
- /** Write raw ANSI text to stdout and capture for scrollback */
53769
+ /** Write raw ANSI text to stdout and capture for scrollback.
53770
+ * Wraps each write in autowrap-disable (DECAWM off) to prevent the terminal
53771
+ * from injecting line breaks when a token fragment reaches the right edge. */
53756
53772
  writeRaw(text) {
53757
- process.stdout.write(text);
53773
+ if (isTTY8) {
53774
+ process.stdout.write(`\x1B[?7l${text}\x1B[?7h`);
53775
+ } else {
53776
+ process.stdout.write(text);
53777
+ }
53758
53778
  if (this.onRenderedLine) {
53759
53779
  const parts = text.split("\n");
53760
53780
  for (let i = 0; i < parts.length - 1; i++) {
@@ -53767,6 +53787,16 @@ var init_stream_renderer = __esm({
53767
53787
  }
53768
53788
  /** Flush partial buffer (non-newline-terminated tokens) */
53769
53789
  flushPartial(kind) {
53790
+ if (this.lineBuffer.length === 0)
53791
+ return;
53792
+ if (this.lineBuffer.includes("<think>")) {
53793
+ this.inThinkBlock = true;
53794
+ this.lineBuffer = this.lineBuffer.replace(/<think>/g, "");
53795
+ }
53796
+ if (this.lineBuffer.includes("</think>")) {
53797
+ this.inThinkBlock = false;
53798
+ this.lineBuffer = this.lineBuffer.replace(/<\/think>/g, "");
53799
+ }
53770
53800
  if (this.lineBuffer.length === 0)
53771
53801
  return;
53772
53802
  const effectiveKind = this.inThinkBlock ? "thinking" : kind;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.184.45",
3
+ "version": "0.184.47",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",