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