@openclaw/llama-cpp-provider 2026.10.5-beta.2 → 2026.10.5-beta.4

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.
@@ -113,12 +113,4 @@ function buildLlamaCppProviderConfig(params = {}) {
113
113
  };
114
114
  }
115
115
  //#endregion
116
- //#region extensions/llama-cpp/src/managed-provider-config.ts
117
- const MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE = "Local embeddings need the managed llama.cpp server config (llama-server). The in-process node-llama-cpp runtime was removed; semantic memory recall is degraded until setup. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.";
118
- function resolveManagedLlamaCppProviderConfig(config) {
119
- const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
120
- if (!provider?.localService || !provider.baseUrl) throw new Error(MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE);
121
- return provider;
122
- }
123
- //#endregion
124
- export { resolveCachedLlamaCppModelPath as C, resolveLlamaCppEmbeddingModel as D, resolveLlamaCppDataDir as E, resolveLlamaCppModelCacheDir as O, buildLlamaCppProviderConfig as S, resolveLegacyLlamaCppModelCacheDir as T, LLAMA_CPP_DEFAULT_PORT as _, DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE as a, LLAMA_CPP_PROVIDER_LABEL as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION as c, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE as d, DEFAULT_LLAMA_CPP_MODEL_ID as f, DEFAULT_LLAMA_CPP_MODEL_URI as g, DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES as h, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE as i, resolveLlamaCppModelSource as k, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as l, DEFAULT_LLAMA_CPP_MODEL_SHA256 as m, resolveManagedLlamaCppProviderConfig as n, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as o, DEFAULT_LLAMA_CPP_MODEL_REVISION as p, DEFAULT_LLAMA_CPP_CONTEXT_SIZE as r, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as s, MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE as t, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as u, LLAMA_CPP_LOCAL_AUTH_MARKER as v, resolveHomePath as w, buildLlamaCppModel as x, LLAMA_CPP_PROVIDER_ID as y };
116
+ export { resolveLegacyLlamaCppModelCacheDir as C, resolveLlamaCppModelSource as D, resolveLlamaCppModelCacheDir as E, resolveHomePath as S, resolveLlamaCppEmbeddingModel as T, LLAMA_CPP_PROVIDER_ID as _, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID as a, buildLlamaCppProviderConfig as b, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES as c, DEFAULT_LLAMA_CPP_MODEL_REVISION as d, DEFAULT_LLAMA_CPP_MODEL_SHA256 as f, LLAMA_CPP_LOCAL_AUTH_MARKER as g, LLAMA_CPP_DEFAULT_PORT as h, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL as i, DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE as l, DEFAULT_LLAMA_CPP_MODEL_URI as m, DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE as n, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION as o, DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES as p, DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE as r, DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256 as s, DEFAULT_LLAMA_CPP_CONTEXT_SIZE as t, DEFAULT_LLAMA_CPP_MODEL_ID as u, LLAMA_CPP_PROVIDER_LABEL as v, resolveLlamaCppDataDir as w, resolveCachedLlamaCppModelPath as x, buildLlamaCppModel as y };
@@ -0,0 +1,10 @@
1
+ import { _ as LLAMA_CPP_PROVIDER_ID } from "./defaults-ATX0SyoG.mjs";
2
+ //#region extensions/llama-cpp/src/managed-provider-config.ts
3
+ const MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE = "Local embeddings need the managed llama.cpp server config (llama-server). The in-process node-llama-cpp runtime was removed; semantic memory recall is degraded until setup. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.";
4
+ function resolveManagedLlamaCppProviderConfig(config) {
5
+ const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
6
+ if (!provider?.localService || !provider.baseUrl) throw new Error(MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE);
7
+ return provider;
8
+ }
9
+ //#endregion
10
+ export { resolveManagedLlamaCppProviderConfig as n, MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE as t };
@@ -0,0 +1,230 @@
1
+ import { _ as LLAMA_CPP_PROVIDER_ID } from "./defaults-ATX0SyoG.mjs";
2
+ import { n as normalizeLlamaServerProviderConfig, o as LLAMA_SERVER_DISCOVERY_TIMEOUT_MS, r as resolveLlamaServerEndpoint, s as hasLlamaServerAuthorizationHeader } from "./provider-discovery-CEcEBzKt.mjs";
3
+ import { asOptionalRecord, asPositiveSafeInteger } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import { isNonSecretApiKeyMarker } from "openclaw/plugin-sdk/provider-auth";
5
+ import { LiveModelCatalogHttpError, runLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
6
+ import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
7
+ import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
8
+ import { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, discoverOpenAICompatibleLocalModels } from "openclaw/plugin-sdk/provider-setup";
9
+ //#region \0rolldown/runtime.js
10
+ var __defProp = Object.defineProperty;
11
+ var __exportAll = (all, no_symbols) => {
12
+ let target = {};
13
+ for (var name in all) __defProp(target, name, {
14
+ get: all[name],
15
+ enumerable: true
16
+ });
17
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ return target;
19
+ };
20
+ //#endregion
21
+ //#region extensions/llama-cpp/src/external-server/auth.ts
22
+ async function resolveLlamaServerProviderHeaders(params) {
23
+ const headers = asOptionalRecord(params.headers);
24
+ if (!headers) return;
25
+ const resolved = {};
26
+ for (const [name, value] of Object.entries(headers)) {
27
+ if (!params.config) {
28
+ if (typeof value === "string" && value.trim()) resolved[name] = value.trim();
29
+ continue;
30
+ }
31
+ const path = `models.providers.${LLAMA_CPP_PROVIDER_ID}.headers[${JSON.stringify(name)}]`;
32
+ const header = await resolveConfiguredSecretInputString({
33
+ config: params.config,
34
+ env: params.env ?? process.env,
35
+ value,
36
+ path,
37
+ unresolvedReasonStyle: "detailed"
38
+ });
39
+ if (header.unresolvedRefReason) throw new Error(`${path}: ${header.unresolvedRefReason}`);
40
+ if (header.value) resolved[name] = header.value;
41
+ }
42
+ return Object.keys(resolved).length > 0 ? resolved : void 0;
43
+ }
44
+ async function resolveLlamaServerRuntimeApiKey(params) {
45
+ const apiKey = (await resolveApiKeyForProvider({
46
+ provider: LLAMA_CPP_PROVIDER_ID,
47
+ cfg: params.config,
48
+ agentDir: params.agentDir,
49
+ profileId: params.profileId,
50
+ lockedProfile: params.profileId !== void 0
51
+ })).apiKey?.trim();
52
+ return apiKey && !isNonSecretApiKeyMarker(apiKey) ? apiKey : void 0;
53
+ }
54
+ //#endregion
55
+ //#region extensions/llama-cpp/src/external-server/models.ts
56
+ function normalizeStatus(value) {
57
+ switch (value) {
58
+ case "unloaded":
59
+ case "loading":
60
+ case "loaded":
61
+ case "sleeping":
62
+ case "downloading": return value;
63
+ default: return "unknown";
64
+ }
65
+ }
66
+ function resolveMaxTokens(props, contextWindow) {
67
+ const params = props?.default_generation_settings?.params;
68
+ const advertised = asPositiveSafeInteger(params?.max_tokens) ?? asPositiveSafeInteger(params?.n_predict);
69
+ return Math.min(advertised ?? SELF_HOSTED_DEFAULT_MAX_TOKENS, contextWindow);
70
+ }
71
+ function resolveInput(row, props) {
72
+ const advertised = row.architecture?.input_modalities;
73
+ return Array.isArray(advertised) && advertised.includes("image") || props?.modalities?.vision === true ? ["text", "image"] : ["text"];
74
+ }
75
+ function buildCompat(props, useRuntimeDefaults) {
76
+ const caps = props?.chat_template_caps;
77
+ return {
78
+ supportsStore: false,
79
+ supportsDeveloperRole: false,
80
+ supportsReasoningEffort: caps?.supports_reasoning_effort === true,
81
+ supportsTemperature: true,
82
+ supportsUsageInStreaming: true,
83
+ ...typeof caps?.supports_tool_calls === "boolean" || useRuntimeDefaults ? { supportsTools: caps?.supports_tool_calls === true } : {},
84
+ supportsStrictMode: false,
85
+ supportsJsonSchemaResponseFormat: true,
86
+ requiresStringContent: caps?.supports_typed_content !== true,
87
+ maxTokensField: "max_tokens"
88
+ };
89
+ }
90
+ /** Maps one llama-server model row plus optional runtime properties into OpenClaw config. */
91
+ function mapLlamaServerModel(row, props, useRuntimeDefaults = true) {
92
+ const id = typeof row.id === "string" ? row.id.trim() : "";
93
+ if (!id || row.object !== void 0 && row.object !== "model") return null;
94
+ const contextWindow = asPositiveSafeInteger(props?.default_generation_settings?.n_ctx) ?? asPositiveSafeInteger(props?.n_ctx) ?? (useRuntimeDefaults ? SELF_HOSTED_DEFAULT_CONTEXT_WINDOW : void 0);
95
+ const compat = buildCompat(props, useRuntimeDefaults);
96
+ return {
97
+ config: {
98
+ id,
99
+ name: id,
100
+ reasoning: compat.supportsReasoningEffort === true,
101
+ input: resolveInput(row, props),
102
+ cost: { ...SELF_HOSTED_DEFAULT_COST },
103
+ contextWindow,
104
+ contextTokens: contextWindow,
105
+ maxTokens: resolveMaxTokens(props, contextWindow ?? SELF_HOSTED_DEFAULT_CONTEXT_WINDOW),
106
+ compat
107
+ },
108
+ status: normalizeStatus(row.status?.value),
109
+ failed: row.status?.failed === true
110
+ };
111
+ }
112
+ function buildLlamaServerProviderConfig(params) {
113
+ const baseUrl = resolveLlamaServerEndpoint(params.configured?.baseUrl).inferenceBaseUrl;
114
+ const discoveredById = new Map(params.discoveredModels.map(({ config }) => [config.id, config]));
115
+ const models = (params.configured?.models ?? []).map((configured) => {
116
+ const discovered = discoveredById.get(configured.id);
117
+ discoveredById.delete(configured.id);
118
+ const matchesRoute = (!configured.api || configured.api === "openai-completions") && resolveLlamaServerEndpoint(configured.baseUrl?.trim() || baseUrl).inferenceBaseUrl === baseUrl;
119
+ return discovered && matchesRoute ? Object.assign({}, discovered, configured, {
120
+ contextWindow: configured.contextWindow ?? discovered.contextWindow,
121
+ contextTokens: configured.contextTokens ?? discovered.contextTokens,
122
+ compat: {
123
+ ...discovered.compat,
124
+ ...configured.compat
125
+ }
126
+ }) : configured;
127
+ });
128
+ models.push(...discoveredById.values());
129
+ return normalizeLlamaServerProviderConfig({
130
+ ...params.configured,
131
+ baseUrl,
132
+ models
133
+ });
134
+ }
135
+ //#endregion
136
+ //#region extensions/llama-cpp/src/external-server/discovery.ts
137
+ /** Discovers llama-server models without loading, waking, or unloading them. */
138
+ async function discoverLlamaServer(params) {
139
+ const endpoint = resolveLlamaServerEndpoint(params.baseUrl);
140
+ const result = await discoverOpenAICompatibleLocalModels({
141
+ baseUrl: endpoint.inferenceBaseUrl,
142
+ serverBaseUrl: endpoint.origin,
143
+ apiKey: params.apiKey,
144
+ headers: params.headers,
145
+ label: "llama-server",
146
+ healthPath: "/health",
147
+ modelsPathOrder: "server-first",
148
+ routerModelProps: true,
149
+ timeoutMs: LLAMA_SERVER_DISCOVERY_TIMEOUT_MS,
150
+ signal: params.signal,
151
+ rawResult: true
152
+ });
153
+ if (result.kind !== "success") return {
154
+ ...result,
155
+ endpoint
156
+ };
157
+ return {
158
+ kind: "success",
159
+ endpoint,
160
+ models: result.rows.flatMap(({ model, props }) => {
161
+ const mapped = mapLlamaServerModel(model, props, params.useRuntimeDefaults);
162
+ return mapped ? [mapped] : [];
163
+ })
164
+ };
165
+ }
166
+ //#endregion
167
+ //#region extensions/llama-cpp/src/external-server/provider.ts
168
+ var provider_exports = /* @__PURE__ */ __exportAll({
169
+ discoverLlamaServerProvider: () => discoverLlamaServerProvider,
170
+ prepareLlamaServerDynamicModel: () => prepareLlamaServerDynamicModel
171
+ });
172
+ /** Discovers external llama-server models for provider runtime resolution. */
173
+ async function discoverLlamaServerProvider(ctx) {
174
+ const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
175
+ const auth = ctx.resolveProviderApiKey(LLAMA_CPP_PROVIDER_ID);
176
+ const headers = await resolveLlamaServerProviderHeaders({
177
+ config: ctx.config,
178
+ env: ctx.env,
179
+ headers: configured?.headers
180
+ });
181
+ const authApiKey = auth.discoveryApiKey ?? auth.apiKey;
182
+ const apiKey = hasLlamaServerAuthorizationHeader(headers) || authApiKey && isNonSecretApiKeyMarker(authApiKey) ? void 0 : authApiKey;
183
+ return await runLiveProviderCatalog({
184
+ providerId: LLAMA_CPP_PROVIDER_ID,
185
+ profileId: apiKey ? auth.profileId : void 0,
186
+ run: async () => {
187
+ const discovery = await discoverLlamaServer({
188
+ baseUrl: configured?.baseUrl,
189
+ apiKey,
190
+ headers
191
+ });
192
+ if (discovery.kind !== "success") {
193
+ if (!configured && !apiKey && !headers) return null;
194
+ throw discovery.kind === "http-error" ? new LiveModelCatalogHttpError(LLAMA_CPP_PROVIDER_ID, discovery.status) : discovery.error;
195
+ }
196
+ return { provider: buildLlamaServerProviderConfig({
197
+ configured,
198
+ discoveredModels: discovery.models
199
+ }) };
200
+ }
201
+ });
202
+ }
203
+ async function prepareLlamaServerDynamicModel(ctx) {
204
+ const apiKey = await resolveLlamaServerRuntimeApiKey({
205
+ config: ctx.config,
206
+ agentDir: ctx.agentDir,
207
+ profileId: ctx.authProfileId
208
+ });
209
+ const headers = await resolveLlamaServerProviderHeaders({
210
+ config: ctx.config,
211
+ env: process.env,
212
+ headers: ctx.providerConfig?.headers
213
+ });
214
+ const discovery = await discoverLlamaServer({
215
+ baseUrl: ctx.providerConfig?.baseUrl,
216
+ apiKey: hasLlamaServerAuthorizationHeader(headers) ? void 0 : apiKey,
217
+ headers
218
+ });
219
+ const model = discovery.kind === "success" ? discovery.models.find((entry) => entry.config.id === ctx.modelId) : void 0;
220
+ if (!model) return;
221
+ return {
222
+ ...model.config,
223
+ provider: LLAMA_CPP_PROVIDER_ID,
224
+ api: ctx.providerConfig?.api ?? "openai-completions",
225
+ baseUrl: resolveLlamaServerEndpoint(ctx.providerConfig?.baseUrl).inferenceBaseUrl,
226
+ input: model.config.input.filter((entry) => entry === "text" || entry === "image")
227
+ };
228
+ }
229
+ //#endregion
230
+ export { resolveLlamaServerProviderHeaders as a, buildLlamaServerProviderConfig as i, provider_exports as n, resolveLlamaServerRuntimeApiKey as o, discoverLlamaServer as r, prepareLlamaServerDynamicModel as t };
@@ -0,0 +1,84 @@
1
+ import { _ as LLAMA_CPP_PROVIDER_ID, b as buildLlamaCppProviderConfig, g as LLAMA_CPP_LOCAL_AUTH_MARKER, v as LLAMA_CPP_PROVIDER_LABEL } from "./defaults-ATX0SyoG.mjs";
2
+ import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { CUSTOM_LOCAL_AUTH_MARKER, hasConfiguredSecretInput, normalizeOptionalSecretInput } from "openclaw/plugin-sdk/provider-auth";
4
+ //#region extensions/llama-cpp/src/external-server/auth-policy.ts
5
+ function hasLlamaServerAuthorizationHeader(headers) {
6
+ const record = asOptionalRecord(headers);
7
+ if (!record) return false;
8
+ return Object.entries(record).some(([name, value]) => name.trim().toLowerCase() === "authorization" && hasConfiguredSecretInput(value));
9
+ }
10
+ function shouldUseLlamaServerSyntheticAuth(providerConfig) {
11
+ const apiKey = normalizeOptionalSecretInput(providerConfig?.apiKey)?.trim();
12
+ return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !== "llama-cpp-local" && apiKey !== CUSTOM_LOCAL_AUTH_MARKER);
13
+ }
14
+ //#endregion
15
+ //#region extensions/llama-cpp/src/external-server/defaults.ts
16
+ const LLAMA_SERVER_DEFAULT_ORIGIN = "http://127.0.0.1:8080";
17
+ const LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR = "LLAMA_SERVER_API_KEY";
18
+ const LLAMA_SERVER_DISCOVERY_TIMEOUT_MS = 5e3;
19
+ //#endregion
20
+ //#region extensions/llama-cpp/src/external-server/endpoint.ts
21
+ /** Resolves the server origin and its OpenAI-compatible `/v1` inference base. */
22
+ function resolveLlamaServerEndpoint(configuredBaseUrl) {
23
+ const configured = configuredBaseUrl?.trim() || "http://127.0.0.1:8080";
24
+ const parsed = new URL(/^[a-z][a-z\d+.-]*:\/\//iu.test(configured) ? configured : `http://${configured}`);
25
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`Unsupported llama-server protocol: ${parsed.protocol}`);
26
+ if (parsed.username || parsed.password) throw new TypeError("llama-server base URL must not contain credentials");
27
+ parsed.pathname = parsed.pathname.replace(/\/+$/u, "").replace(/\/v1$/iu, "") || "/";
28
+ parsed.search = "";
29
+ parsed.hash = "";
30
+ const origin = parsed.toString().replace(/\/$/u, "");
31
+ return {
32
+ origin,
33
+ inferenceBaseUrl: `${origin}/v1`
34
+ };
35
+ }
36
+ /** Canonicalizes persisted provider config for the shared OpenAI transport. */
37
+ function normalizeLlamaServerProviderConfig(provider) {
38
+ const endpoint = resolveLlamaServerEndpoint(provider.baseUrl);
39
+ const request = provider.request ?? {};
40
+ const normalizedRequest = typeof request.allowPrivateNetwork === "boolean" ? request : {
41
+ ...request,
42
+ allowPrivateNetwork: true
43
+ };
44
+ return {
45
+ ...provider,
46
+ baseUrl: endpoint.inferenceBaseUrl,
47
+ api: "openai-completions",
48
+ request: normalizedRequest
49
+ };
50
+ }
51
+ //#endregion
52
+ //#region extensions/llama-cpp/provider-discovery.ts
53
+ var provider_discovery_default = {
54
+ id: LLAMA_CPP_PROVIDER_ID,
55
+ label: LLAMA_CPP_PROVIDER_LABEL,
56
+ docsPath: "/plugins/llama-cpp",
57
+ envVars: [LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR],
58
+ auth: [],
59
+ catalog: {
60
+ order: "late",
61
+ run: async (ctx) => {
62
+ const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
63
+ if (configured?.localService) return { provider: buildLlamaCppProviderConfig({
64
+ existing: configured,
65
+ modelInventory: configured.models
66
+ }) };
67
+ const { discoverLlamaServerProvider } = await import("./provider-OCMqlJ0I.mjs").then((n) => n.n);
68
+ return await discoverLlamaServerProvider(ctx);
69
+ }
70
+ },
71
+ staticCatalog: {
72
+ order: "late",
73
+ run: async () => ({ provider: buildLlamaCppProviderConfig() })
74
+ },
75
+ resolveSyntheticAuth: ({ providerConfig }) => providerConfig?.localService || shouldUseLlamaServerSyntheticAuth(providerConfig) ? {
76
+ apiKey: LLAMA_CPP_LOCAL_AUTH_MARKER,
77
+ source: providerConfig?.localService ? "managed local llama.cpp server" : hasLlamaServerAuthorizationHeader(providerConfig?.headers) ? "models.providers.llama-cpp.headers.Authorization" : "models.providers.llama-cpp (synthetic local key)",
78
+ mode: "api-key"
79
+ } : void 0,
80
+ shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() === "llama-cpp-local" || resolvedApiKey?.trim() === CUSTOM_LOCAL_AUTH_MARKER,
81
+ normalizeConfig: ({ providerConfig }) => providerConfig.localService ? providerConfig : normalizeLlamaServerProviderConfig(providerConfig)
82
+ };
83
+ //#endregion
84
+ export { LLAMA_SERVER_DEFAULT_ORIGIN as a, LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR as i, normalizeLlamaServerProviderConfig as n, LLAMA_SERVER_DISCOVERY_TIMEOUT_MS as o, resolveLlamaServerEndpoint as r, hasLlamaServerAuthorizationHeader as s, provider_discovery_default as t };
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
- import { C as resolveCachedLlamaCppModelPath, D as resolveLlamaCppEmbeddingModel, E as resolveLlamaCppDataDir, O as resolveLlamaCppModelCacheDir, S as buildLlamaCppProviderConfig, T as resolveLegacyLlamaCppModelCacheDir, _ as LLAMA_CPP_DEFAULT_PORT, a as DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE, b as LLAMA_CPP_PROVIDER_LABEL, c as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, d as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, f as DEFAULT_LLAMA_CPP_MODEL_ID, g as DEFAULT_LLAMA_CPP_MODEL_URI, h as DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES, i as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, k as resolveLlamaCppModelSource, l as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256, m as DEFAULT_LLAMA_CPP_MODEL_SHA256, n as resolveManagedLlamaCppProviderConfig, o as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, p as DEFAULT_LLAMA_CPP_MODEL_REVISION, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, u as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES, v as LLAMA_CPP_LOCAL_AUTH_MARKER, w as resolveHomePath, x as buildLlamaCppModel, y as LLAMA_CPP_PROVIDER_ID } from "./.setup/managed-provider-config-D0abOkC_.mjs";
1
+ import { a as resolveLlamaServerProviderHeaders, i as buildLlamaServerProviderConfig, o as resolveLlamaServerRuntimeApiKey, r as discoverLlamaServer, t as prepareLlamaServerDynamicModel } from "./.setup/provider-OCMqlJ0I.mjs";
2
+ import { C as resolveLegacyLlamaCppModelCacheDir, D as resolveLlamaCppModelSource, E as resolveLlamaCppModelCacheDir, S as resolveHomePath, T as resolveLlamaCppEmbeddingModel, _ as LLAMA_CPP_PROVIDER_ID, a as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_ID, b as buildLlamaCppProviderConfig, c as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SIZE_BYTES, d as DEFAULT_LLAMA_CPP_MODEL_REVISION, f as DEFAULT_LLAMA_CPP_MODEL_SHA256, h as LLAMA_CPP_DEFAULT_PORT, i as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, l as DEFAULT_LLAMA_CPP_MODEL_CACHE_FILE, m as DEFAULT_LLAMA_CPP_MODEL_URI, n as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, o as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_REVISION, p as DEFAULT_LLAMA_CPP_MODEL_SIZE_BYTES, r as DEFAULT_LLAMA_CPP_EMBEDDING_CONTEXT_SIZE, s as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL_SHA256, u as DEFAULT_LLAMA_CPP_MODEL_ID, v as LLAMA_CPP_PROVIDER_LABEL, w as resolveLlamaCppDataDir, x as resolveCachedLlamaCppModelPath, y as buildLlamaCppModel } from "./.setup/defaults-ATX0SyoG.mjs";
3
+ import { n as resolveManagedLlamaCppProviderConfig } from "./.setup/managed-provider-config-Nd32gsuH.mjs";
4
+ import { a as LLAMA_SERVER_DEFAULT_ORIGIN, i as LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR, r as resolveLlamaServerEndpoint, s as hasLlamaServerAuthorizationHeader, t as provider_discovery_default } from "./.setup/provider-discovery-CEcEBzKt.mjs";
2
5
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
6
  import path from "node:path";
4
7
  import { getEmbeddingProvider } from "openclaw/plugin-sdk/embedding-providers";
5
8
  import os from "node:os";
6
- import { asOptionalRecord, asPositiveSafeInteger, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
9
+ import { asOptionalRecord, isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
7
10
  import { createHash, randomUUID } from "node:crypto";
8
11
  import fs from "node:fs/promises";
9
12
  import net from "node:net";
@@ -18,12 +21,11 @@ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
18
21
  import { toErrorObject } from "openclaw/plugin-sdk/error-runtime";
19
22
  import { ARCHIVE_LIMIT_ERROR_CODE, ArchiveLimitError, extractArchive } from "openclaw/plugin-sdk/archive";
20
23
  import { createSubsystemLogger } from "openclaw/plugin-sdk/logging-core";
21
- import { CUSTOM_LOCAL_AUTH_MARKER, applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, hasConfiguredSecretInput, isNonSecretApiKeyMarker, normalizeOptionalSecretInput, upsertAuthProfileWithLock } from "openclaw/plugin-sdk/provider-auth";
22
24
  import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
23
- import { removeAuthProfileConfig, removeProviderAuthProfilesWithLock, resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
24
- import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
25
- import { LiveModelCatalogHttpError, runLiveProviderCatalog } from "openclaw/plugin-sdk/provider-catalog-live-runtime";
26
- import { SELF_HOSTED_DEFAULT_CONTEXT_WINDOW, SELF_HOSTED_DEFAULT_COST, SELF_HOSTED_DEFAULT_MAX_TOKENS, applyProviderDefaultModel, discoverOpenAICompatibleLocalModels } from "openclaw/plugin-sdk/provider-setup";
25
+ import { applyAuthProfileConfig, buildApiKeyCredential, ensureApiKeyFromEnvOrPrompt, normalizeOptionalSecretInput } from "openclaw/plugin-sdk/provider-auth";
26
+ import { removeAuthProfileConfig, removeProviderAuthProfilesWithLock } from "openclaw/plugin-sdk/provider-auth-runtime";
27
+ import { applyProviderDefaultModel } from "openclaw/plugin-sdk/provider-setup";
28
+ import { upsertAuthProfileWithLockOrThrow } from "openclaw/plugin-sdk/provider-auth-api-key";
27
29
  import { selectPreferredLocalModelId } from "openclaw/plugin-sdk/provider-model-shared";
28
30
  import { streamSimple } from "openclaw/plugin-sdk/llm";
29
31
  import { setQwenChatTemplateThinking } from "openclaw/plugin-sdk/provider-stream-shared";
@@ -1761,251 +1763,6 @@ const llamaCppEmbeddingProviderAdapter = {
1761
1763
  }
1762
1764
  };
1763
1765
  //#endregion
1764
- //#region extensions/llama-cpp/src/external-server/auth.ts
1765
- function hasLlamaServerAuthorizationHeader(headers) {
1766
- const record = asOptionalRecord(headers);
1767
- if (!record) return false;
1768
- return Object.entries(record).some(([name, value]) => name.trim().toLowerCase() === "authorization" && hasConfiguredSecretInput(value));
1769
- }
1770
- function shouldUseLlamaServerSyntheticAuth(providerConfig) {
1771
- const apiKey = normalizeOptionalSecretInput(providerConfig?.apiKey)?.trim();
1772
- return !(hasConfiguredSecretInput(providerConfig?.apiKey) && apiKey !== "llama-cpp-local" && apiKey !== CUSTOM_LOCAL_AUTH_MARKER);
1773
- }
1774
- async function resolveLlamaServerProviderHeaders(params) {
1775
- const headers = asOptionalRecord(params.headers);
1776
- if (!headers) return;
1777
- const resolved = {};
1778
- for (const [name, value] of Object.entries(headers)) {
1779
- if (!params.config) {
1780
- if (typeof value === "string" && value.trim()) resolved[name] = value.trim();
1781
- continue;
1782
- }
1783
- const path = `models.providers.${LLAMA_CPP_PROVIDER_ID}.headers[${JSON.stringify(name)}]`;
1784
- const header = await resolveConfiguredSecretInputString({
1785
- config: params.config,
1786
- env: params.env ?? process.env,
1787
- value,
1788
- path,
1789
- unresolvedReasonStyle: "detailed"
1790
- });
1791
- if (header.unresolvedRefReason) throw new Error(`${path}: ${header.unresolvedRefReason}`);
1792
- if (header.value) resolved[name] = header.value;
1793
- }
1794
- return Object.keys(resolved).length > 0 ? resolved : void 0;
1795
- }
1796
- async function resolveLlamaServerRuntimeApiKey(params) {
1797
- const apiKey = (await resolveApiKeyForProvider({
1798
- provider: LLAMA_CPP_PROVIDER_ID,
1799
- cfg: params.config,
1800
- agentDir: params.agentDir,
1801
- profileId: params.profileId,
1802
- lockedProfile: params.profileId !== void 0
1803
- })).apiKey?.trim();
1804
- return apiKey && !isNonSecretApiKeyMarker(apiKey) ? apiKey : void 0;
1805
- }
1806
- //#endregion
1807
- //#region extensions/llama-cpp/src/external-server/defaults.ts
1808
- const LLAMA_SERVER_DEFAULT_ORIGIN = "http://127.0.0.1:8080";
1809
- const LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR = "LLAMA_SERVER_API_KEY";
1810
- const LLAMA_SERVER_DISCOVERY_TIMEOUT_MS = 5e3;
1811
- //#endregion
1812
- //#region extensions/llama-cpp/src/external-server/endpoint.ts
1813
- /** Resolves the server origin and its OpenAI-compatible `/v1` inference base. */
1814
- function resolveLlamaServerEndpoint(configuredBaseUrl) {
1815
- const configured = configuredBaseUrl?.trim() || "http://127.0.0.1:8080";
1816
- const parsed = new URL(/^[a-z][a-z\d+.-]*:\/\//iu.test(configured) ? configured : `http://${configured}`);
1817
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new TypeError(`Unsupported llama-server protocol: ${parsed.protocol}`);
1818
- if (parsed.username || parsed.password) throw new TypeError("llama-server base URL must not contain credentials");
1819
- parsed.pathname = parsed.pathname.replace(/\/+$/u, "").replace(/\/v1$/iu, "") || "/";
1820
- parsed.search = "";
1821
- parsed.hash = "";
1822
- const origin = parsed.toString().replace(/\/$/u, "");
1823
- return {
1824
- origin,
1825
- inferenceBaseUrl: `${origin}/v1`
1826
- };
1827
- }
1828
- /** Canonicalizes persisted provider config for the shared OpenAI transport. */
1829
- function normalizeLlamaServerProviderConfig(provider) {
1830
- const endpoint = resolveLlamaServerEndpoint(provider.baseUrl);
1831
- const request = provider.request ?? {};
1832
- const normalizedRequest = typeof request.allowPrivateNetwork === "boolean" ? request : {
1833
- ...request,
1834
- allowPrivateNetwork: true
1835
- };
1836
- return {
1837
- ...provider,
1838
- baseUrl: endpoint.inferenceBaseUrl,
1839
- api: "openai-completions",
1840
- request: normalizedRequest
1841
- };
1842
- }
1843
- //#endregion
1844
- //#region extensions/llama-cpp/src/external-server/models.ts
1845
- function normalizeStatus(value) {
1846
- switch (value) {
1847
- case "unloaded":
1848
- case "loading":
1849
- case "loaded":
1850
- case "sleeping":
1851
- case "downloading": return value;
1852
- default: return "unknown";
1853
- }
1854
- }
1855
- function resolveContextWindow(props) {
1856
- return asPositiveSafeInteger(props?.default_generation_settings?.n_ctx) ?? asPositiveSafeInteger(props?.n_ctx) ?? SELF_HOSTED_DEFAULT_CONTEXT_WINDOW;
1857
- }
1858
- function resolveMaxTokens(props, contextWindow) {
1859
- const params = props?.default_generation_settings?.params;
1860
- const advertised = asPositiveSafeInteger(params?.max_tokens) ?? asPositiveSafeInteger(params?.n_predict);
1861
- return Math.min(advertised ?? SELF_HOSTED_DEFAULT_MAX_TOKENS, contextWindow);
1862
- }
1863
- function resolveInput(row, props) {
1864
- const advertised = row.architecture?.input_modalities;
1865
- return Array.isArray(advertised) && advertised.includes("image") || props?.modalities?.vision === true ? ["text", "image"] : ["text"];
1866
- }
1867
- function buildCompat(props) {
1868
- const caps = props?.chat_template_caps;
1869
- return {
1870
- supportsStore: false,
1871
- supportsDeveloperRole: false,
1872
- supportsReasoningEffort: caps?.supports_reasoning_effort === true,
1873
- supportsTemperature: true,
1874
- supportsUsageInStreaming: true,
1875
- supportsTools: caps?.supports_tool_calls === true,
1876
- supportsStrictMode: false,
1877
- supportsJsonSchemaResponseFormat: true,
1878
- requiresStringContent: caps?.supports_typed_content !== true,
1879
- maxTokensField: "max_tokens"
1880
- };
1881
- }
1882
- /** Maps one llama-server model row plus optional runtime properties into OpenClaw config. */
1883
- function mapLlamaServerModel(row, props) {
1884
- const id = typeof row.id === "string" ? row.id.trim() : "";
1885
- if (!id || row.object !== void 0 && row.object !== "model") return null;
1886
- const contextWindow = resolveContextWindow(props);
1887
- const compat = buildCompat(props);
1888
- return {
1889
- config: {
1890
- id,
1891
- name: id,
1892
- reasoning: compat.supportsReasoningEffort === true,
1893
- input: resolveInput(row, props),
1894
- cost: { ...SELF_HOSTED_DEFAULT_COST },
1895
- contextWindow,
1896
- contextTokens: contextWindow,
1897
- maxTokens: resolveMaxTokens(props, contextWindow),
1898
- compat
1899
- },
1900
- status: normalizeStatus(row.status?.value),
1901
- failed: row.status?.failed === true
1902
- };
1903
- }
1904
- function buildLlamaServerProviderConfig(params) {
1905
- const models = Array.isArray(params.configured?.models) ? [...params.configured.models] : [];
1906
- const seen = new Set(models.map((model) => model.id));
1907
- for (const discovered of params.discoveredModels) {
1908
- if (seen.has(discovered.config.id)) continue;
1909
- seen.add(discovered.config.id);
1910
- models.push(discovered.config);
1911
- }
1912
- return normalizeLlamaServerProviderConfig({
1913
- ...params.configured,
1914
- baseUrl: params.configured?.baseUrl ?? "http://127.0.0.1:8080",
1915
- models
1916
- });
1917
- }
1918
- //#endregion
1919
- //#region extensions/llama-cpp/src/external-server/discovery.ts
1920
- /** Discovers llama-server models without loading, waking, or unloading them. */
1921
- async function discoverLlamaServer(params) {
1922
- const endpoint = resolveLlamaServerEndpoint(params.baseUrl);
1923
- const result = await discoverOpenAICompatibleLocalModels({
1924
- baseUrl: endpoint.inferenceBaseUrl,
1925
- serverBaseUrl: endpoint.origin,
1926
- apiKey: params.apiKey,
1927
- headers: params.headers,
1928
- label: "llama-server",
1929
- healthPath: "/health",
1930
- modelsPathOrder: "server-first",
1931
- routerModelProps: true,
1932
- timeoutMs: LLAMA_SERVER_DISCOVERY_TIMEOUT_MS,
1933
- signal: params.signal,
1934
- rawResult: true
1935
- });
1936
- if (result.kind !== "success") return {
1937
- ...result,
1938
- endpoint
1939
- };
1940
- return {
1941
- kind: "success",
1942
- endpoint,
1943
- models: result.rows.flatMap(({ model, props }) => {
1944
- const mapped = mapLlamaServerModel(model, props);
1945
- return mapped ? [mapped] : [];
1946
- })
1947
- };
1948
- }
1949
- //#endregion
1950
- //#region extensions/llama-cpp/src/external-server/provider.ts
1951
- /** Discovers external llama-server models for provider runtime resolution. */
1952
- async function discoverLlamaServerProvider(ctx) {
1953
- const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
1954
- const auth = ctx.resolveProviderApiKey(LLAMA_CPP_PROVIDER_ID);
1955
- const headers = await resolveLlamaServerProviderHeaders({
1956
- config: ctx.config,
1957
- env: ctx.env,
1958
- headers: configured?.headers
1959
- });
1960
- const authApiKey = auth.discoveryApiKey ?? auth.apiKey;
1961
- const apiKey = hasLlamaServerAuthorizationHeader(headers) || authApiKey && isNonSecretApiKeyMarker(authApiKey) ? void 0 : authApiKey;
1962
- return await runLiveProviderCatalog({
1963
- providerId: LLAMA_CPP_PROVIDER_ID,
1964
- profileId: apiKey ? auth.profileId : void 0,
1965
- run: async () => {
1966
- const discovery = await discoverLlamaServer({
1967
- baseUrl: configured?.baseUrl,
1968
- apiKey,
1969
- headers
1970
- });
1971
- if (discovery.kind !== "success") {
1972
- if (!configured && !apiKey && !headers) return null;
1973
- throw discovery.kind === "http-error" ? new LiveModelCatalogHttpError(LLAMA_CPP_PROVIDER_ID, discovery.status) : discovery.error;
1974
- }
1975
- return { provider: buildLlamaServerProviderConfig({
1976
- configured,
1977
- discoveredModels: discovery.models
1978
- }) };
1979
- }
1980
- });
1981
- }
1982
- async function prepareLlamaServerDynamicModel(ctx) {
1983
- const apiKey = await resolveLlamaServerRuntimeApiKey({
1984
- config: ctx.config,
1985
- agentDir: ctx.agentDir,
1986
- profileId: ctx.authProfileId
1987
- });
1988
- const headers = await resolveLlamaServerProviderHeaders({
1989
- config: ctx.config,
1990
- env: process.env,
1991
- headers: ctx.providerConfig?.headers
1992
- });
1993
- const discovery = await discoverLlamaServer({
1994
- baseUrl: ctx.providerConfig?.baseUrl,
1995
- apiKey: hasLlamaServerAuthorizationHeader(headers) ? void 0 : apiKey,
1996
- headers
1997
- });
1998
- const model = discovery.kind === "success" ? discovery.models.find((entry) => entry.config.id === ctx.modelId) : void 0;
1999
- if (!model) return;
2000
- return {
2001
- ...model.config,
2002
- provider: LLAMA_CPP_PROVIDER_ID,
2003
- api: ctx.providerConfig?.api ?? "openai-completions",
2004
- baseUrl: resolveLlamaServerEndpoint(ctx.providerConfig?.baseUrl).inferenceBaseUrl,
2005
- input: model.config.input.filter((entry) => entry === "text" || entry === "image")
2006
- };
2007
- }
2008
- //#endregion
2009
1766
  //#region extensions/llama-cpp/src/auth-config.ts
2010
1767
  const LLAMA_CPP_DEFAULT_PROFILE_ID = `${LLAMA_CPP_PROVIDER_ID}:default`;
2011
1768
  function buildLlamaCppAuthProfileRemovalPatch(config) {
@@ -2065,7 +1822,8 @@ function stripEndpointCredentials(provider) {
2065
1822
  }
2066
1823
  function hasEndpointChanged(provider, baseUrl) {
2067
1824
  if (!provider) return false;
2068
- return resolveLlamaServerEndpoint(provider.baseUrl ?? "http://127.0.0.1:8080").inferenceBaseUrl !== resolveLlamaServerEndpoint(baseUrl).inferenceBaseUrl;
1825
+ const configuredBaseUrl = provider.baseUrl ?? "http://127.0.0.1:8080";
1826
+ return resolveLlamaServerEndpoint(configuredBaseUrl).inferenceBaseUrl !== resolveLlamaServerEndpoint(baseUrl).inferenceBaseUrl;
2069
1827
  }
2070
1828
  function stripLlamaServerEndpointAuth(config) {
2071
1829
  const withoutProfile = removeAuthProfileConfig(config, LLAMA_CPP_DEFAULT_PROFILE_ID);
@@ -2138,7 +1896,8 @@ async function discoverForSetup(ctx) {
2138
1896
  baseUrl: provider?.baseUrl ?? "http://127.0.0.1:8080",
2139
1897
  apiKey,
2140
1898
  headers,
2141
- signal: ctx.signal
1899
+ signal: ctx.signal,
1900
+ useRuntimeDefaults: false
2142
1901
  });
2143
1902
  return discovery.kind === "success" ? discovery : null;
2144
1903
  } catch {
@@ -2175,7 +1934,7 @@ async function prepareLlamaServerSetup(ctx) {
2175
1934
  async function runLlamaServerSetup(ctx) {
2176
1935
  const existing = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
2177
1936
  const defaultOrigin = resolveLlamaServerEndpoint(existing?.baseUrl).origin;
2178
- const endpoint = resolveLlamaServerEndpoint(await ctx.prompter.text({
1937
+ const baseUrl = await ctx.prompter.text({
2179
1938
  message: `${LLAMA_CPP_PROVIDER_LABEL} URL`,
2180
1939
  initialValue: defaultOrigin,
2181
1940
  placeholder: LLAMA_SERVER_DEFAULT_ORIGIN,
@@ -2188,7 +1947,8 @@ async function runLlamaServerSetup(ctx) {
2188
1947
  return "Enter a valid HTTP or HTTPS URL without embedded credentials (e.g. http://localhost:8080).";
2189
1948
  }
2190
1949
  }
2191
- }));
1950
+ });
1951
+ const endpoint = resolveLlamaServerEndpoint(baseUrl);
2192
1952
  const endpointChanged = Boolean(existing?.localService) || hasEndpointChanged(existing, endpoint.inferenceBaseUrl);
2193
1953
  const resolvedHeaders = endpointChanged ? void 0 : await resolveLlamaServerProviderHeaders({
2194
1954
  config: ctx.config,
@@ -2241,7 +2001,8 @@ async function runLlamaServerSetup(ctx) {
2241
2001
  baseUrl: endpoint.inferenceBaseUrl,
2242
2002
  apiKey,
2243
2003
  headers,
2244
- signal: ctx.signal
2004
+ signal: ctx.signal,
2005
+ useRuntimeDefaults: false
2245
2006
  });
2246
2007
  if (discovery.kind !== "success") throw new Error(describeDiscoveryFailure(discovery));
2247
2008
  const modelId = selectSetupModelId(discovery);
@@ -2300,7 +2061,8 @@ async function validateNonInteractiveDiscovery(ctx) {
2300
2061
  const discovery = await discoverLlamaServer({
2301
2062
  baseUrl,
2302
2063
  apiKey,
2303
- headers
2064
+ headers,
2065
+ useRuntimeDefaults: false
2304
2066
  });
2305
2067
  if (discovery.kind !== "success") throw new Error(describeDiscoveryFailure(discovery));
2306
2068
  const requestedModelId = normalizeOptionalSecretInput(ctx.opts.customModelId);
@@ -2344,7 +2106,7 @@ async function configureLlamaServerNonInteractive(ctx) {
2344
2106
  resolved: validated.persistence.credential
2345
2107
  });
2346
2108
  if (!credential) return null;
2347
- await upsertAuthProfileWithLock({
2109
+ await upsertAuthProfileWithLockOrThrow({
2348
2110
  profileId: LLAMA_CPP_DEFAULT_PROFILE_ID,
2349
2111
  credential,
2350
2112
  agentDir: ctx.agentDir
@@ -2404,15 +2166,16 @@ function formatDownloadProgress(label, params) {
2404
2166
  function describeEmbeddingDownload(isDefault) {
2405
2167
  return isDefault ? "the local embedding model (about 0.3 GB)" : "your configured local embedding model";
2406
2168
  }
2407
- function readPrimaryModel(config) {
2408
- const model = config.agents?.defaults?.model;
2409
- return typeof model === "string" ? model : model?.primary;
2410
- }
2411
- function configuredCandidates(config) {
2169
+ async function configuredCandidates(config) {
2412
2170
  const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
2413
2171
  if (!provider?.localService) return [];
2414
- const primary = readPrimaryModel(config);
2415
- const primaryId = primary?.startsWith(`llama-cpp/`) ? primary.slice(LLAMA_CPP_PROVIDER_ID.length + 1) : void 0;
2172
+ const { resolveDefaultModelForAgent } = await import("openclaw/plugin-sdk/agent-runtime");
2173
+ const primary = resolveDefaultModelForAgent({
2174
+ cfg: config,
2175
+ allowManifestNormalization: false,
2176
+ allowPluginNormalization: false
2177
+ });
2178
+ const primaryId = primary.provider === "llama-cpp" ? primary.model : void 0;
2416
2179
  return provider.models.map((model) => ({
2417
2180
  model,
2418
2181
  provider
@@ -2465,7 +2228,7 @@ async function detectLlamaCppSetup(ctx) {
2465
2228
  const command = existing?.localService?.command;
2466
2229
  const presetPath = existing?.localService?.args?.find((_, index, args) => args[index - 1] === "--models-preset");
2467
2230
  if (!command || !path.isAbsolute(command) || !await isFile(command) || !presetPath || !await isFile(presetPath)) return null;
2468
- for (const candidate of configuredCandidates(ctx.config)) if (await resolveCachedCandidate(candidate, ctx.signal)) return {
2231
+ for (const candidate of await configuredCandidates(ctx.config)) if (await resolveCachedCandidate(candidate, ctx.signal)) return {
2469
2232
  modelRef: `${LLAMA_CPP_PROVIDER_ID}/${candidate.model.id}`,
2470
2233
  detail: "Managed llama.cpp server ready"
2471
2234
  };
@@ -2631,7 +2394,7 @@ async function runLlamaCppSetup(ctx) {
2631
2394
  asset = selectLlamaServerAsset(hardware.platform, hardware.arch, { kind: "cpu" });
2632
2395
  runtimeNote = `${error instanceof Error ? error.message : String(error)} This recommendation uses CPU execution.`;
2633
2396
  }
2634
- const plan = await resolveSetupPlan(ctx, configuredCandidates(ctx.config), embeddingModel.isDefault, embeddingSetup.localMemoryIntent, hardware, asset, runtimeNote);
2397
+ const plan = await resolveSetupPlan(ctx, await configuredCandidates(ctx.config), embeddingModel.isDefault, embeddingSetup.localMemoryIntent, hardware, asset, runtimeNote);
2635
2398
  if (!plan) return { profiles: [] };
2636
2399
  const progress = ctx.prompter.progress("Preparing managed llama.cpp server…");
2637
2400
  try {
@@ -2710,10 +2473,7 @@ function wrapLlamaCppStream(ctx) {
2710
2473
  }
2711
2474
  function registerLlamaCppProvider(api) {
2712
2475
  api.registerProvider({
2713
- id: LLAMA_CPP_PROVIDER_ID,
2714
- label: LLAMA_CPP_PROVIDER_LABEL,
2715
- docsPath: "/plugins/llama-cpp",
2716
- envVars: [LLAMA_SERVER_DEFAULT_API_KEY_ENV_VAR],
2476
+ ...provider_discovery_default,
2717
2477
  auth: [{
2718
2478
  id: "local",
2719
2479
  label: LLAMA_CPP_PROVIDER_LABEL,
@@ -2755,27 +2515,6 @@ function registerLlamaCppProvider(api) {
2755
2515
  validateNonInteractive: validateLlamaServerNonInteractive,
2756
2516
  runNonInteractive: configureLlamaServerNonInteractive
2757
2517
  }],
2758
- catalog: {
2759
- order: "late",
2760
- run: async (ctx) => {
2761
- const configured = ctx.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
2762
- return configured?.localService ? { provider: buildLlamaCppProviderConfig({
2763
- existing: configured,
2764
- modelInventory: configured.models
2765
- }) } : await discoverLlamaServerProvider(ctx);
2766
- }
2767
- },
2768
- staticCatalog: {
2769
- order: "late",
2770
- run: async () => ({ provider: buildLlamaCppProviderConfig() })
2771
- },
2772
- resolveSyntheticAuth: ({ providerConfig }) => providerConfig?.localService || shouldUseLlamaServerSyntheticAuth(providerConfig) ? {
2773
- apiKey: LLAMA_CPP_LOCAL_AUTH_MARKER,
2774
- source: providerConfig?.localService ? "managed local llama.cpp server" : hasLlamaServerAuthorizationHeader(providerConfig?.headers) ? "models.providers.llama-cpp.headers.Authorization" : "models.providers.llama-cpp (synthetic local key)",
2775
- mode: "api-key"
2776
- } : void 0,
2777
- shouldDeferSyntheticProfileAuth: ({ resolvedApiKey }) => resolvedApiKey?.trim() === "llama-cpp-local" || resolvedApiKey?.trim() === CUSTOM_LOCAL_AUTH_MARKER,
2778
- normalizeConfig: ({ providerConfig }) => providerConfig.localService ? providerConfig : normalizeLlamaServerProviderConfig(providerConfig),
2779
2518
  prepareDynamicModel: async (ctx) => ctx.config?.models?.providers?.["llama-cpp"]?.localService ? void 0 : await prepareLlamaServerDynamicModel(ctx),
2780
2519
  reconcileLocalService: reconcileManagedLlamaServer,
2781
2520
  wrapSimpleCompletionStreamFn: wrapLlamaCppStream,
@@ -0,0 +1,2 @@
1
+ import { t as provider_discovery_default } from "./.setup/provider-discovery-CEcEBzKt.mjs";
2
+ export { provider_discovery_default as default };
@@ -1,4 +1,4 @@
1
- import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-D0abOkC_.mjs";
1
+ import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-Nd32gsuH.mjs";
2
2
  //#region extensions/llama-cpp/provider-policy-api.ts
3
3
  function inspectEmbeddingProviderSetup(params) {
4
4
  if (params.provider !== "local") return null;
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "id": "llama-cpp",
3
- "categories": ["models"],
3
+ "categories": [
4
+ "models"
5
+ ],
4
6
  "name": "llama.cpp Provider",
5
7
  "description": "Managed and external llama.cpp servers for GGUF chat and embeddings.",
6
8
  "activation": {
7
9
  "onStartup": false
8
10
  },
11
+ "providerCatalogEntry": "./dist/provider-discovery.js",
9
12
  "enabledByDefault": true,
10
- "autoEnableWhenConfiguredProviders": ["llama-cpp"],
11
- "providers": ["llama-cpp"],
13
+ "autoEnableWhenConfiguredProviders": [
14
+ "llama-cpp"
15
+ ],
16
+ "providers": [
17
+ "llama-cpp"
18
+ ],
12
19
  "modelCatalog": {
13
20
  "discovery": {
14
21
  "llama-cpp": "refreshable"
@@ -31,13 +38,19 @@
31
38
  }
32
39
  }
33
40
  },
34
- "syntheticAuthRefs": ["llama-cpp"],
35
- "nonSecretAuthMarkers": ["llama-cpp-local"],
41
+ "syntheticAuthRefs": [
42
+ "llama-cpp"
43
+ ],
44
+ "nonSecretAuthMarkers": [
45
+ "llama-cpp-local"
46
+ ],
36
47
  "setup": {
37
48
  "providers": [
38
49
  {
39
50
  "id": "llama-cpp",
40
- "envVars": ["LLAMA_SERVER_API_KEY"]
51
+ "envVars": [
52
+ "LLAMA_SERVER_API_KEY"
53
+ ]
41
54
  }
42
55
  ]
43
56
  },
@@ -72,7 +85,9 @@
72
85
  }
73
86
  ],
74
87
  "contracts": {
75
- "embeddingProviders": ["local"]
88
+ "embeddingProviders": [
89
+ "local"
90
+ ]
76
91
  },
77
92
  "configSchema": {
78
93
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/llama-cpp-provider",
3
- "version": "2026.10.5-beta.2",
3
+ "version": "2026.10.5-beta.4",
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.10.5-beta.2"
24
+ "pluginApi": ">=2026.10.5-beta.4"
25
25
  },
26
26
  "build": {
27
- "openclawVersion": "2026.10.5-beta.2"
27
+ "openclawVersion": "2026.10.5-beta.4"
28
28
  },
29
29
  "release": {
30
30
  "bundleRuntimeDependencies": false,
@@ -46,7 +46,7 @@
46
46
  "assets/activity.svg"
47
47
  ],
48
48
  "peerDependencies": {
49
- "openclaw": ">=2026.10.5-beta.2"
49
+ "openclaw": ">=2026.10.5-beta.4"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "openclaw": {