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