@resolveio/server-lib 22.1.10 → 22.1.11

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.
@@ -12837,8 +12837,27 @@ function isAssistantCollectionRefinementOf(currentCollection, genericCollection)
12837
12837
  || current.endsWith("_".concat(generic))
12838
12838
  || current.includes("_".concat(generic, "_"));
12839
12839
  }
12840
+ function resolveAssistantCollectionScore(collectionRanking, collectionName) {
12841
+ var _a;
12842
+ var ranked = Array.isArray(collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked) ? collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked : [];
12843
+ var rankedScore = (_a = ranked.find(function (entry) { return (entry === null || entry === void 0 ? void 0 : entry.name) === collectionName; })) === null || _a === void 0 ? void 0 : _a.score;
12844
+ if (typeof rankedScore === 'number') {
12845
+ return rankedScore;
12846
+ }
12847
+ var tokens = Array.isArray(collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.tokens)
12848
+ ? collectionRanking.tokens.filter(function (token) { return typeof token === 'string' && !!token; })
12849
+ : [];
12850
+ if (!tokens.length) {
12851
+ return 0;
12852
+ }
12853
+ var rankingWeights = collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.tokenWeights;
12854
+ var hasRankingWeights = rankingWeights && typeof rankingWeights === 'object';
12855
+ var weights = hasRankingWeights
12856
+ ? rankingWeights
12857
+ : computeCollectionTokenWeights(tokens).weights;
12858
+ return scoreCollectionMatch(tokens, collectionName, weights);
12859
+ }
12840
12860
  function resolveAssistantCollectionOverride(collectionRanking, currentCollection) {
12841
- var _a, _b;
12842
12861
  var ranked = Array.isArray(collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked) ? collectionRanking === null || collectionRanking === void 0 ? void 0 : collectionRanking.ranked : [];
12843
12862
  if (!ranked.length) {
12844
12863
  return null;
@@ -12860,7 +12879,7 @@ function resolveAssistantCollectionOverride(collectionRanking, currentCollection
12860
12879
  if (current === top.name) {
12861
12880
  return null;
12862
12881
  }
12863
- var currentScore = (_b = (_a = ranked.find(function (entry) { return entry.name === current; })) === null || _a === void 0 ? void 0 : _a.score) !== null && _b !== void 0 ? _b : 0;
12882
+ var currentScore = resolveAssistantCollectionScore(collectionRanking, current);
12864
12883
  if (currentScore >= AI_ASSISTANT_COLLECTION_OVERRIDE_MIN_SCORE
12865
12884
  && isAssistantGenericCollectionName(top.name)
12866
12885
  && isAssistantCollectionRefinementOf(current, top.name)) {
@@ -12869,7 +12888,7 @@ function resolveAssistantCollectionOverride(collectionRanking, currentCollection
12869
12888
  var scoreGap = top.score - currentScore;
12870
12889
  var currentIsVersion = isVersionCollectionName(current);
12871
12890
  var topIsVersion = isVersionCollectionName(top.name);
12872
- if (scoreGap < AI_ASSISTANT_COLLECTION_OVERRIDE_SCORE_GAP && !(currentIsVersion && !topIsVersion)) {
12891
+ if (scoreGap <= AI_ASSISTANT_COLLECTION_OVERRIDE_SCORE_GAP && !(currentIsVersion && !topIsVersion)) {
12873
12892
  return null;
12874
12893
  }
12875
12894
  var reason = currentIsVersion && !topIsVersion