@absolutejs/absolute 0.19.0-beta.617 → 0.19.0-beta.619

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.
@@ -654,7 +654,7 @@ export type RAGChunkSection = {
654
654
  title?: string;
655
655
  path?: string[];
656
656
  depth?: number;
657
- kind?: 'markdown_heading' | 'html_heading' | 'office_heading' | 'spreadsheet_rows' | 'presentation_slide';
657
+ kind?: 'markdown_heading' | 'html_heading' | 'office_heading' | 'office_block' | 'pdf_block' | 'spreadsheet_rows' | 'presentation_slide';
658
658
  };
659
659
  export type RAGChunkSequence = {
660
660
  sectionChunkId?: string;
@@ -688,7 +688,7 @@ export type RAGChunkGraphSectionGroup = {
688
688
  title?: string;
689
689
  path?: string[];
690
690
  depth?: number;
691
- kind?: 'markdown_heading' | 'html_heading' | 'office_heading' | 'spreadsheet_rows' | 'presentation_slide';
691
+ kind?: 'markdown_heading' | 'html_heading' | 'office_heading' | 'office_block' | 'pdf_block' | 'spreadsheet_rows' | 'presentation_slide';
692
692
  chunkIds: string[];
693
693
  chunkCount: number;
694
694
  leadChunkId?: string;
@@ -2903,6 +2903,7 @@ export type RAGRetrievalLanePromotionStateSummary = {
2903
2903
  export type RAGRetrievalReleaseIncidentRecord = {
2904
2904
  id: string;
2905
2905
  groupKey: string;
2906
+ corpusGroupKey?: string;
2906
2907
  targetRolloutLabel?: RAGRetrievalBaselineRecord['rolloutLabel'];
2907
2908
  severity: 'warning' | 'critical';
2908
2909
  status: 'open' | 'resolved';
@@ -2054,6 +2054,7 @@ var createRAGFileRetrievalLaneHandoffDecisionStore = (path) => ({
2054
2054
  });
2055
2055
  var createRAGFileRetrievalReleaseIncidentStore = (path) => ({
2056
2056
  listIncidents: async ({
2057
+ corpusGroupKey,
2057
2058
  groupKey,
2058
2059
  limit,
2059
2060
  severity,
@@ -2070,7 +2071,7 @@ var createRAGFileRetrievalReleaseIncidentStore = (path) => ({
2070
2071
  throw error;
2071
2072
  }
2072
2073
  }
2073
- const filtered = parsed.filter((entry) => (!groupKey || entry.groupKey === groupKey) && (!targetRolloutLabel || entry.targetRolloutLabel === targetRolloutLabel) && (!severity || entry.severity === severity) && (!status || entry.status === status));
2074
+ const filtered = parsed.filter((entry) => (!corpusGroupKey || entry.corpusGroupKey === corpusGroupKey) && (!groupKey || entry.groupKey === groupKey) && (!targetRolloutLabel || entry.targetRolloutLabel === targetRolloutLabel) && (!severity || entry.severity === severity) && (!status || entry.status === status));
2074
2075
  const sorted = normalizeRetrievalReleaseIncidentRecords(filtered);
2075
2076
  return typeof limit === "number" ? sorted.slice(0, limit) : sorted;
2076
2077
  },
@@ -3053,12 +3054,14 @@ var loadRAGRetrievalLaneHandoffDecisions = async ({
3053
3054
  })));
3054
3055
  var loadRAGRetrievalReleaseIncidents = async ({
3055
3056
  store,
3057
+ corpusGroupKey,
3056
3058
  groupKey,
3057
3059
  limit,
3058
3060
  targetRolloutLabel,
3059
3061
  status,
3060
3062
  severity
3061
3063
  }) => normalizeRetrievalReleaseIncidentRecords(await Promise.resolve(store.listIncidents({
3064
+ corpusGroupKey,
3062
3065
  groupKey,
3063
3066
  limit,
3064
3067
  severity,
@@ -4234,6 +4237,25 @@ var buildContextLabel2 = (metadata) => {
4234
4237
  if (!metadata) {
4235
4238
  return;
4236
4239
  }
4240
+ const pdfTextKind = getContextString2(metadata.pdfTextKind);
4241
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
4242
+ const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
4243
+ const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
4244
+ if (pdfTextKind === "table_like" && sectionTitle) {
4245
+ return `PDF table block ${sectionTitle}`;
4246
+ }
4247
+ if (pdfTextKind === "paragraph" && sectionTitle) {
4248
+ return `PDF text block ${sectionTitle}`;
4249
+ }
4250
+ if (officeBlockKind === "table" && sectionTitle) {
4251
+ return `Office table block ${sectionTitle}`;
4252
+ }
4253
+ if (officeBlockKind === "list" && sectionTitle) {
4254
+ return `Office list block ${sectionTitle}`;
4255
+ }
4256
+ if (officeBlockKind === "paragraph" && sectionTitle) {
4257
+ return `Office paragraph block ${sectionTitle}`;
4258
+ }
4237
4259
  const emailKind = getContextString2(metadata.emailKind);
4238
4260
  if (emailKind === "attachment") {
4239
4261
  return "Attachment evidence";
@@ -4270,8 +4292,6 @@ var buildContextLabel2 = (metadata) => {
4270
4292
  if (speaker) {
4271
4293
  return `Speaker ${speaker}`;
4272
4294
  }
4273
- const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
4274
- const sectionTitle = getContextString2(metadata.sectionTitle) ?? sectionPath.at(-1);
4275
4295
  if (sectionTitle) {
4276
4296
  return `Section ${sectionTitle}`;
4277
4297
  }
@@ -4281,11 +4301,21 @@ var buildLocatorLabel2 = (metadata, source, title) => {
4281
4301
  if (!metadata) {
4282
4302
  return;
4283
4303
  }
4304
+ const pdfTextKind = getContextString2(metadata.pdfTextKind);
4305
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
4306
+ const pdfBlockNumber = getContextNumber2(metadata.pdfBlockNumber);
4307
+ const officeBlockNumber = getContextNumber2(metadata.officeBlockNumber);
4284
4308
  const page = getContextNumber2(metadata.page) ?? getContextNumber2(metadata.pageNumber) ?? (typeof metadata.pageIndex === "number" ? metadata.pageIndex + 1 : undefined);
4285
4309
  const region = getContextNumber2(metadata.regionNumber) ?? (typeof metadata.regionIndex === "number" ? metadata.regionIndex + 1 : undefined);
4286
4310
  if (page && region) {
4287
4311
  return `Page ${page} \xB7 Region ${region}`;
4288
4312
  }
4313
+ if (page && pdfBlockNumber && pdfTextKind === "table_like") {
4314
+ return `Page ${page} \xB7 Table Block ${pdfBlockNumber}`;
4315
+ }
4316
+ if (page && pdfBlockNumber) {
4317
+ return `Page ${page} \xB7 Text Block ${pdfBlockNumber}`;
4318
+ }
4289
4319
  if (page) {
4290
4320
  return `Page ${page}`;
4291
4321
  }
@@ -4314,6 +4344,15 @@ var buildLocatorLabel2 = (metadata, source, title) => {
4314
4344
  if (mediaStart) {
4315
4345
  return `Timestamp ${mediaStart}`;
4316
4346
  }
4347
+ if (officeBlockNumber && officeBlockKind === "table") {
4348
+ return `Office table block ${officeBlockNumber}`;
4349
+ }
4350
+ if (officeBlockNumber && officeBlockKind === "list") {
4351
+ return `Office list block ${officeBlockNumber}`;
4352
+ }
4353
+ if (officeBlockNumber && officeBlockKind === "paragraph") {
4354
+ return `Office paragraph block ${officeBlockNumber}`;
4355
+ }
4317
4356
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : [];
4318
4357
  if (sectionPath.length > 0) {
4319
4358
  return `Section ${sectionPath.join(" > ")}`;
@@ -4331,12 +4370,16 @@ var buildProvenanceLabel2 = (metadata) => {
4331
4370
  const mediaKind = getContextString2(metadata.mediaKind);
4332
4371
  const transcriptSource = getContextString2(metadata.transcriptSource);
4333
4372
  const pdfTextMode = getContextString2(metadata.pdfTextMode);
4373
+ const pdfTextKind = getContextString2(metadata.pdfTextKind);
4374
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
4334
4375
  const ocrEngine = getContextString2(metadata.ocrEngine);
4335
4376
  const extractorRegistryMatch = getContextString2(metadata.extractorRegistryMatch);
4336
4377
  const chunkingProfile = getContextString2(metadata.chunkingProfile);
4337
4378
  const ocrConfidence = getContextNumber2(metadata.ocrRegionConfidence) ?? getContextNumber2(metadata.ocrConfidence);
4338
4379
  const labels = [
4339
4380
  pdfTextMode ? `PDF ${pdfTextMode}` : "",
4381
+ pdfTextKind === "table_like" ? "PDF table block" : pdfTextKind === "paragraph" ? "PDF text block" : "",
4382
+ officeBlockKind ? `Office ${officeBlockKind}` : "",
4340
4383
  ocrEngine ? `OCR ${ocrEngine}` : "",
4341
4384
  extractorRegistryMatch ? `Extractor ${extractorRegistryMatch}` : "",
4342
4385
  chunkingProfile ? `Chunking ${chunkingProfile}` : "",
@@ -4372,7 +4415,7 @@ var buildRAGChunkStructure = (metadata) => {
4372
4415
  return;
4373
4416
  }
4374
4417
  const sectionPath = Array.isArray(metadata.sectionPath) ? metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : undefined;
4375
- const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" || metadata.sectionKind === "office_heading" || metadata.sectionKind === "spreadsheet_rows" || metadata.sectionKind === "presentation_slide" ? metadata.sectionKind : undefined;
4418
+ const sectionKind = metadata.sectionKind === "markdown_heading" || metadata.sectionKind === "html_heading" || metadata.sectionKind === "office_heading" || metadata.sectionKind === "office_block" || metadata.sectionKind === "pdf_block" || metadata.sectionKind === "spreadsheet_rows" || metadata.sectionKind === "presentation_slide" ? metadata.sectionKind : undefined;
4376
4419
  const section = {
4377
4420
  depth: getContextNumber2(metadata.sectionDepth),
4378
4421
  kind: sectionKind,
@@ -4692,7 +4735,7 @@ var buildRAGSourceSummaries = (sources) => {
4692
4735
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
4693
4736
  return sourceGroups.map((group) => {
4694
4737
  const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
4695
- const leadChunk = group.chunks.slice().sort((left, right) => right.score - left.score)[0];
4738
+ const leadChunk = getPreferredSourceLeadChunk(group.chunks);
4696
4739
  const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
4697
4740
  const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
4698
4741
  const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
@@ -4720,13 +4763,45 @@ var getSectionPathFromSource = (source) => {
4720
4763
  const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
4721
4764
  return path.length > 0 ? path : undefined;
4722
4765
  };
4766
+ var isBlockAwareContextLabel = (value) => typeof value === "string" && (value.startsWith("PDF ") || value.startsWith("Office "));
4767
+ var getStructuredSectionScoreWeight = (metadata) => {
4768
+ if (!metadata) {
4769
+ return 1;
4770
+ }
4771
+ const pdfTextKind = getContextString2(metadata.pdfTextKind);
4772
+ const officeBlockKind = getContextString2(metadata.officeBlockKind);
4773
+ const sectionKind = getContextString2(metadata.sectionKind);
4774
+ if (pdfTextKind === "table_like") {
4775
+ return 1.28;
4776
+ }
4777
+ if (officeBlockKind === "table" || officeBlockKind === "list") {
4778
+ return 1.24;
4779
+ }
4780
+ if (sectionKind === "pdf_block" || sectionKind === "office_block" || officeBlockKind === "paragraph" || pdfTextKind === "paragraph") {
4781
+ return 1.12;
4782
+ }
4783
+ return 1;
4784
+ };
4785
+ var getStructuredSourceLeadScore = (source) => source.score * getStructuredSectionScoreWeight(source.metadata);
4786
+ var getPreferredSourceLeadChunk = (chunks) => chunks.slice().sort((left, right) => {
4787
+ const leftWeightedScore = getStructuredSourceLeadScore(left);
4788
+ const rightWeightedScore = getStructuredSourceLeadScore(right);
4789
+ if (rightWeightedScore !== leftWeightedScore) {
4790
+ return rightWeightedScore - leftWeightedScore;
4791
+ }
4792
+ if (right.score !== left.score) {
4793
+ return right.score - left.score;
4794
+ }
4795
+ return left.chunkId.localeCompare(right.chunkId);
4796
+ })[0];
4723
4797
  var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4724
- const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
4798
+ const totalScore = sources.reduce((sum, source) => sum + source.score * getStructuredSectionScoreWeight(source.metadata), 0);
4725
4799
  if (sources.length === 0 || totalScore <= 0) {
4726
4800
  return [];
4727
4801
  }
4728
4802
  const sections = new Map;
4729
4803
  for (const source of sources) {
4804
+ const structuredScore = source.score * getStructuredSectionScoreWeight(source.metadata);
4730
4805
  const path = getSectionPathFromSource(source);
4731
4806
  if (!path) {
4732
4807
  continue;
@@ -4758,7 +4833,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4758
4833
  sourceSet: new Set(source.source ? [source.source] : []),
4759
4834
  topChunkId: source.chunkId,
4760
4835
  topSource: source.source,
4761
- totalScore: source.score,
4836
+ totalScore: structuredScore,
4762
4837
  transformedHits,
4763
4838
  variantHits,
4764
4839
  vectorHits
@@ -4766,7 +4841,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4766
4841
  continue;
4767
4842
  }
4768
4843
  existing.count += 1;
4769
- existing.totalScore += source.score;
4844
+ existing.totalScore += structuredScore;
4770
4845
  if (source.source) {
4771
4846
  existing.sourceSet.add(source.source);
4772
4847
  }
@@ -4794,6 +4869,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4794
4869
  const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
4795
4870
  const scoreShare = section.totalScore / totalScore;
4796
4871
  const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
4872
+ const topChunk = sources.find((source) => source.chunkId === section.topChunkId);
4873
+ const topContextLabel = topChunk?.labels?.contextLabel ?? buildContextLabel2(topChunk?.metadata);
4797
4874
  const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
4798
4875
  count: entry.count,
4799
4876
  isActive: entry.key === section.key,
@@ -4919,6 +4996,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4919
4996
  reasons.push("concentrated_evidence");
4920
4997
  }
4921
4998
  const summaryParts = [
4999
+ isBlockAwareContextLabel(topContextLabel) ? topContextLabel : "",
4922
5000
  `${section.count} hit${section.count === 1 ? "" : "s"}`,
4923
5001
  `${(scoreShare * 100).toFixed(0)}% score share`,
4924
5002
  `vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
@@ -5130,22 +5208,21 @@ var updateSourceGroup = (groups, source) => {
5130
5208
  groups.set(key, buildSourceGroup(source, key));
5131
5209
  return;
5132
5210
  }
5133
- if (source.score > existing.bestScore) {
5134
- existing.bestScore = source.score;
5135
- existing.label = buildSourceLabel2(source);
5136
- existing.labels = source.labels ?? buildRAGSourceLabels({
5137
- metadata: source.metadata,
5138
- source: source.source,
5139
- title: source.title
5140
- });
5141
- existing.structure = source.structure ?? buildRAGChunkStructure(source.metadata);
5142
- existing.source = source.source;
5143
- existing.title = source.title;
5144
- } else {
5145
- existing.bestScore = Math.max(existing.bestScore, source.score);
5146
- }
5211
+ existing.bestScore = Math.max(existing.bestScore, source.score);
5147
5212
  existing.count += 1;
5148
5213
  existing.chunks.push(source);
5214
+ const leadChunk = getPreferredSourceLeadChunk(existing.chunks);
5215
+ if (leadChunk) {
5216
+ existing.label = buildSourceLabel2(leadChunk);
5217
+ existing.labels = leadChunk.labels ?? buildRAGSourceLabels({
5218
+ metadata: leadChunk.metadata,
5219
+ source: leadChunk.source,
5220
+ title: leadChunk.title
5221
+ });
5222
+ existing.structure = leadChunk.structure ?? buildRAGChunkStructure(leadChunk.metadata);
5223
+ existing.source = leadChunk.source;
5224
+ existing.title = leadChunk.title;
5225
+ }
5149
5226
  };
5150
5227
  var getLatestAssistantMessage = (messages) => {
5151
5228
  for (let index = messages.length - 1;index >= 0; index -= 1) {
@@ -8270,5 +8347,5 @@ export {
8270
8347
  AIStreamKey
8271
8348
  };
8272
8349
 
8273
- //# debugId=E7B3F402B4D49F5064756E2164756E21
8350
+ //# debugId=3BF09D693D2DEE1B64756E2164756E21
8274
8351
  //# sourceMappingURL=index.js.map