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.
@@ -2626,13 +2626,15 @@ var VectorStore = class {
2626
2626
  };
2627
2627
 
2628
2628
  // src/core/embedder.ts
2629
- import { pipeline } from "@xenova/transformers";
2629
+ import { pipeline } from "@huggingface/transformers";
2630
2630
  var Embedder = class {
2631
2631
  pipeline = null;
2632
2632
  modelName;
2633
+ activeModelName;
2633
2634
  initialized = false;
2634
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano") {
2635
+ constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
2635
2636
  this.modelName = modelName;
2637
+ this.activeModelName = modelName;
2636
2638
  }
2637
2639
  /**
2638
2640
  * Initialize the embedding pipeline
@@ -2640,8 +2642,21 @@ var Embedder = class {
2640
2642
  async initialize() {
2641
2643
  if (this.initialized)
2642
2644
  return;
2643
- this.pipeline = await pipeline("feature-extraction", this.modelName);
2644
- this.initialized = true;
2645
+ try {
2646
+ this.pipeline = await pipeline("feature-extraction", this.modelName);
2647
+ this.activeModelName = this.modelName;
2648
+ this.initialized = true;
2649
+ return;
2650
+ } catch (primaryError) {
2651
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
2652
+ if (fallbackModel === this.modelName) {
2653
+ throw primaryError;
2654
+ }
2655
+ console.warn(`[Embedder] Primary model failed (${this.modelName}). Falling back to ${fallbackModel}`);
2656
+ this.pipeline = await pipeline("feature-extraction", fallbackModel);
2657
+ this.activeModelName = fallbackModel;
2658
+ this.initialized = true;
2659
+ }
2645
2660
  }
2646
2661
  /**
2647
2662
  * Generate embedding for a single text
@@ -2658,7 +2673,7 @@ var Embedder = class {
2658
2673
  const vector = Array.from(output.data);
2659
2674
  return {
2660
2675
  vector,
2661
- model: this.modelName,
2676
+ model: this.activeModelName,
2662
2677
  dimensions: vector.length
2663
2678
  };
2664
2679
  }
@@ -2682,7 +2697,7 @@ var Embedder = class {
2682
2697
  const vector = Array.from(output.data);
2683
2698
  results.push({
2684
2699
  vector,
2685
- model: this.modelName,
2700
+ model: this.activeModelName,
2686
2701
  dimensions: vector.length
2687
2702
  });
2688
2703
  }
@@ -2706,7 +2721,7 @@ var Embedder = class {
2706
2721
  * Get model name
2707
2722
  */
2708
2723
  getModelName() {
2709
- return this.modelName;
2724
+ return this.activeModelName;
2710
2725
  }
2711
2726
  };
2712
2727
  var defaultEmbedder = null;