@ai-matrx/content-ir 0.23.0 → 0.24.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/source.js CHANGED
@@ -3031,7 +3031,7 @@ function collapseGaps(text) {
3031
3031
  }
3032
3032
  return out + text.slice(at).replace(/\n{3,}/g, "\n\n");
3033
3033
  }
3034
- var OPEN_TAG = /<(thinking|reasoning)\b[^>]*>/gi;
3034
+ var OPEN_TAG = /<(thinking|think|reasoning)\b[^>]*>/gi;
3035
3035
  function removeClosedBlocks(input, live) {
3036
3036
  let text = input;
3037
3037
  for (; ; ) {
@@ -3055,7 +3055,20 @@ function removeClosedBlocks(input, live) {
3055
3055
  }
3056
3056
  }
3057
3057
  if (!closer) return { text, openAt: opener.index };
3058
- text = text.slice(0, opener.index) + text.slice(closer.index + closer[0].length);
3058
+ let start = opener.index;
3059
+ let end = closer.index + closer[0].length;
3060
+ let before = 0;
3061
+ let after = 0;
3062
+ while (start > 0 && text[start - 1] === "\n") {
3063
+ start--;
3064
+ before++;
3065
+ }
3066
+ while (end < text.length && text[end] === "\n") {
3067
+ end++;
3068
+ after++;
3069
+ }
3070
+ const gap = before >= 2 || after >= 2 ? "\n\n" : before + after > 0 ? "\n" : "";
3071
+ text = text.slice(0, start) + gap + text.slice(end);
3059
3072
  }
3060
3073
  }
3061
3074
  function stripThinking(input) {