claude-memory-layer 1.0.20 → 1.0.21

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.
@@ -2636,13 +2636,15 @@ var VectorStore = class {
2636
2636
  };
2637
2637
 
2638
2638
  // src/core/embedder.ts
2639
- import { pipeline } from "@xenova/transformers";
2639
+ import { pipeline } from "@huggingface/transformers";
2640
2640
  var Embedder = class {
2641
2641
  pipeline = null;
2642
2642
  modelName;
2643
+ activeModelName;
2643
2644
  initialized = false;
2644
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano") {
2645
+ constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
2645
2646
  this.modelName = modelName;
2647
+ this.activeModelName = modelName;
2646
2648
  }
2647
2649
  /**
2648
2650
  * Initialize the embedding pipeline
@@ -2650,8 +2652,21 @@ var Embedder = class {
2650
2652
  async initialize() {
2651
2653
  if (this.initialized)
2652
2654
  return;
2653
- this.pipeline = await pipeline("feature-extraction", this.modelName);
2654
- this.initialized = true;
2655
+ try {
2656
+ this.pipeline = await pipeline("feature-extraction", this.modelName);
2657
+ this.activeModelName = this.modelName;
2658
+ this.initialized = true;
2659
+ return;
2660
+ } catch (primaryError) {
2661
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
2662
+ if (fallbackModel === this.modelName) {
2663
+ throw primaryError;
2664
+ }
2665
+ console.warn(`[Embedder] Primary model failed (${this.modelName}). Falling back to ${fallbackModel}`);
2666
+ this.pipeline = await pipeline("feature-extraction", fallbackModel);
2667
+ this.activeModelName = fallbackModel;
2668
+ this.initialized = true;
2669
+ }
2655
2670
  }
2656
2671
  /**
2657
2672
  * Generate embedding for a single text
@@ -2668,7 +2683,7 @@ var Embedder = class {
2668
2683
  const vector = Array.from(output.data);
2669
2684
  return {
2670
2685
  vector,
2671
- model: this.modelName,
2686
+ model: this.activeModelName,
2672
2687
  dimensions: vector.length
2673
2688
  };
2674
2689
  }
@@ -2692,7 +2707,7 @@ var Embedder = class {
2692
2707
  const vector = Array.from(output.data);
2693
2708
  results.push({
2694
2709
  vector,
2695
- model: this.modelName,
2710
+ model: this.activeModelName,
2696
2711
  dimensions: vector.length
2697
2712
  });
2698
2713
  }
@@ -2716,7 +2731,7 @@ var Embedder = class {
2716
2731
  * Get model name
2717
2732
  */
2718
2733
  getModelName() {
2719
- return this.modelName;
2734
+ return this.activeModelName;
2720
2735
  }
2721
2736
  };
2722
2737
  var defaultEmbedder = null;