@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.
@@ -1077,10 +1077,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
1077
1077
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
1078
1078
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
1079
1079
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
1080
+ var formatTimestampLabel = (value) => {
1081
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
1082
+ if (!Number.isFinite(timestamp)) {
1083
+ return;
1084
+ }
1085
+ return new Date(timestamp).toLocaleString("en-US", {
1086
+ dateStyle: "medium",
1087
+ timeStyle: "short"
1088
+ });
1089
+ };
1090
+ var formatMediaTimestamp = (value) => {
1091
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
1092
+ return;
1093
+ }
1094
+ const totalSeconds = Math.floor(value / 1000);
1095
+ const minutes = Math.floor(totalSeconds / 60);
1096
+ const seconds = totalSeconds % 60;
1097
+ const milliseconds = Math.floor(value % 1000);
1098
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
1099
+ };
1100
+ var getAttachmentName = (source, title) => {
1101
+ const sourceAttachment = source?.split("/").at(-1);
1102
+ if (sourceAttachment && sourceAttachment.includes(".")) {
1103
+ return sourceAttachment;
1104
+ }
1105
+ const titleAttachment = title?.split(" · ").at(-1);
1106
+ if (titleAttachment && titleAttachment.includes(".")) {
1107
+ return titleAttachment;
1108
+ }
1109
+ return;
1110
+ };
1080
1111
  var buildContextLabel = (metadata) => {
1081
1112
  if (!metadata) {
1082
1113
  return;
1083
1114
  }
1115
+ const emailKind = getContextString(metadata.emailKind);
1116
+ if (emailKind === "attachment") {
1117
+ return "Attachment evidence";
1118
+ }
1119
+ if (emailKind === "message") {
1120
+ const from = getContextString(metadata.from);
1121
+ return from ? `Message from ${from}` : "Message evidence";
1122
+ }
1084
1123
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1085
1124
  if (page) {
1086
1125
  return `Page ${page}`;
@@ -1107,6 +1146,57 @@ var buildContextLabel = (metadata) => {
1107
1146
  }
1108
1147
  return;
1109
1148
  };
1149
+ var buildLocatorLabel = (metadata, source, title) => {
1150
+ if (!metadata) {
1151
+ return;
1152
+ }
1153
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1154
+ if (page) {
1155
+ return `Page ${page}`;
1156
+ }
1157
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
1158
+ if (sheet) {
1159
+ return `Sheet ${sheet}`;
1160
+ }
1161
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
1162
+ if (slide) {
1163
+ return `Slide ${slide}`;
1164
+ }
1165
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
1166
+ if (archiveEntry) {
1167
+ return `Archive entry ${archiveEntry}`;
1168
+ }
1169
+ const emailKind = getContextString(metadata.emailKind);
1170
+ if (emailKind === "attachment") {
1171
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
1172
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
1173
+ }
1174
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
1175
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
1176
+ if (mediaStart && mediaEnd) {
1177
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
1178
+ }
1179
+ if (mediaStart) {
1180
+ return `Timestamp ${mediaStart}`;
1181
+ }
1182
+ return;
1183
+ };
1184
+ var buildProvenanceLabel = (metadata) => {
1185
+ if (!metadata) {
1186
+ return;
1187
+ }
1188
+ const threadTopic = getContextString(metadata.threadTopic);
1189
+ const from = getContextString(metadata.from);
1190
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
1191
+ const speaker = getContextString(metadata.speaker);
1192
+ const labels = [
1193
+ threadTopic ? `Thread ${threadTopic}` : "",
1194
+ speaker ? `Speaker ${speaker}` : "",
1195
+ from ? `Sender ${from}` : "",
1196
+ sentAt ? `Sent ${sentAt}` : ""
1197
+ ].filter((value) => value.length > 0);
1198
+ return labels.length > 0 ? labels.join(" · ") : undefined;
1199
+ };
1110
1200
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
1111
1201
  var buildRAGCitations = (sources) => {
1112
1202
  const unique = new Map;
@@ -1118,9 +1208,12 @@ var buildRAGCitations = (sources) => {
1118
1208
  continue;
1119
1209
  unique.set(key, {
1120
1210
  chunkId: source.chunkId,
1211
+ contextLabel: buildContextLabel(source.metadata),
1121
1212
  key,
1122
1213
  label: buildSourceLabel(source),
1214
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
1123
1215
  metadata: source.metadata,
1216
+ provenanceLabel: buildProvenanceLabel(source.metadata),
1124
1217
  score: source.score,
1125
1218
  source: source.source,
1126
1219
  text: source.text,
@@ -1197,8 +1290,10 @@ var buildRAGGroundingReferences = (sources) => {
1197
1290
  contextLabel: buildContextLabel(citation.metadata),
1198
1291
  excerpt: buildExcerpt(citation.text),
1199
1292
  label: citation.label,
1293
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
1200
1294
  metadata: citation.metadata,
1201
1295
  number: citationReferenceMap[citation.chunkId] ?? 0,
1296
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
1202
1297
  score: citation.score,
1203
1298
  source: citation.source,
1204
1299
  text: citation.text,
@@ -674,10 +674,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
674
674
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
675
675
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
676
676
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
677
+ var formatTimestampLabel = (value) => {
678
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
679
+ if (!Number.isFinite(timestamp)) {
680
+ return;
681
+ }
682
+ return new Date(timestamp).toLocaleString("en-US", {
683
+ dateStyle: "medium",
684
+ timeStyle: "short"
685
+ });
686
+ };
687
+ var formatMediaTimestamp = (value) => {
688
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
689
+ return;
690
+ }
691
+ const totalSeconds = Math.floor(value / 1000);
692
+ const minutes = Math.floor(totalSeconds / 60);
693
+ const seconds = totalSeconds % 60;
694
+ const milliseconds = Math.floor(value % 1000);
695
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
696
+ };
697
+ var getAttachmentName = (source, title) => {
698
+ const sourceAttachment = source?.split("/").at(-1);
699
+ if (sourceAttachment && sourceAttachment.includes(".")) {
700
+ return sourceAttachment;
701
+ }
702
+ const titleAttachment = title?.split(" · ").at(-1);
703
+ if (titleAttachment && titleAttachment.includes(".")) {
704
+ return titleAttachment;
705
+ }
706
+ return;
707
+ };
677
708
  var buildContextLabel = (metadata) => {
678
709
  if (!metadata) {
679
710
  return;
680
711
  }
712
+ const emailKind = getContextString(metadata.emailKind);
713
+ if (emailKind === "attachment") {
714
+ return "Attachment evidence";
715
+ }
716
+ if (emailKind === "message") {
717
+ const from = getContextString(metadata.from);
718
+ return from ? `Message from ${from}` : "Message evidence";
719
+ }
681
720
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
682
721
  if (page) {
683
722
  return `Page ${page}`;
@@ -704,6 +743,57 @@ var buildContextLabel = (metadata) => {
704
743
  }
705
744
  return;
706
745
  };
746
+ var buildLocatorLabel = (metadata, source, title) => {
747
+ if (!metadata) {
748
+ return;
749
+ }
750
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
751
+ if (page) {
752
+ return `Page ${page}`;
753
+ }
754
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
755
+ if (sheet) {
756
+ return `Sheet ${sheet}`;
757
+ }
758
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
759
+ if (slide) {
760
+ return `Slide ${slide}`;
761
+ }
762
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
763
+ if (archiveEntry) {
764
+ return `Archive entry ${archiveEntry}`;
765
+ }
766
+ const emailKind = getContextString(metadata.emailKind);
767
+ if (emailKind === "attachment") {
768
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
769
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
770
+ }
771
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
772
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
773
+ if (mediaStart && mediaEnd) {
774
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
775
+ }
776
+ if (mediaStart) {
777
+ return `Timestamp ${mediaStart}`;
778
+ }
779
+ return;
780
+ };
781
+ var buildProvenanceLabel = (metadata) => {
782
+ if (!metadata) {
783
+ return;
784
+ }
785
+ const threadTopic = getContextString(metadata.threadTopic);
786
+ const from = getContextString(metadata.from);
787
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
788
+ const speaker = getContextString(metadata.speaker);
789
+ const labels = [
790
+ threadTopic ? `Thread ${threadTopic}` : "",
791
+ speaker ? `Speaker ${speaker}` : "",
792
+ from ? `Sender ${from}` : "",
793
+ sentAt ? `Sent ${sentAt}` : ""
794
+ ].filter((value) => value.length > 0);
795
+ return labels.length > 0 ? labels.join(" · ") : undefined;
796
+ };
707
797
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
708
798
  var buildRAGCitations = (sources) => {
709
799
  const unique = new Map;
@@ -715,9 +805,12 @@ var buildRAGCitations = (sources) => {
715
805
  continue;
716
806
  unique.set(key, {
717
807
  chunkId: source.chunkId,
808
+ contextLabel: buildContextLabel(source.metadata),
718
809
  key,
719
810
  label: buildSourceLabel(source),
811
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
720
812
  metadata: source.metadata,
813
+ provenanceLabel: buildProvenanceLabel(source.metadata),
721
814
  score: source.score,
722
815
  source: source.source,
723
816
  text: source.text,
@@ -794,8 +887,10 @@ var buildRAGGroundingReferences = (sources) => {
794
887
  contextLabel: buildContextLabel(citation.metadata),
795
888
  excerpt: buildExcerpt(citation.text),
796
889
  label: citation.label,
890
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
797
891
  metadata: citation.metadata,
798
892
  number: citationReferenceMap[citation.chunkId] ?? 0,
893
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
799
894
  score: citation.score,
800
895
  source: citation.source,
801
896
  text: citation.text,
@@ -962,10 +962,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
962
962
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
963
963
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
964
964
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
965
+ var formatTimestampLabel = (value) => {
966
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
967
+ if (!Number.isFinite(timestamp)) {
968
+ return;
969
+ }
970
+ return new Date(timestamp).toLocaleString("en-US", {
971
+ dateStyle: "medium",
972
+ timeStyle: "short"
973
+ });
974
+ };
975
+ var formatMediaTimestamp = (value) => {
976
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
977
+ return;
978
+ }
979
+ const totalSeconds = Math.floor(value / 1000);
980
+ const minutes = Math.floor(totalSeconds / 60);
981
+ const seconds = totalSeconds % 60;
982
+ const milliseconds = Math.floor(value % 1000);
983
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
984
+ };
985
+ var getAttachmentName = (source, title) => {
986
+ const sourceAttachment = source?.split("/").at(-1);
987
+ if (sourceAttachment && sourceAttachment.includes(".")) {
988
+ return sourceAttachment;
989
+ }
990
+ const titleAttachment = title?.split(" · ").at(-1);
991
+ if (titleAttachment && titleAttachment.includes(".")) {
992
+ return titleAttachment;
993
+ }
994
+ return;
995
+ };
965
996
  var buildContextLabel = (metadata) => {
966
997
  if (!metadata) {
967
998
  return;
968
999
  }
1000
+ const emailKind = getContextString(metadata.emailKind);
1001
+ if (emailKind === "attachment") {
1002
+ return "Attachment evidence";
1003
+ }
1004
+ if (emailKind === "message") {
1005
+ const from = getContextString(metadata.from);
1006
+ return from ? `Message from ${from}` : "Message evidence";
1007
+ }
969
1008
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
970
1009
  if (page) {
971
1010
  return `Page ${page}`;
@@ -992,6 +1031,57 @@ var buildContextLabel = (metadata) => {
992
1031
  }
993
1032
  return;
994
1033
  };
1034
+ var buildLocatorLabel = (metadata, source, title) => {
1035
+ if (!metadata) {
1036
+ return;
1037
+ }
1038
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1039
+ if (page) {
1040
+ return `Page ${page}`;
1041
+ }
1042
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
1043
+ if (sheet) {
1044
+ return `Sheet ${sheet}`;
1045
+ }
1046
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
1047
+ if (slide) {
1048
+ return `Slide ${slide}`;
1049
+ }
1050
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
1051
+ if (archiveEntry) {
1052
+ return `Archive entry ${archiveEntry}`;
1053
+ }
1054
+ const emailKind = getContextString(metadata.emailKind);
1055
+ if (emailKind === "attachment") {
1056
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
1057
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
1058
+ }
1059
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
1060
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
1061
+ if (mediaStart && mediaEnd) {
1062
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
1063
+ }
1064
+ if (mediaStart) {
1065
+ return `Timestamp ${mediaStart}`;
1066
+ }
1067
+ return;
1068
+ };
1069
+ var buildProvenanceLabel = (metadata) => {
1070
+ if (!metadata) {
1071
+ return;
1072
+ }
1073
+ const threadTopic = getContextString(metadata.threadTopic);
1074
+ const from = getContextString(metadata.from);
1075
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
1076
+ const speaker = getContextString(metadata.speaker);
1077
+ const labels = [
1078
+ threadTopic ? `Thread ${threadTopic}` : "",
1079
+ speaker ? `Speaker ${speaker}` : "",
1080
+ from ? `Sender ${from}` : "",
1081
+ sentAt ? `Sent ${sentAt}` : ""
1082
+ ].filter((value) => value.length > 0);
1083
+ return labels.length > 0 ? labels.join(" · ") : undefined;
1084
+ };
995
1085
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
996
1086
  var buildRAGCitations = (sources) => {
997
1087
  const unique = new Map;
@@ -1003,9 +1093,12 @@ var buildRAGCitations = (sources) => {
1003
1093
  continue;
1004
1094
  unique.set(key, {
1005
1095
  chunkId: source.chunkId,
1096
+ contextLabel: buildContextLabel(source.metadata),
1006
1097
  key,
1007
1098
  label: buildSourceLabel(source),
1099
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
1008
1100
  metadata: source.metadata,
1101
+ provenanceLabel: buildProvenanceLabel(source.metadata),
1009
1102
  score: source.score,
1010
1103
  source: source.source,
1011
1104
  text: source.text,
@@ -1082,8 +1175,10 @@ var buildRAGGroundingReferences = (sources) => {
1082
1175
  contextLabel: buildContextLabel(citation.metadata),
1083
1176
  excerpt: buildExcerpt(citation.text),
1084
1177
  label: citation.label,
1178
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
1085
1179
  metadata: citation.metadata,
1086
1180
  number: citationReferenceMap[citation.chunkId] ?? 0,
1181
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
1087
1182
  score: citation.score,
1088
1183
  source: citation.source,
1089
1184
  text: citation.text,
@@ -1213,10 +1213,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
1213
1213
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
1214
1214
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
1215
1215
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
1216
+ var formatTimestampLabel = (value) => {
1217
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
1218
+ if (!Number.isFinite(timestamp)) {
1219
+ return;
1220
+ }
1221
+ return new Date(timestamp).toLocaleString("en-US", {
1222
+ dateStyle: "medium",
1223
+ timeStyle: "short"
1224
+ });
1225
+ };
1226
+ var formatMediaTimestamp = (value) => {
1227
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
1228
+ return;
1229
+ }
1230
+ const totalSeconds = Math.floor(value / 1000);
1231
+ const minutes = Math.floor(totalSeconds / 60);
1232
+ const seconds = totalSeconds % 60;
1233
+ const milliseconds = Math.floor(value % 1000);
1234
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
1235
+ };
1236
+ var getAttachmentName = (source, title) => {
1237
+ const sourceAttachment = source?.split("/").at(-1);
1238
+ if (sourceAttachment && sourceAttachment.includes(".")) {
1239
+ return sourceAttachment;
1240
+ }
1241
+ const titleAttachment = title?.split(" \xB7 ").at(-1);
1242
+ if (titleAttachment && titleAttachment.includes(".")) {
1243
+ return titleAttachment;
1244
+ }
1245
+ return;
1246
+ };
1216
1247
  var buildContextLabel = (metadata) => {
1217
1248
  if (!metadata) {
1218
1249
  return;
1219
1250
  }
1251
+ const emailKind = getContextString(metadata.emailKind);
1252
+ if (emailKind === "attachment") {
1253
+ return "Attachment evidence";
1254
+ }
1255
+ if (emailKind === "message") {
1256
+ const from = getContextString(metadata.from);
1257
+ return from ? `Message from ${from}` : "Message evidence";
1258
+ }
1220
1259
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1221
1260
  if (page) {
1222
1261
  return `Page ${page}`;
@@ -1243,6 +1282,57 @@ var buildContextLabel = (metadata) => {
1243
1282
  }
1244
1283
  return;
1245
1284
  };
1285
+ var buildLocatorLabel = (metadata, source, title) => {
1286
+ if (!metadata) {
1287
+ return;
1288
+ }
1289
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
1290
+ if (page) {
1291
+ return `Page ${page}`;
1292
+ }
1293
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
1294
+ if (sheet) {
1295
+ return `Sheet ${sheet}`;
1296
+ }
1297
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
1298
+ if (slide) {
1299
+ return `Slide ${slide}`;
1300
+ }
1301
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
1302
+ if (archiveEntry) {
1303
+ return `Archive entry ${archiveEntry}`;
1304
+ }
1305
+ const emailKind = getContextString(metadata.emailKind);
1306
+ if (emailKind === "attachment") {
1307
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
1308
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
1309
+ }
1310
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
1311
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
1312
+ if (mediaStart && mediaEnd) {
1313
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
1314
+ }
1315
+ if (mediaStart) {
1316
+ return `Timestamp ${mediaStart}`;
1317
+ }
1318
+ return;
1319
+ };
1320
+ var buildProvenanceLabel = (metadata) => {
1321
+ if (!metadata) {
1322
+ return;
1323
+ }
1324
+ const threadTopic = getContextString(metadata.threadTopic);
1325
+ const from = getContextString(metadata.from);
1326
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
1327
+ const speaker = getContextString(metadata.speaker);
1328
+ const labels = [
1329
+ threadTopic ? `Thread ${threadTopic}` : "",
1330
+ speaker ? `Speaker ${speaker}` : "",
1331
+ from ? `Sender ${from}` : "",
1332
+ sentAt ? `Sent ${sentAt}` : ""
1333
+ ].filter((value) => value.length > 0);
1334
+ return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
1335
+ };
1246
1336
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
1247
1337
  var buildRAGCitations = (sources) => {
1248
1338
  const unique = new Map;
@@ -1254,9 +1344,12 @@ var buildRAGCitations = (sources) => {
1254
1344
  continue;
1255
1345
  unique.set(key, {
1256
1346
  chunkId: source.chunkId,
1347
+ contextLabel: buildContextLabel(source.metadata),
1257
1348
  key,
1258
1349
  label: buildSourceLabel(source),
1350
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
1259
1351
  metadata: source.metadata,
1352
+ provenanceLabel: buildProvenanceLabel(source.metadata),
1260
1353
  score: source.score,
1261
1354
  source: source.source,
1262
1355
  text: source.text,
@@ -1333,8 +1426,10 @@ var buildRAGGroundingReferences = (sources) => {
1333
1426
  contextLabel: buildContextLabel(citation.metadata),
1334
1427
  excerpt: buildExcerpt(citation.text),
1335
1428
  label: citation.label,
1429
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
1336
1430
  metadata: citation.metadata,
1337
1431
  number: citationReferenceMap[citation.chunkId] ?? 0,
1432
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
1338
1433
  score: citation.score,
1339
1434
  source: citation.source,
1340
1435
  text: citation.text,
@@ -1628,5 +1723,5 @@ export {
1628
1723
  AIStreamService
1629
1724
  };
1630
1725
 
1631
- //# debugId=41CC5F65D8327B0E64756E2164756E21
1726
+ //# debugId=33A3947E68DA639A64756E2164756E21
1632
1727
  //# sourceMappingURL=index.js.map