@openclaw/llama-cpp-provider 2026.10.10-beta.5 → 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-Dx2WDi-G.mjs → auth-config-GFuvSOHY.mjs} +2 -3
- package/dist/.setup/{defaults-DX4XN2j1.mjs → defaults-B-3wLNsP.mjs} +2 -3
- package/dist/.setup/{discovery-DdCiAOWU.mjs → discovery-BzqfGNU5.mjs} +5 -9
- package/dist/.setup/{embedding-provider.runtime-djNMas6G.mjs → embedding-provider.runtime-D5WYHk8V.mjs} +49 -42
- package/dist/.setup/{managed-provider-config-BuFqNTx1.mjs → managed-provider-config-XhvrVUR1.mjs} +2 -3
- package/dist/.setup/{managed-server-Bjr1c5yX.mjs → managed-server-CTer5Rq4.mjs} +395 -299
- package/dist/.setup/{media-catalog-BwFQGYtY.mjs → media-catalog-D-CRqGbe.mjs} +10 -218
- package/dist/.setup/{media-config-CZ7CluNV.mjs → media-config-92b6iCHm.mjs} +1 -2
- package/dist/.setup/{media-provider.runtime-MqV-UJ1m.mjs → media-provider.runtime-CW2ZQBg4.mjs} +4 -5
- package/dist/.setup/{media-setup-BQ6-EW_y.mjs → media-setup-DIZRVYUM.mjs} +12 -14
- package/dist/.setup/{provider-tg85QOYU.mjs → provider-abJEzh8u.mjs} +5 -8
- package/dist/.setup/{provider-discovery-CWtKWZkY.mjs → provider-discovery-6Hy2SktE.mjs} +6 -10
- package/dist/.setup/{setup-DmjzzdfH.mjs → setup-4lK0M-lf.mjs} +125 -135
- package/dist/.setup/{setup-CDJ2D5mu.mjs → setup-BnmsVffD.mjs} +8 -11
- package/dist/.setup/{stream-CSBkXmdm.mjs → stream-PxiV675a.mjs} +40 -13
- package/dist/.source-module-urls/2a292bf2cc9d15ab4011c4fb7ee888280524a76675c662fb0329d5dc914f3fba.json +1 -1
- package/dist/index.js +118 -127
- package/dist/provider-discovery.js +1 -1
- package/dist/provider-policy-api.js +2 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-
|
|
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-
|
|
4
|
-
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
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
|
+
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";
|
|
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";
|
|
9
|
-
|
|
8
|
+
import { buildProviderToolCompatFamilyHooks } from "openclaw/plugin-sdk/provider-tools";
|
|
9
|
+
// extensions/llama-cpp/src/embedding-provider.ts
|
|
10
10
|
function readIdentityLocalOptions(options) {
|
|
11
11
|
const local = options.local ?? {};
|
|
12
12
|
const provider = options.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
@@ -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,20 +51,19 @@ 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
|
};
|
|
58
|
-
|
|
59
|
-
//#region extensions/llama-cpp/src/managed-provider.ts
|
|
58
|
+
// extensions/llama-cpp/src/managed-provider.ts
|
|
60
59
|
function wrapLlamaCppStream(ctx) {
|
|
61
60
|
const providerConfig = ctx.config?.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
|
|
62
61
|
const selectedModel = ctx.model;
|
|
63
62
|
if (providerConfig?.localService && !selectedModel) return;
|
|
64
63
|
return async (...args) => {
|
|
65
|
-
const { wrapLlamaServerStream } = await import("./.setup/stream-
|
|
64
|
+
const { wrapLlamaServerStream } = await import("./.setup/stream-PxiV675a.mjs");
|
|
66
65
|
if (providerConfig?.localService && selectedModel) {
|
|
67
|
-
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-
|
|
66
|
+
const { ensureManagedLlamaServerForChat } = await import("./.setup/managed-server-CTer5Rq4.mjs");
|
|
68
67
|
const signal = args[2]?.signal;
|
|
69
68
|
signal?.throwIfAborted();
|
|
70
69
|
await ensureManagedLlamaServerForChat({
|
|
@@ -96,11 +95,11 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
96
95
|
methodId: "local"
|
|
97
96
|
},
|
|
98
97
|
appGuidedSetup: {
|
|
99
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
100
|
-
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)
|
|
101
100
|
},
|
|
102
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
103
|
-
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)
|
|
104
103
|
},
|
|
105
104
|
{
|
|
106
105
|
id: "existing-server",
|
|
@@ -117,12 +116,12 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
117
116
|
methodId: "existing-server"
|
|
118
117
|
},
|
|
119
118
|
appGuidedSetup: {
|
|
120
|
-
detect: async (ctx) => (await import("./.setup/setup-
|
|
121
|
-
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)
|
|
122
121
|
},
|
|
123
|
-
run: async (ctx) => (await import("./.setup/setup-
|
|
124
|
-
validateNonInteractive: async (ctx) => (await import("./.setup/setup-
|
|
125
|
-
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)
|
|
126
125
|
},
|
|
127
126
|
{
|
|
128
127
|
id: "local-media",
|
|
@@ -130,17 +129,17 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
130
129
|
hint: "Recommend, install and verify local image models for this Gateway",
|
|
131
130
|
kind: "custom",
|
|
132
131
|
run: async (ctx) => {
|
|
133
|
-
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-
|
|
132
|
+
const { runLlamaCppMediaSetup } = await import("./.setup/media-setup-DIZRVYUM.mjs");
|
|
134
133
|
return await runLlamaCppMediaSetup(ctx, mediaProvider);
|
|
135
134
|
}
|
|
136
135
|
}
|
|
137
136
|
],
|
|
138
137
|
prepareDynamicModel: async (ctx) => {
|
|
139
138
|
if (ctx.config?.models?.providers?.["llama-cpp"]?.localService) return;
|
|
140
|
-
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-
|
|
139
|
+
const { prepareLlamaServerDynamicModel } = await import("./.setup/provider-abJEzh8u.mjs");
|
|
141
140
|
return prepareLlamaServerDynamicModel(ctx);
|
|
142
141
|
},
|
|
143
|
-
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-
|
|
142
|
+
reconcileLocalService: async (ctx) => (await import("./.setup/managed-server-CTer5Rq4.mjs")).reconcileManagedLlamaServer(ctx),
|
|
144
143
|
wrapSimpleCompletionStreamFn: wrapLlamaCppStream,
|
|
145
144
|
wrapStreamFn: wrapLlamaCppStream,
|
|
146
145
|
...buildProviderToolCompatFamilyHooks("llamacpp-gbnf"),
|
|
@@ -151,114 +150,17 @@ function registerLlamaCppProvider(api, mediaProvider) {
|
|
|
151
150
|
} }
|
|
152
151
|
});
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
//#region extensions/llama-cpp/src/media-provider.ts
|
|
153
|
+
// extensions/llama-cpp/src/media-provider.ts
|
|
156
154
|
/** The setup verifier and local_image tool consume this registered media entry point. */
|
|
157
155
|
function createLlamaCppMediaProvider() {
|
|
158
156
|
return {
|
|
159
157
|
id: LLAMA_CPP_PROVIDER_ID,
|
|
160
158
|
capabilities: ["image"],
|
|
161
|
-
describeImage: async (req) => (await import("./.setup/media-provider.runtime-
|
|
162
|
-
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)
|
|
163
161
|
};
|
|
164
162
|
}
|
|
165
|
-
|
|
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
|
-
//#region extensions/llama-cpp/index.ts
|
|
163
|
+
// extensions/llama-cpp/index.ts
|
|
262
164
|
var llama_cpp_default = definePluginEntry({
|
|
263
165
|
id: "llama-cpp",
|
|
264
166
|
name: "llama.cpp Provider",
|
|
@@ -267,9 +169,98 @@ var llama_cpp_default = definePluginEntry({
|
|
|
267
169
|
const mediaProvider = createLlamaCppMediaProvider();
|
|
268
170
|
api.registerEmbeddingProvider(llamaCppEmbeddingProviderAdapter);
|
|
269
171
|
api.registerMediaUnderstandingProvider(mediaProvider);
|
|
270
|
-
|
|
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" });
|
|
271
263
|
registerLlamaCppProvider(api, mediaProvider);
|
|
272
264
|
}
|
|
273
265
|
});
|
|
274
|
-
//#endregion
|
|
275
266
|
export { llama_cpp_default as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as default } from "./.setup/provider-discovery-
|
|
1
|
+
export { t as default } from "./.setup/provider-discovery-6Hy2SktE.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-
|
|
2
|
-
|
|
1
|
+
import { n as resolveManagedLlamaCppProviderConfig, t as MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE } from "./.setup/managed-provider-config-XhvrVUR1.mjs";
|
|
2
|
+
// extensions/llama-cpp/provider-policy-api.ts
|
|
3
3
|
function inspectEmbeddingProviderSetup(params) {
|
|
4
4
|
if (params.provider !== "local") return null;
|
|
5
5
|
const fixHint = `Run \`openclaw models --agent ${params.agentId} auth login --provider llama-cpp --method local\` in an interactive terminal, then rerun this check.`;
|
|
@@ -15,5 +15,4 @@ function inspectEmbeddingProviderSetup(params) {
|
|
|
15
15
|
}
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { inspectEmbeddingProviderSetup };
|
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": {
|