@openclaw/llama-cpp-provider 2026.8.34 → 2026.8.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +228 -35
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import os from "node:os";
|
|
|
6
6
|
import { asBoolean, asOptionalRecord, asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
7
|
import { execFile } from "node:child_process";
|
|
8
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
9
|
-
import fs from "node:fs";
|
|
10
|
-
import
|
|
9
|
+
import fs, { constants } from "node:fs";
|
|
10
|
+
import fs$1 from "node:fs/promises";
|
|
11
11
|
import JSZip from "jszip";
|
|
12
12
|
import * as tar from "tar";
|
|
13
13
|
import net from "node:net";
|
|
@@ -70,7 +70,24 @@ const LLAMA_SERVER_ASSETS = [
|
|
|
70
70
|
archive: "zip",
|
|
71
71
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-arm64.zip`,
|
|
72
72
|
sha256: "d33618b10fda35d34d85da60926c6c470f98f3f66ce6b52c3c1f583461416012",
|
|
73
|
-
executable: "llama-server.exe"
|
|
73
|
+
executable: "llama-server.exe",
|
|
74
|
+
dependencies: [{
|
|
75
|
+
archive: "vc-redist",
|
|
76
|
+
name: "VC_redist.arm64.exe",
|
|
77
|
+
url: "https://download.visualstudio.microsoft.com/download/pr/ece44298-3977-4f73-ab91-c13fe79cfea8/B70EF586669A620A0A30A1156969C05C6A3831DC8F8BC992DA75779D2A92F944/VC_redist.arm64.exe",
|
|
78
|
+
sha256: "b70ef586669a620a0a30a1156969c05c6a3831dc8f8bc992da75779d2a92f944",
|
|
79
|
+
size: 11870816,
|
|
80
|
+
containerOffset: 684112,
|
|
81
|
+
containerSize: 11176508,
|
|
82
|
+
nestedCabinet: "a1",
|
|
83
|
+
files: [{
|
|
84
|
+
source: "msvcp140.dll_arm64",
|
|
85
|
+
target: "msvcp140.dll"
|
|
86
|
+
}, {
|
|
87
|
+
source: "vcruntime140.dll_arm64",
|
|
88
|
+
target: "vcruntime140.dll"
|
|
89
|
+
}]
|
|
90
|
+
}]
|
|
74
91
|
},
|
|
75
92
|
{
|
|
76
93
|
platform: "win32",
|
|
@@ -79,7 +96,31 @@ const LLAMA_SERVER_ASSETS = [
|
|
|
79
96
|
archive: "zip",
|
|
80
97
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-x64.zip`,
|
|
81
98
|
sha256: "295ae03ad58d9276afa36f5f8d111d67fc1491c7aff3a3e6d13051a772f93c21",
|
|
82
|
-
executable: "llama-server.exe"
|
|
99
|
+
executable: "llama-server.exe",
|
|
100
|
+
dependencies: [{
|
|
101
|
+
archive: "vc-redist",
|
|
102
|
+
name: "VC_redist.x64.exe",
|
|
103
|
+
url: "https://download.visualstudio.microsoft.com/download/pr/ebdab8e5-1d7b-4d9f-a11b-cbb1720c3b12/843068991DAAA1F73AD9F6239BCE4D0F6A07A51F18C37EA2A867E9BECA71295C/VC_redist.x64.exe",
|
|
104
|
+
sha256: "843068991daaa1f73ad9f6239bce4d0f6a07a51f18c37ea2a867e9beca71295c",
|
|
105
|
+
size: 18731856,
|
|
106
|
+
containerOffset: 63e4,
|
|
107
|
+
containerSize: 18091661,
|
|
108
|
+
nestedCabinet: "a4",
|
|
109
|
+
files: [
|
|
110
|
+
{
|
|
111
|
+
source: "msvcp140.dll_amd64",
|
|
112
|
+
target: "msvcp140.dll"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
source: "vcruntime140.dll_amd64",
|
|
116
|
+
target: "vcruntime140.dll"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
source: "vcruntime140_1.dll_amd64",
|
|
120
|
+
target: "vcruntime140_1.dll"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}]
|
|
83
124
|
}
|
|
84
125
|
];
|
|
85
126
|
function selectLlamaServerAsset(platform = process.platform, arch = process.arch) {
|
|
@@ -96,6 +137,118 @@ function resolveManagedLlamaServerPaths(asset = selectLlamaServerAsset()) {
|
|
|
96
137
|
};
|
|
97
138
|
}
|
|
98
139
|
//#endregion
|
|
140
|
+
//#region extensions/llama-cpp/src/llama-server-vc-runtime.ts
|
|
141
|
+
const CAB_HEADER_SIZE = 12;
|
|
142
|
+
const COPY_BUFFER_SIZE = 1048576;
|
|
143
|
+
const EXPAND_TIMEOUT_MS = 6e4;
|
|
144
|
+
function assertManifestBasename(filename) {
|
|
145
|
+
if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid Visual C++ runtime manifest filename: ${filename}`);
|
|
146
|
+
return filename;
|
|
147
|
+
}
|
|
148
|
+
async function writeFully(handle, buffer, length) {
|
|
149
|
+
let offset = 0;
|
|
150
|
+
while (offset < length) {
|
|
151
|
+
const result = await handle.write(buffer, offset, length - offset);
|
|
152
|
+
if (result.bytesWritten <= 0) throw new Error("Visual C++ runtime container copy made no progress");
|
|
153
|
+
offset += result.bytesWritten;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function extractPinnedContainer(params) {
|
|
157
|
+
const source = await fs$1.open(params.bundlePath, "r");
|
|
158
|
+
try {
|
|
159
|
+
const stat = await source.stat();
|
|
160
|
+
if (!stat.isFile() || stat.size !== params.asset.size) throw new Error(`Visual C++ runtime bundle size mismatch: expected ${params.asset.size}, got ${stat.size}`);
|
|
161
|
+
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");
|
|
162
|
+
const header = Buffer.alloc(CAB_HEADER_SIZE);
|
|
163
|
+
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");
|
|
164
|
+
const target = await fs$1.open(params.containerPath, "wx", 384);
|
|
165
|
+
try {
|
|
166
|
+
const buffer = Buffer.allocUnsafe(Math.min(COPY_BUFFER_SIZE, params.asset.containerSize));
|
|
167
|
+
let copied = 0;
|
|
168
|
+
while (copied < params.asset.containerSize) {
|
|
169
|
+
params.signal?.throwIfAborted();
|
|
170
|
+
const requested = Math.min(buffer.length, params.asset.containerSize - copied);
|
|
171
|
+
const result = await source.read(buffer, 0, requested, params.asset.containerOffset + copied);
|
|
172
|
+
if (result.bytesRead <= 0) throw new Error("Visual C++ runtime container ended before its pinned size");
|
|
173
|
+
await writeFully(target, buffer, result.bytesRead);
|
|
174
|
+
copied += result.bytesRead;
|
|
175
|
+
}
|
|
176
|
+
} finally {
|
|
177
|
+
await target.close();
|
|
178
|
+
}
|
|
179
|
+
} finally {
|
|
180
|
+
await source.close();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function resolveExpandCommand() {
|
|
184
|
+
const systemRoot = process.env.SystemRoot;
|
|
185
|
+
if (!systemRoot || !path.win32.isAbsolute(systemRoot)) throw new Error("SystemRoot is unavailable; cannot extract the Visual C++ runtime");
|
|
186
|
+
return path.win32.join(systemRoot, "System32", "expand.exe");
|
|
187
|
+
}
|
|
188
|
+
async function runExpand(command, args, signal) {
|
|
189
|
+
await new Promise((resolve, reject) => {
|
|
190
|
+
execFile(command, args, {
|
|
191
|
+
timeout: EXPAND_TIMEOUT_MS,
|
|
192
|
+
signal,
|
|
193
|
+
windowsHide: true
|
|
194
|
+
}, (error, _stdout, stderr) => {
|
|
195
|
+
if (error) {
|
|
196
|
+
const detail = stderr.trim();
|
|
197
|
+
reject(new Error(`Failed to extract the Visual C++ runtime${detail ? `: ${detail}` : ""}`, { cause: error }));
|
|
198
|
+
} else resolve();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async function assertRegularFile(filePath, label) {
|
|
203
|
+
const stat = await fs$1.lstat(filePath).catch(() => void 0);
|
|
204
|
+
if (!stat?.isFile() || stat.nlink > 1) throw new Error(`Visual C++ runtime does not contain regular file ${label}`);
|
|
205
|
+
}
|
|
206
|
+
/** Extracts the pinned Microsoft redistributable DLLs without installing machine-wide state. */
|
|
207
|
+
async function extractWindowsVcRuntime(params) {
|
|
208
|
+
const nestedCabinet = assertManifestBasename(params.asset.nestedCabinet);
|
|
209
|
+
const files = params.asset.files.map(({ source, target }) => ({
|
|
210
|
+
source: assertManifestBasename(source),
|
|
211
|
+
target: assertManifestBasename(target)
|
|
212
|
+
}));
|
|
213
|
+
if (new Set(files.map((file) => file.target)).size !== files.length) throw new Error("duplicate Visual C++ runtime target filename");
|
|
214
|
+
const expandCommand = resolveExpandCommand();
|
|
215
|
+
const containerPath = path.join(params.destDir, "bundle.cab");
|
|
216
|
+
const nestedDir = path.join(params.destDir, "nested");
|
|
217
|
+
const filesDir = path.join(params.destDir, "files");
|
|
218
|
+
await Promise.all([
|
|
219
|
+
fs$1.mkdir(params.destDir, { recursive: true }),
|
|
220
|
+
fs$1.mkdir(nestedDir, { recursive: true }),
|
|
221
|
+
fs$1.mkdir(filesDir, { recursive: true })
|
|
222
|
+
]);
|
|
223
|
+
await extractPinnedContainer({
|
|
224
|
+
asset: params.asset,
|
|
225
|
+
bundlePath: params.bundlePath,
|
|
226
|
+
containerPath,
|
|
227
|
+
signal: params.signal
|
|
228
|
+
});
|
|
229
|
+
await runExpand(expandCommand, [
|
|
230
|
+
`-F:${nestedCabinet}`,
|
|
231
|
+
containerPath,
|
|
232
|
+
nestedDir
|
|
233
|
+
], params.signal);
|
|
234
|
+
const nestedPath = path.join(nestedDir, nestedCabinet);
|
|
235
|
+
await assertRegularFile(nestedPath, nestedCabinet);
|
|
236
|
+
for (const file of files) {
|
|
237
|
+
params.signal?.throwIfAborted();
|
|
238
|
+
await runExpand(expandCommand, [
|
|
239
|
+
`-F:${file.source}`,
|
|
240
|
+
nestedPath,
|
|
241
|
+
filesDir
|
|
242
|
+
], params.signal);
|
|
243
|
+
const sourcePath = path.join(filesDir, file.source);
|
|
244
|
+
await assertRegularFile(sourcePath, file.source);
|
|
245
|
+
const targetPath = path.join(params.destDir, file.target);
|
|
246
|
+
await fs$1.copyFile(sourcePath, targetPath, constants.COPYFILE_EXCL);
|
|
247
|
+
await assertRegularFile(targetPath, file.target);
|
|
248
|
+
}
|
|
249
|
+
return params.destDir;
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
99
252
|
//#region extensions/llama-cpp/src/llama-server-install.ts
|
|
100
253
|
const DOWNLOAD_TIMEOUT_MS = 18e5;
|
|
101
254
|
const VERSION_TIMEOUT_MS = 15e3;
|
|
@@ -118,7 +271,7 @@ function assertSupportedLinuxRuntime(asset) {
|
|
|
118
271
|
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.`);
|
|
119
272
|
}
|
|
120
273
|
function assetUrl(asset) {
|
|
121
|
-
return `https://github.com/ggml-org/llama.cpp/releases/download/${
|
|
274
|
+
return asset.url ?? `https://github.com/ggml-org/llama.cpp/releases/download/b10534/${asset.name}`;
|
|
122
275
|
}
|
|
123
276
|
async function sha256File(filePath) {
|
|
124
277
|
const hash = createHash("sha256");
|
|
@@ -140,7 +293,7 @@ function readResponseSha256(response) {
|
|
|
140
293
|
}
|
|
141
294
|
async function downloadVerifiedFile(params) {
|
|
142
295
|
const partialPath = `${params.destination}.partial-${randomUUID()}`;
|
|
143
|
-
await
|
|
296
|
+
await fs$1.mkdir(path.dirname(params.destination), { recursive: true });
|
|
144
297
|
const { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } = await import("openclaw/plugin-sdk/ssrf-runtime");
|
|
145
298
|
try {
|
|
146
299
|
const { response, release } = await fetchWithSsrFGuard({
|
|
@@ -157,7 +310,7 @@ async function downloadVerifiedFile(params) {
|
|
|
157
310
|
if (!expectedSha256 && params.requireServerDigest) throw new Error("the download server did not provide a SHA-256 digest; download the GGUF manually and configure its local path");
|
|
158
311
|
const contentLength = Number(response.headers.get("content-length"));
|
|
159
312
|
const totalSize = params.expectedSize ?? (Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0);
|
|
160
|
-
const handle = await
|
|
313
|
+
const handle = await fs$1.open(partialPath, "wx", 384);
|
|
161
314
|
const hash = createHash("sha256");
|
|
162
315
|
let downloadedSize = 0;
|
|
163
316
|
let previousSize = 0;
|
|
@@ -188,29 +341,29 @@ async function downloadVerifiedFile(params) {
|
|
|
188
341
|
if (params.expectedSize && downloadedSize !== params.expectedSize) throw new Error(`download size mismatch: expected ${params.expectedSize}, got ${downloadedSize}`);
|
|
189
342
|
const actualSha256 = hash.digest("hex");
|
|
190
343
|
if (expectedSha256 && actualSha256 !== expectedSha256.toLowerCase()) throw new Error(`download SHA-256 mismatch: expected ${expectedSha256}, got ${actualSha256}`);
|
|
191
|
-
await
|
|
344
|
+
await fs$1.rename(partialPath, params.destination);
|
|
192
345
|
} finally {
|
|
193
346
|
await release();
|
|
194
347
|
}
|
|
195
348
|
} finally {
|
|
196
|
-
await
|
|
349
|
+
await fs$1.rm(partialPath, { force: true }).catch(() => void 0);
|
|
197
350
|
}
|
|
198
351
|
}
|
|
199
352
|
async function extractZip(archivePath, destination) {
|
|
200
|
-
const zip = await JSZip.loadAsync(await
|
|
353
|
+
const zip = await JSZip.loadAsync(await fs$1.readFile(archivePath));
|
|
201
354
|
for (const entry of Object.values(zip.files)) {
|
|
202
355
|
const normalized = path.posix.normalize(entry.name);
|
|
203
356
|
if (normalized.startsWith("/") || normalized === ".." || normalized.startsWith("../")) throw new Error(`unsafe path in llama-server archive: ${entry.name}`);
|
|
204
357
|
const outputPath = path.join(destination, ...normalized.split("/"));
|
|
205
|
-
if (entry.dir) await
|
|
358
|
+
if (entry.dir) await fs$1.mkdir(outputPath, { recursive: true });
|
|
206
359
|
else {
|
|
207
|
-
await
|
|
208
|
-
await
|
|
360
|
+
await fs$1.mkdir(path.dirname(outputPath), { recursive: true });
|
|
361
|
+
await fs$1.writeFile(outputPath, await entry.async("nodebuffer"), { mode: 384 });
|
|
209
362
|
}
|
|
210
363
|
}
|
|
211
364
|
}
|
|
212
365
|
async function findExecutable(root, executable) {
|
|
213
|
-
for (const entry of await
|
|
366
|
+
for (const entry of await fs$1.readdir(root, { withFileTypes: true })) {
|
|
214
367
|
const candidate = path.join(root, entry.name);
|
|
215
368
|
if (entry.isFile() && entry.name === executable) return candidate;
|
|
216
369
|
if (entry.isDirectory()) {
|
|
@@ -234,6 +387,12 @@ function formatRuntimeDependencyError(error) {
|
|
|
234
387
|
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 });
|
|
235
388
|
return new Error(`The verified llama-server build could not start: ${detail}`, { cause: error });
|
|
236
389
|
}
|
|
390
|
+
function validateServerVersionOutput(command, version) {
|
|
391
|
+
const match = (version.split(/\r?\n/u, 1)[0]?.trim() ?? "").match(/^version: .+ \(build (\d+), commit ([a-f\d]{9})\)$/u);
|
|
392
|
+
const build = match?.[1] ? Number(match[1]) : void 0;
|
|
393
|
+
const commit = match?.[2];
|
|
394
|
+
if (build !== 10534 || commit !== "2b5621094ef383cdcd8428ef6d22efe5df976532".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"}`);
|
|
395
|
+
}
|
|
237
396
|
async function validateInstalledServer(command) {
|
|
238
397
|
let version;
|
|
239
398
|
try {
|
|
@@ -241,29 +400,46 @@ async function validateInstalledServer(command) {
|
|
|
241
400
|
} catch (error) {
|
|
242
401
|
throw formatRuntimeDependencyError(error);
|
|
243
402
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
403
|
+
validateServerVersionOutput(command, version);
|
|
404
|
+
}
|
|
405
|
+
async function stageWindowsVcRuntime(params) {
|
|
406
|
+
const archivePath = path.join(params.extractDir, params.dependency.name);
|
|
407
|
+
await downloadVerifiedFile({
|
|
408
|
+
url: params.dependency.url,
|
|
409
|
+
destination: archivePath,
|
|
410
|
+
expectedSha256: params.dependency.sha256,
|
|
411
|
+
expectedSize: params.dependency.size
|
|
412
|
+
});
|
|
413
|
+
const dependencyRoot = await extractWindowsVcRuntime({
|
|
414
|
+
bundlePath: archivePath,
|
|
415
|
+
destDir: path.join(params.extractDir, `dependency-${params.index}`),
|
|
416
|
+
asset: params.dependency
|
|
417
|
+
});
|
|
418
|
+
for (const file of params.dependency.files) await fs$1.copyFile(path.join(dependencyRoot, file.target), path.join(params.extractedRoot, file.target), fs.constants.COPYFILE_EXCL);
|
|
419
|
+
}
|
|
420
|
+
function formatVcRuntimeFallbackError(startupError, fallbackError) {
|
|
421
|
+
const startupDetail = startupError instanceof Error ? startupError.message : String(startupError);
|
|
422
|
+
const fallbackDetail = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
423
|
+
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 });
|
|
248
424
|
}
|
|
249
425
|
async function installLlamaServer(asset) {
|
|
250
426
|
assertSupportedLinuxRuntime(asset);
|
|
251
427
|
const { installDir, command } = resolveManagedLlamaServerPaths(asset);
|
|
252
|
-
if (await
|
|
428
|
+
if (await fs$1.stat(command).then((stat) => stat.isFile()).catch(() => false)) {
|
|
253
429
|
await validateInstalledServer(command);
|
|
254
430
|
return command;
|
|
255
431
|
}
|
|
256
432
|
const dataDir = resolveLlamaCppDataDir();
|
|
257
433
|
const archivePath = path.join(dataDir, `.download-${randomUUID()}-${asset.name}`);
|
|
258
434
|
const extractDir = path.join(dataDir, `.extract-${randomUUID()}`);
|
|
259
|
-
await
|
|
435
|
+
await fs$1.mkdir(dataDir, { recursive: true });
|
|
260
436
|
try {
|
|
261
437
|
await downloadVerifiedFile({
|
|
262
438
|
url: assetUrl(asset),
|
|
263
439
|
destination: archivePath,
|
|
264
440
|
expectedSha256: asset.sha256
|
|
265
441
|
});
|
|
266
|
-
await
|
|
442
|
+
await fs$1.mkdir(extractDir, { recursive: true });
|
|
267
443
|
if (asset.archive === "zip") await extractZip(archivePath, extractDir);
|
|
268
444
|
else await tar.x({
|
|
269
445
|
file: archivePath,
|
|
@@ -272,18 +448,35 @@ async function installLlamaServer(asset) {
|
|
|
272
448
|
});
|
|
273
449
|
const extractedCommand = await findExecutable(extractDir, asset.executable);
|
|
274
450
|
const extractedRoot = path.dirname(extractedCommand);
|
|
275
|
-
await
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
451
|
+
await fs$1.chmod(extractedCommand, 493);
|
|
452
|
+
let version;
|
|
453
|
+
try {
|
|
454
|
+
version = await runVersion(extractedCommand);
|
|
455
|
+
} catch (startupError) {
|
|
456
|
+
if (!asset.dependencies?.length) throw formatRuntimeDependencyError(startupError);
|
|
457
|
+
try {
|
|
458
|
+
for (const [index, dependency] of asset.dependencies.entries()) await stageWindowsVcRuntime({
|
|
459
|
+
dependency,
|
|
460
|
+
extractDir,
|
|
461
|
+
extractedRoot,
|
|
462
|
+
index
|
|
463
|
+
});
|
|
464
|
+
version = await runVersion(extractedCommand);
|
|
465
|
+
} catch (fallbackError) {
|
|
466
|
+
throw formatVcRuntimeFallbackError(startupError, fallbackError);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
validateServerVersionOutput(extractedCommand, version);
|
|
470
|
+
await fs$1.mkdir(path.dirname(installDir), { recursive: true });
|
|
471
|
+
await fs$1.rm(installDir, {
|
|
279
472
|
recursive: true,
|
|
280
473
|
force: true
|
|
281
474
|
});
|
|
282
|
-
await
|
|
475
|
+
await fs$1.rename(extractedRoot, installDir);
|
|
283
476
|
await validateInstalledServer(command);
|
|
284
477
|
return command;
|
|
285
478
|
} finally {
|
|
286
|
-
await Promise.all([
|
|
479
|
+
await Promise.all([fs$1.rm(archivePath, { force: true }), fs$1.rm(extractDir, {
|
|
287
480
|
recursive: true,
|
|
288
481
|
force: true
|
|
289
482
|
})]);
|
|
@@ -396,7 +589,7 @@ function defaultArtifact(source) {
|
|
|
396
589
|
};
|
|
397
590
|
}
|
|
398
591
|
async function assertGguf(filePath) {
|
|
399
|
-
const handle = await
|
|
592
|
+
const handle = await fs$1.open(filePath, "r").catch((error) => {
|
|
400
593
|
if ((error instanceof Error && "code" in error ? error.code : void 0) === "ENOENT") throw new Error(`Model file is missing: ${filePath}. Run interactive llama.cpp setup or correct params.modelPath.`, { cause: error });
|
|
401
594
|
throw error;
|
|
402
595
|
});
|
|
@@ -435,7 +628,7 @@ async function ensureLlamaCppModel(params) {
|
|
|
435
628
|
const pending = modelPromises.get(destination);
|
|
436
629
|
if (pending) return await pending;
|
|
437
630
|
const load = (async () => {
|
|
438
|
-
if (await
|
|
631
|
+
if (await fs$1.stat(destination).then((stat) => stat.isFile()).catch(() => false)) {
|
|
439
632
|
if (artifact.expectedSha256) {
|
|
440
633
|
if (await sha256File(destination) === artifact.expectedSha256) return destination;
|
|
441
634
|
} else {
|
|
@@ -509,14 +702,14 @@ function renderLlamaServerPreset(params) {
|
|
|
509
702
|
].join("\n");
|
|
510
703
|
}
|
|
511
704
|
async function writePreset(presetPath, contents) {
|
|
512
|
-
await
|
|
705
|
+
await fs$1.mkdir(path.dirname(presetPath), { recursive: true });
|
|
513
706
|
const temporary = `${presetPath}.tmp-${randomUUID()}`;
|
|
514
|
-
await
|
|
515
|
-
await
|
|
707
|
+
await fs$1.writeFile(temporary, contents, { mode: 384 });
|
|
708
|
+
await fs$1.rename(temporary, presetPath);
|
|
516
709
|
}
|
|
517
710
|
async function updatePreset(presetPath, params) {
|
|
518
711
|
const pending = (presetWritePromises.get(presetPath) ?? Promise.resolve()).catch(() => void 0).then(async () => {
|
|
519
|
-
const existing = await
|
|
712
|
+
const existing = await fs$1.readFile(presetPath, "utf8").catch((error) => {
|
|
520
713
|
if (asOptionalRecord(error)?.code === "ENOENT") return;
|
|
521
714
|
throw error;
|
|
522
715
|
});
|
|
@@ -604,7 +797,7 @@ async function ensureManagedLlamaServerForChat(params) {
|
|
|
604
797
|
});
|
|
605
798
|
if (!chatModelPath && resolveLlamaCppModelSource(params.model) === "hf:unsloth/gemma-4-E4B-it-GGUF/gemma-4-E4B-it-Q4_K_M.gguf") {
|
|
606
799
|
const legacy = path.join(resolveLegacyLlamaCppModelCacheDir(), "hf_unsloth_gemma-4-E4B-it-GGUF_gemma-4-E4B-it-Q4_K_M.gguf");
|
|
607
|
-
if (await
|
|
800
|
+
if (await fs$1.stat(legacy).then((stat) => stat.isFile()).catch(() => false)) chatModelPath = legacy;
|
|
608
801
|
}
|
|
609
802
|
chatModelPath = await ensureLlamaCppModel({
|
|
610
803
|
source: chatModelPath ?? resolveLlamaCppModelSource(params.model),
|
|
@@ -1543,7 +1736,7 @@ function configuredCandidates(config, scope) {
|
|
|
1543
1736
|
})).toSorted((a, b) => Number(b.model.id === primaryId) - Number(a.model.id === primaryId));
|
|
1544
1737
|
}
|
|
1545
1738
|
async function isFile(filePath) {
|
|
1546
|
-
return await
|
|
1739
|
+
return await fs$1.stat(filePath).then((stat) => stat.isFile()).catch(() => false);
|
|
1547
1740
|
}
|
|
1548
1741
|
async function resolveCachedCandidate(candidate) {
|
|
1549
1742
|
const source = resolveLlamaCppModelSource(candidate.model);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.8.
|
|
3
|
+
"version": "2026.8.35",
|
|
4
4
|
"description": "OpenClaw provider for managed and external llama.cpp servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"minHostVersion": ">=2026.6.2"
|
|
25
25
|
},
|
|
26
26
|
"compat": {
|
|
27
|
-
"pluginApi": ">=2026.8.
|
|
27
|
+
"pluginApi": ">=2026.8.35"
|
|
28
28
|
},
|
|
29
29
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.8.
|
|
30
|
+
"openclawVersion": "2026.8.35"
|
|
31
31
|
},
|
|
32
32
|
"release": {
|
|
33
33
|
"bundleRuntimeDependencies": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"openclaw": ">=2026.8.
|
|
47
|
+
"openclaw": ">=2026.8.35"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
50
50
|
"openclaw": {
|