@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
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-B-3wLNsP.mjs";
|
|
2
|
+
import { a as LLAMA_SERVER_DEFAULT_ORIGIN, t as provider_discovery_default } from "./.setup/provider-discovery-6Hy2SktE.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-92b6iCHm.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
|
// 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-D5WYHk8V.mjs");
|
|
55
55
|
return createLlamaCppEmbeddingProvider(options, resolveLlamaCppEmbeddingModel(local).source, resolveModelIdentity(local, options.dimensions));
|
|
56
56
|
}
|
|
57
57
|
};
|
|
@@ -61,9 +61,9 @@ function wrapLlamaCppStream(ctx) {
|
|
|
61
61
|
const selectedModel = ctx.model;
|
|
62
62
|
if (providerConfig?.localService && !selectedModel) return;
|
|
63
63
|
return async (...args) => {
|
|
64
|
-
const { wrapLlamaServerStream } = await import("./.setup/stream-
|
|
64
|
+
const { wrapLlamaServerStream } = await import("./.setup/stream-PxiV675a.mjs");
|
|
65
65
|
if (providerConfig?.localService && selectedModel) {
|
|
66
|
-
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-
|
|
66
|
+
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-CTer5Rq4.mjs");
|
|
67
67
|
const signal = args[2]?.signal;
|
|
68
68
|
signal?.throwIfAborted();
|
|
69
69
|
await ensureManagedLlamaServerForChat({
|
|
@@ -95,11 +95,11 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
95
95
|
methodId: "local"
|
|
96
96
|
},
|
|
97
97
|
appGuidedSetup: {
|
|
98
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
99
|
-
prepare: async (ctx) => (await import("./.setup/setup-
|
|
98
|
+
detect: async (ctx) => (await import("./.setup/setup-4lK0M-lf.mjs")).detectLlamaCppSetup(ctx),
|
|
99
|
+
prepare: async (ctx) => (await import("./.setup/setup-4lK0M-lf.mjs")).prepareLlamaCppSetup(ctx)
|
|
100
100
|
},
|
|
101
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
102
|
-
runNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
101
|
+
run: async (ctx) => (await import("./.setup/setup-4lK0M-lf.mjs")).runLlamaCppSetup(ctx),
|
|
102
|
+
runNonInteractive: async (ctx) => (await import("./.setup/setup-4lK0M-lf.mjs")).configureLlamaCppNonInteractive(ctx)
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
id: "existing-server",
|
|
@@ -116,12 +116,12 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
116
116
|
methodId: "existing-server"
|
|
117
117
|
},
|
|
118
118
|
appGuidedSetup: {
|
|
119
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
120
|
-
prepare: async (ctx) => (await import("./.setup/setup-
|
|
119
|
+
detect: async (ctx) => (await import("./.setup/setup-BnmsVffD.mjs")).detectLlamaServerSetup(ctx),
|
|
120
|
+
prepare: async (ctx) => (await import("./.setup/setup-BnmsVffD.mjs")).prepareLlamaServerSetup(ctx)
|
|
121
121
|
},
|
|
122
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
123
|
-
validateNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
124
|
-
runNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
122
|
+
run: async (ctx) => (await import("./.setup/setup-BnmsVffD.mjs")).runLlamaServerSetup(ctx),
|
|
123
|
+
validateNonInteractive: async (ctx) => (await import("./.setup/setup-BnmsVffD.mjs")).validateLlamaServerNonInteractive(ctx),
|
|
124
|
+
runNonInteractive: async (ctx) => (await import("./.setup/setup-BnmsVffD.mjs")).configureLlamaServerNonInteractive(ctx)
|
|
125
125
|
},
|
|
126
126
|
{
|
|
127
127
|
id: "local-media",
|
|
@@ -129,17 +129,17 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
129
129
|
hint: "Recommend, install and verify local image models for this Gateway",
|
|
130
130
|
kind: "custom",
|
|
131
131
|
run: async (ctx) => {
|
|
132
|
-
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-
|
|
132
|
+
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-DIZRVYUM.mjs");
|
|
133
133
|
return await runLlamaCppMediaSetup(ctx, mediaProvider);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
],
|
|
137
137
|
prepareDynamicModel: async (ctx) => {
|
|
138
138
|
if (ctx.config?.models?.providers?.["llama-cpp"]?.localService) return;
|
|
139
|
-
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-
|
|
139
|
+
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-abJEzh8u.mjs");
|
|
140
140
|
return prepareLlamaServerDynamicModel(ctx);
|
|
141
141
|
},
|
|
142
|
-
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-
|
|
142
|
+
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-CTer5Rq4.mjs")).reconcileManagedLlamaServer(ctx),
|
|
143
143
|
wrapSimpleCompletionStreamFn: wrapLlamaCppStream,
|
|
144
144
|
wrapStreamFn: wrapLlamaCppStream,
|
|
145
145
|
...buildProviderToolCompatFamilyHooks("llamacpp-gbnf"),
|
|
@@ -156,104 +156,10 @@ function createLlamaCppMediaProvider() {
|
|
|
156
156
|
return {
|
|
157
157
|
id: LLAMA_CPP_PROVIDER_ID,
|
|
158
158
|
capabilities: ["image"],
|
|
159
|
-
describeImage: async (req) => (await import("./.setup/media-provider.runtime-
|
|
160
|
-
describeImages: async (req) => (await import("./.setup/media-provider.runtime-
|
|
159
|
+
describeImage: async (req) => (await import("./.setup/media-provider.runtime-CW2ZQBg4.mjs")).describeLlamaCppImage(req),
|
|
160
|
+
describeImages: async (req) => (await import("./.setup/media-provider.runtime-CW2ZQBg4.mjs")).describeLlamaCppImages(req)
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
// extensions/llama-cpp/src/media-tool.ts
|
|
164
|
-
/** Maps explicit task intent onto the same provider hook used by normal image understanding. */
|
|
165
|
-
function registerLlamaCppMediaTool(api, provider) {
|
|
166
|
-
api.registerTool((ctx) => {
|
|
167
|
-
if (ctx.sandboxed || !provider.describeImage) return null;
|
|
168
|
-
const describeImage = provider.describeImage;
|
|
169
|
-
const getConfig = () => ctx.getRuntimeConfig?.() ?? ctx.runtimeConfig ?? ctx.config ?? api.config;
|
|
170
|
-
const configured = getConfig().models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
171
|
-
if (!isManagedLlamaCppMediaProvider(configured) || !resolveLlamaCppMediaModels(configured)) return null;
|
|
172
|
-
return {
|
|
173
|
-
name: "local_image",
|
|
174
|
-
label: "Local Image",
|
|
175
|
-
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.",
|
|
176
|
-
parameters: {
|
|
177
|
-
type: "object",
|
|
178
|
-
properties: {
|
|
179
|
-
path: {
|
|
180
|
-
type: "string",
|
|
181
|
-
minLength: 1,
|
|
182
|
-
description: "Local image path or media:// reference."
|
|
183
|
-
},
|
|
184
|
-
task: {
|
|
185
|
-
type: "string",
|
|
186
|
-
enum: ["ocr", "vision"],
|
|
187
|
-
default: "vision"
|
|
188
|
-
},
|
|
189
|
-
prompt: {
|
|
190
|
-
type: "string",
|
|
191
|
-
maxLength: 8192
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
required: ["path"],
|
|
195
|
-
additionalProperties: false
|
|
196
|
-
},
|
|
197
|
-
async execute(_toolCallId, args, signal) {
|
|
198
|
-
signal?.throwIfAborted();
|
|
199
|
-
if (!isRecord(args)) throw new Error("Local image input must contain a path and optional ocr or vision task.");
|
|
200
|
-
const task = args.task === void 0 ? "vision" : args.task;
|
|
201
|
-
if (task !== "ocr" && task !== "vision") throw new Error("Local image task must be ocr or vision.");
|
|
202
|
-
const input = normalizeOptionalString(args.path);
|
|
203
|
-
if (!input) throw new Error("Local image path is required.");
|
|
204
|
-
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.");
|
|
205
|
-
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.");
|
|
206
|
-
const cfg = getConfig();
|
|
207
|
-
const configuredProvider = cfg.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
208
|
-
const models = resolveLlamaCppMediaModels(configuredProvider);
|
|
209
|
-
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.");
|
|
210
|
-
const model = configuredProvider?.models.find((entry) => entry.id === models[task]);
|
|
211
|
-
if (!model?.input.includes("image")) throw new Error(`The configured local ${task} model is unavailable. Run managed local media setup again.`);
|
|
212
|
-
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.");
|
|
213
|
-
const workspace = ctx.fsPolicy?.root ?? ctx.workspaceDir;
|
|
214
|
-
const localRoots = ctx.fsPolicy?.workspaceOnly ? workspace ? [path.resolve(workspace)] : [] : (await import("openclaw/plugin-sdk/media-local-roots")).getAgentScopedMediaLocalRoots(cfg, ctx.agentId, workspace);
|
|
215
|
-
const imageConfig = cfg.tools?.media?.image;
|
|
216
|
-
const maxBytes = Math.min(asPositiveSafeInteger(imageConfig?.maxBytes) ?? 10485760, LLAMA_CPP_MEDIA_MAX_BYTES);
|
|
217
|
-
const maxChars = Math.min(asPositiveSafeInteger(imageConfig?.maxChars) ?? 12e3, LLAMA_CPP_MEDIA_MAX_CHARS);
|
|
218
|
-
const timeoutMs = Math.min(imageConfig?.timeoutSeconds === void 0 ? LLAMA_CPP_MEDIA_TIMEOUT_MS : (asPositiveSafeInteger(imageConfig.timeoutSeconds) ?? 600) * 1e3, 2147483647);
|
|
219
|
-
const source = input.startsWith("media://") || input.startsWith("~") || path.isAbsolute(input) ? input : path.resolve(workspace ?? process.cwd(), input);
|
|
220
|
-
signal?.throwIfAborted();
|
|
221
|
-
const image = await api.runtime.media.loadWebMedia(source, {
|
|
222
|
-
maxBytes,
|
|
223
|
-
localRoots: [...localRoots, ...ctx.fsPolicy?.readOnlyRoots ?? []],
|
|
224
|
-
...signal ? { requestInit: { signal } } : {}
|
|
225
|
-
});
|
|
226
|
-
signal?.throwIfAborted();
|
|
227
|
-
if (image.kind !== "image") throw new Error("Local image input must be an image.");
|
|
228
|
-
const result = await describeImage({
|
|
229
|
-
buffer: image.buffer,
|
|
230
|
-
fileName: image.fileName ?? path.basename(source),
|
|
231
|
-
mime: image.contentType,
|
|
232
|
-
provider: LLAMA_CPP_PROVIDER_ID,
|
|
233
|
-
model: model.id,
|
|
234
|
-
prompt: normalizeOptionalString(args.prompt) ?? (task === "ocr" ? "Transcribe all visible text exactly. Return only the text." : "Describe the image."),
|
|
235
|
-
maxTokens: Math.min(asPositiveSafeInteger(model.maxTokens) ?? 2048, LLAMA_CPP_MEDIA_MAX_TOKENS),
|
|
236
|
-
timeoutMs,
|
|
237
|
-
signal,
|
|
238
|
-
cfg,
|
|
239
|
-
agentId: ctx.agentId,
|
|
240
|
-
agentDir: ctx.agentDir,
|
|
241
|
-
workspaceDir: ctx.workspaceDir
|
|
242
|
-
});
|
|
243
|
-
signal?.throwIfAborted();
|
|
244
|
-
if (!result.text.trim()) throw new Error("The local image model returned no text. Run managed local media setup again.");
|
|
245
|
-
const text = truncateUtf16Safe(result.text, maxChars);
|
|
246
|
-
return textResult(text, {
|
|
247
|
-
text,
|
|
248
|
-
task,
|
|
249
|
-
provider: LLAMA_CPP_PROVIDER_ID,
|
|
250
|
-
model: result.model ?? model.id,
|
|
251
|
-
path: input
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
}, { name: "local_image" });
|
|
256
|
-
}
|
|
257
163
|
// extensions/llama-cpp/index.ts
|
|
258
164
|
var llama_cpp_default = definePluginEntry({
|
|
259
165
|
id: "llama-cpp",
|
|
@@ -263,7 +169,97 @@ var llama_cpp_default = definePluginEntry({
|
|
|
263
169
|
const mediaProvider = createLlamaCppMediaProvider();
|
|
264
170
|
api.registerEmbeddingProvider(llamaCppEmbeddingProviderAdapter);
|
|
265
171
|
api.registerMediaUnderstandingProvider(mediaProvider);
|
|
266
|
-
|
|
172
|
+
/** Maps explicit task intent onto the same provider hook used by normal image understanding. */
|
|
173
|
+
api.registerTool((ctx) => {
|
|
174
|
+
if (ctx.sandboxed || !mediaProvider.describeImage) return null;
|
|
175
|
+
const describeImage = mediaProvider.describeImage;
|
|
176
|
+
const getConfig = () => ctx.getRuntimeConfig?.() ?? ctx.runtimeConfig ?? ctx.config ?? api.config;
|
|
177
|
+
const configured = getConfig().models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
178
|
+
if (!isManagedLlamaCppMediaProvider(configured) || !resolveLlamaCppMediaModels(configured)) return null;
|
|
179
|
+
return {
|
|
180
|
+
name: "local_image",
|
|
181
|
+
label: "Local Image",
|
|
182
|
+
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.",
|
|
183
|
+
parameters: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
path: {
|
|
187
|
+
type: "string",
|
|
188
|
+
minLength: 1,
|
|
189
|
+
description: "Local image path or media:// reference."
|
|
190
|
+
},
|
|
191
|
+
task: {
|
|
192
|
+
type: "string",
|
|
193
|
+
enum: ["ocr", "vision"],
|
|
194
|
+
default: "vision"
|
|
195
|
+
},
|
|
196
|
+
prompt: {
|
|
197
|
+
type: "string",
|
|
198
|
+
maxLength: 8192
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
required: ["path"],
|
|
202
|
+
additionalProperties: false
|
|
203
|
+
},
|
|
204
|
+
async execute(_toolCallId, args, signal) {
|
|
205
|
+
signal?.throwIfAborted();
|
|
206
|
+
if (!isRecord(args)) throw new Error("Local image input must contain a path and optional ocr or vision task.");
|
|
207
|
+
const task = args.task === void 0 ? "vision" : args.task;
|
|
208
|
+
if (task !== "ocr" && task !== "vision") throw new Error("Local image task must be ocr or vision.");
|
|
209
|
+
const input = normalizeOptionalString(args.path);
|
|
210
|
+
if (!input) throw new Error("Local image path is required.");
|
|
211
|
+
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.");
|
|
212
|
+
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.");
|
|
213
|
+
const cfg = getConfig();
|
|
214
|
+
const configuredProvider = cfg.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
215
|
+
const models = resolveLlamaCppMediaModels(configuredProvider);
|
|
216
|
+
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.");
|
|
217
|
+
const model = configuredProvider?.models.find((entry) => entry.id === models[task]);
|
|
218
|
+
if (!model?.input.includes("image")) throw new Error(`The configured local ${task} model is unavailable. Run managed local media setup again.`);
|
|
219
|
+
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.");
|
|
220
|
+
const workspace = ctx.fsPolicy?.root ?? ctx.workspaceDir;
|
|
221
|
+
const localRoots = ctx.fsPolicy?.workspaceOnly ? workspace ? [path.resolve(workspace)] : [] : (await import("openclaw/plugin-sdk/media-local-roots")).getAgentScopedMediaLocalRoots(cfg, ctx.agentId, workspace);
|
|
222
|
+
const imageConfig = cfg.tools?.media?.image;
|
|
223
|
+
const maxBytes = Math.min(asPositiveSafeInteger(imageConfig?.maxBytes) ?? 10485760, LLAMA_CPP_MEDIA_MAX_BYTES);
|
|
224
|
+
const maxChars = Math.min(asPositiveSafeInteger(imageConfig?.maxChars) ?? 12e3, LLAMA_CPP_MEDIA_MAX_CHARS);
|
|
225
|
+
const timeoutMs = Math.min(imageConfig?.timeoutSeconds === void 0 ? LLAMA_CPP_MEDIA_TIMEOUT_MS : (asPositiveSafeInteger(imageConfig.timeoutSeconds) ?? 600) * 1e3, 2147483647);
|
|
226
|
+
const source = input.startsWith("media://") || input.startsWith("~") || path.isAbsolute(input) ? input : path.resolve(workspace ?? process.cwd(), input);
|
|
227
|
+
signal?.throwIfAborted();
|
|
228
|
+
const image = await api.runtime.media.loadWebMedia(source, {
|
|
229
|
+
maxBytes,
|
|
230
|
+
localRoots: [...localRoots, ...ctx.fsPolicy?.readOnlyRoots ?? []],
|
|
231
|
+
...signal ? { requestInit: { signal } } : {}
|
|
232
|
+
});
|
|
233
|
+
signal?.throwIfAborted();
|
|
234
|
+
if (image.kind !== "image") throw new Error("Local image input must be an image.");
|
|
235
|
+
const result = await describeImage({
|
|
236
|
+
buffer: image.buffer,
|
|
237
|
+
fileName: image.fileName ?? path.basename(source),
|
|
238
|
+
mime: image.contentType,
|
|
239
|
+
provider: LLAMA_CPP_PROVIDER_ID,
|
|
240
|
+
model: model.id,
|
|
241
|
+
prompt: normalizeOptionalString(args.prompt) ?? (task === "ocr" ? "Transcribe all visible text exactly. Return only the text." : "Describe the image."),
|
|
242
|
+
maxTokens: Math.min(asPositiveSafeInteger(model.maxTokens) ?? 2048, LLAMA_CPP_MEDIA_MAX_TOKENS),
|
|
243
|
+
timeoutMs,
|
|
244
|
+
signal,
|
|
245
|
+
cfg,
|
|
246
|
+
agentId: ctx.agentId,
|
|
247
|
+
agentDir: ctx.agentDir,
|
|
248
|
+
workspaceDir: ctx.workspaceDir
|
|
249
|
+
});
|
|
250
|
+
signal?.throwIfAborted();
|
|
251
|
+
if (!result.text.trim()) throw new Error("The local image model returned no text. Run managed local media setup again.");
|
|
252
|
+
const text = truncateUtf16Safe(result.text, maxChars);
|
|
253
|
+
return textResult(text, {
|
|
254
|
+
text,
|
|
255
|
+
task,
|
|
256
|
+
provider: LLAMA_CPP_PROVIDER_ID,
|
|
257
|
+
model: result.model ?? model.id,
|
|
258
|
+
path: input
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}, { name: "local_image" });
|
|
267
263
|
registerLlamaCppProvider(api, mediaProvider);
|
|
268
264
|
}
|
|
269
265
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./.setup/provider-discovery-
|
|
1
|
+
export { t as default } from "./.setup/provider-discovery-6Hy2SktE.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-XhvrVUR1.mjs";
|
|
2
2
|
// 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.
|
|
3
|
+
"version": "2026.11.5-beta.1",
|
|
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.
|
|
24
|
+
"pluginApi": ">=2026.11.5-beta.1"
|
|
25
25
|
},
|
|
26
26
|
"build": {
|
|
27
|
-
"openclawVersion": "2026.
|
|
27
|
+
"openclawVersion": "2026.11.5-beta.1"
|
|
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.
|
|
49
|
+
"openclaw": ">=2026.11.5-beta.1"
|
|
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
|
// extensions/llama-cpp/src/defaults.ts
|
|
6
6
|
const LLAMA_CPP_PROVIDER_ID = "llama-cpp";
|
|
7
7
|
const LLAMA_CPP_PROVIDER_LABEL = "llama.cpp";
|