@openclaw/llama-cpp-provider 2026.7.2-beta.5 → 2026.8.1-beta.2
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/README.md +17 -18
- package/dist/doctor-contract-api.js +55 -0
- package/dist/index.js +798 -624
- package/dist/llama-server-assets-BEF3s_UC.js +181 -0
- package/openclaw.plugin.json +7 -3
- package/package.json +8 -7
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
4
|
+
//#region extensions/llama-cpp/src/defaults.ts
|
|
5
|
+
const LLAMA_CPP_PROVIDER_ID = "llama-cpp";
|
|
6
|
+
const LLAMA_CPP_PROVIDER_LABEL = "llama.cpp";
|
|
7
|
+
const LLAMA_CPP_LOCAL_AUTH_MARKER = "llama-cpp-local";
|
|
8
|
+
const LLAMA_CPP_DEFAULT_PORT = 19432;
|
|
9
|
+
const LLAMA_CPP_READY_TIMEOUT_MS = 3e4;
|
|
10
|
+
const LLAMA_CPP_IDLE_STOP_MS = 10 * 6e4;
|
|
11
|
+
function resolveLlamaCppSyntheticApiKey() {
|
|
12
|
+
return LLAMA_CPP_LOCAL_AUTH_MARKER;
|
|
13
|
+
}
|
|
14
|
+
const DEFAULT_LLAMA_CPP_MODEL_ID = "gemma-4-e4b-it-q4_k_m";
|
|
15
|
+
const DEFAULT_LLAMA_CPP_MODEL_REF = `${LLAMA_CPP_PROVIDER_ID}/${DEFAULT_LLAMA_CPP_MODEL_ID}`;
|
|
16
|
+
const DEFAULT_LLAMA_CPP_MODEL_URI = "hf:unsloth/gemma-4-E4B-it-GGUF/gemma-4-E4B-it-Q4_K_M.gguf";
|
|
17
|
+
const DEFAULT_LLAMA_CPP_MODEL_REVISION = "bfc15c382204943c3a8fff0c750b94ae2364d7a3";
|
|
18
|
+
const DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE = "hf_unsloth_gemma-4-E4B-it-GGUF_gemma-4-E4B-it-Q4_K_M.gguf";
|
|
19
|
+
const DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES = 4977171584;
|
|
20
|
+
const DEFAULT_LLAMA_CPP_MODEL_SHA256 = "85a896a047553e842f25297ee5b031d64ff30147d9c4af17b1e4b394cd1fab87";
|
|
21
|
+
const DEFAULT_LLAMA_CPP_CONTEXT_SIZE = 65536;
|
|
22
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL = "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf";
|
|
23
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION = "66f974f8cd48cc3b9c41c516b95508e75b4bee64";
|
|
24
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID = "embeddinggemma-300m-qat-q8_0";
|
|
25
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE = "hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf";
|
|
26
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES = 328577056;
|
|
27
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 = "6fa0c02a9c302be6f977521d399b4de3a46310a4f2621ee0063747881b673f67";
|
|
28
|
+
const LLAMA_CPP_DEFAULT_MODEL_RAM_FLOOR_BYTES = 16 * 1024 ** 3;
|
|
29
|
+
function meetsLlamaCppDefaultModelRamFloor(totalmemBytes = os.totalmem()) {
|
|
30
|
+
return totalmemBytes >= LLAMA_CPP_DEFAULT_MODEL_RAM_FLOOR_BYTES;
|
|
31
|
+
}
|
|
32
|
+
function resolveLlamaCppDataDir() {
|
|
33
|
+
return path.join(resolveStateDir(), "tools", "llama.cpp");
|
|
34
|
+
}
|
|
35
|
+
function resolveLlamaCppModelCacheDir(provider) {
|
|
36
|
+
const configured = provider?.params?.modelCacheDir;
|
|
37
|
+
return typeof configured === "string" && configured.trim() ? resolveHomePath(configured.trim()) : path.join(resolveStateDir(), "models", "llama.cpp");
|
|
38
|
+
}
|
|
39
|
+
function resolveLegacyLlamaCppModelCacheDir() {
|
|
40
|
+
return path.join(os.homedir(), ".node-llama-cpp", "models");
|
|
41
|
+
}
|
|
42
|
+
function resolveHomePath(value) {
|
|
43
|
+
if (value === "~") return os.homedir();
|
|
44
|
+
if (value.startsWith("~/")) return path.join(os.homedir(), value.slice(2));
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
function resolveLlamaCppModelSource(model) {
|
|
48
|
+
const configured = model.params?.modelPath;
|
|
49
|
+
if (typeof configured === "string" && configured.trim()) return resolveHomePath(configured.trim());
|
|
50
|
+
return model.id === "gemma-4-e4b-it-q4_k_m" ? DEFAULT_LLAMA_CPP_MODEL_URI : resolveHomePath(model.id);
|
|
51
|
+
}
|
|
52
|
+
function resolveCachedLlamaCppModelPath(params) {
|
|
53
|
+
const source = resolveLlamaCppModelSource(params.model);
|
|
54
|
+
const cacheDir = resolveLlamaCppModelCacheDir(params.provider);
|
|
55
|
+
if (source === "hf:unsloth/gemma-4-E4B-it-GGUF/gemma-4-E4B-it-Q4_K_M.gguf") return path.join(cacheDir, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE);
|
|
56
|
+
if (/^(?:hf:|https?:\/\/)/iu.test(source)) return null;
|
|
57
|
+
return path.isAbsolute(source) ? source : path.resolve(cacheDir, source);
|
|
58
|
+
}
|
|
59
|
+
function buildDefaultLlamaCppModel() {
|
|
60
|
+
return {
|
|
61
|
+
id: DEFAULT_LLAMA_CPP_MODEL_ID,
|
|
62
|
+
name: "Gemma 4 E4B (Q4_K_M)",
|
|
63
|
+
api: "openai-completions",
|
|
64
|
+
reasoning: false,
|
|
65
|
+
input: ["text"],
|
|
66
|
+
cost: {
|
|
67
|
+
input: 0,
|
|
68
|
+
output: 0,
|
|
69
|
+
cacheRead: 0,
|
|
70
|
+
cacheWrite: 0
|
|
71
|
+
},
|
|
72
|
+
contextWindow: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
|
|
73
|
+
contextTokens: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
|
|
74
|
+
maxTokens: 2048,
|
|
75
|
+
params: {
|
|
76
|
+
modelPath: DEFAULT_LLAMA_CPP_MODEL_URI,
|
|
77
|
+
contextSize: DEFAULT_LLAMA_CPP_CONTEXT_SIZE
|
|
78
|
+
},
|
|
79
|
+
compat: {
|
|
80
|
+
supportsTools: true,
|
|
81
|
+
supportsUsageInStreaming: true,
|
|
82
|
+
toolSchemaProfile: "llamacpp"
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function buildLlamaCppProviderConfig(existing, managed) {
|
|
87
|
+
const defaultModel = buildDefaultLlamaCppModel();
|
|
88
|
+
const configuredModels = existing?.models ?? [];
|
|
89
|
+
const models = configuredModels.some((model) => model.id === defaultModel.id) ? configuredModels : [...configuredModels, defaultModel];
|
|
90
|
+
return {
|
|
91
|
+
...existing,
|
|
92
|
+
baseUrl: managed?.baseUrl ?? existing?.baseUrl ?? `http://127.0.0.1:19432/v1`,
|
|
93
|
+
apiKey: existing?.apiKey ?? resolveLlamaCppSyntheticApiKey(),
|
|
94
|
+
api: "openai-completions",
|
|
95
|
+
timeoutSeconds: existing?.timeoutSeconds ?? 600,
|
|
96
|
+
...managed ? { localService: {
|
|
97
|
+
command: managed.command,
|
|
98
|
+
args: managed.args,
|
|
99
|
+
healthUrl: managed.healthUrl,
|
|
100
|
+
readyTimeoutMs: LLAMA_CPP_READY_TIMEOUT_MS,
|
|
101
|
+
idleStopMs: LLAMA_CPP_IDLE_STOP_MS
|
|
102
|
+
} } : {},
|
|
103
|
+
models
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region extensions/llama-cpp/src/llama-server-assets.ts
|
|
108
|
+
const LLAMA_SERVER_RELEASE = "b10357";
|
|
109
|
+
const LLAMA_SERVER_BUILD = 10357;
|
|
110
|
+
const LLAMA_SERVER_COMMIT = "689e227db485c6b33d061555e74034c93a867649";
|
|
111
|
+
const LLAMA_SERVER_ASSETS = [
|
|
112
|
+
{
|
|
113
|
+
platform: "darwin",
|
|
114
|
+
arch: "arm64",
|
|
115
|
+
backend: "metal",
|
|
116
|
+
archive: "tar.gz",
|
|
117
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-macos-arm64.tar.gz`,
|
|
118
|
+
sha256: "7f464a2d473d53ebb9c1d7d16db1258ec98c371569816491850686e6a4334c52",
|
|
119
|
+
executable: "llama-server"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
platform: "darwin",
|
|
123
|
+
arch: "x64",
|
|
124
|
+
backend: "cpu",
|
|
125
|
+
archive: "tar.gz",
|
|
126
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-macos-x64.tar.gz`,
|
|
127
|
+
sha256: "8282cf6b30bfab87080044e98b7b78f2896bfc60414926fae6039a89c0fb6ec2",
|
|
128
|
+
executable: "llama-server"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
platform: "linux",
|
|
132
|
+
arch: "arm64",
|
|
133
|
+
backend: "cpu",
|
|
134
|
+
archive: "tar.gz",
|
|
135
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-ubuntu-arm64.tar.gz`,
|
|
136
|
+
sha256: "0653b6aa14de35920824045bca7e48f98f629f41943d0fefab1e317bbe8e22a8",
|
|
137
|
+
executable: "llama-server"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
platform: "linux",
|
|
141
|
+
arch: "x64",
|
|
142
|
+
backend: "cpu",
|
|
143
|
+
archive: "tar.gz",
|
|
144
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-ubuntu-x64.tar.gz`,
|
|
145
|
+
sha256: "6b0ba012036e6d727521100158bfcaa73b460fbb31acab2931c9485f347bd16b",
|
|
146
|
+
executable: "llama-server"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
platform: "win32",
|
|
150
|
+
arch: "arm64",
|
|
151
|
+
backend: "cpu",
|
|
152
|
+
archive: "zip",
|
|
153
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-arm64.zip`,
|
|
154
|
+
sha256: "a0d73be8d3151d9401fa193f1b83c6d7401191b41786e75f0a60184058333e86",
|
|
155
|
+
executable: "llama-server.exe"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
platform: "win32",
|
|
159
|
+
arch: "x64",
|
|
160
|
+
backend: "cpu",
|
|
161
|
+
archive: "zip",
|
|
162
|
+
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-x64.zip`,
|
|
163
|
+
sha256: "6c64cc7db679980fcb34bbbe96b2b1df6127e90ccdad2bd6fbe39532fee2fc4e",
|
|
164
|
+
executable: "llama-server.exe"
|
|
165
|
+
}
|
|
166
|
+
];
|
|
167
|
+
function selectLlamaServerAsset(platform = process.platform, arch = process.arch) {
|
|
168
|
+
const asset = LLAMA_SERVER_ASSETS.find((candidate) => candidate.platform === platform && candidate.arch === arch);
|
|
169
|
+
if (!asset) throw new Error(`No verified llama-server ${LLAMA_SERVER_RELEASE} build is available for ${platform}/${arch}. Install a compatible llama-server manually, then rerun llama.cpp setup with its absolute path.`);
|
|
170
|
+
return asset;
|
|
171
|
+
}
|
|
172
|
+
function resolveManagedLlamaServerPaths(asset = selectLlamaServerAsset()) {
|
|
173
|
+
const installDir = path.join(resolveLlamaCppDataDir(), LLAMA_SERVER_RELEASE, `${asset.platform}-${asset.arch}`);
|
|
174
|
+
return {
|
|
175
|
+
installDir,
|
|
176
|
+
command: path.join(installDir, asset.executable),
|
|
177
|
+
presetPath: path.join(resolveLlamaCppDataDir(), "models.ini")
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { resolveLlamaCppModelSource as A, buildLlamaCppProviderConfig as C, resolveLegacyLlamaCppModelCacheDir as D, resolveHomePath as E, resolveLlamaCppDataDir as O, LLAMA_CPP_PROVIDER_LABEL as S, resolveCachedLlamaCppModelPath as T, DEFAULT_LLAMA_CPP_MODEL_SHA256 as _, selectLlamaServerAsset as a, LLAMA_CPP_DEFAULT_PORT as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as c, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as d, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as f, DEFAULT_LLAMA_CPP_MODEL_REVISION as g, DEFAULT_LLAMA_CPP_MODEL_REF as h, resolveManagedLlamaServerPaths as i, resolveLlamaCppSyntheticApiKey as j, resolveLlamaCppModelCacheDir as k, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as l, DEFAULT_LLAMA_CPP_MODEL_ID as m, LLAMA_SERVER_COMMIT as n, DEFAULT_LLAMA_CPP_CONTEXT_SIZE as o, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE as p, LLAMA_SERVER_RELEASE as r, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE as s, LLAMA_SERVER_BUILD as t, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION as u, DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES as v, meetsLlamaCppDefaultModelRamFloor as w, LLAMA_CPP_PROVIDER_ID as x, DEFAULT_LLAMA_CPP_MODEL_URI as y };
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "llama-cpp",
|
|
3
3
|
"name": "llama.cpp Provider",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Managed local llama.cpp server for GGUF chat and embeddings.",
|
|
5
|
+
"doctorContract": {
|
|
6
|
+
"configRepair": true
|
|
7
|
+
},
|
|
5
8
|
"activation": {
|
|
6
9
|
"onStartup": false
|
|
7
10
|
},
|
|
@@ -29,8 +32,9 @@
|
|
|
29
32
|
"method": "local",
|
|
30
33
|
"choiceId": "llama-cpp",
|
|
31
34
|
"appGuidedDiscovery": true,
|
|
32
|
-
"
|
|
33
|
-
"
|
|
35
|
+
"appGuidedActionLabel": "Set up model",
|
|
36
|
+
"choiceLabel": "llama.cpp",
|
|
37
|
+
"choiceHint": "Install a verified llama.cpp server and run a private GGUF model managed by OpenClaw",
|
|
34
38
|
"groupId": "llama-cpp",
|
|
35
39
|
"groupLabel": "Local llama.cpp",
|
|
36
40
|
"groupHint": "No API key required"
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.
|
|
4
|
-
"description": "OpenClaw llama.cpp
|
|
3
|
+
"version": "2026.8.1-beta.2",
|
|
4
|
+
"description": "OpenClaw managed llama.cpp server provider plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/openclaw/openclaw"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"jszip": "3.10.1",
|
|
12
|
+
"tar": "7.5.22"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"@openclaw/plugin-sdk": "workspace:*"
|
|
@@ -23,10 +24,10 @@
|
|
|
23
24
|
"minHostVersion": ">=2026.6.2"
|
|
24
25
|
},
|
|
25
26
|
"compat": {
|
|
26
|
-
"pluginApi": ">=2026.
|
|
27
|
+
"pluginApi": ">=2026.8.1-beta.2"
|
|
27
28
|
},
|
|
28
29
|
"build": {
|
|
29
|
-
"openclawVersion": "2026.
|
|
30
|
+
"openclawVersion": "2026.8.1-beta.2"
|
|
30
31
|
},
|
|
31
32
|
"release": {
|
|
32
33
|
"bundleRuntimeDependencies": false,
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"README.md"
|
|
44
45
|
],
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"openclaw": ">=2026.
|
|
47
|
+
"openclaw": ">=2026.8.1-beta.2"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
49
50
|
"openclaw": {
|