@openclaw/llama-cpp-provider 2026.9.4 → 2026.9.6
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/assets/activity.svg +30 -0
- package/assets/icon.png +0 -0
- package/dist/{managed-provider-config-D9X1wNEo.js → .setup/managed-provider-config-BYvyYdAs.mjs} +1 -1
- package/dist/index.js +23 -29
- package/dist/provider-policy-api.js +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +11 -5
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 250">
|
|
2
|
+
<!--
|
|
3
|
+
Adapted from OpenClaw ui/public/provider-icons/ProviderIcon-llamacpp.svg.
|
|
4
|
+
Source: https://github.com/ggml-org/llama.cpp/blob/2cfef4d117d67ab1dec002915b48a15d11ee1973/media/llama1-icon-transparent.svg
|
|
5
|
+
|
|
6
|
+
MIT License
|
|
7
|
+
Copyright (c) 2023-2026 The ggml authors
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Names and marks remain the property of their respective owners.
|
|
28
|
+
-->
|
|
29
|
+
<path fill="currentColor" stroke="none" transform="translate(-995.51066 -129.70875)" d="M0 0 m1163.3 226.8-13.5 24c-17.8-13.7-44.2-15.7-62-1-28.7 23.7-26.7 78.5 18 78.8 12.5 0 23.1-5.9 34.5-9.8l6 23.9c-10.1 4.7-20.4 9.5-31.5 11-101.2 13.8-95.4-132.3-3.9-139.9 19.2-1.6 36.1 3.4 52.5 13z M1093.4 203.8c-15.4 4.6-29.7 13.1-40.5 25-2-24.2 3.4-73.1 30.3-82.7 4-1.4 17.7-4.9 17.3 2.2-.4 7.1-9.9 19.3-12.2 25.9-4 11.6-.3 19.6 5.2 29.7z M1131.4 307.8h-15v-17h-17v-14h15.5l1.5-1.5v-16.5h15v18h16v14h-16zm55 0h-15v-17h-16v-14h15.5l1.5-1.5v-16.5h15v16.5l1.5 1.5h15.5v14h-17z M1142.3 156.9c2 3-9.3 15.9-11.1 19.2-5.2 9.8-1.7 15.4 2.2 24.7-11.3-1.7-21.8-.3-33 1 2.5-21.5 14.6-52.8 41.9-44.9z" />
|
|
30
|
+
</svg>
|
package/assets/icon.png
ADDED
|
Binary file
|
package/dist/{managed-provider-config-D9X1wNEo.js → .setup/managed-provider-config-BYvyYdAs.mjs}
RENAMED
|
@@ -112,7 +112,7 @@ function buildLlamaCppProviderConfig(params = {}) {
|
|
|
112
112
|
}
|
|
113
113
|
//#endregion
|
|
114
114
|
//#region extensions/llama-cpp/src/managed-provider-config.ts
|
|
115
|
-
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`.";
|
|
115
|
+
const MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE = "Local embeddings need the managed llama.cpp server config (llama-server). The in-process node-llama-cpp runtime was removed; semantic memory recall is degraded until setup. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.";
|
|
116
116
|
function resolveManagedLlamaCppProviderConfig(config) {
|
|
117
117
|
const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
118
118
|
if (!provider?.localService || !provider.baseUrl) throw new Error(MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as resolveLlamaCppDataDir, D as resolveLlamaCppSyntheticApiKey, E as resolveLlamaCppModelSource, S as resolveLegacyLlamaCppModelCacheDir, T as resolveLlamaCppModelCacheDir, _ as LLAMA_CPP_PROVIDER_ID, a as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, b as resolveCachedLlamaCppModelPath, c as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256, d as DEFAULT_LLAMA_CPP_MODEL_ID, f as DEFAULT_LLAMA_CPP_MODEL_REVISION, g as LLAMA_CPP_DEFAULT_PORT, h as DEFAULT_LLAMA_CPP_MODEL_URI, i as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, l as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES, m as DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES, n as resolveManagedLlamaCppProviderConfig, o as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, p as DEFAULT_LLAMA_CPP_MODEL_SHA256, r as DEFAULT_LLAMA_CPP_CONTEXT_SIZE, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, u as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, v as LLAMA_CPP_PROVIDER_LABEL, w as resolveLlamaCppEmbeddingModel, x as resolveHomePath, y as buildLlamaCppProviderConfig } from "
|
|
1
|
+
import { C as resolveLlamaCppDataDir, D as resolveLlamaCppSyntheticApiKey, E as resolveLlamaCppModelSource, S as resolveLegacyLlamaCppModelCacheDir, T as resolveLlamaCppModelCacheDir, _ as LLAMA_CPP_PROVIDER_ID, a as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, b as resolveCachedLlamaCppModelPath, c as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256, d as DEFAULT_LLAMA_CPP_MODEL_ID, f as DEFAULT_LLAMA_CPP_MODEL_REVISION, g as LLAMA_CPP_DEFAULT_PORT, h as DEFAULT_LLAMA_CPP_MODEL_URI, i as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, l as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES, m as DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES, n as resolveManagedLlamaCppProviderConfig, o as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, p as DEFAULT_LLAMA_CPP_MODEL_SHA256, r as DEFAULT_LLAMA_CPP_CONTEXT_SIZE, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, u as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, v as LLAMA_CPP_PROVIDER_LABEL, w as resolveLlamaCppEmbeddingModel, x as resolveHomePath, y as buildLlamaCppProviderConfig } from "./.setup/managed-provider-config-BYvyYdAs.mjs";
|
|
2
2
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { getEmbeddingProvider } from "openclaw/plugin-sdk/embedding-providers";
|
|
@@ -12,6 +12,7 @@ import { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } from "open
|
|
|
12
12
|
import { fetchConfiguredLocalOriginWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime-internal";
|
|
13
13
|
import { execFile } from "node:child_process";
|
|
14
14
|
import fs$1, { constants } from "node:fs";
|
|
15
|
+
import { sha256File } from "@openclaw/fs-safe/durability";
|
|
15
16
|
import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
16
17
|
import { ARCHIVE_LIMIT_ERROR_CODE, ArchiveLimitError, extractArchive } from "openclaw/plugin-sdk/archive";
|
|
17
18
|
import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput, upsertAuthProfileWithLock } from "openclaw/plugin-sdk/provider-auth";
|
|
@@ -304,7 +305,7 @@ function rememberVerifiedFile(filePath, stat, sha256) {
|
|
|
304
305
|
if (oldest !== void 0) verifiedFiles.delete(oldest);
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
|
-
async function sha256File(filePath, signal) {
|
|
308
|
+
async function sha256File$1(filePath, signal) {
|
|
308
309
|
signal?.throwIfAborted();
|
|
309
310
|
try {
|
|
310
311
|
const identity = fileIdentity(await fs.stat(filePath, { bigint: true }));
|
|
@@ -314,16 +315,9 @@ async function sha256File(filePath, signal) {
|
|
|
314
315
|
const handle = await fs.open(filePath, "r");
|
|
315
316
|
try {
|
|
316
317
|
const before = fileIdentity(await handle.stat({ bigint: true }));
|
|
317
|
-
const
|
|
318
|
-
const input = handle.createReadStream({
|
|
319
|
-
autoClose: false,
|
|
320
|
-
highWaterMark: 1048576,
|
|
321
|
-
signal
|
|
322
|
-
});
|
|
323
|
-
for await (const chunk of input) hash.update(chunk);
|
|
318
|
+
const { digest: sha256 } = await sha256File(handle, { signal });
|
|
324
319
|
const after = await handle.stat({ bigint: true });
|
|
325
320
|
if (before !== fileIdentity(after) || before !== fileIdentity(await fs.stat(filePath, { bigint: true }))) throw new Error(`File changed during integrity verification: ${filePath}. Retry setup.`);
|
|
326
|
-
const sha256 = hash.digest("hex");
|
|
327
321
|
rememberVerifiedFile(filePath, after, sha256);
|
|
328
322
|
return sha256;
|
|
329
323
|
} finally {
|
|
@@ -377,9 +371,9 @@ async function downloadVerifiedFile(params) {
|
|
|
377
371
|
if (now > previousAt) {
|
|
378
372
|
const currentRate = (downloadedSize - previousSize) * 1e3 / (now - previousAt);
|
|
379
373
|
rollingBytesPerSecond = rollingBytesPerSecond === 0 ? currentRate : rollingBytesPerSecond * .75 + currentRate * .25;
|
|
374
|
+
previousSize = downloadedSize;
|
|
375
|
+
previousAt = now;
|
|
380
376
|
}
|
|
381
|
-
previousSize = downloadedSize;
|
|
382
|
-
previousAt = now;
|
|
383
377
|
params.onProgress?.({
|
|
384
378
|
downloadedSize,
|
|
385
379
|
totalSize,
|
|
@@ -1062,7 +1056,7 @@ async function ensureLlamaCppModel(params) {
|
|
|
1062
1056
|
const destination = path.join(params.cacheDir, artifact.fileName);
|
|
1063
1057
|
const load = modelPromises.get(destination) ?? (async () => {
|
|
1064
1058
|
const exists = await fs.stat(destination).then((stat) => stat.isFile()).catch(() => false);
|
|
1065
|
-
if (exists && artifact.expectedSha256 && await sha256File(destination, params.signal) === artifact.expectedSha256) return destination;
|
|
1059
|
+
if (exists && artifact.expectedSha256 && await sha256File$1(destination, params.signal) === artifact.expectedSha256) return destination;
|
|
1066
1060
|
if (exists && !artifact.expectedSha256) {
|
|
1067
1061
|
await assertGguf(destination);
|
|
1068
1062
|
return destination;
|
|
@@ -1460,7 +1454,7 @@ async function resolveLlamaServerProviderHeaders(params) {
|
|
|
1460
1454
|
if (typeof value === "string" && value.trim()) resolved[name] = value.trim();
|
|
1461
1455
|
continue;
|
|
1462
1456
|
}
|
|
1463
|
-
const path = `models.providers.${LLAMA_CPP_PROVIDER_ID}.headers
|
|
1457
|
+
const path = `models.providers.${LLAMA_CPP_PROVIDER_ID}.headers[${JSON.stringify(name)}]`;
|
|
1464
1458
|
const header = await resolveConfiguredSecretInputString({
|
|
1465
1459
|
config: params.config,
|
|
1466
1460
|
env: params.env ?? process.env,
|
|
@@ -1549,16 +1543,18 @@ function resolveInput(row, props) {
|
|
|
1549
1543
|
}
|
|
1550
1544
|
function buildCompat(props) {
|
|
1551
1545
|
const caps = props?.chat_template_caps;
|
|
1546
|
+
const supportsTools = asBoolean(caps?.supports_tool_calls) === true;
|
|
1547
|
+
const supportsTypedContent = asBoolean(caps?.supports_typed_content) === true;
|
|
1552
1548
|
return {
|
|
1553
1549
|
supportsStore: false,
|
|
1554
1550
|
supportsDeveloperRole: false,
|
|
1555
|
-
supportsReasoningEffort:
|
|
1551
|
+
supportsReasoningEffort: asBoolean(caps?.supports_reasoning_effort) === true,
|
|
1556
1552
|
supportsTemperature: true,
|
|
1557
1553
|
supportsUsageInStreaming: true,
|
|
1558
|
-
supportsTools
|
|
1554
|
+
supportsTools,
|
|
1559
1555
|
supportsStrictMode: false,
|
|
1560
1556
|
supportsJsonSchemaResponseFormat: true,
|
|
1561
|
-
requiresStringContent: !
|
|
1557
|
+
requiresStringContent: !supportsTypedContent,
|
|
1562
1558
|
maxTokensField: "max_tokens"
|
|
1563
1559
|
};
|
|
1564
1560
|
}
|
|
@@ -1567,17 +1563,18 @@ function mapLlamaServerModel(row, props) {
|
|
|
1567
1563
|
const id = typeof row.id === "string" ? row.id.trim() : "";
|
|
1568
1564
|
if (!id || row.object !== void 0 && row.object !== "model") return null;
|
|
1569
1565
|
const contextWindow = resolveContextWindow(props);
|
|
1566
|
+
const compat = buildCompat(props);
|
|
1570
1567
|
return {
|
|
1571
1568
|
config: {
|
|
1572
1569
|
id,
|
|
1573
1570
|
name: id,
|
|
1574
|
-
reasoning:
|
|
1571
|
+
reasoning: compat.supportsReasoningEffort === true,
|
|
1575
1572
|
input: resolveInput(row, props),
|
|
1576
1573
|
cost: { ...SELF_HOSTED_DEFAULT_COST },
|
|
1577
1574
|
contextWindow,
|
|
1578
1575
|
contextTokens: contextWindow,
|
|
1579
1576
|
maxTokens: resolveMaxTokens(props, contextWindow),
|
|
1580
|
-
compat
|
|
1577
|
+
compat
|
|
1581
1578
|
},
|
|
1582
1579
|
status: normalizeStatus(row.status?.value),
|
|
1583
1580
|
failed: row.status?.failed === true
|
|
@@ -2129,7 +2126,7 @@ function wrapLlamaServerStream(ctx) {
|
|
|
2129
2126
|
onPayload: async (payload, requestModel) => {
|
|
2130
2127
|
const customized = await onPayload?.(payload, requestModel) ?? payload;
|
|
2131
2128
|
if (isRecord(customized)) {
|
|
2132
|
-
if (ctx.thinkingLevel === "off") setQwenChatTemplateThinking(customized, false);
|
|
2129
|
+
if ((options?.reasoning ?? ctx.thinkingLevel) === "off") setQwenChatTemplateThinking(customized, false);
|
|
2133
2130
|
normalizeLlamaServerResponseFormat(customized, options?.responseFormat);
|
|
2134
2131
|
}
|
|
2135
2132
|
return customized;
|
|
@@ -2408,12 +2405,12 @@ async function runLlamaCppSetup(ctx) {
|
|
|
2408
2405
|
}
|
|
2409
2406
|
//#endregion
|
|
2410
2407
|
//#region extensions/llama-cpp/src/managed-provider.ts
|
|
2411
|
-
function
|
|
2408
|
+
function wrapLlamaCppStream(ctx) {
|
|
2409
|
+
const inner = wrapLlamaServerStream(ctx);
|
|
2412
2410
|
const providerConfig = ctx.config?.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
2413
|
-
if (!providerConfig?.localService) return;
|
|
2414
|
-
const inner = streamFn;
|
|
2411
|
+
if (!providerConfig?.localService) return inner;
|
|
2415
2412
|
const selectedModel = ctx.model;
|
|
2416
|
-
if (!
|
|
2413
|
+
if (!selectedModel) return;
|
|
2417
2414
|
return async (...args) => {
|
|
2418
2415
|
await ensureManagedLlamaServerForChat({
|
|
2419
2416
|
provider: providerConfig,
|
|
@@ -2492,11 +2489,8 @@ function registerLlamaCppProvider(api) {
|
|
|
2492
2489
|
normalizeConfig: ({ providerConfig }) => providerConfig.localService ? providerConfig : normalizeLlamaServerProviderConfig(providerConfig),
|
|
2493
2490
|
prepareDynamicModel: async (ctx) => ctx.config?.models?.providers?.["llama-cpp"]?.localService ? void 0 : await prepareLlamaServerDynamicModel(ctx),
|
|
2494
2491
|
reconcileLocalService: reconcileManagedLlamaServer,
|
|
2495
|
-
wrapSimpleCompletionStreamFn:
|
|
2496
|
-
wrapStreamFn:
|
|
2497
|
-
const streamFn = wrapLlamaServerStream(ctx);
|
|
2498
|
-
return ctx.config?.models?.providers?.["llama-cpp"]?.localService ? wrapManagedLlamaCppStream(ctx, streamFn) : streamFn;
|
|
2499
|
-
},
|
|
2492
|
+
wrapSimpleCompletionStreamFn: wrapLlamaCppStream,
|
|
2493
|
+
wrapStreamFn: wrapLlamaCppStream,
|
|
2500
2494
|
...buildProviderToolCompatFamilyHooks("llamacpp-gbnf"),
|
|
2501
2495
|
wizard: { modelPicker: {
|
|
2502
2496
|
label: "llama.cpp",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "
|
|
1
|
+
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-BYvyYdAs.mjs";
|
|
2
2
|
//#region extensions/llama-cpp/provider-policy-api.ts
|
|
3
3
|
function inspectEmbeddingProviderSetup(params) {
|
|
4
4
|
if (params.provider !== "local") return null;
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.6",
|
|
4
4
|
"description": "OpenClaw provider for managed and external llama.cpp servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
"./index.ts"
|
|
16
16
|
],
|
|
17
17
|
"install": {
|
|
18
|
+
"clawhubSpec": "clawhub:@openclaw/llama-cpp-provider",
|
|
18
19
|
"npmSpec": "@openclaw/llama-cpp-provider",
|
|
19
20
|
"defaultChoice": "npm",
|
|
20
21
|
"minHostVersion": ">=2026.6.2"
|
|
21
22
|
},
|
|
22
23
|
"compat": {
|
|
23
|
-
"pluginApi": ">=2026.9.
|
|
24
|
+
"pluginApi": ">=2026.9.6"
|
|
24
25
|
},
|
|
25
26
|
"build": {
|
|
26
|
-
"openclawVersion": "2026.9.
|
|
27
|
+
"openclawVersion": "2026.9.6"
|
|
27
28
|
},
|
|
28
29
|
"release": {
|
|
29
30
|
"bundleRuntimeDependencies": false,
|
|
@@ -34,13 +35,18 @@
|
|
|
34
35
|
"./dist/index.js"
|
|
35
36
|
]
|
|
36
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@openclaw/fs-safe": "0.18.1"
|
|
40
|
+
},
|
|
37
41
|
"files": [
|
|
38
42
|
"dist/**",
|
|
39
43
|
"openclaw.plugin.json",
|
|
40
|
-
"README.md"
|
|
44
|
+
"README.md",
|
|
45
|
+
"assets/icon.png",
|
|
46
|
+
"assets/activity.svg"
|
|
41
47
|
],
|
|
42
48
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.9.
|
|
49
|
+
"openclaw": ">=2026.9.6"
|
|
44
50
|
},
|
|
45
51
|
"peerDependenciesMeta": {
|
|
46
52
|
"openclaw": {
|