@openclaw/llama-cpp-provider 2026.10.10 → 2026.11.5-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.
- package/dist/.setup/{auth-config-DJJFzW-_.mjs → auth-config-GFuvSOHY.mjs} +1 -1
- package/dist/.setup/{discovery-CW4BYFnI.mjs → discovery-BzqfGNU5.mjs} +2 -3
- package/dist/.setup/{embedding-provider.runtime-COEhdT_8.mjs → embedding-provider.runtime-D5WYHk8V.mjs} +46 -37
- package/dist/.setup/{managed-provider-config-Cz1_Bnx9.mjs → managed-provider-config-XhvrVUR1.mjs} +1 -1
- package/dist/.setup/{managed-server-BPsuApNG.mjs → managed-server-CTer5Rq4.mjs} +394 -292
- package/dist/.setup/{media-catalog-CoQoxXtb.mjs → media-catalog-D-CRqGbe.mjs} +7 -211
- package/dist/.setup/{media-provider.runtime-YlkMRBHl.mjs → media-provider.runtime-CW2ZQBg4.mjs} +2 -2
- package/dist/.setup/{media-setup-BMn7h2QR.mjs → media-setup-DIZRVYUM.mjs} +9 -9
- package/dist/.setup/{provider-CHgYfn_q.mjs → provider-abJEzh8u.mjs} +4 -6
- package/dist/.setup/{provider-discovery-DfRE3MjJ.mjs → provider-discovery-6Hy2SktE.mjs} +2 -2
- package/dist/.setup/{setup-Bsr6thoJ.mjs → setup-4lK0M-lf.mjs} +123 -132
- package/dist/.setup/{setup-BGhlNiBF.mjs → setup-BnmsVffD.mjs} +7 -9
- package/dist/.setup/{stream-DhWCTeEa.mjs → stream-PxiV675a.mjs} +39 -11
- package/dist/.source-module-urls/2a292bf2cc9d15ab4011c4fb7ee888280524a76675c662fb0329d5dc914f3fba.json +1 -1
- package/dist/index.js +113 -117
- package/dist/provider-discovery.js +1 -1
- package/dist/provider-policy-api.js +1 -1
- package/package.json +5 -5
- package/dist/.setup/{defaults-D8fdQAQN.mjs → defaults-B-3wLNsP.mjs} +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as resolveLegacyLlamaCppModelCacheDir, D as resolveLlamaCppModelSource, E as resolveLlamaCppModelCacheDir, T as resolveLlamaCppEmbeddingModel, _ as LLAMA_CPP_PROVIDER_ID, b as buildLlamaCppProviderConfig, l as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, x as resolveCachedLlamaCppModelPath } from "./defaults-
|
|
1
|
+
import { C as resolveLegacyLlamaCppModelCacheDir, D as resolveLlamaCppModelSource, E as resolveLlamaCppModelCacheDir, T as resolveLlamaCppEmbeddingModel, _ as LLAMA_CPP_PROVIDER_ID, b as buildLlamaCppProviderConfig, l as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, x as resolveCachedLlamaCppModelPath } from "./defaults-B-3wLNsP.mjs";
|
|
2
2
|
import { o as resolveLlamaCppMediaModels } from "./media-config-92b6iCHm.mjs";
|
|
3
|
-
import { c as formatLlamaCppMemory, i as recommendLlamaCppModel,
|
|
4
|
-
import { ensureLlamaCppModel, n as UnsupportedLlamaServerHostError, prepareManagedLlamaServer, r as ensureLlamaServerInstalled, resolveLlamaCppModelDownloadSize } from "./managed-server-
|
|
5
|
-
import { n as buildLlamaCppAuthProfileRemovalPatch } from "./auth-config-
|
|
3
|
+
import { c as formatLlamaCppMemory, i as recommendLlamaCppModel, o as resolveLlamaCppModelCandidates, s as detectLlamaCppHardware } from "./media-catalog-D-CRqGbe.mjs";
|
|
4
|
+
import { a as resolveManagedLlamaServerPaths, ensureLlamaCppModel, n as UnsupportedLlamaServerHostError, o as selectLlamaServerAsset, prepareManagedLlamaServer, r as ensureLlamaServerInstalled, resolveLlamaCppModelDownloadSize } from "./managed-server-CTer5Rq4.mjs";
|
|
5
|
+
import { n as buildLlamaCppAuthProfileRemovalPatch } from "./auth-config-GFuvSOHY.mjs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import os from "node:os";
|
|
8
|
-
import fs from "node:fs/promises";
|
|
9
8
|
import { listAgentIds, resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
9
|
+
import { safeStat } from "openclaw/plugin-sdk/path-existence-runtime";
|
|
10
10
|
import { mergeDeep } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
11
11
|
// extensions/llama-cpp/src/setup.ts
|
|
12
12
|
const BYTES_PER_GB = 1e9;
|
|
@@ -37,9 +37,6 @@ async function configuredCandidates(config) {
|
|
|
37
37
|
const primaryId = primary.provider === "llama-cpp" ? primary.model : void 0;
|
|
38
38
|
return candidates.toSorted((a, b) => Number(b.model.id === primaryId) - Number(a.model.id === primaryId));
|
|
39
39
|
}
|
|
40
|
-
async function isFile(filePath) {
|
|
41
|
-
return await fs.stat(filePath).then((stat) => stat.isFile()).catch(() => false);
|
|
42
|
-
}
|
|
43
40
|
async function resolveCachedArtifact(source, cacheDir, signal) {
|
|
44
41
|
return await ensureLlamaCppModel({
|
|
45
42
|
source,
|
|
@@ -53,10 +50,10 @@ async function resolveCachedArtifact(source, cacheDir, signal) {
|
|
|
53
50
|
async function resolveCachedCandidate(candidate, signal) {
|
|
54
51
|
const source = resolveLlamaCppModelSource(candidate.model);
|
|
55
52
|
const resolved = resolveCachedLlamaCppModelPath(candidate);
|
|
56
|
-
if (resolved && await
|
|
53
|
+
if (resolved && (await safeStat(resolved))?.isFile()) return resolved;
|
|
57
54
|
if (candidate.model.id === "gemma-4-e4b-it-q4_k_m") {
|
|
58
55
|
const legacy = path.join(resolveLegacyLlamaCppModelCacheDir(), DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE);
|
|
59
|
-
if (await
|
|
56
|
+
if ((await safeStat(legacy))?.isFile()) return legacy;
|
|
60
57
|
}
|
|
61
58
|
if (/^(?:hf|huggingface|https):/iu.test(source)) return await resolveCachedArtifact(source, resolveLlamaCppModelCacheDir(candidate.provider), signal);
|
|
62
59
|
}
|
|
@@ -83,7 +80,7 @@ async function detectLlamaCppSetup(ctx) {
|
|
|
83
80
|
const existing = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
84
81
|
const command = existing?.localService?.command;
|
|
85
82
|
const presetPath = existing?.localService?.args?.find((_, index, args) => args[index - 1] === "--models-preset");
|
|
86
|
-
if (!command || !path.isAbsolute(command) || !await
|
|
83
|
+
if (!command || !path.isAbsolute(command) || !(await safeStat(command))?.isFile() || !presetPath || !(await safeStat(presetPath))?.isFile()) return null;
|
|
87
84
|
for (const candidate of await configuredCandidates(ctx.config)) if (await resolveCachedCandidate(candidate, ctx.signal)) return {
|
|
88
85
|
modelRef: `${LLAMA_CPP_PROVIDER_ID}/${candidate.model.id}`,
|
|
89
86
|
detail: "Managed llama.cpp server ready"
|
|
@@ -108,123 +105,6 @@ async function prepareLlamaCppSetup(ctx) {
|
|
|
108
105
|
}
|
|
109
106
|
});
|
|
110
107
|
}
|
|
111
|
-
function resolveEmbeddingSetup(config, cacheDir) {
|
|
112
|
-
const defaults = config.memory?.search;
|
|
113
|
-
const models = listAgentIds(config).flatMap((agentId) => {
|
|
114
|
-
const override = resolveAgentConfig(config, agentId)?.memory?.search;
|
|
115
|
-
if (!(override?.enabled ?? defaults?.enabled ?? true) || (override?.provider ?? defaults?.provider) !== "local") return [];
|
|
116
|
-
return [resolveLlamaCppEmbeddingModel({
|
|
117
|
-
modelPath: override?.local?.modelPath ?? defaults?.local?.modelPath,
|
|
118
|
-
modelCacheDir: cacheDir
|
|
119
|
-
})];
|
|
120
|
-
});
|
|
121
|
-
const model = models[0] ?? resolveLlamaCppEmbeddingModel({ modelCacheDir: cacheDir });
|
|
122
|
-
return {
|
|
123
|
-
model,
|
|
124
|
-
localMemoryIntent: models.length > 0,
|
|
125
|
-
conflict: models.some((candidate) => candidate.source !== model.source)
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async function resolveSetupPlan(ctx, candidates, embeddingModelIsDefault, localMemoryIntent, hardware, asset, runtimeNote) {
|
|
129
|
-
if (ctx.embeddingOnly) return await resolveEmbeddingOnlyPlan(ctx, candidates, localMemoryIntent);
|
|
130
|
-
let candidate = candidates[0];
|
|
131
|
-
const configuredPath = candidate ? await resolveCachedCandidate(candidate, ctx.signal) : void 0;
|
|
132
|
-
if (candidate && configuredPath) {
|
|
133
|
-
if (runtimeNote && !await ctx.prompter.confirm({
|
|
134
|
-
message: `${runtimeNote} Use cached ${candidate.model.name} on Gateway host ${os.hostname()} with the verified CPU runtime?`,
|
|
135
|
-
initialValue: false
|
|
136
|
-
})) return;
|
|
137
|
-
return {
|
|
138
|
-
kind: "chat",
|
|
139
|
-
candidate,
|
|
140
|
-
cachedPath: configuredPath
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
const existing = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
144
|
-
const provider = existing?.localService ? existing : buildLlamaCppProviderConfig();
|
|
145
|
-
const cacheDir = resolveLlamaCppModelCacheDir(provider);
|
|
146
|
-
if (candidate) {
|
|
147
|
-
const source = resolveLlamaCppModelSource(candidate.model);
|
|
148
|
-
let size;
|
|
149
|
-
try {
|
|
150
|
-
if (path.isAbsolute(source) || !/^[a-z][a-z\d+.-]*:/iu.test(source)) {
|
|
151
|
-
const cachedPath = await ensureLlamaCppModel({
|
|
152
|
-
source,
|
|
153
|
-
cacheDir,
|
|
154
|
-
download: false,
|
|
155
|
-
signal: ctx.signal
|
|
156
|
-
});
|
|
157
|
-
return {
|
|
158
|
-
kind: "chat",
|
|
159
|
-
candidate,
|
|
160
|
-
cachedPath
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
size = await resolveLlamaCppModelDownloadSize(source, cacheDir, ctx.signal);
|
|
164
|
-
} catch (error) {
|
|
165
|
-
ctx.signal?.throwIfAborted();
|
|
166
|
-
await ctx.prompter.note(`Cannot use configured model ${candidate.model.name}: ${error instanceof Error ? error.message : String(error)} Check params.modelPath and retry llama.cpp setup.`, "Setup skipped");
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
return await ctx.prompter.confirm({
|
|
170
|
-
message: `${runtimeNote ? `${runtimeNote}\n` : ""}Download ${candidate.model.name} (${size ? `${(size / BYTES_PER_GB).toFixed(1)} GB` : "size unknown"}), ${describeEmbeddingDownload(embeddingModelIsDefault)}, and the verified ${asset.backend.toUpperCase()} runtime on Gateway host ${os.hostname()}, then use this model?`,
|
|
171
|
-
initialValue: false
|
|
172
|
-
}) ? {
|
|
173
|
-
kind: "chat",
|
|
174
|
-
candidate
|
|
175
|
-
} : void 0;
|
|
176
|
-
}
|
|
177
|
-
const cachedModels = /* @__PURE__ */ new Map();
|
|
178
|
-
for (const recipe of resolveLlamaCppModelCandidates(hardware, asset.backend).recipes) {
|
|
179
|
-
const cached = await resolveCachedArtifact(resolveLlamaCppModelSource(recipe.model), cacheDir, ctx.signal);
|
|
180
|
-
if (cached) {
|
|
181
|
-
cachedModels.set(recipe.model.id, cached);
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const cachedEmbedding = embeddingModelIsDefault && Boolean(await resolveCachedArtifact("hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf", cacheDir, ctx.signal));
|
|
186
|
-
const recommendation = recommendLlamaCppModel(hardware, asset.backend, {
|
|
187
|
-
modelIds: new Set(cachedModels.keys()),
|
|
188
|
-
embedding: cachedEmbedding,
|
|
189
|
-
runtime: await isFile(resolveManagedLlamaServerPaths(asset).command)
|
|
190
|
-
});
|
|
191
|
-
if (recommendation.kind === "recommended") {
|
|
192
|
-
const { recipe } = recommendation;
|
|
193
|
-
const cachedPath = cachedModels.get(recipe.model.id);
|
|
194
|
-
candidate = {
|
|
195
|
-
model: recipe.model,
|
|
196
|
-
provider
|
|
197
|
-
};
|
|
198
|
-
const recommendationSummary = [
|
|
199
|
-
`Runs on Gateway host ${os.hostname()} (${hardware.platform}/${hardware.arch}), using ${asset.backend === "metal" ? "Apple Metal" : asset.backend === "cuda" ? "NVIDIA CUDA" : "the CPU"}.`,
|
|
200
|
-
`${formatLlamaCppMemory(hardware.totalMemoryBytes)} RAM; ${formatLlamaCppMemory(hardware.availableDiskBytes ?? 0)} free disk.`,
|
|
201
|
-
!hardware.sharedDisk ? `${formatLlamaCppMemory(hardware.availableRuntimeDiskBytes ?? 0)} free on the runtime volume.` : void 0,
|
|
202
|
-
runtimeNote,
|
|
203
|
-
recommendation.reason,
|
|
204
|
-
!embeddingModelIsDefault ? "This estimate includes the default embedding model; your configured embedding model may need more memory and disk space." : void 0,
|
|
205
|
-
"OpenClaw will check a real tool call before making this your default model."
|
|
206
|
-
].filter(Boolean).join("\n");
|
|
207
|
-
if (await ctx.prompter.confirm({
|
|
208
|
-
message: `${recommendationSummary}\n\n${cachedPath ? `Use cached ${recipe.model.name}, download any missing embedding and ${asset.backend.toUpperCase()} runtime files, then use this model?` : `Download ${recipe.model.name} (${(recipe.sizeBytes / BYTES_PER_GB).toFixed(1)} GB), ${describeEmbeddingDownload(embeddingModelIsDefault)}, and the verified ${asset.backend.toUpperCase()} runtime, then use this model?`}`,
|
|
209
|
-
initialValue: false
|
|
210
|
-
})) return {
|
|
211
|
-
kind: "chat",
|
|
212
|
-
candidate,
|
|
213
|
-
cachedPath
|
|
214
|
-
};
|
|
215
|
-
} else if (!localMemoryIntent) {
|
|
216
|
-
await ctx.prompter.note(recommendation.reason, "Setup skipped");
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const embeddingPlan = await resolveEmbeddingOnlyPlan(ctx, candidates, localMemoryIntent);
|
|
220
|
-
if (embeddingPlan) {
|
|
221
|
-
if (await ctx.prompter.confirm({
|
|
222
|
-
message: `${runtimeNote ? `${runtimeNote} ` : ""}Install a verified ${asset.backend.toUpperCase()} llama.cpp server on Gateway host ${os.hostname()} and download only ${describeEmbeddingDownload(embeddingModelIsDefault)}? Your chat model will stay unchanged.`,
|
|
223
|
-
initialValue: false
|
|
224
|
-
})) return embeddingPlan;
|
|
225
|
-
}
|
|
226
|
-
await ctx.prompter.note("Local model setup skipped.", "Setup skipped");
|
|
227
|
-
}
|
|
228
108
|
async function resolveEmbeddingOnlyPlan(ctx, candidates, localMemoryIntent) {
|
|
229
109
|
const existing = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
230
110
|
if (localMemoryIntent && existing && (!existing.localService || candidates.length > 0)) {
|
|
@@ -238,12 +118,21 @@ async function runLlamaCppSetup(ctx) {
|
|
|
238
118
|
const managedExisting = existing?.localService ? existing : void 0;
|
|
239
119
|
const mediaModels = resolveLlamaCppMediaModels(managedExisting);
|
|
240
120
|
const cacheDir = resolveLlamaCppModelCacheDir(managedExisting);
|
|
241
|
-
const
|
|
242
|
-
|
|
121
|
+
const defaults = ctx.config.memory?.search;
|
|
122
|
+
const models = listAgentIds(ctx.config).flatMap((agentId) => {
|
|
123
|
+
const override = resolveAgentConfig(ctx.config, agentId)?.memory?.search;
|
|
124
|
+
if (!(override?.enabled ?? defaults?.enabled ?? true) || (override?.provider ?? defaults?.provider) !== "local") return [];
|
|
125
|
+
return [resolveLlamaCppEmbeddingModel({
|
|
126
|
+
modelPath: override?.local?.modelPath ?? defaults?.local?.modelPath,
|
|
127
|
+
modelCacheDir: cacheDir
|
|
128
|
+
})];
|
|
129
|
+
});
|
|
130
|
+
const embeddingModel = models[0] ?? resolveLlamaCppEmbeddingModel({ modelCacheDir: cacheDir });
|
|
131
|
+
const localMemoryIntent = models.length > 0;
|
|
132
|
+
if (models.some((candidate) => candidate.source !== embeddingModel.source)) {
|
|
243
133
|
await ctx.prompter.note("Configured agents resolve to different local embedding models. Set memory.search.local.modelPath and any per-agent overrides to the same value, then retry llama.cpp setup.", "Setup skipped");
|
|
244
134
|
return { profiles: [] };
|
|
245
135
|
}
|
|
246
|
-
const embeddingModel = embeddingSetup.model;
|
|
247
136
|
const hardware = await detectLlamaCppHardware({
|
|
248
137
|
cacheDir,
|
|
249
138
|
signal: ctx.signal
|
|
@@ -257,7 +146,109 @@ async function runLlamaCppSetup(ctx) {
|
|
|
257
146
|
asset = selectLlamaServerAsset(hardware.platform, hardware.arch, { kind: "cpu" });
|
|
258
147
|
runtimeNote = `${error instanceof Error ? error.message : String(error)} This recommendation uses CPU execution.`;
|
|
259
148
|
}
|
|
260
|
-
const
|
|
149
|
+
const candidates = await configuredCandidates(ctx.config);
|
|
150
|
+
async function resolveSetupPlan() {
|
|
151
|
+
const embeddingModelIsDefault = embeddingModel.isDefault;
|
|
152
|
+
if (ctx.embeddingOnly) return await resolveEmbeddingOnlyPlan(ctx, candidates, localMemoryIntent);
|
|
153
|
+
let candidate = candidates[0];
|
|
154
|
+
const configuredPath = candidate ? await resolveCachedCandidate(candidate, ctx.signal) : void 0;
|
|
155
|
+
if (candidate && configuredPath) {
|
|
156
|
+
if (runtimeNote && !await ctx.prompter.confirm({
|
|
157
|
+
message: `${runtimeNote} Use cached ${candidate.model.name} on Gateway host ${os.hostname()} with the verified CPU runtime?`,
|
|
158
|
+
initialValue: false
|
|
159
|
+
})) return;
|
|
160
|
+
return {
|
|
161
|
+
kind: "chat",
|
|
162
|
+
candidate,
|
|
163
|
+
cachedPath: configuredPath
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const planExisting = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
167
|
+
const provider = planExisting?.localService ? planExisting : buildLlamaCppProviderConfig();
|
|
168
|
+
const planCacheDir = resolveLlamaCppModelCacheDir(provider);
|
|
169
|
+
if (candidate) {
|
|
170
|
+
const source = resolveLlamaCppModelSource(candidate.model);
|
|
171
|
+
let size;
|
|
172
|
+
try {
|
|
173
|
+
if (path.isAbsolute(source) || !/^[a-z][a-z\d+.-]*:/iu.test(source)) {
|
|
174
|
+
const cachedPath = await ensureLlamaCppModel({
|
|
175
|
+
source,
|
|
176
|
+
cacheDir: planCacheDir,
|
|
177
|
+
download: false,
|
|
178
|
+
signal: ctx.signal
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
kind: "chat",
|
|
182
|
+
candidate,
|
|
183
|
+
cachedPath
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
size = await resolveLlamaCppModelDownloadSize(source, planCacheDir, ctx.signal);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
ctx.signal?.throwIfAborted();
|
|
189
|
+
await ctx.prompter.note(`Cannot use configured model ${candidate.model.name}: ${error instanceof Error ? error.message : String(error)} Check params.modelPath and retry llama.cpp setup.`, "Setup skipped");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
return await ctx.prompter.confirm({
|
|
193
|
+
message: `${runtimeNote ? `${runtimeNote}\n` : ""}Download ${candidate.model.name} (${size ? `${(size / BYTES_PER_GB).toFixed(1)} GB` : "size unknown"}), ${describeEmbeddingDownload(embeddingModelIsDefault)}, and the verified ${asset.backend.toUpperCase()} runtime on Gateway host ${os.hostname()}, then use this model?`,
|
|
194
|
+
initialValue: false
|
|
195
|
+
}) ? {
|
|
196
|
+
kind: "chat",
|
|
197
|
+
candidate
|
|
198
|
+
} : void 0;
|
|
199
|
+
}
|
|
200
|
+
const cachedModels = /* @__PURE__ */ new Map();
|
|
201
|
+
for (const recipe of resolveLlamaCppModelCandidates(hardware, asset.backend).recipes) {
|
|
202
|
+
const cached = await resolveCachedArtifact(resolveLlamaCppModelSource(recipe.model), planCacheDir, ctx.signal);
|
|
203
|
+
if (cached) {
|
|
204
|
+
cachedModels.set(recipe.model.id, cached);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const cachedEmbedding = embeddingModelIsDefault && Boolean(await resolveCachedArtifact("hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf", planCacheDir, ctx.signal));
|
|
209
|
+
const recommendation = recommendLlamaCppModel(hardware, asset.backend, {
|
|
210
|
+
modelIds: new Set(cachedModels.keys()),
|
|
211
|
+
embedding: cachedEmbedding,
|
|
212
|
+
runtime: (await safeStat(resolveManagedLlamaServerPaths(asset).command))?.isFile() === true
|
|
213
|
+
});
|
|
214
|
+
if (recommendation.kind === "recommended") {
|
|
215
|
+
const { recipe } = recommendation;
|
|
216
|
+
const cachedPath = cachedModels.get(recipe.model.id);
|
|
217
|
+
candidate = {
|
|
218
|
+
model: recipe.model,
|
|
219
|
+
provider
|
|
220
|
+
};
|
|
221
|
+
const recommendationSummary = [
|
|
222
|
+
`Runs on Gateway host ${os.hostname()} (${hardware.platform}/${hardware.arch}), using ${asset.backend === "metal" ? "Apple Metal" : asset.backend === "cuda" ? "NVIDIA CUDA" : "the CPU"}.`,
|
|
223
|
+
`${formatLlamaCppMemory(hardware.totalMemoryBytes)} RAM; ${formatLlamaCppMemory(hardware.availableDiskBytes ?? 0)} free disk.`,
|
|
224
|
+
!hardware.sharedDisk ? `${formatLlamaCppMemory(hardware.availableRuntimeDiskBytes ?? 0)} free on the runtime volume.` : void 0,
|
|
225
|
+
runtimeNote,
|
|
226
|
+
recommendation.reason,
|
|
227
|
+
!embeddingModelIsDefault ? "This estimate includes the default embedding model; your configured embedding model may need more memory and disk space." : void 0,
|
|
228
|
+
"OpenClaw will check a real tool call before making this your default model."
|
|
229
|
+
].filter(Boolean).join("\n");
|
|
230
|
+
if (await ctx.prompter.confirm({
|
|
231
|
+
message: `${recommendationSummary}\n\n${cachedPath ? `Use cached ${recipe.model.name}, download any missing embedding and ${asset.backend.toUpperCase()} runtime files, then use this model?` : `Download ${recipe.model.name} (${(recipe.sizeBytes / BYTES_PER_GB).toFixed(1)} GB), ${describeEmbeddingDownload(embeddingModelIsDefault)}, and the verified ${asset.backend.toUpperCase()} runtime, then use this model?`}`,
|
|
232
|
+
initialValue: false
|
|
233
|
+
})) return {
|
|
234
|
+
kind: "chat",
|
|
235
|
+
candidate,
|
|
236
|
+
cachedPath
|
|
237
|
+
};
|
|
238
|
+
} else if (!localMemoryIntent) {
|
|
239
|
+
await ctx.prompter.note(recommendation.reason, "Setup skipped");
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const embeddingPlan = await resolveEmbeddingOnlyPlan(ctx, candidates, localMemoryIntent);
|
|
243
|
+
if (embeddingPlan) {
|
|
244
|
+
if (await ctx.prompter.confirm({
|
|
245
|
+
message: `${runtimeNote ? `${runtimeNote} ` : ""}Install a verified ${asset.backend.toUpperCase()} llama.cpp server on Gateway host ${os.hostname()} and download only ${describeEmbeddingDownload(embeddingModelIsDefault)}? Your chat model will stay unchanged.`,
|
|
246
|
+
initialValue: false
|
|
247
|
+
})) return embeddingPlan;
|
|
248
|
+
}
|
|
249
|
+
await ctx.prompter.note("Local model setup skipped.", "Setup skipped");
|
|
250
|
+
}
|
|
251
|
+
const plan = await resolveSetupPlan();
|
|
261
252
|
if (!plan) return { profiles: [] };
|
|
262
253
|
const progress = ctx.prompter.progress(`${ctx.embeddingOnly && runtimeNote ? `${runtimeNote}\n` : ""}Preparing managed llama.cpp server…`);
|
|
263
254
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as LLAMA_CPP_PROVIDER_ID, v as LLAMA_CPP_PROVIDER_LABEL } from "./defaults-
|
|
2
|
-
import { a as LLAMA_SERVER_DEFAULT_ORIGIN, i as LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR, r as resolveLlamaServerEndpoint, s as hasLlamaServerAuthorizationHeader } from "./provider-discovery-
|
|
3
|
-
import { i as resolveLlamaServerRuntimeApiKey, n as buildLlamaServerProviderConfig, r as resolveLlamaServerProviderHeaders, t as discoverLlamaServer } from "./discovery-
|
|
4
|
-
import { n as buildLlamaCppAuthProfileRemovalPatch, t as LLAMA_CPP_DEFAULT_PROFILE_ID } from "./auth-config-
|
|
1
|
+
import { _ as LLAMA_CPP_PROVIDER_ID, v as LLAMA_CPP_PROVIDER_LABEL } from "./defaults-B-3wLNsP.mjs";
|
|
2
|
+
import { a as LLAMA_SERVER_DEFAULT_ORIGIN, i as LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR, r as resolveLlamaServerEndpoint, s as hasLlamaServerAuthorizationHeader } from "./provider-discovery-6Hy2SktE.mjs";
|
|
3
|
+
import { i as resolveLlamaServerRuntimeApiKey, n as buildLlamaServerProviderConfig, r as resolveLlamaServerProviderHeaders, t as discoverLlamaServer } from "./discovery-BzqfGNU5.mjs";
|
|
4
|
+
import { n as buildLlamaCppAuthProfileRemovalPatch, t as LLAMA_CPP_DEFAULT_PROFILE_ID } from "./auth-config-GFuvSOHY.mjs";
|
|
5
5
|
import { applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, normalizeOptionalSecretInput } from "openclaw/plugin-sdk/provider-auth";
|
|
6
6
|
import { removeAuthProfileConfig, removeProviderAuthProfilesWithLock } from "openclaw/plugin-sdk/provider-auth-runtime";
|
|
7
7
|
import { applyProviderDefaultModel } from "openclaw/plugin-sdk/provider-setup";
|
|
@@ -160,16 +160,14 @@ async function prepareLlamaServerSetup(ctx) {
|
|
|
160
160
|
persistence: { kind: "preserve" }
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
/** Interactive setup for an existing llama-server endpoint. */
|
|
164
163
|
async function runLlamaServerSetup(ctx) {
|
|
165
164
|
const existing = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
166
|
-
const defaultOrigin = resolveLlamaServerEndpoint(existing?.baseUrl).origin;
|
|
167
165
|
const baseUrl = await ctx.prompter.text({
|
|
168
166
|
message: `${LLAMA_CPP_PROVIDER_LABEL} URL`,
|
|
169
|
-
initialValue:
|
|
167
|
+
initialValue: existing?.baseUrl ? resolveLlamaServerEndpoint(existing.baseUrl).origin : void 0,
|
|
170
168
|
placeholder: LLAMA_SERVER_DEFAULT_ORIGIN,
|
|
171
169
|
validate: (value) => {
|
|
172
|
-
if (!value
|
|
170
|
+
if (!value.trim()) return;
|
|
173
171
|
try {
|
|
174
172
|
resolveLlamaServerEndpoint(value);
|
|
175
173
|
return;
|
|
@@ -178,7 +176,7 @@ async function runLlamaServerSetup(ctx) {
|
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
});
|
|
181
|
-
const endpoint = resolveLlamaServerEndpoint(baseUrl);
|
|
179
|
+
const endpoint = resolveLlamaServerEndpoint(baseUrl.trim() || existing?.baseUrl);
|
|
182
180
|
const endpointChanged = Boolean(existing?.localService) || hasEndpointChanged(existing, endpoint.inferenceBaseUrl);
|
|
183
181
|
const resolvedHeaders = endpointChanged ? void 0 : await resolveLlamaServerProviderHeaders({
|
|
184
182
|
config: ctx.config,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "./defaults-
|
|
1
|
+
import "./defaults-B-3wLNsP.mjs";
|
|
2
2
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
4
4
|
import { setQwenChatTemplateThinking } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
5
|
+
import { createProviderWaitObserver } from "openclaw/plugin-sdk/provider-transport-runtime";
|
|
5
6
|
// extensions/llama-cpp/src/external-server/stream.ts
|
|
6
7
|
/** Maps shared structured-output requests to the shape accepted by older llama-server builds. */
|
|
7
8
|
function normalizeLlamaServerResponseFormat(payload, requestedResponseFormat) {
|
|
@@ -19,17 +20,44 @@ function wrapLlamaServerStream(ctx) {
|
|
|
19
20
|
return (model, context, options) => {
|
|
20
21
|
if (model.provider !== "llama-cpp") return underlying(model, context, options);
|
|
21
22
|
const onPayload = options?.onPayload;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const wait = createProviderWaitObserver(options);
|
|
24
|
+
try {
|
|
25
|
+
const source = underlying(model, context, {
|
|
26
|
+
...options,
|
|
27
|
+
onPayload: async (payload, requestModel) => {
|
|
28
|
+
const customized = await onPayload?.(payload, requestModel) ?? payload;
|
|
29
|
+
if (isRecord(customized)) {
|
|
30
|
+
if ((options?.reasoning ?? ctx.thinkingLevel) === "off") setQwenChatTemplateThinking(customized, false);
|
|
31
|
+
normalizeLlamaServerResponseFormat(customized, options?.responseFormat);
|
|
32
|
+
}
|
|
33
|
+
wait.start();
|
|
34
|
+
return customized;
|
|
29
35
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
});
|
|
37
|
+
if (!options?.onProviderWait) return source;
|
|
38
|
+
return Promise.resolve(source).then((stream) => {
|
|
39
|
+
stream.result().then(wait.stop, wait.stop);
|
|
40
|
+
return {
|
|
41
|
+
async *[Symbol.asyncIterator]() {
|
|
42
|
+
try {
|
|
43
|
+
for await (const event of stream) {
|
|
44
|
+
wait.stop();
|
|
45
|
+
yield event;
|
|
46
|
+
}
|
|
47
|
+
} finally {
|
|
48
|
+
wait.stop();
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
result: () => stream.result()
|
|
52
|
+
};
|
|
53
|
+
}, (error) => {
|
|
54
|
+
wait.stop();
|
|
55
|
+
throw error;
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
wait.stop();
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
33
61
|
};
|
|
34
62
|
}
|
|
35
63
|
export { wrapLlamaServerStream };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"entries":[{"output":"index.js","source":"extensions/llama-cpp/index.ts"},{"output":"provider-discovery.js","source":"extensions/llama-cpp/provider-discovery.ts"},{"output":"provider-policy-api.js","source":"extensions/llama-cpp/provider-policy-api.ts"}],"chunks":[{"output":".setup/auth-config-
|
|
1
|
+
{"version":3,"entries":[{"output":"index.js","source":"extensions/llama-cpp/index.ts"},{"output":"provider-discovery.js","source":"extensions/llama-cpp/provider-discovery.ts"},{"output":"provider-policy-api.js","source":"extensions/llama-cpp/provider-policy-api.ts"}],"chunks":[{"output":".setup/auth-config-GFuvSOHY.mjs","sha256":"c24f545e5d5381f4ea8b97d43c3f86d0560fbf11485e77a903d29606752cab79","facadeSource":null,"sources":["extensions/llama-cpp/src/auth-config.ts"]},{"output":".setup/defaults-B-3wLNsP.mjs","sha256":"3f4537c84767de10c7d635005a8ca074ac2c7bbfcf48acf47f9733b6d80f5e16","facadeSource":null,"sources":["extensions/llama-cpp/src/defaults.ts"]},{"output":".setup/discovery-BzqfGNU5.mjs","sha256":"66748fa2f8061729d0a39db45c9cb8515baf097a970d4121385da499b3e977e1","facadeSource":null,"sources":["extensions/llama-cpp/src/external-server/auth.ts","extensions/llama-cpp/src/external-server/discovery.ts","extensions/llama-cpp/src/external-server/models.ts"]},{"output":".setup/embedding-provider.runtime-D5WYHk8V.mjs","sha256":"be5e8d7edccbb85d961a1c7f80596132efaf9e19b9626153a3828534093f8698","facadeSource":"extensions/llama-cpp/src/embedding-provider.runtime.ts","sources":["extensions/llama-cpp/src/embedding-provider.runtime.ts","extensions/llama-cpp/src/managed-server-inspection.ts"]},{"output":".setup/managed-provider-config-XhvrVUR1.mjs","sha256":"0c1cd89c5840149f92ee3d6afefbde6b65d10e67a40f910b2fb48db5fabb68a0","facadeSource":null,"sources":["extensions/llama-cpp/src/managed-provider-config.ts"]},{"output":".setup/managed-server-CTer5Rq4.mjs","sha256":"7e1b3bc12c5b459b68080352f677ab4f90015c6eb2262cef0b8c2f1f70dd57ef","facadeSource":"extensions/llama-cpp/src/managed-server.ts","sources":["extensions/llama-cpp/src/llama-server-assets.ts","extensions/llama-cpp/src/llama-server-install.ts","extensions/llama-cpp/src/llama-server-preset.ts","extensions/llama-cpp/src/managed-server.ts","extensions/llama-cpp/src/runtime-error.ts"]},{"output":".setup/media-catalog-D-CRqGbe.mjs","sha256":"54fd57343c32fac68a23f5724b426f47c55df2abde6a8c58243994bac01e207f","facadeSource":null,"sources":["extensions/llama-cpp/src/hardware.ts","extensions/llama-cpp/src/media-catalog.ts","extensions/llama-cpp/src/model-catalog.ts"]},{"output":".setup/media-config-92b6iCHm.mjs","sha256":"63c1b29fa0a1b1934dbf5fdefdcb9564e02cd3948881f410e2aca62496451094","facadeSource":null,"sources":["extensions/llama-cpp/src/media-config.ts"]},{"output":".setup/media-provider.runtime-CW2ZQBg4.mjs","sha256":"8aaefd189c179c4a28bae4285eed7e77c63600055a24a9e4cf8eb0ee86ebb7a6","facadeSource":"extensions/llama-cpp/src/media-provider.runtime.ts","sources":["extensions/llama-cpp/src/media-provider.runtime.ts"]},{"output":".setup/media-setup-DIZRVYUM.mjs","sha256":"d50a170f9841adcbc41f5a5b11d2a142262ed951e86a751f4496ea0e76f9390c","facadeSource":"extensions/llama-cpp/src/media-setup.ts","sources":["extensions/llama-cpp/src/media-setup.ts","extensions/llama-cpp/src/media-verification-fixtures.ts"]},{"output":".setup/provider-abJEzh8u.mjs","sha256":"be13c810f301e97c0b9ba7341fa4d2f1ed8f80405c94e56cb78f87a18a5128c4","facadeSource":"extensions/llama-cpp/src/external-server/provider.ts","sources":["extensions/llama-cpp/src/external-server/provider.ts"]},{"output":".setup/provider-discovery-6Hy2SktE.mjs","sha256":"9042a2fec2303dbddc9a326bc9d6d1a89ab107e1f595fe890dfc60b0e6266b4b","facadeSource":null,"sources":["extensions/llama-cpp/provider-discovery.ts","extensions/llama-cpp/src/external-server/auth-policy.ts","extensions/llama-cpp/src/external-server/defaults.ts","extensions/llama-cpp/src/external-server/endpoint.ts"]},{"output":".setup/setup-4lK0M-lf.mjs","sha256":"b628fa38588351f0c4d0c62757e0b33da682e9d42f22777cfc49a39d886e41ef","facadeSource":"extensions/llama-cpp/src/setup.ts","sources":["extensions/llama-cpp/src/setup.ts"]},{"output":".setup/setup-BnmsVffD.mjs","sha256":"b8578b01b2dc10092c91964b11d845194490e7558ff7df25f04f61f65eb397c7","facadeSource":"extensions/llama-cpp/src/external-server/setup.ts","sources":["extensions/llama-cpp/src/external-server/setup.ts"]},{"output":".setup/stream-PxiV675a.mjs","sha256":"0089d54f6f0816677dabf11acddfb6a40226e24eb5c0a4c91036e08257add84b","facadeSource":"extensions/llama-cpp/src/external-server/stream.ts","sources":["extensions/llama-cpp/src/external-server/stream.ts"]},{"output":"index.js","sha256":"0cf08b96abbd24caedd8c816d6e6316f30e1ef762a54dac985dd3f1e25aae10f","facadeSource":"extensions/llama-cpp/index.ts","sources":["extensions/llama-cpp/index.ts","extensions/llama-cpp/src/embedding-provider.ts","extensions/llama-cpp/src/managed-provider.ts","extensions/llama-cpp/src/media-provider.ts"]},{"output":"provider-discovery.js","sha256":"ade4cdfa79c1ce849d650b974e0ad9c7f66ef1c69de9ede71b3588c191f76a73","facadeSource":"extensions/llama-cpp/provider-discovery.ts","sources":[]},{"output":"provider-policy-api.js","sha256":"f640665b89c854a5e185edde923e46f1e5576e925abbdb7b24115b221bab8505","facadeSource":"extensions/llama-cpp/provider-policy-api.ts","sources":["extensions/llama-cpp/provider-policy-api.ts"]}],"unrenderedSources":[]}
|