@absolutejs/absolute 0.19.0-beta.503 → 0.19.0-beta.504

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.
@@ -785,10 +785,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
785
785
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
786
786
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
787
787
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
788
+ var formatTimestampLabel = (value) => {
789
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
790
+ if (!Number.isFinite(timestamp)) {
791
+ return;
792
+ }
793
+ return new Date(timestamp).toLocaleString("en-US", {
794
+ dateStyle: "medium",
795
+ timeStyle: "short"
796
+ });
797
+ };
798
+ var formatMediaTimestamp = (value) => {
799
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
800
+ return;
801
+ }
802
+ const totalSeconds = Math.floor(value / 1000);
803
+ const minutes = Math.floor(totalSeconds / 60);
804
+ const seconds = totalSeconds % 60;
805
+ const milliseconds = Math.floor(value % 1000);
806
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
807
+ };
808
+ var getAttachmentName = (source, title) => {
809
+ const sourceAttachment = source?.split("/").at(-1);
810
+ if (sourceAttachment && sourceAttachment.includes(".")) {
811
+ return sourceAttachment;
812
+ }
813
+ const titleAttachment = title?.split(" \xB7 ").at(-1);
814
+ if (titleAttachment && titleAttachment.includes(".")) {
815
+ return titleAttachment;
816
+ }
817
+ return;
818
+ };
788
819
  var buildContextLabel = (metadata) => {
789
820
  if (!metadata) {
790
821
  return;
791
822
  }
823
+ const emailKind = getContextString(metadata.emailKind);
824
+ if (emailKind === "attachment") {
825
+ return "Attachment evidence";
826
+ }
827
+ if (emailKind === "message") {
828
+ const from = getContextString(metadata.from);
829
+ return from ? `Message from ${from}` : "Message evidence";
830
+ }
792
831
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
793
832
  if (page) {
794
833
  return `Page ${page}`;
@@ -815,6 +854,57 @@ var buildContextLabel = (metadata) => {
815
854
  }
816
855
  return;
817
856
  };
857
+ var buildLocatorLabel = (metadata, source, title) => {
858
+ if (!metadata) {
859
+ return;
860
+ }
861
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
862
+ if (page) {
863
+ return `Page ${page}`;
864
+ }
865
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
866
+ if (sheet) {
867
+ return `Sheet ${sheet}`;
868
+ }
869
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
870
+ if (slide) {
871
+ return `Slide ${slide}`;
872
+ }
873
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
874
+ if (archiveEntry) {
875
+ return `Archive entry ${archiveEntry}`;
876
+ }
877
+ const emailKind = getContextString(metadata.emailKind);
878
+ if (emailKind === "attachment") {
879
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
880
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
881
+ }
882
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
883
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
884
+ if (mediaStart && mediaEnd) {
885
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
886
+ }
887
+ if (mediaStart) {
888
+ return `Timestamp ${mediaStart}`;
889
+ }
890
+ return;
891
+ };
892
+ var buildProvenanceLabel = (metadata) => {
893
+ if (!metadata) {
894
+ return;
895
+ }
896
+ const threadTopic = getContextString(metadata.threadTopic);
897
+ const from = getContextString(metadata.from);
898
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
899
+ const speaker = getContextString(metadata.speaker);
900
+ const labels = [
901
+ threadTopic ? `Thread ${threadTopic}` : "",
902
+ speaker ? `Speaker ${speaker}` : "",
903
+ from ? `Sender ${from}` : "",
904
+ sentAt ? `Sent ${sentAt}` : ""
905
+ ].filter((value) => value.length > 0);
906
+ return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
907
+ };
818
908
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
819
909
  var buildRAGCitations = (sources) => {
820
910
  const unique = new Map;
@@ -826,9 +916,12 @@ var buildRAGCitations = (sources) => {
826
916
  continue;
827
917
  unique.set(key, {
828
918
  chunkId: source.chunkId,
919
+ contextLabel: buildContextLabel(source.metadata),
829
920
  key,
830
921
  label: buildSourceLabel(source),
922
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
831
923
  metadata: source.metadata,
924
+ provenanceLabel: buildProvenanceLabel(source.metadata),
832
925
  score: source.score,
833
926
  source: source.source,
834
927
  text: source.text,
@@ -905,8 +998,10 @@ var buildRAGGroundingReferences = (sources) => {
905
998
  contextLabel: buildContextLabel(citation.metadata),
906
999
  excerpt: buildExcerpt(citation.text),
907
1000
  label: citation.label,
1001
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
908
1002
  metadata: citation.metadata,
909
1003
  number: citationReferenceMap[citation.chunkId] ?? 0,
1004
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
910
1005
  score: citation.score,
911
1006
  source: citation.source,
912
1007
  text: citation.text,
@@ -2716,5 +2811,5 @@ export {
2716
2811
  AIStreamProvider
2717
2812
  };
2718
2813
 
2719
- //# debugId=CD9857A68C4F8C5664756E2164756E21
2814
+ //# debugId=9E2FD9A0CCC5620D64756E2164756E21
2720
2815
  //# sourceMappingURL=index.js.map