@openclaw/llama-cpp-provider 2026.8.2 → 2026.9.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.
- package/dist/index.js +140 -61
- package/package.json +4 -8
package/dist/index.js
CHANGED
|
@@ -6,11 +6,11 @@ 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
|
|
11
|
-
import
|
|
12
|
-
import * as tar from "tar";
|
|
9
|
+
import fs, { constants } from "node:fs";
|
|
10
|
+
import fs$1 from "node:fs/promises";
|
|
11
|
+
import { ARCHIVE_LIMIT_ERROR_CODE, ArchiveLimitError, extractArchive } from "openclaw/plugin-sdk/archive";
|
|
13
12
|
import net from "node:net";
|
|
13
|
+
import { readProviderJsonResponse, readProviderTextResponse } from "openclaw/plugin-sdk/provider-http";
|
|
14
14
|
import { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
15
15
|
import { fetchConfiguredLocalOriginWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime-internal";
|
|
16
16
|
import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput, upsertAuthProfileWithLock } from "openclaw/plugin-sdk/provider-auth";
|
|
@@ -26,60 +26,90 @@ import { listAgentIds, resolveAgentConfig } from "openclaw/plugin-sdk/agent-scop
|
|
|
26
26
|
//#region extensions/llama-cpp/src/llama-server-assets.ts
|
|
27
27
|
const LLAMA_SERVER_RELEASE = "b10534";
|
|
28
28
|
const LLAMA_SERVER_COMMIT = "2b5621094ef383cdcd8428ef6d22efe5df976532";
|
|
29
|
+
const MACOS_ALIASES = [
|
|
30
|
+
["libggml-rpc.0.20.2.dylib", ["libggml-rpc.0.dylib", "libggml-rpc.dylib"]],
|
|
31
|
+
["libllama.0.1.2.dylib", ["libllama.0.dylib", "libllama.dylib"]],
|
|
32
|
+
["libmtmd.0.1.2.dylib", ["libmtmd.0.dylib", "libmtmd.dylib"]],
|
|
33
|
+
["libggml.0.20.2.dylib", ["libggml.0.dylib", "libggml.dylib"]],
|
|
34
|
+
["libggml-base.0.20.2.dylib", ["libggml-base.0.dylib", "libggml-base.dylib"]],
|
|
35
|
+
["libggml-blas.0.20.2.dylib", ["libggml-blas.0.dylib", "libggml-blas.dylib"]],
|
|
36
|
+
["libllama-common.0.1.2.dylib", ["libllama-common.0.dylib", "libllama-common.dylib"]],
|
|
37
|
+
["libggml-cpu.0.20.2.dylib", ["libggml-cpu.0.dylib", "libggml-cpu.dylib"]]
|
|
38
|
+
];
|
|
39
|
+
const MACOS_METAL_ALIASES = [...MACOS_ALIASES, ["libggml-metal.0.20.2.dylib", ["libggml-metal.0.dylib", "libggml-metal.dylib"]]];
|
|
40
|
+
const LINUX_ALIASES = [
|
|
41
|
+
["libllama.so.0.1.2", ["libllama.so.0", "libllama.so"]],
|
|
42
|
+
["libggml.so.0.20.2", ["libggml.so.0", "libggml.so"]],
|
|
43
|
+
["libmtmd.so.0.1.2", ["libmtmd.so.0", "libmtmd.so"]],
|
|
44
|
+
["libggml-base.so.0.20.2", ["libggml-base.so.0", "libggml-base.so"]],
|
|
45
|
+
["libllama-common.so.0.1.2", ["libllama-common.so.0", "libllama-common.so"]]
|
|
46
|
+
];
|
|
29
47
|
const LLAMA_SERVER_ASSETS = [
|
|
30
48
|
{
|
|
31
49
|
platform: "darwin",
|
|
32
50
|
arch: "arm64",
|
|
33
51
|
backend: "metal",
|
|
34
52
|
archive: "tar.gz",
|
|
53
|
+
archiveRoot: `llama-${LLAMA_SERVER_RELEASE}`,
|
|
35
54
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-macos-arm64.tar.gz`,
|
|
36
55
|
sha256: "51f193eef26b053554e288fb924b24d41d3d7b2bafa338c19e2817fa793d5e86",
|
|
37
|
-
executable: "llama-server"
|
|
56
|
+
executable: "llama-server",
|
|
57
|
+
regularFileAliases: MACOS_METAL_ALIASES
|
|
38
58
|
},
|
|
39
59
|
{
|
|
40
60
|
platform: "darwin",
|
|
41
61
|
arch: "x64",
|
|
42
62
|
backend: "cpu",
|
|
43
63
|
archive: "tar.gz",
|
|
64
|
+
archiveRoot: `llama-${LLAMA_SERVER_RELEASE}`,
|
|
44
65
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-macos-x64.tar.gz`,
|
|
45
66
|
sha256: "69b13035f4301354922a8cfacd1bcf2bb2de4ff0c2e19fedb44963378ff53dc5",
|
|
46
|
-
executable: "llama-server"
|
|
67
|
+
executable: "llama-server",
|
|
68
|
+
regularFileAliases: MACOS_ALIASES
|
|
47
69
|
},
|
|
48
70
|
{
|
|
49
71
|
platform: "linux",
|
|
50
72
|
arch: "arm64",
|
|
51
73
|
backend: "cpu",
|
|
52
74
|
archive: "tar.gz",
|
|
75
|
+
archiveRoot: `llama-${LLAMA_SERVER_RELEASE}`,
|
|
53
76
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-ubuntu-arm64.tar.gz`,
|
|
54
77
|
sha256: "66535de5cb9293c075a1951c51a3b2ae6f1899623e21177845f6d2a73b78c94e",
|
|
55
|
-
executable: "llama-server"
|
|
78
|
+
executable: "llama-server",
|
|
79
|
+
regularFileAliases: LINUX_ALIASES
|
|
56
80
|
},
|
|
57
81
|
{
|
|
58
82
|
platform: "linux",
|
|
59
83
|
arch: "x64",
|
|
60
84
|
backend: "cpu",
|
|
61
85
|
archive: "tar.gz",
|
|
86
|
+
archiveRoot: `llama-${LLAMA_SERVER_RELEASE}`,
|
|
62
87
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-ubuntu-x64.tar.gz`,
|
|
63
88
|
sha256: "cc6a12b026edcf1b211be2bb7366c5dadcad778fd8f13019d0694038053d5e4a",
|
|
64
|
-
executable: "llama-server"
|
|
89
|
+
executable: "llama-server",
|
|
90
|
+
regularFileAliases: LINUX_ALIASES
|
|
65
91
|
},
|
|
66
92
|
{
|
|
67
93
|
platform: "win32",
|
|
68
94
|
arch: "arm64",
|
|
69
95
|
backend: "cpu",
|
|
70
96
|
archive: "zip",
|
|
97
|
+
archiveRoot: ".",
|
|
71
98
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-arm64.zip`,
|
|
72
99
|
sha256: "d33618b10fda35d34d85da60926c6c470f98f3f66ce6b52c3c1f583461416012",
|
|
73
|
-
executable: "llama-server.exe"
|
|
100
|
+
executable: "llama-server.exe",
|
|
101
|
+
regularFileAliases: []
|
|
74
102
|
},
|
|
75
103
|
{
|
|
76
104
|
platform: "win32",
|
|
77
105
|
arch: "x64",
|
|
78
106
|
backend: "cpu",
|
|
79
107
|
archive: "zip",
|
|
108
|
+
archiveRoot: ".",
|
|
80
109
|
name: `llama-${LLAMA_SERVER_RELEASE}-bin-win-cpu-x64.zip`,
|
|
81
110
|
sha256: "295ae03ad58d9276afa36f5f8d111d67fc1491c7aff3a3e6d13051a772f93c21",
|
|
82
|
-
executable: "llama-server.exe"
|
|
111
|
+
executable: "llama-server.exe",
|
|
112
|
+
regularFileAliases: []
|
|
83
113
|
}
|
|
84
114
|
];
|
|
85
115
|
function selectLlamaServerAsset(platform = process.platform, arch = process.arch) {
|
|
@@ -96,6 +126,81 @@ function resolveManagedLlamaServerPaths(asset = selectLlamaServerAsset()) {
|
|
|
96
126
|
};
|
|
97
127
|
}
|
|
98
128
|
//#endregion
|
|
129
|
+
//#region extensions/llama-cpp/src/llama-server-extract.ts
|
|
130
|
+
const MEBIBYTE = 1048576;
|
|
131
|
+
const LLAMA_ARCHIVE_LIMITS = {
|
|
132
|
+
maxArchiveBytes: 256 * MEBIBYTE,
|
|
133
|
+
maxEntries: 1e3,
|
|
134
|
+
maxExtractedBytes: 512 * MEBIBYTE,
|
|
135
|
+
maxEntryBytes: 256 * MEBIBYTE,
|
|
136
|
+
maxMetaEntryBytes: MEBIBYTE
|
|
137
|
+
};
|
|
138
|
+
const MAX_ALIAS_BYTES = 512 * MEBIBYTE;
|
|
139
|
+
function assertManifestBasename(filename) {
|
|
140
|
+
if (!filename || filename === "." || filename === ".." || /[\\/]/u.test(filename) || path.basename(filename) !== filename) throw new Error(`invalid llama-server archive manifest filename: ${filename}`);
|
|
141
|
+
return filename;
|
|
142
|
+
}
|
|
143
|
+
function resolveArchiveRoot(destDir, archiveRoot) {
|
|
144
|
+
if (archiveRoot === ".") return destDir;
|
|
145
|
+
if (path.isAbsolute(archiveRoot) || /\\/u.test(archiveRoot)) throw new Error(`invalid llama-server archive root: ${archiveRoot}`);
|
|
146
|
+
const parts = archiveRoot.split("/");
|
|
147
|
+
if (parts.some((part) => !part || part === "." || part === "..")) throw new Error(`invalid llama-server archive root: ${archiveRoot}`);
|
|
148
|
+
return path.join(destDir, ...parts);
|
|
149
|
+
}
|
|
150
|
+
async function assertRegularFile(filePath, label) {
|
|
151
|
+
const stat = await fs$1.lstat(filePath).catch(() => void 0);
|
|
152
|
+
if (!stat?.isFile() || stat.nlink > 1) throw new Error(`llama-server archive does not contain regular ${label}`);
|
|
153
|
+
return stat;
|
|
154
|
+
}
|
|
155
|
+
async function materializeAssetAliases(params) {
|
|
156
|
+
const claimedNames = /* @__PURE__ */ new Set([assertManifestBasename(params.asset.executable)]);
|
|
157
|
+
await assertRegularFile(path.join(params.rootDir, params.asset.executable), `executable ${params.asset.executable}`);
|
|
158
|
+
let copiedBytes = 0;
|
|
159
|
+
for (const [rawSource, rawAliases] of params.asset.regularFileAliases) {
|
|
160
|
+
const source = assertManifestBasename(rawSource);
|
|
161
|
+
if (claimedNames.has(source)) throw new Error(`duplicate llama-server archive manifest filename: ${source}`);
|
|
162
|
+
claimedNames.add(source);
|
|
163
|
+
const sourcePath = path.join(params.rootDir, source);
|
|
164
|
+
const sourceStat = await assertRegularFile(sourcePath, `alias source ${source}`);
|
|
165
|
+
for (const rawAlias of rawAliases) {
|
|
166
|
+
const alias = assertManifestBasename(rawAlias);
|
|
167
|
+
if (claimedNames.has(alias)) throw new Error(`duplicate llama-server archive manifest filename: ${alias}`);
|
|
168
|
+
claimedNames.add(alias);
|
|
169
|
+
copiedBytes += sourceStat.size;
|
|
170
|
+
if (copiedBytes > MAX_ALIAS_BYTES) throw new ArchiveLimitError(ARCHIVE_LIMIT_ERROR_CODE.EXTRACTED_SIZE_EXCEEDS_LIMIT);
|
|
171
|
+
const aliasPath = path.join(params.rootDir, alias);
|
|
172
|
+
await fs$1.copyFile(sourcePath, aliasPath, constants.COPYFILE_EXCL);
|
|
173
|
+
await fs$1.chmod(aliasPath, sourceStat.mode & 511);
|
|
174
|
+
if ((await assertRegularFile(aliasPath, `alias ${alias}`)).size !== sourceStat.size) throw new Error(`llama-server archive alias copy is incomplete: ${alias}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Extracts one verified asset and returns its unpublished executable path. */
|
|
179
|
+
async function extractLlamaServerArchive(params) {
|
|
180
|
+
const isTar = params.asset.archive === "tar.gz";
|
|
181
|
+
const aliasCount = params.asset.regularFileAliases.reduce((count, [, aliases]) => count + aliases.length, 0);
|
|
182
|
+
if (aliasCount > LLAMA_ARCHIVE_LIMITS.maxEntries) throw new ArchiveLimitError(ARCHIVE_LIMIT_ERROR_CODE.ENTRY_COUNT_EXCEEDS_LIMIT);
|
|
183
|
+
await extractArchive({
|
|
184
|
+
archivePath: params.archivePath,
|
|
185
|
+
destDir: params.destDir,
|
|
186
|
+
kind: isTar ? "tar" : "zip",
|
|
187
|
+
timeoutMs: 0,
|
|
188
|
+
limits: {
|
|
189
|
+
...LLAMA_ARCHIVE_LIMITS,
|
|
190
|
+
maxEntries: LLAMA_ARCHIVE_LIMITS.maxEntries - aliasCount
|
|
191
|
+
},
|
|
192
|
+
tarGzip: isTar,
|
|
193
|
+
entryFilter: (entry) => entry.kind === "symlink" ? "skip" : "extract",
|
|
194
|
+
onFiltered: "skip-entry"
|
|
195
|
+
});
|
|
196
|
+
const rootDir = resolveArchiveRoot(params.destDir, params.asset.archiveRoot);
|
|
197
|
+
await materializeAssetAliases({
|
|
198
|
+
rootDir,
|
|
199
|
+
asset: params.asset
|
|
200
|
+
});
|
|
201
|
+
return path.join(rootDir, params.asset.executable);
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
99
204
|
//#region extensions/llama-cpp/src/llama-server-install.ts
|
|
100
205
|
const DOWNLOAD_TIMEOUT_MS = 18e5;
|
|
101
206
|
const VERSION_TIMEOUT_MS = 15e3;
|
|
@@ -140,7 +245,7 @@ function readResponseSha256(response) {
|
|
|
140
245
|
}
|
|
141
246
|
async function downloadVerifiedFile(params) {
|
|
142
247
|
const partialPath = `${params.destination}.partial-${randomUUID()}`;
|
|
143
|
-
await
|
|
248
|
+
await fs$1.mkdir(path.dirname(params.destination), { recursive: true });
|
|
144
249
|
const { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } = await import("openclaw/plugin-sdk/ssrf-runtime");
|
|
145
250
|
try {
|
|
146
251
|
const { response, release } = await fetchWithSsrFGuard({
|
|
@@ -157,7 +262,7 @@ async function downloadVerifiedFile(params) {
|
|
|
157
262
|
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
263
|
const contentLength = Number(response.headers.get("content-length"));
|
|
159
264
|
const totalSize = params.expectedSize ?? (Number.isFinite(contentLength) && contentLength > 0 ? contentLength : 0);
|
|
160
|
-
const handle = await
|
|
265
|
+
const handle = await fs$1.open(partialPath, "wx", 384);
|
|
161
266
|
const hash = createHash("sha256");
|
|
162
267
|
let downloadedSize = 0;
|
|
163
268
|
let previousSize = 0;
|
|
@@ -188,38 +293,14 @@ async function downloadVerifiedFile(params) {
|
|
|
188
293
|
if (params.expectedSize && downloadedSize !== params.expectedSize) throw new Error(`download size mismatch: expected ${params.expectedSize}, got ${downloadedSize}`);
|
|
189
294
|
const actualSha256 = hash.digest("hex");
|
|
190
295
|
if (expectedSha256 && actualSha256 !== expectedSha256.toLowerCase()) throw new Error(`download SHA-256 mismatch: expected ${expectedSha256}, got ${actualSha256}`);
|
|
191
|
-
await
|
|
296
|
+
await fs$1.rename(partialPath, params.destination);
|
|
192
297
|
} finally {
|
|
193
298
|
await release();
|
|
194
299
|
}
|
|
195
300
|
} finally {
|
|
196
|
-
await
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async function extractZip(archivePath, destination) {
|
|
200
|
-
const zip = await JSZip.loadAsync(await fsp.readFile(archivePath));
|
|
201
|
-
for (const entry of Object.values(zip.files)) {
|
|
202
|
-
const normalized = path.posix.normalize(entry.name);
|
|
203
|
-
if (normalized.startsWith("/") || normalized === ".." || normalized.startsWith("../")) throw new Error(`unsafe path in llama-server archive: ${entry.name}`);
|
|
204
|
-
const outputPath = path.join(destination, ...normalized.split("/"));
|
|
205
|
-
if (entry.dir) await fsp.mkdir(outputPath, { recursive: true });
|
|
206
|
-
else {
|
|
207
|
-
await fsp.mkdir(path.dirname(outputPath), { recursive: true });
|
|
208
|
-
await fsp.writeFile(outputPath, await entry.async("nodebuffer"), { mode: 384 });
|
|
209
|
-
}
|
|
301
|
+
await fs$1.rm(partialPath, { force: true }).catch(() => void 0);
|
|
210
302
|
}
|
|
211
303
|
}
|
|
212
|
-
async function findExecutable(root, executable) {
|
|
213
|
-
for (const entry of await fsp.readdir(root, { withFileTypes: true })) {
|
|
214
|
-
const candidate = path.join(root, entry.name);
|
|
215
|
-
if (entry.isFile() && entry.name === executable) return candidate;
|
|
216
|
-
if (entry.isDirectory()) {
|
|
217
|
-
const nested = await findExecutable(candidate, executable).catch(() => void 0);
|
|
218
|
-
if (nested) return nested;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
throw new Error(`llama-server archive does not contain ${executable}`);
|
|
222
|
-
}
|
|
223
304
|
async function runVersion(command) {
|
|
224
305
|
return await new Promise((resolve, reject) => {
|
|
225
306
|
execFile(command, ["--version"], { timeout: VERSION_TIMEOUT_MS }, (error, stdout, stderr) => {
|
|
@@ -249,41 +330,39 @@ async function validateInstalledServer(command) {
|
|
|
249
330
|
async function installLlamaServer(asset) {
|
|
250
331
|
assertSupportedLinuxRuntime(asset);
|
|
251
332
|
const { installDir, command } = resolveManagedLlamaServerPaths(asset);
|
|
252
|
-
if (await
|
|
333
|
+
if (await fs$1.stat(command).then((stat) => stat.isFile()).catch(() => false)) {
|
|
253
334
|
await validateInstalledServer(command);
|
|
254
335
|
return command;
|
|
255
336
|
}
|
|
256
337
|
const dataDir = resolveLlamaCppDataDir();
|
|
257
338
|
const archivePath = path.join(dataDir, `.download-${randomUUID()}-${asset.name}`);
|
|
258
339
|
const extractDir = path.join(dataDir, `.extract-${randomUUID()}`);
|
|
259
|
-
await
|
|
340
|
+
await fs$1.mkdir(dataDir, { recursive: true });
|
|
260
341
|
try {
|
|
261
342
|
await downloadVerifiedFile({
|
|
262
343
|
url: assetUrl(asset),
|
|
263
344
|
destination: archivePath,
|
|
264
345
|
expectedSha256: asset.sha256
|
|
265
346
|
});
|
|
266
|
-
await
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
preservePaths: false
|
|
347
|
+
await fs$1.mkdir(extractDir, { recursive: true });
|
|
348
|
+
const extractedCommand = await extractLlamaServerArchive({
|
|
349
|
+
archivePath,
|
|
350
|
+
destDir: extractDir,
|
|
351
|
+
asset
|
|
272
352
|
});
|
|
273
|
-
const extractedCommand = await findExecutable(extractDir, asset.executable);
|
|
274
353
|
const extractedRoot = path.dirname(extractedCommand);
|
|
275
|
-
await
|
|
354
|
+
await fs$1.chmod(extractedCommand, 493);
|
|
276
355
|
await validateInstalledServer(extractedCommand);
|
|
277
|
-
await
|
|
278
|
-
await
|
|
356
|
+
await fs$1.mkdir(path.dirname(installDir), { recursive: true });
|
|
357
|
+
await fs$1.rm(installDir, {
|
|
279
358
|
recursive: true,
|
|
280
359
|
force: true
|
|
281
360
|
});
|
|
282
|
-
await
|
|
361
|
+
await fs$1.rename(extractedRoot, installDir);
|
|
283
362
|
await validateInstalledServer(command);
|
|
284
363
|
return command;
|
|
285
364
|
} finally {
|
|
286
|
-
await Promise.all([
|
|
365
|
+
await Promise.all([fs$1.rm(archivePath, { force: true }), fs$1.rm(extractDir, {
|
|
287
366
|
recursive: true,
|
|
288
367
|
force: true
|
|
289
368
|
})]);
|
|
@@ -396,7 +475,7 @@ function defaultArtifact(source) {
|
|
|
396
475
|
};
|
|
397
476
|
}
|
|
398
477
|
async function assertGguf(filePath) {
|
|
399
|
-
const handle = await
|
|
478
|
+
const handle = await fs$1.open(filePath, "r").catch((error) => {
|
|
400
479
|
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
480
|
throw error;
|
|
402
481
|
});
|
|
@@ -435,7 +514,7 @@ async function ensureLlamaCppModel(params) {
|
|
|
435
514
|
const pending = modelPromises.get(destination);
|
|
436
515
|
if (pending) return await pending;
|
|
437
516
|
const load = (async () => {
|
|
438
|
-
if (await
|
|
517
|
+
if (await fs$1.stat(destination).then((stat) => stat.isFile()).catch(() => false)) {
|
|
439
518
|
if (artifact.expectedSha256) {
|
|
440
519
|
if (await sha256File(destination) === artifact.expectedSha256) return destination;
|
|
441
520
|
} else {
|
|
@@ -509,14 +588,14 @@ function renderLlamaServerPreset(params) {
|
|
|
509
588
|
].join("\n");
|
|
510
589
|
}
|
|
511
590
|
async function writePreset(presetPath, contents) {
|
|
512
|
-
await
|
|
591
|
+
await fs$1.mkdir(path.dirname(presetPath), { recursive: true });
|
|
513
592
|
const temporary = `${presetPath}.tmp-${randomUUID()}`;
|
|
514
|
-
await
|
|
515
|
-
await
|
|
593
|
+
await fs$1.writeFile(temporary, contents, { mode: 384 });
|
|
594
|
+
await fs$1.rename(temporary, presetPath);
|
|
516
595
|
}
|
|
517
596
|
async function updatePreset(presetPath, params) {
|
|
518
597
|
const pending = (presetWritePromises.get(presetPath) ?? Promise.resolve()).catch(() => void 0).then(async () => {
|
|
519
|
-
const existing = await
|
|
598
|
+
const existing = await fs$1.readFile(presetPath, "utf8").catch((error) => {
|
|
520
599
|
if (asOptionalRecord(error)?.code === "ENOENT") return;
|
|
521
600
|
throw error;
|
|
522
601
|
});
|
|
@@ -604,7 +683,7 @@ async function ensureManagedLlamaServerForChat(params) {
|
|
|
604
683
|
});
|
|
605
684
|
if (!chatModelPath && resolveLlamaCppModelSource(params.model) === "hf:unsloth/gemma-4-E4B-it-GGUF/gemma-4-E4B-it-Q4_K_M.gguf") {
|
|
606
685
|
const legacy = path.join(resolveLegacyLlamaCppModelCacheDir(), "hf_unsloth_gemma-4-E4B-it-GGUF_gemma-4-E4B-it-Q4_K_M.gguf");
|
|
607
|
-
if (await
|
|
686
|
+
if (await fs$1.stat(legacy).then((stat) => stat.isFile()).catch(() => false)) chatModelPath = legacy;
|
|
608
687
|
}
|
|
609
688
|
chatModelPath = await ensureLlamaCppModel({
|
|
610
689
|
source: chatModelPath ?? resolveLlamaCppModelSource(params.model),
|
|
@@ -647,7 +726,7 @@ async function fetchEndpoint(url, accept) {
|
|
|
647
726
|
if (!response.ok) return { ok: false };
|
|
648
727
|
return {
|
|
649
728
|
ok: true,
|
|
650
|
-
value: accept === "json" ? await response
|
|
729
|
+
value: accept === "json" ? await readProviderJsonResponse(response, "llama-server inspection") : await readProviderTextResponse(response, "llama-server inspection")
|
|
651
730
|
};
|
|
652
731
|
} finally {
|
|
653
732
|
await release();
|
|
@@ -1543,7 +1622,7 @@ function configuredCandidates(config, scope) {
|
|
|
1543
1622
|
})).toSorted((a, b) => Number(b.model.id === primaryId) - Number(a.model.id === primaryId));
|
|
1544
1623
|
}
|
|
1545
1624
|
async function isFile(filePath) {
|
|
1546
|
-
return await
|
|
1625
|
+
return await fs$1.stat(filePath).then((stat) => stat.isFile()).catch(() => false);
|
|
1547
1626
|
}
|
|
1548
1627
|
async function resolveCachedCandidate(candidate) {
|
|
1549
1628
|
const source = resolveLlamaCppModelSource(candidate.model);
|
package/package.json
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/llama-cpp-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.9.1",
|
|
4
4
|
"description": "OpenClaw provider for managed and external llama.cpp servers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/openclaw/openclaw"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"jszip": "3.10.1",
|
|
12
|
-
"tar": "7.5.22"
|
|
13
|
-
},
|
|
14
10
|
"devDependencies": {
|
|
15
11
|
"@openclaw/plugin-sdk": "workspace:*"
|
|
16
12
|
},
|
|
@@ -24,10 +20,10 @@
|
|
|
24
20
|
"minHostVersion": ">=2026.6.2"
|
|
25
21
|
},
|
|
26
22
|
"compat": {
|
|
27
|
-
"pluginApi": ">=2026.
|
|
23
|
+
"pluginApi": ">=2026.9.1"
|
|
28
24
|
},
|
|
29
25
|
"build": {
|
|
30
|
-
"openclawVersion": "2026.
|
|
26
|
+
"openclawVersion": "2026.9.1"
|
|
31
27
|
},
|
|
32
28
|
"release": {
|
|
33
29
|
"bundleRuntimeDependencies": false,
|
|
@@ -44,7 +40,7 @@
|
|
|
44
40
|
"README.md"
|
|
45
41
|
],
|
|
46
42
|
"peerDependencies": {
|
|
47
|
-
"openclaw": ">=2026.
|
|
43
|
+
"openclaw": ">=2026.9.1"
|
|
48
44
|
},
|
|
49
45
|
"peerDependenciesMeta": {
|
|
50
46
|
"openclaw": {
|