@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
package/dist/ai/rag/ui.js CHANGED
@@ -238,21 +238,48 @@ var buildExcerpt = (text, maxLength = 160) => {
238
238
  };
239
239
  var selectPreferredExcerpt = (excerpts, sectionChunkCount) => {
240
240
  if (!excerpts) {
241
- return "";
241
+ return {
242
+ excerpt: "",
243
+ mode: "chunk",
244
+ reason: "single_chunk"
245
+ };
242
246
  }
243
247
  const chunkExcerpt = excerpts.chunkExcerpt?.trim() ?? "";
244
248
  const windowExcerpt = excerpts.windowExcerpt?.trim() ?? "";
245
249
  const sectionExcerpt = excerpts.sectionExcerpt?.trim() ?? "";
246
250
  if (sectionChunkCount && sectionChunkCount > 1 && chunkExcerpt.length > 0 && chunkExcerpt.length < 72) {
247
251
  if (sectionChunkCount <= 3 && sectionExcerpt) {
248
- return sectionExcerpt;
252
+ return {
253
+ excerpt: sectionExcerpt,
254
+ mode: "section",
255
+ reason: "section_small_enough"
256
+ };
249
257
  }
250
258
  if (windowExcerpt) {
251
- return windowExcerpt;
259
+ return {
260
+ excerpt: windowExcerpt,
261
+ mode: "window",
262
+ reason: "section_too_large_use_window"
263
+ };
252
264
  }
265
+ return {
266
+ excerpt: chunkExcerpt,
267
+ mode: "chunk",
268
+ reason: "chunk_too_narrow"
269
+ };
253
270
  }
254
- return chunkExcerpt || windowExcerpt || sectionExcerpt;
271
+ return {
272
+ excerpt: chunkExcerpt || windowExcerpt || sectionExcerpt,
273
+ mode: "chunk",
274
+ reason: (sectionChunkCount ?? 0) > 1 ? "chunk_too_narrow" : "single_chunk"
275
+ };
255
276
  };
277
+ var buildExcerptModeCounts = (references) => references.reduce((counts, reference) => {
278
+ if (reference?.excerptSelection) {
279
+ counts[reference.excerptSelection.mode] += 1;
280
+ }
281
+ return counts;
282
+ }, { chunk: 0, section: 0, window: 0 });
256
283
  var buildGroundingChunkExcerpts = (sources, activeChunkId) => {
257
284
  if (sources.length === 0) {
258
285
  return;
@@ -308,8 +335,9 @@ var buildGroundedAnswerCitationDetail = (reference) => ({
308
335
  contextLabel: reference.contextLabel,
309
336
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
310
337
  evidenceSummary: buildGroundingReferenceEvidenceSummary(reference),
311
- excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || reference.excerpt,
338
+ excerpt: selectPreferredExcerpt(reference.excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || reference.excerpt,
312
339
  excerpts: reference.excerpts,
340
+ excerptSelection: reference.excerptSelection,
313
341
  label: reference.label,
314
342
  locatorLabel: reference.locatorLabel,
315
343
  number: reference.number,
@@ -326,11 +354,14 @@ var buildRAGCitations = (sources) => {
326
354
  const hasBetterExisting = existing !== undefined && existing.score >= source.score;
327
355
  if (hasBetterExisting)
328
356
  continue;
357
+ const excerpts = buildGroundingChunkExcerpts(sources, source.chunkId);
358
+ const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(source.metadata?.sectionChunkCount));
329
359
  unique.set(key, {
330
360
  chunkId: source.chunkId,
331
361
  contextLabel: source.labels?.contextLabel ?? buildContextLabel(source.metadata),
332
- excerpt: selectPreferredExcerpt(buildGroundingChunkExcerpts(sources, source.chunkId), getContextNumber(source.metadata?.sectionChunkCount)) || buildExcerpt(source.text),
333
- excerpts: buildGroundingChunkExcerpts(sources, source.chunkId),
362
+ excerpt: excerptSelection.excerpt || buildExcerpt(source.text),
363
+ excerpts,
364
+ excerptSelection,
334
365
  key,
335
366
  label: buildSourceLabel(source),
336
367
  locatorLabel: source.labels?.locatorLabel ?? buildLocatorLabel(source.metadata, source.source, source.title),
@@ -351,6 +382,7 @@ var buildRAGCitations = (sources) => {
351
382
  };
352
383
  var buildRAGGroundedAnswer = (content, sources) => {
353
384
  const references = buildRAGGroundingReferences(sources);
385
+ const sectionSummaries = buildRAGGroundedAnswerSectionSummaries(references);
354
386
  const referenceMap = new Map(references.map((reference) => [reference.number, reference]));
355
387
  const parts = [];
356
388
  const ungroundedReferenceNumbers = new Set;
@@ -394,10 +426,14 @@ var buildRAGGroundedAnswer = (content, sources) => {
394
426
  return {
395
427
  content,
396
428
  coverage,
429
+ excerptModeCounts: buildExcerptModeCounts([
430
+ ...references,
431
+ ...sectionSummaries
432
+ ]),
397
433
  hasCitations,
398
434
  parts,
399
435
  references,
400
- sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
436
+ sectionSummaries,
401
437
  ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
402
438
  };
403
439
  };
@@ -416,8 +452,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
416
452
  chunkIds: [reference.chunkId],
417
453
  contextLabel: reference.contextLabel,
418
454
  count: 1,
419
- excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)) || excerpts?.sectionExcerpt || reference.excerpt,
455
+ excerpt: selectPreferredExcerpt(excerpts, getContextNumber(reference.metadata?.sectionChunkCount)).excerpt || excerpts?.sectionExcerpt || reference.excerpt,
420
456
  excerpts,
457
+ excerptSelection: reference.excerptSelection,
421
458
  key,
422
459
  label: key,
423
460
  locatorLabel: reference.locatorLabel,
@@ -453,6 +490,9 @@ var buildRAGGroundedAnswerSectionSummaries = (references) => {
453
490
  };
454
491
  existing.excerpt = reference.excerpts.sectionExcerpt;
455
492
  }
493
+ if (!existing.excerptSelection && reference.excerptSelection) {
494
+ existing.excerptSelection = reference.excerptSelection;
495
+ }
456
496
  }
457
497
  return [...groups.values()].map((group) => ({
458
498
  ...group,
@@ -472,11 +512,13 @@ var buildRAGGroundingReferences = (sources) => {
472
512
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
473
513
  return citations.map((citation) => {
474
514
  const excerpts = buildGroundingChunkExcerpts(sources, citation.chunkId);
515
+ const excerptSelection = selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount));
475
516
  return {
476
517
  chunkId: citation.chunkId,
477
518
  contextLabel: citation.contextLabel ?? buildContextLabel(citation.metadata),
478
- excerpt: selectPreferredExcerpt(excerpts, getContextNumber(citation.metadata?.sectionChunkCount)) || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
519
+ excerpt: excerptSelection.excerpt || excerpts?.chunkExcerpt || buildExcerpt(citation.text),
479
520
  excerpts,
521
+ excerptSelection,
480
522
  label: citation.label,
481
523
  locatorLabel: citation.locatorLabel ?? buildLocatorLabel(citation.metadata, citation.source, citation.title),
482
524
  metadata: citation.metadata,
@@ -1135,22 +1177,49 @@ var buildRAGChunkExcerpts = (chunks, activeChunkId) => {
1135
1177
  windowExcerpt: buildExcerpt2(collectText(orderedWindowIds), 240)
1136
1178
  };
1137
1179
  };
1138
- var buildRAGPreferredExcerpt = (excerpts, structure) => {
1180
+ var buildRAGExcerptSelection = (excerpts, structure) => {
1139
1181
  if (!excerpts) {
1140
- return "";
1182
+ return {
1183
+ excerpt: "",
1184
+ mode: "chunk",
1185
+ reason: "single_chunk"
1186
+ };
1141
1187
  }
1142
1188
  const chunkLength = excerpts.chunkExcerpt.trim().length;
1143
1189
  const sectionChunkCount = structure?.sequence?.sectionChunkCount ?? 1;
1144
1190
  if (sectionChunkCount > 1 && chunkLength > 0 && chunkLength < 72) {
1145
1191
  if (sectionChunkCount <= 3 && excerpts.sectionExcerpt.trim().length > 0) {
1146
- return excerpts.sectionExcerpt;
1192
+ return {
1193
+ excerpt: excerpts.sectionExcerpt,
1194
+ mode: "section",
1195
+ reason: "section_small_enough"
1196
+ };
1147
1197
  }
1148
1198
  if (excerpts.windowExcerpt.trim().length > 0) {
1149
- return excerpts.windowExcerpt;
1199
+ return {
1200
+ excerpt: excerpts.windowExcerpt,
1201
+ mode: "window",
1202
+ reason: "section_too_large_use_window"
1203
+ };
1150
1204
  }
1205
+ return {
1206
+ excerpt: excerpts.chunkExcerpt,
1207
+ mode: "chunk",
1208
+ reason: "chunk_too_narrow"
1209
+ };
1151
1210
  }
1152
- return excerpts.chunkExcerpt;
1211
+ return {
1212
+ excerpt: excerpts.chunkExcerpt,
1213
+ mode: "chunk",
1214
+ reason: sectionChunkCount > 1 ? "chunk_too_narrow" : "single_chunk"
1215
+ };
1153
1216
  };
1217
+ var buildRAGExcerptModeCounts = (selections) => selections.reduce((counts, selection) => {
1218
+ if (selection) {
1219
+ counts[selection.mode] += 1;
1220
+ }
1221
+ return counts;
1222
+ }, { chunk: 0, section: 0, window: 0 });
1154
1223
  var buildRAGChunkGraph = (chunks) => {
1155
1224
  const nodes = [];
1156
1225
  const edges = [];
@@ -1339,19 +1408,27 @@ var buildRAGRetrievedState = (messages) => {
1339
1408
  return null;
1340
1409
  }
1341
1410
  const sources = message.sources ?? [];
1411
+ const citations = buildRAGCitations(sources);
1412
+ const sectionDiagnostics = buildRAGSectionRetrievalDiagnostics(sources, isRAGRetrievalTrace(message.retrievalTrace) ? message.retrievalTrace : undefined);
1413
+ const sourceSummaries = buildRAGSourceSummaries(sources);
1342
1414
  const groundedAnswer = buildRAGGroundedAnswer(message.content, sources);
1343
1415
  return {
1344
- citationReferenceMap: buildRAGCitationReferenceMap(buildRAGCitations(sources)),
1345
- citations: buildRAGCitations(sources),
1416
+ citationReferenceMap: buildRAGCitationReferenceMap(citations),
1417
+ citations,
1346
1418
  conversationId: message.conversationId,
1419
+ excerptModeCounts: buildRAGExcerptModeCounts([
1420
+ ...citations.map((citation) => citation.excerptSelection),
1421
+ ...sourceSummaries.map((summary) => summary.excerptSelection)
1422
+ ]),
1347
1423
  groundedAnswer,
1348
1424
  messageId: message.id,
1349
1425
  retrievalDurationMs: message.retrievalDurationMs,
1350
1426
  retrievalStartedAt: message.retrievalStartedAt,
1351
1427
  retrievedAt: message.retrievedAt,
1352
1428
  trace: isRAGRetrievalTrace(message.retrievalTrace) ? message.retrievalTrace : undefined,
1429
+ sectionDiagnostics,
1353
1430
  sourceGroups: buildRAGSourceGroups(sources),
1354
- sourceSummaries: buildRAGSourceSummaries(sources),
1431
+ sourceSummaries,
1355
1432
  sources
1356
1433
  };
1357
1434
  };
@@ -1363,6 +1440,8 @@ var buildRAGSourceSummaries = (sources) => {
1363
1440
  const groupCitations = citations.filter((citation) => group.chunks.some((chunk) => chunk.chunkId === citation.chunkId));
1364
1441
  const leadChunk = group.chunks.slice().sort((left, right) => right.score - left.score)[0];
1365
1442
  const excerpts = leadChunk ? buildRAGChunkExcerpts(group.chunks, leadChunk.chunkId) : undefined;
1443
+ const structure = leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata);
1444
+ const excerptSelection = buildRAGExcerptSelection(excerpts, structure);
1366
1445
  return {
1367
1446
  bestScore: group.bestScore,
1368
1447
  citationNumbers: groupCitations.map((citation) => citationReferenceMap[citation.chunkId] ?? 0),
@@ -1370,18 +1449,154 @@ var buildRAGSourceSummaries = (sources) => {
1370
1449
  chunkIds: group.chunks.map((chunk) => chunk.chunkId),
1371
1450
  contextLabel: leadChunk?.labels?.contextLabel ?? buildContextLabel2(leadChunk?.metadata),
1372
1451
  count: group.count,
1373
- excerpt: buildRAGPreferredExcerpt(excerpts, leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata)) || buildExcerpt2(leadChunk?.text ?? ""),
1452
+ excerpt: excerptSelection.excerpt || buildExcerpt2(leadChunk?.text ?? ""),
1374
1453
  excerpts,
1454
+ excerptSelection,
1375
1455
  key: group.key,
1376
1456
  label: group.label,
1377
1457
  locatorLabel: leadChunk?.labels?.locatorLabel ?? buildLocatorLabel2(leadChunk?.metadata, leadChunk?.source, leadChunk?.title),
1378
1458
  provenanceLabel: leadChunk?.labels?.provenanceLabel ?? buildProvenanceLabel2(leadChunk?.metadata),
1379
- structure: leadChunk?.structure ?? buildRAGChunkStructure(leadChunk?.metadata),
1459
+ structure,
1380
1460
  source: group.source,
1381
1461
  title: group.title
1382
1462
  };
1383
1463
  });
1384
1464
  };
1465
+ var getSectionPathFromSource = (source) => {
1466
+ const path = source.structure?.section?.path ?? (Array.isArray(source.metadata?.sectionPath) ? source.metadata.sectionPath.map((value) => getContextString2(value)).filter((value) => typeof value === "string") : []);
1467
+ return path.length > 0 ? path : undefined;
1468
+ };
1469
+ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1470
+ const totalScore = sources.reduce((sum, source) => sum + source.score, 0);
1471
+ if (sources.length === 0 || totalScore <= 0) {
1472
+ return [];
1473
+ }
1474
+ const sections = new Map;
1475
+ for (const source of sources) {
1476
+ const path = getSectionPathFromSource(source);
1477
+ if (!path) {
1478
+ continue;
1479
+ }
1480
+ const key = path.join(" > ");
1481
+ const label = path.at(-1) ?? key;
1482
+ const parentLabel = path.length > 1 ? path.slice(0, -1).join(" > ") : undefined;
1483
+ const existing = sections.get(key);
1484
+ const channels = Array.isArray(source.metadata?.retrievalChannels) ? source.metadata.retrievalChannels.filter((value) => value === "vector" || value === "lexical") : [];
1485
+ const isHybrid = channels.includes("vector") && channels.includes("lexical");
1486
+ const vectorHits = channels.includes("vector") ? 1 : 0;
1487
+ const lexicalHits = channels.includes("lexical") ? 1 : 0;
1488
+ const hybridHits = isHybrid ? 1 : 0;
1489
+ if (!existing) {
1490
+ sections.set(key, {
1491
+ bestScore: source.score,
1492
+ count: 1,
1493
+ hybridHits,
1494
+ key,
1495
+ label,
1496
+ lexicalHits,
1497
+ parentLabel,
1498
+ path,
1499
+ sourceSet: new Set(source.source ? [source.source] : []),
1500
+ topChunkId: source.chunkId,
1501
+ topSource: source.source,
1502
+ totalScore: source.score,
1503
+ vectorHits
1504
+ });
1505
+ continue;
1506
+ }
1507
+ existing.count += 1;
1508
+ existing.totalScore += source.score;
1509
+ if (source.source) {
1510
+ existing.sourceSet.add(source.source);
1511
+ }
1512
+ existing.vectorHits += vectorHits;
1513
+ existing.lexicalHits += lexicalHits;
1514
+ existing.hybridHits += hybridHits;
1515
+ if (source.score > existing.bestScore) {
1516
+ existing.bestScore = source.score;
1517
+ existing.topChunkId = source.chunkId;
1518
+ existing.topSource = source.source;
1519
+ }
1520
+ }
1521
+ const diagnostics = [...sections.values()];
1522
+ const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
1523
+ return diagnostics.map((section) => {
1524
+ const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
1525
+ const siblings = siblingPool.filter((entry) => entry.key !== section.key);
1526
+ const strongestSibling = siblings.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
1527
+ const parentTotal = siblingPool.reduce((sum, entry) => sum + entry.totalScore, 0);
1528
+ const scoreShare = section.totalScore / totalScore;
1529
+ const parentShare = parentTotal > 0 ? section.totalScore / parentTotal : undefined;
1530
+ const parentDistribution = parentTotal > 0 ? siblingPool.map((entry) => ({
1531
+ count: entry.count,
1532
+ isActive: entry.key === section.key,
1533
+ key: entry.key,
1534
+ label: entry.label,
1535
+ parentShare: entry.totalScore / parentTotal,
1536
+ totalScore: entry.totalScore
1537
+ })).sort((left, right) => right.totalScore - left.totalScore) : [];
1538
+ const reasons = [];
1539
+ if (section.bestScore >= strongestBestHit) {
1540
+ reasons.push("best_hit");
1541
+ }
1542
+ if (section.count > 1) {
1543
+ reasons.push("multi_hit_section");
1544
+ }
1545
+ if (siblings.length === 0) {
1546
+ reasons.push("only_section_in_parent");
1547
+ } else if (!strongestSibling || section.totalScore >= strongestSibling.totalScore) {
1548
+ reasons.push("dominant_within_parent");
1549
+ }
1550
+ if (scoreShare >= 0.5 || (parentShare ?? 0) >= 0.6) {
1551
+ reasons.push("concentrated_evidence");
1552
+ }
1553
+ const summaryParts = [
1554
+ `${section.count} hit${section.count === 1 ? "" : "s"}`,
1555
+ `${(scoreShare * 100).toFixed(0)}% score share`,
1556
+ `vector ${section.vectorHits} \xB7 lexical ${section.lexicalHits} \xB7 hybrid ${section.hybridHits}`,
1557
+ typeof parentShare === "number" ? `${(parentShare * 100).toFixed(0)}% of parent section set` : "",
1558
+ strongestSibling ? `ahead of ${strongestSibling.label} by ${(section.totalScore - strongestSibling.totalScore).toFixed(2)}` : "no sibling competition"
1559
+ ].filter(Boolean);
1560
+ return {
1561
+ averageScore: section.totalScore / section.count,
1562
+ bestScore: section.bestScore,
1563
+ count: section.count,
1564
+ key: section.key,
1565
+ label: section.label,
1566
+ parentLabel: section.parentLabel,
1567
+ parentDistribution,
1568
+ parentShare,
1569
+ parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
1570
+ path: section.path,
1571
+ retrievalMode: trace?.mode,
1572
+ reasons,
1573
+ rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
1574
+ scoreShare,
1575
+ scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
1576
+ siblingCount: siblings.length,
1577
+ siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
1578
+ sourceCount: section.sourceSet.size,
1579
+ sourceBalanceApplied: trace?.steps.some((step) => step.stage === "source_balance"),
1580
+ strongestSiblingLabel: strongestSibling?.label,
1581
+ strongestSiblingScore: strongestSibling?.totalScore,
1582
+ summary: summaryParts.join(" \xB7 "),
1583
+ topChunkId: section.topChunkId,
1584
+ topSource: section.topSource,
1585
+ totalScore: section.totalScore,
1586
+ hybridHits: section.hybridHits,
1587
+ lexicalHits: section.lexicalHits,
1588
+ vectorHits: section.vectorHits
1589
+ };
1590
+ }).sort((left, right) => {
1591
+ if (right.totalScore !== left.totalScore) {
1592
+ return right.totalScore - left.totalScore;
1593
+ }
1594
+ if (right.bestScore !== left.bestScore) {
1595
+ return right.bestScore - left.bestScore;
1596
+ }
1597
+ return left.label.localeCompare(right.label);
1598
+ });
1599
+ };
1385
1600
  var buildStreamProgressState = (messages) => {
1386
1601
  const latestMessage = getLatestAssistantMessage(messages);
1387
1602
  const retrieved = latestMessage ? buildRAGRetrievedState(messages) : undefined;
@@ -1445,12 +1660,19 @@ var buildRAGAnswerWorkflowState = ({
1445
1660
  const groundingReferences = buildRAGGroundingReferences(sources);
1446
1661
  const groundedAnswer = buildRAGGroundedAnswer(latestAssistantMessage?.content ?? "", sources);
1447
1662
  const retrieval = buildRAGRetrievedState(messages);
1663
+ const sectionDiagnostics = buildRAGSectionRetrievalDiagnostics(sources, retrieval?.trace);
1448
1664
  const progress = buildRAGStreamProgress({
1449
1665
  error,
1450
1666
  isStreaming,
1451
1667
  messages
1452
1668
  });
1453
1669
  return {
1670
+ excerptModeCounts: buildRAGExcerptModeCounts([
1671
+ ...citations.map((citation) => citation.excerptSelection),
1672
+ ...sourceSummaries.map((summary) => summary.excerptSelection),
1673
+ ...groundingReferences.map((reference) => reference.excerptSelection),
1674
+ ...groundedAnswer.sectionSummaries.map((summary) => summary.excerptSelection)
1675
+ ]),
1454
1676
  citationReferenceMap,
1455
1677
  citations,
1456
1678
  coverage: groundedAnswer.coverage,
@@ -1475,6 +1697,7 @@ var buildRAGAnswerWorkflowState = ({
1475
1697
  retrievalDurationMs: retrieval?.retrievalDurationMs,
1476
1698
  retrievalStartedAt: retrieval?.retrievalStartedAt,
1477
1699
  retrievedAt: retrieval?.retrievedAt,
1700
+ sectionDiagnostics,
1478
1701
  sourceGroups,
1479
1702
  sourceSummaries,
1480
1703
  sources,
@@ -2160,6 +2383,7 @@ export {
2160
2383
  buildRAGStreamProgress,
2161
2384
  buildRAGSourceSummaries,
2162
2385
  buildRAGSourceGroups,
2386
+ buildRAGSectionRetrievalDiagnostics,
2163
2387
  buildRAGRetrievedState,
2164
2388
  buildRAGRetrievalTracePresentation,
2165
2389
  buildRAGRetrievalOverviewPresentation,
@@ -2200,5 +2424,5 @@ export {
2200
2424
  buildRAGAdminActionPresentation
2201
2425
  };
2202
2426
 
2203
- //# debugId=62489218E5536C5664756E2164756E21
2427
+ //# debugId=AFF4F013EF7B227064756E2164756E21
2204
2428
  //# sourceMappingURL=ui.js.map