@absolutejs/absolute 0.19.0-beta.507 → 0.19.0-beta.509

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
@@ -2221,6 +2221,16 @@ var extractWeightedLexicalFields = (result) => {
2221
2221
  const source = result.source ?? "";
2222
2222
  const archivePath = typeof metadata.archivePath === "string" ? metadata.archivePath : source.includes("#") ? source.split("#")[1] ?? "" : "";
2223
2223
  const mediaSegments = Array.isArray(metadata.mediaSegments) ? metadata.mediaSegments.map((segment) => segment && typeof segment === "object" ? toFieldText(segment) : "").filter(Boolean).join(" ") : "";
2224
+ const mediaTimestampFocus = metadata.sourceNativeKind === "media_segment" ? [
2225
+ typeof metadata.mediaKind === "string" ? metadata.mediaKind : "",
2226
+ "audio",
2227
+ "video",
2228
+ "media",
2229
+ "timestamp",
2230
+ "segment",
2231
+ typeof metadata.mediaSegmentStartMs === "number" ? `timestamp ${metadata.mediaSegmentStartMs}` : "",
2232
+ typeof metadata.mediaSegmentEndMs === "number" ? `timestamp ${metadata.mediaSegmentEndMs}` : ""
2233
+ ].filter(Boolean).join(" ") : "";
2224
2234
  const spreadsheetFocus = metadata.sourceNativeKind === "spreadsheet_sheet" ? [
2225
2235
  "spreadsheet",
2226
2236
  "workbook",
@@ -2231,6 +2241,7 @@ var extractWeightedLexicalFields = (result) => {
2231
2241
  ].filter(Boolean).join(" ") : "";
2232
2242
  const metadataFocus = [
2233
2243
  metadata.sourceNativeKind,
2244
+ mediaTimestampFocus,
2234
2245
  spreadsheetFocus,
2235
2246
  metadata.sheetName,
2236
2247
  metadata.sheetNames,
@@ -2445,7 +2456,9 @@ var resolveFileKindBoost = (queryTokens, metadata) => {
2445
2456
  "framework",
2446
2457
  "transcript",
2447
2458
  "audio",
2448
- "video"
2459
+ "video",
2460
+ "timestamp",
2461
+ "segment"
2449
2462
  ])) {
2450
2463
  return 0.75;
2451
2464
  }
@@ -2461,7 +2474,8 @@ var resolveTranscriptBoost = (queryTokens, metadata) => {
2461
2474
  return 0;
2462
2475
  }
2463
2476
  const overlap = queryTokens.filter((token) => segmentText.includes(token)).length;
2464
- return overlap / Math.max(1, queryTokens.length);
2477
+ const timestampBoost = queryTokens.includes("timestamp") ? 0.35 : 0;
2478
+ return Math.min(1, overlap / Math.max(1, queryTokens.length) + timestampBoost);
2465
2479
  };
2466
2480
  var resolveArchiveBoost = (queryTokens, result) => {
2467
2481
  const archivePath = typeof result.metadata?.archivePath === "string" ? result.metadata.archivePath.toLowerCase() : typeof result.source === "string" && result.source.includes("#") ? result.source.split("#")[1]?.toLowerCase() ?? "" : "";
@@ -2701,6 +2715,17 @@ var detectDomains = (tokens) => {
2701
2715
  return [...domains];
2702
2716
  };
2703
2717
  var uniqueQueryStrings = (values) => Array.from(new Set(values.map((value) => value.trim()).filter((value) => value.length > 0)));
2718
+ var hasExplicitTimestamp = (query) => /\b\d{1,2}:\d{2}\b/.test(query) || /\b\d{1,2}:\d{2}\s*(?:to|-)\s*\d{1,2}:\d{2}\b/i.test(query);
2719
+ var hasNamedSourcePhrase = (query) => /\bnamed\s+[a-z0-9]/i.test(query) || /\btitled\s+[a-z0-9]/i.test(query);
2720
+ var shouldPreservePrimaryQuery = (query, domains) => {
2721
+ if (hasExplicitTimestamp(query) && (domains.includes("audio") || domains.includes("video"))) {
2722
+ return true;
2723
+ }
2724
+ if (hasNamedSourcePhrase(query) && domains.includes("spreadsheet")) {
2725
+ return true;
2726
+ }
2727
+ return false;
2728
+ };
2704
2729
  var createHeuristicRAGQueryTransform = (options = {}) => createRAGQueryTransform({
2705
2730
  defaultModel: options.defaultModel ?? "absolute-heuristic-query-transform",
2706
2731
  providerName: options.providerName ?? "absolute_heuristic",
@@ -2744,9 +2769,10 @@ var createHeuristicRAGQueryTransform = (options = {}) => createRAGQueryTransform
2744
2769
  if (mediaTimestampVariant.length > 0) {
2745
2770
  variants.push(mediaTimestampVariant);
2746
2771
  }
2772
+ const preservePrimaryQuery = shouldPreservePrimaryQuery(query, domains);
2747
2773
  return {
2748
- query: rewrittenQuery,
2749
- variants: uniqueQueryStrings(variants)
2774
+ query: preservePrimaryQuery ? query : rewrittenQuery,
2775
+ variants: uniqueQueryStrings(preservePrimaryQuery ? [rewrittenQuery, ...variants] : variants)
2750
2776
  };
2751
2777
  }
2752
2778
  });
@@ -3055,6 +3081,16 @@ var normalizeWhitespace = (value) => value.replace(/\r\n?/g, `
3055
3081
  `).replace(/\n{3,}/g, `
3056
3082
 
3057
3083
  `).trim();
3084
+ var formatMediaTimestampForIngest = (value) => {
3085
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
3086
+ return;
3087
+ }
3088
+ const totalSeconds = Math.floor(value / 1000);
3089
+ const minutes = Math.floor(totalSeconds / 60);
3090
+ const seconds = totalSeconds % 60;
3091
+ const milliseconds = Math.floor(value % 1000);
3092
+ return `${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}.${String(milliseconds).padStart(3, "0")}`;
3093
+ };
3058
3094
  var decodeHtmlEntities = (value) => {
3059
3095
  let output = value;
3060
3096
  for (const [pattern, replacement] of HTML_ENTITY_REPLACEMENTS) {
@@ -3687,6 +3723,9 @@ var createRAGMediaFileExtractor = (transcriber) => ({
3687
3723
  }
3688
3724
  const startMs = typeof segment.startMs === "number" ? segment.startMs : undefined;
3689
3725
  const endMs = typeof segment.endMs === "number" ? segment.endMs : undefined;
3726
+ const startLabel = formatMediaTimestampForIngest(startMs);
3727
+ const endLabel = formatMediaTimestampForIngest(endMs);
3728
+ const mediaKind = typeof result.metadata?.mediaKind === "string" ? result.metadata.mediaKind : "media";
3690
3729
  segmentDocuments.push({
3691
3730
  chunking: input.chunking,
3692
3731
  contentType: input.contentType,
@@ -3703,9 +3742,9 @@ var createRAGMediaFileExtractor = (transcriber) => ({
3703
3742
  speaker: typeof segment.speaker === "string" ? segment.speaker : undefined
3704
3743
  },
3705
3744
  source,
3706
- text: normalizeWhitespace(`Media transcript segment${typeof startMs === "number" ? ` ${startMs}-${endMs ?? startMs}ms` : ""} from ${input.title ?? input.name ?? input.path ?? DEFAULT_BINARY_NAME}.
3745
+ text: normalizeWhitespace(`${mediaKind} transcript segment${startLabel ? ` at timestamp ${startLabel}${endLabel ? ` to ${endLabel}` : ""}` : ""} from ${input.title ?? input.name ?? input.path ?? DEFAULT_BINARY_NAME}. ` + `${mediaKind} timestamp evidence${startLabel ? ` ${startLabel}${endLabel ? ` to ${endLabel}` : ""}` : ""}.` + `
3707
3746
  ${text}`),
3708
- title: input.title ? `${input.title} \xB7 Segment ${index + 1}` : `Segment ${index + 1}`
3747
+ title: input.title ? `${input.title} \xB7 ${mediaKind[0]?.toUpperCase() + mediaKind.slice(1)} segment ${index + 1}` : `${mediaKind[0]?.toUpperCase() + mediaKind.slice(1)} segment ${index + 1}`
3709
3748
  });
3710
3749
  }
3711
3750
  const summaryDocument = {
@@ -10238,5 +10277,5 @@ export {
10238
10277
  aiChat
10239
10278
  };
10240
10279
 
10241
- //# debugId=80FE4F97C8F27FEB64756E2164756E21
10280
+ //# debugId=E4C202F91B1AEC6364756E2164756E21
10242
10281
  //# sourceMappingURL=index.js.map