@absolutejs/absolute 0.19.0-beta.609 → 0.19.0-beta.610

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.
Files changed (44) hide show
  1. package/dist/ai/client/index.js +244 -21
  2. package/dist/ai/client/index.js.map +4 -4
  3. package/dist/ai/client/ui.js +245 -21
  4. package/dist/ai/client/ui.js.map +4 -4
  5. package/dist/ai/index.js +294 -28
  6. package/dist/ai/index.js.map +7 -7
  7. package/dist/ai/rag/quality.js +53 -11
  8. package/dist/ai/rag/quality.js.map +3 -3
  9. package/dist/ai/rag/ui.js +245 -21
  10. package/dist/ai/rag/ui.js.map +4 -4
  11. package/dist/ai-client/angular/ai/index.js +243 -20
  12. package/dist/ai-client/react/ai/index.js +262 -20
  13. package/dist/ai-client/vue/ai/index.js +262 -20
  14. package/dist/angular/ai/index.js +244 -21
  15. package/dist/angular/ai/index.js.map +4 -4
  16. package/dist/angular/index.js +2 -2
  17. package/dist/angular/index.js.map +1 -1
  18. package/dist/angular/server.js +2 -2
  19. package/dist/angular/server.js.map +1 -1
  20. package/dist/build.js +2 -2
  21. package/dist/build.js.map +1 -1
  22. package/dist/index.js +2 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/react/ai/index.js +263 -21
  25. package/dist/react/ai/index.js.map +6 -6
  26. package/dist/src/ai/client/ui.d.ts +1 -1
  27. package/dist/src/ai/rag/index.d.ts +1 -1
  28. package/dist/src/ai/rag/presentation.d.ts +8 -1
  29. package/dist/src/ai/rag/ui.d.ts +1 -1
  30. package/dist/src/react/ai/useRAG.d.ts +3 -0
  31. package/dist/src/react/ai/useRAGChunkPreview.d.ts +2 -0
  32. package/dist/src/react/ai/useRAGSources.d.ts +1 -0
  33. package/dist/src/svelte/ai/createRAG.d.ts +3 -0
  34. package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +2 -0
  35. package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
  36. package/dist/src/vue/ai/useRAG.d.ts +11 -0
  37. package/dist/src/vue/ai/useRAGChunkPreview.d.ts +10 -0
  38. package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
  39. package/dist/svelte/ai/index.js +263 -21
  40. package/dist/svelte/ai/index.js.map +6 -6
  41. package/dist/types/ai.d.ts +56 -0
  42. package/dist/vue/ai/index.js +263 -21
  43. package/dist/vue/ai/index.js.map +6 -6
  44. package/package.json +1 -1
@@ -349,21 +349,48 @@ var buildExcerpt = (text, maxLength = 160) => {
349
349
  };
350
350
  var selectPreferredExcerpt = (excerpts, sectionChunkCount) => {
351
351
  if (!excerpts) {
352
- return "";
352
+ return {
353
+ excerpt: "",
354
+ mode: "chunk",
355
+ reason: "single_chunk"
356
+ };
353
357
  }
354
358
  const chunkExcerpt = excerpts.chunkExcerpt?.trim() ?? "";
355
359
  const windowExcerpt = excerpts.windowExcerpt?.trim() ?? "";
356
360
  const sectionExcerpt = excerpts.sectionExcerpt?.trim() ?? "";
357
361
  if (sectionChunkCount && sectionChunkCount > 1 && chunkExcerpt.length > 0 && chunkExcerpt.length < 72) {
358
362
  if (sectionChunkCount <= 3 && sectionExcerpt) {
359
- return sectionExcerpt;
363
+ return {
364
+ excerpt: sectionExcerpt,
365
+ mode: "section",
366
+ reason: "section_small_enough"
367
+ };
360
368
  }
361
369
  if (windowExcerpt) {
362
- return windowExcerpt;
370
+ return {
371
+ excerpt: windowExcerpt,
372
+ mode: "window",
373
+ reason: "section_too_large_use_window"
374
+ };
363
375
  }
376
+ return {
377
+ excerpt: chunkExcerpt,
378
+ mode: "chunk",
379
+ reason: "chunk_too_narrow"
380
+ };
364
381
  }
365
- return chunkExcerpt || windowExcerpt || sectionExcerpt;
382
+ return {
383
+ excerpt: chunkExcerpt || windowExcerpt || sectionExcerpt,
384
+ mode: "chunk",
385
+ reason: (sectionChunkCount ?? 0) > 1 ? "chunk_too_narrow" : "single_chunk"
386
+ };
366
387
  };
388
+ var buildExcerptModeCounts = (references) => references.reduce((counts, reference) => {
389
+ if (reference?.excerptSelection) {
390
+ counts[reference.excerptSelection.mode] += 1;
391
+ }
392
+ return counts;
393
+ }, { chunk: 0, section: 0, window: 0 });
367
394
  var buildGroundingChunkExcerpts = (sources, activeChunkId) => {
368
395
  if (sources.length === 0) {
369
396
  return;
@@ -419,8 +446,9 @@ var buildGroundedAnswerCitationDetail = (reference) => ({
419
446
  contextLabel: reference.contextLabel,
420
447
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
421
448
  evidenceSummary: buildGroundingReferenceEvidenceSummary(reference),
422
- excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || reference.excerpt,
449
+ excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || reference.excerpt,
423
450
  excerpts: reference.excerpts,
451
+ excerptSelection: reference.excerptSelection,
424
452
  label: reference.label,
425
453
  locatorLabel: reference.locatorLabel,
426
454
  number: reference.number,
@@ -437,11 +465,14 @@ var buildRAGCitations = (sources) => {
437
465
  const hasBetterExisting = existing !== undefined && existing.score >= source.score;
438
466
  if (hasBetterExisting)
439
467
  continue;
468
+ const excerpts = buildGroundingChunkExcerpts(sources, source.chunkId);
469
+ const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(source.metadata?.sectionChunkCount));
440
470
  unique.set(key, {
441
471
  chunkId: source.chunkId,
442
472
  contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
443
- excerpt: selectPreferredExcerpt(buildGroundingChunkExcerpts(sources, source.chunkId), getContextNumber(source.metadata?.sectionChunkCount)) || buildExcerpt(source.text),
444
- excerpts: buildGroundingChunkExcerpts(sources, source.chunkId),
473
+ excerpt: excerptSelection.excerpt || buildExcerpt(source.text),
474
+ excerpts,
475
+ excerptSelection,
445
476
  key,
446
477
  label: buildSourceLabel(source),
447
478
  locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
@@ -462,6 +493,7 @@ var buildRAGCitations = (sources) => {
462
493
  };
463
494
  var buildRAGGroundedAnswer = (content, sources) => {
464
495
  const references = buildRAGGroundingReferences(sources);
496
+ const sectionSummaries = buildRAGGroundedAnswerSectionSummaries(references);
465
497
  const referenceMap = new Map(references.map((reference) => [reference.number, reference]));
466
498
  const parts = [];
467
499
  const ungroundedReferenceNumbers = new Set;
@@ -505,10 +537,14 @@ var buildRAGGroundedAnswer = (content, sources) => {
505
537
  return {
506
538
  content,
507
539
  coverage,
540
+ excerptModeCounts: buildExcerptModeCounts([
541
+ ...references,
542
+ ...sectionSummaries
543
+ ]),
508
544
  hasCitations,
509
545
  parts,
510
546
  references,
511
- sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
547
+ sectionSummaries,
512
548
  ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
513
549
  };
514
550
  };
@@ -527,8 +563,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
527
563
  chunkIds: [reference.chunkId],
528
564
  contextLabel: reference.contextLabel,
529
565
  count: 1,
530
- excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || excerpts?.sectionExcerpt || reference.excerpt,
566
+ excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || excerpts?.sectionExcerpt || reference.excerpt,
531
567
  excerpts,
568
+ excerptSelection: reference.excerptSelection,
532
569
  key,
533
570
  label: key,
534
571
  locatorLabel: reference.locatorLabel,
@@ -564,6 +601,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
564
601
  };
565
602
  existing.excerpt = reference.excerpts.sectionExcerpt;
566
603
  }
604
+ if (!existing.excerptSelection && reference.excerptSelection) {
605
+ existing.excerptSelection = reference.excerptSelection;
606
+ }
567
607
  }
568
608
  return [...groups.values()].map((group) => ({
569
609
  ...group,
@@ -583,11 +623,13 @@ var buildRAGGroundingReferences = (sources) => {
583
623
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
584
624
  return citations.map((citation) => {
585
625
  const excerpts = buildGroundingChunkExcerpts(sources, citation.chunkId);
626
+ const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount));
586
627
  return {
587
628
  chunkId: citation.chunkId,
588
629
  contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
589
- excerpt: selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount)) || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
630
+ excerpt: excerptSelection.excerpt || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
590
631
  excerpts,
632
+ excerptSelection,
591
633
  label: citation.label,
592
634
  locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
593
635
  metadata: citation.metadata,
@@ -4914,22 +4956,49 @@ var buildRAGChunkExcerpts = (chunks, activeChunkId) => {
4914
4956
  windowExcerpt: buildExcerpt2(collectText(orderedWindowIds), 240)
4915
4957
  };
4916
4958
  };
4917
- var buildRAGPreferredExcerpt = (excerpts, structure) => {
4959
+ var buildRAGExcerptSelection = (excerpts, structure) => {
4918
4960
  if (!excerpts) {
4919
- return "";
4961
+ return {
4962
+ excerpt: "",
4963
+ mode: "chunk",
4964
+ reason: "single_chunk"
4965
+ };
4920
4966
  }
4921
4967
  const chunkLength = excerpts.chunkExcerpt.trim().length;
4922
4968
  const sectionChunkCount = structure?.sequence?.sectionChunkCount ?? 1;
4923
4969
  if (sectionChunkCount > 1 && chunkLength > 0 && chunkLength < 72) {
4924
4970
  if (sectionChunkCount <= 3 && excerpts.sectionExcerpt.trim().length > 0) {
4925
- return excerpts.sectionExcerpt;
4971
+ return {
4972
+ excerpt: excerpts.sectionExcerpt,
4973
+ mode: "section",
4974
+ reason: "section_small_enough"
4975
+ };
4926
4976
  }
4927
4977
  if (excerpts.windowExcerpt.trim().length > 0) {
4928
- return excerpts.windowExcerpt;
4978
+ return {
4979
+ excerpt: excerpts.windowExcerpt,
4980
+ mode: "window",
4981
+ reason: "section_too_large_use_window"
4982
+ };
4929
4983
  }
4984
+ return {
4985
+ excerpt: excerpts.chunkExcerpt,
4986
+ mode: "chunk",
4987
+ reason: "chunk_too_narrow"
4988
+ };
4930
4989
  }
4931
- return excerpts.chunkExcerpt;
4990
+ return {
4991
+ excerpt: excerpts.chunkExcerpt,
4992
+ mode: "chunk",
4993
+ reason: sectionChunkCount > 1 ? "chunk_too_narrow" : "single_chunk"
4994
+ };
4932
4995
  };
4996
+ var buildRAGExcerptModeCounts = (selections) => selections.reduce((counts, selection) => {
4997
+ if (selection) {
4998
+ counts[selection.mode] += 1;
4999
+ }
5000
+ return counts;
5001
+ }, { chunk: 0, section: 0, window: 0 });
4933
5002
  var buildRAGChunkGraph = (chunks) => {
4934
5003
  const nodes = [];
4935
5004
  const edges = [];
@@ -5118,19 +5187,27 @@ var buildRAGRetrievedState = (messages) => {
5118
5187
  return null;
5119
5188
  }
5120
5189
  const sources = message.sources ?? [];
5190
+ const citations = buildRAGCitations(sources);
5191
+ const sectionDiagnostics = buildRAGSectionRetrievalDiagnostics(sources, isRAGRetrievalTrace(message.retrievalTrace) ? message.retrievalTrace : undefined);
5192
+ const sourceSummaries = buildRAGSourceSummaries(sources);
5121
5193
  const groundedAnswer = buildRAGGroundedAnswer(message.content, sources);
5122
5194
  return {
5123
- citationReferenceMap: buildRAGCitationReferenceMap(buildRAGCitations(sources)),
5124
- citations: buildRAGCitations(sources),
5195
+ citationReferenceMap: buildRAGCitationReferenceMap(citations),
5196
+ citations,
5125
5197
  conversationId: message.conversationId,
5198
+ excerptModeCounts: buildRAGExcerptModeCounts([
5199
+ ...citations.map((citation) => citation.excerptSelection),
5200
+ ...sourceSummaries.map((summary) => summary.excerptSelection)
5201
+ ]),
5126
5202
  groundedAnswer,
5127
5203
  messageId: message.id,
5128
5204
  retrievalDurationMs: message.retrievalDurationMs,
5129
5205
  retrievalStartedAt: message.retrievalStartedAt,
5130
5206
  retrievedAt: message.retrievedAt,
5131
5207
  trace: isRAGRetrievalTrace(message.retrievalTrace) ? message.retrievalTrace : undefined,
5208
+ sectionDiagnostics,
5132
5209
  sourceGroups: buildRAGSourceGroups(sources),
5133
- sourceSummaries: buildRAGSourceSummaries(sources),
5210
+ sourceSummaries,
5134
5211
  sources
5135
5212
  };
5136
5213
  };
@@ -5142,6 +5219,8 @@ var buildRAGSourceSummaries = (sources) => {
5142
5219
  const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
5143
5220
  const leadChunk = group.chunks.slice().sort((left, right) => right.score - left.score)[0];
5144
5221
  const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
5222
+ const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
5223
+ const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
5145
5224
  return {
5146
5225
  bestScore: group.bestScore,
5147
5226
  citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
@@ -5149,18 +5228,154 @@ var buildRAGSourceSummaries = (sources) => {
5149
5228
  chunkIds: group.chunks.map((chunk) => chunk.chunkId),
5150
5229
  contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
5151
5230
  count: group.count,
5152
- excerpt: buildRAGPreferredExcerpt(excerpts, leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata)) || buildExcerpt2(leadChunk?.text ?? ""),
5231
+ excerpt: excerptSelection.excerpt || buildExcerpt2(leadChunk?.text ?? ""),
5153
5232
  excerpts,
5233
+ excerptSelection,
5154
5234
  key: group.key,
5155
5235
  label: group.label,
5156
5236
  locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
5157
5237
  provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
5158
- structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
5238
+ structure,
5159
5239
  source: group.source,
5160
5240
  title: group.title
5161
5241
  };
5162
5242
  });
5163
5243
  };
5244
+ var getSectionPathFromSource = (source) => {
5245
+ const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
5246
+ return path.length > 0 ? path : undefined;
5247
+ };
5248
+ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
5249
+ const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
5250
+ if (sources.length === 0 || totalScore <= 0) {
5251
+ return [];
5252
+ }
5253
+ const sections = new Map;
5254
+ for (const source of sources) {
5255
+ const path = getSectionPathFromSource(source);
5256
+ if (!path) {
5257
+ continue;
5258
+ }
5259
+ const key = path.join(" > ");
5260
+ const label = path.at(-1) ?? key;
5261
+ const parentLabel = path.length > 1 ? path.slice(0, -1).join(" > ") : undefined;
5262
+ const existing = sections.get(key);
5263
+ const channels = Array.isArray(source.metadata?.retrievalChannels) ? source.metadata.retrievalChannels.filter((value) => value === "vector" || value === "lexical") : [];
5264
+ const isHybrid = channels.includes("vector") && channels.includes("lexical");
5265
+ const vectorHits = channels.includes("vector") ? 1 : 0;
5266
+ const lexicalHits = channels.includes("lexical") ? 1 : 0;
5267
+ const hybridHits = isHybrid ? 1 : 0;
5268
+ if (!existing) {
5269
+ sections.set(key, {
5270
+ bestScore: source.score,
5271
+ count: 1,
5272
+ hybridHits,
5273
+ key,
5274
+ label,
5275
+ lexicalHits,
5276
+ parentLabel,
5277
+ path,
5278
+ sourceSet: new Set(source.source ? [source.source] : []),
5279
+ topChunkId: source.chunkId,
5280
+ topSource: source.source,
5281
+ totalScore: source.score,
5282
+ vectorHits
5283
+ });
5284
+ continue;
5285
+ }
5286
+ existing.count += 1;
5287
+ existing.totalScore += source.score;
5288
+ if (source.source) {
5289
+ existing.sourceSet.add(source.source);
5290
+ }
5291
+ existing.vectorHits += vectorHits;
5292
+ existing.lexicalHits += lexicalHits;
5293
+ existing.hybridHits += hybridHits;
5294
+ if (source.score > existing.bestScore) {
5295
+ existing.bestScore = source.score;
5296
+ existing.topChunkId = source.chunkId;
5297
+ existing.topSource = source.source;
5298
+ }
5299
+ }
5300
+ const diagnostics = [...sections.values()];
5301
+ const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
5302
+ return diagnostics.map((section) => {
5303
+ const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
5304
+ const siblings = siblingPool.filter((entry) => entry.key !== section.key);
5305
+ const strongestSibling = siblings.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
5306
+ const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
5307
+ const scoreShare = section.totalScore / totalScore;
5308
+ const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
5309
+ const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
5310
+ count: entry.count,
5311
+ isActive: entry.key === section.key,
5312
+ key: entry.key,
5313
+ label: entry.label,
5314
+ parentShare: entry.totalScore / parentTotal,
5315
+ totalScore: entry.totalScore
5316
+ })).sort((left, right) => right.totalScore - left.totalScore) : [];
5317
+ const reasons = [];
5318
+ if (section.bestScore >= strongestBestHit) {
5319
+ reasons.push("best_hit");
5320
+ }
5321
+ if (section.count > 1) {
5322
+ reasons.push("multi_hit_section");
5323
+ }
5324
+ if (siblings.length === 0) {
5325
+ reasons.push("only_section_in_parent");
5326
+ } else if (!strongestSibling || section.totalScore >= strongestSibling.totalScore) {
5327
+ reasons.push("dominant_within_parent");
5328
+ }
5329
+ if (scoreShare >= 0.5 || (parentShare ?? 0) >= 0.6) {
5330
+ reasons.push("concentrated_evidence");
5331
+ }
5332
+ const summaryParts = [
5333
+ `${section.count} hit${section.count === 1 ? "" : "s"}`,
5334
+ `${(scoreShare * 100).toFixed(0)}% score share`,
5335
+ `vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
5336
+ typeof parentShare === "number" ? `${(parentShare * 100).toFixed(0)}% of parent section set` : "",
5337
+ strongestSibling ? `ahead of ${strongestSibling.label} by ${(section.totalScore - strongestSibling.totalScore).toFixed(2)}` : "no sibling competition"
5338
+ ].filter(Boolean);
5339
+ return {
5340
+ averageScore: section.totalScore / section.count,
5341
+ bestScore: section.bestScore,
5342
+ count: section.count,
5343
+ key: section.key,
5344
+ label: section.label,
5345
+ parentLabel: section.parentLabel,
5346
+ parentDistribution,
5347
+ parentShare,
5348
+ parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
5349
+ path: section.path,
5350
+ retrievalMode: trace?.mode,
5351
+ reasons,
5352
+ rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
5353
+ scoreShare,
5354
+ scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
5355
+ siblingCount: siblings.length,
5356
+ siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
5357
+ sourceCount: section.sourceSet.size,
5358
+ sourceBalanceApplied: trace?.steps.some((step) => step.stage === "source_balance"),
5359
+ strongestSiblingLabel: strongestSibling?.label,
5360
+ strongestSiblingScore: strongestSibling?.totalScore,
5361
+ summary: summaryParts.join(" \xB7 "),
5362
+ topChunkId: section.topChunkId,
5363
+ topSource: section.topSource,
5364
+ totalScore: section.totalScore,
5365
+ hybridHits: section.hybridHits,
5366
+ lexicalHits: section.lexicalHits,
5367
+ vectorHits: section.vectorHits
5368
+ };
5369
+ }).sort((left, right) => {
5370
+ if (right.totalScore !== left.totalScore) {
5371
+ return right.totalScore - left.totalScore;
5372
+ }
5373
+ if (right.bestScore !== left.bestScore) {
5374
+ return right.bestScore - left.bestScore;
5375
+ }
5376
+ return left.label.localeCompare(right.label);
5377
+ });
5378
+ };
5164
5379
  var buildStreamProgressState = (messages) => {
5165
5380
  const latestMessage = getLatestAssistantMessage(messages);
5166
5381
  const retrieved = latestMessage ? buildRAGRetrievedState(messages) : undefined;
@@ -5224,12 +5439,19 @@ var buildRAGAnswerWorkflowState = ({
5224
5439
  const groundingReferences = buildRAGGroundingReferences(sources);
5225
5440
  const groundedAnswer = buildRAGGroundedAnswer(latestAssistantMessage?.content ?? "", sources);
5226
5441
  const retrieval = buildRAGRetrievedState(messages);
5442
+ const sectionDiagnostics = buildRAGSectionRetrievalDiagnostics(sources, retrieval?.trace);
5227
5443
  const progress = buildRAGStreamProgress({
5228
5444
  error,
5229
5445
  isStreaming,
5230
5446
  messages
5231
5447
  });
5232
5448
  return {
5449
+ excerptModeCounts: buildRAGExcerptModeCounts([
5450
+ ...citations.map((citation) => citation.excerptSelection),
5451
+ ...sourceSummaries.map((summary) => summary.excerptSelection),
5452
+ ...groundingReferences.map((reference) => reference.excerptSelection),
5453
+ ...groundedAnswer.sectionSummaries.map((summary) => summary.excerptSelection)
5454
+ ]),
5233
5455
  citationReferenceMap,
5234
5456
  citations,
5235
5457
  coverage: groundedAnswer.coverage,
@@ -5254,6 +5476,7 @@ var buildRAGAnswerWorkflowState = ({
5254
5476
  retrievalDurationMs: retrieval?.retrievalDurationMs,
5255
5477
  retrievalStartedAt: retrieval?.retrievalStartedAt,
5256
5478
  retrievedAt: retrieval?.retrievedAt,
5479
+ sectionDiagnostics,
5257
5480
  sourceGroups,
5258
5481
  sourceSummaries,
5259
5482
  sources,
@@ -7083,5 +7306,5 @@ export {
7083
7306
  buildRAGEvaluationLeaderboard
7084
7307
  };
7085
7308
 
7086
- //# debugId=6D715A9108C4DFEA64756E2164756E21
7309
+ //# debugId=3709E5ECFB9CD0AA64756E2164756E21
7087
7310
  //# sourceMappingURL=index.js.map