@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/index.js CHANGED
@@ -7962,7 +7962,7 @@ function collapseGaps(text) {
7962
7962
  }
7963
7963
  return out + text.slice(at).replace(/\n{3,}/g, "\n\n");
7964
7964
  }
7965
- var OPEN_TAG = /<(thinking|reasoning)\b[^>]*>/gi;
7965
+ var OPEN_TAG = /<(thinking|think|reasoning)\b[^>]*>/gi;
7966
7966
  function removeClosedBlocks(input, live) {
7967
7967
  let text = input;
7968
7968
  for (; ; ) {
@@ -7986,7 +7986,20 @@ function removeClosedBlocks(input, live) {
7986
7986
  }
7987
7987
  }
7988
7988
  if (!closer) return { text, openAt: opener.index };
7989
- text = text.slice(0, opener.index) + text.slice(closer.index + closer[0].length);
7989
+ let start = opener.index;
7990
+ let end = closer.index + closer[0].length;
7991
+ let before = 0;
7992
+ let after = 0;
7993
+ while (start > 0 && text[start - 1] === "\n") {
7994
+ start--;
7995
+ before++;
7996
+ }
7997
+ while (end < text.length && text[end] === "\n") {
7998
+ end++;
7999
+ after++;
8000
+ }
8001
+ const gap = before >= 2 || after >= 2 ? "\n\n" : before + after > 0 ? "\n" : "";
8002
+ text = text.slice(0, start) + gap + text.slice(end);
7990
8003
  }
7991
8004
  }
7992
8005
  function stripThinking(input) {