@anuma/sdk 10.4.3 → 10.5.1
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/index.cjs +204 -14
- package/dist/expo/index.d.mts +20 -2
- package/dist/expo/index.d.ts +20 -2
- package/dist/expo/index.mjs +201 -14
- package/dist/index.cjs +69 -4
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.mjs +67 -4
- package/dist/react/{chunk-6ANL34M3.mjs → chunk-6QCUNXU6.mjs} +1 -0
- package/dist/react/{consolidate-JL4P6FXW.mjs → consolidate-RASCVKD2.mjs} +1 -1
- package/dist/react/index.cjs +259 -53
- package/dist/react/index.d.mts +20 -2
- package/dist/react/index.d.ts +20 -2
- package/dist/react/index.mjs +259 -55
- package/dist/server/{chunk-BIMEZT3O.mjs → chunk-JEY3L7WD.mjs} +1 -0
- package/dist/server/{consolidate-JZJYY3SZ.mjs → consolidate-5DFDLGSS.mjs} +1 -1
- package/dist/server/index.cjs +130 -6
- package/dist/server/index.mjs +132 -8
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -30938,6 +30938,7 @@ init_logger();
|
|
|
30938
30938
|
init_redactor();
|
|
30939
30939
|
|
|
30940
30940
|
// src/lib/memory/entitySalience.ts
|
|
30941
|
+
init_patterns();
|
|
30941
30942
|
var GENERIC_ENTITY_NAMES = /* @__PURE__ */ new Set([
|
|
30942
30943
|
"today",
|
|
30943
30944
|
"tomorrow",
|
|
@@ -31083,6 +31084,125 @@ var WEAK_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
31083
31084
|
"and",
|
|
31084
31085
|
"or"
|
|
31085
31086
|
]);
|
|
31087
|
+
var MAX_ENTITY_NAME_LENGTH = 120;
|
|
31088
|
+
var MAX_ENTITY_NAME_TOKENS = 11;
|
|
31089
|
+
var PREFIXED_HEX = /^0x[0-9a-f]{16,}$/i;
|
|
31090
|
+
var BARE_HEX = /^[0-9a-f]{32,}$/i;
|
|
31091
|
+
var BASE58_STRING = /^[1-9A-HJ-NP-Za-km-z]{32,88}$/;
|
|
31092
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
31093
|
+
var TRUNCATED_ID = /^[0-9a-z]{3,}(?:…|\.{2,3})[0-9a-z]{3,}$/i;
|
|
31094
|
+
var KEY_SEGMENT_MIN_LENGTH = 16;
|
|
31095
|
+
var LONG_DIGIT_RUN = /^\d{6,}$/;
|
|
31096
|
+
var CURRENCY_MARKED = /[$€£¥₹₿]\d|\d[$€£¥₹₿]/;
|
|
31097
|
+
var NUMERIC_TOKEN = /^[~≈+\-−]?(?:us\$|[$€£¥₹₿])?\d(?:[\d,.]*\d)?(?:k|mm|m|bn|b|t|x|%|[$€£¥₹₿])?$/i;
|
|
31098
|
+
var PLAIN_YEAR = /^(?:1\d{3}|20\d{2})$/;
|
|
31099
|
+
var SUFFIXED_NAME = /^\d*[1-9][kmb]$/i;
|
|
31100
|
+
var BARE_INTEGER = /^\d+$/;
|
|
31101
|
+
var TICKER = /^\$?[A-Z]{2,6}$/;
|
|
31102
|
+
var DETACHED_CURRENCY_SYMBOL = /(^|\s)([$€£¥₹₿])\s+(?=\d)|(\d)\s+([$€£¥₹₿])(?=\s|$)/gu;
|
|
31103
|
+
var LEADING_PUNCTUATION = /^[^\p{L}\p{N}$€£¥₹₿~≈+\-−]+/u;
|
|
31104
|
+
var TRAILING_KEPT_CHARACTER = /[\p{L}\p{N}$€£¥₹₿%]/u;
|
|
31105
|
+
var LEADING_CURRENCY_CODES = /* @__PURE__ */ new Set(["usd", "eur", "gbp", "jpy", "cad", "aud", "chf", "cny"]);
|
|
31106
|
+
var QUANTITY_UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
31107
|
+
"usd",
|
|
31108
|
+
"usdc",
|
|
31109
|
+
"usdt",
|
|
31110
|
+
"eur",
|
|
31111
|
+
"gbp",
|
|
31112
|
+
"sol",
|
|
31113
|
+
"eth",
|
|
31114
|
+
"btc",
|
|
31115
|
+
"dollar",
|
|
31116
|
+
"dollars",
|
|
31117
|
+
"euro",
|
|
31118
|
+
"euros",
|
|
31119
|
+
"buck",
|
|
31120
|
+
"bucks",
|
|
31121
|
+
"k",
|
|
31122
|
+
"thousand",
|
|
31123
|
+
"million",
|
|
31124
|
+
"billion",
|
|
31125
|
+
"trillion",
|
|
31126
|
+
"share",
|
|
31127
|
+
"shares",
|
|
31128
|
+
"token",
|
|
31129
|
+
"tokens",
|
|
31130
|
+
"coin",
|
|
31131
|
+
"coins",
|
|
31132
|
+
"unit",
|
|
31133
|
+
"units",
|
|
31134
|
+
"position",
|
|
31135
|
+
"balance",
|
|
31136
|
+
"stake",
|
|
31137
|
+
"holdings"
|
|
31138
|
+
]);
|
|
31139
|
+
var AMOUNT_WORDS = /* @__PURE__ */ new Set([...QUANTITY_UNIT_WORDS, "percent", "of"]);
|
|
31140
|
+
var NAME_PII_CATEGORIES = /* @__PURE__ */ new Set(["EMAIL", "PHONE", "SSN", "CREDIT_CARD"]);
|
|
31141
|
+
var NAME_PII_PATTERNS = PII_PATTERNS.filter(
|
|
31142
|
+
(pattern) => NAME_PII_CATEGORIES.has(pattern.category) && pattern.context === void 0
|
|
31143
|
+
);
|
|
31144
|
+
var KEPT_PLACEHOLDER_CATEGORIES = /* @__PURE__ */ new Set(["PERSON", "LOCATION", "ORG"]);
|
|
31145
|
+
var PLACEHOLDER_TOKEN = /\b([A-Za-z]+(?:_[A-Za-z]+)*)_\d+\b/g;
|
|
31146
|
+
function trimPunctuation(token) {
|
|
31147
|
+
const chars = Array.from(token.replace(LEADING_PUNCTUATION, ""));
|
|
31148
|
+
let end = chars.length;
|
|
31149
|
+
while (end > 0 && !TRAILING_KEPT_CHARACTER.test(chars[end - 1])) end--;
|
|
31150
|
+
return chars.slice(0, end).join("");
|
|
31151
|
+
}
|
|
31152
|
+
function hasLetterAndDigit(text12) {
|
|
31153
|
+
return /\p{L}/u.test(text12) && /\p{N}/u.test(text12);
|
|
31154
|
+
}
|
|
31155
|
+
function isIdentifierToken(token) {
|
|
31156
|
+
if (PREFIXED_HEX.test(token) || BARE_HEX.test(token) || BASE58_STRING.test(token)) return true;
|
|
31157
|
+
if (UUID.test(token) || LONG_DIGIT_RUN.test(token)) return true;
|
|
31158
|
+
if (TRUNCATED_ID.test(token) && hasLetterAndDigit(token)) return true;
|
|
31159
|
+
return token.split(/[-_.]/).some((segment) => segment.length >= KEY_SEGMENT_MIN_LENGTH && hasLetterAndDigit(segment));
|
|
31160
|
+
}
|
|
31161
|
+
function containsStructuredPii(name) {
|
|
31162
|
+
return NAME_PII_PATTERNS.some(
|
|
31163
|
+
(pattern) => (name.match(pattern.regex) ?? []).some((match) => pattern.validate?.(match) ?? true)
|
|
31164
|
+
);
|
|
31165
|
+
}
|
|
31166
|
+
function isAmountUnitToken(token) {
|
|
31167
|
+
return NUMERIC_TOKEN.test(token) || TICKER.test(token) || AMOUNT_WORDS.has(token.toLowerCase());
|
|
31168
|
+
}
|
|
31169
|
+
function isAmountWordOrNumber(token) {
|
|
31170
|
+
return NUMERIC_TOKEN.test(token) || AMOUNT_WORDS.has(token.toLowerCase());
|
|
31171
|
+
}
|
|
31172
|
+
function isAmount(tokens) {
|
|
31173
|
+
const start = LEADING_CURRENCY_CODES.has(tokens[0]?.toLowerCase() ?? "") ? 1 : 0;
|
|
31174
|
+
const first = tokens[start];
|
|
31175
|
+
if (first === void 0 || !NUMERIC_TOKEN.test(first)) return false;
|
|
31176
|
+
const units = tokens.slice(start + 1);
|
|
31177
|
+
if (start === 0 && units.length === 0)
|
|
31178
|
+
return !PLAIN_YEAR.test(first) && !SUFFIXED_NAME.test(first);
|
|
31179
|
+
if (!units.every(isAmountUnitToken)) return false;
|
|
31180
|
+
return start === 1 || !BARE_INTEGER.test(first) || units.some(isAmountWordOrNumber);
|
|
31181
|
+
}
|
|
31182
|
+
function hasQuantityPhrase(tokens) {
|
|
31183
|
+
return tokens.some(
|
|
31184
|
+
(token, i) => NUMERIC_TOKEN.test(token) && QUANTITY_UNIT_WORDS.has(tokens[i + 1]?.toLowerCase() ?? "")
|
|
31185
|
+
);
|
|
31186
|
+
}
|
|
31187
|
+
function isIdentifierOrAmountEntityName(name) {
|
|
31188
|
+
const trimmed = name.trim();
|
|
31189
|
+
if (trimmed.length > MAX_ENTITY_NAME_LENGTH) return true;
|
|
31190
|
+
if (containsStructuredPii(trimmed)) return true;
|
|
31191
|
+
const tokens = trimmed.replace(DETACHED_CURRENCY_SYMBOL, "$1$2$3$4").split(/\s+/).map(trimPunctuation).filter((token) => token.length > 0);
|
|
31192
|
+
if (tokens.length === 0) return false;
|
|
31193
|
+
if (tokens.length > MAX_ENTITY_NAME_TOKENS) return true;
|
|
31194
|
+
if (tokens.some(isIdentifierToken)) return true;
|
|
31195
|
+
if (tokens.some((token) => CURRENCY_MARKED.test(token))) return true;
|
|
31196
|
+
return isAmount(tokens) || hasQuantityPhrase(tokens);
|
|
31197
|
+
}
|
|
31198
|
+
function restoreEntityName(name, redactor) {
|
|
31199
|
+
for (const [token, category] of name.matchAll(PLACEHOLDER_TOKEN)) {
|
|
31200
|
+
if (KEPT_PLACEHOLDER_CATEGORIES.has(category.toUpperCase())) continue;
|
|
31201
|
+
if (redactor.restoreForStorage(token).text !== token) return null;
|
|
31202
|
+
}
|
|
31203
|
+
const restored = redactor.restoreForStorage(name);
|
|
31204
|
+
return restored.unresolved || isIdentifierOrAmountEntityName(restored.text) ? null : restored.text;
|
|
31205
|
+
}
|
|
31086
31206
|
|
|
31087
31207
|
// src/lib/memory/injectionClassifier.ts
|
|
31088
31208
|
init_logger();
|
|
@@ -33895,8 +34015,8 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
33895
34015
|
...c,
|
|
33896
34016
|
content: content.text,
|
|
33897
34017
|
entities: c.entities.flatMap((e) => {
|
|
33898
|
-
const
|
|
33899
|
-
return
|
|
34018
|
+
const name = restoreEntityName(e.name, redactor);
|
|
34019
|
+
return name === null ? [] : [{ ...e, name }];
|
|
33900
34020
|
})
|
|
33901
34021
|
},
|
|
33902
34022
|
unresolved: content.unresolved
|
|
@@ -34164,18 +34284,21 @@ function validateCandidates(parsed, validIds, userIds, fallbackSourceId, ownName
|
|
|
34164
34284
|
}
|
|
34165
34285
|
return out;
|
|
34166
34286
|
}
|
|
34287
|
+
function isAcceptedEntityName(name) {
|
|
34288
|
+
return name.length > 0 && !isGenericEntityName(name) && !isIdentifierOrAmountEntityName(name);
|
|
34289
|
+
}
|
|
34167
34290
|
function parseEntities(raw) {
|
|
34168
34291
|
const out = [];
|
|
34169
34292
|
for (const e of raw) {
|
|
34170
34293
|
if (typeof e === "string") {
|
|
34171
34294
|
const name2 = e.trim();
|
|
34172
|
-
if (
|
|
34295
|
+
if (isAcceptedEntityName(name2)) out.push({ name: name2 });
|
|
34173
34296
|
continue;
|
|
34174
34297
|
}
|
|
34175
34298
|
if (typeof e !== "object" || e === null) continue;
|
|
34176
34299
|
const obj = e;
|
|
34177
34300
|
const name = typeof obj.name === "string" ? obj.name.trim() : "";
|
|
34178
|
-
if (
|
|
34301
|
+
if (!isAcceptedEntityName(name)) continue;
|
|
34179
34302
|
const kind = typeof obj.kind === "string" && ENTITY_KINDS.includes(obj.kind) ? obj.kind : void 0;
|
|
34180
34303
|
const weight = typeof obj.salience === "string" && Object.keys(TOPIC_SALIENCE_WEIGHTS).includes(obj.salience) ? TOPIC_SALIENCE_WEIGHTS[obj.salience] : void 0;
|
|
34181
34304
|
out.push({
|
|
@@ -36365,6 +36488,7 @@ Each memory is a short statement about the user. For each memory, list the NAMED
|
|
|
36365
36488
|
Include only NAMED entities, skip generic/common nouns. A topic must identify a specific thing the user could recognize by name; if it would be equally true of thousands of unrelated memories, leave it out:
|
|
36366
36489
|
- SKIP bare generic nouns even when the memory capitalizes them or a calendar entry is titled that way \u2014 "Home", "Work", "Meeting", "Lunch", "Birthday", "Appointment", "Trip", "Today", "Friday", "March" are NOT topics.
|
|
36367
36490
|
- KEEP the specific thing instead, when the memory names one: "Blue Bottle on Valencia" over "cafe", "Chicago Marathon" over "event", "Hollowpoint Labs" over "work".
|
|
36491
|
+
- SKIP identifiers and numbers \u2014 addresses, hashes, keys, account or order numbers, balances, prices, amounts and position sizes are NOT topics. Use the general subject instead: "Solana" or "trading" rather than "3.5 SOL" or an address.
|
|
36368
36492
|
- Prefer 0 entities over a weak one. A memory whose only candidate is a generic noun has NO entities.
|
|
36369
36493
|
${ENTITY_KIND_GUIDELINES}
|
|
36370
36494
|
|
|
@@ -36470,8 +36594,8 @@ List each memory's named entities.`,
|
|
|
36470
36594
|
}
|
|
36471
36595
|
function restoreEntities(entities, redactor) {
|
|
36472
36596
|
return entities.flatMap((e) => {
|
|
36473
|
-
const
|
|
36474
|
-
return
|
|
36597
|
+
const name = restoreEntityName(e.name, redactor);
|
|
36598
|
+
return name === null ? [] : [{ ...e, name }];
|
|
36475
36599
|
});
|
|
36476
36600
|
}
|
|
36477
36601
|
function parseTopicResponse(parsed, validIds) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
INTERNAL_FLOW_MARKER,
|
|
3
|
+
PII_PATTERNS,
|
|
3
4
|
callPortalJsonCompletion,
|
|
4
5
|
createStreamingDeAnonymizer,
|
|
5
6
|
extractCompletionContent,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
taskTypeHeader,
|
|
14
15
|
validateEndpointOverride,
|
|
15
16
|
withInternalFlowMarker
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-JEY3L7WD.mjs";
|
|
17
18
|
import {
|
|
18
19
|
BASE_URL,
|
|
19
20
|
__commonJS,
|
|
@@ -29337,6 +29338,125 @@ var WEAK_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
29337
29338
|
"and",
|
|
29338
29339
|
"or"
|
|
29339
29340
|
]);
|
|
29341
|
+
var MAX_ENTITY_NAME_LENGTH = 120;
|
|
29342
|
+
var MAX_ENTITY_NAME_TOKENS = 11;
|
|
29343
|
+
var PREFIXED_HEX = /^0x[0-9a-f]{16,}$/i;
|
|
29344
|
+
var BARE_HEX = /^[0-9a-f]{32,}$/i;
|
|
29345
|
+
var BASE58_STRING = /^[1-9A-HJ-NP-Za-km-z]{32,88}$/;
|
|
29346
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
29347
|
+
var TRUNCATED_ID = /^[0-9a-z]{3,}(?:…|\.{2,3})[0-9a-z]{3,}$/i;
|
|
29348
|
+
var KEY_SEGMENT_MIN_LENGTH = 16;
|
|
29349
|
+
var LONG_DIGIT_RUN = /^\d{6,}$/;
|
|
29350
|
+
var CURRENCY_MARKED = /[$€£¥₹₿]\d|\d[$€£¥₹₿]/;
|
|
29351
|
+
var NUMERIC_TOKEN = /^[~≈+\-−]?(?:us\$|[$€£¥₹₿])?\d(?:[\d,.]*\d)?(?:k|mm|m|bn|b|t|x|%|[$€£¥₹₿])?$/i;
|
|
29352
|
+
var PLAIN_YEAR = /^(?:1\d{3}|20\d{2})$/;
|
|
29353
|
+
var SUFFIXED_NAME = /^\d*[1-9][kmb]$/i;
|
|
29354
|
+
var BARE_INTEGER = /^\d+$/;
|
|
29355
|
+
var TICKER = /^\$?[A-Z]{2,6}$/;
|
|
29356
|
+
var DETACHED_CURRENCY_SYMBOL = /(^|\s)([$€£¥₹₿])\s+(?=\d)|(\d)\s+([$€£¥₹₿])(?=\s|$)/gu;
|
|
29357
|
+
var LEADING_PUNCTUATION = /^[^\p{L}\p{N}$€£¥₹₿~≈+\-−]+/u;
|
|
29358
|
+
var TRAILING_KEPT_CHARACTER = /[\p{L}\p{N}$€£¥₹₿%]/u;
|
|
29359
|
+
var LEADING_CURRENCY_CODES = /* @__PURE__ */ new Set(["usd", "eur", "gbp", "jpy", "cad", "aud", "chf", "cny"]);
|
|
29360
|
+
var QUANTITY_UNIT_WORDS = /* @__PURE__ */ new Set([
|
|
29361
|
+
"usd",
|
|
29362
|
+
"usdc",
|
|
29363
|
+
"usdt",
|
|
29364
|
+
"eur",
|
|
29365
|
+
"gbp",
|
|
29366
|
+
"sol",
|
|
29367
|
+
"eth",
|
|
29368
|
+
"btc",
|
|
29369
|
+
"dollar",
|
|
29370
|
+
"dollars",
|
|
29371
|
+
"euro",
|
|
29372
|
+
"euros",
|
|
29373
|
+
"buck",
|
|
29374
|
+
"bucks",
|
|
29375
|
+
"k",
|
|
29376
|
+
"thousand",
|
|
29377
|
+
"million",
|
|
29378
|
+
"billion",
|
|
29379
|
+
"trillion",
|
|
29380
|
+
"share",
|
|
29381
|
+
"shares",
|
|
29382
|
+
"token",
|
|
29383
|
+
"tokens",
|
|
29384
|
+
"coin",
|
|
29385
|
+
"coins",
|
|
29386
|
+
"unit",
|
|
29387
|
+
"units",
|
|
29388
|
+
"position",
|
|
29389
|
+
"balance",
|
|
29390
|
+
"stake",
|
|
29391
|
+
"holdings"
|
|
29392
|
+
]);
|
|
29393
|
+
var AMOUNT_WORDS = /* @__PURE__ */ new Set([...QUANTITY_UNIT_WORDS, "percent", "of"]);
|
|
29394
|
+
var NAME_PII_CATEGORIES = /* @__PURE__ */ new Set(["EMAIL", "PHONE", "SSN", "CREDIT_CARD"]);
|
|
29395
|
+
var NAME_PII_PATTERNS = PII_PATTERNS.filter(
|
|
29396
|
+
(pattern) => NAME_PII_CATEGORIES.has(pattern.category) && pattern.context === void 0
|
|
29397
|
+
);
|
|
29398
|
+
var KEPT_PLACEHOLDER_CATEGORIES = /* @__PURE__ */ new Set(["PERSON", "LOCATION", "ORG"]);
|
|
29399
|
+
var PLACEHOLDER_TOKEN = /\b([A-Za-z]+(?:_[A-Za-z]+)*)_\d+\b/g;
|
|
29400
|
+
function trimPunctuation(token) {
|
|
29401
|
+
const chars = Array.from(token.replace(LEADING_PUNCTUATION, ""));
|
|
29402
|
+
let end = chars.length;
|
|
29403
|
+
while (end > 0 && !TRAILING_KEPT_CHARACTER.test(chars[end - 1])) end--;
|
|
29404
|
+
return chars.slice(0, end).join("");
|
|
29405
|
+
}
|
|
29406
|
+
function hasLetterAndDigit(text12) {
|
|
29407
|
+
return /\p{L}/u.test(text12) && /\p{N}/u.test(text12);
|
|
29408
|
+
}
|
|
29409
|
+
function isIdentifierToken(token) {
|
|
29410
|
+
if (PREFIXED_HEX.test(token) || BARE_HEX.test(token) || BASE58_STRING.test(token)) return true;
|
|
29411
|
+
if (UUID.test(token) || LONG_DIGIT_RUN.test(token)) return true;
|
|
29412
|
+
if (TRUNCATED_ID.test(token) && hasLetterAndDigit(token)) return true;
|
|
29413
|
+
return token.split(/[-_.]/).some((segment) => segment.length >= KEY_SEGMENT_MIN_LENGTH && hasLetterAndDigit(segment));
|
|
29414
|
+
}
|
|
29415
|
+
function containsStructuredPii(name) {
|
|
29416
|
+
return NAME_PII_PATTERNS.some(
|
|
29417
|
+
(pattern) => (name.match(pattern.regex) ?? []).some((match) => pattern.validate?.(match) ?? true)
|
|
29418
|
+
);
|
|
29419
|
+
}
|
|
29420
|
+
function isAmountUnitToken(token) {
|
|
29421
|
+
return NUMERIC_TOKEN.test(token) || TICKER.test(token) || AMOUNT_WORDS.has(token.toLowerCase());
|
|
29422
|
+
}
|
|
29423
|
+
function isAmountWordOrNumber(token) {
|
|
29424
|
+
return NUMERIC_TOKEN.test(token) || AMOUNT_WORDS.has(token.toLowerCase());
|
|
29425
|
+
}
|
|
29426
|
+
function isAmount(tokens) {
|
|
29427
|
+
const start = LEADING_CURRENCY_CODES.has(tokens[0]?.toLowerCase() ?? "") ? 1 : 0;
|
|
29428
|
+
const first = tokens[start];
|
|
29429
|
+
if (first === void 0 || !NUMERIC_TOKEN.test(first)) return false;
|
|
29430
|
+
const units = tokens.slice(start + 1);
|
|
29431
|
+
if (start === 0 && units.length === 0)
|
|
29432
|
+
return !PLAIN_YEAR.test(first) && !SUFFIXED_NAME.test(first);
|
|
29433
|
+
if (!units.every(isAmountUnitToken)) return false;
|
|
29434
|
+
return start === 1 || !BARE_INTEGER.test(first) || units.some(isAmountWordOrNumber);
|
|
29435
|
+
}
|
|
29436
|
+
function hasQuantityPhrase(tokens) {
|
|
29437
|
+
return tokens.some(
|
|
29438
|
+
(token, i) => NUMERIC_TOKEN.test(token) && QUANTITY_UNIT_WORDS.has(tokens[i + 1]?.toLowerCase() ?? "")
|
|
29439
|
+
);
|
|
29440
|
+
}
|
|
29441
|
+
function isIdentifierOrAmountEntityName(name) {
|
|
29442
|
+
const trimmed = name.trim();
|
|
29443
|
+
if (trimmed.length > MAX_ENTITY_NAME_LENGTH) return true;
|
|
29444
|
+
if (containsStructuredPii(trimmed)) return true;
|
|
29445
|
+
const tokens = trimmed.replace(DETACHED_CURRENCY_SYMBOL, "$1$2$3$4").split(/\s+/).map(trimPunctuation).filter((token) => token.length > 0);
|
|
29446
|
+
if (tokens.length === 0) return false;
|
|
29447
|
+
if (tokens.length > MAX_ENTITY_NAME_TOKENS) return true;
|
|
29448
|
+
if (tokens.some(isIdentifierToken)) return true;
|
|
29449
|
+
if (tokens.some((token) => CURRENCY_MARKED.test(token))) return true;
|
|
29450
|
+
return isAmount(tokens) || hasQuantityPhrase(tokens);
|
|
29451
|
+
}
|
|
29452
|
+
function restoreEntityName(name, redactor) {
|
|
29453
|
+
for (const [token, category] of name.matchAll(PLACEHOLDER_TOKEN)) {
|
|
29454
|
+
if (KEPT_PLACEHOLDER_CATEGORIES.has(category.toUpperCase())) continue;
|
|
29455
|
+
if (redactor.restoreForStorage(token).text !== token) return null;
|
|
29456
|
+
}
|
|
29457
|
+
const restored = redactor.restoreForStorage(name);
|
|
29458
|
+
return restored.unresolved || isIdentifierOrAmountEntityName(restored.text) ? null : restored.text;
|
|
29459
|
+
}
|
|
29340
29460
|
|
|
29341
29461
|
// src/lib/memory/injectionClassifier.ts
|
|
29342
29462
|
var DEFAULT_MODEL = "inclusionai/ling-2.6-flash";
|
|
@@ -31839,7 +31959,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31839
31959
|
content: m.content,
|
|
31840
31960
|
similarity: m.similarity
|
|
31841
31961
|
}));
|
|
31842
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
31962
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-5DFDLGSS.mjs");
|
|
31843
31963
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
31844
31964
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
31845
31965
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -32132,8 +32252,8 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
32132
32252
|
...c,
|
|
32133
32253
|
content: content.text,
|
|
32134
32254
|
entities: c.entities.flatMap((e) => {
|
|
32135
|
-
const
|
|
32136
|
-
return
|
|
32255
|
+
const name = restoreEntityName(e.name, redactor);
|
|
32256
|
+
return name === null ? [] : [{ ...e, name }];
|
|
32137
32257
|
})
|
|
32138
32258
|
},
|
|
32139
32259
|
unresolved: content.unresolved
|
|
@@ -32401,18 +32521,21 @@ function validateCandidates(parsed, validIds, userIds, fallbackSourceId, ownName
|
|
|
32401
32521
|
}
|
|
32402
32522
|
return out;
|
|
32403
32523
|
}
|
|
32524
|
+
function isAcceptedEntityName(name) {
|
|
32525
|
+
return name.length > 0 && !isGenericEntityName(name) && !isIdentifierOrAmountEntityName(name);
|
|
32526
|
+
}
|
|
32404
32527
|
function parseEntities(raw) {
|
|
32405
32528
|
const out = [];
|
|
32406
32529
|
for (const e of raw) {
|
|
32407
32530
|
if (typeof e === "string") {
|
|
32408
32531
|
const name2 = e.trim();
|
|
32409
|
-
if (
|
|
32532
|
+
if (isAcceptedEntityName(name2)) out.push({ name: name2 });
|
|
32410
32533
|
continue;
|
|
32411
32534
|
}
|
|
32412
32535
|
if (typeof e !== "object" || e === null) continue;
|
|
32413
32536
|
const obj = e;
|
|
32414
32537
|
const name = typeof obj.name === "string" ? obj.name.trim() : "";
|
|
32415
|
-
if (
|
|
32538
|
+
if (!isAcceptedEntityName(name)) continue;
|
|
32416
32539
|
const kind = typeof obj.kind === "string" && ENTITY_KINDS.includes(obj.kind) ? obj.kind : void 0;
|
|
32417
32540
|
const weight = typeof obj.salience === "string" && Object.keys(TOPIC_SALIENCE_WEIGHTS).includes(obj.salience) ? TOPIC_SALIENCE_WEIGHTS[obj.salience] : void 0;
|
|
32418
32541
|
out.push({
|
|
@@ -34581,6 +34704,7 @@ Each memory is a short statement about the user. For each memory, list the NAMED
|
|
|
34581
34704
|
Include only NAMED entities, skip generic/common nouns. A topic must identify a specific thing the user could recognize by name; if it would be equally true of thousands of unrelated memories, leave it out:
|
|
34582
34705
|
- SKIP bare generic nouns even when the memory capitalizes them or a calendar entry is titled that way \u2014 "Home", "Work", "Meeting", "Lunch", "Birthday", "Appointment", "Trip", "Today", "Friday", "March" are NOT topics.
|
|
34583
34706
|
- KEEP the specific thing instead, when the memory names one: "Blue Bottle on Valencia" over "cafe", "Chicago Marathon" over "event", "Hollowpoint Labs" over "work".
|
|
34707
|
+
- SKIP identifiers and numbers \u2014 addresses, hashes, keys, account or order numbers, balances, prices, amounts and position sizes are NOT topics. Use the general subject instead: "Solana" or "trading" rather than "3.5 SOL" or an address.
|
|
34584
34708
|
- Prefer 0 entities over a weak one. A memory whose only candidate is a generic noun has NO entities.
|
|
34585
34709
|
${ENTITY_KIND_GUIDELINES}
|
|
34586
34710
|
|
|
@@ -34686,8 +34810,8 @@ List each memory's named entities.`,
|
|
|
34686
34810
|
}
|
|
34687
34811
|
function restoreEntities(entities, redactor) {
|
|
34688
34812
|
return entities.flatMap((e) => {
|
|
34689
|
-
const
|
|
34690
|
-
return
|
|
34813
|
+
const name = restoreEntityName(e.name, redactor);
|
|
34814
|
+
return name === null ? [] : [{ ...e, name }];
|
|
34691
34815
|
});
|
|
34692
34816
|
}
|
|
34693
34817
|
function parseTopicResponse(parsed, validIds) {
|