@openclaw/llama-cpp-provider 2026.9.6 → 2026.9.8

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/icon.png CHANGED
Binary file
@@ -9,9 +9,6 @@ const LLAMA_CPP_LOCAL_AUTH_MARKER = "llama-cpp-local";
9
9
  const LLAMA_CPP_DEFAULT_PORT = 19432;
10
10
  const LLAMA_CPP_READY_TIMEOUT_MS = 3e4;
11
11
  const LLAMA_CPP_IDLE_STOP_MS = 6e5;
12
- function resolveLlamaCppSyntheticApiKey() {
13
- return LLAMA_CPP_LOCAL_AUTH_MARKER;
14
- }
15
12
  const DEFAULT_LLAMA_CPP_MODEL_ID = "gemma-4-e4b-it-q4_k_m";
16
13
  const DEFAULT_LLAMA_CPP_MODEL_URI = "hf:unsloth/gemma-4-E4B-it-GGUF/gemma-4-E4B-it-Q4_K_M.gguf";
17
14
  const DEFAULT_LLAMA_CPP_MODEL_REVISION = "bfc15c382204943c3a8fff0c750b94ae2364d7a3";
@@ -62,12 +59,12 @@ function resolveCachedLlamaCppModelPath(params) {
62
59
  if (/^(?:hf:|https?:\/\/)/iu.test(source)) return null;
63
60
  return path.isAbsolute(source) ? source : path.resolve(cacheDir, source);
64
61
  }
65
- function buildDefaultLlamaCppModel() {
62
+ function buildLlamaCppModel(model) {
66
63
  return {
67
- id: DEFAULT_LLAMA_CPP_MODEL_ID,
68
- name: "Gemma 4 E4B (Q4_K_M)",
64
+ id: model.id,
65
+ name: model.name,
69
66
  api: "openai-completions",
70
- reasoning: false,
67
+ reasoning: model.reasoning ?? false,
71
68
  input: ["text"],
72
69
  cost: {
73
70
  input: 0,
@@ -77,9 +74,9 @@ function buildDefaultLlamaCppModel() {
77
74
  },
78
75
  contextWindow: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
79
76
  contextTokens: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
80
- maxTokens: 2048,
77
+ maxTokens: model.maxTokens ?? 2048,
81
78
  params: {
82
- modelPath: DEFAULT_LLAMA_CPP_MODEL_URI,
79
+ modelPath: model.source,
83
80
  contextSize: DEFAULT_LLAMA_CPP_CONTEXT_SIZE
84
81
  },
85
82
  compat: {
@@ -91,13 +88,17 @@ function buildDefaultLlamaCppModel() {
91
88
  }
92
89
  function buildLlamaCppProviderConfig(params = {}) {
93
90
  const { existing, managed, modelInventory } = params;
94
- const defaultModel = buildDefaultLlamaCppModel();
91
+ const defaultModel = buildLlamaCppModel({
92
+ id: DEFAULT_LLAMA_CPP_MODEL_ID,
93
+ name: "Gemma 4 E4B (Q4_K_M)",
94
+ source: DEFAULT_LLAMA_CPP_MODEL_URI
95
+ });
95
96
  const configuredModels = existing?.models ?? [];
96
97
  const models = modelInventory ?? (configuredModels.some((model) => model.id === defaultModel.id) ? configuredModels : [...configuredModels, defaultModel]);
97
98
  return {
98
99
  ...existing,
99
100
  baseUrl: managed?.baseUrl ?? existing?.baseUrl ?? `http://127.0.0.1:19432/v1`,
100
- apiKey: existing?.apiKey ?? resolveLlamaCppSyntheticApiKey(),
101
+ apiKey: existing?.apiKey ?? "llama-cpp-local",
101
102
  api: "openai-completions",
102
103
  timeoutSeconds: existing?.timeoutSeconds ?? 600,
103
104
  ...managed ? { localService: {
@@ -119,4 +120,4 @@ function resolveManagedLlamaCppProviderConfig(config) {
119
120
  return provider;
120
121
  }
121
122
  //#endregion
122
- export { resolveLlamaCppDataDir as C, resolveLlamaCppSyntheticApiKey as D, resolveLlamaCppModelSource as E, resolveLegacyLlamaCppModelCacheDir as S, resolveLlamaCppModelCacheDir as T, LLAMA_CPP_PROVIDER_ID as _, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as a, resolveCachedLlamaCppModelPath 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_LABEL as v, resolveLlamaCppEmbeddingModel as w, resolveHomePath as x, buildLlamaCppProviderConfig as y };
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 };
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 "./.setup/managed-provider-config-BYvyYdAs.mjs";
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";
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";
@@ -19,7 +19,7 @@ import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential
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
- import * as liveCatalogRuntime from "openclaw/plugin-sdk/provider-catalog-live-runtime";
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
25
  import { selectPreferredLocalModelId } from "openclaw/plugin-sdk/provider-model-shared";
@@ -35,6 +35,47 @@ const CUDA_ARCHIVE_LIMITS = {
35
35
  maxExtractedBytes: 600 * MEBIBYTE$1,
36
36
  maxEntryBytes: 521 * MEBIBYTE$1
37
37
  };
38
+ const WINDOWS_X64_VC_RUNTIME = {
39
+ archive: "vc-redist",
40
+ name: "VC_redist.x64.exe",
41
+ url: "https://download.visualstudio.microsoft.com/download/pr/ebdab8e5-1d7b-4d9f-a11b-cbb1720c3b12/843068991DAAA1F73AD9F6239BCE4D0F6A07A51F18C37EA2A867E9BECA71295C/VC_redist.x64.exe",
42
+ sha256: "843068991daaa1f73ad9f6239bce4d0f6a07a51f18c37ea2a867e9beca71295c",
43
+ size: 18731856,
44
+ containerOffset: 63e4,
45
+ containerSize: 18091661,
46
+ nestedCabinet: "a4",
47
+ files: [
48
+ {
49
+ source: "msvcp140.dll_amd64",
50
+ target: "msvcp140.dll"
51
+ },
52
+ {
53
+ source: "vcruntime140.dll_amd64",
54
+ target: "vcruntime140.dll"
55
+ },
56
+ {
57
+ source: "vcruntime140_1.dll_amd64",
58
+ target: "vcruntime140_1.dll"
59
+ }
60
+ ]
61
+ };
62
+ const WINDOWS_ARM64_VC_RUNTIME = {
63
+ archive: "vc-redist",
64
+ name: "VC_redist.arm64.exe",
65
+ url: "https://download.visualstudio.microsoft.com/download/pr/ece44298-3977-4f73-ab91-c13fe79cfea8/B70EF586669A620A0A30A1156969C05C6A3831DC8F8BC992DA75779D2A92F944/VC_redist.arm64.exe",
66
+ sha256: "b70ef586669a620a0a30a1156969c05c6a3831dc8f8bc992da75779d2a92f944",
67
+ size: 11870816,
68
+ containerOffset: 684112,
69
+ containerSize: 11176508,
70
+ nestedCabinet: "a1",
71
+ files: [{
72
+ source: "msvcp140.dll_arm64",
73
+ target: "msvcp140.dll"
74
+ }, {
75
+ source: "vcruntime140.dll_arm64",
76
+ target: "vcruntime140.dll"
77
+ }]
78
+ };
38
79
  const MACOS_ALIASES = [
39
80
  ["libggml-rpc.0.23.0.dylib", ["libggml-rpc.0.dylib", "libggml-rpc.dylib"]],
40
81
  ["libllama.0.4.0.dylib", ["libllama.0.dylib", "libllama.dylib"]],
@@ -124,7 +165,7 @@ const LLAMA_SERVER_ASSETS = [
124
165
  ...CUDA_ARCHIVE_LIMITS,
125
166
  maxEntries: 3
126
167
  }
127
- }]
168
+ }, WINDOWS_X64_VC_RUNTIME]
128
169
  },
129
170
  {
130
171
  platform: "win32",
@@ -135,7 +176,8 @@ const LLAMA_SERVER_ASSETS = [
135
176
  name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-arm64.zip`,
136
177
  sha256: "c1058fe5764a687275c8d20d6bbc1454e787cdbb8ebb8c37a2f959f2b144dc77",
137
178
  executable: "llama-server.exe",
138
- regularFileAliases: []
179
+ regularFileAliases: [],
180
+ dependencies: [WINDOWS_ARM64_VC_RUNTIME]
139
181
  },
140
182
  {
141
183
  platform: "win32",
@@ -146,7 +188,8 @@ const LLAMA_SERVER_ASSETS = [
146
188
  name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-x64.zip`,
147
189
  sha256: "9df3158ed228a641a4b127942d7f459f24c9e13f04682659d05c00c80099b6b5",
148
190
  executable: "llama-server.exe",
149
- regularFileAliases: []
191
+ regularFileAliases: [],
192
+ dependencies: [WINDOWS_X64_VC_RUNTIME]
150
193
  }
151
194
  ];
152
195
  function selectLlamaServerAsset(platform = process.platform, arch = process.arch, acceleration) {
@@ -181,7 +224,7 @@ const LLAMA_ARCHIVE_LIMITS = {
181
224
  maxMetaEntryBytes: MEBIBYTE
182
225
  };
183
226
  const MAX_ALIAS_BYTES = 512 * MEBIBYTE;
184
- function assertManifestBasename(filename) {
227
+ function assertManifestBasename$1(filename) {
185
228
  if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid llama-server archive manifest filename: ${filename}`);
186
229
  return filename;
187
230
  }
@@ -192,23 +235,23 @@ function resolveArchiveRoot(destDir, archiveRoot) {
192
235
  if (parts.some((part) => !part || part === "." || part === "..")) throw new Error(`invalid llama-server archive root: ${archiveRoot}`);
193
236
  return path.join(destDir, ...parts);
194
237
  }
195
- async function assertRegularFile(filePath, label) {
238
+ async function assertRegularFile$1(filePath, label) {
196
239
  const stat = await fs.lstat(filePath).catch(() => void 0);
197
240
  if (!stat?.isFile() || stat.nlink > 1) throw new Error(`llama-server archive does not contain regular ${label}`);
198
241
  return stat;
199
242
  }
200
243
  async function materializeAssetAliases(params) {
201
- const claimedNames = new Set(params.requiredFiles.map(assertManifestBasename));
202
- for (const file of claimedNames) await assertRegularFile(path.join(params.rootDir, file), `file ${file}`);
244
+ const claimedNames = new Set(params.requiredFiles.map(assertManifestBasename$1));
245
+ for (const file of claimedNames) await assertRegularFile$1(path.join(params.rootDir, file), `file ${file}`);
203
246
  let copiedBytes = 0;
204
247
  for (const [rawSource, rawAliases] of params.asset.regularFileAliases) {
205
- const source = assertManifestBasename(rawSource);
248
+ const source = assertManifestBasename$1(rawSource);
206
249
  if (claimedNames.has(source)) throw new Error(`duplicate llama-server archive manifest filename: ${source}`);
207
250
  claimedNames.add(source);
208
251
  const sourcePath = path.join(params.rootDir, source);
209
- const sourceStat = await assertRegularFile(sourcePath, `alias source ${source}`);
252
+ const sourceStat = await assertRegularFile$1(sourcePath, `alias source ${source}`);
210
253
  for (const rawAlias of rawAliases) {
211
- const alias = assertManifestBasename(rawAlias);
254
+ const alias = assertManifestBasename$1(rawAlias);
212
255
  if (claimedNames.has(alias)) throw new Error(`duplicate llama-server archive manifest filename: ${alias}`);
213
256
  claimedNames.add(alias);
214
257
  copiedBytes += sourceStat.size;
@@ -216,7 +259,7 @@ async function materializeAssetAliases(params) {
216
259
  const aliasPath = path.join(params.rootDir, alias);
217
260
  await fs.copyFile(sourcePath, aliasPath, constants.COPYFILE_EXCL);
218
261
  await fs.chmod(aliasPath, sourceStat.mode & 511);
219
- if ((await assertRegularFile(aliasPath, `alias ${alias}`)).size !== sourceStat.size) throw new Error(`llama-server archive alias copy is incomplete: ${alias}`);
262
+ if ((await assertRegularFile$1(aliasPath, `alias ${alias}`)).size !== sourceStat.size) throw new Error(`llama-server archive alias copy is incomplete: ${alias}`);
220
263
  }
221
264
  }
222
265
  }
@@ -264,6 +307,118 @@ async function extractLlamaServerDependencyArchive(params) {
264
307
  });
265
308
  }
266
309
  //#endregion
310
+ //#region extensions/llama-cpp/src/llama-server-vc-runtime.ts
311
+ const CAB_HEADER_SIZE = 12;
312
+ const COPY_BUFFER_SIZE = 1048576;
313
+ const EXPAND_TIMEOUT_MS = 6e4;
314
+ function assertManifestBasename(filename) {
315
+ if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid Visual C++ runtime manifest filename: ${filename}`);
316
+ return filename;
317
+ }
318
+ async function writeFully(handle, buffer, length) {
319
+ let offset = 0;
320
+ while (offset < length) {
321
+ const result = await handle.write(buffer, offset, length - offset);
322
+ if (result.bytesWritten <= 0) throw new Error("Visual C++ runtime container copy made no progress");
323
+ offset += result.bytesWritten;
324
+ }
325
+ }
326
+ async function extractPinnedContainer(params) {
327
+ const source = await fs.open(params.bundlePath, "r");
328
+ try {
329
+ const stat = await source.stat();
330
+ if (!stat.isFile() || stat.size !== params.asset.size) throw new Error(`Visual C++ runtime bundle size mismatch: expected ${params.asset.size}, got ${stat.size}`);
331
+ if (params.asset.containerOffset < 0 || params.asset.containerSize < CAB_HEADER_SIZE || params.asset.containerOffset + params.asset.containerSize > stat.size) throw new Error("invalid Visual C++ runtime container bounds");
332
+ const header = Buffer.alloc(CAB_HEADER_SIZE);
333
+ if ((await source.read(header, 0, header.length, params.asset.containerOffset)).bytesRead !== header.length || header.subarray(0, 4).toString("ascii") !== "MSCF" || header.readUInt32LE(8) !== params.asset.containerSize) throw new Error("Visual C++ runtime bundle does not contain the pinned cabinet");
334
+ const target = await fs.open(params.containerPath, "wx", 384);
335
+ try {
336
+ const buffer = Buffer.allocUnsafe(Math.min(COPY_BUFFER_SIZE, params.asset.containerSize));
337
+ let copied = 0;
338
+ while (copied < params.asset.containerSize) {
339
+ params.signal?.throwIfAborted();
340
+ const requested = Math.min(buffer.length, params.asset.containerSize - copied);
341
+ const result = await source.read(buffer, 0, requested, params.asset.containerOffset + copied);
342
+ if (result.bytesRead <= 0) throw new Error("Visual C++ runtime container ended before its pinned size");
343
+ await writeFully(target, buffer, result.bytesRead);
344
+ copied += result.bytesRead;
345
+ }
346
+ } finally {
347
+ await target.close();
348
+ }
349
+ } finally {
350
+ await source.close();
351
+ }
352
+ }
353
+ function resolveExpandCommand() {
354
+ const systemRoot = process.env.SystemRoot;
355
+ if (!systemRoot || !path.win32.isAbsolute(systemRoot)) throw new Error("SystemRoot is unavailable; cannot extract the Visual C++ runtime");
356
+ return path.win32.join(systemRoot, "System32", "expand.exe");
357
+ }
358
+ async function runExpand(command, args, signal) {
359
+ await new Promise((resolve, reject) => {
360
+ execFile(command, args, {
361
+ timeout: EXPAND_TIMEOUT_MS,
362
+ signal,
363
+ windowsHide: true
364
+ }, (error, _stdout, stderr) => {
365
+ if (error) {
366
+ const detail = stderr.trim();
367
+ reject(new Error(`Failed to extract the Visual C++ runtime${detail ? `: ${detail}` : ""}`, { cause: error }));
368
+ } else resolve();
369
+ });
370
+ });
371
+ }
372
+ async function assertRegularFile(filePath, label) {
373
+ const stat = await fs.lstat(filePath).catch(() => void 0);
374
+ if (!stat?.isFile() || stat.nlink > 1) throw new Error(`Visual C++ runtime does not contain regular file ${label}`);
375
+ }
376
+ /** Extracts the pinned Microsoft redistributable DLLs without installing machine-wide state. */
377
+ async function extractWindowsVcRuntime(params) {
378
+ const nestedCabinet = assertManifestBasename(params.asset.nestedCabinet);
379
+ const files = params.asset.files.map(({ source, target }) => ({
380
+ source: assertManifestBasename(source),
381
+ target: assertManifestBasename(target)
382
+ }));
383
+ if (new Set(files.map((file) => file.target)).size !== files.length) throw new Error("duplicate Visual C++ runtime target filename");
384
+ const expandCommand = resolveExpandCommand();
385
+ const containerPath = path.join(params.destDir, "bundle.cab");
386
+ const nestedDir = path.join(params.destDir, "nested");
387
+ const filesDir = path.join(params.destDir, "files");
388
+ await Promise.all([
389
+ fs.mkdir(params.destDir, { recursive: true }),
390
+ fs.mkdir(nestedDir, { recursive: true }),
391
+ fs.mkdir(filesDir, { recursive: true })
392
+ ]);
393
+ await extractPinnedContainer({
394
+ asset: params.asset,
395
+ bundlePath: params.bundlePath,
396
+ containerPath,
397
+ signal: params.signal
398
+ });
399
+ await runExpand(expandCommand, [
400
+ `-F:${nestedCabinet}`,
401
+ containerPath,
402
+ nestedDir
403
+ ], params.signal);
404
+ const nestedPath = path.join(nestedDir, nestedCabinet);
405
+ await assertRegularFile(nestedPath, nestedCabinet);
406
+ for (const file of files) {
407
+ params.signal?.throwIfAborted();
408
+ await runExpand(expandCommand, [
409
+ `-F:${file.source}`,
410
+ nestedPath,
411
+ filesDir
412
+ ], params.signal);
413
+ const sourcePath = path.join(filesDir, file.source);
414
+ await assertRegularFile(sourcePath, file.source);
415
+ const targetPath = path.join(params.destDir, file.target);
416
+ await fs.copyFile(sourcePath, targetPath, constants.COPYFILE_EXCL);
417
+ await assertRegularFile(targetPath, file.target);
418
+ }
419
+ return params.destDir;
420
+ }
421
+ //#endregion
267
422
  //#region extensions/llama-cpp/src/llama-server-install.ts
268
423
  const DOWNLOAD_TIMEOUT_MS = 18e5;
269
424
  const VERSION_TIMEOUT_MS = 15e3;
@@ -287,7 +442,7 @@ function assertSupportedLinuxRuntime(asset) {
287
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.`);
288
443
  }
289
444
  function assetUrl(asset) {
290
- return `https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_SERVER_RELEASE}/${asset.name}`;
445
+ return asset.url ?? `https://github.com/ggml-org/llama.cpp/releases/download/b10809/${asset.name}`;
291
446
  }
292
447
  const verifiedFiles = /* @__PURE__ */ new Map();
293
448
  const VERIFIED_FILE_LIMIT = 16;
@@ -413,26 +568,64 @@ async function runServerCommand(command, args, signal, timeoutMs = VERSION_TIMEO
413
568
  function formatRuntimeDependencyError(error) {
414
569
  const detail = error instanceof Error ? error.message : String(error);
415
570
  if (process.platform === "linux") return new Error(`The verified llama-server build could not start. Install the OpenMP runtime (for example libgomp1 on Debian/Ubuntu or libgomp on Fedora), then rerun llama.cpp setup. Detail: ${detail}`, { cause: error });
416
- if (process.platform === "win32") return new Error(`The verified llama-server build could not start. Install the Microsoft Visual C++ 2015-2022 Redistributable, then rerun llama.cpp setup. Detail: ${detail}`, { cause: error });
571
+ if (process.platform === "win32") return new Error(`The verified llama-server build could not start with its app-local Visual C++ runtime. Rerun llama.cpp setup to reinstall it, or configure a compatible llama-server manually. Detail: ${detail}`, { cause: error });
417
572
  return new Error(`The verified llama-server build could not start: ${detail}`, { cause: error });
418
573
  }
419
- async function validateInstalledServer(command, asset, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
420
- let version;
574
+ async function queryServerVersion(command, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
421
575
  try {
422
- version = await runServerCommand(command, ["--version"], signal, versionTimeoutMs);
576
+ return await runServerCommand(command, ["--version"], signal, versionTimeoutMs);
423
577
  } catch (error) {
424
578
  signal?.throwIfAborted();
425
579
  throw formatRuntimeDependencyError(error);
426
580
  }
581
+ }
582
+ function validateServerVersionOutput(command, version) {
427
583
  const match = (version.split(/\r?\n/u, 1)[0]?.trim() ?? "").match(/^version: .+ \(build (\d+), commit ([a-f\d]{9})\)$/u);
428
584
  const build = match?.[1] ? Number(match[1]) : void 0;
429
585
  const commit = match?.[2];
430
586
  if (build !== 10809 || commit !== "5266f24da75dc449bd56cbed7addb9c8e4a6a73e".slice(0, 9)) throw new Error(`Unexpected llama-server build at ${command}: expected ${LLAMA_SERVER_RELEASE} (${LLAMA_SERVER_COMMIT.slice(0, 9)}), got ${version || "no version output"}`);
587
+ }
588
+ async function validateCudaServer(command, asset, signal) {
431
589
  if (asset.backend === "cuda") {
432
590
  const devices = await runServerCommand(command, ["--list-devices"], signal);
433
591
  if (!/^\s*CUDA\d+: .+\(\d+ MiB, \d+ MiB free\)$/mu.test(devices)) throw new Error("The verified llama-server could not initialize an NVIDIA CUDA device. Update the NVIDIA driver and rerun setup, or configure a compatible llama-server manually. CPU fallback was not activated.");
434
592
  }
435
593
  }
594
+ async function validateInstalledServer(command, asset, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
595
+ validateServerVersionOutput(command, await queryServerVersion(command, signal, versionTimeoutMs));
596
+ await validateCudaServer(command, asset, signal);
597
+ }
598
+ async function stageLlamaServerDependency(params) {
599
+ const { dependency, extractDir, extractedRoot, index, options } = params;
600
+ options.signal?.throwIfAborted();
601
+ const dependencyArchive = path.join(extractDir, dependency.name);
602
+ await downloadVerifiedFile({
603
+ url: assetUrl(dependency),
604
+ destination: dependencyArchive,
605
+ expectedSha256: dependency.sha256,
606
+ expectedSize: dependency.archive === "vc-redist" ? dependency.size : void 0,
607
+ signal: options.signal,
608
+ onProgress: options.onProgress
609
+ });
610
+ const dependencyExtractDir = path.join(extractDir, `dependency-${index}`);
611
+ await fs.mkdir(dependencyExtractDir);
612
+ const dependencyRoot = dependency.archive === "vc-redist" ? await extractWindowsVcRuntime({
613
+ bundlePath: dependencyArchive,
614
+ destDir: dependencyExtractDir,
615
+ asset: dependency,
616
+ signal: options.signal
617
+ }) : await extractLlamaServerDependencyArchive({
618
+ archivePath: dependencyArchive,
619
+ destDir: dependencyExtractDir,
620
+ asset: dependency
621
+ });
622
+ for (const file of dependencyFiles(dependency)) await fs.copyFile(path.join(dependencyRoot, file), path.join(extractedRoot, file), fs$1.constants.COPYFILE_EXCL);
623
+ }
624
+ function formatVcRuntimeFallbackError(startupError, fallbackError) {
625
+ const startupDetail = startupError instanceof Error ? startupError.message : String(startupError);
626
+ const fallbackDetail = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
627
+ return new Error(`The extracted llama-server could not start with the installed Windows runtime, and its app-local Visual C++ runtime fallback did not restore it. Initial startup detail: ${startupDetail} Fallback detail: ${fallbackDetail}`, { cause: fallbackError });
628
+ }
436
629
  async function installLlamaServer(asset, options) {
437
630
  options.signal?.throwIfAborted();
438
631
  assertSupportedLinuxRuntime(asset);
@@ -461,28 +654,49 @@ async function installLlamaServer(asset, options) {
461
654
  asset
462
655
  });
463
656
  const extractedRoot = path.dirname(extractedCommand);
464
- for (const [index, dependency] of (asset.dependencies ?? []).entries()) {
465
- options.signal?.throwIfAborted();
466
- const dependencyArchive = path.join(extractDir, dependency.name);
467
- await downloadVerifiedFile({
468
- url: assetUrl(dependency),
469
- destination: dependencyArchive,
470
- expectedSha256: dependency.sha256,
471
- signal: options.signal,
472
- onProgress: options.onProgress
473
- });
474
- const dependencyExtractDir = path.join(extractDir, `dependency-${index}`);
475
- await fs.mkdir(dependencyExtractDir);
476
- const dependencyRoot = await extractLlamaServerDependencyArchive({
477
- archivePath: dependencyArchive,
478
- destDir: dependencyExtractDir,
479
- asset: dependency
480
- });
481
- for (const file of dependency.files) await fs.copyFile(path.join(dependencyRoot, file), path.join(extractedRoot, file), fs$1.constants.COPYFILE_EXCL);
482
- }
657
+ const dependencies = asset.dependencies ?? [];
658
+ const windowsRuntimeDependencies = [];
659
+ for (const [index, dependency] of dependencies.entries()) if (dependency.archive === "vc-redist") windowsRuntimeDependencies.push({
660
+ dependency,
661
+ index
662
+ });
663
+ else await stageLlamaServerDependency({
664
+ dependency,
665
+ index,
666
+ extractDir,
667
+ extractedRoot,
668
+ options
669
+ });
483
670
  options.signal?.throwIfAborted();
484
671
  await fs.chmod(extractedCommand, 493);
485
- await validateInstalledServer(extractedCommand, asset, options.signal, FRESH_VERSION_TIMEOUT_MS);
672
+ if (windowsRuntimeDependencies.length > 0) {
673
+ let version;
674
+ try {
675
+ version = await queryServerVersion(extractedCommand, options.signal, FRESH_VERSION_TIMEOUT_MS);
676
+ } catch (startupError) {
677
+ options.signal?.throwIfAborted();
678
+ try {
679
+ for (const { dependency, index } of windowsRuntimeDependencies) await stageLlamaServerDependency({
680
+ dependency,
681
+ index,
682
+ extractDir,
683
+ extractedRoot,
684
+ options
685
+ });
686
+ } catch (stagingError) {
687
+ options.signal?.throwIfAborted();
688
+ throw formatVcRuntimeFallbackError(startupError, stagingError);
689
+ }
690
+ try {
691
+ version = await queryServerVersion(extractedCommand, options.signal, FRESH_VERSION_TIMEOUT_MS);
692
+ } catch (retryError) {
693
+ options.signal?.throwIfAborted();
694
+ throw formatVcRuntimeFallbackError(startupError, retryError);
695
+ }
696
+ }
697
+ validateServerVersionOutput(extractedCommand, version);
698
+ await validateCudaServer(extractedCommand, asset, options.signal);
699
+ } else await validateInstalledServer(extractedCommand, asset, options.signal, FRESH_VERSION_TIMEOUT_MS);
486
700
  await fs.mkdir(path.dirname(installDir), { recursive: true });
487
701
  options.signal?.throwIfAborted();
488
702
  await fs.rm(installDir, {
@@ -499,6 +713,9 @@ async function installLlamaServer(asset, options) {
499
713
  })]);
500
714
  }
501
715
  }
716
+ function dependencyFiles(dependency) {
717
+ return dependency.archive === "vc-redist" ? dependency.files.map((file) => file.target) : dependency.files;
718
+ }
502
719
  async function ensureLlamaServerInstalled(options = {}) {
503
720
  options.signal?.throwIfAborted();
504
721
  const asset = options.asset ?? selectLlamaServerAsset();
@@ -728,31 +945,10 @@ const GIB = 1024 ** 3;
728
945
  function modelRecipe(params) {
729
946
  const source = params.source ?? `hf:${params.repository}/${params.file}#${params.revision}`;
730
947
  return {
731
- model: {
732
- id: params.id,
733
- name: params.name,
734
- api: "openai-completions",
735
- reasoning: params.reasoning ?? false,
736
- input: ["text"],
737
- cost: {
738
- input: 0,
739
- output: 0,
740
- cacheRead: 0,
741
- cacheWrite: 0
742
- },
743
- contextWindow: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
744
- contextTokens: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
745
- maxTokens: params.maxTokens ?? 2048,
746
- params: {
747
- modelPath: source,
748
- contextSize: DEFAULT_LLAMA_CPP_CONTEXT_SIZE
749
- },
750
- compat: {
751
- supportsTools: true,
752
- supportsUsageInStreaming: true,
753
- toolSchemaProfile: "llamacpp"
754
- }
755
- },
948
+ model: buildLlamaCppModel({
949
+ ...params,
950
+ source
951
+ }),
756
952
  sizeBytes: params.sizeBytes,
757
953
  memoryBytes: params.memoryGiB * GIB,
758
954
  minimumSystemMemoryBytes: params.minimumSystemGiB * GIB,
@@ -1289,11 +1485,8 @@ async function inspectLlamaServerRuntime(params) {
1289
1485
  //#endregion
1290
1486
  //#region extensions/llama-cpp/src/embedding-provider.ts
1291
1487
  const LOCAL_EMBEDDING_RUNTIME_FACTS = Symbol.for("openclaw.localEmbeddingRuntimeFacts");
1292
- function readLocalOptions(options) {
1293
- return options.local ?? {};
1294
- }
1295
1488
  function readIdentityLocalOptions(options) {
1296
- const local = readLocalOptions(options);
1489
+ const local = options.local ?? {};
1297
1490
  const provider = options.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
1298
1491
  return provider?.localService ? {
1299
1492
  ...local,
@@ -1309,39 +1502,30 @@ function createCacheKeyData(model, dimensions) {
1309
1502
  }
1310
1503
  function resolveModelIdentity(local, dimensions) {
1311
1504
  const embeddingModel = resolveLlamaCppEmbeddingModel(local);
1312
- const configuredCacheDir = embeddingModel.cacheDir;
1313
- const currentDefaultPath = path.resolve(configuredCacheDir, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE);
1314
- const legacyDefaultPath = path.resolve(resolveLegacyLlamaCppModelCacheDir(), DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE);
1315
- if (!embeddingModel.isDefault) return {
1316
- model: embeddingModel.source,
1317
- cacheKeyData: createCacheKeyData(embeddingModel.source, dimensions),
1318
- aliases: []
1319
- };
1320
- const aliases = /* @__PURE__ */ new Set([
1321
- currentDefaultPath,
1322
- legacyDefaultPath,
1323
- DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE
1324
- ]);
1325
- if (embeddingModel.source !== "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf") aliases.add(embeddingModel.source);
1505
+ const model = embeddingModel.isDefault ? DEFAULT_LLAMA_CPP_EMBEDDING_MODEL : embeddingModel.source;
1506
+ const aliases = /* @__PURE__ */ new Set();
1507
+ if (embeddingModel.isDefault) {
1508
+ aliases.add(path.resolve(embeddingModel.cacheDir, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE));
1509
+ aliases.add(path.resolve(resolveLegacyLlamaCppModelCacheDir(), DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE));
1510
+ aliases.add(DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE);
1511
+ if (embeddingModel.source !== model) aliases.add(embeddingModel.source);
1512
+ }
1326
1513
  return {
1327
- model: DEFAULT_LLAMA_CPP_EMBEDDING_MODEL,
1328
- cacheKeyData: createCacheKeyData(DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, dimensions),
1329
- aliases: [...aliases].map((model) => ({
1330
- model,
1331
- cacheKeyData: createCacheKeyData(model, dimensions)
1514
+ model,
1515
+ cacheKeyData: createCacheKeyData(model, dimensions),
1516
+ aliases: [...aliases].map((alias) => ({
1517
+ model: alias,
1518
+ cacheKeyData: createCacheKeyData(alias, dimensions)
1332
1519
  }))
1333
1520
  };
1334
1521
  }
1335
- function resolveConfiguredProvider(options) {
1336
- return resolveManagedLlamaCppProviderConfig(options.config);
1337
- }
1338
1522
  function resolveProviderPort(provider) {
1339
1523
  const port = Number(new URL(provider.baseUrl ?? "").port);
1340
1524
  if (!Number.isInteger(port) || port <= 0) throw new Error("Managed llama.cpp provider baseUrl must include a loopback port.");
1341
1525
  return port;
1342
1526
  }
1343
1527
  async function prepareEmbeddingServer(options, embeddingSource, embeddingModelIsDefault) {
1344
- const provider = resolveConfiguredProvider(options);
1528
+ const provider = resolveManagedLlamaCppProviderConfig(options.config);
1345
1529
  const embeddingModelPath = await ensureLlamaCppModel({
1346
1530
  source: embeddingSource,
1347
1531
  cacheDir: resolveLlamaCppModelCacheDir(provider),
@@ -1422,7 +1606,7 @@ const llamaCppEmbeddingProviderAdapter = {
1422
1606
  provider: wrapProvider({
1423
1607
  provider: result.provider,
1424
1608
  canonicalModel: identity.model,
1425
- baseUrl: resolveConfiguredProvider(options).baseUrl ?? ""
1609
+ baseUrl: resolveManagedLlamaCppProviderConfig(options.config).baseUrl ?? ""
1426
1610
  }),
1427
1611
  runtime: {
1428
1612
  id: "local",
@@ -1443,7 +1627,7 @@ function hasLlamaServerAuthorizationHeader(headers) {
1443
1627
  }
1444
1628
  function shouldUseLlamaServerSyntheticAuth(providerConfig) {
1445
1629
  const apiKey = normalizeOptionalSecretInput(providerConfig?.apiKey)?.trim();
1446
- return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !== resolveLlamaCppSyntheticApiKey() && apiKey !== CUSTOM_LOCAL_AUTH_MARKER);
1630
+ return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !== "llama-cpp-local" && apiKey !== CUSTOM_LOCAL_AUTH_MARKER);
1447
1631
  }
1448
1632
  async function resolveLlamaServerProviderHeaders(params) {
1449
1633
  const headers = asOptionalRecord(params.headers);
@@ -1483,14 +1667,10 @@ const LLAMA_SERVER_DEFAULT_ORIGIN = "http://127.0.0.1:8080";
1483
1667
  const LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR = "LLAMA_SERVER_API_KEY";
1484
1668
  //#endregion
1485
1669
  //#region extensions/llama-cpp/src/external-server/endpoint.ts
1486
- function toFetchableBaseUrl(value) {
1487
- if (/^[a-z][a-z\d+.-]*:\/\//iu.test(value)) return value;
1488
- return `http://${value}`;
1489
- }
1490
1670
  /** Resolves the server origin and its OpenAI-compatible `/v1` inference base. */
1491
1671
  function resolveLlamaServerEndpoint(configuredBaseUrl) {
1492
1672
  const configured = configuredBaseUrl?.trim() || "http://127.0.0.1:8080";
1493
- const parsed = new URL(toFetchableBaseUrl(configured));
1673
+ const parsed = new URL(/^[a-z][a-z\d+.-]*:\/\//iu.test(configured) ? configured : `http://${configured}`);
1494
1674
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`Unsupported llama-server protocol: ${parsed.protocol}`);
1495
1675
  if (parsed.username || parsed.password) throw new TypeError("llama-server base URL must not contain credentials");
1496
1676
  parsed.pathname = parsed.pathname.replace(/\/+$/u, "").replace(/\/v1$/iu, "") || "/";
@@ -1580,26 +1760,18 @@ function mapLlamaServerModel(row, props) {
1580
1760
  failed: row.status?.failed === true
1581
1761
  };
1582
1762
  }
1583
- /** Keeps explicit rows first and appends models discovered from the server. */
1584
- function mergeLlamaServerModels(params) {
1585
- const explicit = Array.isArray(params.explicitModels) ? params.explicitModels : [];
1586
- const merged = [...explicit];
1587
- const seen = new Set(explicit.map((model) => model.id));
1763
+ function buildLlamaServerProviderConfig(params) {
1764
+ const models = Array.isArray(params.configured?.models) ? [...params.configured.models] : [];
1765
+ const seen = new Set(models.map((model) => model.id));
1588
1766
  for (const discovered of params.discoveredModels) {
1589
1767
  if (seen.has(discovered.config.id)) continue;
1590
1768
  seen.add(discovered.config.id);
1591
- merged.push(discovered.config);
1769
+ models.push(discovered.config);
1592
1770
  }
1593
- return merged;
1594
- }
1595
- function buildLlamaServerProviderConfig(params) {
1596
1771
  return normalizeLlamaServerProviderConfig({
1597
1772
  ...params.configured,
1598
1773
  baseUrl: params.configured?.baseUrl ?? "http://127.0.0.1:8080",
1599
- models: mergeLlamaServerModels({
1600
- explicitModels: params.configured?.models,
1601
- discoveredModels: params.discoveredModels
1602
- })
1774
+ models
1603
1775
  });
1604
1776
  }
1605
1777
  //#endregion
@@ -1648,36 +1820,6 @@ async function discoverLlamaServer(params) {
1648
1820
  }
1649
1821
  //#endregion
1650
1822
  //#region extensions/llama-cpp/src/external-server/provider.ts
1651
- const liveCatalogSdk = liveCatalogRuntime;
1652
- async function runLlamaServerCatalog(params) {
1653
- if (liveCatalogSdk.runLiveProviderCatalog) return await liveCatalogSdk.runLiveProviderCatalog(params);
1654
- const identity = {
1655
- provider: params.providerId,
1656
- ...params.profileId ? { profileId: params.profileId } : {}
1657
- };
1658
- try {
1659
- const result = await params.run();
1660
- return result ? {
1661
- ...result,
1662
- outcomes: [...result.outcomes ?? [], {
1663
- ...identity,
1664
- status: "ready"
1665
- }]
1666
- } : result;
1667
- } catch (error) {
1668
- return {
1669
- providers: {},
1670
- outcomes: [error instanceof liveCatalogRuntime.LiveModelCatalogHttpError && (error.status === 401 || error.status === 403) ? {
1671
- ...identity,
1672
- status: "auth-rejected",
1673
- rejectionScope: "catalog"
1674
- } : {
1675
- ...identity,
1676
- status: "unavailable"
1677
- }]
1678
- };
1679
- }
1680
- }
1681
1823
  /** Discovers external llama-server models for provider runtime resolution. */
1682
1824
  async function discoverLlamaServerProvider(ctx) {
1683
1825
  const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
@@ -1689,7 +1831,7 @@ async function discoverLlamaServerProvider(ctx) {
1689
1831
  });
1690
1832
  const authApiKey = auth.discoveryApiKey ?? auth.apiKey;
1691
1833
  const apiKey = hasLlamaServerAuthorizationHeader(headers) || authApiKey && isNonSecretApiKeyMarker(authApiKey) ? void 0 : authApiKey;
1692
- return await runLlamaServerCatalog({
1834
+ return await runLiveProviderCatalog({
1693
1835
  providerId: LLAMA_CPP_PROVIDER_ID,
1694
1836
  profileId: apiKey ? auth.profileId : void 0,
1695
1837
  run: async () => {
@@ -1701,7 +1843,7 @@ async function discoverLlamaServerProvider(ctx) {
1701
1843
  });
1702
1844
  if (discovery.kind !== "success") {
1703
1845
  if (!configured && !apiKey && !headers) return null;
1704
- throw discovery.kind === "http-error" ? new liveCatalogRuntime.LiveModelCatalogHttpError(LLAMA_CPP_PROVIDER_ID, discovery.status) : discovery.error;
1846
+ throw discovery.kind === "http-error" ? new LiveModelCatalogHttpError(LLAMA_CPP_PROVIDER_ID, discovery.status) : discovery.error;
1705
1847
  }
1706
1848
  return { provider: buildLlamaServerProviderConfig({
1707
1849
  configured,
@@ -1878,15 +2020,6 @@ async function discoverForSetup(ctx) {
1878
2020
  return null;
1879
2021
  }
1880
2022
  }
1881
- async function discoverWithAccess(params) {
1882
- return await discoverLlamaServer({
1883
- baseUrl: params.baseUrl,
1884
- apiKey: params.apiKey,
1885
- headers: params.headers,
1886
- signal: params.signal,
1887
- cacheTtlMs: 0
1888
- });
1889
- }
1890
2023
  /** Read-only discovery for the guided local-provider setup ladder. */
1891
2024
  async function detectLlamaServerSetup(ctx) {
1892
2025
  const discovery = await discoverForSetup(ctx);
@@ -1971,11 +2104,12 @@ async function runLlamaServerSetup(ctx) {
1971
2104
  };
1972
2105
  }
1973
2106
  }
1974
- const discovery = await discoverWithAccess({
2107
+ const discovery = await discoverLlamaServer({
1975
2108
  baseUrl: endpoint.inferenceBaseUrl,
1976
2109
  apiKey,
1977
2110
  headers,
1978
- signal: ctx.signal
2111
+ signal: ctx.signal,
2112
+ cacheTtlMs: 0
1979
2113
  });
1980
2114
  if (discovery.kind !== "success") throw new Error(describeDiscoveryFailure(discovery));
1981
2115
  const modelId = selectSetupModelId(discovery);
@@ -2031,10 +2165,11 @@ async function validateNonInteractiveDiscovery(ctx) {
2031
2165
  credential: resolvedApiKey
2032
2166
  };
2033
2167
  } else persistence = { kind: "remove" };
2034
- const discovery = await discoverWithAccess({
2168
+ const discovery = await discoverLlamaServer({
2035
2169
  baseUrl,
2036
2170
  apiKey,
2037
- headers
2171
+ headers,
2172
+ cacheTtlMs: 0
2038
2173
  });
2039
2174
  if (discovery.kind !== "success") {
2040
2175
  ctx.runtime.error(describeDiscoveryFailure(discovery));
@@ -2065,9 +2200,7 @@ async function configureLlamaServerNonInteractive(ctx) {
2065
2200
  if (!validated) return null;
2066
2201
  const providerConfig = buildExistingProviderConfig({
2067
2202
  config: ctx.config,
2068
- discovery: validated.discovery,
2069
- resetEndpoint: validated.resetEndpoint,
2070
- persistence: validated.persistence
2203
+ ...validated
2071
2204
  });
2072
2205
  let config = {
2073
2206
  ...ctx.config,
@@ -2464,7 +2597,7 @@ function registerLlamaCppProvider(api) {
2464
2597
  },
2465
2598
  run: runLlamaServerSetup,
2466
2599
  validateNonInteractive: validateLlamaServerNonInteractive,
2467
- runNonInteractive: async (ctx) => await configureLlamaServerNonInteractive(ctx)
2600
+ runNonInteractive: configureLlamaServerNonInteractive
2468
2601
  }],
2469
2602
  catalog: {
2470
2603
  order: "late",
@@ -2481,11 +2614,11 @@ function registerLlamaCppProvider(api) {
2481
2614
  run: async () => ({ provider: buildLlamaCppProviderConfig() })
2482
2615
  },
2483
2616
  resolveSyntheticAuth: ({ providerConfig }) => providerConfig?.localService || shouldUseLlamaServerSyntheticAuth(providerConfig) ? {
2484
- apiKey: resolveLlamaCppSyntheticApiKey(),
2617
+ apiKey: LLAMA_CPP_LOCAL_AUTH_MARKER,
2485
2618
  source: providerConfig?.localService ? "managed local llama.cpp server" : hasLlamaServerAuthorizationHeader(providerConfig?.headers) ? "models.providers.llama-cpp.headers.Authorization" : "models.providers.llama-cpp (synthetic local key)",
2486
2619
  mode: "api-key"
2487
2620
  } : void 0,
2488
- shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() === resolveLlamaCppSyntheticApiKey() || resolvedApiKey?.trim() === CUSTOM_LOCAL_AUTH_MARKER,
2621
+ shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() === "llama-cpp-local" || resolvedApiKey?.trim() === CUSTOM_LOCAL_AUTH_MARKER,
2489
2622
  normalizeConfig: ({ providerConfig }) => providerConfig.localService ? providerConfig : normalizeLlamaServerProviderConfig(providerConfig),
2490
2623
  prepareDynamicModel: async (ctx) => ctx.config?.models?.providers?.["llama-cpp"]?.localService ? void 0 : await prepareLlamaServerDynamicModel(ctx),
2491
2624
  reconcileLocalService: reconcileManagedLlamaServer,
@@ -1,4 +1,4 @@
1
- import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-BYvyYdAs.mjs";
1
+ import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-B99gmBnE.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.6",
3
+ "version": "2026.9.8",
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.6"
24
+ "pluginApi": ">=2026.9.8"
25
25
  },
26
26
  "build": {
27
- "openclawVersion": "2026.9.6"
27
+ "openclawVersion": "2026.9.8"
28
28
  },
29
29
  "release": {
30
30
  "bundleRuntimeDependencies": false,
@@ -36,7 +36,7 @@
36
36
  ]
37
37
  },
38
38
  "dependencies": {
39
- "@openclaw/fs-safe": "0.18.1"
39
+ "@openclaw/fs-safe": "0.21.1"
40
40
  },
41
41
  "files": [
42
42
  "dist/**",
@@ -46,7 +46,7 @@
46
46
  "assets/activity.svg"
47
47
  ],
48
48
  "peerDependencies": {
49
- "openclaw": ">=2026.9.6"
49
+ "openclaw": ">=2026.9.8"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "openclaw": {