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