@sentry/junior-memory 0.129.0 → 0.131.0

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.
package/dist/index.js CHANGED
@@ -204,16 +204,11 @@ function rankMemoryMatches(matches, options) {
204
204
  }
205
205
  byId.set(match.memory.id, {
206
206
  ...existing,
207
- exactIdentifier: existing.exactIdentifier || match.exactIdentifier,
208
207
  ...match.lexical ? { lexical: match.lexical } : {},
209
208
  ...match.vector ? { vector: match.vector } : {}
210
209
  });
211
210
  }
212
211
  return [...byId.values()].sort((left, right) => {
213
- const identifierDelta = Number(right.exactIdentifier) - Number(left.exactIdentifier);
214
- if (identifierDelta !== 0) {
215
- return identifierDelta;
216
- }
217
212
  const scoreDelta = matchScore(right) - matchScore(left);
218
213
  if (scoreDelta !== 0) {
219
214
  return scoreDelta;
@@ -649,14 +644,6 @@ async function archiveExpiredMemoryBatch(args) {
649
644
  });
650
645
  return { archivedCount: archivedIds.length };
651
646
  }
652
- function structuredQueryIdentifiers(query) {
653
- const matches = query.toLowerCase().match(
654
- /(?:[a-z0-9][a-z0-9._-]*\/)+[a-z0-9][a-z0-9._-]*|[a-z0-9]+(?:[._][a-z0-9]+)+|[a-z0-9]+(?:-[a-z0-9]+){2,}/g
655
- ) ?? [];
656
- return [
657
- ...new Set(matches.map((identifier) => identifier.replace(/\.+$/, "")))
658
- ];
659
- }
660
647
  function denseRanks(values, key) {
661
648
  let previous;
662
649
  let rank = 0;
@@ -908,37 +895,16 @@ async function searchVisibleLexicalMemories(args) {
908
895
  )`;
909
896
  const textsearch = sql2`to_tsvector('english', ${juniorMemoryMemories.content})`;
910
897
  const textRank = sql2`ts_rank_cd(${textsearch}, ${tsquery})`;
911
- const identifiers = structuredQueryIdentifiers(args.query);
912
- const contentTokens = sql2`regexp_split_to_array(lower(${juniorMemoryMemories.content}), '[^a-z0-9._/-]+')`;
913
- const identifierArray = identifiers.length > 0 ? sql2`ARRAY[${sql2.join(
914
- identifiers.map((identifier) => sql2`${identifier}`),
915
- sql2`, `
916
- )}]::text[]` : void 0;
917
- const exactIdentifierMatch = identifierArray !== void 0 ? sql2`EXISTS (
918
- SELECT 1
919
- FROM unnest(${contentTokens}) AS content_token(value)
920
- CROSS JOIN unnest(${identifierArray}) AS query_identifier(value)
921
- WHERE strpos(
922
- '/' || regexp_replace(content_token.value, '\\.+$', '') || '/',
923
- '/' || query_identifier.value || '/'
924
- ) > 0
925
- )` : sql2`false`;
926
898
  const rows = await args.db.select({
927
- exactIdentifierMatch,
928
899
  memory: juniorMemoryMemories,
929
900
  textRank
930
901
  }).from(juniorMemoryMemories).where(and(predicate, sql2`${textsearch} @@ ${tsquery}`)).orderBy(
931
- ...identifiers.length > 0 ? [desc(exactIdentifierMatch)] : [],
932
902
  desc(textRank),
933
903
  desc(juniorMemoryMemories.observedAtMs),
934
904
  asc(juniorMemoryMemories.id)
935
905
  ).limit(args.limit);
936
- const ranks = denseRanks(
937
- rows,
938
- (row) => `${row.exactIdentifierMatch}:${Number(row.textRank)}`
939
- );
906
+ const ranks = denseRanks(rows, (row) => Number(row.textRank));
940
907
  return rows.map((row, index2) => ({
941
- exactIdentifier: row.exactIdentifierMatch,
942
908
  lexical: { rank: ranks[index2] },
943
909
  memory: parseMemoryRow(row.memory),
944
910
  sourceKey: row.memory.sourceKey
@@ -993,7 +959,6 @@ async function searchVisibleVectorMemories(args) {
993
959
  }
994
960
  return [
995
961
  {
996
- exactIdentifier: false,
997
962
  memory: parseMemoryRow(row.memory),
998
963
  sourceKey: row.memory.sourceKey,
999
964
  vector: {