@absolutejs/rag 0.2.0 → 0.3.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.
@@ -14824,6 +14824,8 @@ var emailStructureUnits = (value, metadata) => {
14824
14824
  return "Forwarded Headers";
14825
14825
  case "quoted_history":
14826
14826
  return "Quoted History";
14827
+ case "signature":
14828
+ return "Signature";
14827
14829
  }
14828
14830
  };
14829
14831
  const familyKeyBase = threadTopic || from || "Email Message";
@@ -17032,15 +17034,30 @@ var EMAIL_FORWARDED_HEADER_PATTERN = /^(?:from|sent|to|cc|bcc|subject|date|reply
17032
17034
  var EMAIL_FORWARDED_SEPARATOR_PATTERN = /^-{2,}\s*forwarded message\s*-{2,}$/i;
17033
17035
  var EMAIL_HTML_QUOTE_OPEN_TOKEN = "[[ABS_EMAIL_QUOTE_OPEN]]";
17034
17036
  var EMAIL_HTML_QUOTE_CLOSE_TOKEN = "[[ABS_EMAIL_QUOTE_CLOSE]]";
17037
+ var EMAIL_ATTRIBUTION_PATTERNS = [
17038
+ /^on\s.+\bwrote:$/iu,
17039
+ /^on\s.+\bat\s.+\bwrote:$/iu,
17040
+ /^-+\s*original message\s*-+$/iu,
17041
+ /^_{5,}$/u,
17042
+ /^el\s.+\bescribi\u00F3:$/iu,
17043
+ /^le\s.+\ba \u00E9crit\s*:$/iu
17044
+ ];
17045
+ var EMAIL_SIGNATURE_DELIMITER = /^--\s?$/u;
17035
17046
  var classifyEmailBodyLine = (line, currentKind) => {
17036
17047
  const trimmed = line.trim();
17037
17048
  if (!trimmed) {
17038
17049
  return currentKind;
17039
17050
  }
17051
+ if (currentKind === "signature") {
17052
+ return "signature";
17053
+ }
17054
+ if (EMAIL_SIGNATURE_DELIMITER.test(line)) {
17055
+ return "signature";
17056
+ }
17040
17057
  if (/^>+/.test(trimmed)) {
17041
17058
  return "quoted_history";
17042
17059
  }
17043
- if (/^on .+wrote:$/i.test(trimmed)) {
17060
+ if (EMAIL_ATTRIBUTION_PATTERNS.some((pattern) => pattern.test(trimmed))) {
17044
17061
  return "quoted_history";
17045
17062
  }
17046
17063
  if (EMAIL_FORWARDED_SEPARATOR_PATTERN.test(trimmed)) {
@@ -17228,16 +17245,8 @@ var scoreEmailBodyCandidate = (candidate) => {
17228
17245
  return Number.NEGATIVE_INFINITY;
17229
17246
  }
17230
17247
  const sections = parseEmailBodySections(candidate);
17231
- const structuralScore = sections.reduce((score, section) => {
17232
- if (section.kind === "forwarded_headers") {
17233
- return score + 8;
17234
- }
17235
- if (section.kind === "quoted_history") {
17236
- return score + 6 + (section.quotedDepth ?? 0);
17237
- }
17238
- return score + 1;
17239
- }, 0);
17240
- return structuralScore * 10 + Math.min(candidate.length, 5000) / 100;
17248
+ const authoredChars = sections.filter((section) => section.kind === "authored_text").reduce((total, section) => total + section.text.trim().length, 0);
17249
+ return authoredChars * 10 + Math.min(candidate.length, 5000) / 1000;
17241
17250
  };
17242
17251
  var choosePreferredEmailBodyText = (htmlText, plainText) => {
17243
17252
  const htmlScore = scoreEmailBodyCandidate(htmlText);
@@ -17334,6 +17343,12 @@ var parseEmailMimeParts = (body, contentType) => {
17334
17343
  bodyText
17335
17344
  };
17336
17345
  };
17346
+ var authoredEmailText = (text) => {
17347
+ const authored = parseEmailBodySections(text).filter((section) => section.kind === "authored_text").map((section) => section.text.trim()).filter(Boolean).join(`
17348
+
17349
+ `).trim();
17350
+ return authored || text;
17351
+ };
17337
17352
  var extractEmailText = (raw) => {
17338
17353
  const { body, headerBlock } = splitEmailMessage(raw);
17339
17354
  const headers = parseHeaderBlock(headerBlock);
@@ -31325,5 +31340,5 @@ export {
31325
31340
  RAG_NATIVE_QUERY_CANDIDATE_LIMIT
31326
31341
  };
31327
31342
 
31328
- //# debugId=86AE9E92B8164CAE64756E2164756E21
31343
+ //# debugId=03EEE30357F4429664756E2164756E21
31329
31344
  //# sourceMappingURL=index.js.map