@anuma/sdk 6.8.2 → 6.10.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.
@@ -141,7 +141,7 @@ import {
141
141
  updateVaultMemoryOp,
142
142
  upsertMessageOp,
143
143
  vaultMemoryToStored
144
- } from "./chunk-IP6PGI7H.mjs";
144
+ } from "./chunk-I56324FR.mjs";
145
145
  import {
146
146
  createStreamingDeAnonymizer,
147
147
  notifyConsolidationFallback,
@@ -6371,7 +6371,7 @@ function createAutoExtractor(options) {
6371
6371
  const t0 = Date.now();
6372
6372
  void (async () => {
6373
6373
  try {
6374
- const { candidates, results, failedCount, outcome } = await extractAndRetain(
6374
+ const { candidates, results, failedCount, outcome, failure } = await extractAndRetain(
6375
6375
  window2,
6376
6376
  retainCtx,
6377
6377
  {
@@ -6411,7 +6411,11 @@ function createAutoExtractor(options) {
6411
6411
  failedCount,
6412
6412
  durationMs: Date.now() - t0,
6413
6413
  conversationId,
6414
- outcome
6414
+ outcome,
6415
+ // Only set alongside `outcome: "empty-after-retry"`. Spread so the key
6416
+ // is absent rather than explicitly undefined on a healthy turn —
6417
+ // analytics backends store an explicit undefined as a real value.
6418
+ ...failure !== void 0 && { failure }
6415
6419
  });
6416
6420
  } catch (err) {
6417
6421
  options.onError?.(err instanceof Error ? err : new Error(String(err)), conversationId);
@@ -7675,6 +7679,18 @@ function parseTopicResponse(parsed, validIds) {
7675
7679
  }
7676
7680
  return out;
7677
7681
  }
7682
+ var DEGRADED_TOPIC_SKIP = {
7683
+ excluded: false,
7684
+ "link-declined": false,
7685
+ "stamp-declined": false,
7686
+ "llm-unanswered": true,
7687
+ unreadable: true,
7688
+ "not-found": true,
7689
+ "link-failed": true
7690
+ };
7691
+ function isDegradedTopicSkip(reason) {
7692
+ return DEGRADED_TOPIC_SKIP[reason] === true;
7693
+ }
7678
7694
  async function extractAndLinkEntitiesForMemoriesOp(ctx, memoryIds, options) {
7679
7695
  const entityCtx = ctx.entityCtx;
7680
7696
  if (!entityCtx) {
@@ -7683,17 +7699,24 @@ async function extractAndLinkEntitiesForMemoriesOp(ctx, memoryIds, options) {
7683
7699
  const log = getLogger();
7684
7700
  const extractedAt = options.now ?? Date.now();
7685
7701
  const skippedIds = [];
7702
+ const skippedReasons = /* @__PURE__ */ new Map();
7703
+ const skip = (id, reason) => {
7704
+ if (skippedReasons.has(id)) return;
7705
+ skippedIds.push(id);
7706
+ skippedReasons.set(id, reason);
7707
+ };
7686
7708
  const inputs = [];
7687
- for (const id of memoryIds) {
7709
+ for (const id of new Set(memoryIds)) {
7688
7710
  let record;
7689
7711
  try {
7690
7712
  record = await ctx.vaultMemoryCollection.find(id);
7691
- } catch {
7692
- skippedIds.push(id);
7713
+ } catch (err) {
7714
+ log.warn("[memory/topics] vault lookup failed for extraction", err);
7715
+ skip(id, "not-found");
7693
7716
  continue;
7694
7717
  }
7695
7718
  if (record.isDeleted || ctx.userId !== void 0 && record.userId !== ctx.userId || record.topicsUserManaged) {
7696
- skippedIds.push(id);
7719
+ skip(id, "excluded");
7697
7720
  continue;
7698
7721
  }
7699
7722
  try {
@@ -7706,7 +7729,7 @@ async function extractAndLinkEntitiesForMemoriesOp(ctx, memoryIds, options) {
7706
7729
  inputs.push({ id, content: stored.content });
7707
7730
  } catch (err) {
7708
7731
  log.warn("[memory/topics] failed to load memory for extraction", err);
7709
- skippedIds.push(id);
7732
+ skip(id, "unreadable");
7710
7733
  }
7711
7734
  }
7712
7735
  const entitiesByMemory = await extractEntitiesForMemories(inputs, options);
@@ -7714,19 +7737,19 @@ async function extractAndLinkEntitiesForMemoriesOp(ctx, memoryIds, options) {
7714
7737
  for (const input of inputs) {
7715
7738
  const entities = entitiesByMemory.get(input.id);
7716
7739
  if (entities === void 0) {
7717
- skippedIds.push(input.id);
7740
+ skip(input.id, "llm-unanswered");
7718
7741
  continue;
7719
7742
  }
7720
7743
  try {
7721
7744
  const linked = await replaceMemoryEntitiesGuardedOp(entityCtx, input.id, entities);
7722
7745
  if (linked === null) {
7723
- skippedIds.push(input.id);
7746
+ skip(input.id, "link-declined");
7724
7747
  entitiesByMemory.delete(input.id);
7725
7748
  continue;
7726
7749
  }
7727
7750
  } catch (err) {
7728
7751
  log.warn("[memory/topics] replaceMemoryEntitiesGuardedOp failed", err);
7729
- skippedIds.push(input.id);
7752
+ skip(input.id, "link-failed");
7730
7753
  entitiesByMemory.delete(input.id);
7731
7754
  continue;
7732
7755
  }
@@ -7736,11 +7759,11 @@ async function extractAndLinkEntitiesForMemoriesOp(ctx, memoryIds, options) {
7736
7759
  const stampedSet = new Set(stampedIds);
7737
7760
  for (const id of toStamp) {
7738
7761
  if (!stampedSet.has(id)) {
7739
- skippedIds.push(id);
7762
+ skip(id, "stamp-declined");
7740
7763
  entitiesByMemory.delete(id);
7741
7764
  }
7742
7765
  }
7743
- return { entitiesByMemory, stampedIds, skippedIds };
7766
+ return { entitiesByMemory, stampedIds, skippedIds, skippedReasons };
7744
7767
  }
7745
7768
 
7746
7769
  // src/lib/memory/verifySupport.ts
@@ -13757,6 +13780,7 @@ export {
13757
13780
  hasKeyPair,
13758
13781
  ingestPublishedPhotoMemoriesOp,
13759
13782
  injectionSignatureCatalog,
13783
+ isDegradedTopicSkip,
13760
13784
  isRerankerAvailable,
13761
13785
  isSupportedFile,
13762
13786
  isSupportedMediaType,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-IP6PGI7H.mjs";
3
+ } from "./chunk-I56324FR.mjs";
4
4
  import "./chunk-KF5OU4IN.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "6.8.2",
3
+ "version": "6.10.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",