@absolutejs/absolute 0.19.0-beta.614 → 0.19.0-beta.615

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 (38) hide show
  1. package/dist/ai/client/index.js +33 -1
  2. package/dist/ai/client/index.js.map +3 -3
  3. package/dist/ai/client/ui.js +33 -1
  4. package/dist/ai/client/ui.js.map +3 -3
  5. package/dist/ai/index.js +171 -42
  6. package/dist/ai/index.js.map +7 -6
  7. package/dist/ai/rag/ui.js +33 -1
  8. package/dist/ai/rag/ui.js.map +3 -3
  9. package/dist/ai-client/angular/ai/index.js +7 -0
  10. package/dist/ai-client/react/ai/index.js +7 -0
  11. package/dist/ai-client/vue/ai/index.js +7 -0
  12. package/dist/angular/ai/index.js +33 -1
  13. package/dist/angular/ai/index.js.map +3 -3
  14. package/dist/angular/index.js +2 -2
  15. package/dist/angular/index.js.map +1 -1
  16. package/dist/angular/server.js +2 -2
  17. package/dist/angular/server.js.map +1 -1
  18. package/dist/build.js +2 -2
  19. package/dist/build.js.map +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/react/ai/index.js +33 -1
  23. package/dist/react/ai/index.js.map +3 -3
  24. package/dist/src/ai/index.d.ts +1 -1
  25. package/dist/src/ai/rag/collection.d.ts +2 -1
  26. package/dist/src/ai/rag/index.d.ts +1 -0
  27. package/dist/src/ai/rag/retrievalStrategies.d.ts +6 -0
  28. package/dist/src/react/ai/useRAG.d.ts +2 -0
  29. package/dist/src/svelte/ai/createRAG.d.ts +2 -0
  30. package/dist/src/vue/ai/useRAG.d.ts +18 -0
  31. package/dist/src/vue/ai/useRAGEvaluate.d.ts +6 -0
  32. package/dist/src/vue/ai/useRAGSearch.d.ts +10 -0
  33. package/dist/svelte/ai/index.js +33 -1
  34. package/dist/svelte/ai/index.js.map +3 -3
  35. package/dist/types/ai.d.ts +52 -1
  36. package/dist/vue/ai/index.js +33 -1
  37. package/dist/vue/ai/index.js.map +3 -3
  38. package/package.json +7 -7
package/dist/ai/index.js CHANGED
@@ -3772,10 +3772,35 @@ var buildRAGRetrievalTracePresentation = (trace) => {
3772
3772
  ];
3773
3773
  const details = [
3774
3774
  { label: "Transformed query", value: trace.transformedQuery },
3775
+ ...trace.queryTransformLabel || trace.queryTransformProvider ? [
3776
+ {
3777
+ label: "Query transform",
3778
+ value: trace.queryTransformLabel ?? trace.queryTransformProvider ?? "configured"
3779
+ },
3780
+ ...trace.queryTransformReason ? [
3781
+ {
3782
+ label: "Query transform reason",
3783
+ value: trace.queryTransformReason
3784
+ }
3785
+ ] : []
3786
+ ] : [],
3775
3787
  {
3776
3788
  label: "Variant queries",
3777
3789
  value: trace.variantQueries.length > 0 ? trace.variantQueries.join(" \xB7 ") : "none"
3778
3790
  },
3791
+ ...trace.requestedMode && trace.requestedMode !== trace.mode ? [{ label: "Requested mode", value: trace.requestedMode }] : [],
3792
+ ...trace.routingLabel || trace.routingProvider ? [
3793
+ {
3794
+ label: "Routing decision",
3795
+ value: trace.routingLabel ?? trace.routingProvider ?? "configured"
3796
+ },
3797
+ ...trace.routingReason ? [
3798
+ {
3799
+ label: "Routing reason",
3800
+ value: trace.routingReason
3801
+ }
3802
+ ] : []
3803
+ ] : [],
3779
3804
  { label: "Candidate topK", value: String(trace.candidateTopK) },
3780
3805
  { label: "Lexical topK", value: String(trace.lexicalTopK) }
3781
3806
  ];
@@ -4878,7 +4903,14 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4878
4903
  transformedHits: section.transformedHits,
4879
4904
  variantHits: section.variantHits
4880
4905
  },
4906
+ requestedMode: trace?.requestedMode,
4881
4907
  retrievalMode: trace?.mode,
4908
+ routingLabel: trace?.routingLabel,
4909
+ routingProvider: trace?.routingProvider,
4910
+ routingReason: trace?.routingReason,
4911
+ queryTransformLabel: trace?.queryTransformLabel,
4912
+ queryTransformProvider: trace?.queryTransformProvider,
4913
+ queryTransformReason: trace?.queryTransformReason,
4882
4914
  reasons,
4883
4915
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
4884
4916
  scoreShare,
@@ -8356,7 +8388,17 @@ var STOP_WORDS3 = new Set([
8356
8388
  "which",
8357
8389
  "why"
8358
8390
  ]);
8359
- var collectMetadataStrings2 = (value) => {
8391
+ var INTERNAL_RETRIEVAL_METADATA_KEYS = new Set([
8392
+ "retrievalChannels",
8393
+ "retrievalQuery",
8394
+ "retrievalQueryIndex",
8395
+ "retrievalQueryOrigin",
8396
+ "retrievalQueryOrigins"
8397
+ ]);
8398
+ var collectMetadataStrings2 = (value, key) => {
8399
+ if (typeof key === "string" && INTERNAL_RETRIEVAL_METADATA_KEYS.has(key)) {
8400
+ return [];
8401
+ }
8360
8402
  if (typeof value === "string" || typeof value === "number") {
8361
8403
  return [String(value)];
8362
8404
  }
@@ -8364,7 +8406,7 @@ var collectMetadataStrings2 = (value) => {
8364
8406
  return value.flatMap((entry) => collectMetadataStrings2(entry));
8365
8407
  }
8366
8408
  if (value && typeof value === "object") {
8367
- return Object.values(value).flatMap((entry) => collectMetadataStrings2(entry));
8409
+ return Object.entries(value).flatMap(([entryKey, entry]) => collectMetadataStrings2(entry, entryKey));
8368
8410
  }
8369
8411
  return [];
8370
8412
  };
@@ -10752,6 +10794,19 @@ var annotateRetrievalQueryOrigin = (input) => {
10752
10794
  };
10753
10795
  var shouldRunVectorRetrieval = (mode) => mode === "vector" || mode === "hybrid";
10754
10796
  var shouldRunLexicalRetrieval = (mode, store) => mode === "lexical" || mode === "hybrid" && Boolean(store.queryLexical);
10797
+ var resolveRAGRetrievalStrategy = (retrievalStrategy) => {
10798
+ if (!retrievalStrategy) {
10799
+ return null;
10800
+ }
10801
+ if (typeof retrievalStrategy === "function") {
10802
+ return {
10803
+ defaultLabel: undefined,
10804
+ providerName: undefined,
10805
+ select: retrievalStrategy
10806
+ };
10807
+ }
10808
+ return retrievalStrategy;
10809
+ };
10755
10810
  var createRAGCollection = (options) => {
10756
10811
  const defaultTopK = options.defaultTopK ?? DEFAULT_TOP_K2;
10757
10812
  const defaultCandidateMultiplier = Math.max(1, Math.floor(options.defaultCandidateMultiplier ?? 4));
@@ -10768,10 +10823,11 @@ var createRAGCollection = (options) => {
10768
10823
  const model = input.model ?? options.defaultModel;
10769
10824
  const topK = input.topK ?? defaultTopK;
10770
10825
  const hasReranker = Boolean(input.rerank ?? options.rerank);
10771
- const retrieval = resolveRAGHybridSearchOptions(input.retrieval);
10826
+ const requestedRetrieval = resolveRAGHybridSearchOptions(input.retrieval);
10772
10827
  const hasQueryTransform = Boolean(input.queryTransform ?? options.queryTransform);
10773
- const shouldExpandCandidates = hasReranker || hasQueryTransform || retrieval.mode !== "vector";
10828
+ const shouldExpandCandidates = hasReranker || hasQueryTransform || requestedRetrieval.mode !== "vector";
10774
10829
  const candidateTopK = Math.max(topK, Math.floor(input.candidateTopK ?? (shouldExpandCandidates ? topK * defaultCandidateMultiplier : topK)));
10830
+ const resolvedQueryTransform = resolveRAGQueryTransform(input.queryTransform ?? options.queryTransform);
10775
10831
  const transformed = await applyRAGQueryTransform({
10776
10832
  input: {
10777
10833
  candidateTopK,
@@ -10781,9 +10837,25 @@ var createRAGCollection = (options) => {
10781
10837
  scoreThreshold: input.scoreThreshold,
10782
10838
  topK
10783
10839
  },
10784
- queryTransform: input.queryTransform ?? options.queryTransform
10840
+ queryTransform: resolvedQueryTransform ?? undefined
10785
10841
  });
10786
10842
  const searchQueries = Array.from(new Set([transformed.query, ...transformed.variants ?? []])).filter(Boolean);
10843
+ const resolvedRetrievalStrategy = resolveRAGRetrievalStrategy(input.retrievalStrategy ?? options.retrievalStrategy);
10844
+ const retrievalDecision = resolvedRetrievalStrategy ? await Promise.resolve(resolvedRetrievalStrategy.select({
10845
+ candidateTopK,
10846
+ filter: input.filter,
10847
+ model,
10848
+ query: input.query,
10849
+ retrieval: requestedRetrieval,
10850
+ scoreThreshold: input.scoreThreshold,
10851
+ topK,
10852
+ transformedQuery: transformed.query,
10853
+ variantQueries: searchQueries.slice(1)
10854
+ })) : undefined;
10855
+ const retrieval = retrievalDecision ? {
10856
+ ...requestedRetrieval,
10857
+ ...retrievalDecision
10858
+ } : requestedRetrieval;
10787
10859
  const runVector = shouldRunVectorRetrieval(retrieval.mode);
10788
10860
  const runLexical = shouldRunLexicalRetrieval(retrieval.mode, options.store);
10789
10861
  const lexicalTopK = Math.max(topK, Math.floor(retrieval.lexicalTopK ?? candidateTopK));
@@ -10826,12 +10898,31 @@ var createRAGCollection = (options) => {
10826
10898
  steps.push({
10827
10899
  label: "Expanded query variants",
10828
10900
  metadata: {
10901
+ label: transformed.label ?? resolvedQueryTransform?.providerName ?? null,
10902
+ providerName: resolvedQueryTransform?.providerName ?? null,
10903
+ reason: transformed.reason ?? null,
10829
10904
  transformedQuery: transformed.query,
10830
- variantCount: Math.max(0, searchQueries.length - 1)
10905
+ variantCount: Math.max(0, searchQueries.length - 1),
10906
+ ...transformed.metadata ?? {}
10831
10907
  },
10832
10908
  stage: "query_transform"
10833
10909
  });
10834
10910
  }
10911
+ if (retrievalDecision || requestedRetrieval.mode !== retrieval.mode || requestedRetrieval.lexicalTopK !== retrieval.lexicalTopK) {
10912
+ steps.push({
10913
+ label: retrievalDecision?.label ?? "Selected retrieval strategy",
10914
+ metadata: {
10915
+ applied: Boolean(retrievalDecision),
10916
+ label: retrievalDecision?.label ?? resolvedRetrievalStrategy?.defaultLabel ?? null,
10917
+ providerName: resolvedRetrievalStrategy?.providerName ?? null,
10918
+ reason: retrievalDecision?.reason ?? null,
10919
+ requestedMode: requestedRetrieval.mode,
10920
+ selectedMode: retrieval.mode,
10921
+ ...retrievalDecision?.metadata ?? {}
10922
+ },
10923
+ stage: "routing"
10924
+ });
10925
+ }
10835
10926
  const resultGroups = await Promise.all(searchQueries.map(async (query, queryIndex) => {
10836
10927
  const [vectorResults2, lexicalResults2] = await Promise.all([
10837
10928
  runVector ? embed({
@@ -10990,6 +11081,9 @@ var createRAGCollection = (options) => {
10990
11081
  mode: retrieval.mode,
10991
11082
  diversityStrategy: retrieval.diversityStrategy,
10992
11083
  query: input.query,
11084
+ queryTransformLabel: transformed.label,
11085
+ queryTransformProvider: resolvedQueryTransform?.providerName,
11086
+ queryTransformReason: transformed.reason,
10993
11087
  resultCounts: {
10994
11088
  final: limited.length,
10995
11089
  fused: results.length,
@@ -10997,8 +11091,12 @@ var createRAGCollection = (options) => {
10997
11091
  reranked: diversified.length,
10998
11092
  vector: vectorResults.length
10999
11093
  },
11094
+ requestedMode: requestedRetrieval.mode,
11000
11095
  runLexical,
11001
11096
  runVector,
11097
+ routingLabel: retrievalDecision?.label ?? resolvedRetrievalStrategy?.defaultLabel,
11098
+ routingProvider: resolvedRetrievalStrategy?.providerName,
11099
+ routingReason: retrievalDecision?.reason,
11002
11100
  sourceBalanceStrategy: retrieval.sourceBalanceStrategy,
11003
11101
  steps,
11004
11102
  topK,
@@ -11039,6 +11137,9 @@ var createRAGCollection = (options) => {
11039
11137
  mode: retrieval.mode,
11040
11138
  diversityStrategy: retrieval.diversityStrategy,
11041
11139
  query: input.query,
11140
+ queryTransformLabel: transformed.label,
11141
+ queryTransformProvider: resolvedQueryTransform?.providerName,
11142
+ queryTransformReason: transformed.reason,
11042
11143
  resultCounts: {
11043
11144
  final: filtered.length,
11044
11145
  fused: results.length,
@@ -11046,8 +11147,12 @@ var createRAGCollection = (options) => {
11046
11147
  reranked: diversified.length,
11047
11148
  vector: vectorResults.length
11048
11149
  },
11150
+ requestedMode: requestedRetrieval.mode,
11049
11151
  runLexical,
11050
11152
  runVector,
11153
+ routingLabel: retrievalDecision?.label ?? resolvedRetrievalStrategy?.defaultLabel,
11154
+ routingProvider: resolvedRetrievalStrategy?.providerName,
11155
+ routingReason: retrievalDecision?.reason,
11051
11156
  scoreThreshold,
11052
11157
  sourceBalanceStrategy: retrieval.sourceBalanceStrategy,
11053
11158
  steps,
@@ -18108,6 +18213,64 @@ var ragChat = (config) => {
18108
18213
  // src/ai/rag/htmxConfig.ts
18109
18214
  var createRAGHTMXConfig = (config) => config;
18110
18215
  var createRAGHTMXWorkflowRenderConfig = (config) => config;
18216
+ // src/ai/rag/retrievalStrategies.ts
18217
+ var tokenize4 = (value) => value.toLowerCase().split(/[^a-z0-9]+/i).map((token) => token.trim()).filter((token) => token.length > 0);
18218
+ var hasAnyToken2 = (tokens, values) => values.some((value) => tokens.includes(value));
18219
+ var createHeuristicRAGRetrievalStrategy = (options = {}) => ({
18220
+ defaultLabel: options.defaultLabel ?? "Heuristic retrieval routing",
18221
+ providerName: options.providerName ?? "heuristic_retrieval_strategy",
18222
+ select: (input) => {
18223
+ const scopedSource = typeof input.filter?.source === "string" && input.filter.source.trim().length > 0;
18224
+ const scopedDocumentId = typeof input.filter?.documentId === "string" && input.filter.documentId.trim().length > 0;
18225
+ if ((scopedSource || scopedDocumentId) && input.retrieval.mode !== "vector") {
18226
+ return {
18227
+ label: "Scoped direct route",
18228
+ mode: "vector",
18229
+ reason: scopedDocumentId ? "documentId filter narrows retrieval to one target document" : "source filter narrows retrieval to one source family",
18230
+ metadata: {
18231
+ selector: "scoped_direct_route"
18232
+ }
18233
+ };
18234
+ }
18235
+ const tokens = tokenize4(input.query);
18236
+ const transformedTokens = tokenize4(input.transformedQuery);
18237
+ const combined = Array.from(new Set([...tokens, ...transformedTokens]));
18238
+ const hasVariants = input.variantQueries.length > 0;
18239
+ const supportLexical = hasAnyToken2(combined, ["faq", "policy", "password", "billing"]) && !hasVariants;
18240
+ if (supportLexical) {
18241
+ return {
18242
+ label: "Support lexical route",
18243
+ mode: "lexical",
18244
+ reason: "faq/support phrase matched",
18245
+ metadata: {
18246
+ selector: "support_lexical"
18247
+ }
18248
+ };
18249
+ }
18250
+ const sourceNativeHybrid = hasVariants || hasAnyToken2(combined, [
18251
+ "sheet",
18252
+ "worksheet",
18253
+ "workbook",
18254
+ "spreadsheet",
18255
+ "timestamp",
18256
+ "transcript",
18257
+ "attachment",
18258
+ "archive"
18259
+ ]);
18260
+ if (sourceNativeHybrid && input.retrieval.mode === "vector") {
18261
+ return {
18262
+ label: "Source-native hybrid route",
18263
+ mode: "hybrid",
18264
+ lexicalTopK: Math.max(input.topK, Math.floor(input.retrieval.lexicalTopK ?? input.candidateTopK)),
18265
+ reason: hasVariants ? "query expansion introduced source-native variants" : "source-native terminology benefits from hybrid retrieval",
18266
+ metadata: {
18267
+ selector: "source_native_hybrid"
18268
+ }
18269
+ };
18270
+ }
18271
+ return;
18272
+ }
18273
+ });
18111
18274
  // src/ai/rag/embeddingProviders.ts
18112
18275
  var DEFAULT_OPENAI_BASE_URL = "https://api.openai.com";
18113
18276
  var DEFAULT_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com";
@@ -22369,6 +22532,7 @@ export {
22369
22532
  createMemoryStore,
22370
22533
  createLegacyDocumentExtractor,
22371
22534
  createInMemoryRAGStore,
22535
+ createHeuristicRAGRetrievalStrategy,
22372
22536
  createHeuristicRAGReranker,
22373
22537
  createHeuristicRAGQueryTransform,
22374
22538
  createEmailExtractor,
@@ -22382,56 +22546,21 @@ export {
22382
22546
  buildRAGUpsertInputFromURLs,
22383
22547
  buildRAGUpsertInputFromDocuments,
22384
22548
  buildRAGUpsertInputFromDirectory,
22385
- buildRAGSyncSourcePresentations,
22386
- buildRAGSyncSourcePresentation,
22387
- buildRAGSyncOverviewPresentation,
22388
- buildRAGSourceSummaries,
22389
- buildRAGSourceGroups,
22390
22549
  buildRAGSearchTraceRecord,
22391
22550
  buildRAGSearchTraceDiff,
22392
- buildRAGRetrievalTracePresentation,
22393
22551
  buildRAGRetrievalTraceHistoryTrend,
22394
22552
  buildRAGRetrievalReleaseVerdict,
22395
- buildRAGRetrievalOverviewPresentation,
22396
- buildRAGRetrievalComparisonPresentations,
22397
- buildRAGRetrievalComparisonOverviewPresentation,
22398
22553
  buildRAGRetrievalComparisonDecisionSummary,
22399
- buildRAGRerankerOverviewPresentation,
22400
- buildRAGRerankerComparisonPresentations,
22401
- buildRAGRerankerComparisonOverviewPresentation,
22402
- buildRAGReadinessPresentation,
22403
- buildRAGQualityOverviewPresentation,
22404
22554
  buildRAGLexicalHaystack,
22405
- buildRAGGroundingReferences,
22406
- buildRAGGroundingProviderPresentations,
22407
- buildRAGGroundingProviderOverviewPresentation,
22408
- buildRAGGroundingProviderCaseComparisonPresentations,
22409
- buildRAGGroundingOverviewPresentation,
22410
- buildRAGGroundedAnswer,
22411
22555
  buildRAGEvaluationRunDiff,
22412
22556
  buildRAGEvaluationResponse,
22413
22557
  buildRAGEvaluationLeaderboard,
22414
- buildRAGEvaluationHistoryRows,
22415
- buildRAGEvaluationHistoryPresentation,
22416
- buildRAGEvaluationCaseTracePresentations,
22417
- buildRAGCorpusHealthPresentation,
22418
22558
  buildRAGContext,
22419
- buildRAGComparisonTraceSummaryRows,
22420
- buildRAGComparisonTraceDiffRows,
22421
- buildRAGCitations,
22422
- buildRAGCitationReferenceMap,
22423
- buildRAGAnswerGroundingHistoryRows,
22424
- buildRAGAnswerGroundingHistoryPresentation,
22425
22559
  buildRAGAnswerGroundingEvaluationRunDiff,
22426
22560
  buildRAGAnswerGroundingEvaluationResponse,
22427
22561
  buildRAGAnswerGroundingEvaluationLeaderboard,
22428
- buildRAGAnswerGroundingCaseSnapshotPresentations,
22429
22562
  buildRAGAnswerGroundingCaseDifficultyRunDiff,
22430
22563
  buildRAGAnswerGroundingCaseDifficultyLeaderboard,
22431
- buildRAGAdminJobPresentations,
22432
- buildRAGAdminJobPresentation,
22433
- buildRAGAdminActionPresentations,
22434
- buildRAGAdminActionPresentation,
22435
22564
  applyRAGReranking,
22436
22565
  applyRAGQueryTransform,
22437
22566
  anthropicOCR,
@@ -22440,5 +22569,5 @@ export {
22440
22569
  aiChat
22441
22570
  };
22442
22571
 
22443
- //# debugId=593D26DEF70C96A364756E2164756E21
22572
+ //# debugId=2EBD38302AA26EE564756E2164756E21
22444
22573
  //# sourceMappingURL=index.js.map