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