@absolutejs/absolute 0.19.0-beta.643 → 0.19.0-beta.645

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.
Files changed (37) hide show
  1. package/dist/ai/client/index.js +976 -15
  2. package/dist/ai/client/index.js.map +6 -6
  3. package/dist/ai/client/ui.js +807 -15
  4. package/dist/ai/client/ui.js.map +5 -5
  5. package/dist/ai/index.js +2737 -141
  6. package/dist/ai/index.js.map +13 -13
  7. package/dist/ai/rag/quality.js +813 -15
  8. package/dist/ai/rag/quality.js.map +5 -5
  9. package/dist/ai/rag/ui.js +807 -15
  10. package/dist/ai/rag/ui.js.map +5 -5
  11. package/dist/ai-client/angular/ai/index.js +436 -8
  12. package/dist/ai-client/react/ai/index.js +436 -8
  13. package/dist/ai-client/vue/ai/index.js +436 -8
  14. package/dist/angular/ai/index.js +976 -15
  15. package/dist/angular/ai/index.js.map +6 -6
  16. package/dist/index.js +6 -6
  17. package/dist/index.js.map +2 -2
  18. package/dist/react/ai/index.js +976 -15
  19. package/dist/react/ai/index.js.map +6 -6
  20. package/dist/src/ai/client/ragClient.d.ts +74 -1
  21. package/dist/src/ai/index.d.ts +2 -1
  22. package/dist/src/ai/rag/adapters/queryPlanning.d.ts +8 -0
  23. package/dist/src/ai/rag/chat.d.ts +135 -7
  24. package/dist/src/ai/rag/index.d.ts +1 -1
  25. package/dist/src/ai/rag/presentation.d.ts +5 -1
  26. package/dist/src/ai/rag/quality.d.ts +34 -1
  27. package/dist/src/vue/ai/useRAG.d.ts +84 -0
  28. package/dist/src/vue/ai/useRAGEvaluate.d.ts +74 -0
  29. package/dist/src/vue/ai/useRAGSearch.d.ts +10 -0
  30. package/dist/svelte/ai/index.js +976 -15
  31. package/dist/svelte/ai/index.js.map +6 -6
  32. package/dist/types/ai.d.ts +115 -13
  33. package/dist/types/index.d.ts +1 -0
  34. package/dist/types/session.d.ts +16 -0
  35. package/dist/vue/ai/index.js +976 -15
  36. package/dist/vue/ai/index.js.map +6 -6
  37. package/package.json +8 -7
@@ -690,6 +690,7 @@ var buildContextLabel = (metadata) => {
690
690
  return;
691
691
  }
692
692
  const emailKind = getContextString(metadata.emailKind);
693
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
693
694
  if (emailKind === "attachment") {
694
695
  return "Attachment evidence";
695
696
  }
@@ -727,6 +728,16 @@ var buildContextLabel = (metadata) => {
727
728
  }
728
729
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
729
730
  const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
731
+ const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
732
+ if (officeBlockKind === "table" && officeSectionLabel) {
733
+ return `Office table block ${officeSectionLabel}`;
734
+ }
735
+ if (officeBlockKind === "list" && officeSectionLabel) {
736
+ return `Office list block ${officeSectionLabel}`;
737
+ }
738
+ if (officeBlockKind === "paragraph" && officeSectionLabel) {
739
+ return `Office paragraph block ${officeSectionLabel}`;
740
+ }
730
741
  if (sectionTitle) {
731
742
  return `Section ${sectionTitle}`;
732
743
  }
@@ -748,6 +759,46 @@ var formatMediaDurationLabel = (value) => {
748
759
  }
749
760
  return formatMediaTimestamp(value);
750
761
  };
762
+ var formatOfficeListLevelsLabel = (value) => {
763
+ if (!Array.isArray(value) || value.length === 0) {
764
+ return;
765
+ }
766
+ const levels = value.map((entry) => getContextNumber(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
767
+ if (levels.length === 0) {
768
+ return;
769
+ }
770
+ const minLevel = levels[0];
771
+ const maxLevel = levels[levels.length - 1];
772
+ return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
773
+ };
774
+ var getOfficeTableCitationScope = (metadata) => {
775
+ if (!metadata) {
776
+ return;
777
+ }
778
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
779
+ if (officeBlockKind !== "table" && officeBlockKind !== "list") {
780
+ return;
781
+ }
782
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
783
+ const sectionTitle = getContextString(metadata.sectionTitle) ?? sectionPath.at(-1);
784
+ const officeContextText = officeBlockKind === "table" ? getContextString(metadata.officeTableContextText) : getContextString(metadata.officeListContextText);
785
+ if (!sectionTitle) {
786
+ return;
787
+ }
788
+ return {
789
+ blockKind: officeBlockKind,
790
+ pathDepth: sectionPath.length,
791
+ sectionTitle,
792
+ hasContext: typeof officeContextText === "string"
793
+ };
794
+ };
795
+ var getOfficeTableCitationPreference = (metadata) => {
796
+ const scope = getOfficeTableCitationScope(metadata);
797
+ if (!scope) {
798
+ return 0;
799
+ }
800
+ return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
801
+ };
751
802
  var buildLocatorLabel = (metadata, source, title) => {
752
803
  if (!metadata) {
753
804
  return;
@@ -773,6 +824,10 @@ var buildLocatorLabel = (metadata, source, title) => {
773
824
  return `Archive entry ${archiveEntry}`;
774
825
  }
775
826
  const emailKind = getContextString(metadata.emailKind);
827
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
828
+ const officeBlockNumber = getContextNumber(metadata.officeBlockNumber);
829
+ const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
830
+ const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
776
831
  if (emailKind === "attachment") {
777
832
  const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
778
833
  return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
@@ -785,6 +840,18 @@ var buildLocatorLabel = (metadata, source, title) => {
785
840
  if (mediaStart) {
786
841
  return `Timestamp ${mediaStart}`;
787
842
  }
843
+ if (officeBlockNumber && officeBlockKind === "table") {
844
+ if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
845
+ return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
846
+ }
847
+ return `Office table block ${officeBlockNumber}`;
848
+ }
849
+ if (officeBlockNumber && officeBlockKind === "list") {
850
+ return `Office list block ${officeBlockNumber}`;
851
+ }
852
+ if (officeBlockNumber && officeBlockKind === "paragraph") {
853
+ return `Office paragraph block ${officeBlockNumber}`;
854
+ }
788
855
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
789
856
  if (sectionPath.length > 0) {
790
857
  return `Section ${sectionPath.join(" > ")}`;
@@ -818,10 +885,31 @@ var buildProvenanceLabel = (metadata) => {
818
885
  const mediaDurationLabel = formatMediaDurationLabel(metadata.mediaDurationMs);
819
886
  const transcriptSource = getContextString(metadata.transcriptSource);
820
887
  const pdfTextMode = getContextString(metadata.pdfTextMode);
888
+ const officeBlockKind = getContextString(metadata.officeBlockKind);
889
+ const officeListContextText = getContextString(metadata.officeListContextText);
890
+ const officeListGroupItemCount = getContextNumber(metadata.officeListGroupItemCount);
891
+ const officeListLevelsLabel = formatOfficeListLevelsLabel(metadata.officeListLevels);
892
+ const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
893
+ const officeTableColumnCount = getContextNumber(metadata.officeTableColumnCount);
894
+ const officeTableBodyRowCount = getContextNumber(metadata.officeTableBodyRowCount);
895
+ const officeTableBodyRowStart = getContextNumber(metadata.officeTableBodyRowStart);
896
+ const officeTableBodyRowEnd = getContextNumber(metadata.officeTableBodyRowEnd);
897
+ const officeTableContextText = getContextString(metadata.officeTableContextText);
898
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString(value)).filter((value) => typeof value === "string") : [];
821
899
  const ocrEngine = getContextString(metadata.ocrEngine);
822
900
  const ocrConfidence = getContextNumber(metadata.ocrRegionConfidence) ?? getContextNumber(metadata.ocrConfidence);
823
901
  const labels = [
824
902
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
903
+ officeBlockKind ? `Office ${officeBlockKind}` : "",
904
+ typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
905
+ officeListLevelsLabel ?? "",
906
+ sectionPath.length > 0 && officeBlockKind ? `Source-aware office ${officeBlockKind} block ${sectionPath.join(" > ")}` : "",
907
+ officeListContextText ? `Office list context ${officeListContextText}` : "",
908
+ officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
909
+ typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
910
+ typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
911
+ typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
912
+ officeTableContextText ? `Office table context ${officeTableContextText}` : "",
825
913
  ocrEngine ? `OCR ${ocrEngine}` : "",
826
914
  typeof ocrConfidence === "number" ? `Confidence ${ocrConfidence.toFixed(2)}` : "",
827
915
  mediaKind ? `Media ${mediaKind}` : "",
@@ -985,6 +1073,15 @@ var buildRAGCitations = (sources) => {
985
1073
  });
986
1074
  }
987
1075
  return [...unique.values()].sort((left, right) => {
1076
+ const leftOfficeScope = getOfficeTableCitationScope(left.metadata);
1077
+ const rightOfficeScope = getOfficeTableCitationScope(right.metadata);
1078
+ if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
1079
+ const leftOfficePreference = getOfficeTableCitationPreference(left.metadata);
1080
+ const rightOfficePreference = getOfficeTableCitationPreference(right.metadata);
1081
+ if (rightOfficePreference !== leftOfficePreference) {
1082
+ return rightOfficePreference - leftOfficePreference;
1083
+ }
1084
+ }
988
1085
  if (right.score !== left.score) {
989
1086
  return right.score - left.score;
990
1087
  }
@@ -1557,6 +1654,7 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1557
1654
  const sectionKind = getContextString2(metadata.sectionKind);
1558
1655
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
1559
1656
  const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
1657
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1560
1658
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1561
1659
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1562
1660
  const sheetName = getContextString2(metadata.sheetName);
@@ -1567,6 +1665,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1567
1665
  return `Source-aware section ${sectionPath.join(" > ")}`;
1568
1666
  }
1569
1667
  if (sectionKind === "pdf_block") {
1668
+ if (pdfSemanticRole === "figure_caption" && sectionTitle) {
1669
+ return `Source-aware PDF figure caption ${sectionTitle}`;
1670
+ }
1671
+ if (pdfSemanticRole === "figure_body" && sectionTitle) {
1672
+ return `Source-aware PDF figure body ${sectionTitle}`;
1673
+ }
1570
1674
  if (pdfTextKind === "table_like" && sectionTitle) {
1571
1675
  return `Source-aware PDF table block ${sectionTitle}`;
1572
1676
  }
@@ -1576,11 +1680,12 @@ var buildSourceAwareUnitScopeLabel = (metadata) => {
1576
1680
  return "Source-aware PDF block";
1577
1681
  }
1578
1682
  if (sectionKind === "office_block") {
1579
- if (officeBlockKind && sectionTitle) {
1580
- return `Source-aware office ${officeBlockKind} block ${sectionTitle}`;
1683
+ const officeSectionLabel = sectionPath.length > 0 ? sectionPath.join(" > ") : sectionTitle;
1684
+ if (officeBlockKind && officeSectionLabel) {
1685
+ return `Source-aware office ${officeBlockKind} block ${officeSectionLabel}`;
1581
1686
  }
1582
- if (sectionTitle) {
1583
- return `Source-aware office block ${sectionTitle}`;
1687
+ if (officeSectionLabel) {
1688
+ return `Source-aware office block ${officeSectionLabel}`;
1584
1689
  }
1585
1690
  return "Source-aware office block";
1586
1691
  }
@@ -1662,6 +1767,18 @@ var formatSpreadsheetTableLabel = (tableIndex, tableCount) => {
1662
1767
  }
1663
1768
  return `Table ${tableIndex}`;
1664
1769
  };
1770
+ var formatOfficeListLevelsLabel2 = (value) => {
1771
+ if (!Array.isArray(value) || value.length === 0) {
1772
+ return;
1773
+ }
1774
+ const levels = value.map((entry) => getContextNumber2(entry)).filter((entry) => typeof entry === "number").sort((left, right) => left - right);
1775
+ if (levels.length === 0) {
1776
+ return;
1777
+ }
1778
+ const minLevel = levels[0];
1779
+ const maxLevel = levels[levels.length - 1];
1780
+ return minLevel === maxLevel ? `Office list level ${minLevel}` : `Office list levels ${minLevel}-${maxLevel}`;
1781
+ };
1665
1782
  var formatMediaDurationLabel2 = (value) => {
1666
1783
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
1667
1784
  return;
@@ -1673,9 +1790,18 @@ var buildContextLabel2 = (metadata) => {
1673
1790
  return;
1674
1791
  }
1675
1792
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1793
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1794
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
1795
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1676
1796
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1677
1797
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
1678
1798
  const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
1799
+ if (pdfSemanticRole === "figure_caption" && sectionTitle) {
1800
+ return `PDF figure caption ${sectionTitle}`;
1801
+ }
1802
+ if (pdfSemanticRole === "figure_body" && sectionTitle) {
1803
+ return `PDF figure body ${sectionTitle}`;
1804
+ }
1679
1805
  if (pdfTextKind === "table_like" && sectionTitle) {
1680
1806
  return `PDF table block ${sectionTitle}`;
1681
1807
  }
@@ -1683,13 +1809,13 @@ var buildContextLabel2 = (metadata) => {
1683
1809
  return `PDF text block ${sectionTitle}`;
1684
1810
  }
1685
1811
  if (officeBlockKind === "table" && sectionTitle) {
1686
- return `Office table block ${sectionTitle}`;
1812
+ return `Office table block ${sectionPath.join(" > ") || sectionTitle}`;
1687
1813
  }
1688
1814
  if (officeBlockKind === "list" && sectionTitle) {
1689
- return `Office list block ${sectionTitle}`;
1815
+ return `Office list block ${sectionPath.join(" > ") || sectionTitle}`;
1690
1816
  }
1691
1817
  if (officeBlockKind === "paragraph" && sectionTitle) {
1692
- return `Office paragraph block ${sectionTitle}`;
1818
+ return `Office paragraph block ${sectionPath.join(" > ") || sectionTitle}`;
1693
1819
  }
1694
1820
  const emailKind = getContextString2(metadata.emailKind);
1695
1821
  if (emailKind === "attachment") {
@@ -1787,9 +1913,14 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1787
1913
  return;
1788
1914
  }
1789
1915
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
1916
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1790
1917
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
1791
1918
  const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
1919
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
1920
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1792
1921
  const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
1922
+ const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
1923
+ const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
1793
1924
  const spreadsheetRowStart = getContextNumber2(metadata.spreadsheetRowStart);
1794
1925
  const spreadsheetRowEnd = getContextNumber2(metadata.spreadsheetRowEnd);
1795
1926
  const slideTitle = getContextString2(metadata.slideTitle);
@@ -1800,7 +1931,16 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1800
1931
  if (page && region) {
1801
1932
  return `Page ${page} · Region ${region}`;
1802
1933
  }
1934
+ if (page && pdfBlockNumber && pdfSemanticRole === "figure_caption") {
1935
+ return `Page ${page} · Figure Caption ${pdfBlockNumber}`;
1936
+ }
1937
+ if (page && pdfBlockNumber && pdfSemanticRole === "figure_body") {
1938
+ return `Page ${page} · Figure Body ${pdfBlockNumber}`;
1939
+ }
1803
1940
  if (page && pdfBlockNumber && pdfTextKind === "table_like") {
1941
+ if (typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number") {
1942
+ return pdfTableBodyRowStart === pdfTableBodyRowEnd ? `Page ${page} · Table Block ${pdfBlockNumber} · Row ${pdfTableBodyRowStart}` : `Page ${page} · Table Block ${pdfBlockNumber} · Rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}`;
1943
+ }
1804
1944
  return `Page ${page} · Table Block ${pdfBlockNumber}`;
1805
1945
  }
1806
1946
  if (page && pdfBlockNumber) {
@@ -1863,6 +2003,9 @@ var buildLocatorLabel2 = (metadata, source, title) => {
1863
2003
  return `Timestamp ${mediaStart}`;
1864
2004
  }
1865
2005
  if (officeBlockNumber && officeBlockKind === "table") {
2006
+ if (typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number") {
2007
+ return officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table block ${officeBlockNumber} · Row ${officeTableBodyRowStart}` : `Office table block ${officeBlockNumber} · Rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}`;
2008
+ }
1866
2009
  return `Office table block ${officeBlockNumber}`;
1867
2010
  }
1868
2011
  if (officeBlockNumber && officeBlockKind === "list") {
@@ -1899,11 +2042,27 @@ var buildProvenanceLabel2 = (metadata) => {
1899
2042
  const mediaSegmentWindowDurationLabel = formatMediaDurationLabel2(metadata.mediaSegmentGroupDurationMs);
1900
2043
  const mediaSegmentGapLabel = formatMediaDurationLabel2(metadata.mediaSegmentGapFromPreviousMs);
1901
2044
  const spreadsheetHeaders = getSpreadsheetHeaders(metadata);
2045
+ const pdfTableHeaders = Array.isArray(metadata.pdfTableHeaders) ? metadata.pdfTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2046
+ const pdfTableColumnCount = getContextNumber2(metadata.pdfTableColumnCount);
2047
+ const pdfTableBodyRowCount = getContextNumber2(metadata.pdfTableBodyRowCount);
1902
2048
  const spreadsheetColumnRange = formatSpreadsheetColumnRange(getContextString2(metadata.spreadsheetColumnStart), getContextString2(metadata.spreadsheetColumnEnd));
1903
2049
  const slideNotesText = getContextString2(metadata.slideNotesText);
1904
2050
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
2051
+ const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
2052
+ const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
2053
+ const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
1905
2054
  const pdfTextKind = getContextString2(metadata.pdfTextKind);
2055
+ const pdfSemanticRole = getContextString2(metadata.pdfSemanticRole);
1906
2056
  const officeBlockKind = getContextString2(metadata.officeBlockKind);
2057
+ const officeListContextText = getContextString2(metadata.officeListContextText);
2058
+ const officeListGroupItemCount = getContextNumber2(metadata.officeListGroupItemCount);
2059
+ const officeListLevelsLabel = formatOfficeListLevelsLabel2(metadata.officeListLevels);
2060
+ const officeTableHeaders = Array.isArray(metadata.officeTableHeaders) ? metadata.officeTableHeaders.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2061
+ const officeTableColumnCount = getContextNumber2(metadata.officeTableColumnCount);
2062
+ const officeTableBodyRowCount = getContextNumber2(metadata.officeTableBodyRowCount);
2063
+ const officeTableBodyRowStart = getContextNumber2(metadata.officeTableBodyRowStart);
2064
+ const officeTableBodyRowEnd = getContextNumber2(metadata.officeTableBodyRowEnd);
2065
+ const officeTableContextText = getContextString2(metadata.officeTableContextText);
1907
2066
  const ocrEngine = getContextString2(metadata.ocrEngine);
1908
2067
  const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
1909
2068
  const chunkingProfile = getContextString2(metadata.chunkingProfile);
@@ -1919,10 +2078,19 @@ var buildProvenanceLabel2 = (metadata) => {
1919
2078
  const ocrMinConfidence = getContextNumber2(metadata.ocrPageMinConfidence) ?? getContextNumber2(metadata.ocrMinConfidence);
1920
2079
  const ocrMaxConfidence = getContextNumber2(metadata.ocrPageMaxConfidence) ?? getContextNumber2(metadata.ocrMaxConfidence);
1921
2080
  const ocrRegionCount = getContextNumber2(metadata.ocrRegionCount);
2081
+ const pdfTableBodyRowStart = getContextNumber2(metadata.pdfTableBodyRowStart);
2082
+ const pdfTableBodyRowEnd = getContextNumber2(metadata.pdfTableBodyRowEnd);
1922
2083
  const labels = [
1923
2084
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
1924
- pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
2085
+ pdfEvidenceMode ? `PDF evidence ${pdfEvidenceMode}` : "",
2086
+ pdfEvidenceOrigin ? `PDF origin ${pdfEvidenceOrigin}` : "",
2087
+ pdfEvidenceSupplement ? `PDF supplement ${pdfEvidenceSupplement}` : "",
2088
+ pdfSemanticRole === "figure_caption" ? "PDF figure caption" : "",
2089
+ pdfSemanticRole === "figure_body" ? "PDF figure body" : "",
2090
+ pdfSemanticRole === "figure_caption" ? "" : pdfSemanticRole === "figure_body" ? "" : pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
1925
2091
  officeBlockKind ? `Office ${officeBlockKind}` : "",
2092
+ typeof officeListGroupItemCount === "number" ? `Office list ${officeListGroupItemCount} items` : "",
2093
+ officeListLevelsLabel ?? "",
1926
2094
  ocrEngine ? `OCR ${ocrEngine}` : "",
1927
2095
  extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
1928
2096
  chunkingProfile ? `Chunking ${chunkingProfile}` : "",
@@ -1932,6 +2100,16 @@ var buildProvenanceLabel2 = (metadata) => {
1932
2100
  typeof ocrAverageConfidence === "number" && ocrAverageConfidence !== ocrConfidence ? `Average ${ocrAverageConfidence.toFixed(2)}` : "",
1933
2101
  typeof ocrMinConfidence === "number" && typeof ocrMaxConfidence === "number" && ocrMinConfidence !== ocrMaxConfidence ? `Range ${ocrMinConfidence.toFixed(2)}-${ocrMaxConfidence.toFixed(2)}` : "",
1934
2102
  typeof ocrRegionCount === "number" ? `${ocrRegionCount} regions` : "",
2103
+ pdfTableHeaders.length > 0 ? `PDF table ${pdfTableHeaders.join(", ")}` : "",
2104
+ typeof pdfTableColumnCount === "number" ? `PDF table ${pdfTableColumnCount} cols` : "",
2105
+ typeof pdfTableBodyRowCount === "number" ? `PDF table ${pdfTableBodyRowCount} body rows` : "",
2106
+ typeof pdfTableBodyRowStart === "number" && typeof pdfTableBodyRowEnd === "number" ? pdfTableBodyRowStart === pdfTableBodyRowEnd ? `PDF table row ${pdfTableBodyRowStart}` : `PDF table rows ${pdfTableBodyRowStart}-${pdfTableBodyRowEnd}` : "",
2107
+ officeListContextText ? `Office list context ${officeListContextText}` : "",
2108
+ officeTableHeaders.length > 0 ? `Office table ${officeTableHeaders.join(", ")}` : "",
2109
+ typeof officeTableColumnCount === "number" ? `Office table ${officeTableColumnCount} cols` : "",
2110
+ typeof officeTableBodyRowCount === "number" ? `Office table ${officeTableBodyRowCount} body rows` : "",
2111
+ typeof officeTableBodyRowStart === "number" && typeof officeTableBodyRowEnd === "number" ? officeTableBodyRowStart === officeTableBodyRowEnd ? `Office table row ${officeTableBodyRowStart}` : `Office table rows ${officeTableBodyRowStart}-${officeTableBodyRowEnd}` : "",
2112
+ officeTableContextText ? `Office table context ${officeTableContextText}` : "",
1935
2113
  spreadsheetHeaders.length > 0 ? `Spreadsheet ${spreadsheetHeaders.join(", ")}` : "",
1936
2114
  spreadsheetColumnRange ? `Spreadsheet ${spreadsheetColumnRange}` : "",
1937
2115
  spreadsheetTableLabel ? `Spreadsheet ${spreadsheetTableLabel}` : "",
@@ -2363,12 +2541,92 @@ var getStructuredSectionScoreWeight = (metadata) => {
2363
2541
  return 1;
2364
2542
  };
2365
2543
  var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
2544
+ var getPDFLeadEvidencePreference = (metadata) => {
2545
+ if (!metadata) {
2546
+ return 0;
2547
+ }
2548
+ const pdfEvidenceMode = getContextString2(metadata.pdfEvidenceMode);
2549
+ const pdfEvidenceOrigin = getContextString2(metadata.pdfEvidenceOrigin);
2550
+ const pdfEvidenceSupplement = getContextString2(metadata.pdfEvidenceSupplement);
2551
+ if (pdfEvidenceMode === "hybrid" && pdfEvidenceOrigin === "native" && pdfEvidenceSupplement === "ocr") {
2552
+ return 3;
2553
+ }
2554
+ if (pdfEvidenceMode === "native" && pdfEvidenceOrigin === "native") {
2555
+ return 2;
2556
+ }
2557
+ if (pdfEvidenceMode === "ocr" && pdfEvidenceOrigin === "ocr") {
2558
+ return 1;
2559
+ }
2560
+ return 0;
2561
+ };
2562
+ var getPDFLeadScope = (metadata) => {
2563
+ if (!metadata) {
2564
+ return;
2565
+ }
2566
+ const pageNumber = getContextNumber2(metadata.pageNumber) ?? getContextNumber2(metadata.page) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
2567
+ const sectionTitle = getContextString2(metadata.sectionTitle);
2568
+ const sourceNativeKind = getContextString2(metadata.sourceNativeKind);
2569
+ if (typeof pageNumber !== "number" && !sectionTitle && !sourceNativeKind) {
2570
+ return;
2571
+ }
2572
+ return {
2573
+ pageNumber,
2574
+ sectionTitle,
2575
+ sourceNativeKind
2576
+ };
2577
+ };
2578
+ var getOfficeLeadScope = (metadata) => {
2579
+ if (!metadata) {
2580
+ return;
2581
+ }
2582
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
2583
+ if (officeBlockKind !== "table" && officeBlockKind !== "list") {
2584
+ return;
2585
+ }
2586
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
2587
+ const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
2588
+ const officeContextText = officeBlockKind === "table" ? getContextString2(metadata.officeTableContextText) : getContextString2(metadata.officeListContextText);
2589
+ if (!sectionTitle) {
2590
+ return;
2591
+ }
2592
+ return {
2593
+ blockKind: officeBlockKind,
2594
+ pathDepth: sectionPath.length,
2595
+ sectionTitle,
2596
+ hasContext: typeof officeContextText === "string"
2597
+ };
2598
+ };
2599
+ var getOfficeLeadEvidencePreference = (metadata) => {
2600
+ const scope = getOfficeLeadScope(metadata);
2601
+ if (!scope) {
2602
+ return 0;
2603
+ }
2604
+ return scope.pathDepth * 10 + (scope.hasContext ? 1 : 0) + (scope.blockKind === "list" && typeof metadata?.officeListGroupItemCount === "number" && metadata.officeListGroupItemCount > 1 ? 1 : 0);
2605
+ };
2366
2606
  var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
2607
+ const leftOfficeScope = getOfficeLeadScope(left.metadata);
2608
+ const rightOfficeScope = getOfficeLeadScope(right.metadata);
2609
+ if (left.source === right.source && leftOfficeScope && rightOfficeScope && leftOfficeScope.blockKind === rightOfficeScope.blockKind && leftOfficeScope.sectionTitle === rightOfficeScope.sectionTitle) {
2610
+ const leftOfficePreference = getOfficeLeadEvidencePreference(left.metadata);
2611
+ const rightOfficePreference = getOfficeLeadEvidencePreference(right.metadata);
2612
+ if (rightOfficePreference !== leftOfficePreference) {
2613
+ return rightOfficePreference - leftOfficePreference;
2614
+ }
2615
+ }
2367
2616
  const leftWeightedScore = getStructuredSourceLeadScore(left);
2368
2617
  const rightWeightedScore = getStructuredSourceLeadScore(right);
2369
2618
  if (rightWeightedScore !== leftWeightedScore) {
2370
2619
  return rightWeightedScore - leftWeightedScore;
2371
2620
  }
2621
+ const leftScope = getPDFLeadScope(left.metadata);
2622
+ const rightScope = getPDFLeadScope(right.metadata);
2623
+ 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)) {
2624
+ const leftEvidencePreference = getPDFLeadEvidencePreference(left.metadata);
2625
+ const rightEvidencePreference = getPDFLeadEvidencePreference(right.metadata);
2626
+ if (rightEvidencePreference !== leftEvidencePreference) {
2627
+ return rightEvidencePreference - leftEvidencePreference;
2628
+ }
2629
+ }
2372
2630
  if (right.score !== left.score) {
2373
2631
  return right.score - left.score;
2374
2632
  }
@@ -2622,6 +2880,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
2622
2880
  queryTransformProvider: trace?.queryTransformProvider,
2623
2881
  queryTransformReason: trace?.queryTransformReason,
2624
2882
  reasons,
2883
+ evidenceReconcileApplied: trace?.steps.some((step) => step.stage === "evidence_reconcile"),
2625
2884
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
2626
2885
  scoreShare,
2627
2886
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
@@ -3173,6 +3432,9 @@ var createRAGClient = (options) => {
3173
3432
  if (typeof input.runLimit === "number") {
3174
3433
  searchParams.set("runLimit", String(input.runLimit));
3175
3434
  }
3435
+ if (typeof input.benchmarkLimit === "number") {
3436
+ searchParams.set("benchmarkLimit", String(input.benchmarkLimit));
3437
+ }
3176
3438
  if (input.targetRolloutLabel) {
3177
3439
  searchParams.set("targetRolloutLabel", input.targetRolloutLabel);
3178
3440
  }
@@ -3186,6 +3448,172 @@ var createRAGClient = (options) => {
3186
3448
  }
3187
3449
  return payload;
3188
3450
  },
3451
+ async adaptiveNativePlannerBenchmark(input) {
3452
+ const searchParams = new URLSearchParams;
3453
+ if (typeof input?.limit === "number") {
3454
+ searchParams.set("limit", String(input.limit));
3455
+ }
3456
+ if (typeof input?.runLimit === "number") {
3457
+ searchParams.set("runLimit", String(input.runLimit));
3458
+ }
3459
+ if (input?.label) {
3460
+ searchParams.set("label", input.label);
3461
+ }
3462
+ if (input?.description) {
3463
+ searchParams.set("description", input.description);
3464
+ }
3465
+ if (input?.groupKey) {
3466
+ searchParams.set("benchmarkGroupKey", input.groupKey);
3467
+ }
3468
+ if (input?.corpusGroupKey) {
3469
+ searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
3470
+ }
3471
+ const suffix = searchParams.size ? `?${searchParams}` : "";
3472
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner${suffix}`);
3473
+ if (!response.ok) {
3474
+ throw new Error(await toErrorMessage(response));
3475
+ }
3476
+ const payload = await parseJson(response);
3477
+ if (!payload.ok) {
3478
+ throw new Error(payload.error ?? "Adaptive native planner benchmark history failed");
3479
+ }
3480
+ return payload;
3481
+ },
3482
+ async runAdaptiveNativePlannerBenchmark(input) {
3483
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/run`, {
3484
+ body: JSON.stringify({
3485
+ baselineRetrievalId: input?.baselineRetrievalId,
3486
+ candidateRetrievalId: input?.candidateRetrievalId,
3487
+ corpusGroupKey: input?.corpusGroupKey,
3488
+ description: input?.description,
3489
+ groupKey: input?.groupKey,
3490
+ label: input?.label,
3491
+ limit: input?.limit,
3492
+ metadata: input?.metadata,
3493
+ persistRun: input?.persistRun,
3494
+ retrievals: input?.retrievals,
3495
+ runLimit: input?.runLimit,
3496
+ tags: input?.tags,
3497
+ topK: input?.topK
3498
+ }),
3499
+ headers: jsonHeaders,
3500
+ method: "POST"
3501
+ });
3502
+ if (!response.ok) {
3503
+ throw new Error(await toErrorMessage(response));
3504
+ }
3505
+ const payload = await parseJson(response);
3506
+ if (!payload.ok) {
3507
+ throw new Error(payload.error ?? "Adaptive native planner benchmark run failed");
3508
+ }
3509
+ return payload;
3510
+ },
3511
+ async saveAdaptiveNativePlannerBenchmarkSnapshot(input) {
3512
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/adaptive-native-planner/snapshots`, {
3513
+ body: JSON.stringify({
3514
+ createdAt: input?.createdAt,
3515
+ description: input?.description,
3516
+ label: input?.label,
3517
+ limit: input?.limit,
3518
+ metadata: input?.metadata,
3519
+ snapshotMetadata: input?.snapshotMetadata,
3520
+ version: input?.version
3521
+ }),
3522
+ headers: jsonHeaders,
3523
+ method: "POST"
3524
+ });
3525
+ if (!response.ok) {
3526
+ throw new Error(await toErrorMessage(response));
3527
+ }
3528
+ const payload = await parseJson(response);
3529
+ if (!payload.ok) {
3530
+ throw new Error(payload.error ?? "Adaptive native planner benchmark snapshot failed");
3531
+ }
3532
+ return payload;
3533
+ },
3534
+ async nativeBackendComparisonBenchmark(input) {
3535
+ const searchParams = new URLSearchParams;
3536
+ if (typeof input?.limit === "number") {
3537
+ searchParams.set("limit", String(input.limit));
3538
+ }
3539
+ if (typeof input?.runLimit === "number") {
3540
+ searchParams.set("runLimit", String(input.runLimit));
3541
+ }
3542
+ if (input?.label) {
3543
+ searchParams.set("label", input.label);
3544
+ }
3545
+ if (input?.description) {
3546
+ searchParams.set("description", input.description);
3547
+ }
3548
+ if (input?.groupKey) {
3549
+ searchParams.set("benchmarkGroupKey", input.groupKey);
3550
+ }
3551
+ if (input?.corpusGroupKey) {
3552
+ searchParams.set("benchmarkCorpusGroupKey", input.corpusGroupKey);
3553
+ }
3554
+ const suffix = searchParams.size ? `?${searchParams}` : "";
3555
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison${suffix}`);
3556
+ if (!response.ok) {
3557
+ throw new Error(await toErrorMessage(response));
3558
+ }
3559
+ const payload = await parseJson(response);
3560
+ if (!payload.ok) {
3561
+ throw new Error(payload.error ?? "Native backend comparison benchmark history failed");
3562
+ }
3563
+ return payload;
3564
+ },
3565
+ async runNativeBackendComparisonBenchmark(input) {
3566
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/run`, {
3567
+ body: JSON.stringify({
3568
+ baselineRetrievalId: input?.baselineRetrievalId,
3569
+ candidateRetrievalId: input?.candidateRetrievalId,
3570
+ corpusGroupKey: input?.corpusGroupKey,
3571
+ description: input?.description,
3572
+ groupKey: input?.groupKey,
3573
+ label: input?.label,
3574
+ limit: input?.limit,
3575
+ metadata: input?.metadata,
3576
+ persistRun: input?.persistRun,
3577
+ retrievals: input?.retrievals,
3578
+ runLimit: input?.runLimit,
3579
+ tags: input?.tags,
3580
+ topK: input?.topK
3581
+ }),
3582
+ headers: jsonHeaders,
3583
+ method: "POST"
3584
+ });
3585
+ if (!response.ok) {
3586
+ throw new Error(await toErrorMessage(response));
3587
+ }
3588
+ const payload = await parseJson(response);
3589
+ if (!payload.ok) {
3590
+ throw new Error(payload.error ?? "Native backend comparison benchmark run failed");
3591
+ }
3592
+ return payload;
3593
+ },
3594
+ async saveNativeBackendComparisonBenchmarkSnapshot(input) {
3595
+ const response = await fetchImpl(`${basePath}/compare/retrieval/benchmarks/native-backend-comparison/snapshots`, {
3596
+ body: JSON.stringify({
3597
+ createdAt: input?.createdAt,
3598
+ description: input?.description,
3599
+ label: input?.label,
3600
+ limit: input?.limit,
3601
+ metadata: input?.metadata,
3602
+ snapshotMetadata: input?.snapshotMetadata,
3603
+ version: input?.version
3604
+ }),
3605
+ headers: jsonHeaders,
3606
+ method: "POST"
3607
+ });
3608
+ if (!response.ok) {
3609
+ throw new Error(await toErrorMessage(response));
3610
+ }
3611
+ const payload = await parseJson(response);
3612
+ if (!payload.ok) {
3613
+ throw new Error(payload.error ?? "Native backend comparison benchmark snapshot failed");
3614
+ }
3615
+ return payload;
3616
+ },
3189
3617
  async retrievalLaneHandoffs(input) {
3190
3618
  const searchParams = new URLSearchParams;
3191
3619
  if (input?.groupKey) {