claude-memory-layer 1.0.28 → 1.0.30

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