@openclaw/llama-cpp-provider 2026.11.3 → 2026.11.5-beta.2
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-Dx2WDi-G.mjs → auth-config-BJOlAPuO.mjs} +1 -1
- package/dist/.setup/{discovery-osk0TXQN.mjs → discovery-CghcMQy6.mjs} +4 -6
- package/dist/.setup/{embedding-provider.runtime-djNMas6G.mjs → embedding-provider.runtime-Bb0UVBwq.mjs} +46 -37
- package/dist/.setup/{managed-provider-config-BuFqNTx1.mjs → managed-provider-config-Dn-MKZjS.mjs} +1 -1
- package/dist/.setup/{managed-server-Bjr1c5yX.mjs → managed-server-CZGhj7j8.mjs} +396 -295
- package/dist/.setup/{media-catalog-BwFQGYtY.mjs → media-catalog-DgRc3mpW.mjs} +7 -212
- package/dist/.setup/{media-provider.runtime-MqV-UJ1m.mjs → media-provider.runtime-Cd4dOeAN.mjs} +2 -2
- package/dist/.setup/{media-setup-BQ6-EW_y.mjs → media-setup-CYVQ5us2.mjs} +9 -9
- package/dist/.setup/{provider-DVEnxK8Q.mjs → provider-CwnlpLK5.mjs} +4 -6
- package/dist/.setup/{provider-discovery-SxEYhgMV.mjs → provider-discovery-D3_7fprf.mjs} +2 -2
- package/dist/.setup/{setup-DmjzzdfH.mjs → setup-Cd7vqUzv.mjs} +123 -132
- package/dist/.setup/{setup-D9_0z5GM.mjs → setup-DDuIGmUb.mjs} +8 -10
- package/dist/.setup/{stream-CSBkXmdm.mjs → stream-lxVe6M15.mjs} +39 -11
- package/dist/.source-module-urls/2a292bf2cc9d15ab4011c4fb7ee888280524a76675c662fb0329d5dc914f3fba.json +1 -0
- package/dist/index.js +113 -118
- package/dist/provider-discovery.js +1 -2
- package/dist/provider-policy-api.js +1 -1
- package/package.json +5 -5
- package/dist/.setup/{defaults-DX4XN2j1.mjs → defaults-CZr5jpH7.mjs} +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as resolveLegacyLlamaCppModelCacheDir, E as resolveLlamaCppModelCacheDir, T as resolveLlamaCppEmbeddingModel, _ as LLAMA_CPP_PROVIDER_ID, i as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, n as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, v as LLAMA_CPP_PROVIDER_LABEL } from "./.setup/defaults-
|
|
2
|
-
import { a as LLAMA_SERVER_DEFAULT_ORIGIN, t as provider_discovery_default } from "./.setup/provider-discovery-
|
|
1
|
+
import { C as resolveLegacyLlamaCppModelCacheDir, E as resolveLlamaCppModelCacheDir, T as resolveLlamaCppEmbeddingModel, _ as LLAMA_CPP_PROVIDER_ID, i as DEFAULT_LLAMA_CPP_EMBEDDING_MODEL, n as DEFAULT_LLAMA_CPP_EMBEDDING_CACHE_FILE, v as LLAMA_CPP_PROVIDER_LABEL } from "./.setup/defaults-CZr5jpH7.mjs";
|
|
2
|
+
import { a as LLAMA_SERVER_DEFAULT_ORIGIN, t as provider_discovery_default } from "./.setup/provider-discovery-D3_7fprf.mjs";
|
|
3
3
|
import { a as isManagedLlamaCppMediaProvider, i as LLAMA_CPP_MEDIA_TIMEOUT_MS, n as LLAMA_CPP_MEDIA_MAX_CHARS, o as resolveLlamaCppMediaModels, r as LLAMA_CPP_MEDIA_MAX_TOKENS, t as LLAMA_CPP_MEDIA_MAX_BYTES } from "./.setup/media-config-CZ7CluNV.mjs";
|
|
4
|
-
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
5
4
|
import path from "node:path";
|
|
5
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
6
6
|
import { asPositiveSafeInteger, isRecord, normalizeOptionalString, truncateUtf16Safe } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
-
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
8
7
|
import { textResult } from "openclaw/plugin-sdk/tool-results";
|
|
8
|
+
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
9
9
|
//#region extensions/llama-cpp/src/embedding-provider.ts
|
|
10
10
|
function readIdentityLocalOptions(options) {
|
|
11
11
|
const local = options.local ?? {};
|
|
@@ -19,7 +19,7 @@ function createCacheKeyData(model, dimensions) {
|
|
|
19
19
|
return {
|
|
20
20
|
provider: "local",
|
|
21
21
|
model,
|
|
22
|
-
...
|
|
22
|
+
...dimensions !== void 0 ? { outputDimensionality: dimensions } : {}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function resolveModelIdentity(local, dimensions) {
|
|
@@ -51,7 +51,7 @@ const llamaCppEmbeddingProviderAdapter = {
|
|
|
51
51
|
},
|
|
52
52
|
create: async (options) => {
|
|
53
53
|
const local = readIdentityLocalOptions(options);
|
|
54
|
-
const { createLlamaCppEmbeddingProvider } = await import("./.setup/embedding-provider.runtime-
|
|
54
|
+
const { createLlamaCppEmbeddingProvider } = await import("./.setup/embedding-provider.runtime-Bb0UVBwq.mjs");
|
|
55
55
|
return createLlamaCppEmbeddingProvider(options, resolveLlamaCppEmbeddingModel(local).source, resolveModelIdentity(local, options.dimensions));
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -62,9 +62,9 @@ function wrapLlamaCppStream(ctx) {
|
|
|
62
62
|
const selectedModel = ctx.model;
|
|
63
63
|
if (providerConfig?.localService && !selectedModel) return;
|
|
64
64
|
return async (...args) => {
|
|
65
|
-
const { wrapLlamaServerStream } = await import("./.setup/stream-
|
|
65
|
+
const { wrapLlamaServerStream } = await import("./.setup/stream-lxVe6M15.mjs");
|
|
66
66
|
if (providerConfig?.localService && selectedModel) {
|
|
67
|
-
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-
|
|
67
|
+
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-CZGhj7j8.mjs");
|
|
68
68
|
const signal = args[2]?.signal;
|
|
69
69
|
signal?.throwIfAborted();
|
|
70
70
|
await ensureManagedLlamaServerForChat({
|
|
@@ -96,11 +96,11 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
96
96
|
methodId: "local"
|
|
97
97
|
},
|
|
98
98
|
appGuidedSetup: {
|
|
99
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
100
|
-
prepare: async (ctx) => (await import("./.setup/setup-
|
|
99
|
+
detect: async (ctx) => (await import("./.setup/setup-Cd7vqUzv.mjs")).detectLlamaCppSetup(ctx),
|
|
100
|
+
prepare: async (ctx) => (await import("./.setup/setup-Cd7vqUzv.mjs")).prepareLlamaCppSetup(ctx)
|
|
101
101
|
},
|
|
102
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
103
|
-
runNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
102
|
+
run: async (ctx) => (await import("./.setup/setup-Cd7vqUzv.mjs")).runLlamaCppSetup(ctx),
|
|
103
|
+
runNonInteractive: async (ctx) => (await import("./.setup/setup-Cd7vqUzv.mjs")).configureLlamaCppNonInteractive(ctx)
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
id: "existing-server",
|
|
@@ -117,12 +117,12 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
117
117
|
methodId: "existing-server"
|
|
118
118
|
},
|
|
119
119
|
appGuidedSetup: {
|
|
120
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
121
|
-
prepare: async (ctx) => (await import("./.setup/setup-
|
|
120
|
+
detect: async (ctx) => (await import("./.setup/setup-DDuIGmUb.mjs")).detectLlamaServerSetup(ctx),
|
|
121
|
+
prepare: async (ctx) => (await import("./.setup/setup-DDuIGmUb.mjs")).prepareLlamaServerSetup(ctx)
|
|
122
122
|
},
|
|
123
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
124
|
-
validateNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
125
|
-
runNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
123
|
+
run: async (ctx) => (await import("./.setup/setup-DDuIGmUb.mjs")).runLlamaServerSetup(ctx),
|
|
124
|
+
validateNonInteractive: async (ctx) => (await import("./.setup/setup-DDuIGmUb.mjs")).validateLlamaServerNonInteractive(ctx),
|
|
125
|
+
runNonInteractive: async (ctx) => (await import("./.setup/setup-DDuIGmUb.mjs")).configureLlamaServerNonInteractive(ctx)
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
id: "local-media",
|
|
@@ -130,17 +130,17 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
130
130
|
hint: "Recommend, install and verify local image models for this Gateway",
|
|
131
131
|
kind: "custom",
|
|
132
132
|
run: async (ctx) => {
|
|
133
|
-
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-
|
|
133
|
+
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-CYVQ5us2.mjs");
|
|
134
134
|
return await runLlamaCppMediaSetup(ctx, mediaProvider);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
],
|
|
138
138
|
prepareDynamicModel: async (ctx) => {
|
|
139
139
|
if (ctx.config?.models?.providers?.["llama-cpp"]?.localService) return;
|
|
140
|
-
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-
|
|
140
|
+
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-CwnlpLK5.mjs");
|
|
141
141
|
return prepareLlamaServerDynamicModel(ctx);
|
|
142
142
|
},
|
|
143
|
-
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-
|
|
143
|
+
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-CZGhj7j8.mjs")).reconcileManagedLlamaServer(ctx),
|
|
144
144
|
wrapSimpleCompletionStreamFn: wrapLlamaCppStream,
|
|
145
145
|
wrapStreamFn: wrapLlamaCppStream,
|
|
146
146
|
...buildProviderToolCompatFamilyHooks("llamacpp-gbnf"),
|
|
@@ -158,106 +158,11 @@ function createLlamaCppMediaProvider() {
|
|
|
158
158
|
return {
|
|
159
159
|
id: LLAMA_CPP_PROVIDER_ID,
|
|
160
160
|
capabilities: ["image"],
|
|
161
|
-
describeImage: async (req) => (await import("./.setup/media-provider.runtime-
|
|
162
|
-
describeImages: async (req) => (await import("./.setup/media-provider.runtime-
|
|
161
|
+
describeImage: async (req) => (await import("./.setup/media-provider.runtime-Cd4dOeAN.mjs")).describeLlamaCppImage(req),
|
|
162
|
+
describeImages: async (req) => (await import("./.setup/media-provider.runtime-Cd4dOeAN.mjs")).describeLlamaCppImages(req)
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region extensions/llama-cpp/src/media-tool.ts
|
|
167
|
-
/** Maps explicit task intent onto the same provider hook used by normal image understanding. */
|
|
168
|
-
function registerLlamaCppMediaTool(api, provider) {
|
|
169
|
-
api.registerTool((ctx) => {
|
|
170
|
-
if (ctx.sandboxed || !provider.describeImage) return null;
|
|
171
|
-
const describeImage = provider.describeImage;
|
|
172
|
-
const getConfig = () => ctx.getRuntimeConfig?.() ?? ctx.runtimeConfig ?? ctx.config ?? api.config;
|
|
173
|
-
const configured = getConfig().models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
174
|
-
if (!isManagedLlamaCppMediaProvider(configured) || !resolveLlamaCppMediaModels(configured)) return null;
|
|
175
|
-
return {
|
|
176
|
-
name: "local_image",
|
|
177
|
-
label: "Local Image",
|
|
178
|
-
description: "Inspect a local image with installed local models. Choose task ocr to transcribe visible text, or vision for photos, charts, diagrams, and spatial questions (default). No cloud fallback or model downloads. The original image remains available.",
|
|
179
|
-
parameters: {
|
|
180
|
-
type: "object",
|
|
181
|
-
properties: {
|
|
182
|
-
path: {
|
|
183
|
-
type: "string",
|
|
184
|
-
minLength: 1,
|
|
185
|
-
description: "Local image path or media:// reference."
|
|
186
|
-
},
|
|
187
|
-
task: {
|
|
188
|
-
type: "string",
|
|
189
|
-
enum: ["ocr", "vision"],
|
|
190
|
-
default: "vision"
|
|
191
|
-
},
|
|
192
|
-
prompt: {
|
|
193
|
-
type: "string",
|
|
194
|
-
maxLength: 8192
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
required: ["path"],
|
|
198
|
-
additionalProperties: false
|
|
199
|
-
},
|
|
200
|
-
async execute(_toolCallId, args, signal) {
|
|
201
|
-
signal?.throwIfAborted();
|
|
202
|
-
if (!isRecord(args)) throw new Error("Local image input must contain a path and optional ocr or vision task.");
|
|
203
|
-
const task = args.task === void 0 ? "vision" : args.task;
|
|
204
|
-
if (task !== "ocr" && task !== "vision") throw new Error("Local image task must be ocr or vision.");
|
|
205
|
-
const input = normalizeOptionalString(args.path);
|
|
206
|
-
if (!input) throw new Error("Local image path is required.");
|
|
207
|
-
if (/^[a-z][a-z0-9+.-]*:/iu.test(input) && !input.startsWith("media://") && !/^[a-z]:[\\/]/iu.test(input)) throw new Error("Local image requires a local path or media:// reference; URLs are not accepted.");
|
|
208
|
-
if (args.prompt !== void 0 && (typeof args.prompt !== "string" || args.prompt.length > 8192)) throw new Error("Local image prompt must be a string of at most 8192 characters.");
|
|
209
|
-
const cfg = getConfig();
|
|
210
|
-
const configuredProvider = cfg.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
211
|
-
const models = resolveLlamaCppMediaModels(configuredProvider);
|
|
212
|
-
if (!isManagedLlamaCppMediaProvider(configuredProvider) || !models || !ctx.agentDir) throw new Error("Run managed local media setup for this agent without an explicit llama.cpp request proxy before using local_image. When using an environment proxy, add the server address to NO_PROXY.");
|
|
213
|
-
const model = configuredProvider?.models.find((entry) => entry.id === models[task]);
|
|
214
|
-
if (!model?.input.includes("image")) throw new Error(`The configured local ${task} model is unavailable. Run managed local media setup again.`);
|
|
215
|
-
if (model.baseUrl !== void 0 && model.baseUrl !== configuredProvider?.baseUrl) throw new Error("The local image model endpoint must match the managed llama.cpp provider. Run managed local media setup again.");
|
|
216
|
-
const workspace = ctx.fsPolicy?.root ?? ctx.workspaceDir;
|
|
217
|
-
const localRoots = ctx.fsPolicy?.workspaceOnly ? workspace ? [path.resolve(workspace)] : [] : (await import("openclaw/plugin-sdk/media-local-roots")).getAgentScopedMediaLocalRoots(cfg, ctx.agentId, workspace);
|
|
218
|
-
const imageConfig = cfg.tools?.media?.image;
|
|
219
|
-
const maxBytes = Math.min(asPositiveSafeInteger(imageConfig?.maxBytes) ?? 10485760, LLAMA_CPP_MEDIA_MAX_BYTES);
|
|
220
|
-
const maxChars = Math.min(asPositiveSafeInteger(imageConfig?.maxChars) ?? 12e3, LLAMA_CPP_MEDIA_MAX_CHARS);
|
|
221
|
-
const timeoutMs = Math.min(imageConfig?.timeoutSeconds === void 0 ? LLAMA_CPP_MEDIA_TIMEOUT_MS : (asPositiveSafeInteger(imageConfig.timeoutSeconds) ?? 600) * 1e3, 2147483647);
|
|
222
|
-
const source = input.startsWith("media://") || input.startsWith("~") || path.isAbsolute(input) ? input : path.resolve(workspace ?? process.cwd(), input);
|
|
223
|
-
signal?.throwIfAborted();
|
|
224
|
-
const image = await api.runtime.media.loadWebMedia(source, {
|
|
225
|
-
maxBytes,
|
|
226
|
-
localRoots: [...localRoots, ...ctx.fsPolicy?.readOnlyRoots ?? []],
|
|
227
|
-
...signal ? { requestInit: { signal } } : {}
|
|
228
|
-
});
|
|
229
|
-
signal?.throwIfAborted();
|
|
230
|
-
if (image.kind !== "image") throw new Error("Local image input must be an image.");
|
|
231
|
-
const result = await describeImage({
|
|
232
|
-
buffer: image.buffer,
|
|
233
|
-
fileName: image.fileName ?? path.basename(source),
|
|
234
|
-
mime: image.contentType,
|
|
235
|
-
provider: LLAMA_CPP_PROVIDER_ID,
|
|
236
|
-
model: model.id,
|
|
237
|
-
prompt: normalizeOptionalString(args.prompt) ?? (task === "ocr" ? "Transcribe all visible text exactly. Return only the text." : "Describe the image."),
|
|
238
|
-
maxTokens: Math.min(asPositiveSafeInteger(model.maxTokens) ?? 2048, LLAMA_CPP_MEDIA_MAX_TOKENS),
|
|
239
|
-
timeoutMs,
|
|
240
|
-
signal,
|
|
241
|
-
cfg,
|
|
242
|
-
agentId: ctx.agentId,
|
|
243
|
-
agentDir: ctx.agentDir,
|
|
244
|
-
workspaceDir: ctx.workspaceDir
|
|
245
|
-
});
|
|
246
|
-
signal?.throwIfAborted();
|
|
247
|
-
if (!result.text.trim()) throw new Error("The local image model returned no text. Run managed local media setup again.");
|
|
248
|
-
const text = truncateUtf16Safe(result.text, maxChars);
|
|
249
|
-
return textResult(text, {
|
|
250
|
-
text,
|
|
251
|
-
task,
|
|
252
|
-
provider: LLAMA_CPP_PROVIDER_ID,
|
|
253
|
-
model: result.model ?? model.id,
|
|
254
|
-
path: input
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
}, { name: "local_image" });
|
|
259
|
-
}
|
|
260
|
-
//#endregion
|
|
261
166
|
//#region extensions/llama-cpp/index.ts
|
|
262
167
|
var llama_cpp_default = definePluginEntry({
|
|
263
168
|
id: "llama-cpp",
|
|
@@ -267,7 +172,97 @@ var llama_cpp_default = definePluginEntry({
|
|
|
267
172
|
const mediaProvider = createLlamaCppMediaProvider();
|
|
268
173
|
api.registerEmbeddingProvider(llamaCppEmbeddingProviderAdapter);
|
|
269
174
|
api.registerMediaUnderstandingProvider(mediaProvider);
|
|
270
|
-
|
|
175
|
+
/** Maps explicit task intent onto the same provider hook used by normal image understanding. */
|
|
176
|
+
api.registerTool((ctx) => {
|
|
177
|
+
if (ctx.sandboxed || !mediaProvider.describeImage) return null;
|
|
178
|
+
const describeImage = mediaProvider.describeImage;
|
|
179
|
+
const getConfig = () => ctx.getRuntimeConfig?.() ?? ctx.runtimeConfig ?? ctx.config ?? api.config;
|
|
180
|
+
const configured = getConfig().models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
181
|
+
if (!isManagedLlamaCppMediaProvider(configured) || !resolveLlamaCppMediaModels(configured)) return null;
|
|
182
|
+
return {
|
|
183
|
+
name: "local_image",
|
|
184
|
+
label: "Local Image",
|
|
185
|
+
description: "Inspect a local image with installed local models. Choose task ocr to transcribe visible text, or vision for photos, charts, diagrams, and spatial questions (default). No cloud fallback or model downloads. The original image remains available.",
|
|
186
|
+
parameters: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
path: {
|
|
190
|
+
type: "string",
|
|
191
|
+
minLength: 1,
|
|
192
|
+
description: "Local image path or media:// reference."
|
|
193
|
+
},
|
|
194
|
+
task: {
|
|
195
|
+
type: "string",
|
|
196
|
+
enum: ["ocr", "vision"],
|
|
197
|
+
default: "vision"
|
|
198
|
+
},
|
|
199
|
+
prompt: {
|
|
200
|
+
type: "string",
|
|
201
|
+
maxLength: 8192
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
required: ["path"],
|
|
205
|
+
additionalProperties: false
|
|
206
|
+
},
|
|
207
|
+
async execute(_toolCallId, args, signal) {
|
|
208
|
+
signal?.throwIfAborted();
|
|
209
|
+
if (!isRecord(args)) throw new Error("Local image input must contain a path and optional ocr or vision task.");
|
|
210
|
+
const task = args.task === void 0 ? "vision" : args.task;
|
|
211
|
+
if (task !== "ocr" && task !== "vision") throw new Error("Local image task must be ocr or vision.");
|
|
212
|
+
const input = normalizeOptionalString(args.path);
|
|
213
|
+
if (!input) throw new Error("Local image path is required.");
|
|
214
|
+
if (/^[a-z][a-z0-9+.-]*:/iu.test(input) && !input.startsWith("media://") && !/^[a-z]:[\\/]/iu.test(input)) throw new Error("Local image requires a local path or media:// reference; URLs are not accepted.");
|
|
215
|
+
if (args.prompt !== void 0 && (typeof args.prompt !== "string" || args.prompt.length > 8192)) throw new Error("Local image prompt must be a string of at most 8192 characters.");
|
|
216
|
+
const cfg = getConfig();
|
|
217
|
+
const configuredProvider = cfg.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
218
|
+
const models = resolveLlamaCppMediaModels(configuredProvider);
|
|
219
|
+
if (!isManagedLlamaCppMediaProvider(configuredProvider) || !models || !ctx.agentDir) throw new Error("Run managed local media setup for this agent without an explicit llama.cpp request proxy before using local_image. When using an environment proxy, add the server address to NO_PROXY.");
|
|
220
|
+
const model = configuredProvider?.models.find((entry) => entry.id === models[task]);
|
|
221
|
+
if (!model?.input.includes("image")) throw new Error(`The configured local ${task} model is unavailable. Run managed local media setup again.`);
|
|
222
|
+
if (model.baseUrl !== void 0 && model.baseUrl !== configuredProvider?.baseUrl) throw new Error("The local image model endpoint must match the managed llama.cpp provider. Run managed local media setup again.");
|
|
223
|
+
const workspace = ctx.fsPolicy?.root ?? ctx.workspaceDir;
|
|
224
|
+
const localRoots = ctx.fsPolicy?.workspaceOnly ? workspace ? [path.resolve(workspace)] : [] : (await import("openclaw/plugin-sdk/media-local-roots")).getAgentScopedMediaLocalRoots(cfg, ctx.agentId, workspace);
|
|
225
|
+
const imageConfig = cfg.tools?.media?.image;
|
|
226
|
+
const maxBytes = Math.min(asPositiveSafeInteger(imageConfig?.maxBytes) ?? 10485760, LLAMA_CPP_MEDIA_MAX_BYTES);
|
|
227
|
+
const maxChars = Math.min(asPositiveSafeInteger(imageConfig?.maxChars) ?? 12e3, LLAMA_CPP_MEDIA_MAX_CHARS);
|
|
228
|
+
const timeoutMs = Math.min(imageConfig?.timeoutSeconds === void 0 ? LLAMA_CPP_MEDIA_TIMEOUT_MS : (asPositiveSafeInteger(imageConfig.timeoutSeconds) ?? 600) * 1e3, 2147483647);
|
|
229
|
+
const source = input.startsWith("media://") || input.startsWith("~") || path.isAbsolute(input) ? input : path.resolve(workspace ?? process.cwd(), input);
|
|
230
|
+
signal?.throwIfAborted();
|
|
231
|
+
const image = await api.runtime.media.loadWebMedia(source, {
|
|
232
|
+
maxBytes,
|
|
233
|
+
localRoots: [...localRoots, ...ctx.fsPolicy?.readOnlyRoots ?? []],
|
|
234
|
+
...signal ? { requestInit: { signal } } : {}
|
|
235
|
+
});
|
|
236
|
+
signal?.throwIfAborted();
|
|
237
|
+
if (image.kind !== "image") throw new Error("Local image input must be an image.");
|
|
238
|
+
const result = await describeImage({
|
|
239
|
+
buffer: image.buffer,
|
|
240
|
+
fileName: image.fileName ?? path.basename(source),
|
|
241
|
+
mime: image.contentType,
|
|
242
|
+
provider: LLAMA_CPP_PROVIDER_ID,
|
|
243
|
+
model: model.id,
|
|
244
|
+
prompt: normalizeOptionalString(args.prompt) ?? (task === "ocr" ? "Transcribe all visible text exactly. Return only the text." : "Describe the image."),
|
|
245
|
+
maxTokens: Math.min(asPositiveSafeInteger(model.maxTokens) ?? 2048, LLAMA_CPP_MEDIA_MAX_TOKENS),
|
|
246
|
+
timeoutMs,
|
|
247
|
+
signal,
|
|
248
|
+
cfg,
|
|
249
|
+
agentId: ctx.agentId,
|
|
250
|
+
agentDir: ctx.agentDir,
|
|
251
|
+
workspaceDir: ctx.workspaceDir
|
|
252
|
+
});
|
|
253
|
+
signal?.throwIfAborted();
|
|
254
|
+
if (!result.text.trim()) throw new Error("The local image model returned no text. Run managed local media setup again.");
|
|
255
|
+
const text = truncateUtf16Safe(result.text, maxChars);
|
|
256
|
+
return textResult(text, {
|
|
257
|
+
text,
|
|
258
|
+
task,
|
|
259
|
+
provider: LLAMA_CPP_PROVIDER_ID,
|
|
260
|
+
model: result.model ?? model.id,
|
|
261
|
+
path: input
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}, { name: "local_image" });
|
|
271
266
|
registerLlamaCppProvider(api, mediaProvider);
|
|
272
267
|
}
|
|
273
268
|
});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { provider_discovery_default as default };
|
|
1
|
+
export { t as default } from "./.setup/provider-discovery-D3_7fprf.mjs";
|
|
@@ -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-Dn-MKZjS.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.11.
|
|
3
|
+
"version": "2026.11.5-beta.2",
|
|
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.11.
|
|
24
|
+
"pluginApi": ">=2026.11.5-beta.2"
|
|
25
25
|
},
|
|
26
26
|
"build": {
|
|
27
|
-
"openclawVersion": "2026.11.
|
|
27
|
+
"openclawVersion": "2026.11.5-beta.2"
|
|
28
28
|
},
|
|
29
29
|
"release": {
|
|
30
30
|
"bundleRuntimeDependencies": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@openclaw/fs-safe": "0.26.
|
|
39
|
+
"@openclaw/fs-safe": "0.26.13"
|
|
40
40
|
},
|
|
41
41
|
"files": [
|
|
42
42
|
"dist/**",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"assets/activity.svg"
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"openclaw": ">=2026.11.
|
|
49
|
+
"openclaw": ">=2026.11.5-beta.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependenciesMeta": {
|
|
52
52
|
"openclaw": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import { resolveManagedResourceStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
4
|
-
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
//#region extensions/llama-cpp/src/defaults.ts
|
|
6
6
|
const LLAMA_CPP_PROVIDER_ID = "llama-cpp";
|
|
7
7
|
const LLAMA_CPP_PROVIDER_LABEL = "llama.cpp";
|