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