@openclaw/llama-cpp-provider 2026.7.2-beta.7 → 2026.8.1-beta.3
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 +31 -19
- package/dist/index.js +1606 -642
- package/dist/managed-provider-config-BDKErKo0.js +115 -0
- package/dist/provider-policy-api.js +19 -0
- package/openclaw.plugin.json +39 -5
- package/package.json +8 -7
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import os from "node:os";
|
|
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/managed-provider-config.ts
|
|
108
|
+
const MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE = "Local embeddings need the managed llama.cpp server config. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.";
|
|
109
|
+
function resolveManagedLlamaCppProviderConfig(config) {
|
|
110
|
+
const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
111
|
+
if (!provider?.localService || !provider.baseUrl) throw new Error(MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE);
|
|
112
|
+
return provider;
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { resolveHomePath as C, resolveLlamaCppModelSource as D, resolveLlamaCppModelCacheDir as E, resolveLlamaCppSyntheticApiKey as O, resolveCachedLlamaCppModelPath as S, resolveLlamaCppDataDir as T, LLAMA_CPP_DEFAULT_PORT as _, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as a, buildLlamaCppProviderConfig as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as c, DEFAULT_LLAMA_CPP_MODEL_ID as d, DEFAULT_LLAMA_CPP_MODEL_REF as f, DEFAULT_LLAMA_CPP_MODEL_URI as g, DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES as h, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE as i, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as l, DEFAULT_LLAMA_CPP_MODEL_SHA256 as m, resolveManagedLlamaCppProviderConfig as n, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as o, DEFAULT_LLAMA_CPP_MODEL_REVISION as p, DEFAULT_LLAMA_CPP_CONTEXT_SIZE as r, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION as s, MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE as t, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE as u, LLAMA_CPP_PROVIDER_ID as v, resolveLegacyLlamaCppModelCacheDir as w, meetsLlamaCppDefaultModelRamFloor as x, LLAMA_CPP_PROVIDER_LABEL as y };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./managed-provider-config-BDKErKo0.js";
|
|
2
|
+
//#region extensions/llama-cpp/provider-policy-api.ts
|
|
3
|
+
function inspectEmbeddingProviderSetup(params) {
|
|
4
|
+
if (params.provider !== "local") return null;
|
|
5
|
+
const fixHint = `Run \`openclaw models --agent ${params.agentId} auth login --provider llama-cpp --method local\` in an interactive terminal, then rerun this check.`;
|
|
6
|
+
try {
|
|
7
|
+
resolveManagedLlamaCppProviderConfig(params.config);
|
|
8
|
+
} catch {
|
|
9
|
+
return {
|
|
10
|
+
provider: params.provider,
|
|
11
|
+
reason: MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE,
|
|
12
|
+
requirement: "managed-llama-cpp-setup",
|
|
13
|
+
fixHint
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { inspectEmbeddingProviderSetup };
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "llama-cpp",
|
|
3
3
|
"name": "llama.cpp Provider",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Managed and external llama.cpp servers for GGUF chat and embeddings.",
|
|
5
5
|
"activation": {
|
|
6
6
|
"onStartup": false
|
|
7
7
|
},
|
|
8
8
|
"enabledByDefault": true,
|
|
9
|
+
"autoEnableWhenConfiguredProviders": ["llama-cpp"],
|
|
9
10
|
"providers": ["llama-cpp"],
|
|
11
|
+
"modelCatalog": {
|
|
12
|
+
"discovery": {
|
|
13
|
+
"llama-cpp": "refreshable"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
10
16
|
"providerRequest": {
|
|
11
17
|
"providers": {
|
|
12
18
|
"llama-cpp": {
|
|
13
|
-
"family": "llama-cpp"
|
|
19
|
+
"family": "llama-cpp",
|
|
20
|
+
"openAICompletions": {
|
|
21
|
+
"supportsStreamingUsage": true
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
},
|
|
@@ -23,17 +32,42 @@
|
|
|
23
32
|
},
|
|
24
33
|
"syntheticAuthRefs": ["llama-cpp"],
|
|
25
34
|
"nonSecretAuthMarkers": ["llama-cpp-local"],
|
|
35
|
+
"setup": {
|
|
36
|
+
"providers": [
|
|
37
|
+
{
|
|
38
|
+
"id": "llama-cpp",
|
|
39
|
+
"envVars": ["LLAMA_SERVER_API_KEY"]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
26
43
|
"providerAuthChoices": [
|
|
27
44
|
{
|
|
28
45
|
"provider": "llama-cpp",
|
|
29
46
|
"method": "local",
|
|
30
47
|
"choiceId": "llama-cpp",
|
|
31
48
|
"appGuidedDiscovery": true,
|
|
32
|
-
"
|
|
33
|
-
"
|
|
49
|
+
"appGuidedActionLabel": "Set up model",
|
|
50
|
+
"choiceLabel": "Managed local server",
|
|
51
|
+
"choiceHint": "Install a verified llama.cpp server and run a private GGUF model managed by OpenClaw",
|
|
52
|
+
"groupId": "llama-cpp",
|
|
53
|
+
"groupLabel": "Local llama.cpp",
|
|
54
|
+
"groupHint": "Managed or external llama.cpp server"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"provider": "llama-cpp",
|
|
58
|
+
"method": "existing-server",
|
|
59
|
+
"choiceId": "llama-cpp-existing-server",
|
|
60
|
+
"appGuidedDiscovery": true,
|
|
61
|
+
"appGuidedSecret": true,
|
|
62
|
+
"choiceLabel": "Existing llama-server",
|
|
63
|
+
"choiceHint": "Connect to a llama.cpp server managed outside OpenClaw",
|
|
34
64
|
"groupId": "llama-cpp",
|
|
35
65
|
"groupLabel": "Local llama.cpp",
|
|
36
|
-
"groupHint": "
|
|
66
|
+
"groupHint": "Managed or external llama.cpp server",
|
|
67
|
+
"optionKey": "llamaServerApiKey",
|
|
68
|
+
"cliFlag": "--llama-server-api-key",
|
|
69
|
+
"cliOption": "--llama-server-api-key <key>",
|
|
70
|
+
"cliDescription": "llama-server API key"
|
|
37
71
|
}
|
|
38
72
|
],
|
|
39
73
|
"contracts": {
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.
|
|
4
|
-
"description": "OpenClaw
|
|
3
|
+
"version": "2026.8.1-beta.3",
|
|
4
|
+
"description": "OpenClaw provider for managed and external llama.cpp servers",
|
|
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.3"
|
|
27
28
|
},
|
|
28
29
|
"build": {
|
|
29
|
-
"openclawVersion": "2026.
|
|
30
|
+
"openclawVersion": "2026.8.1-beta.3"
|
|
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.3"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
49
50
|
"openclaw": {
|