@anuma/sdk 3.11.2 → 3.11.3

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.
@@ -5164,7 +5164,20 @@ type RecallDegradation =
5164
5164
  "rerank-unavailable"
5165
5165
  /** `budget: 'high'` requested but no `decomposeOptions`, so query
5166
5166
  * decomposition was skipped and the budget downgraded to mid. */
5167
- | "decompose-unavailable";
5167
+ | "decompose-unavailable"
5168
+ /** There was no usable cosine lane, so results were ranked on BM25 (lexical)
5169
+ * alone: either the query embedding failed (or came back empty), or no
5170
+ * candidate had a vector to score against it because the row (re)embed failed.
5171
+ * Also set when the chunk lane — cosine-only, with no lexical equivalent — was
5172
+ * skipped for the same reason. The embeddings provider is a single upstream
5173
+ * with no fallback, so this is a whole-provider outage rather than a per-item
5174
+ * miss — expect a quality drop, not a total loss.
5175
+ *
5176
+ * NOT set for a partial failure that leaves cosine running (a sub-query embed
5177
+ * failing back to the single-query path, or a row batch failing while other
5178
+ * rows keep usable vectors) — those are logged, not reported, so this stays a
5179
+ * reliable outage signal rather than a general embedding-error counter. */
5180
+ | "embeddings-unavailable";
5168
5181
  /**
5169
5182
  * Per-call recall observability payload (see {@link RecallOptions.onDiagnostics}).
5170
5183
  * All timings are wall-clock milliseconds. Lane counts are post-dedupe,
@@ -4,11 +4,14 @@ import {
4
4
  DEFAULT_CHUNK_SIZE,
5
5
  DEFAULT_MIN_CHUNK_SIZE,
6
6
  DEFAULT_VAULT_CACHE_SIZE,
7
+ EMBEDDINGS_DEGRADED_EMPTY,
7
8
  ENTITY_FANOUT,
8
9
  ENTITY_KINDS,
9
10
  LRUCache,
10
11
  MAX_HOPS,
11
12
  NODE_BUDGET,
13
+ RECALL_MAX_LIMIT,
14
+ RECALL_TOOL_NAME,
12
15
  RerankerUnavailableError,
13
16
  TOPICS_EXTRACTION_VERSION,
14
17
  TREND_RECENT_WINDOW_DAYS,
@@ -128,7 +131,7 @@ import {
128
131
  updateVaultMemoryOp,
129
132
  upsertMessageOp,
130
133
  vaultMemoryToStored
131
- } from "./chunk-NCKDSZPQ.mjs";
134
+ } from "./chunk-FZZCEZL2.mjs";
132
135
  import {
133
136
  createStreamingDeAnonymizer,
134
137
  resolvePiiRedactor
@@ -5334,6 +5337,11 @@ async function retain(content, ctx, options = {}) {
5334
5337
  ...options.folderId !== void 0 && { folderId: options.folderId }
5335
5338
  }
5336
5339
  );
5340
+ if (prepared.embeddingFailure || prepared.embeddingsUnavailable) {
5341
+ throw new Error(
5342
+ "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."
5343
+ );
5344
+ }
5337
5345
  if (options.consolidateOptions) {
5338
5346
  const outcome = await tryConsolidate(trimmed, ctx, options, prepared);
5339
5347
  if (outcome) {
@@ -6566,10 +6574,6 @@ function rankProfileCandidates(inputs, now = Date.now(), options = {}) {
6566
6574
  return ranked;
6567
6575
  }
6568
6576
 
6569
- // src/lib/memory/recallConstants.ts
6570
- var RECALL_TOOL_NAME = "recall_memory";
6571
- var RECALL_MAX_LIMIT = 50;
6572
-
6573
6577
  // src/lib/memory/recallTool.ts
6574
6578
  var DEFAULT_LIMIT = 8;
6575
6579
  var DEFAULT_BUDGET = "low";
@@ -6720,7 +6724,11 @@ function createRecallTool(ctx, toolOptions, callbacks) {
6720
6724
  conversationMemories += effectiveLimit;
6721
6725
  let surfaced = 0;
6722
6726
  try {
6727
+ let recallDegraded = [];
6723
6728
  const recallOpts = {
6729
+ onDiagnostics: (d) => {
6730
+ recallDegraded = d.degraded;
6731
+ },
6724
6732
  types: defaultTypes,
6725
6733
  limit: effectiveLimit,
6726
6734
  budget: defaultBudget,
@@ -6752,6 +6760,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
6752
6760
  }
6753
6761
  }
6754
6762
  surfaced = result.memories.length;
6763
+ if (result.memories.length === 0 && recallDegraded.includes("embeddings-unavailable")) {
6764
+ return EMBEDDINGS_DEGRADED_EMPTY;
6765
+ }
6755
6766
  const formatted = formatRecallResult(result.memories);
6756
6767
  return truncatedByBudget && surfaced > 0 ? `${formatted}
6757
6768
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-NCKDSZPQ.mjs";
3
+ } from "./chunk-FZZCEZL2.mjs";
4
4
  import "./chunk-OBDRKQQI.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": "3.11.2",
3
+ "version": "3.11.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",