@anuma/sdk 3.9.3 → 3.9.4
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/expo/{chunk-UQQCL7KP.mjs → chunk-4VXLX7SL.mjs} +32 -2
- package/dist/expo/index.cjs +32 -2
- package/dist/expo/index.mjs +1 -1
- package/dist/expo/{recall-RSLYPJ5L.mjs → recall-XGRLGIEH.mjs} +1 -1
- package/dist/react/{chunk-HLBQICNL.mjs → chunk-P5ED24DP.mjs} +32 -2
- package/dist/react/index.cjs +32 -2
- package/dist/react/index.mjs +1 -1
- package/dist/react/{recall-UCCIEG37.mjs → recall-F33QYRYU.mjs} +1 -1
- package/dist/server/{chunk-ICGTS7X6.mjs → chunk-FJFPCJRI.mjs} +32 -2
- package/dist/server/index.cjs +32 -2
- package/dist/server/index.mjs +1 -1
- package/dist/server/{recall-5OW4RJVC.mjs → recall-23VTTAEG.mjs} +1 -1
- package/package.json +1 -1
|
@@ -5624,7 +5624,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
5624
5624
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
5625
5625
|
);
|
|
5626
5626
|
}
|
|
5627
|
-
const { recall: recall2 } = await import("./recall-
|
|
5627
|
+
const { recall: recall2 } = await import("./recall-XGRLGIEH.mjs");
|
|
5628
5628
|
const result = await recall2(
|
|
5629
5629
|
query,
|
|
5630
5630
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -5717,6 +5717,18 @@ var STOPWORDS2 = new Set(
|
|
|
5717
5717
|
].map((w) => w.toLowerCase())
|
|
5718
5718
|
);
|
|
5719
5719
|
var ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
5720
|
+
var FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
5721
|
+
var FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
5722
|
+
var MAX_FALLBACK_CANDIDATES = 12;
|
|
5723
|
+
var MAX_FALLBACK_TOKENS = 3;
|
|
5724
|
+
function hasMeaningfulCandidate(candidates) {
|
|
5725
|
+
for (const candidate of candidates) {
|
|
5726
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
5727
|
+
return true;
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
return false;
|
|
5731
|
+
}
|
|
5720
5732
|
function extractQueryEntities(query) {
|
|
5721
5733
|
if (!query) return [];
|
|
5722
5734
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -5732,7 +5744,25 @@ function extractQueryEntities(query) {
|
|
|
5732
5744
|
seen.add(candidate);
|
|
5733
5745
|
}
|
|
5734
5746
|
}
|
|
5735
|
-
return [...seen];
|
|
5747
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
5748
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
5749
|
+
}
|
|
5750
|
+
function extractFallbackCandidates(query) {
|
|
5751
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
5752
|
+
const out = [];
|
|
5753
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5754
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
5755
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
5756
|
+
const gram = tokens.slice(start, start + n);
|
|
5757
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
5758
|
+
const candidate = gram.join(" ");
|
|
5759
|
+
if (seen.has(candidate)) continue;
|
|
5760
|
+
seen.add(candidate);
|
|
5761
|
+
out.push(candidate);
|
|
5762
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5765
|
+
return out;
|
|
5736
5766
|
}
|
|
5737
5767
|
|
|
5738
5768
|
// src/lib/memory/graphTraversal.ts
|
package/dist/expo/index.cjs
CHANGED
|
@@ -5880,6 +5880,14 @@ var init_lruCache = __esm({
|
|
|
5880
5880
|
});
|
|
5881
5881
|
|
|
5882
5882
|
// src/lib/memory/queryEntities.ts
|
|
5883
|
+
function hasMeaningfulCandidate(candidates) {
|
|
5884
|
+
for (const candidate of candidates) {
|
|
5885
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
5886
|
+
return true;
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
return false;
|
|
5890
|
+
}
|
|
5883
5891
|
function extractQueryEntities(query) {
|
|
5884
5892
|
if (!query) return [];
|
|
5885
5893
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -5895,9 +5903,27 @@ function extractQueryEntities(query) {
|
|
|
5895
5903
|
seen.add(candidate);
|
|
5896
5904
|
}
|
|
5897
5905
|
}
|
|
5898
|
-
return [...seen];
|
|
5906
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
5907
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
5908
|
+
}
|
|
5909
|
+
function extractFallbackCandidates(query) {
|
|
5910
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
5911
|
+
const out = [];
|
|
5912
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5913
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
5914
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
5915
|
+
const gram = tokens.slice(start, start + n);
|
|
5916
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
5917
|
+
const candidate = gram.join(" ");
|
|
5918
|
+
if (seen.has(candidate)) continue;
|
|
5919
|
+
seen.add(candidate);
|
|
5920
|
+
out.push(candidate);
|
|
5921
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
return out;
|
|
5899
5925
|
}
|
|
5900
|
-
var STOPWORDS2, ENTITY_REGEX;
|
|
5926
|
+
var STOPWORDS2, ENTITY_REGEX, FALLBACK_ONLY_STOPWORDS, FALLBACK_STOPWORDS, MAX_FALLBACK_CANDIDATES, MAX_FALLBACK_TOKENS;
|
|
5901
5927
|
var init_queryEntities = __esm({
|
|
5902
5928
|
"src/lib/memory/queryEntities.ts"() {
|
|
5903
5929
|
"use strict";
|
|
@@ -5949,6 +5975,10 @@ var init_queryEntities = __esm({
|
|
|
5949
5975
|
].map((w) => w.toLowerCase())
|
|
5950
5976
|
);
|
|
5951
5977
|
ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
5978
|
+
FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
5979
|
+
FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
5980
|
+
MAX_FALLBACK_CANDIDATES = 12;
|
|
5981
|
+
MAX_FALLBACK_TOKENS = 3;
|
|
5952
5982
|
}
|
|
5953
5983
|
});
|
|
5954
5984
|
|
package/dist/expo/index.mjs
CHANGED
|
@@ -5925,7 +5925,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
5925
5925
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
5926
5926
|
);
|
|
5927
5927
|
}
|
|
5928
|
-
const { recall: recall2 } = await import("./recall-
|
|
5928
|
+
const { recall: recall2 } = await import("./recall-F33QYRYU.mjs");
|
|
5929
5929
|
const result = await recall2(
|
|
5930
5930
|
query,
|
|
5931
5931
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -6018,6 +6018,18 @@ var STOPWORDS2 = new Set(
|
|
|
6018
6018
|
].map((w) => w.toLowerCase())
|
|
6019
6019
|
);
|
|
6020
6020
|
var ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
6021
|
+
var FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
6022
|
+
var FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
6023
|
+
var MAX_FALLBACK_CANDIDATES = 12;
|
|
6024
|
+
var MAX_FALLBACK_TOKENS = 3;
|
|
6025
|
+
function hasMeaningfulCandidate(candidates) {
|
|
6026
|
+
for (const candidate of candidates) {
|
|
6027
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
6028
|
+
return true;
|
|
6029
|
+
}
|
|
6030
|
+
}
|
|
6031
|
+
return false;
|
|
6032
|
+
}
|
|
6021
6033
|
function extractQueryEntities(query) {
|
|
6022
6034
|
if (!query) return [];
|
|
6023
6035
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -6033,7 +6045,25 @@ function extractQueryEntities(query) {
|
|
|
6033
6045
|
seen.add(candidate);
|
|
6034
6046
|
}
|
|
6035
6047
|
}
|
|
6036
|
-
return [...seen];
|
|
6048
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
6049
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
6050
|
+
}
|
|
6051
|
+
function extractFallbackCandidates(query) {
|
|
6052
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
6053
|
+
const out = [];
|
|
6054
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6055
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
6056
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
6057
|
+
const gram = tokens.slice(start, start + n);
|
|
6058
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
6059
|
+
const candidate = gram.join(" ");
|
|
6060
|
+
if (seen.has(candidate)) continue;
|
|
6061
|
+
seen.add(candidate);
|
|
6062
|
+
out.push(candidate);
|
|
6063
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6066
|
+
return out;
|
|
6037
6067
|
}
|
|
6038
6068
|
|
|
6039
6069
|
// src/lib/memory/graphTraversal.ts
|
package/dist/react/index.cjs
CHANGED
|
@@ -6181,6 +6181,14 @@ var init_lruCache = __esm({
|
|
|
6181
6181
|
});
|
|
6182
6182
|
|
|
6183
6183
|
// src/lib/memory/queryEntities.ts
|
|
6184
|
+
function hasMeaningfulCandidate(candidates) {
|
|
6185
|
+
for (const candidate of candidates) {
|
|
6186
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
6187
|
+
return true;
|
|
6188
|
+
}
|
|
6189
|
+
}
|
|
6190
|
+
return false;
|
|
6191
|
+
}
|
|
6184
6192
|
function extractQueryEntities(query) {
|
|
6185
6193
|
if (!query) return [];
|
|
6186
6194
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -6196,9 +6204,27 @@ function extractQueryEntities(query) {
|
|
|
6196
6204
|
seen.add(candidate);
|
|
6197
6205
|
}
|
|
6198
6206
|
}
|
|
6199
|
-
return [...seen];
|
|
6207
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
6208
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
6209
|
+
}
|
|
6210
|
+
function extractFallbackCandidates(query) {
|
|
6211
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
6212
|
+
const out = [];
|
|
6213
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6214
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
6215
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
6216
|
+
const gram = tokens.slice(start, start + n);
|
|
6217
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
6218
|
+
const candidate = gram.join(" ");
|
|
6219
|
+
if (seen.has(candidate)) continue;
|
|
6220
|
+
seen.add(candidate);
|
|
6221
|
+
out.push(candidate);
|
|
6222
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
6223
|
+
}
|
|
6224
|
+
}
|
|
6225
|
+
return out;
|
|
6200
6226
|
}
|
|
6201
|
-
var STOPWORDS2, ENTITY_REGEX;
|
|
6227
|
+
var STOPWORDS2, ENTITY_REGEX, FALLBACK_ONLY_STOPWORDS, FALLBACK_STOPWORDS, MAX_FALLBACK_CANDIDATES, MAX_FALLBACK_TOKENS;
|
|
6202
6228
|
var init_queryEntities = __esm({
|
|
6203
6229
|
"src/lib/memory/queryEntities.ts"() {
|
|
6204
6230
|
"use strict";
|
|
@@ -6250,6 +6276,10 @@ var init_queryEntities = __esm({
|
|
|
6250
6276
|
].map((w) => w.toLowerCase())
|
|
6251
6277
|
);
|
|
6252
6278
|
ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
6279
|
+
FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
6280
|
+
FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
6281
|
+
MAX_FALLBACK_CANDIDATES = 12;
|
|
6282
|
+
MAX_FALLBACK_TOKENS = 3;
|
|
6253
6283
|
}
|
|
6254
6284
|
});
|
|
6255
6285
|
|
package/dist/react/index.mjs
CHANGED
|
@@ -19815,7 +19815,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
19815
19815
|
legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
|
|
19816
19816
|
);
|
|
19817
19817
|
}
|
|
19818
|
-
const { recall: recall2 } = await import("./recall-
|
|
19818
|
+
const { recall: recall2 } = await import("./recall-23VTTAEG.mjs");
|
|
19819
19819
|
const result = await recall2(
|
|
19820
19820
|
query,
|
|
19821
19821
|
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
@@ -19908,6 +19908,18 @@ var STOPWORDS2 = new Set(
|
|
|
19908
19908
|
].map((w) => w.toLowerCase())
|
|
19909
19909
|
);
|
|
19910
19910
|
var ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
19911
|
+
var FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
19912
|
+
var FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
19913
|
+
var MAX_FALLBACK_CANDIDATES = 12;
|
|
19914
|
+
var MAX_FALLBACK_TOKENS = 3;
|
|
19915
|
+
function hasMeaningfulCandidate(candidates) {
|
|
19916
|
+
for (const candidate of candidates) {
|
|
19917
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
19918
|
+
return true;
|
|
19919
|
+
}
|
|
19920
|
+
}
|
|
19921
|
+
return false;
|
|
19922
|
+
}
|
|
19911
19923
|
function extractQueryEntities(query) {
|
|
19912
19924
|
if (!query) return [];
|
|
19913
19925
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -19923,7 +19935,25 @@ function extractQueryEntities(query) {
|
|
|
19923
19935
|
seen.add(candidate);
|
|
19924
19936
|
}
|
|
19925
19937
|
}
|
|
19926
|
-
return [...seen];
|
|
19938
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
19939
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
19940
|
+
}
|
|
19941
|
+
function extractFallbackCandidates(query) {
|
|
19942
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
19943
|
+
const out = [];
|
|
19944
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19945
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
19946
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
19947
|
+
const gram = tokens.slice(start, start + n);
|
|
19948
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
19949
|
+
const candidate = gram.join(" ");
|
|
19950
|
+
if (seen.has(candidate)) continue;
|
|
19951
|
+
seen.add(candidate);
|
|
19952
|
+
out.push(candidate);
|
|
19953
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
19954
|
+
}
|
|
19955
|
+
}
|
|
19956
|
+
return out;
|
|
19927
19957
|
}
|
|
19928
19958
|
|
|
19929
19959
|
// src/lib/memory/graphTraversal.ts
|
package/dist/server/index.cjs
CHANGED
|
@@ -20053,6 +20053,14 @@ var init_lruCache = __esm({
|
|
|
20053
20053
|
});
|
|
20054
20054
|
|
|
20055
20055
|
// src/lib/memory/queryEntities.ts
|
|
20056
|
+
function hasMeaningfulCandidate(candidates) {
|
|
20057
|
+
for (const candidate of candidates) {
|
|
20058
|
+
if (!candidate.split(/\s+/).every((token) => FALLBACK_STOPWORDS.has(token))) {
|
|
20059
|
+
return true;
|
|
20060
|
+
}
|
|
20061
|
+
}
|
|
20062
|
+
return false;
|
|
20063
|
+
}
|
|
20056
20064
|
function extractQueryEntities(query) {
|
|
20057
20065
|
if (!query) return [];
|
|
20058
20066
|
const matches = query.matchAll(ENTITY_REGEX);
|
|
@@ -20068,9 +20076,27 @@ function extractQueryEntities(query) {
|
|
|
20068
20076
|
seen.add(candidate);
|
|
20069
20077
|
}
|
|
20070
20078
|
}
|
|
20071
|
-
return [...seen];
|
|
20079
|
+
if (hasMeaningfulCandidate(seen)) return [...seen];
|
|
20080
|
+
return [.../* @__PURE__ */ new Set([...extractFallbackCandidates(query), ...seen])];
|
|
20081
|
+
}
|
|
20082
|
+
function extractFallbackCandidates(query) {
|
|
20083
|
+
const tokens = (query.match(/\p{L}[\p{L}'-]*/gu) ?? []).map(normalizeEntityName);
|
|
20084
|
+
const out = [];
|
|
20085
|
+
const seen = /* @__PURE__ */ new Set();
|
|
20086
|
+
for (let n = 1; n <= MAX_FALLBACK_TOKENS; n++) {
|
|
20087
|
+
for (let start = 0; start + n <= tokens.length; start++) {
|
|
20088
|
+
const gram = tokens.slice(start, start + n);
|
|
20089
|
+
if (gram.some((t) => t.length < 2 || FALLBACK_STOPWORDS.has(t))) continue;
|
|
20090
|
+
const candidate = gram.join(" ");
|
|
20091
|
+
if (seen.has(candidate)) continue;
|
|
20092
|
+
seen.add(candidate);
|
|
20093
|
+
out.push(candidate);
|
|
20094
|
+
if (out.length >= MAX_FALLBACK_CANDIDATES) return out;
|
|
20095
|
+
}
|
|
20096
|
+
}
|
|
20097
|
+
return out;
|
|
20072
20098
|
}
|
|
20073
|
-
var STOPWORDS2, ENTITY_REGEX;
|
|
20099
|
+
var STOPWORDS2, ENTITY_REGEX, FALLBACK_ONLY_STOPWORDS, FALLBACK_STOPWORDS, MAX_FALLBACK_CANDIDATES, MAX_FALLBACK_TOKENS;
|
|
20074
20100
|
var init_queryEntities = __esm({
|
|
20075
20101
|
"src/lib/memory/queryEntities.ts"() {
|
|
20076
20102
|
"use strict";
|
|
@@ -20122,6 +20148,10 @@ var init_queryEntities = __esm({
|
|
|
20122
20148
|
].map((w) => w.toLowerCase())
|
|
20123
20149
|
);
|
|
20124
20150
|
ENTITY_REGEX = /\b\p{Lu}[\p{L}'-]{2,}(?:\s+\p{Lu}[\p{L}'-]+){0,2}\b/gu;
|
|
20151
|
+
FALLBACK_ONLY_STOPWORDS = "a an and or but nor not if then than because so too also just very really about above after again against all am any anyone anybody anything are around as at be been being before behind below between both by can cannot could currently did do does doing done down during each ever every everybody everyone everything few find finds finding for from get gets getting go goes going gone got had has have having he help her here hers him his hmm i in into is it its knew know knows later like liked likes live lived lives living look looked looking looks made make makes may me meet meets might mine more most must my near need needed needs never nobody nothing now of off okay on once only onto other our ours out over own people person please recently said same say says see seen shall she should since some somebody someone something soon still such talk tell tells thank that the their theirs them there these they think thinks this those thought through to today told tomorrow under until up us want wanted wants was we went were which while will with without work worked working works would yeah year years yep yesterday you your yours aren't can't couldn't didn't doesn't don't hadn't hasn't haven't he's how's i'd i'll i'm i've isn't it's let's she's shouldn't that's there's they're they've wasn't we're we've weren't what's when's where's who's why's won't wouldn't you'll you're you've".split(" ");
|
|
20152
|
+
FALLBACK_STOPWORDS = /* @__PURE__ */ new Set([...STOPWORDS2, ...FALLBACK_ONLY_STOPWORDS]);
|
|
20153
|
+
MAX_FALLBACK_CANDIDATES = 12;
|
|
20154
|
+
MAX_FALLBACK_TOKENS = 3;
|
|
20125
20155
|
}
|
|
20126
20156
|
});
|
|
20127
20157
|
|
package/dist/server/index.mjs
CHANGED