@anuma/sdk 5.0.1 → 5.0.2

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.
@@ -55,12 +55,14 @@ async function consolidateMemory(newContent, candidates, options) {
55
55
  if (trimmed.length === 0) return fallback;
56
56
  if (candidates.length === 0) return fallback;
57
57
  const redactor = resolvePiiRedactor(options.piiRedaction);
58
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
59
- const candidateText = candidates.map((c, i) => {
60
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
61
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
62
- ${safeContent}`;
63
- }).join("\n");
58
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
59
+ const rows = [];
60
+ for (const [i, c] of candidates.entries()) {
61
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
62
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
63
+ ${safeContent}`);
64
+ }
65
+ const candidateText = rows.join("\n");
64
66
  const userMessage = `New memory:
65
67
  ${safeTrimmed}
66
68
 
@@ -8755,12 +8755,14 @@ async function consolidateMemory(newContent, candidates, options) {
8755
8755
  if (trimmed.length === 0) return fallback;
8756
8756
  if (candidates.length === 0) return fallback;
8757
8757
  const redactor = resolvePiiRedactor(options.piiRedaction);
8758
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
8759
- const candidateText = candidates.map((c, i) => {
8760
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
8761
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
8762
- ${safeContent}`;
8763
- }).join("\n");
8758
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
8759
+ const rows = [];
8760
+ for (const [i, c] of candidates.entries()) {
8761
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
8762
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
8763
+ ${safeContent}`);
8764
+ }
8765
+ const candidateText = rows.join("\n");
8764
8766
  const userMessage = `New memory:
8765
8767
  ${safeTrimmed}
8766
8768
 
@@ -15190,10 +15192,12 @@ async function classifyInjectionCandidates(candidates, options) {
15190
15192
  );
15191
15193
  }
15192
15194
  const redactor = resolvePiiRedactor(options.piiRedaction);
15193
- const numbered = scope.map((c, i) => {
15194
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
15195
- return `[${i + 1}] ${safe}`;
15196
- }).join("\n");
15195
+ const lines = [];
15196
+ for (const [i, c] of scope.entries()) {
15197
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
15198
+ lines.push(`[${i + 1}] ${safe}`);
15199
+ }
15200
+ const numbered = lines.join("\n");
15197
15201
  let parsed;
15198
15202
  try {
15199
15203
  parsed = await callPortalJsonCompletion({
@@ -16515,7 +16519,7 @@ function createLlmDecayClassifier(options) {
16515
16519
  }
16516
16520
  if (!content || content.trim().length === 0) return ruleVerdict;
16517
16521
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
16518
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
16522
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
16519
16523
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
16520
16524
  let parsed;
16521
16525
  try {
@@ -17645,17 +17649,22 @@ async function extractEntitiesForMemories(memories, options) {
17645
17649
  const out = /* @__PURE__ */ new Map();
17646
17650
  if (memories.length === 0) return out;
17647
17651
  const redactor = resolvePiiRedactor(options.piiRedaction);
17648
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
17652
+ const vocabulary = [];
17653
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
17654
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
17655
+ }
17649
17656
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
17650
17657
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
17651
17658
 
17652
17659
  ` : "";
17653
17660
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
17654
17661
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
17655
- const listing = batch.map((m) => {
17662
+ const rows = [];
17663
+ for (const m of batch) {
17656
17664
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
17657
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
17658
- }).join("\n");
17665
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
17666
+ }
17667
+ const listing = rows.join("\n");
17659
17668
  const parsed = await callPortalJsonCompletion({
17660
17669
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
17661
17670
  ...options.getToken !== void 0 && { getToken: options.getToken },
@@ -6193,10 +6193,12 @@ async function classifyInjectionCandidates(candidates, options) {
6193
6193
  );
6194
6194
  }
6195
6195
  const redactor = resolvePiiRedactor(options.piiRedaction);
6196
- const numbered = scope.map((c, i) => {
6197
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
6198
- return `[${i + 1}] ${safe}`;
6199
- }).join("\n");
6196
+ const lines = [];
6197
+ for (const [i, c] of scope.entries()) {
6198
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
6199
+ lines.push(`[${i + 1}] ${safe}`);
6200
+ }
6201
+ const numbered = lines.join("\n");
6200
6202
  let parsed;
6201
6203
  try {
6202
6204
  parsed = await callPortalJsonCompletion({
@@ -6677,7 +6679,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
6677
6679
  content: m.content,
6678
6680
  similarity: m.similarity
6679
6681
  }));
6680
- const { consolidateMemory: doConsolidate } = await import("./consolidate-KASO7JDS.mjs");
6682
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-T6GZ5YQ4.mjs");
6681
6683
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
6682
6684
  if (decision.action === "create") return null;
6683
6685
  if (decision.action === "supersede" && decision.content) {
@@ -7501,7 +7503,7 @@ function createLlmDecayClassifier(options) {
7501
7503
  }
7502
7504
  if (!content || content.trim().length === 0) return ruleVerdict;
7503
7505
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
7504
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
7506
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
7505
7507
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
7506
7508
  let parsed;
7507
7509
  try {
@@ -8598,17 +8600,22 @@ async function extractEntitiesForMemories(memories, options) {
8598
8600
  const out = /* @__PURE__ */ new Map();
8599
8601
  if (memories.length === 0) return out;
8600
8602
  const redactor = resolvePiiRedactor(options.piiRedaction);
8601
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
8603
+ const vocabulary = [];
8604
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
8605
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
8606
+ }
8602
8607
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
8603
8608
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
8604
8609
 
8605
8610
  ` : "";
8606
8611
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
8607
8612
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
8608
- const listing = batch.map((m) => {
8613
+ const rows = [];
8614
+ for (const m of batch) {
8609
8615
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
8610
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
8611
- }).join("\n");
8616
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
8617
+ }
8618
+ const listing = rows.join("\n");
8612
8619
  const parsed = await callPortalJsonCompletion({
8613
8620
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
8614
8621
  ...options.getToken !== void 0 && { getToken: options.getToken },
@@ -55,12 +55,14 @@ async function consolidateMemory(newContent, candidates, options) {
55
55
  if (trimmed.length === 0) return fallback;
56
56
  if (candidates.length === 0) return fallback;
57
57
  const redactor = resolvePiiRedactor(options.piiRedaction);
58
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
59
- const candidateText = candidates.map((c, i) => {
60
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
61
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
62
- ${safeContent}`;
63
- }).join("\n");
58
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
59
+ const rows = [];
60
+ for (const [i, c] of candidates.entries()) {
61
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
62
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
63
+ ${safeContent}`);
64
+ }
65
+ const candidateText = rows.join("\n");
64
66
  const userMessage = `New memory:
65
67
  ${safeTrimmed}
66
68
 
@@ -9038,12 +9038,14 @@ async function consolidateMemory(newContent, candidates, options) {
9038
9038
  if (trimmed.length === 0) return fallback;
9039
9039
  if (candidates.length === 0) return fallback;
9040
9040
  const redactor = resolvePiiRedactor(options.piiRedaction);
9041
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
9042
- const candidateText = candidates.map((c, i) => {
9043
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
9044
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
9045
- ${safeContent}`;
9046
- }).join("\n");
9041
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
9042
+ const rows = [];
9043
+ for (const [i, c] of candidates.entries()) {
9044
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
9045
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
9046
+ ${safeContent}`);
9047
+ }
9048
+ const candidateText = rows.join("\n");
9047
9049
  const userMessage = `New memory:
9048
9050
  ${safeTrimmed}
9049
9051
 
@@ -16489,10 +16491,12 @@ async function classifyInjectionCandidates(candidates, options) {
16489
16491
  );
16490
16492
  }
16491
16493
  const redactor = resolvePiiRedactor(options.piiRedaction);
16492
- const numbered = scope.map((c, i) => {
16493
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
16494
- return `[${i + 1}] ${safe}`;
16495
- }).join("\n");
16494
+ const lines = [];
16495
+ for (const [i, c] of scope.entries()) {
16496
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
16497
+ lines.push(`[${i + 1}] ${safe}`);
16498
+ }
16499
+ const numbered = lines.join("\n");
16496
16500
  let parsed;
16497
16501
  try {
16498
16502
  parsed = await callPortalJsonCompletion({
@@ -17814,7 +17818,7 @@ function createLlmDecayClassifier(options) {
17814
17818
  }
17815
17819
  if (!content || content.trim().length === 0) return ruleVerdict;
17816
17820
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
17817
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
17821
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
17818
17822
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
17819
17823
  let parsed;
17820
17824
  try {
@@ -18944,17 +18948,22 @@ async function extractEntitiesForMemories(memories, options) {
18944
18948
  const out = /* @__PURE__ */ new Map();
18945
18949
  if (memories.length === 0) return out;
18946
18950
  const redactor = resolvePiiRedactor(options.piiRedaction);
18947
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
18951
+ const vocabulary = [];
18952
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
18953
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
18954
+ }
18948
18955
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
18949
18956
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
18950
18957
 
18951
18958
  ` : "";
18952
18959
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
18953
18960
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
18954
- const listing = batch.map((m) => {
18961
+ const rows = [];
18962
+ for (const m of batch) {
18955
18963
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
18956
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
18957
- }).join("\n");
18964
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
18965
+ }
18966
+ const listing = rows.join("\n");
18958
18967
  const parsed = await callPortalJsonCompletion({
18959
18968
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
18960
18969
  ...options.getToken !== void 0 && { getToken: options.getToken },
@@ -7010,10 +7010,12 @@ async function classifyInjectionCandidates(candidates, options) {
7010
7010
  );
7011
7011
  }
7012
7012
  const redactor = resolvePiiRedactor(options.piiRedaction);
7013
- const numbered = scope.map((c, i) => {
7014
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
7015
- return `[${i + 1}] ${safe}`;
7016
- }).join("\n");
7013
+ const lines = [];
7014
+ for (const [i, c] of scope.entries()) {
7015
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
7016
+ lines.push(`[${i + 1}] ${safe}`);
7017
+ }
7018
+ const numbered = lines.join("\n");
7017
7019
  let parsed;
7018
7020
  try {
7019
7021
  parsed = await callPortalJsonCompletion({
@@ -7494,7 +7496,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
7494
7496
  content: m.content,
7495
7497
  similarity: m.similarity
7496
7498
  }));
7497
- const { consolidateMemory: doConsolidate } = await import("./consolidate-IFIKT25Z.mjs");
7499
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-POPTUI54.mjs");
7498
7500
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
7499
7501
  if (decision.action === "create") return null;
7500
7502
  if (decision.action === "supersede" && decision.content) {
@@ -8318,7 +8320,7 @@ function createLlmDecayClassifier(options) {
8318
8320
  }
8319
8321
  if (!content || content.trim().length === 0) return ruleVerdict;
8320
8322
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
8321
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
8323
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
8322
8324
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
8323
8325
  let parsed;
8324
8326
  try {
@@ -9415,17 +9417,22 @@ async function extractEntitiesForMemories(memories, options) {
9415
9417
  const out = /* @__PURE__ */ new Map();
9416
9418
  if (memories.length === 0) return out;
9417
9419
  const redactor = resolvePiiRedactor(options.piiRedaction);
9418
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
9420
+ const vocabulary = [];
9421
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
9422
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
9423
+ }
9419
9424
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
9420
9425
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
9421
9426
 
9422
9427
  ` : "";
9423
9428
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
9424
9429
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
9425
- const listing = batch.map((m) => {
9430
+ const rows = [];
9431
+ for (const m of batch) {
9426
9432
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
9427
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
9428
- }).join("\n");
9433
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
9434
+ }
9435
+ const listing = rows.join("\n");
9429
9436
  const parsed = await callPortalJsonCompletion({
9430
9437
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
9431
9438
  ...options.getToken !== void 0 && { getToken: options.getToken },
@@ -55,12 +55,14 @@ async function consolidateMemory(newContent, candidates, options) {
55
55
  if (trimmed.length === 0) return fallback;
56
56
  if (candidates.length === 0) return fallback;
57
57
  const redactor = resolvePiiRedactor(options.piiRedaction);
58
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
59
- const candidateText = candidates.map((c, i) => {
60
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
61
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
62
- ${safeContent}`;
63
- }).join("\n");
58
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
59
+ const rows = [];
60
+ for (const [i, c] of candidates.entries()) {
61
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
62
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
63
+ ${safeContent}`);
64
+ }
65
+ const candidateText = rows.join("\n");
64
66
  const userMessage = `New memory:
65
67
  ${safeTrimmed}
66
68
 
@@ -23580,12 +23580,14 @@ async function consolidateMemory(newContent, candidates, options) {
23580
23580
  if (trimmed.length === 0) return fallback;
23581
23581
  if (candidates.length === 0) return fallback;
23582
23582
  const redactor = resolvePiiRedactor(options.piiRedaction);
23583
- const safeTrimmed = redactor ? redactor.redactText(trimmed).text : trimmed;
23584
- const candidateText = candidates.map((c, i) => {
23585
- const safeContent = redactor ? redactor.redactText(c.content).text : c.content;
23586
- return `[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
23587
- ${safeContent}`;
23588
- }).join("\n");
23583
+ const safeTrimmed = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
23584
+ const rows = [];
23585
+ for (const [i, c] of candidates.entries()) {
23586
+ const safeContent = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
23587
+ rows.push(`[${i + 1}] (id: ${c.id}, sim: ${c.similarity.toFixed(2)})
23588
+ ${safeContent}`);
23589
+ }
23590
+ const candidateText = rows.join("\n");
23589
23591
  const userMessage = `New memory:
23590
23592
  ${safeTrimmed}
23591
23593
 
@@ -28260,10 +28262,12 @@ async function classifyInjectionCandidates(candidates, options) {
28260
28262
  );
28261
28263
  }
28262
28264
  const redactor = resolvePiiRedactor(options.piiRedaction);
28263
- const numbered = scope.map((c, i) => {
28264
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
28265
- return `[${i + 1}] ${safe}`;
28266
- }).join("\n");
28265
+ const lines = [];
28266
+ for (const [i, c] of scope.entries()) {
28267
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
28268
+ lines.push(`[${i + 1}] ${safe}`);
28269
+ }
28270
+ const numbered = lines.join("\n");
28267
28271
  let parsed;
28268
28272
  try {
28269
28273
  parsed = await callPortalJsonCompletion({
@@ -29585,7 +29589,7 @@ function createLlmDecayClassifier(options) {
29585
29589
  }
29586
29590
  if (!content || content.trim().length === 0) return ruleVerdict;
29587
29591
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
29588
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
29592
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
29589
29593
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
29590
29594
  let parsed;
29591
29595
  try {
@@ -30715,17 +30719,22 @@ async function extractEntitiesForMemories(memories, options) {
30715
30719
  const out = /* @__PURE__ */ new Map();
30716
30720
  if (memories.length === 0) return out;
30717
30721
  const redactor = resolvePiiRedactor(options.piiRedaction);
30718
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
30722
+ const vocabulary = [];
30723
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
30724
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
30725
+ }
30719
30726
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
30720
30727
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
30721
30728
 
30722
30729
  ` : "";
30723
30730
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
30724
30731
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
30725
- const listing = batch.map((m) => {
30732
+ const rows = [];
30733
+ for (const m of batch) {
30726
30734
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
30727
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
30728
- }).join("\n");
30735
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
30736
+ }
30737
+ const listing = rows.join("\n");
30729
30738
  const parsed = await callPortalJsonCompletion({
30730
30739
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
30731
30740
  ...options.getToken !== void 0 && { getToken: options.getToken },
@@ -5017,10 +5017,12 @@ async function classifyInjectionCandidates(candidates, options) {
5017
5017
  );
5018
5018
  }
5019
5019
  const redactor = resolvePiiRedactor(options.piiRedaction);
5020
- const numbered = scope.map((c, i) => {
5021
- const safe = redactor ? redactor.redactText(c.content).text : c.content;
5022
- return `[${i + 1}] ${safe}`;
5023
- }).join("\n");
5020
+ const lines = [];
5021
+ for (const [i, c] of scope.entries()) {
5022
+ const safe = redactor ? (await redactor.redactTextAsync(c.content)).text : c.content;
5023
+ lines.push(`[${i + 1}] ${safe}`);
5024
+ }
5025
+ const numbered = lines.join("\n");
5024
5026
  let parsed;
5025
5027
  try {
5026
5028
  parsed = await callPortalJsonCompletion({
@@ -5501,7 +5503,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
5501
5503
  content: m.content,
5502
5504
  similarity: m.similarity
5503
5505
  }));
5504
- const { consolidateMemory: doConsolidate } = await import("./consolidate-GRMEDWKK.mjs");
5506
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-LMIDJFR6.mjs");
5505
5507
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
5506
5508
  if (decision.action === "create") return null;
5507
5509
  if (decision.action === "supersede" && decision.content) {
@@ -6325,7 +6327,7 @@ function createLlmDecayClassifier(options) {
6325
6327
  }
6326
6328
  if (!content || content.trim().length === 0) return ruleVerdict;
6327
6329
  const trimmed = content.trim().slice(0, MAX_CONTENT_CHARS);
6328
- const safe = redactor ? redactor.redactText(trimmed).text : trimmed;
6330
+ const safe = redactor ? (await redactor.redactTextAsync(trimmed)).text : trimmed;
6329
6331
  const meta = `factType: ${input.factType ?? "none"}; ageDays: ${ageDays(input.updatedAt, now)}`;
6330
6332
  let parsed;
6331
6333
  try {
@@ -7422,17 +7424,22 @@ async function extractEntitiesForMemories(memories, options) {
7422
7424
  const out = /* @__PURE__ */ new Map();
7423
7425
  if (memories.length === 0) return out;
7424
7426
  const redactor = resolvePiiRedactor(options.piiRedaction);
7425
- const vocabulary = (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES).map((n) => redactor ? redactor.redactText(n).text : n);
7427
+ const vocabulary = [];
7428
+ for (const name of (options.existingEntityNames ?? []).filter((n) => n.trim().length > 0).slice(0, MAX_VOCABULARY_NAMES)) {
7429
+ vocabulary.push(redactor ? (await redactor.redactTextAsync(name)).text : name);
7430
+ }
7426
7431
  const vocabularyNote = vocabulary.length > 0 ? `The user's existing topics: ${vocabulary.join(", ")}.
7427
7432
  When a memory refers to one of these, reuse the EXACT existing name (same spelling, casing, spacing and punctuation) instead of a variant \u2014 if "Foo.ai" is listed, never emit "Foo ai" or "Foo AI", and if "Jane Roe" is listed, emit that rather than a bare "Jane".
7428
7433
 
7429
7434
  ` : "";
7430
7435
  for (let i = 0; i < memories.length; i += TOPIC_EXTRACTION_BATCH_SIZE) {
7431
7436
  const batch = memories.slice(i, i + TOPIC_EXTRACTION_BATCH_SIZE);
7432
- const listing = batch.map((m) => {
7437
+ const rows = [];
7438
+ for (const m of batch) {
7433
7439
  const content = m.content.slice(0, MAX_CHARS_PER_MEMORY).replace(/\s+/g, " ").trim();
7434
- return `${m.id}: ${redactor ? redactor.redactText(content).text : content}`;
7435
- }).join("\n");
7440
+ rows.push(`${m.id}: ${redactor ? (await redactor.redactTextAsync(content)).text : content}`);
7441
+ }
7442
+ const listing = rows.join("\n");
7436
7443
  const parsed = await callPortalJsonCompletion({
7437
7444
  ...options.apiKey !== void 0 && { apiKey: options.apiKey },
7438
7445
  ...options.getToken !== void 0 && { getToken: options.getToken },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -136,8 +136,9 @@
136
136
  "lint:fix": "eslint . --fix",
137
137
  "format": "prettier --write .",
138
138
  "format:check": "prettier --check .",
139
- "typecheck": "tsc --noEmit && pnpm run typecheck:test",
139
+ "typecheck": "tsc --noEmit && pnpm run typecheck:test && pnpm run check:excluded-suites",
140
140
  "typecheck:test": "tsc -p tsconfig.test.json",
141
+ "check:excluded-suites": "node scripts/assert-excluded-suites-still-fail.mjs",
141
142
  "knip": "knip",
142
143
  "check:export-consumers": "node scripts/assert-export-consumers.mjs",
143
144
  "check-exports": "publint && attw --pack --ignore-rules no-resolution false-cjs && node scripts/assert-no-client-self-import.mjs",