claude-memory-layer 1.0.29 → 1.0.31

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.
@@ -1645,12 +1645,14 @@ import * as fs5 from "fs";
1645
1645
  import * as path4 from "path";
1646
1646
 
1647
1647
  // src/extensions/vector/embedder.ts
1648
+ var DEFAULT_EMBEDDING_MODEL = "Xenova/multilingual-e5-small";
1649
+ var DEFAULT_EMBEDDING_FALLBACK_MODEL = "intfloat/multilingual-e5-small";
1648
1650
  var Embedder = class _Embedder {
1649
1651
  pipeline = null;
1650
1652
  modelName;
1651
1653
  activeModelName;
1652
1654
  initialized = false;
1653
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
1655
+ constructor(modelName = DEFAULT_EMBEDDING_MODEL) {
1654
1656
  this.modelName = modelName;
1655
1657
  this.activeModelName = modelName;
1656
1658
  }
@@ -1660,14 +1662,23 @@ var Embedder = class _Embedder {
1660
1662
  async initialize() {
1661
1663
  if (this.initialized)
1662
1664
  return;
1663
- const pipeline = await withSuppressedKnownTransformersWarnings(() => loadTransformersPipeline());
1665
+ const pipeline = await withSuppressedKnownTransformersWarnings(async () => {
1666
+ try {
1667
+ return await loadTransformersPipeline();
1668
+ } catch (error) {
1669
+ if (isMissingTransformersDependencyError(error)) {
1670
+ throw createEmbeddingBackendUnavailableError(error);
1671
+ }
1672
+ throw error;
1673
+ }
1674
+ });
1664
1675
  try {
1665
1676
  this.pipeline = await withSuppressedKnownTransformersWarnings(() => pipeline("feature-extraction", this.modelName));
1666
1677
  this.activeModelName = this.modelName;
1667
1678
  this.initialized = true;
1668
1679
  return;
1669
1680
  } catch (primaryError) {
1670
- const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
1681
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || DEFAULT_EMBEDDING_FALLBACK_MODEL;
1671
1682
  if (fallbackModel === this.modelName) {
1672
1683
  throw primaryError;
1673
1684
  }
@@ -1786,6 +1797,28 @@ async function withSuppressedKnownTransformersWarnings(fn) {
1786
1797
  function isKnownBenignTransformersWarning(message) {
1787
1798
  return message.includes('Unknown model class "eurobert"') || message.includes('dtype not specified for "model"');
1788
1799
  }
1800
+ function isMissingTransformersDependencyError(error) {
1801
+ const maybeError = error;
1802
+ const message = typeof maybeError?.message === "string" ? maybeError.message : "";
1803
+ return maybeError?.code === "ERR_MODULE_NOT_FOUND" && message.includes("@huggingface/transformers");
1804
+ }
1805
+ function createEmbeddingBackendUnavailableError(cause) {
1806
+ const error = new Error(
1807
+ [
1808
+ "Required embedding backend is not installed.",
1809
+ "",
1810
+ "Claude Memory Layer requires @huggingface/transformers for local semantic/vector embeddings.",
1811
+ "The backend runs on CPU-only ONNX Runtime; CUDA is not required.",
1812
+ "Reinstall globally with:",
1813
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install -g claude-memory-layer@latest",
1814
+ "",
1815
+ "If you are inside a local checkout or package directory, repair only the backend with:",
1816
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install --no-save --no-package-lock --omit=dev @huggingface/transformers@3.8.1"
1817
+ ].join("\n")
1818
+ );
1819
+ error.cause = cause;
1820
+ return error;
1821
+ }
1789
1822
  async function loadTransformersPipeline() {
1790
1823
  const dynamicImport = new Function("specifier", "return import(specifier)");
1791
1824
  const transformers = await dynamicImport("@huggingface/transformers");