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.
@@ -1531,12 +1531,14 @@ import * as fs5 from "fs";
1531
1531
  import * as path4 from "path";
1532
1532
 
1533
1533
  // src/extensions/vector/embedder.ts
1534
+ var DEFAULT_EMBEDDING_MODEL = "Xenova/multilingual-e5-small";
1535
+ var DEFAULT_EMBEDDING_FALLBACK_MODEL = "intfloat/multilingual-e5-small";
1534
1536
  var Embedder = class _Embedder {
1535
1537
  pipeline = null;
1536
1538
  modelName;
1537
1539
  activeModelName;
1538
1540
  initialized = false;
1539
- constructor(modelName = "jinaai/jina-embeddings-v5-text-nano-text-matching") {
1541
+ constructor(modelName = DEFAULT_EMBEDDING_MODEL) {
1540
1542
  this.modelName = modelName;
1541
1543
  this.activeModelName = modelName;
1542
1544
  }
@@ -1546,14 +1548,23 @@ var Embedder = class _Embedder {
1546
1548
  async initialize() {
1547
1549
  if (this.initialized)
1548
1550
  return;
1549
- const pipeline = await withSuppressedKnownTransformersWarnings(() => loadTransformersPipeline());
1551
+ const pipeline = await withSuppressedKnownTransformersWarnings(async () => {
1552
+ try {
1553
+ return await loadTransformersPipeline();
1554
+ } catch (error) {
1555
+ if (isMissingTransformersDependencyError(error)) {
1556
+ throw createEmbeddingBackendUnavailableError(error);
1557
+ }
1558
+ throw error;
1559
+ }
1560
+ });
1550
1561
  try {
1551
1562
  this.pipeline = await withSuppressedKnownTransformersWarnings(() => pipeline("feature-extraction", this.modelName));
1552
1563
  this.activeModelName = this.modelName;
1553
1564
  this.initialized = true;
1554
1565
  return;
1555
1566
  } catch (primaryError) {
1556
- const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || "onnx-community/embeddinggemma-300m-ONNX";
1567
+ const fallbackModel = process.env.CLAUDE_MEMORY_EMBEDDING_FALLBACK_MODEL || DEFAULT_EMBEDDING_FALLBACK_MODEL;
1557
1568
  if (fallbackModel === this.modelName) {
1558
1569
  throw primaryError;
1559
1570
  }
@@ -1672,6 +1683,28 @@ async function withSuppressedKnownTransformersWarnings(fn) {
1672
1683
  function isKnownBenignTransformersWarning(message) {
1673
1684
  return message.includes('Unknown model class "eurobert"') || message.includes('dtype not specified for "model"');
1674
1685
  }
1686
+ function isMissingTransformersDependencyError(error) {
1687
+ const maybeError = error;
1688
+ const message = typeof maybeError?.message === "string" ? maybeError.message : "";
1689
+ return maybeError?.code === "ERR_MODULE_NOT_FOUND" && message.includes("@huggingface/transformers");
1690
+ }
1691
+ function createEmbeddingBackendUnavailableError(cause) {
1692
+ const error = new Error(
1693
+ [
1694
+ "Required embedding backend is not installed.",
1695
+ "",
1696
+ "Claude Memory Layer requires @huggingface/transformers for local semantic/vector embeddings.",
1697
+ "The backend runs on CPU-only ONNX Runtime; CUDA is not required.",
1698
+ "Reinstall globally with:",
1699
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install -g claude-memory-layer@latest",
1700
+ "",
1701
+ "If you are inside a local checkout or package directory, repair only the backend with:",
1702
+ " ONNXRUNTIME_NODE_INSTALL_CUDA=skip npm install --no-save --no-package-lock --omit=dev @huggingface/transformers@3.8.1"
1703
+ ].join("\n")
1704
+ );
1705
+ error.cause = cause;
1706
+ return error;
1707
+ }
1675
1708
  async function loadTransformersPipeline() {
1676
1709
  const dynamicImport = new Function("specifier", "return import(specifier)");
1677
1710
  const transformers = await dynamicImport("@huggingface/transformers");