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