@openclaw/llama-cpp-provider 2026.9.7 → 2026.10.1-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +269 -50
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@ 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";
5
5
  import os from "node:os";
6
- import { asBoolean, asOptionalRecord, asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
6
+ import { asOptionalRecord, asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
7
7
  import { createHash, randomUUID } from "node:crypto";
8
8
  import fs from "node:fs/promises";
9
9
  import net from "node:net";
10
+ import { createAsyncLock } from "openclaw/plugin-sdk/async-lock-runtime";
10
11
  import { readProviderJsonResponse, readProviderTextResponse } from "openclaw/plugin-sdk/provider-http";
11
12
  import { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } from "openclaw/plugin-sdk/ssrf-runtime";
12
13
  import { fetchConfiguredLocalOriginWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime-internal";
@@ -35,6 +36,47 @@ const CUDA_ARCHIVE_LIMITS = {
35
36
  maxExtractedBytes: 600 * MEBIBYTE$1,
36
37
  maxEntryBytes: 521 * MEBIBYTE$1
37
38
  };
39
+ const WINDOWS_X64_VC_RUNTIME = {
40
+ archive: "vc-redist",
41
+ name: "VC_redist.x64.exe",
42
+ url: "https://download.visualstudio.microsoft.com/download/pr/ebdab8e5-1d7b-4d9f-a11b-cbb1720c3b12/843068991DAAA1F73AD9F6239BCE4D0F6A07A51F18C37EA2A867E9BECA71295C/VC_redist.x64.exe",
43
+ sha256: "843068991daaa1f73ad9f6239bce4d0f6a07a51f18c37ea2a867e9beca71295c",
44
+ size: 18731856,
45
+ containerOffset: 63e4,
46
+ containerSize: 18091661,
47
+ nestedCabinet: "a4",
48
+ files: [
49
+ {
50
+ source: "msvcp140.dll_amd64",
51
+ target: "msvcp140.dll"
52
+ },
53
+ {
54
+ source: "vcruntime140.dll_amd64",
55
+ target: "vcruntime140.dll"
56
+ },
57
+ {
58
+ source: "vcruntime140_1.dll_amd64",
59
+ target: "vcruntime140_1.dll"
60
+ }
61
+ ]
62
+ };
63
+ const WINDOWS_ARM64_VC_RUNTIME = {
64
+ archive: "vc-redist",
65
+ name: "VC_redist.arm64.exe",
66
+ url: "https://download.visualstudio.microsoft.com/download/pr/ece44298-3977-4f73-ab91-c13fe79cfea8/B70EF586669A620A0A30A1156969C05C6A3831DC8F8BC992DA75779D2A92F944/VC_redist.arm64.exe",
67
+ sha256: "b70ef586669a620a0a30a1156969c05c6a3831dc8f8bc992da75779d2a92f944",
68
+ size: 11870816,
69
+ containerOffset: 684112,
70
+ containerSize: 11176508,
71
+ nestedCabinet: "a1",
72
+ files: [{
73
+ source: "msvcp140.dll_arm64",
74
+ target: "msvcp140.dll"
75
+ }, {
76
+ source: "vcruntime140.dll_arm64",
77
+ target: "vcruntime140.dll"
78
+ }]
79
+ };
38
80
  const MACOS_ALIASES = [
39
81
  ["libggml-rpc.0.23.0.dylib", ["libggml-rpc.0.dylib", "libggml-rpc.dylib"]],
40
82
  ["libllama.0.4.0.dylib", ["libllama.0.dylib", "libllama.dylib"]],
@@ -124,7 +166,7 @@ const LLAMA_SERVER_ASSETS = [
124
166
  ...CUDA_ARCHIVE_LIMITS,
125
167
  maxEntries: 3
126
168
  }
127
- }]
169
+ }, WINDOWS_X64_VC_RUNTIME]
128
170
  },
129
171
  {
130
172
  platform: "win32",
@@ -135,7 +177,8 @@ const LLAMA_SERVER_ASSETS = [
135
177
  name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-arm64.zip`,
136
178
  sha256: "c1058fe5764a687275c8d20d6bbc1454e787cdbb8ebb8c37a2f959f2b144dc77",
137
179
  executable: "llama-server.exe",
138
- regularFileAliases: []
180
+ regularFileAliases: [],
181
+ dependencies: [WINDOWS_ARM64_VC_RUNTIME]
139
182
  },
140
183
  {
141
184
  platform: "win32",
@@ -146,7 +189,8 @@ const LLAMA_SERVER_ASSETS = [
146
189
  name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-x64.zip`,
147
190
  sha256: "9df3158ed228a641a4b127942d7f459f24c9e13f04682659d05c00c80099b6b5",
148
191
  executable: "llama-server.exe",
149
- regularFileAliases: []
192
+ regularFileAliases: [],
193
+ dependencies: [WINDOWS_X64_VC_RUNTIME]
150
194
  }
151
195
  ];
152
196
  function selectLlamaServerAsset(platform = process.platform, arch = process.arch, acceleration) {
@@ -181,7 +225,7 @@ const LLAMA_ARCHIVE_LIMITS = {
181
225
  maxMetaEntryBytes: MEBIBYTE
182
226
  };
183
227
  const MAX_ALIAS_BYTES = 512 * MEBIBYTE;
184
- function assertManifestBasename(filename) {
228
+ function assertManifestBasename$1(filename) {
185
229
  if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid llama-server archive manifest filename: ${filename}`);
186
230
  return filename;
187
231
  }
@@ -192,23 +236,23 @@ function resolveArchiveRoot(destDir, archiveRoot) {
192
236
  if (parts.some((part) => !part || part === "." || part === "..")) throw new Error(`invalid llama-server archive root: ${archiveRoot}`);
193
237
  return path.join(destDir, ...parts);
194
238
  }
195
- async function assertRegularFile(filePath, label) {
239
+ async function assertRegularFile$1(filePath, label) {
196
240
  const stat = await fs.lstat(filePath).catch(() => void 0);
197
241
  if (!stat?.isFile() || stat.nlink > 1) throw new Error(`llama-server archive does not contain regular ${label}`);
198
242
  return stat;
199
243
  }
200
244
  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}`);
245
+ const claimedNames = new Set(params.requiredFiles.map(assertManifestBasename$1));
246
+ for (const file of claimedNames) await assertRegularFile$1(path.join(params.rootDir, file), `file ${file}`);
203
247
  let copiedBytes = 0;
204
248
  for (const [rawSource, rawAliases] of params.asset.regularFileAliases) {
205
- const source = assertManifestBasename(rawSource);
249
+ const source = assertManifestBasename$1(rawSource);
206
250
  if (claimedNames.has(source)) throw new Error(`duplicate llama-server archive manifest filename: ${source}`);
207
251
  claimedNames.add(source);
208
252
  const sourcePath = path.join(params.rootDir, source);
209
- const sourceStat = await assertRegularFile(sourcePath, `alias source ${source}`);
253
+ const sourceStat = await assertRegularFile$1(sourcePath, `alias source ${source}`);
210
254
  for (const rawAlias of rawAliases) {
211
- const alias = assertManifestBasename(rawAlias);
255
+ const alias = assertManifestBasename$1(rawAlias);
212
256
  if (claimedNames.has(alias)) throw new Error(`duplicate llama-server archive manifest filename: ${alias}`);
213
257
  claimedNames.add(alias);
214
258
  copiedBytes += sourceStat.size;
@@ -216,7 +260,7 @@ async function materializeAssetAliases(params) {
216
260
  const aliasPath = path.join(params.rootDir, alias);
217
261
  await fs.copyFile(sourcePath, aliasPath, constants.COPYFILE_EXCL);
218
262
  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}`);
263
+ if ((await assertRegularFile$1(aliasPath, `alias ${alias}`)).size !== sourceStat.size) throw new Error(`llama-server archive alias copy is incomplete: ${alias}`);
220
264
  }
221
265
  }
222
266
  }
@@ -264,6 +308,118 @@ async function extractLlamaServerDependencyArchive(params) {
264
308
  });
265
309
  }
266
310
  //#endregion
311
+ //#region extensions/llama-cpp/src/llama-server-vc-runtime.ts
312
+ const CAB_HEADER_SIZE = 12;
313
+ const COPY_BUFFER_SIZE = 1048576;
314
+ const EXPAND_TIMEOUT_MS = 6e4;
315
+ function assertManifestBasename(filename) {
316
+ if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid Visual C++ runtime manifest filename: ${filename}`);
317
+ return filename;
318
+ }
319
+ async function writeFully(handle, buffer, length) {
320
+ let offset = 0;
321
+ while (offset < length) {
322
+ const result = await handle.write(buffer, offset, length - offset);
323
+ if (result.bytesWritten <= 0) throw new Error("Visual C++ runtime container copy made no progress");
324
+ offset += result.bytesWritten;
325
+ }
326
+ }
327
+ async function extractPinnedContainer(params) {
328
+ const source = await fs.open(params.bundlePath, "r");
329
+ try {
330
+ const stat = await source.stat();
331
+ if (!stat.isFile() || stat.size !== params.asset.size) throw new Error(`Visual C++ runtime bundle size mismatch: expected ${params.asset.size}, got ${stat.size}`);
332
+ 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");
333
+ const header = Buffer.alloc(CAB_HEADER_SIZE);
334
+ 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");
335
+ const target = await fs.open(params.containerPath, "wx", 384);
336
+ try {
337
+ const buffer = Buffer.allocUnsafe(Math.min(COPY_BUFFER_SIZE, params.asset.containerSize));
338
+ let copied = 0;
339
+ while (copied < params.asset.containerSize) {
340
+ params.signal?.throwIfAborted();
341
+ const requested = Math.min(buffer.length, params.asset.containerSize - copied);
342
+ const result = await source.read(buffer, 0, requested, params.asset.containerOffset + copied);
343
+ if (result.bytesRead <= 0) throw new Error("Visual C++ runtime container ended before its pinned size");
344
+ await writeFully(target, buffer, result.bytesRead);
345
+ copied += result.bytesRead;
346
+ }
347
+ } finally {
348
+ await target.close();
349
+ }
350
+ } finally {
351
+ await source.close();
352
+ }
353
+ }
354
+ function resolveExpandCommand() {
355
+ const systemRoot = process.env.SystemRoot;
356
+ if (!systemRoot || !path.win32.isAbsolute(systemRoot)) throw new Error("SystemRoot is unavailable; cannot extract the Visual C++ runtime");
357
+ return path.win32.join(systemRoot, "System32", "expand.exe");
358
+ }
359
+ async function runExpand(command, args, signal) {
360
+ await new Promise((resolve, reject) => {
361
+ execFile(command, args, {
362
+ timeout: EXPAND_TIMEOUT_MS,
363
+ signal,
364
+ windowsHide: true
365
+ }, (error, _stdout, stderr) => {
366
+ if (error) {
367
+ const detail = stderr.trim();
368
+ reject(new Error(`Failed to extract the Visual C++ runtime${detail ? `: ${detail}` : ""}`, { cause: error }));
369
+ } else resolve();
370
+ });
371
+ });
372
+ }
373
+ async function assertRegularFile(filePath, label) {
374
+ const stat = await fs.lstat(filePath).catch(() => void 0);
375
+ if (!stat?.isFile() || stat.nlink > 1) throw new Error(`Visual C++ runtime does not contain regular file ${label}`);
376
+ }
377
+ /** Extracts the pinned Microsoft redistributable DLLs without installing machine-wide state. */
378
+ async function extractWindowsVcRuntime(params) {
379
+ const nestedCabinet = assertManifestBasename(params.asset.nestedCabinet);
380
+ const files = params.asset.files.map(({ source, target }) => ({
381
+ source: assertManifestBasename(source),
382
+ target: assertManifestBasename(target)
383
+ }));
384
+ if (new Set(files.map((file) => file.target)).size !== files.length) throw new Error("duplicate Visual C++ runtime target filename");
385
+ const expandCommand = resolveExpandCommand();
386
+ const containerPath = path.join(params.destDir, "bundle.cab");
387
+ const nestedDir = path.join(params.destDir, "nested");
388
+ const filesDir = path.join(params.destDir, "files");
389
+ await Promise.all([
390
+ fs.mkdir(params.destDir, { recursive: true }),
391
+ fs.mkdir(nestedDir, { recursive: true }),
392
+ fs.mkdir(filesDir, { recursive: true })
393
+ ]);
394
+ await extractPinnedContainer({
395
+ asset: params.asset,
396
+ bundlePath: params.bundlePath,
397
+ containerPath,
398
+ signal: params.signal
399
+ });
400
+ await runExpand(expandCommand, [
401
+ `-F:${nestedCabinet}`,
402
+ containerPath,
403
+ nestedDir
404
+ ], params.signal);
405
+ const nestedPath = path.join(nestedDir, nestedCabinet);
406
+ await assertRegularFile(nestedPath, nestedCabinet);
407
+ for (const file of files) {
408
+ params.signal?.throwIfAborted();
409
+ await runExpand(expandCommand, [
410
+ `-F:${file.source}`,
411
+ nestedPath,
412
+ filesDir
413
+ ], params.signal);
414
+ const sourcePath = path.join(filesDir, file.source);
415
+ await assertRegularFile(sourcePath, file.source);
416
+ const targetPath = path.join(params.destDir, file.target);
417
+ await fs.copyFile(sourcePath, targetPath, constants.COPYFILE_EXCL);
418
+ await assertRegularFile(targetPath, file.target);
419
+ }
420
+ return params.destDir;
421
+ }
422
+ //#endregion
267
423
  //#region extensions/llama-cpp/src/llama-server-install.ts
268
424
  const DOWNLOAD_TIMEOUT_MS = 18e5;
269
425
  const VERSION_TIMEOUT_MS = 15e3;
@@ -287,7 +443,7 @@ function assertSupportedLinuxRuntime(asset) {
287
443
  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
444
  }
289
445
  function assetUrl(asset) {
290
- return `https://github.com/ggml-org/llama.cpp/releases/download/${LLAMA_SERVER_RELEASE}/${asset.name}`;
446
+ return asset.url ?? `https://github.com/ggml-org/llama.cpp/releases/download/b10809/${asset.name}`;
291
447
  }
292
448
  const verifiedFiles = /* @__PURE__ */ new Map();
293
449
  const VERIFIED_FILE_LIMIT = 16;
@@ -413,26 +569,64 @@ async function runServerCommand(command, args, signal, timeoutMs = VERSION_TIMEO
413
569
  function formatRuntimeDependencyError(error) {
414
570
  const detail = error instanceof Error ? error.message : String(error);
415
571
  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 });
572
+ 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
573
  return new Error(`The verified llama-server build could not start: ${detail}`, { cause: error });
418
574
  }
419
- async function validateInstalledServer(command, asset, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
420
- let version;
575
+ async function queryServerVersion(command, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
421
576
  try {
422
- version = await runServerCommand(command, ["--version"], signal, versionTimeoutMs);
577
+ return await runServerCommand(command, ["--version"], signal, versionTimeoutMs);
423
578
  } catch (error) {
424
579
  signal?.throwIfAborted();
425
580
  throw formatRuntimeDependencyError(error);
426
581
  }
582
+ }
583
+ function validateServerVersionOutput(command, version) {
427
584
  const match = (version.split(/\r?\n/u, 1)[0]?.trim() ?? "").match(/^version: .+ \(build (\d+), commit ([a-f\d]{9})\)$/u);
428
585
  const build = match?.[1] ? Number(match[1]) : void 0;
429
586
  const commit = match?.[2];
430
587
  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"}`);
588
+ }
589
+ async function validateCudaServer(command, asset, signal) {
431
590
  if (asset.backend === "cuda") {
432
591
  const devices = await runServerCommand(command, ["--list-devices"], signal);
433
592
  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
593
  }
435
594
  }
595
+ async function validateInstalledServer(command, asset, signal, versionTimeoutMs = VERSION_TIMEOUT_MS) {
596
+ validateServerVersionOutput(command, await queryServerVersion(command, signal, versionTimeoutMs));
597
+ await validateCudaServer(command, asset, signal);
598
+ }
599
+ async function stageLlamaServerDependency(params) {
600
+ const { dependency, extractDir, extractedRoot, index, options } = params;
601
+ options.signal?.throwIfAborted();
602
+ const dependencyArchive = path.join(extractDir, dependency.name);
603
+ await downloadVerifiedFile({
604
+ url: assetUrl(dependency),
605
+ destination: dependencyArchive,
606
+ expectedSha256: dependency.sha256,
607
+ expectedSize: dependency.archive === "vc-redist" ? dependency.size : void 0,
608
+ signal: options.signal,
609
+ onProgress: options.onProgress
610
+ });
611
+ const dependencyExtractDir = path.join(extractDir, `dependency-${index}`);
612
+ await fs.mkdir(dependencyExtractDir);
613
+ const dependencyRoot = dependency.archive === "vc-redist" ? await extractWindowsVcRuntime({
614
+ bundlePath: dependencyArchive,
615
+ destDir: dependencyExtractDir,
616
+ asset: dependency,
617
+ signal: options.signal
618
+ }) : await extractLlamaServerDependencyArchive({
619
+ archivePath: dependencyArchive,
620
+ destDir: dependencyExtractDir,
621
+ asset: dependency
622
+ });
623
+ for (const file of dependencyFiles(dependency)) await fs.copyFile(path.join(dependencyRoot, file), path.join(extractedRoot, file), fs$1.constants.COPYFILE_EXCL);
624
+ }
625
+ function formatVcRuntimeFallbackError(startupError, fallbackError) {
626
+ const startupDetail = startupError instanceof Error ? startupError.message : String(startupError);
627
+ const fallbackDetail = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
628
+ 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 });
629
+ }
436
630
  async function installLlamaServer(asset, options) {
437
631
  options.signal?.throwIfAborted();
438
632
  assertSupportedLinuxRuntime(asset);
@@ -461,28 +655,49 @@ async function installLlamaServer(asset, options) {
461
655
  asset
462
656
  });
463
657
  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
- }
658
+ const dependencies = asset.dependencies ?? [];
659
+ const windowsRuntimeDependencies = [];
660
+ for (const [index, dependency] of dependencies.entries()) if (dependency.archive === "vc-redist") windowsRuntimeDependencies.push({
661
+ dependency,
662
+ index
663
+ });
664
+ else await stageLlamaServerDependency({
665
+ dependency,
666
+ index,
667
+ extractDir,
668
+ extractedRoot,
669
+ options
670
+ });
483
671
  options.signal?.throwIfAborted();
484
672
  await fs.chmod(extractedCommand, 493);
485
- await validateInstalledServer(extractedCommand, asset, options.signal, FRESH_VERSION_TIMEOUT_MS);
673
+ if (windowsRuntimeDependencies.length > 0) {
674
+ let version;
675
+ try {
676
+ version = await queryServerVersion(extractedCommand, options.signal, FRESH_VERSION_TIMEOUT_MS);
677
+ } catch (startupError) {
678
+ options.signal?.throwIfAborted();
679
+ try {
680
+ for (const { dependency, index } of windowsRuntimeDependencies) await stageLlamaServerDependency({
681
+ dependency,
682
+ index,
683
+ extractDir,
684
+ extractedRoot,
685
+ options
686
+ });
687
+ } catch (stagingError) {
688
+ options.signal?.throwIfAborted();
689
+ throw formatVcRuntimeFallbackError(startupError, stagingError);
690
+ }
691
+ try {
692
+ version = await queryServerVersion(extractedCommand, options.signal, FRESH_VERSION_TIMEOUT_MS);
693
+ } catch (retryError) {
694
+ options.signal?.throwIfAborted();
695
+ throw formatVcRuntimeFallbackError(startupError, retryError);
696
+ }
697
+ }
698
+ validateServerVersionOutput(extractedCommand, version);
699
+ await validateCudaServer(extractedCommand, asset, options.signal);
700
+ } else await validateInstalledServer(extractedCommand, asset, options.signal, FRESH_VERSION_TIMEOUT_MS);
486
701
  await fs.mkdir(path.dirname(installDir), { recursive: true });
487
702
  options.signal?.throwIfAborted();
488
703
  await fs.rm(installDir, {
@@ -499,6 +714,9 @@ async function installLlamaServer(asset, options) {
499
714
  })]);
500
715
  }
501
716
  }
717
+ function dependencyFiles(dependency) {
718
+ return dependency.archive === "vc-redist" ? dependency.files.map((file) => file.target) : dependency.files;
719
+ }
502
720
  async function ensureLlamaServerInstalled(options = {}) {
503
721
  options.signal?.throwIfAborted();
504
722
  const asset = options.asset ?? selectLlamaServerAsset();
@@ -897,9 +1115,9 @@ const modelPromises = /* @__PURE__ */ new Map();
897
1115
  const resolvedModelArtifacts = /* @__PURE__ */ new Map();
898
1116
  const presetState = {
899
1117
  appliedRevisions: /* @__PURE__ */ new Map(),
900
- desiredRevisions: /* @__PURE__ */ new Map(),
901
- transition: Promise.resolve()
1118
+ desiredRevisions: /* @__PURE__ */ new Map()
902
1119
  };
1120
+ const runPresetTransition = createAsyncLock();
903
1121
  const LLAMA_CPP_PRESET_RELOAD_TIMEOUT_MS = 15e3;
904
1122
  function parseHuggingFaceSource(source) {
905
1123
  const [pathPart, revisionPart] = source.replace(/^(?:hf|huggingface):(?:\/\/)?/iu, "").split("#", 2);
@@ -1070,11 +1288,6 @@ async function writePreset(presetPath, contents) {
1070
1288
  await fs.rm(temporary, { force: true });
1071
1289
  }
1072
1290
  }
1073
- async function runPresetTransition(run) {
1074
- const pending = presetState.transition.catch(() => void 0).then(run);
1075
- presetState.transition = pending;
1076
- await pending;
1077
- }
1078
1291
  async function updatePreset(presetPath, params) {
1079
1292
  await runPresetTransition(async () => {
1080
1293
  const existing = await fs.readFile(presetPath, "utf8").catch((error) => {
@@ -1506,18 +1719,16 @@ function resolveInput(row, props) {
1506
1719
  }
1507
1720
  function buildCompat(props) {
1508
1721
  const caps = props?.chat_template_caps;
1509
- const supportsTools = asBoolean(caps?.supports_tool_calls) === true;
1510
- const supportsTypedContent = asBoolean(caps?.supports_typed_content) === true;
1511
1722
  return {
1512
1723
  supportsStore: false,
1513
1724
  supportsDeveloperRole: false,
1514
- supportsReasoningEffort: asBoolean(caps?.supports_reasoning_effort) === true,
1725
+ supportsReasoningEffort: caps?.supports_reasoning_effort === true,
1515
1726
  supportsTemperature: true,
1516
1727
  supportsUsageInStreaming: true,
1517
- supportsTools,
1728
+ supportsTools: caps?.supports_tool_calls === true,
1518
1729
  supportsStrictMode: false,
1519
1730
  supportsJsonSchemaResponseFormat: true,
1520
- requiresStringContent: !supportsTypedContent,
1731
+ requiresStringContent: caps?.supports_typed_content !== true,
1521
1732
  maxTokensField: "max_tokens"
1522
1733
  };
1523
1734
  }
@@ -1837,7 +2048,15 @@ async function runLlamaServerSetup(ctx) {
1837
2048
  message: `${LLAMA_CPP_PROVIDER_LABEL} URL`,
1838
2049
  initialValue: defaultOrigin,
1839
2050
  placeholder: LLAMA_SERVER_DEFAULT_ORIGIN,
1840
- validate: (value) => value?.trim() ? void 0 : "Required"
2051
+ validate: (value) => {
2052
+ if (!value?.trim()) return "Required";
2053
+ try {
2054
+ resolveLlamaServerEndpoint(value);
2055
+ return;
2056
+ } catch {
2057
+ return "Enter a valid HTTP or HTTPS URL without embedded credentials (e.g. http://localhost:8080).";
2058
+ }
2059
+ }
1841
2060
  }));
1842
2061
  const endpointChanged = Boolean(existing?.localService) || hasEndpointChanged(existing, endpoint.inferenceBaseUrl);
1843
2062
  const resolvedHeaders = endpointChanged ? void 0 : await resolveLlamaServerProviderHeaders({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/llama-cpp-provider",
3
- "version": "2026.9.7",
3
+ "version": "2026.10.1-beta.1",
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.7"
24
+ "pluginApi": ">=2026.10.1-beta.1"
25
25
  },
26
26
  "build": {
27
- "openclawVersion": "2026.9.7"
27
+ "openclawVersion": "2026.10.1-beta.1"
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.21.1"
39
+ "@openclaw/fs-safe": "0.23.0"
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.7"
49
+ "openclaw": ">=2026.10.1-beta.1"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "openclaw": {