@openclaw/llama-cpp-provider 2026.9.9 → 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.
@@ -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 { resolveHomePath as C, resolveLlamaCppModelCacheDir as D, resolveLlamaCppEmbeddingModel as E, resolveLlamaCppModelSource as O, resolveCachedLlamaCppModelPath as S, resolveLlamaCppDataDir as T, LLAMA_CPP_LOCAL_AUTH_MARKER as _, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as a, buildLlamaCppModel as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as c, DEFAULT_LLAMA_CPP_MODEL_ID as d, DEFAULT_LLAMA_CPP_MODEL_REVISION as f, LLAMA_CPP_DEFAULT_PORT as g, DEFAULT_LLAMA_CPP_MODEL_URI as h, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE as i, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as l, DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES as m, resolveManagedLlamaCppProviderConfig as n, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as o, DEFAULT_LLAMA_CPP_MODEL_SHA256 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, buildLlamaCppProviderConfig as x, LLAMA_CPP_PROVIDER_LABEL as y };
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 resolveHomePath, D as resolveLlamaCppModelCacheDir, E as resolveLlamaCppEmbeddingModel, O as resolveLlamaCppModelSource, S as resolveCachedLlamaCppModelPath, T as resolveLlamaCppDataDir, _ as LLAMA_CPP_LOCAL_AUTH_MARKER, a as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, b as buildLlamaCppModel, 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, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, u as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, v as LLAMA_CPP_PROVIDER_ID, w as resolveLegacyLlamaCppModelCacheDir, x as buildLlamaCppProviderConfig, y as LLAMA_CPP_PROVIDER_LABEL } from "./.setup/managed-provider-config-B99gmBnE.mjs";
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";
@@ -15,13 +15,14 @@ import fs$1, { constants } from "node:fs";
15
15
  import { sha256File } from "@openclaw/fs-safe/durability";
16
16
  import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
17
17
  import { ARCHIVE_LIMIT_ERROR_CODE, ArchiveLimitError, extractArchive } from "openclaw/plugin-sdk/archive";
18
- import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput, upsertAuthProfileWithLock } from "openclaw/plugin-sdk/provider-auth";
18
+ import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput } from "openclaw/plugin-sdk/provider-auth";
19
19
  import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
20
20
  import { removeAuthProfileConfig, removeProviderAuthProfilesWithLock, resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
21
21
  import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
22
22
  import { LiveModelCatalogHttpError, runLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
23
23
  import { getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
24
24
  import { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, applyProviderDefaultModel, discoverOpenAICompatibleLocalModels } from "openclaw/plugin-sdk/provider-setup";
25
+ import { upsertAuthProfileWithLockOrThrow } from "openclaw/plugin-sdk/provider-auth-api-key";
25
26
  import { selectPreferredLocalModelId } from "openclaw/plugin-sdk/provider-model-shared";
26
27
  import { streamSimple } from "openclaw/plugin-sdk/llm";
27
28
  import { setQwenChatTemplateThinking } from "openclaw/plugin-sdk/provider-stream-shared";
@@ -433,13 +434,30 @@ function compareVersion(left, right) {
433
434
  }
434
435
  return 0;
435
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
+ };
436
444
  function assertSupportedLinuxRuntime(asset) {
437
445
  if (asset.platform !== "linux") return;
438
446
  const header = asOptionalRecord(asOptionalRecord(process.report?.getReport())?.header);
439
447
  const glibc = typeof header?.glibcVersionRuntime === "string" ? header.glibcVersionRuntime : "";
440
- if (!glibc) throw new Error("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.");
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.");
441
449
  const minimum = asset.arch === "arm64" ? "2.38" : "2.34";
442
- if (compareVersion(glibc, minimum) < 0) throw new Error(`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.`);
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 });
443
461
  }
444
462
  function assetUrl(asset) {
445
463
  return asset.url ?? `https://github.com/ggml-org/llama.cpp/releases/download/b10809/${asset.name}`;
@@ -631,9 +649,15 @@ async function installLlamaServer(asset, options) {
631
649
  assertSupportedLinuxRuntime(asset);
632
650
  const { installDir, command } = resolveManagedLlamaServerPaths(asset);
633
651
  if (await fs.stat(command).then((stat) => stat.isFile()).catch(() => false)) {
634
- await validateInstalledServer(command, asset, options.signal);
652
+ try {
653
+ await validateInstalledServer(command, asset, options.signal);
654
+ } catch (error) {
655
+ await assertSupportedMacosRuntime(asset, options.signal, error);
656
+ throw error;
657
+ }
635
658
  return command;
636
659
  }
660
+ await assertSupportedMacosRuntime(asset, options.signal);
637
661
  const dataDir = resolveLlamaCppDataDir();
638
662
  const archivePath = path.join(dataDir, `.download-${randomUUID()}-${asset.name}`);
639
663
  const extractDir = path.join(dataDir, `.extract-${randomUUID()}`);
@@ -738,7 +762,6 @@ async function ensureLlamaServerInstalled(options = {}) {
738
762
  }
739
763
  //#endregion
740
764
  //#region extensions/llama-cpp/src/llama-server-preset.ts
741
- const LLAMA_CPP_EMBEDDING_UBATCH_SIZE = 2048;
742
765
  function assertIniValue(value, label) {
743
766
  if (/\r|\n/u.test(value)) throw new Error(`${label} cannot contain a newline`);
744
767
  return value;
@@ -770,14 +793,26 @@ const PRESET_KEY_ALIASES = {
770
793
  ub: "ubatch-size",
771
794
  LLAMA_ARG_UBATCH: "ubatch-size",
772
795
  embeddings: "embedding",
773
- 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"
774
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
+ }
775
810
  function updateModelSection(sections, id, values, newline) {
776
811
  assertIniValue(id, "llama.cpp model id");
777
812
  if (id.includes("]")) throw new Error("llama.cpp model ids cannot contain ]");
778
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;
779
814
  const pending = new Set(Object.keys(values));
780
- let contents = (sections.get(name) ?? `[${id}]${newline}`).replace(/(?<![^\r\n])([a-zA-Z_][a-zA-Z0-9_.-]*)([ \t]*=[ \t]*)([^\r\n]*?)([ \t]*(?:[;#][^\r\n]*)?)(\r\n|\n|\r|(?![\s\S]))/g, (line, key, separator, _value, comment, ending) => {
815
+ let contents = (sections.get(name) ?? `[${id}]${newline}`).replace(PRESET_SETTING_PATTERN, (line, key, separator, _value, comment, ending) => {
781
816
  const canonical = PRESET_KEY_ALIASES[key] ?? key;
782
817
  if (!Object.hasOwn(values, canonical)) return line;
783
818
  pending.delete(canonical);
@@ -799,11 +834,22 @@ function buildLlamaServerPreset(existing, params) {
799
834
  }, newline);
800
835
  const embeddingPath = params.embeddingModelPath ?? (!sections.has("embeddinggemma-300m-qat-q8_0") ? params.defaultEmbeddingModelPath : void 0);
801
836
  if (embeddingPath) {
802
- const isDefault = params.embeddingModelPath ? params.embeddingModelIsDefault : true;
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];
803
849
  updateModelSection(sections, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, {
804
850
  model: assertIniValue(embeddingPath, "llama.cpp embedding model path"),
805
- ...isDefault ? { "ubatch-size": String(LLAMA_CPP_EMBEDDING_UBATCH_SIZE) } : {},
806
- embedding: "true"
851
+ embedding: "true",
852
+ ...defaults
807
853
  }, newline);
808
854
  }
809
855
  const embeddingSection = sections.get(DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID);
@@ -1368,9 +1414,15 @@ async function prepareManagedLlamaServer(params) {
1368
1414
  await updatePreset(presetPath, {
1369
1415
  chatModel: params.chatModel,
1370
1416
  configuredChatModelIds: params.configuredChatModelIds,
1371
- embeddingModelIsDefault: params.embeddingModelIsDefault,
1372
1417
  embeddingModelPath: params.embeddingModelPath,
1373
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
+ },
1374
1426
  reconcileOrigin: params.isolated ? void 0 : reconcileOrigin
1375
1427
  });
1376
1428
  params.signal?.throwIfAborted();
@@ -1524,7 +1576,7 @@ function resolveProviderPort(provider) {
1524
1576
  if (!Number.isInteger(port) || port <= 0) throw new Error("Managed llama.cpp provider baseUrl must include a loopback port.");
1525
1577
  return port;
1526
1578
  }
1527
- async function prepareEmbeddingServer(options, embeddingSource, embeddingModelIsDefault) {
1579
+ async function prepareEmbeddingServer(options, embeddingSource) {
1528
1580
  const provider = resolveManagedLlamaCppProviderConfig(options.config);
1529
1581
  const embeddingModelPath = await ensureLlamaCppModel({
1530
1582
  source: embeddingSource,
@@ -1534,7 +1586,6 @@ async function prepareEmbeddingServer(options, embeddingSource, embeddingModelIs
1534
1586
  await prepareManagedLlamaServer({
1535
1587
  chatModel: { mode: "preserve" },
1536
1588
  configuredChatModelIds: provider.models.map((model) => model.id),
1537
- embeddingModelIsDefault,
1538
1589
  embeddingModelPath,
1539
1590
  port: resolveProviderPort(provider),
1540
1591
  reconcileBaseUrl: provider.baseUrl,
@@ -1564,7 +1615,7 @@ function wrapProvider(params) {
1564
1615
  id: "local",
1565
1616
  model: params.canonicalModel,
1566
1617
  dimensions: params.provider.dimensions,
1567
- maxInputTokens: params.provider.maxInputTokens,
1618
+ maxInputTokens: params.provider.maxInputTokens ?? 2044,
1568
1619
  embed: async (input, callOptions) => await withFacts(async () => await params.provider.embed(input, callOptions)),
1569
1620
  embedBatch: async (inputs, callOptions) => await withFacts(async () => await params.provider.embedBatch(inputs, callOptions)),
1570
1621
  close: params.provider.close
@@ -1587,7 +1638,7 @@ const llamaCppEmbeddingProviderAdapter = {
1587
1638
  const local = readIdentityLocalOptions(options);
1588
1639
  const embeddingModel = resolveLlamaCppEmbeddingModel(local);
1589
1640
  const identity = resolveModelIdentity(local, options.dimensions);
1590
- await prepareEmbeddingServer(options, embeddingModel.source, embeddingModel.isDefault);
1641
+ await prepareEmbeddingServer(options, embeddingModel.source);
1591
1642
  const genericAdapter = getEmbeddingProvider("openai-compatible", options.config);
1592
1643
  if (!genericAdapter) throw new Error("OpenAI-compatible embedding transport is unavailable.");
1593
1644
  const acquireLocalService = options.acquireLocalService;
@@ -2219,7 +2270,7 @@ async function configureLlamaServerNonInteractive(ctx) {
2219
2270
  resolved: validated.persistence.credential
2220
2271
  });
2221
2272
  if (!credential) return null;
2222
- await upsertAuthProfileWithLock({
2273
+ await upsertAuthProfileWithLockOrThrow({
2223
2274
  profileId: LLAMA_CPP_DEFAULT_PROFILE_ID,
2224
2275
  credential,
2225
2276
  agentDir: ctx.agentDir
@@ -2279,19 +2330,20 @@ function formatDownloadProgress(label, params) {
2279
2330
  function describeEmbeddingDownload(isDefault) {
2280
2331
  return isDefault ? "the local embedding model (about 0.3 GB)" : "your configured local embedding model";
2281
2332
  }
2282
- function readPrimaryModel(config) {
2283
- const model = config.agents?.defaults?.model;
2284
- return typeof model === "string" ? model : model?.primary;
2285
- }
2286
- function configuredCandidates(config, scope) {
2333
+ async function configuredCandidates(config, scope) {
2287
2334
  const existing = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
2288
2335
  const managedExisting = existing?.localService ? existing : void 0;
2289
2336
  const provider = buildLlamaCppProviderConfig({
2290
2337
  existing: managedExisting,
2291
2338
  ...managedExisting && scope === "detection" ? { modelInventory: managedExisting.models } : {}
2292
2339
  });
2293
- const primary = readPrimaryModel(config);
2294
- const primaryId = primary?.startsWith(`llama-cpp/`) ? primary.slice(LLAMA_CPP_PROVIDER_ID.length + 1) : void 0;
2340
+ const { resolveDefaultModelForAgent } = await import("openclaw/plugin-sdk/agent-runtime");
2341
+ const primary = resolveDefaultModelForAgent({
2342
+ cfg: config,
2343
+ allowManifestNormalization: false,
2344
+ allowPluginNormalization: false
2345
+ });
2346
+ const primaryId = primary.provider === "llama-cpp" ? primary.model : void 0;
2295
2347
  return provider.models.map((model) => ({
2296
2348
  model,
2297
2349
  provider
@@ -2344,7 +2396,7 @@ async function detectLlamaCppSetup(ctx) {
2344
2396
  const command = existing?.localService?.command;
2345
2397
  const presetPath = existing?.localService?.args?.find((_, index, args) => args[index - 1] === "--models-preset");
2346
2398
  if (!command || !path.isAbsolute(command) || !await isFile(command) || !presetPath || !await isFile(presetPath)) return null;
2347
- for (const candidate of configuredCandidates(ctx.config, "detection")) if (await resolveCachedCandidate(candidate, ctx.signal)) return {
2399
+ for (const candidate of await configuredCandidates(ctx.config, "detection")) if (await resolveCachedCandidate(candidate, ctx.signal)) return {
2348
2400
  modelRef: `${LLAMA_CPP_PROVIDER_ID}/${candidate.model.id}`,
2349
2401
  detail: "Managed llama.cpp server ready"
2350
2402
  };
@@ -2479,10 +2531,15 @@ async function runLlamaCppSetup(ctx) {
2479
2531
  asset = selectLlamaServerAsset(hardware.platform, hardware.arch, { kind: "cpu" });
2480
2532
  runtimeNote = `${error instanceof Error ? error.message : String(error)} This recommendation uses CPU execution.`;
2481
2533
  }
2482
- const plan = await resolveSetupPlan(ctx, configuredCandidates(ctx.config, "setup"), embeddingModel.isDefault, embeddingSetup.localMemoryIntent, hardware, asset, runtimeNote);
2534
+ const plan = await resolveSetupPlan(ctx, await configuredCandidates(ctx.config, "setup"), embeddingModel.isDefault, embeddingSetup.localMemoryIntent, hardware, asset, runtimeNote);
2483
2535
  if (!plan) return { profiles: [] };
2484
2536
  const progress = ctx.prompter.progress("Preparing managed llama.cpp server…");
2485
2537
  try {
2538
+ await ensureLlamaServerInstalled({
2539
+ asset,
2540
+ signal: ctx.signal,
2541
+ onProgress: (status) => progress.update(formatDownloadProgress("llama.cpp runtime", status))
2542
+ });
2486
2543
  let chatModel;
2487
2544
  if (plan.kind === "chat") {
2488
2545
  const chatModelPath = plan.cachedPath ?? await ensureLlamaCppModel({
@@ -2512,7 +2569,6 @@ async function runLlamaCppSetup(ctx) {
2512
2569
  const managed = await prepareManagedLlamaServer({
2513
2570
  chatModel,
2514
2571
  configuredChatModelIds: plan.kind === "chat" ? plan.candidate.provider.models.map((model) => model.id) : [],
2515
- embeddingModelIsDefault: embeddingModel.isDefault,
2516
2572
  embeddingModelPath,
2517
2573
  asset,
2518
2574
  isolated: true,
@@ -2533,7 +2589,7 @@ async function runLlamaCppSetup(ctx) {
2533
2589
  } catch (error) {
2534
2590
  progress.stop("llama.cpp setup failed");
2535
2591
  const detail = error instanceof Error ? error.message : String(error);
2536
- 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 });
2537
2593
  }
2538
2594
  }
2539
2595
  //#endregion
@@ -1,4 +1,4 @@
1
- import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-B99gmBnE.mjs";
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.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.9"
24
+ "pluginApi": ">=2026.9.34"
25
25
  },
26
26
  "build": {
27
- "openclawVersion": "2026.9.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.9"
49
+ "openclaw": ">=2026.9.34"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "openclaw": {