@swestash/agent-lens 0.3.0 → 0.4.0

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.
@@ -1760,6 +1760,8 @@ function flattenText(content) {
1760
1760
  const text = parts.join("\n").trim();
1761
1761
  return text || null;
1762
1762
  }
1763
+ var RESULT_SUMMARY_MAX_LINES = 40;
1764
+ var RESULT_SUMMARY_MAX_CHARS = 2e3;
1763
1765
  function summarizeResult(content) {
1764
1766
  let s = null;
1765
1767
  if (typeof content === "string")
@@ -1777,8 +1779,24 @@ function summarizeResult(content) {
1777
1779
  }
1778
1780
  if (!s)
1779
1781
  return null;
1780
- s = s.replace(/\s+/g, " ").trim();
1781
- return s.slice(0, 280) || null;
1782
+ s = s.replace(/\r\n/g, "\n").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
1783
+ if (!s)
1784
+ return null;
1785
+ let truncated = false;
1786
+ const lines = s.split("\n");
1787
+ if (lines.length > RESULT_SUMMARY_MAX_LINES) {
1788
+ s = lines.slice(0, RESULT_SUMMARY_MAX_LINES).join("\n");
1789
+ truncated = true;
1790
+ }
1791
+ if (s.length > RESULT_SUMMARY_MAX_CHARS) {
1792
+ s = s.slice(0, RESULT_SUMMARY_MAX_CHARS);
1793
+ const nl = s.lastIndexOf("\n");
1794
+ if (nl > RESULT_SUMMARY_MAX_CHARS - 200)
1795
+ s = s.slice(0, nl);
1796
+ truncated = true;
1797
+ }
1798
+ s = s.trimEnd();
1799
+ return (truncated ? s + "\n\u2026 (truncated)" : s) || null;
1782
1800
  }
1783
1801
  function asString(v) {
1784
1802
  return typeof v === "string" && v.length > 0 ? v : null;