@absolutejs/absolute 0.19.0-beta.605 → 0.19.0-beta.607

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 (37) hide show
  1. package/dist/ai/client/index.js +112 -1
  2. package/dist/ai/client/index.js.map +4 -4
  3. package/dist/ai/client/ui.js +113 -1
  4. package/dist/ai/client/ui.js.map +4 -4
  5. package/dist/ai/index.js +153 -4
  6. package/dist/ai/index.js.map +6 -6
  7. package/dist/ai/rag/quality.js +60 -1
  8. package/dist/ai/rag/quality.js.map +3 -3
  9. package/dist/ai/rag/ui.js +113 -1
  10. package/dist/ai/rag/ui.js.map +4 -4
  11. package/dist/ai-client/angular/ai/index.js +111 -0
  12. package/dist/ai-client/react/ai/index.js +141 -7
  13. package/dist/ai-client/vue/ai/index.js +135 -1
  14. package/dist/angular/ai/index.js +112 -1
  15. package/dist/angular/ai/index.js.map +4 -4
  16. package/dist/react/ai/index.js +142 -8
  17. package/dist/react/ai/index.js.map +6 -6
  18. package/dist/src/ai/client/ui.d.ts +1 -1
  19. package/dist/src/ai/rag/grounding.d.ts +2 -1
  20. package/dist/src/ai/rag/index.d.ts +1 -1
  21. package/dist/src/ai/rag/presentation.d.ts +2 -2
  22. package/dist/src/ai/rag/ui.d.ts +1 -1
  23. package/dist/src/react/ai/useRAG.d.ts +4 -0
  24. package/dist/src/react/ai/useRAGChunkPreview.d.ts +3 -0
  25. package/dist/src/react/ai/useRAGSources.d.ts +1 -0
  26. package/dist/src/svelte/ai/createRAG.d.ts +4 -0
  27. package/dist/src/svelte/ai/createRAGChunkPreview.d.ts +3 -0
  28. package/dist/src/svelte/ai/createRAGSources.d.ts +1 -0
  29. package/dist/src/vue/ai/useRAG.d.ts +4 -0
  30. package/dist/src/vue/ai/useRAGChunkPreview.d.ts +3 -0
  31. package/dist/src/vue/ai/useRAGSources.d.ts +1 -0
  32. package/dist/svelte/ai/index.js +149 -3
  33. package/dist/svelte/ai/index.js.map +6 -6
  34. package/dist/types/ai.d.ts +20 -1
  35. package/dist/vue/ai/index.js +136 -2
  36. package/dist/vue/ai/index.js.map +6 -6
  37. package/package.json +1 -1
@@ -354,6 +354,13 @@ var buildGroundingReferenceEvidenceSummary = (reference) => [
354
354
  reference.contextLabel,
355
355
  reference.provenanceLabel
356
356
  ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
357
+ var buildGroundingSectionKey = (reference) => reference.contextLabel ?? reference.locatorLabel ?? reference.label ?? reference.source ?? reference.chunkId;
358
+ var buildGroundingSectionSummaryLine = (reference) => [
359
+ reference.source ?? reference.title ?? reference.chunkId,
360
+ reference.locatorLabel,
361
+ reference.contextLabel,
362
+ reference.provenanceLabel
363
+ ].filter((value) => Boolean(value && value.length > 0)).filter((value, index, values) => values.findIndex((entry) => entry === value) === index).join(" \xB7 ");
357
364
  var buildGroundedAnswerCitationDetail = (reference) => ({
358
365
  contextLabel: reference.contextLabel,
359
366
  evidenceLabel: buildGroundingReferenceEvidenceLabel(reference),
@@ -444,9 +451,61 @@ var buildRAGGroundedAnswer = (content, sources) => {
444
451
  hasCitations,
445
452
  parts,
446
453
  references,
454
+ sectionSummaries: buildRAGGroundedAnswerSectionSummaries(references),
447
455
  ungroundedReferenceNumbers: [...ungroundedReferenceNumbers].sort((left, right) => left - right)
448
456
  };
449
457
  };
458
+ var buildRAGGroundedAnswerSectionSummaries = (references) => {
459
+ const groups = new Map;
460
+ for (const reference of references) {
461
+ const key = buildGroundingSectionKey(reference);
462
+ const existing = groups.get(key);
463
+ if (!existing) {
464
+ groups.set(key, {
465
+ chunkIds: [reference.chunkId],
466
+ contextLabel: reference.contextLabel,
467
+ count: 1,
468
+ key,
469
+ label: key,
470
+ locatorLabel: reference.locatorLabel,
471
+ provenanceLabel: reference.provenanceLabel,
472
+ referenceNumbers: [reference.number],
473
+ references: [reference],
474
+ summary: buildGroundingSectionSummaryLine(reference) || reference.label || reference.chunkId
475
+ });
476
+ continue;
477
+ }
478
+ existing.count += 1;
479
+ if (!existing.chunkIds.includes(reference.chunkId)) {
480
+ existing.chunkIds.push(reference.chunkId);
481
+ }
482
+ if (!existing.referenceNumbers.includes(reference.number)) {
483
+ existing.referenceNumbers.push(reference.number);
484
+ }
485
+ existing.references.push(reference);
486
+ if (!existing.contextLabel && reference.contextLabel) {
487
+ existing.contextLabel = reference.contextLabel;
488
+ }
489
+ if (!existing.locatorLabel && reference.locatorLabel) {
490
+ existing.locatorLabel = reference.locatorLabel;
491
+ }
492
+ if (!existing.provenanceLabel && reference.provenanceLabel) {
493
+ existing.provenanceLabel = reference.provenanceLabel;
494
+ }
495
+ }
496
+ return [...groups.values()].map((group) => ({
497
+ ...group,
498
+ referenceNumbers: [...group.referenceNumbers].sort((left, right) => left - right),
499
+ references: group.references.slice().sort((left, right) => left.number - right.number)
500
+ })).sort((left, right) => {
501
+ const leftFirst = left.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
502
+ const rightFirst = right.referenceNumbers[0] ?? Number.POSITIVE_INFINITY;
503
+ if (leftFirst !== rightFirst) {
504
+ return leftFirst - rightFirst;
505
+ }
506
+ return left.label.localeCompare(right.label);
507
+ });
508
+ };
450
509
  var buildRAGGroundingReferences = (sources) => {
451
510
  const citations = buildRAGCitations(sources);
452
511
  const citationReferenceMap = buildRAGCitationReferenceMap(citations);
@@ -4204,11 +4263,13 @@ var buildRAGChunkGraph = (chunks) => {
4204
4263
  const existing = sections.get(sectionId);
4205
4264
  if (!existing) {
4206
4265
  sections.set(sectionId, {
4266
+ childSectionIds: [],
4207
4267
  chunkCount: structure.sequence?.sectionChunkCount ?? 1,
4208
4268
  chunkIds: [chunk.chunkId],
4209
4269
  depth: structure.section?.depth,
4210
4270
  id: sectionId,
4211
4271
  kind: structure.section?.kind,
4272
+ leadChunkId: chunk.chunkId,
4212
4273
  path: structure.section?.path,
4213
4274
  title: structure.section?.title
4214
4275
  });
@@ -4231,6 +4292,48 @@ var buildRAGChunkGraph = (chunks) => {
4231
4292
  }
4232
4293
  return left.localeCompare(right);
4233
4294
  });
4295
+ section.leadChunkId = section.chunkIds[0];
4296
+ }
4297
+ const sectionPathIndex = new Map;
4298
+ for (const section of sections.values()) {
4299
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4300
+ if (path && path.length > 0) {
4301
+ sectionPathIndex.set(path.join("\x00"), section);
4302
+ }
4303
+ }
4304
+ for (const section of sections.values()) {
4305
+ const path = section.path && section.path.length > 0 ? section.path : section.title ? [section.title] : undefined;
4306
+ if (!path || path.length < 2) {
4307
+ continue;
4308
+ }
4309
+ const parent = sectionPathIndex.get(path.slice(0, -1).join("\x00"));
4310
+ if (!parent || parent.id === section.id) {
4311
+ continue;
4312
+ }
4313
+ section.parentSectionId = parent.id;
4314
+ if (!parent.childSectionIds.includes(section.id)) {
4315
+ parent.childSectionIds.push(section.id);
4316
+ }
4317
+ if (parent.leadChunkId && section.leadChunkId) {
4318
+ const parentKey = `section_parent:${section.leadChunkId}:${parent.leadChunkId}`;
4319
+ if (!edgeKeys.has(parentKey)) {
4320
+ edgeKeys.add(parentKey);
4321
+ edges.push({
4322
+ fromChunkId: section.leadChunkId,
4323
+ relation: "section_parent",
4324
+ toChunkId: parent.leadChunkId
4325
+ });
4326
+ }
4327
+ const childKey = `section_child:${parent.leadChunkId}:${section.leadChunkId}`;
4328
+ if (!edgeKeys.has(childKey)) {
4329
+ edgeKeys.add(childKey);
4330
+ edges.push({
4331
+ fromChunkId: parent.leadChunkId,
4332
+ relation: "section_child",
4333
+ toChunkId: section.leadChunkId
4334
+ });
4335
+ }
4336
+ }
4234
4337
  }
4235
4338
  nodes.sort((left, right) => {
4236
4339
  const leftSection = left.structure?.sequence?.sectionChunkIndex ?? Number.MAX_SAFE_INTEGER;
@@ -4264,6 +4367,8 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4264
4367
  if (graph.nodes.length === 0) {
4265
4368
  return {
4266
4369
  activeChunkId,
4370
+ childSections: [],
4371
+ siblingSections: [],
4267
4372
  sectionNodes: []
4268
4373
  };
4269
4374
  }
@@ -4272,13 +4377,19 @@ var buildRAGChunkGraphNavigation = (graph, activeChunkId) => {
4272
4377
  const previousNode = activeNode?.structure?.sequence?.previousChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.previousChunkId) : undefined;
4273
4378
  const nextNode = activeNode?.structure?.sequence?.nextChunkId ? graph.nodes.find((node) => node.chunkId === activeNode.structure?.sequence?.nextChunkId) : undefined;
4274
4379
  const section = activeNode?.structure?.sequence?.sectionChunkId ? graph.sections.find((entry) => entry.id === activeNode.structure?.sequence?.sectionChunkId) : undefined;
4380
+ const parentSection = section?.parentSectionId ? graph.sections.find((entry) => entry.id === section.parentSectionId) : undefined;
4381
+ const childSections = section ? section.childSectionIds.map((sectionId) => graph.sections.find((entry) => entry.id === sectionId)).filter((entry) => Boolean(entry)) : [];
4382
+ const siblingSections = section?.parentSectionId ? graph.sections.filter((entry) => entry.parentSectionId === section.parentSectionId && entry.id !== section.id) : [];
4275
4383
  const sectionNodes = section ? section.chunkIds.map((chunkId) => graph.nodes.find((node) => node.chunkId === chunkId)).filter((node) => Boolean(node)) : activeNode ? [activeNode] : [];
4276
4384
  return {
4277
4385
  activeChunkId: resolvedActiveChunkId,
4278
4386
  activeNode,
4387
+ childSections,
4279
4388
  nextNode,
4389
+ parentSection,
4280
4390
  previousNode,
4281
4391
  section,
4392
+ siblingSections,
4282
4393
  sectionNodes
4283
4394
  };
4284
4395
  };
@@ -6995,6 +7106,24 @@ var useRAGChunkPreview = (path) => {
6995
7106
  const selectChunk = useCallback2((id) => {
6996
7107
  setActiveChunkId(id);
6997
7108
  }, []);
7109
+ const selectParentSection = useCallback2(() => {
7110
+ const leadChunkId = navigation?.parentSection?.leadChunkId;
7111
+ if (leadChunkId) {
7112
+ setActiveChunkId(leadChunkId);
7113
+ }
7114
+ }, [navigation]);
7115
+ const selectChildSection = useCallback2((sectionId) => {
7116
+ const leadChunkId = navigation?.childSections.find((section) => section.id === sectionId)?.leadChunkId;
7117
+ if (leadChunkId) {
7118
+ setActiveChunkId(leadChunkId);
7119
+ }
7120
+ }, [navigation]);
7121
+ const selectSiblingSection = useCallback2((sectionId) => {
7122
+ const leadChunkId = navigation?.siblingSections.find((section) => section.id === sectionId)?.leadChunkId;
7123
+ if (leadChunkId) {
7124
+ setActiveChunkId(leadChunkId);
7125
+ }
7126
+ }, [navigation]);
6998
7127
  return {
6999
7128
  activeChunkId,
7000
7129
  chunkGraph,
@@ -7004,7 +7133,10 @@ var useRAGChunkPreview = (path) => {
7004
7133
  isLoading,
7005
7134
  navigation,
7006
7135
  preview,
7007
- selectChunk
7136
+ selectChildSection,
7137
+ selectChunk,
7138
+ selectParentSection,
7139
+ selectSiblingSection
7008
7140
  };
7009
7141
  };
7010
7142
  // src/react/ai/useRAG.ts
@@ -7579,7 +7711,7 @@ var useRAGSearch = (path) => {
7579
7711
  };
7580
7712
 
7581
7713
  // src/react/ai/useRAGSources.ts
7582
- import { useMemo as useMemo10 } from "react";
7714
+ import { useCallback as useCallback9, useMemo as useMemo10 } from "react";
7583
7715
  var useRAGSources = (messages) => {
7584
7716
  const latestAssistantMessage = useMemo10(() => getLatestAssistantMessage(messages), [messages]);
7585
7717
  const sources = useMemo10(() => getLatestRAGSources(messages), [messages]);
@@ -7587,11 +7719,13 @@ var useRAGSources = (messages) => {
7587
7719
  const sourceSummaries = useMemo10(() => buildRAGSourceSummaries(sources), [sources]);
7588
7720
  const chunkGraph = useMemo10(() => buildRAGChunkGraph(sources), [sources]);
7589
7721
  const citationReferenceMap = useMemo10(() => buildRAGCitationReferenceMap(sourceSummaries.flatMap((summary) => summary.citations)), [sourceSummaries]);
7722
+ const navigationForChunk = useCallback9((chunkId) => buildRAGChunkGraphNavigation(chunkGraph, chunkId ?? undefined), [chunkGraph]);
7590
7723
  return {
7591
7724
  citationReferenceMap,
7592
7725
  chunkGraph,
7593
7726
  hasSources: sources.length > 0,
7594
7727
  latestAssistantMessage,
7728
+ navigationForChunk,
7595
7729
  sourceGroups,
7596
7730
  sources,
7597
7731
  sourceSummaries
@@ -7599,14 +7733,14 @@ var useRAGSources = (messages) => {
7599
7733
  };
7600
7734
 
7601
7735
  // src/react/ai/useRAGStatus.ts
7602
- import { useCallback as useCallback9, useEffect as useEffect4, useMemo as useMemo11, useState as useState8 } from "react";
7736
+ import { useCallback as useCallback10, useEffect as useEffect4, useMemo as useMemo11, useState as useState8 } from "react";
7603
7737
  var useRAGStatus = (path, autoLoad = true) => {
7604
7738
  const client = useMemo11(() => createRAGClient({ path }), [path]);
7605
7739
  const [status, setStatus] = useState8();
7606
7740
  const [capabilities, setCapabilities] = useState8();
7607
7741
  const [error, setError] = useState8(null);
7608
7742
  const [isLoading, setIsLoading] = useState8(autoLoad);
7609
- const refresh = useCallback9(async () => {
7743
+ const refresh = useCallback10(async () => {
7610
7744
  setIsLoading(true);
7611
7745
  setError(null);
7612
7746
  try {
@@ -7622,7 +7756,7 @@ var useRAGStatus = (path, autoLoad = true) => {
7622
7756
  setIsLoading(false);
7623
7757
  }
7624
7758
  }, [client]);
7625
- const reset = useCallback9(() => {
7759
+ const reset = useCallback10(() => {
7626
7760
  setCapabilities(undefined);
7627
7761
  setError(null);
7628
7762
  setIsLoading(false);
@@ -7649,7 +7783,7 @@ var useRAGStatus = (path, autoLoad = true) => {
7649
7783
  import { useMemo as useMemo13 } from "react";
7650
7784
 
7651
7785
  // src/react/ai/useRAGStream.ts
7652
- import { useCallback as useCallback10, useMemo as useMemo12 } from "react";
7786
+ import { useCallback as useCallback11, useMemo as useMemo12 } from "react";
7653
7787
  var useRAGStream = (path, conversationId) => {
7654
7788
  const stream = useAIStream(path, conversationId);
7655
7789
  const workflow = useMemo12(() => buildRAGAnswerWorkflowState({
@@ -7679,7 +7813,7 @@ var useRAGStream = (path, conversationId) => {
7679
7813
  sourceCount: workflow.sources.length,
7680
7814
  stage: workflow.stage
7681
7815
  }), [workflow]);
7682
- const query = useCallback10((content, attachments) => {
7816
+ const query = useCallback11((content, attachments) => {
7683
7817
  stream.send(content, attachments);
7684
7818
  }, [stream]);
7685
7819
  return {
@@ -7791,5 +7925,5 @@ export {
7791
7925
  AIStreamProvider
7792
7926
  };
7793
7927
 
7794
- //# debugId=AB794411AE9A001D64756E2164756E21
7928
+ //# debugId=D69799996BCD92A364756E2164756E21
7795
7929
  //# sourceMappingURL=index.js.map