claude-memory-layer 1.0.20 → 1.0.22

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.
@@ -2645,13 +2645,15 @@ var VectorStore = class {
2645
2645
  };
2646
2646
 
2647
2647
  // src/core/embedder.ts
2648
- import { pipeline } from "@xenova/transformers";
2648
+ import { pipeline } from "@huggingface/transformers";
2649
2649
  var Embedder = class {
2650
2650
  pipeline = null;
2651
2651
  modelName;
2652
+ activeModelName;
2652
2653
  initialized = false;
2653
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano") {
2654
+ constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
2654
2655
  this.modelName = modelName;
2656
+ this.activeModelName = modelName;
2655
2657
  }
2656
2658
  /**
2657
2659
  * Initialize the embedding pipeline
@@ -2659,8 +2661,21 @@ var Embedder = class {
2659
2661
  async initialize() {
2660
2662
  if (this.initialized)
2661
2663
  return;
2662
- this.pipeline = await pipeline("feature-extraction", this.modelName);
2663
- this.initialized = true;
2664
+ try {
2665
+ this.pipeline = await pipeline("feature-extraction", this.modelName);
2666
+ this.activeModelName = this.modelName;
2667
+ this.initialized = true;
2668
+ return;
2669
+ } catch (primaryError) {
2670
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
2671
+ if (fallbackModel === this.modelName) {
2672
+ throw primaryError;
2673
+ }
2674
+ console.warn(`[Embedder] Primary model failed (${this.modelName}). Falling back to ${fallbackModel}`);
2675
+ this.pipeline = await pipeline("feature-extraction", fallbackModel);
2676
+ this.activeModelName = fallbackModel;
2677
+ this.initialized = true;
2678
+ }
2664
2679
  }
2665
2680
  /**
2666
2681
  * Generate embedding for a single text
@@ -2677,7 +2692,7 @@ var Embedder = class {
2677
2692
  const vector = Array.from(output.data);
2678
2693
  return {
2679
2694
  vector,
2680
- model: this.modelName,
2695
+ model: this.activeModelName,
2681
2696
  dimensions: vector.length
2682
2697
  };
2683
2698
  }
@@ -2701,7 +2716,7 @@ var Embedder = class {
2701
2716
  const vector = Array.from(output.data);
2702
2717
  results.push({
2703
2718
  vector,
2704
- model: this.modelName,
2719
+ model: this.activeModelName,
2705
2720
  dimensions: vector.length
2706
2721
  });
2707
2722
  }
@@ -2725,7 +2740,7 @@ var Embedder = class {
2725
2740
  * Get model name
2726
2741
  */
2727
2742
  getModelName() {
2728
- return this.modelName;
2743
+ return this.activeModelName;
2729
2744
  }
2730
2745
  };
2731
2746
  var defaultEmbedder = null;