@absolutejs/absolute 0.19.0-beta.644 → 0.19.0-beta.646

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.
@@ -730,6 +730,7 @@ var buildContextLabel = (metadata) => {
730
730
  return;
731
731
  }
732
732
  const emailKind = getContextString(metadata.emailKind);
733
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
733
734
  if (emailKind === "attachment") {
734
735
  return "Attachment evidence";
735
736
  }
@@ -767,6 +768,16 @@ var buildContextLabel = (metadata) => {
767
768
  }
768
769
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
769
770
  const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
771
+ const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
772
+ if (officeBlockKind === "table" && officeSectionLabel) {
773
+ return `Office table block ${officeSectionLabel}`;
774
+ }
775
+ if (officeBlockKind === "list" && officeSectionLabel) {
776
+ return `Office list block ${officeSectionLabel}`;
777
+ }
778
+ if (officeBlockKind === "paragraph" && officeSectionLabel) {
779
+ return `Office paragraph block ${officeSectionLabel}`;
780
+ }
770
781
  if (sectionTitle) {
771
782
  return `Section ${sectionTitle}`;
772
783
  }
@@ -788,6 +799,46 @@ var formatMediaDurationLabel = (value) => {
788
799
  }
789
800
  return formatMediaTimestamp(value);
790
801
  };
802
+ var formatOfficeListLevelsLabel = (value) => {
803
+ if (!Array.isArray(value) || value.length === 0) {
804
+ return;
805
+ }
806
+ const levels = value.map((entry) => getContextNumber(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
807
+ if (levels.length === 0) {
808
+ return;
809
+ }
810
+ const minLevel = levels[0];
811
+ const maxLevel = levels[levels.length - 1];
812
+ return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
813
+ };
814
+ var getOfficeTableCitationScope = (metadata) => {
815
+ if (!metadata) {
816
+ return;
817
+ }
818
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
819
+ if (officeBlockKind !== "table" && officeBlockKind !== "list") {
820
+ return;
821
+ }
822
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
823
+ const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
824
+ const officeContextText = officeBlockKind === "table" ? getContextString(metadata.officeTableContextText) : getContextString(metadata.officeListContextText);
825
+ if (!sectionTitle) {
826
+ return;
827
+ }
828
+ return {
829
+ blockKind: officeBlockKind,
830
+ pathDepth: sectionPath.length,
831
+ sectionTitle,
832
+ hasContext: typeof officeContextText === "string"
833
+ };
834
+ };
835
+ var getOfficeTableCitationPreference = (metadata) => {
836
+ const scope = getOfficeTableCitationScope(metadata);
837
+ if (!scope) {
838
+ return 0;
839
+ }
840
+ return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
841
+ };
791
842
  var buildLocatorLabel = (metadata, source, title) => {
792
843
  if (!metadata) {
793
844
  return;
@@ -813,6 +864,10 @@ var buildLocatorLabel = (metadata, source, title) => {
813
864
  return `Archive entry ${archiveEntry}`;
814
865
  }
815
866
  const emailKind = getContextString(metadata.emailKind);
867
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
868
+ const officeBlockNumber = getContextNumber(metadata.officeBlockNumber);
869
+ const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
870
+ const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
816
871
  if (emailKind === "attachment") {
817
872
  const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
818
873
  return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
@@ -825,6 +880,18 @@ var buildLocatorLabel = (metadata, source, title) => {
825
880
  if (mediaStart) {
826
881
  return `Timestamp ${mediaStart}`;
827
882
  }
883
+ if (officeBlockNumber && officeBlockKind === "table") {
884
+ if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
885
+ return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
886
+ }
887
+ return `Office table block ${officeBlockNumber}`;
888
+ }
889
+ if (officeBlockNumber && officeBlockKind === "list") {
890
+ return `Office list block ${officeBlockNumber}`;
891
+ }
892
+ if (officeBlockNumber && officeBlockKind === "paragraph") {
893
+ return `Office paragraph block ${officeBlockNumber}`;
894
+ }
828
895
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
829
896
  if (sectionPath.length > 0) {
830
897
  return `Section ${sectionPath.join(" > ")}`;
@@ -858,10 +925,31 @@ var buildProvenanceLabel = (metadata) => {
858
925
  const mediaDurationLabel = formatMediaDurationLabel(metadata.mediaDurationMs);
859
926
  const transcriptSource = getContextString(metadata.transcriptSource);
860
927
  const pdfTextMode = getContextString(metadata.pdfTextMode);
928
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
929
+ const officeListContextText = getContextString(metadata.officeListContextText);
930
+ const officeListGroupItemCount = getContextNumber(metadata.officeListGroupItemCount);
931
+ const officeListLevelsLabel = formatOfficeListLevelsLabel(metadata.officeListLevels);
932
+ const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
933
+ const officeTableColumnCount = getContextNumber(metadata.officeTableColumnCount);
934
+ const officeTableBodyRowCount = getContextNumber(metadata.officeTableBodyRowCount);
935
+ const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
936
+ const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
937
+ const officeTableContextText = getContextString(metadata.officeTableContextText);
938
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
861
939
  const ocrEngine = getContextString(metadata.ocrEngine);
862
940
  const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
863
941
  const labels = [
864
942
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
943
+ officeBlockKind ? `Office ${officeBlockKind}` : "",
944
+ typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
945
+ officeListLevelsLabel ?? "",
946
+ sectionPath.length > 0 && officeBlockKind ? `Source-aware office ${officeBlockKind} block ${sectionPath.join(" > ")}` : "",
947
+ officeListContextText ? `Office list context ${officeListContextText}` : "",
948
+ officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
949
+ typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
950
+ typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
951
+ typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
952
+ officeTableContextText ? `Office table context ${officeTableContextText}` : "",
865
953
  ocrEngine ? `OCR ${ocrEngine}` : "",
866
954
  typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
867
955
  mediaKind ? `Media ${mediaKind}` : "",
@@ -1025,6 +1113,15 @@ var buildRAGCitations = (sources) => {
1025
1113
  });
1026
1114
  }
1027
1115
  return [...unique.values()].sort((left, right) => {
1116
+ const leftOfficeScope = getOfficeTableCitationScope(left.metadata);
1117
+ const rightOfficeScope = getOfficeTableCitationScope(right.metadata);
1118
+ if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
1119
+ const leftOfficePreference = getOfficeTableCitationPreference(left.metadata);
1120
+ const rightOfficePreference = getOfficeTableCitationPreference(right.metadata);
1121
+ if (rightOfficePreference !== leftOfficePreference) {
1122
+ return rightOfficePreference - leftOfficePreference;
1123
+ }
1124
+ }
1028
1125
  if (right.score !== left.score) {
1029
1126
  return right.score - left.score;
1030
1127
  }
@@ -1597,6 +1694,7 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1597
1694
  const sectionKind = getContextString2(metadata.sectionKind);
1598
1695
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
1599
1696
  const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
1697
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1600
1698
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1601
1699
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1602
1700
  const sheetName = getContextString2(metadata.sheetName);
@@ -1607,6 +1705,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1607
1705
  return `Source-aware section ${sectionPath.join(" > ")}`;
1608
1706
  }
1609
1707
  if (sectionKind === "pdf_block") {
1708
+ if (pdfSemanticRole === "figure_caption" && sectionTitle) {
1709
+ return `Source-aware PDF figure caption ${sectionTitle}`;
1710
+ }
1711
+ if (pdfSemanticRole === "figure_body" && sectionTitle) {
1712
+ return `Source-aware PDF figure body ${sectionTitle}`;
1713
+ }
1610
1714
  if (pdfTextKind === "table_like" && sectionTitle) {
1611
1715
  return `Source-aware PDF table block ${sectionTitle}`;
1612
1716
  }
@@ -1616,11 +1720,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1616
1720
  return "Source-aware PDF block";
1617
1721
  }
1618
1722
  if (sectionKind === "office_block") {
1619
- if (officeBlockKind && sectionTitle) {
1620
- return `Source-aware office ${officeBlockKind} block ${sectionTitle}`;
1723
+ const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
1724
+ if (officeBlockKind && officeSectionLabel) {
1725
+ return `Source-aware office ${officeBlockKind} block ${officeSectionLabel}`;
1621
1726
  }
1622
- if (sectionTitle) {
1623
- return `Source-aware office block ${sectionTitle}`;
1727
+ if (officeSectionLabel) {
1728
+ return `Source-aware office block ${officeSectionLabel}`;
1624
1729
  }
1625
1730
  return "Source-aware office block";
1626
1731
  }
@@ -1702,6 +1807,18 @@ var formatSpreadsheetTableLabel = (tableIndex, tableCount) => {
1702
1807
  }
1703
1808
  return `Table ${tableIndex}`;
1704
1809
  };
1810
+ var formatOfficeListLevelsLabel2 = (value) => {
1811
+ if (!Array.isArray(value) || value.length === 0) {
1812
+ return;
1813
+ }
1814
+ const levels = value.map((entry) => getContextNumber2(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
1815
+ if (levels.length === 0) {
1816
+ return;
1817
+ }
1818
+ const minLevel = levels[0];
1819
+ const maxLevel = levels[levels.length - 1];
1820
+ return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
1821
+ };
1705
1822
  var formatMediaDurationLabel2 = (value) => {
1706
1823
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
1707
1824
  return;
@@ -1713,9 +1830,18 @@ var buildContextLabel2 = (metadata) => {
1713
1830
  return;
1714
1831
  }
1715
1832
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1833
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1834
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
1835
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1716
1836
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1717
1837
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
1718
1838
  const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
1839
+ if (pdfSemanticRole === "figure_caption" && sectionTitle) {
1840
+ return `PDF figure caption ${sectionTitle}`;
1841
+ }
1842
+ if (pdfSemanticRole === "figure_body" && sectionTitle) {
1843
+ return `PDF figure body ${sectionTitle}`;
1844
+ }
1719
1845
  if (pdfTextKind === "table_like" && sectionTitle) {
1720
1846
  return `PDF table block ${sectionTitle}`;
1721
1847
  }
@@ -1723,13 +1849,13 @@ var buildContextLabel2 = (metadata) => {
1723
1849
  return `PDF text block ${sectionTitle}`;
1724
1850
  }
1725
1851
  if (officeBlockKind === "table" && sectionTitle) {
1726
- return `Office table block ${sectionTitle}`;
1852
+ return `Office table block ${sectionPath.join(" > ") || sectionTitle}`;
1727
1853
  }
1728
1854
  if (officeBlockKind === "list" && sectionTitle) {
1729
- return `Office list block ${sectionTitle}`;
1855
+ return `Office list block ${sectionPath.join(" > ") || sectionTitle}`;
1730
1856
  }
1731
1857
  if (officeBlockKind === "paragraph" && sectionTitle) {
1732
- return `Office paragraph block ${sectionTitle}`;
1858
+ return `Office paragraph block ${sectionPath.join(" > ") || sectionTitle}`;
1733
1859
  }
1734
1860
  const emailKind = getContextString2(metadata.emailKind);
1735
1861
  if (emailKind === "attachment") {
@@ -1827,9 +1953,14 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1827
1953
  return;
1828
1954
  }
1829
1955
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1956
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1830
1957
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1831
1958
  const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
1959
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
1960
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1832
1961
  const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
1962
+ const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
1963
+ const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
1833
1964
  const spreadsheetRowStart = getContextNumber2(metadata.spreadsheetRowStart);
1834
1965
  const spreadsheetRowEnd = getContextNumber2(metadata.spreadsheetRowEnd);
1835
1966
  const slideTitle = getContextString2(metadata.slideTitle);
@@ -1840,7 +1971,16 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1840
1971
  if (page && region) {
1841
1972
  return `Page ${page} · Region ${region}`;
1842
1973
  }
1974
+ if (page && pdfBlockNumber && pdfSemanticRole === "figure_caption") {
1975
+ return `Page ${page} · Figure Caption ${pdfBlockNumber}`;
1976
+ }
1977
+ if (page && pdfBlockNumber && pdfSemanticRole === "figure_body") {
1978
+ return `Page ${page} · Figure Body ${pdfBlockNumber}`;
1979
+ }
1843
1980
  if (page && pdfBlockNumber && pdfTextKind === "table_like") {
1981
+ if (typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number") {
1982
+ return pdfTableBodyRowStart === pdfTableBodyRowEnd ? `Page ${page} · Table Block ${pdfBlockNumber} · Row ${pdfTableBodyRowStart}` : `Page ${page} · Table Block ${pdfBlockNumber} · Rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}`;
1983
+ }
1844
1984
  return `Page ${page} · Table Block ${pdfBlockNumber}`;
1845
1985
  }
1846
1986
  if (page && pdfBlockNumber) {
@@ -1903,6 +2043,9 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1903
2043
  return `Timestamp ${mediaStart}`;
1904
2044
  }
1905
2045
  if (officeBlockNumber && officeBlockKind === "table") {
2046
+ if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
2047
+ return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
2048
+ }
1906
2049
  return `Office table block ${officeBlockNumber}`;
1907
2050
  }
1908
2051
  if (officeBlockNumber && officeBlockKind === "list") {
@@ -1939,11 +2082,27 @@ var buildProvenanceLabel2 = (metadata) => {
1939
2082
  const mediaSegmentWindowDurationLabel = formatMediaDurationLabel2(metadata.mediaSegmentGroupDurationMs);
1940
2083
  const mediaSegmentGapLabel = formatMediaDurationLabel2(metadata.mediaSegmentGapFromPreviousMs);
1941
2084
  const spreadsheetHeaders = getSpreadsheetHeaders(metadata);
2085
+ const pdfTableHeaders = Array.isArray(metadata.pdfTableHeaders) ? metadata.pdfTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2086
+ const pdfTableColumnCount = getContextNumber2(metadata.pdfTableColumnCount);
2087
+ const pdfTableBodyRowCount = getContextNumber2(metadata.pdfTableBodyRowCount);
1942
2088
  const spreadsheetColumnRange = formatSpreadsheetColumnRange(getContextString2(metadata.spreadsheetColumnStart), getContextString2(metadata.spreadsheetColumnEnd));
1943
2089
  const slideNotesText = getContextString2(metadata.slideNotesText);
1944
2090
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
2091
+ const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
2092
+ const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
2093
+ const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
1945
2094
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
2095
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1946
2096
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
2097
+ const officeListContextText = getContextString2(metadata.officeListContextText);
2098
+ const officeListGroupItemCount = getContextNumber2(metadata.officeListGroupItemCount);
2099
+ const officeListLevelsLabel = formatOfficeListLevelsLabel2(metadata.officeListLevels);
2100
+ const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2101
+ const officeTableColumnCount = getContextNumber2(metadata.officeTableColumnCount);
2102
+ const officeTableBodyRowCount = getContextNumber2(metadata.officeTableBodyRowCount);
2103
+ const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
2104
+ const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
2105
+ const officeTableContextText = getContextString2(metadata.officeTableContextText);
1947
2106
  const ocrEngine = getContextString2(metadata.ocrEngine);
1948
2107
  const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
1949
2108
  const chunkingProfile = getContextString2(metadata.chunkingProfile);
@@ -1959,10 +2118,19 @@ var buildProvenanceLabel2 = (metadata) => {
1959
2118
  const ocrMinConfidence = getContextNumber2(metadata.ocrPageMinConfidence) ?? getContextNumber2(metadata.ocrMinConfidence);
1960
2119
  const ocrMaxConfidence = getContextNumber2(metadata.ocrPageMaxConfidence) ?? getContextNumber2(metadata.ocrMaxConfidence);
1961
2120
  const ocrRegionCount = getContextNumber2(metadata.ocrRegionCount);
2121
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
2122
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1962
2123
  const labels = [
1963
2124
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
1964
- pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
2125
+ pdfEvidenceMode ? `PDF evidence ${pdfEvidenceMode}` : "",
2126
+ pdfEvidenceOrigin ? `PDF origin ${pdfEvidenceOrigin}` : "",
2127
+ pdfEvidenceSupplement ? `PDF supplement ${pdfEvidenceSupplement}` : "",
2128
+ pdfSemanticRole === "figure_caption" ? "PDF figure caption" : "",
2129
+ pdfSemanticRole === "figure_body" ? "PDF figure body" : "",
2130
+ pdfSemanticRole === "figure_caption" ? "" : pdfSemanticRole === "figure_body" ? "" : pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
1965
2131
  officeBlockKind ? `Office ${officeBlockKind}` : "",
2132
+ typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
2133
+ officeListLevelsLabel ?? "",
1966
2134
  ocrEngine ? `OCR ${ocrEngine}` : "",
1967
2135
  extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
1968
2136
  chunkingProfile ? `Chunking ${chunkingProfile}` : "",
@@ -1972,6 +2140,16 @@ var buildProvenanceLabel2 = (metadata) => {
1972
2140
  typeof ocrAverageConfidence === "number" && ocrAverageConfidence !== ocrConfidence ? `Average ${ocrAverageConfidence.toFixed(2)}` : "",
1973
2141
  typeof ocrMinConfidence === "number" && typeof ocrMaxConfidence === "number" && ocrMinConfidence !== ocrMaxConfidence ? `Range ${ocrMinConfidence.toFixed(2)}-${ocrMaxConfidence.toFixed(2)}` : "",
1974
2142
  typeof ocrRegionCount === "number" ? `${ocrRegionCount} regions` : "",
2143
+ pdfTableHeaders.length > 0 ? `PDF table ${pdfTableHeaders.join(", ")}` : "",
2144
+ typeof pdfTableColumnCount === "number" ? `PDF table ${pdfTableColumnCount} cols` : "",
2145
+ typeof pdfTableBodyRowCount === "number" ? `PDF table ${pdfTableBodyRowCount} body rows` : "",
2146
+ typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number" ? pdfTableBodyRowStart === pdfTableBodyRowEnd ? `PDF table row ${pdfTableBodyRowStart}` : `PDF table rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}` : "",
2147
+ officeListContextText ? `Office list context ${officeListContextText}` : "",
2148
+ officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
2149
+ typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
2150
+ typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
2151
+ typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
2152
+ officeTableContextText ? `Office table context ${officeTableContextText}` : "",
1975
2153
  spreadsheetHeaders.length > 0 ? `Spreadsheet ${spreadsheetHeaders.join(", ")}` : "",
1976
2154
  spreadsheetColumnRange ? `Spreadsheet ${spreadsheetColumnRange}` : "",
1977
2155
  spreadsheetTableLabel ? `Spreadsheet ${spreadsheetTableLabel}` : "",
@@ -2403,12 +2581,92 @@ var getStructuredSectionScoreWeight = (metadata) => {
2403
2581
  return 1;
2404
2582
  };
2405
2583
  var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
2584
+ var getPDFLeadEvidencePreference = (metadata) => {
2585
+ if (!metadata) {
2586
+ return 0;
2587
+ }
2588
+ const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
2589
+ const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
2590
+ const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
2591
+ if (pdfEvidenceMode === "hybrid" && pdfEvidenceOrigin === "native" && pdfEvidenceSupplement === "ocr") {
2592
+ return 3;
2593
+ }
2594
+ if (pdfEvidenceMode === "native" && pdfEvidenceOrigin === "native") {
2595
+ return 2;
2596
+ }
2597
+ if (pdfEvidenceMode === "ocr" && pdfEvidenceOrigin === "ocr") {
2598
+ return 1;
2599
+ }
2600
+ return 0;
2601
+ };
2602
+ var getPDFLeadScope = (metadata) => {
2603
+ if (!metadata) {
2604
+ return;
2605
+ }
2606
+ const pageNumber = getContextNumber2(metadata.pageNumber) ?? getContextNumber2(metadata.page) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
2607
+ const sectionTitle = getContextString2(metadata.sectionTitle);
2608
+ const sourceNativeKind = getContextString2(metadata.sourceNativeKind);
2609
+ if (typeof pageNumber !== "number" && !sectionTitle && !sourceNativeKind) {
2610
+ return;
2611
+ }
2612
+ return {
2613
+ pageNumber,
2614
+ sectionTitle,
2615
+ sourceNativeKind
2616
+ };
2617
+ };
2618
+ var getOfficeLeadScope = (metadata) => {
2619
+ if (!metadata) {
2620
+ return;
2621
+ }
2622
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
2623
+ if (officeBlockKind !== "table" && officeBlockKind !== "list") {
2624
+ return;
2625
+ }
2626
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2627
+ const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
2628
+ const officeContextText = officeBlockKind === "table" ? getContextString2(metadata.officeTableContextText) : getContextString2(metadata.officeListContextText);
2629
+ if (!sectionTitle) {
2630
+ return;
2631
+ }
2632
+ return {
2633
+ blockKind: officeBlockKind,
2634
+ pathDepth: sectionPath.length,
2635
+ sectionTitle,
2636
+ hasContext: typeof officeContextText === "string"
2637
+ };
2638
+ };
2639
+ var getOfficeLeadEvidencePreference = (metadata) => {
2640
+ const scope = getOfficeLeadScope(metadata);
2641
+ if (!scope) {
2642
+ return 0;
2643
+ }
2644
+ return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
2645
+ };
2406
2646
  var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
2647
+ const leftOfficeScope = getOfficeLeadScope(left.metadata);
2648
+ const rightOfficeScope = getOfficeLeadScope(right.metadata);
2649
+ if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
2650
+ const leftOfficePreference = getOfficeLeadEvidencePreference(left.metadata);
2651
+ const rightOfficePreference = getOfficeLeadEvidencePreference(right.metadata);
2652
+ if (rightOfficePreference !== leftOfficePreference) {
2653
+ return rightOfficePreference - leftOfficePreference;
2654
+ }
2655
+ }
2407
2656
  const leftWeightedScore = getStructuredSourceLeadScore(left);
2408
2657
  const rightWeightedScore = getStructuredSourceLeadScore(right);
2409
2658
  if (rightWeightedScore !== leftWeightedScore) {
2410
2659
  return rightWeightedScore - leftWeightedScore;
2411
2660
  }
2661
+ const leftScope = getPDFLeadScope(left.metadata);
2662
+ const rightScope = getPDFLeadScope(right.metadata);
2663
+ if (left.source === right.source && leftScope && rightScope && (leftScope.sectionTitle && rightScope.sectionTitle && leftScope.sectionTitle === rightScope.sectionTitle || typeof leftScope.pageNumber === "number" && typeof rightScope.pageNumber === "number" && leftScope.pageNumber === rightScope.pageNumber)) {
2664
+ const leftEvidencePreference = getPDFLeadEvidencePreference(left.metadata);
2665
+ const rightEvidencePreference = getPDFLeadEvidencePreference(right.metadata);
2666
+ if (rightEvidencePreference !== leftEvidencePreference) {
2667
+ return rightEvidencePreference - leftEvidencePreference;
2668
+ }
2669
+ }
2412
2670
  if (right.score !== left.score) {
2413
2671
  return right.score - left.score;
2414
2672
  }
@@ -2662,6 +2920,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
2662
2920
  queryTransformProvider: trace?.queryTransformProvider,
2663
2921
  queryTransformReason: trace?.queryTransformReason,
2664
2922
  reasons,
2923
+ evidenceReconcileApplied: trace?.steps.some((step) => step.stage === "evidence_reconcile"),
2665
2924
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
2666
2925
  scoreShare,
2667
2926
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
@@ -3312,12 +3571,21 @@ var createRAGClient = (options) => {
3312
3571
  if (typeof input?.limit === "number") {
3313
3572
  searchParams.set("limit", String(input.limit));
3314
3573
  }
3574
+ if (typeof input?.runLimit === "number") {
3575
+ searchParams.set("runLimit", String(input.runLimit));
3576
+ }
3315
3577
  if (input?.label) {
3316
3578
  searchParams.set("label", input.label);
3317
3579
  }
3318
3580
  if (input?.description) {
3319
3581
  searchParams.set("description", input.description);
3320
3582
  }
3583
+ if (input?.groupKey) {
3584
+ searchParams.set("benchmarkGroupKey", input.groupKey);
3585
+ }
3586
+ if (input?.corpusGroupKey) {
3587
+ searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
3588
+ }
3321
3589
  const suffix = searchParams.size ? `?${searchParams}` : "";
3322
3590
  const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner${suffix}`);
3323
3591
  if (!response.ok) {
@@ -3329,6 +3597,35 @@ var createRAGClient = (options) => {
3329
3597
  }
3330
3598
  return payload;
3331
3599
  },
3600
+ async runAdaptiveNativePlannerBenchmark(input) {
3601
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/run`, {
3602
+ body: JSON.stringify({
3603
+ baselineRetrievalId: input?.baselineRetrievalId,
3604
+ candidateRetrievalId: input?.candidateRetrievalId,
3605
+ corpusGroupKey: input?.corpusGroupKey,
3606
+ description: input?.description,
3607
+ groupKey: input?.groupKey,
3608
+ label: input?.label,
3609
+ limit: input?.limit,
3610
+ metadata: input?.metadata,
3611
+ persistRun: input?.persistRun,
3612
+ retrievals: input?.retrievals,
3613
+ runLimit: input?.runLimit,
3614
+ tags: input?.tags,
3615
+ topK: input?.topK
3616
+ }),
3617
+ headers: jsonHeaders,
3618
+ method: "POST"
3619
+ });
3620
+ if (!response.ok) {
3621
+ throw new Error(await toErrorMessage(response));
3622
+ }
3623
+ const payload = await parseJson(response);
3624
+ if (!payload.ok) {
3625
+ throw new Error(payload.error ?? "Adaptive native planner benchmark run failed");
3626
+ }
3627
+ return payload;
3628
+ },
3332
3629
  async saveAdaptiveNativePlannerBenchmarkSnapshot(input) {
3333
3630
  const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/snapshots`, {
3334
3631
  body: JSON.stringify({
@@ -3352,6 +3649,89 @@ var createRAGClient = (options) => {
3352
3649
  }
3353
3650
  return payload;
3354
3651
  },
3652
+ async nativeBackendComparisonBenchmark(input) {
3653
+ const searchParams = new URLSearchParams;
3654
+ if (typeof input?.limit === "number") {
3655
+ searchParams.set("limit", String(input.limit));
3656
+ }
3657
+ if (typeof input?.runLimit === "number") {
3658
+ searchParams.set("runLimit", String(input.runLimit));
3659
+ }
3660
+ if (input?.label) {
3661
+ searchParams.set("label", input.label);
3662
+ }
3663
+ if (input?.description) {
3664
+ searchParams.set("description", input.description);
3665
+ }
3666
+ if (input?.groupKey) {
3667
+ searchParams.set("benchmarkGroupKey", input.groupKey);
3668
+ }
3669
+ if (input?.corpusGroupKey) {
3670
+ searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
3671
+ }
3672
+ const suffix = searchParams.size ? `?${searchParams}` : "";
3673
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison${suffix}`);
3674
+ if (!response.ok) {
3675
+ throw new Error(await toErrorMessage(response));
3676
+ }
3677
+ const payload = await parseJson(response);
3678
+ if (!payload.ok) {
3679
+ throw new Error(payload.error ?? "Native backend comparison benchmark history failed");
3680
+ }
3681
+ return payload;
3682
+ },
3683
+ async runNativeBackendComparisonBenchmark(input) {
3684
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/run`, {
3685
+ body: JSON.stringify({
3686
+ baselineRetrievalId: input?.baselineRetrievalId,
3687
+ candidateRetrievalId: input?.candidateRetrievalId,
3688
+ corpusGroupKey: input?.corpusGroupKey,
3689
+ description: input?.description,
3690
+ groupKey: input?.groupKey,
3691
+ label: input?.label,
3692
+ limit: input?.limit,
3693
+ metadata: input?.metadata,
3694
+ persistRun: input?.persistRun,
3695
+ retrievals: input?.retrievals,
3696
+ runLimit: input?.runLimit,
3697
+ tags: input?.tags,
3698
+ topK: input?.topK
3699
+ }),
3700
+ headers: jsonHeaders,
3701
+ method: "POST"
3702
+ });
3703
+ if (!response.ok) {
3704
+ throw new Error(await toErrorMessage(response));
3705
+ }
3706
+ const payload = await parseJson(response);
3707
+ if (!payload.ok) {
3708
+ throw new Error(payload.error ?? "Native backend comparison benchmark run failed");
3709
+ }
3710
+ return payload;
3711
+ },
3712
+ async saveNativeBackendComparisonBenchmarkSnapshot(input) {
3713
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/snapshots`, {
3714
+ body: JSON.stringify({
3715
+ createdAt: input?.createdAt,
3716
+ description: input?.description,
3717
+ label: input?.label,
3718
+ limit: input?.limit,
3719
+ metadata: input?.metadata,
3720
+ snapshotMetadata: input?.snapshotMetadata,
3721
+ version: input?.version
3722
+ }),
3723
+ headers: jsonHeaders,
3724
+ method: "POST"
3725
+ });
3726
+ if (!response.ok) {
3727
+ throw new Error(await toErrorMessage(response));
3728
+ }
3729
+ const payload = await parseJson(response);
3730
+ if (!payload.ok) {
3731
+ throw new Error(payload.error ?? "Native backend comparison benchmark snapshot failed");
3732
+ }
3733
+ return payload;
3734
+ },
3355
3735
  async retrievalLaneHandoffs(input) {
3356
3736
  const searchParams = new URLSearchParams;
3357
3737
  if (input?.groupKey) {