@openclaw/llama-cpp-provider 2026.6.8 → 2026.6.9-beta.1
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.
- package/dist/index.js +55 -20
- package/npm-shrinkwrap.json +8 -8
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,16 +1,46 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
3
5
|
import { pathToFileURL } from "node:url";
|
|
4
6
|
import { createLocalEmbeddingProvider } from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
5
7
|
//#region extensions/llama-cpp/src/embedding-provider.ts
|
|
6
8
|
const LLAMA_CPP_EMBEDDING_PROVIDER_ID = "local";
|
|
7
9
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL = "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf";
|
|
10
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_CACHE_FILE_NAME = "hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf";
|
|
8
11
|
function normalizeOptionalString(value) {
|
|
9
12
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
10
13
|
}
|
|
11
14
|
function readLocalOptions(options) {
|
|
12
15
|
return options.local ?? {};
|
|
13
16
|
}
|
|
17
|
+
function createLlamaCppCacheKeyData(model, outputDimensionality) {
|
|
18
|
+
return {
|
|
19
|
+
provider: LLAMA_CPP_EMBEDDING_PROVIDER_ID,
|
|
20
|
+
model,
|
|
21
|
+
...typeof outputDimensionality === "number" ? { outputDimensionality } : {}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function resolveLlamaCppModelIdentity(local, modelPath, outputDimensionality) {
|
|
25
|
+
const modelCacheDir = normalizeOptionalString(local.modelCacheDir) ?? path.join(os.homedir(), ".node-llama-cpp", "models");
|
|
26
|
+
const resolvedDefaultModelPath = path.resolve(modelCacheDir, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_CACHE_FILE_NAME);
|
|
27
|
+
const resolvedModelPath = /^(?:hf:|https?:\/\/)/i.test(modelPath) ? void 0 : path.resolve(modelCacheDir, modelPath);
|
|
28
|
+
if (modelPath !== "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf" && resolvedModelPath !== resolvedDefaultModelPath) return {
|
|
29
|
+
model: modelPath,
|
|
30
|
+
cacheKeyData: createLlamaCppCacheKeyData(modelPath, outputDimensionality),
|
|
31
|
+
aliases: []
|
|
32
|
+
};
|
|
33
|
+
const aliasModels = new Set([resolvedDefaultModelPath, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_CACHE_FILE_NAME]);
|
|
34
|
+
if (modelPath !== "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf") aliasModels.add(modelPath);
|
|
35
|
+
return {
|
|
36
|
+
model: DEFAULT_LLAMA_CPP_EMBEDDING_MODEL,
|
|
37
|
+
cacheKeyData: createLlamaCppCacheKeyData(DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, outputDimensionality),
|
|
38
|
+
aliases: Array.from(aliasModels, (aliasModel) => ({
|
|
39
|
+
model: aliasModel,
|
|
40
|
+
cacheKeyData: createLlamaCppCacheKeyData(aliasModel, outputDimensionality)
|
|
41
|
+
}))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
14
44
|
function textFromEmbeddingInput(input) {
|
|
15
45
|
return typeof input === "string" ? input : input.text;
|
|
16
46
|
}
|
|
@@ -56,16 +86,24 @@ function adaptMemoryEmbeddingProvider(provider) {
|
|
|
56
86
|
close: provider.close
|
|
57
87
|
};
|
|
58
88
|
}
|
|
59
|
-
async function createLlamaCppEmbeddingProvider(options, runtimeOptions = {}) {
|
|
60
|
-
const result = await createLlamaCppMemoryEmbeddingProvider(buildMemoryCreateOptions(options, options.dimensions), runtimeOptions);
|
|
61
|
-
if (!result.provider) throw new Error("llama.cpp local embedding provider was unavailable");
|
|
62
|
-
return adaptMemoryEmbeddingProvider(result.provider);
|
|
63
|
-
}
|
|
64
89
|
async function createLlamaCppMemoryEmbeddingProvider(options, runtimeOptions = {}) {
|
|
65
|
-
const
|
|
90
|
+
const createOptions = buildMemoryCreateOptions(options, options.outputDimensionality);
|
|
91
|
+
const local = readLocalOptions(createOptions);
|
|
92
|
+
const provider = await createLocalEmbeddingProvider(createOptions, { nodeLlamaCppImportUrl: runtimeOptions.nodeLlamaCppImportUrl ?? resolveNodeLlamaCppImportUrl() });
|
|
93
|
+
const identity = resolveLlamaCppModelIdentity(local, provider.model, createOptions.outputDimensionality);
|
|
94
|
+
return {
|
|
95
|
+
provider: identity.model === provider.model ? provider : {
|
|
96
|
+
...provider,
|
|
97
|
+
model: identity.model
|
|
98
|
+
},
|
|
99
|
+
runtime: createLlamaCppEmbeddingProviderRuntime(identity)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async function createLlamaCppEmbeddingProviderResult(options, runtimeOptions = {}) {
|
|
103
|
+
const result = await createLlamaCppMemoryEmbeddingProvider(buildMemoryCreateOptions(options, options.dimensions), runtimeOptions);
|
|
66
104
|
return {
|
|
67
|
-
provider,
|
|
68
|
-
runtime:
|
|
105
|
+
provider: result.provider ? adaptMemoryEmbeddingProvider(result.provider) : null,
|
|
106
|
+
runtime: result.runtime
|
|
69
107
|
};
|
|
70
108
|
}
|
|
71
109
|
function buildMemoryCreateOptions(options, outputDimensionality) {
|
|
@@ -88,15 +126,13 @@ function buildMemoryCreateOptions(options, outputDimensionality) {
|
|
|
88
126
|
outputDimensionality
|
|
89
127
|
};
|
|
90
128
|
}
|
|
91
|
-
function createLlamaCppEmbeddingProviderRuntime(
|
|
129
|
+
function createLlamaCppEmbeddingProviderRuntime(identity) {
|
|
92
130
|
return {
|
|
93
131
|
id: LLAMA_CPP_EMBEDDING_PROVIDER_ID,
|
|
94
132
|
inlineQueryTimeoutMs: 5 * 6e4,
|
|
95
133
|
inlineBatchTimeoutMs: 10 * 6e4,
|
|
96
|
-
cacheKeyData:
|
|
97
|
-
|
|
98
|
-
model: provider.model
|
|
99
|
-
}
|
|
134
|
+
cacheKeyData: identity.cacheKeyData,
|
|
135
|
+
...identity.aliases.length > 0 ? { indexIdentityAliases: identity.aliases } : {}
|
|
100
136
|
};
|
|
101
137
|
}
|
|
102
138
|
const llamaCppEmbeddingProviderAdapter = {
|
|
@@ -104,13 +140,12 @@ const llamaCppEmbeddingProviderAdapter = {
|
|
|
104
140
|
defaultModel: DEFAULT_LLAMA_CPP_EMBEDDING_MODEL,
|
|
105
141
|
transport: "local",
|
|
106
142
|
formatSetupError: formatLlamaCppSetupError,
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
143
|
+
resolveIndexIdentity: (options) => {
|
|
144
|
+
const createOptions = buildMemoryCreateOptions(options, options.dimensions);
|
|
145
|
+
const local = readLocalOptions(createOptions);
|
|
146
|
+
return resolveLlamaCppModelIdentity(local, normalizeOptionalString(local.modelPath) ?? "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf", createOptions.outputDimensionality);
|
|
147
|
+
},
|
|
148
|
+
create: async (options) => await createLlamaCppEmbeddingProviderResult(options)
|
|
114
149
|
};
|
|
115
150
|
//#endregion
|
|
116
151
|
//#region extensions/llama-cpp/index.ts
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.6.
|
|
3
|
+
"version": "2026.6.9-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/llama-cpp-provider",
|
|
9
|
-
"version": "2026.6.
|
|
9
|
+
"version": "2026.6.9-beta.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"node-llama-cpp": "3.18.1"
|
|
12
12
|
}
|
|
@@ -1363,9 +1363,9 @@
|
|
|
1363
1363
|
}
|
|
1364
1364
|
},
|
|
1365
1365
|
"node_modules/semver": {
|
|
1366
|
-
"version": "7.8.
|
|
1367
|
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.
|
|
1368
|
-
"integrity": "sha512-
|
|
1366
|
+
"version": "7.8.4",
|
|
1367
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz",
|
|
1368
|
+
"integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==",
|
|
1369
1369
|
"license": "ISC",
|
|
1370
1370
|
"bin": {
|
|
1371
1371
|
"semver": "bin/semver.js"
|
|
@@ -1543,9 +1543,9 @@
|
|
|
1543
1543
|
}
|
|
1544
1544
|
},
|
|
1545
1545
|
"node_modules/tar": {
|
|
1546
|
-
"version": "7.5.
|
|
1547
|
-
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.
|
|
1548
|
-
"integrity": "sha512-
|
|
1546
|
+
"version": "7.5.16",
|
|
1547
|
+
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.16.tgz",
|
|
1548
|
+
"integrity": "sha512-56adEpPMouktRlBLXiaYFFzZ/3+JXa8P9n7WbR+ibIjtviN55mEaOkiysCnPnWm+7kkui1Dn8J9l+g6zV8731w==",
|
|
1549
1549
|
"license": "BlueOak-1.0.0",
|
|
1550
1550
|
"dependencies": {
|
|
1551
1551
|
"@isaacs/fs-minipass": "^4.0.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.6.
|
|
3
|
+
"version": "2026.6.9-beta.1",
|
|
4
4
|
"description": "OpenClaw llama.cpp embedding provider plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"minHostVersion": ">=2026.6.2"
|
|
24
24
|
},
|
|
25
25
|
"compat": {
|
|
26
|
-
"pluginApi": ">=2026.6.
|
|
26
|
+
"pluginApi": ">=2026.6.9-beta.1"
|
|
27
27
|
},
|
|
28
28
|
"build": {
|
|
29
|
-
"openclawVersion": "2026.6.
|
|
29
|
+
"openclawVersion": "2026.6.9-beta.1"
|
|
30
30
|
},
|
|
31
31
|
"release": {
|
|
32
32
|
"bundleRuntimeDependencies": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"openclaw": ">=2026.6.
|
|
47
|
+
"openclaw": ">=2026.6.9-beta.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"openclaw": {
|