@openclaw/llama-cpp-provider 2026.9.5 → 2026.9.7
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
|
package/dist/.setup/{managed-provider-config-BYvyYdAs.mjs → managed-provider-config-B99gmBnE.mjs}
RENAMED
|
@@ -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
|
|
62
|
+
function buildLlamaCppModel(model) {
|
|
66
63
|
return {
|
|
67
|
-
id:
|
|
68
|
-
name:
|
|
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:
|
|
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 =
|
|
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 ??
|
|
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 {
|
|
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
|
|
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";
|
|
@@ -12,13 +12,14 @@ import { fetchWithSsrFGuard, ssrfPolicyFromHttpBaseUrlAllowedOrigin } from "open
|
|
|
12
12
|
import { fetchConfiguredLocalOriginWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime-internal";
|
|
13
13
|
import { execFile } from "node:child_process";
|
|
14
14
|
import fs$1, { constants } from "node:fs";
|
|
15
|
+
import { sha256File } from "@openclaw/fs-safe/durability";
|
|
15
16
|
import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
|
|
16
17
|
import { ARCHIVE_LIMIT_ERROR_CODE, ArchiveLimitError, extractArchive } from "openclaw/plugin-sdk/archive";
|
|
17
18
|
import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput, upsertAuthProfileWithLock } from "openclaw/plugin-sdk/provider-auth";
|
|
18
19
|
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
19
20
|
import { removeAuthProfileConfig, removeProviderAuthProfilesWithLock, resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
|
|
20
21
|
import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
21
|
-
import
|
|
22
|
+
import { LiveModelCatalogHttpError, runLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
|
|
22
23
|
import { getCachedLiveCatalogValue } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
23
24
|
import { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, applyProviderDefaultModel, discoverOpenAICompatibleLocalModels } from "openclaw/plugin-sdk/provider-setup";
|
|
24
25
|
import { selectPreferredLocalModelId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
@@ -304,7 +305,7 @@ function rememberVerifiedFile(filePath, stat, sha256) {
|
|
|
304
305
|
if (oldest !== void 0) verifiedFiles.delete(oldest);
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
|
-
async function sha256File(filePath, signal) {
|
|
308
|
+
async function sha256File$1(filePath, signal) {
|
|
308
309
|
signal?.throwIfAborted();
|
|
309
310
|
try {
|
|
310
311
|
const identity = fileIdentity(await fs.stat(filePath, { bigint: true }));
|
|
@@ -314,16 +315,9 @@ async function sha256File(filePath, signal) {
|
|
|
314
315
|
const handle = await fs.open(filePath, "r");
|
|
315
316
|
try {
|
|
316
317
|
const before = fileIdentity(await handle.stat({ bigint: true }));
|
|
317
|
-
const
|
|
318
|
-
const input = handle.createReadStream({
|
|
319
|
-
autoClose: false,
|
|
320
|
-
highWaterMark: 1048576,
|
|
321
|
-
signal
|
|
322
|
-
});
|
|
323
|
-
for await (const chunk of input) hash.update(chunk);
|
|
318
|
+
const { digest: sha256 } = await sha256File(handle, { signal });
|
|
324
319
|
const after = await handle.stat({ bigint: true });
|
|
325
320
|
if (before !== fileIdentity(after) || before !== fileIdentity(await fs.stat(filePath, { bigint: true }))) throw new Error(`File changed during integrity verification: ${filePath}. Retry setup.`);
|
|
326
|
-
const sha256 = hash.digest("hex");
|
|
327
321
|
rememberVerifiedFile(filePath, after, sha256);
|
|
328
322
|
return sha256;
|
|
329
323
|
} finally {
|
|
@@ -734,31 +728,10 @@ const GIB = 1024 ** 3;
|
|
|
734
728
|
function modelRecipe(params) {
|
|
735
729
|
const source = params.source ?? `hf:${params.repository}/${params.file}#${params.revision}`;
|
|
736
730
|
return {
|
|
737
|
-
model: {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
reasoning: params.reasoning ?? false,
|
|
742
|
-
input: ["text"],
|
|
743
|
-
cost: {
|
|
744
|
-
input: 0,
|
|
745
|
-
output: 0,
|
|
746
|
-
cacheRead: 0,
|
|
747
|
-
cacheWrite: 0
|
|
748
|
-
},
|
|
749
|
-
contextWindow: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
|
|
750
|
-
contextTokens: DEFAULT_LLAMA_CPP_CONTEXT_SIZE,
|
|
751
|
-
maxTokens: params.maxTokens ?? 2048,
|
|
752
|
-
params: {
|
|
753
|
-
modelPath: source,
|
|
754
|
-
contextSize: DEFAULT_LLAMA_CPP_CONTEXT_SIZE
|
|
755
|
-
},
|
|
756
|
-
compat: {
|
|
757
|
-
supportsTools: true,
|
|
758
|
-
supportsUsageInStreaming: true,
|
|
759
|
-
toolSchemaProfile: "llamacpp"
|
|
760
|
-
}
|
|
761
|
-
},
|
|
731
|
+
model: buildLlamaCppModel({
|
|
732
|
+
...params,
|
|
733
|
+
source
|
|
734
|
+
}),
|
|
762
735
|
sizeBytes: params.sizeBytes,
|
|
763
736
|
memoryBytes: params.memoryGiB * GIB,
|
|
764
737
|
minimumSystemMemoryBytes: params.minimumSystemGiB * GIB,
|
|
@@ -1062,7 +1035,7 @@ async function ensureLlamaCppModel(params) {
|
|
|
1062
1035
|
const destination = path.join(params.cacheDir, artifact.fileName);
|
|
1063
1036
|
const load = modelPromises.get(destination) ?? (async () => {
|
|
1064
1037
|
const exists = await fs.stat(destination).then((stat) => stat.isFile()).catch(() => false);
|
|
1065
|
-
if (exists && artifact.expectedSha256 && await sha256File(destination, params.signal) === artifact.expectedSha256) return destination;
|
|
1038
|
+
if (exists && artifact.expectedSha256 && await sha256File$1(destination, params.signal) === artifact.expectedSha256) return destination;
|
|
1066
1039
|
if (exists && !artifact.expectedSha256) {
|
|
1067
1040
|
await assertGguf(destination);
|
|
1068
1041
|
return destination;
|
|
@@ -1295,11 +1268,8 @@ async function inspectLlamaServerRuntime(params) {
|
|
|
1295
1268
|
//#endregion
|
|
1296
1269
|
//#region extensions/llama-cpp/src/embedding-provider.ts
|
|
1297
1270
|
const LOCAL_EMBEDDING_RUNTIME_FACTS = Symbol.for("openclaw.localEmbeddingRuntimeFacts");
|
|
1298
|
-
function readLocalOptions(options) {
|
|
1299
|
-
return options.local ?? {};
|
|
1300
|
-
}
|
|
1301
1271
|
function readIdentityLocalOptions(options) {
|
|
1302
|
-
const local =
|
|
1272
|
+
const local = options.local ?? {};
|
|
1303
1273
|
const provider = options.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
1304
1274
|
return provider?.localService ? {
|
|
1305
1275
|
...local,
|
|
@@ -1315,39 +1285,30 @@ function createCacheKeyData(model, dimensions) {
|
|
|
1315
1285
|
}
|
|
1316
1286
|
function resolveModelIdentity(local, dimensions) {
|
|
1317
1287
|
const embeddingModel = resolveLlamaCppEmbeddingModel(local);
|
|
1318
|
-
const
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
aliases
|
|
1325
|
-
}
|
|
1326
|
-
const aliases = /* @__PURE__ */ new Set([
|
|
1327
|
-
currentDefaultPath,
|
|
1328
|
-
legacyDefaultPath,
|
|
1329
|
-
DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE
|
|
1330
|
-
]);
|
|
1331
|
-
if (embeddingModel.source !== "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf") aliases.add(embeddingModel.source);
|
|
1288
|
+
const model = embeddingModel.isDefault ? DEFAULT_LLAMA_CPP_EMBEDDING_MODEL : embeddingModel.source;
|
|
1289
|
+
const aliases = /* @__PURE__ */ new Set();
|
|
1290
|
+
if (embeddingModel.isDefault) {
|
|
1291
|
+
aliases.add(path.resolve(embeddingModel.cacheDir, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE));
|
|
1292
|
+
aliases.add(path.resolve(resolveLegacyLlamaCppModelCacheDir(), DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE));
|
|
1293
|
+
aliases.add(DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE);
|
|
1294
|
+
if (embeddingModel.source !== model) aliases.add(embeddingModel.source);
|
|
1295
|
+
}
|
|
1332
1296
|
return {
|
|
1333
|
-
model
|
|
1334
|
-
cacheKeyData: createCacheKeyData(
|
|
1335
|
-
aliases: [...aliases].map((
|
|
1336
|
-
model,
|
|
1337
|
-
cacheKeyData: createCacheKeyData(
|
|
1297
|
+
model,
|
|
1298
|
+
cacheKeyData: createCacheKeyData(model, dimensions),
|
|
1299
|
+
aliases: [...aliases].map((alias) => ({
|
|
1300
|
+
model: alias,
|
|
1301
|
+
cacheKeyData: createCacheKeyData(alias, dimensions)
|
|
1338
1302
|
}))
|
|
1339
1303
|
};
|
|
1340
1304
|
}
|
|
1341
|
-
function resolveConfiguredProvider(options) {
|
|
1342
|
-
return resolveManagedLlamaCppProviderConfig(options.config);
|
|
1343
|
-
}
|
|
1344
1305
|
function resolveProviderPort(provider) {
|
|
1345
1306
|
const port = Number(new URL(provider.baseUrl ?? "").port);
|
|
1346
1307
|
if (!Number.isInteger(port) || port <= 0) throw new Error("Managed llama.cpp provider baseUrl must include a loopback port.");
|
|
1347
1308
|
return port;
|
|
1348
1309
|
}
|
|
1349
1310
|
async function prepareEmbeddingServer(options, embeddingSource, embeddingModelIsDefault) {
|
|
1350
|
-
const provider =
|
|
1311
|
+
const provider = resolveManagedLlamaCppProviderConfig(options.config);
|
|
1351
1312
|
const embeddingModelPath = await ensureLlamaCppModel({
|
|
1352
1313
|
source: embeddingSource,
|
|
1353
1314
|
cacheDir: resolveLlamaCppModelCacheDir(provider),
|
|
@@ -1428,7 +1389,7 @@ const llamaCppEmbeddingProviderAdapter = {
|
|
|
1428
1389
|
provider: wrapProvider({
|
|
1429
1390
|
provider: result.provider,
|
|
1430
1391
|
canonicalModel: identity.model,
|
|
1431
|
-
baseUrl:
|
|
1392
|
+
baseUrl: resolveManagedLlamaCppProviderConfig(options.config).baseUrl ?? ""
|
|
1432
1393
|
}),
|
|
1433
1394
|
runtime: {
|
|
1434
1395
|
id: "local",
|
|
@@ -1449,7 +1410,7 @@ function hasLlamaServerAuthorizationHeader(headers) {
|
|
|
1449
1410
|
}
|
|
1450
1411
|
function shouldUseLlamaServerSyntheticAuth(providerConfig) {
|
|
1451
1412
|
const apiKey = normalizeOptionalSecretInput(providerConfig?.apiKey)?.trim();
|
|
1452
|
-
return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !==
|
|
1413
|
+
return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !== "llama-cpp-local" && apiKey !== CUSTOM_LOCAL_AUTH_MARKER);
|
|
1453
1414
|
}
|
|
1454
1415
|
async function resolveLlamaServerProviderHeaders(params) {
|
|
1455
1416
|
const headers = asOptionalRecord(params.headers);
|
|
@@ -1489,14 +1450,10 @@ const LLAMA_SERVER_DEFAULT_ORIGIN = "http://127.0.0.1:8080";
|
|
|
1489
1450
|
const LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR = "LLAMA_SERVER_API_KEY";
|
|
1490
1451
|
//#endregion
|
|
1491
1452
|
//#region extensions/llama-cpp/src/external-server/endpoint.ts
|
|
1492
|
-
function toFetchableBaseUrl(value) {
|
|
1493
|
-
if (/^[a-z][a-z\d+.-]*:\/\//iu.test(value)) return value;
|
|
1494
|
-
return `http://${value}`;
|
|
1495
|
-
}
|
|
1496
1453
|
/** Resolves the server origin and its OpenAI-compatible `/v1` inference base. */
|
|
1497
1454
|
function resolveLlamaServerEndpoint(configuredBaseUrl) {
|
|
1498
1455
|
const configured = configuredBaseUrl?.trim() || "http://127.0.0.1:8080";
|
|
1499
|
-
const parsed = new URL(
|
|
1456
|
+
const parsed = new URL(/^[a-z][a-z\d+.-]*:\/\//iu.test(configured) ? configured : `http://${configured}`);
|
|
1500
1457
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`Unsupported llama-server protocol: ${parsed.protocol}`);
|
|
1501
1458
|
if (parsed.username || parsed.password) throw new TypeError("llama-server base URL must not contain credentials");
|
|
1502
1459
|
parsed.pathname = parsed.pathname.replace(/\/+$/u, "").replace(/\/v1$/iu, "") || "/";
|
|
@@ -1586,26 +1543,18 @@ function mapLlamaServerModel(row, props) {
|
|
|
1586
1543
|
failed: row.status?.failed === true
|
|
1587
1544
|
};
|
|
1588
1545
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
const
|
|
1592
|
-
const merged = [...explicit];
|
|
1593
|
-
const seen = new Set(explicit.map((model) => model.id));
|
|
1546
|
+
function buildLlamaServerProviderConfig(params) {
|
|
1547
|
+
const models = Array.isArray(params.configured?.models) ? [...params.configured.models] : [];
|
|
1548
|
+
const seen = new Set(models.map((model) => model.id));
|
|
1594
1549
|
for (const discovered of params.discoveredModels) {
|
|
1595
1550
|
if (seen.has(discovered.config.id)) continue;
|
|
1596
1551
|
seen.add(discovered.config.id);
|
|
1597
|
-
|
|
1552
|
+
models.push(discovered.config);
|
|
1598
1553
|
}
|
|
1599
|
-
return merged;
|
|
1600
|
-
}
|
|
1601
|
-
function buildLlamaServerProviderConfig(params) {
|
|
1602
1554
|
return normalizeLlamaServerProviderConfig({
|
|
1603
1555
|
...params.configured,
|
|
1604
1556
|
baseUrl: params.configured?.baseUrl ?? "http://127.0.0.1:8080",
|
|
1605
|
-
models
|
|
1606
|
-
explicitModels: params.configured?.models,
|
|
1607
|
-
discoveredModels: params.discoveredModels
|
|
1608
|
-
})
|
|
1557
|
+
models
|
|
1609
1558
|
});
|
|
1610
1559
|
}
|
|
1611
1560
|
//#endregion
|
|
@@ -1654,36 +1603,6 @@ async function discoverLlamaServer(params) {
|
|
|
1654
1603
|
}
|
|
1655
1604
|
//#endregion
|
|
1656
1605
|
//#region extensions/llama-cpp/src/external-server/provider.ts
|
|
1657
|
-
const liveCatalogSdk = liveCatalogRuntime;
|
|
1658
|
-
async function runLlamaServerCatalog(params) {
|
|
1659
|
-
if (liveCatalogSdk.runLiveProviderCatalog) return await liveCatalogSdk.runLiveProviderCatalog(params);
|
|
1660
|
-
const identity = {
|
|
1661
|
-
provider: params.providerId,
|
|
1662
|
-
...params.profileId ? { profileId: params.profileId } : {}
|
|
1663
|
-
};
|
|
1664
|
-
try {
|
|
1665
|
-
const result = await params.run();
|
|
1666
|
-
return result ? {
|
|
1667
|
-
...result,
|
|
1668
|
-
outcomes: [...result.outcomes ?? [], {
|
|
1669
|
-
...identity,
|
|
1670
|
-
status: "ready"
|
|
1671
|
-
}]
|
|
1672
|
-
} : result;
|
|
1673
|
-
} catch (error) {
|
|
1674
|
-
return {
|
|
1675
|
-
providers: {},
|
|
1676
|
-
outcomes: [error instanceof liveCatalogRuntime.LiveModelCatalogHttpError && (error.status === 401 || error.status === 403) ? {
|
|
1677
|
-
...identity,
|
|
1678
|
-
status: "auth-rejected",
|
|
1679
|
-
rejectionScope: "catalog"
|
|
1680
|
-
} : {
|
|
1681
|
-
...identity,
|
|
1682
|
-
status: "unavailable"
|
|
1683
|
-
}]
|
|
1684
|
-
};
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
1606
|
/** Discovers external llama-server models for provider runtime resolution. */
|
|
1688
1607
|
async function discoverLlamaServerProvider(ctx) {
|
|
1689
1608
|
const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
@@ -1695,7 +1614,7 @@ async function discoverLlamaServerProvider(ctx) {
|
|
|
1695
1614
|
});
|
|
1696
1615
|
const authApiKey = auth.discoveryApiKey ?? auth.apiKey;
|
|
1697
1616
|
const apiKey = hasLlamaServerAuthorizationHeader(headers) || authApiKey && isNonSecretApiKeyMarker(authApiKey) ? void 0 : authApiKey;
|
|
1698
|
-
return await
|
|
1617
|
+
return await runLiveProviderCatalog({
|
|
1699
1618
|
providerId: LLAMA_CPP_PROVIDER_ID,
|
|
1700
1619
|
profileId: apiKey ? auth.profileId : void 0,
|
|
1701
1620
|
run: async () => {
|
|
@@ -1707,7 +1626,7 @@ async function discoverLlamaServerProvider(ctx) {
|
|
|
1707
1626
|
});
|
|
1708
1627
|
if (discovery.kind !== "success") {
|
|
1709
1628
|
if (!configured && !apiKey && !headers) return null;
|
|
1710
|
-
throw discovery.kind === "http-error" ? new
|
|
1629
|
+
throw discovery.kind === "http-error" ? new LiveModelCatalogHttpError(LLAMA_CPP_PROVIDER_ID, discovery.status) : discovery.error;
|
|
1711
1630
|
}
|
|
1712
1631
|
return { provider: buildLlamaServerProviderConfig({
|
|
1713
1632
|
configured,
|
|
@@ -1884,15 +1803,6 @@ async function discoverForSetup(ctx) {
|
|
|
1884
1803
|
return null;
|
|
1885
1804
|
}
|
|
1886
1805
|
}
|
|
1887
|
-
async function discoverWithAccess(params) {
|
|
1888
|
-
return await discoverLlamaServer({
|
|
1889
|
-
baseUrl: params.baseUrl,
|
|
1890
|
-
apiKey: params.apiKey,
|
|
1891
|
-
headers: params.headers,
|
|
1892
|
-
signal: params.signal,
|
|
1893
|
-
cacheTtlMs: 0
|
|
1894
|
-
});
|
|
1895
|
-
}
|
|
1896
1806
|
/** Read-only discovery for the guided local-provider setup ladder. */
|
|
1897
1807
|
async function detectLlamaServerSetup(ctx) {
|
|
1898
1808
|
const discovery = await discoverForSetup(ctx);
|
|
@@ -1977,11 +1887,12 @@ async function runLlamaServerSetup(ctx) {
|
|
|
1977
1887
|
};
|
|
1978
1888
|
}
|
|
1979
1889
|
}
|
|
1980
|
-
const discovery = await
|
|
1890
|
+
const discovery = await discoverLlamaServer({
|
|
1981
1891
|
baseUrl: endpoint.inferenceBaseUrl,
|
|
1982
1892
|
apiKey,
|
|
1983
1893
|
headers,
|
|
1984
|
-
signal: ctx.signal
|
|
1894
|
+
signal: ctx.signal,
|
|
1895
|
+
cacheTtlMs: 0
|
|
1985
1896
|
});
|
|
1986
1897
|
if (discovery.kind !== "success") throw new Error(describeDiscoveryFailure(discovery));
|
|
1987
1898
|
const modelId = selectSetupModelId(discovery);
|
|
@@ -2037,10 +1948,11 @@ async function validateNonInteractiveDiscovery(ctx) {
|
|
|
2037
1948
|
credential: resolvedApiKey
|
|
2038
1949
|
};
|
|
2039
1950
|
} else persistence = { kind: "remove" };
|
|
2040
|
-
const discovery = await
|
|
1951
|
+
const discovery = await discoverLlamaServer({
|
|
2041
1952
|
baseUrl,
|
|
2042
1953
|
apiKey,
|
|
2043
|
-
headers
|
|
1954
|
+
headers,
|
|
1955
|
+
cacheTtlMs: 0
|
|
2044
1956
|
});
|
|
2045
1957
|
if (discovery.kind !== "success") {
|
|
2046
1958
|
ctx.runtime.error(describeDiscoveryFailure(discovery));
|
|
@@ -2071,9 +1983,7 @@ async function configureLlamaServerNonInteractive(ctx) {
|
|
|
2071
1983
|
if (!validated) return null;
|
|
2072
1984
|
const providerConfig = buildExistingProviderConfig({
|
|
2073
1985
|
config: ctx.config,
|
|
2074
|
-
|
|
2075
|
-
resetEndpoint: validated.resetEndpoint,
|
|
2076
|
-
persistence: validated.persistence
|
|
1986
|
+
...validated
|
|
2077
1987
|
});
|
|
2078
1988
|
let config = {
|
|
2079
1989
|
...ctx.config,
|
|
@@ -2470,7 +2380,7 @@ function registerLlamaCppProvider(api) {
|
|
|
2470
2380
|
},
|
|
2471
2381
|
run: runLlamaServerSetup,
|
|
2472
2382
|
validateNonInteractive: validateLlamaServerNonInteractive,
|
|
2473
|
-
runNonInteractive:
|
|
2383
|
+
runNonInteractive: configureLlamaServerNonInteractive
|
|
2474
2384
|
}],
|
|
2475
2385
|
catalog: {
|
|
2476
2386
|
order: "late",
|
|
@@ -2487,11 +2397,11 @@ function registerLlamaCppProvider(api) {
|
|
|
2487
2397
|
run: async () => ({ provider: buildLlamaCppProviderConfig() })
|
|
2488
2398
|
},
|
|
2489
2399
|
resolveSyntheticAuth: ({ providerConfig }) => providerConfig?.localService || shouldUseLlamaServerSyntheticAuth(providerConfig) ? {
|
|
2490
|
-
apiKey:
|
|
2400
|
+
apiKey: LLAMA_CPP_LOCAL_AUTH_MARKER,
|
|
2491
2401
|
source: providerConfig?.localService ? "managed local llama.cpp server" : hasLlamaServerAuthorizationHeader(providerConfig?.headers) ? "models.providers.llama-cpp.headers.Authorization" : "models.providers.llama-cpp (synthetic local key)",
|
|
2492
2402
|
mode: "api-key"
|
|
2493
2403
|
} : void 0,
|
|
2494
|
-
shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() ===
|
|
2404
|
+
shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() === "llama-cpp-local" || resolvedApiKey?.trim() === CUSTOM_LOCAL_AUTH_MARKER,
|
|
2495
2405
|
normalizeConfig: ({ providerConfig }) => providerConfig.localService ? providerConfig : normalizeLlamaServerProviderConfig(providerConfig),
|
|
2496
2406
|
prepareDynamicModel: async (ctx) => ctx.config?.models?.providers?.["llama-cpp"]?.localService ? void 0 : await prepareLlamaServerDynamicModel(ctx),
|
|
2497
2407
|
reconcileLocalService: reconcileManagedLlamaServer,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-
|
|
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.
|
|
3
|
+
"version": "2026.9.7",
|
|
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.
|
|
24
|
+
"pluginApi": ">=2026.9.7"
|
|
25
25
|
},
|
|
26
26
|
"build": {
|
|
27
|
-
"openclawVersion": "2026.9.
|
|
27
|
+
"openclawVersion": "2026.9.7"
|
|
28
28
|
},
|
|
29
29
|
"release": {
|
|
30
30
|
"bundleRuntimeDependencies": false,
|
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
"./dist/index.js"
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@openclaw/fs-safe": "0.21.1"
|
|
40
|
+
},
|
|
38
41
|
"files": [
|
|
39
42
|
"dist/**",
|
|
40
43
|
"openclaw.plugin.json",
|
|
@@ -43,7 +46,7 @@
|
|
|
43
46
|
"assets/activity.svg"
|
|
44
47
|
],
|
|
45
48
|
"peerDependencies": {
|
|
46
|
-
"openclaw": ">=2026.9.
|
|
49
|
+
"openclaw": ">=2026.9.7"
|
|
47
50
|
},
|
|
48
51
|
"peerDependenciesMeta": {
|
|
49
52
|
"openclaw": {
|