@openclaw/llama-cpp-provider 2026.9.33 → 2026.9.34
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/.setup/{managed-provider-config-B99gmBnE.mjs → managed-provider-config-D0abOkC_.mjs}
RENAMED
|
@@ -19,6 +19,7 @@ const DEFAULT_LLAMA_CPP_CONTEXT_SIZE = 65536;
|
|
|
19
19
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL = "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf";
|
|
20
20
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION = "66f974f8cd48cc3b9c41c516b95508e75b4bee64";
|
|
21
21
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID = "embeddinggemma-300m-qat-q8_0";
|
|
22
|
+
const DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE = 2048;
|
|
22
23
|
const DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE = "hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf";
|
|
23
24
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES = 328577056;
|
|
24
25
|
const DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 = "6fa0c02a9c302be6f977521d399b4de3a46310a4f2621ee0063747881b673f67";
|
|
@@ -120,4 +121,4 @@ function resolveManagedLlamaCppProviderConfig(config) {
|
|
|
120
121
|
return provider;
|
|
121
122
|
}
|
|
122
123
|
//#endregion
|
|
123
|
-
export {
|
|
124
|
+
export { resolveCachedLlamaCppModelPath as C, resolveLlamaCppEmbeddingModel as D, resolveLlamaCppDataDir as E, resolveLlamaCppModelCacheDir as O, buildLlamaCppProviderConfig as S, resolveLegacyLlamaCppModelCacheDir as T, LLAMA_CPP_DEFAULT_PORT as _, DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE as a, LLAMA_CPP_PROVIDER_LABEL as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION as c, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE as d, DEFAULT_LLAMA_CPP_MODEL_ID 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, resolveLlamaCppModelSource as k, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as l, DEFAULT_LLAMA_CPP_MODEL_SHA256 as m, resolveManagedLlamaCppProviderConfig as n, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as o, DEFAULT_LLAMA_CPP_MODEL_REVISION as p, DEFAULT_LLAMA_CPP_CONTEXT_SIZE as r, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as s, MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE as t, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as u, LLAMA_CPP_LOCAL_AUTH_MARKER as v, resolveHomePath as w, buildLlamaCppModel as x, LLAMA_CPP_PROVIDER_ID as y };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as resolveCachedLlamaCppModelPath, D as resolveLlamaCppEmbeddingModel, E as resolveLlamaCppDataDir, O as resolveLlamaCppModelCacheDir, S as buildLlamaCppProviderConfig, T as resolveLegacyLlamaCppModelCacheDir, _ as LLAMA_CPP_DEFAULT_PORT, a as DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE, b as LLAMA_CPP_PROVIDER_LABEL, c as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, d as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, f as DEFAULT_LLAMA_CPP_MODEL_ID, g as DEFAULT_LLAMA_CPP_MODEL_URI, h as DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES, i as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, k as resolveLlamaCppModelSource, l as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256, m as DEFAULT_LLAMA_CPP_MODEL_SHA256, n as resolveManagedLlamaCppProviderConfig, o as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, p as DEFAULT_LLAMA_CPP_MODEL_REVISION, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, u as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES, v as LLAMA_CPP_LOCAL_AUTH_MARKER, w as resolveHomePath, x as buildLlamaCppModel, y as LLAMA_CPP_PROVIDER_ID } from "./.setup/managed-provider-config-D0abOkC_.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";
|
|
@@ -434,13 +434,30 @@ function compareVersion(left, right) {
|
|
|
434
434
|
}
|
|
435
435
|
return 0;
|
|
436
436
|
}
|
|
437
|
+
/** The verified build cannot run on this host; rerunning setup cannot change that. */
|
|
438
|
+
var UnsupportedLlamaServerHostError = class extends Error {
|
|
439
|
+
constructor(..._args) {
|
|
440
|
+
super(..._args);
|
|
441
|
+
this.name = "UnsupportedLlamaServerHostError";
|
|
442
|
+
}
|
|
443
|
+
};
|
|
437
444
|
function assertSupportedLinuxRuntime(asset) {
|
|
438
445
|
if (asset.platform !== "linux") return;
|
|
439
446
|
const header = asOptionalRecord(asOptionalRecord(process.report?.getReport())?.header);
|
|
440
447
|
const glibc = typeof header?.glibcVersionRuntime === "string" ? header.glibcVersionRuntime : "";
|
|
441
|
-
if (!glibc) throw new
|
|
448
|
+
if (!glibc) throw new UnsupportedLlamaServerHostError("The verified Ubuntu llama-server build requires glibc and cannot run on musl/Alpine. Install llama-server manually for this host and configure its absolute path.");
|
|
442
449
|
const minimum = asset.arch === "arm64" ? "2.38" : "2.34";
|
|
443
|
-
if (compareVersion(glibc, minimum) < 0) throw new
|
|
450
|
+
if (compareVersion(glibc, minimum) < 0) throw new UnsupportedLlamaServerHostError(`The verified llama-server build requires glibc ${minimum}+ on Linux ${asset.arch}; this host has ${glibc}. Install a compatible llama-server manually and configure its absolute path.`);
|
|
451
|
+
}
|
|
452
|
+
const MACOS_MINIMUM = "13.3";
|
|
453
|
+
async function assertSupportedMacosRuntime(asset, signal, cause) {
|
|
454
|
+
if (asset.platform !== "darwin") return;
|
|
455
|
+
const version = await runServerCommand("/usr/bin/sw_vers", ["-productVersion"], signal).catch(() => {
|
|
456
|
+
signal?.throwIfAborted();
|
|
457
|
+
return "";
|
|
458
|
+
});
|
|
459
|
+
if (!/^\d+\.\d+(?:\.\d+)?$/u.test(version) || compareVersion(version, MACOS_MINIMUM) >= 0) return;
|
|
460
|
+
throw new UnsupportedLlamaServerHostError(`The verified llama-server ${LLAMA_SERVER_RELEASE} build requires macOS ${MACOS_MINIMUM}+; this Mac runs macOS ${version}. Build llama-server for this Mac and set models.providers.llama-cpp.localService.command to its absolute path, or use a remote model or embedding provider.`, cause === void 0 ? void 0 : { cause });
|
|
444
461
|
}
|
|
445
462
|
function assetUrl(asset) {
|
|
446
463
|
return asset.url ?? `https://github.com/ggml-org/llama.cpp/releases/download/b10809/${asset.name}`;
|
|
@@ -632,9 +649,15 @@ async function installLlamaServer(asset, options) {
|
|
|
632
649
|
assertSupportedLinuxRuntime(asset);
|
|
633
650
|
const { installDir, command } = resolveManagedLlamaServerPaths(asset);
|
|
634
651
|
if (await fs.stat(command).then((stat) => stat.isFile()).catch(() => false)) {
|
|
635
|
-
|
|
652
|
+
try {
|
|
653
|
+
await validateInstalledServer(command, asset, options.signal);
|
|
654
|
+
} catch (error) {
|
|
655
|
+
await assertSupportedMacosRuntime(asset, options.signal, error);
|
|
656
|
+
throw error;
|
|
657
|
+
}
|
|
636
658
|
return command;
|
|
637
659
|
}
|
|
660
|
+
await assertSupportedMacosRuntime(asset, options.signal);
|
|
638
661
|
const dataDir = resolveLlamaCppDataDir();
|
|
639
662
|
const archivePath = path.join(dataDir, `.download-${randomUUID()}-${asset.name}`);
|
|
640
663
|
const extractDir = path.join(dataDir, `.extract-${randomUUID()}`);
|
|
@@ -739,7 +762,6 @@ async function ensureLlamaServerInstalled(options = {}) {
|
|
|
739
762
|
}
|
|
740
763
|
//#endregion
|
|
741
764
|
//#region extensions/llama-cpp/src/llama-server-preset.ts
|
|
742
|
-
const LLAMA_CPP_EMBEDDING_UBATCH_SIZE = 2048;
|
|
743
765
|
function assertIniValue(value, label) {
|
|
744
766
|
if (/\r|\n/u.test(value)) throw new Error(`${label} cannot contain a newline`);
|
|
745
767
|
return value;
|
|
@@ -771,14 +793,26 @@ const PRESET_KEY_ALIASES = {
|
|
|
771
793
|
ub: "ubatch-size",
|
|
772
794
|
LLAMA_ARG_UBATCH: "ubatch-size",
|
|
773
795
|
embeddings: "embedding",
|
|
774
|
-
LLAMA_ARG_EMBEDDINGS: "embedding"
|
|
796
|
+
LLAMA_ARG_EMBEDDINGS: "embedding",
|
|
797
|
+
np: "parallel",
|
|
798
|
+
LLAMA_ARG_N_PARALLEL: "parallel",
|
|
799
|
+
LLAMA_ARG_KV_UNIFIED_PER_SLOT: "kv-unified-per-slot"
|
|
775
800
|
};
|
|
801
|
+
const PRESET_SETTING_PATTERN = /(?<![^\r\n])([a-zA-Z_][a-zA-Z0-9_.-]*)([ \t]*=[ \t]*)([^\r\n]*?)([ \t]*(?:[;#][^\r\n]*)?)(\r\n|\n|\r|(?![\s\S]))/g;
|
|
802
|
+
function readSettingKeys(section) {
|
|
803
|
+
return new Set([...(section ?? "").matchAll(PRESET_SETTING_PATTERN)].map(([, key = ""]) => PRESET_KEY_ALIASES[key] ?? key));
|
|
804
|
+
}
|
|
805
|
+
function readServiceSettingKeys(service) {
|
|
806
|
+
const caseInsensitiveEnv = process.platform === "win32";
|
|
807
|
+
const keys = [...Object.entries(service?.env ?? {}).filter(([, value]) => value !== void 0).map(([key]) => caseInsensitiveEnv ? key.toUpperCase() : key).filter((key) => key.startsWith("LLAMA_ARG_")), ...(service?.args ?? []).filter((arg) => arg.startsWith("-")).map((arg) => arg.startsWith("--") ? arg.slice(2).replaceAll("_", "-") : arg.slice(1))];
|
|
808
|
+
return new Set(keys.map((key) => PRESET_KEY_ALIASES[key] ?? key));
|
|
809
|
+
}
|
|
776
810
|
function updateModelSection(sections, id, values, newline) {
|
|
777
811
|
assertIniValue(id, "llama.cpp model id");
|
|
778
812
|
if (id.includes("]")) throw new Error("llama.cpp model ids cannot contain ]");
|
|
779
813
|
const name = [...sections.keys()].filter((candidate) => normalizePresetName(candidate) === normalizePresetName(id)).toSorted((left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right))).at(-1) ?? id;
|
|
780
814
|
const pending = new Set(Object.keys(values));
|
|
781
|
-
let contents = (sections.get(name) ?? `[${id}]${newline}`).replace(
|
|
815
|
+
let contents = (sections.get(name) ?? `[${id}]${newline}`).replace(PRESET_SETTING_PATTERN, (line, key, separator, _value, comment, ending) => {
|
|
782
816
|
const canonical = PRESET_KEY_ALIASES[key] ?? key;
|
|
783
817
|
if (!Object.hasOwn(values, canonical)) return line;
|
|
784
818
|
pending.delete(canonical);
|
|
@@ -800,11 +834,22 @@ function buildLlamaServerPreset(existing, params) {
|
|
|
800
834
|
}, newline);
|
|
801
835
|
const embeddingPath = params.embeddingModelPath ?? (!sections.has("embeddinggemma-300m-qat-q8_0") ? params.defaultEmbeddingModelPath : void 0);
|
|
802
836
|
if (embeddingPath) {
|
|
803
|
-
const
|
|
837
|
+
const configured = /* @__PURE__ */ new Set([
|
|
838
|
+
...readSettingKeys(sections.get(DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID)),
|
|
839
|
+
...readSettingKeys(sections.get("*")),
|
|
840
|
+
...readServiceSettingKeys(params.serviceSettings)
|
|
841
|
+
]);
|
|
842
|
+
const defaults = {
|
|
843
|
+
parallel: "1",
|
|
844
|
+
"ctx-size": String(DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE),
|
|
845
|
+
"ubatch-size": String(DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE)
|
|
846
|
+
};
|
|
847
|
+
if (configured.has("parallel") || configured.has("kv-unified-per-slot")) delete defaults["ctx-size"];
|
|
848
|
+
for (const key of configured) delete defaults[key];
|
|
804
849
|
updateModelSection(sections, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, {
|
|
805
850
|
model: assertIniValue(embeddingPath, "llama.cpp embedding model path"),
|
|
806
|
-
|
|
807
|
-
|
|
851
|
+
embedding: "true",
|
|
852
|
+
...defaults
|
|
808
853
|
}, newline);
|
|
809
854
|
}
|
|
810
855
|
const embeddingSection = sections.get(DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID);
|
|
@@ -1369,9 +1414,15 @@ async function prepareManagedLlamaServer(params) {
|
|
|
1369
1414
|
await updatePreset(presetPath, {
|
|
1370
1415
|
chatModel: params.chatModel,
|
|
1371
1416
|
configuredChatModelIds: params.configuredChatModelIds,
|
|
1372
|
-
embeddingModelIsDefault: params.embeddingModelIsDefault,
|
|
1373
1417
|
embeddingModelPath: params.embeddingModelPath,
|
|
1374
1418
|
defaultEmbeddingModelPath: params.defaultEmbeddingModelPath,
|
|
1419
|
+
serviceSettings: params.isolated ? { env: process.env } : {
|
|
1420
|
+
args: params.localService?.args,
|
|
1421
|
+
env: {
|
|
1422
|
+
...process.env,
|
|
1423
|
+
...params.localService?.env
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1375
1426
|
reconcileOrigin: params.isolated ? void 0 : reconcileOrigin
|
|
1376
1427
|
});
|
|
1377
1428
|
params.signal?.throwIfAborted();
|
|
@@ -1525,7 +1576,7 @@ function resolveProviderPort(provider) {
|
|
|
1525
1576
|
if (!Number.isInteger(port) || port <= 0) throw new Error("Managed llama.cpp provider baseUrl must include a loopback port.");
|
|
1526
1577
|
return port;
|
|
1527
1578
|
}
|
|
1528
|
-
async function prepareEmbeddingServer(options, embeddingSource
|
|
1579
|
+
async function prepareEmbeddingServer(options, embeddingSource) {
|
|
1529
1580
|
const provider = resolveManagedLlamaCppProviderConfig(options.config);
|
|
1530
1581
|
const embeddingModelPath = await ensureLlamaCppModel({
|
|
1531
1582
|
source: embeddingSource,
|
|
@@ -1535,7 +1586,6 @@ async function prepareEmbeddingServer(options, embeddingSource, embeddingModelIs
|
|
|
1535
1586
|
await prepareManagedLlamaServer({
|
|
1536
1587
|
chatModel: { mode: "preserve" },
|
|
1537
1588
|
configuredChatModelIds: provider.models.map((model) => model.id),
|
|
1538
|
-
embeddingModelIsDefault,
|
|
1539
1589
|
embeddingModelPath,
|
|
1540
1590
|
port: resolveProviderPort(provider),
|
|
1541
1591
|
reconcileBaseUrl: provider.baseUrl,
|
|
@@ -1565,7 +1615,7 @@ function wrapProvider(params) {
|
|
|
1565
1615
|
id: "local",
|
|
1566
1616
|
model: params.canonicalModel,
|
|
1567
1617
|
dimensions: params.provider.dimensions,
|
|
1568
|
-
maxInputTokens: params.provider.maxInputTokens,
|
|
1618
|
+
maxInputTokens: params.provider.maxInputTokens ?? 2044,
|
|
1569
1619
|
embed: async (input, callOptions) => await withFacts(async () => await params.provider.embed(input, callOptions)),
|
|
1570
1620
|
embedBatch: async (inputs, callOptions) => await withFacts(async () => await params.provider.embedBatch(inputs, callOptions)),
|
|
1571
1621
|
close: params.provider.close
|
|
@@ -1588,7 +1638,7 @@ const llamaCppEmbeddingProviderAdapter = {
|
|
|
1588
1638
|
const local = readIdentityLocalOptions(options);
|
|
1589
1639
|
const embeddingModel = resolveLlamaCppEmbeddingModel(local);
|
|
1590
1640
|
const identity = resolveModelIdentity(local, options.dimensions);
|
|
1591
|
-
await prepareEmbeddingServer(options, embeddingModel.source
|
|
1641
|
+
await prepareEmbeddingServer(options, embeddingModel.source);
|
|
1592
1642
|
const genericAdapter = getEmbeddingProvider("openai-compatible", options.config);
|
|
1593
1643
|
if (!genericAdapter) throw new Error("OpenAI-compatible embedding transport is unavailable.");
|
|
1594
1644
|
const acquireLocalService = options.acquireLocalService;
|
|
@@ -2485,6 +2535,11 @@ async function runLlamaCppSetup(ctx) {
|
|
|
2485
2535
|
if (!plan) return { profiles: [] };
|
|
2486
2536
|
const progress = ctx.prompter.progress("Preparing managed llama.cpp server…");
|
|
2487
2537
|
try {
|
|
2538
|
+
await ensureLlamaServerInstalled({
|
|
2539
|
+
asset,
|
|
2540
|
+
signal: ctx.signal,
|
|
2541
|
+
onProgress: (status) => progress.update(formatDownloadProgress("llama.cpp runtime", status))
|
|
2542
|
+
});
|
|
2488
2543
|
let chatModel;
|
|
2489
2544
|
if (plan.kind === "chat") {
|
|
2490
2545
|
const chatModelPath = plan.cachedPath ?? await ensureLlamaCppModel({
|
|
@@ -2514,7 +2569,6 @@ async function runLlamaCppSetup(ctx) {
|
|
|
2514
2569
|
const managed = await prepareManagedLlamaServer({
|
|
2515
2570
|
chatModel,
|
|
2516
2571
|
configuredChatModelIds: plan.kind === "chat" ? plan.candidate.provider.models.map((model) => model.id) : [],
|
|
2517
|
-
embeddingModelIsDefault: embeddingModel.isDefault,
|
|
2518
2572
|
embeddingModelPath,
|
|
2519
2573
|
asset,
|
|
2520
2574
|
isolated: true,
|
|
@@ -2535,7 +2589,7 @@ async function runLlamaCppSetup(ctx) {
|
|
|
2535
2589
|
} catch (error) {
|
|
2536
2590
|
progress.stop("llama.cpp setup failed");
|
|
2537
2591
|
const detail = error instanceof Error ? error.message : String(error);
|
|
2538
|
-
throw new Error(`Managed llama.cpp setup failed. Run openclaw doctor, fix the reported runtime or model issue, then retry. ${detail}`, { cause: error });
|
|
2592
|
+
throw new Error(error instanceof UnsupportedLlamaServerHostError ? `Managed llama.cpp setup is unavailable on this host. ${detail}` : `Managed llama.cpp setup failed. Run openclaw doctor, fix the reported runtime or model issue, then retry. ${detail}`, { cause: error });
|
|
2539
2593
|
}
|
|
2540
2594
|
}
|
|
2541
2595
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-
|
|
1
|
+
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-D0abOkC_.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.34",
|
|
4
4
|
"description": "OpenClaw provider for managed and external llama.cpp servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"minHostVersion": ">=2026.6.2"
|
|
22
22
|
},
|
|
23
23
|
"compat": {
|
|
24
|
-
"pluginApi": ">=2026.9.
|
|
24
|
+
"pluginApi": ">=2026.9.34"
|
|
25
25
|
},
|
|
26
26
|
"build": {
|
|
27
|
-
"openclawVersion": "2026.9.
|
|
27
|
+
"openclawVersion": "2026.9.34"
|
|
28
28
|
},
|
|
29
29
|
"release": {
|
|
30
30
|
"bundleRuntimeDependencies": false,
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"assets/activity.svg"
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"openclaw": ">=2026.9.
|
|
49
|
+
"openclaw": ">=2026.9.34"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"openclaw": {
|