@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.
package/dist/ai/index.js CHANGED
@@ -7126,10 +7126,49 @@ var buildSourceGroupKey = (source) => source.source ?? source.title ?? source.ch
7126
7126
  var buildSourceLabel = (source) => source.source ?? source.title ?? source.chunkId;
7127
7127
  var getContextNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
7128
7128
  var getContextString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
7129
+ var formatTimestampLabel = (value) => {
7130
+ const timestamp = typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
7131
+ if (!Number.isFinite(timestamp)) {
7132
+ return;
7133
+ }
7134
+ return new Date(timestamp).toLocaleString("en-US", {
7135
+ dateStyle: "medium",
7136
+ timeStyle: "short"
7137
+ });
7138
+ };
7139
+ var formatMediaTimestamp = (value) => {
7140
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
7141
+ return;
7142
+ }
7143
+ const totalSeconds = Math.floor(value / 1000);
7144
+ const minutes = Math.floor(totalSeconds / 60);
7145
+ const seconds = totalSeconds % 60;
7146
+ const milliseconds = Math.floor(value % 1000);
7147
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
7148
+ };
7149
+ var getAttachmentName = (source, title) => {
7150
+ const sourceAttachment = source?.split("/").at(-1);
7151
+ if (sourceAttachment && sourceAttachment.includes(".")) {
7152
+ return sourceAttachment;
7153
+ }
7154
+ const titleAttachment = title?.split(" \xB7 ").at(-1);
7155
+ if (titleAttachment && titleAttachment.includes(".")) {
7156
+ return titleAttachment;
7157
+ }
7158
+ return;
7159
+ };
7129
7160
  var buildContextLabel = (metadata) => {
7130
7161
  if (!metadata) {
7131
7162
  return;
7132
7163
  }
7164
+ const emailKind = getContextString(metadata.emailKind);
7165
+ if (emailKind === "attachment") {
7166
+ return "Attachment evidence";
7167
+ }
7168
+ if (emailKind === "message") {
7169
+ const from = getContextString(metadata.from);
7170
+ return from ? `Message from ${from}` : "Message evidence";
7171
+ }
7133
7172
  const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
7134
7173
  if (page) {
7135
7174
  return `Page ${page}`;
@@ -7156,6 +7195,57 @@ var buildContextLabel = (metadata) => {
7156
7195
  }
7157
7196
  return;
7158
7197
  };
7198
+ var buildLocatorLabel = (metadata, source, title) => {
7199
+ if (!metadata) {
7200
+ return;
7201
+ }
7202
+ const page = getContextNumber(metadata.page) ?? getContextNumber(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
7203
+ if (page) {
7204
+ return `Page ${page}`;
7205
+ }
7206
+ const sheet = getContextString(metadata.sheetName) ?? (Array.isArray(metadata.sheetNames) ? getContextString(metadata.sheetNames[0]) : undefined);
7207
+ if (sheet) {
7208
+ return `Sheet ${sheet}`;
7209
+ }
7210
+ const slide = getContextNumber(metadata.slide) ?? getContextNumber(metadata.slideNumber) ?? (typeof metadata.slideIndex === "number" ? metadata.slideIndex + 1 : undefined);
7211
+ if (slide) {
7212
+ return `Slide ${slide}`;
7213
+ }
7214
+ const archiveEntry = getContextString(metadata.archiveEntryPath) ?? getContextString(metadata.entryPath);
7215
+ if (archiveEntry) {
7216
+ return `Archive entry ${archiveEntry}`;
7217
+ }
7218
+ const emailKind = getContextString(metadata.emailKind);
7219
+ if (emailKind === "attachment") {
7220
+ const attachmentName = getContextString(metadata.attachmentName) ?? getAttachmentName(source, title);
7221
+ return attachmentName ? `Attachment ${attachmentName}` : "Attachment";
7222
+ }
7223
+ const mediaStart = formatMediaTimestamp(metadata.startMs);
7224
+ const mediaEnd = formatMediaTimestamp(metadata.endMs);
7225
+ if (mediaStart && mediaEnd) {
7226
+ return `Timestamp ${mediaStart} - ${mediaEnd}`;
7227
+ }
7228
+ if (mediaStart) {
7229
+ return `Timestamp ${mediaStart}`;
7230
+ }
7231
+ return;
7232
+ };
7233
+ var buildProvenanceLabel = (metadata) => {
7234
+ if (!metadata) {
7235
+ return;
7236
+ }
7237
+ const threadTopic = getContextString(metadata.threadTopic);
7238
+ const from = getContextString(metadata.from);
7239
+ const sentAt = formatTimestampLabel(metadata.sentAt) ?? formatTimestampLabel(metadata.receivedAt);
7240
+ const speaker = getContextString(metadata.speaker);
7241
+ const labels = [
7242
+ threadTopic ? `Thread ${threadTopic}` : "",
7243
+ speaker ? `Speaker ${speaker}` : "",
7244
+ from ? `Sender ${from}` : "",
7245
+ sentAt ? `Sent ${sentAt}` : ""
7246
+ ].filter((value) => value.length > 0);
7247
+ return labels.length > 0 ? labels.join(" \xB7 ") : undefined;
7248
+ };
7159
7249
  var buildRAGCitationReferenceMap = (citations) => Object.fromEntries(citations.map((citation, index) => [citation.chunkId, index + 1]));
7160
7250
  var buildRAGCitations = (sources) => {
7161
7251
  const unique = new Map;
@@ -7167,9 +7257,12 @@ var buildRAGCitations = (sources) => {
7167
7257
  continue;
7168
7258
  unique.set(key, {
7169
7259
  chunkId: source.chunkId,
7260
+ contextLabel: buildContextLabel(source.metadata),
7170
7261
  key,
7171
7262
  label: buildSourceLabel(source),
7263
+ locatorLabel: buildLocatorLabel(source.metadata, source.source, source.title),
7172
7264
  metadata: source.metadata,
7265
+ provenanceLabel: buildProvenanceLabel(source.metadata),
7173
7266
  score: source.score,
7174
7267
  source: source.source,
7175
7268
  text: source.text,
@@ -7246,8 +7339,10 @@ var buildRAGGroundingReferences = (sources) => {
7246
7339
  contextLabel: buildContextLabel(citation.metadata),
7247
7340
  excerpt: buildExcerpt(citation.text),
7248
7341
  label: citation.label,
7342
+ locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
7249
7343
  metadata: citation.metadata,
7250
7344
  number: citationReferenceMap[citation.chunkId] ?? 0,
7345
+ provenanceLabel: citation.provenanceLabel ?? buildProvenanceLabel(citation.metadata),
7251
7346
  score: citation.score,
7252
7347
  source: citation.source,
7253
7348
  text: citation.text,
@@ -10096,5 +10191,5 @@ export {
10096
10191
  aiChat
10097
10192
  };
10098
10193
 
10099
- //# debugId=BD95265DF2B97B7764756E2164756E21
10194
+ //# debugId=A6A9C1B546E5A8FD64756E2164756E21
10100
10195
  //# sourceMappingURL=index.js.map