@anuma/sdk 3.11.2 → 3.11.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.
@@ -5232,7 +5232,20 @@ type RecallDegradation =
5232
5232
  "rerank-unavailable"
5233
5233
  /** `budget: 'high'` requested but no `decomposeOptions`, so query
5234
5234
  * decomposition was skipped and the budget downgraded to mid. */
5235
- | "decompose-unavailable";
5235
+ | "decompose-unavailable"
5236
+ /** There was no usable cosine lane, so results were ranked on BM25 (lexical)
5237
+ * alone: either the query embedding failed (or came back empty), or no
5238
+ * candidate had a vector to score against it because the row (re)embed failed.
5239
+ * Also set when the chunk lane — cosine-only, with no lexical equivalent — was
5240
+ * skipped for the same reason. The embeddings provider is a single upstream
5241
+ * with no fallback, so this is a whole-provider outage rather than a per-item
5242
+ * miss — expect a quality drop, not a total loss.
5243
+ *
5244
+ * NOT set for a partial failure that leaves cosine running (a sub-query embed
5245
+ * failing back to the single-query path, or a row batch failing while other
5246
+ * rows keep usable vectors) — those are logged, not reported, so this stays a
5247
+ * reliable outage signal rather than a general embedding-error counter. */
5248
+ | "embeddings-unavailable";
5236
5249
  /**
5237
5250
  * Per-call recall observability payload (see {@link RecallOptions.onDiagnostics}).
5238
5251
  * All timings are wall-clock milliseconds. Lane counts are post-dedupe,
@@ -5232,7 +5232,20 @@ type RecallDegradation =
5232
5232
  "rerank-unavailable"
5233
5233
  /** `budget: 'high'` requested but no `decomposeOptions`, so query
5234
5234
  * decomposition was skipped and the budget downgraded to mid. */
5235
- | "decompose-unavailable";
5235
+ | "decompose-unavailable"
5236
+ /** There was no usable cosine lane, so results were ranked on BM25 (lexical)
5237
+ * alone: either the query embedding failed (or came back empty), or no
5238
+ * candidate had a vector to score against it because the row (re)embed failed.
5239
+ * Also set when the chunk lane — cosine-only, with no lexical equivalent — was
5240
+ * skipped for the same reason. The embeddings provider is a single upstream
5241
+ * with no fallback, so this is a whole-provider outage rather than a per-item
5242
+ * miss — expect a quality drop, not a total loss.
5243
+ *
5244
+ * NOT set for a partial failure that leaves cosine running (a sub-query embed
5245
+ * failing back to the single-query path, or a row batch failing while other
5246
+ * rows keep usable vectors) — those are logged, not reported, so this stays a
5247
+ * reliable outage signal rather than a general embedding-error counter. */
5248
+ | "embeddings-unavailable";
5236
5249
  /**
5237
5250
  * Per-call recall observability payload (see {@link RecallOptions.onDiagnostics}).
5238
5251
  * All timings are wall-clock milliseconds. Lane counts are post-dedupe,
@@ -5,11 +5,14 @@ import {
5
5
  DEFAULT_MIN_CHUNK_SIZE,
6
6
  DEFAULT_MIN_CONTENT_LENGTH,
7
7
  DEFAULT_VAULT_CACHE_SIZE,
8
+ EMBEDDINGS_DEGRADED_EMPTY,
8
9
  ENTITY_FANOUT,
9
10
  ENTITY_KINDS,
10
11
  LRUCache,
11
12
  MAX_HOPS,
12
13
  NODE_BUDGET,
14
+ RECALL_MAX_LIMIT,
15
+ RECALL_TOOL_NAME,
13
16
  RerankerUnavailableError,
14
17
  TOPICS_EXTRACTION_VERSION,
15
18
  TREND_RECENT_WINDOW_DAYS,
@@ -111,7 +114,7 @@ import {
111
114
  upsertMessageOp,
112
115
  useEncryption,
113
116
  vaultMemoryToStored
114
- } from "./chunk-7CTI3XR6.mjs";
117
+ } from "./chunk-7AW2VD5W.mjs";
115
118
  import {
116
119
  PII_PATTERNS,
117
120
  PiiRedactor,
@@ -6424,6 +6427,11 @@ async function retain(content, ctx, options = {}) {
6424
6427
  ...options.folderId !== void 0 && { folderId: options.folderId }
6425
6428
  }
6426
6429
  );
6430
+ if (prepared.embeddingFailure || prepared.embeddingsUnavailable) {
6431
+ throw new Error(
6432
+ "retain: embeddings unavailable \u2014 refusing to auto-merge against an inert cosine lane, which would create a duplicate instead of merging into the existing memory. Retry when embeddings recover, or pass enableAutoMerge: false to force a create."
6433
+ );
6434
+ }
6427
6435
  if (options.consolidateOptions) {
6428
6436
  const outcome = await tryConsolidate(trimmed, ctx, options, prepared);
6429
6437
  if (outcome) {
@@ -7656,10 +7664,6 @@ function rankProfileCandidates(inputs, now = Date.now(), options = {}) {
7656
7664
  return ranked;
7657
7665
  }
7658
7666
 
7659
- // src/lib/memory/recallConstants.ts
7660
- var RECALL_TOOL_NAME = "recall_memory";
7661
- var RECALL_MAX_LIMIT = 50;
7662
-
7663
7667
  // src/lib/memory/recallTool.ts
7664
7668
  var DEFAULT_LIMIT = 8;
7665
7669
  var DEFAULT_BUDGET = "low";
@@ -7810,7 +7814,11 @@ function createRecallTool(ctx, toolOptions, callbacks) {
7810
7814
  conversationMemories += effectiveLimit;
7811
7815
  let surfaced = 0;
7812
7816
  try {
7817
+ let recallDegraded = [];
7813
7818
  const recallOpts = {
7819
+ onDiagnostics: (d) => {
7820
+ recallDegraded = d.degraded;
7821
+ },
7814
7822
  types: defaultTypes,
7815
7823
  limit: effectiveLimit,
7816
7824
  budget: defaultBudget,
@@ -7842,6 +7850,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
7842
7850
  }
7843
7851
  }
7844
7852
  surfaced = result.memories.length;
7853
+ if (result.memories.length === 0 && recallDegraded.includes("embeddings-unavailable")) {
7854
+ return EMBEDDINGS_DEGRADED_EMPTY;
7855
+ }
7845
7856
  const formatted = formatRecallResult(result.memories);
7846
7857
  return truncatedByBudget && surfaced > 0 ? `${formatted}
7847
7858
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-7CTI3XR6.mjs";
3
+ } from "./chunk-7AW2VD5W.mjs";
4
4
  import "./chunk-ILAWDQDE.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {