@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.
package/dist/index.js CHANGED
@@ -15103,6 +15103,8 @@ var emailStructureUnits = (value, metadata) => {
15103
15103
  return "Forwarded Headers";
15104
15104
  case "quoted_history":
15105
15105
  return "Quoted History";
15106
+ case "signature":
15107
+ return "Signature";
15106
15108
  }
15107
15109
  };
15108
15110
  const familyKeyBase = threadTopic || from || "Email Message";
@@ -17311,15 +17313,30 @@ var EMAIL_FORWARDED_HEADER_PATTERN = /^(?:from|sent|to|cc|bcc|subject|date|reply
17311
17313
  var EMAIL_FORWARDED_SEPARATOR_PATTERN = /^-{2,}\s*forwarded message\s*-{2,}$/i;
17312
17314
  var EMAIL_HTML_QUOTE_OPEN_TOKEN = "[[ABS_EMAIL_QUOTE_OPEN]]";
17313
17315
  var EMAIL_HTML_QUOTE_CLOSE_TOKEN = "[[ABS_EMAIL_QUOTE_CLOSE]]";
17316
+ var EMAIL_ATTRIBUTION_PATTERNS = [
17317
+ /^on\s.+\bwrote:$/iu,
17318
+ /^on\s.+\bat\s.+\bwrote:$/iu,
17319
+ /^-+\s*original message\s*-+$/iu,
17320
+ /^_{5,}$/u,
17321
+ /^el\s.+\bescribi\u00F3:$/iu,
17322
+ /^le\s.+\ba \u00E9crit\s*:$/iu
17323
+ ];
17324
+ var EMAIL_SIGNATURE_DELIMITER = /^--\s?$/u;
17314
17325
  var classifyEmailBodyLine = (line, currentKind) => {
17315
17326
  const trimmed = line.trim();
17316
17327
  if (!trimmed) {
17317
17328
  return currentKind;
17318
17329
  }
17330
+ if (currentKind === "signature") {
17331
+ return "signature";
17332
+ }
17333
+ if (EMAIL_SIGNATURE_DELIMITER.test(line)) {
17334
+ return "signature";
17335
+ }
17319
17336
  if (/^>+/.test(trimmed)) {
17320
17337
  return "quoted_history";
17321
17338
  }
17322
- if (/^on .+wrote:$/i.test(trimmed)) {
17339
+ if (EMAIL_ATTRIBUTION_PATTERNS.some((pattern) => pattern.test(trimmed))) {
17323
17340
  return "quoted_history";
17324
17341
  }
17325
17342
  if (EMAIL_FORWARDED_SEPARATOR_PATTERN.test(trimmed)) {
@@ -17507,16 +17524,8 @@ var scoreEmailBodyCandidate = (candidate) => {
17507
17524
  return Number.NEGATIVE_INFINITY;
17508
17525
  }
17509
17526
  const sections = parseEmailBodySections(candidate);
17510
- const structuralScore = sections.reduce((score, section) => {
17511
- if (section.kind === "forwarded_headers") {
17512
- return score + 8;
17513
- }
17514
- if (section.kind === "quoted_history") {
17515
- return score + 6 + (section.quotedDepth ?? 0);
17516
- }
17517
- return score + 1;
17518
- }, 0);
17519
- return structuralScore * 10 + Math.min(candidate.length, 5000) / 100;
17527
+ const authoredChars = sections.filter((section) => section.kind === "authored_text").reduce((total, section) => total + section.text.trim().length, 0);
17528
+ return authoredChars * 10 + Math.min(candidate.length, 5000) / 1000;
17520
17529
  };
17521
17530
  var choosePreferredEmailBodyText = (htmlText, plainText) => {
17522
17531
  const htmlScore = scoreEmailBodyCandidate(htmlText);
@@ -17613,6 +17622,12 @@ var parseEmailMimeParts = (body, contentType) => {
17613
17622
  bodyText
17614
17623
  };
17615
17624
  };
17625
+ var authoredEmailText = (text) => {
17626
+ const authored = parseEmailBodySections(text).filter((section) => section.kind === "authored_text").map((section) => section.text.trim()).filter(Boolean).join(`
17627
+
17628
+ `).trim();
17629
+ return authored || text;
17630
+ };
17616
17631
  var extractEmailText = (raw) => {
17617
17632
  const { body, headerBlock } = splitEmailMessage(raw);
17618
17633
  const headers = parseHeaderBlock(headerBlock);
@@ -36346,6 +36361,7 @@ export {
36346
36361
  buildRAGAdminJobPresentation,
36347
36362
  buildRAGAdminActionPresentations,
36348
36363
  buildRAGAdminActionPresentation,
36364
+ authoredEmailText,
36349
36365
  applyRAGSQLiteStoreMigrations,
36350
36366
  applyRAGReranking,
36351
36367
  applyRAGQueryTransform,
@@ -36355,5 +36371,5 @@ export {
36355
36371
  addRAGEvaluationSuiteCase
36356
36372
  };
36357
36373
 
36358
- //# debugId=A910166B20BDB76264756E2164756E21
36374
+ //# debugId=176571A7F3C6808164756E2164756E21
36359
36375
  //# sourceMappingURL=index.js.map