@openclaw/llama-cpp-provider 2026.7.2-beta.3 → 2026.7.2-beta.5

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/README.md CHANGED
@@ -31,9 +31,9 @@ for custom GGUF model configuration and hardware guidance.
31
31
 
32
32
  ## Configure embeddings
33
33
 
34
- Set `agents.defaults.memorySearch.provider` to `local`. By default, the plugin
34
+ Set `memory.search.provider` to `local`. By default, the plugin
35
35
  downloads and uses the EmbeddingGemma GGUF model. Configure
36
- `agents.defaults.memorySearch.local.modelPath` to use another local path, Hugging
36
+ `memory.search.local.modelPath` to use another local path, Hugging
37
37
  Face model URI, or HTTPS model URL.
38
38
 
39
39
  ## Package
package/dist/index.js CHANGED
@@ -285,6 +285,18 @@ function extractText(content) {
285
285
  function normalizeArguments(value) {
286
286
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
287
287
  }
288
+ async function resolveLlamaCppResponseGrammar(params) {
289
+ const responseFormat = params.responseFormat;
290
+ if (!responseFormat) return;
291
+ if (Object.keys(responseFormat).length === 0) return await params.llama.getGrammarFor("json");
292
+ if (responseFormat.type === "json_object") return await params.llama.getGrammarFor("json");
293
+ if (responseFormat.type === "text") return;
294
+ if (responseFormat.type === "json_schema") {
295
+ const schema = normalizeArguments(normalizeArguments(responseFormat.json_schema).schema);
296
+ return Object.keys(schema).length > 0 ? await params.llama.createGrammarForJsonSchema(schema) : await params.llama.getGrammarFor("json");
297
+ }
298
+ return await params.llama.createGrammarForJsonSchema(responseFormat);
299
+ }
288
300
  function mapContextToLlamaChatHistory(context) {
289
301
  const history = [];
290
302
  if (context.systemPrompt?.trim()) history.push({
@@ -389,6 +401,7 @@ async function getLoadedModel(params) {
389
401
  const sequence = context.getSequence();
390
402
  loadedModel = {
391
403
  key,
404
+ llama,
392
405
  model,
393
406
  context,
394
407
  sequence
@@ -445,18 +458,20 @@ function createLlamaCppStreamFn(params) {
445
458
  signal?.removeEventListener("abort", abortWhileQueued);
446
459
  try {
447
460
  const runtime = await importNodeLlamaCpp();
448
- const sequence = (await getLoadedModel({
461
+ const loaded = await getLoadedModel({
449
462
  runtime,
450
463
  model,
451
464
  providerConfig: params.providerConfig,
452
465
  signal: options?.signal
453
- })).sequence;
466
+ });
467
+ const sequence = loaded.sequence;
454
468
  const chat = new runtime.LlamaChat({
455
469
  contextSequence: sequence,
456
470
  chatWrapper: "auto",
457
471
  autoDisposeSequence: false
458
472
  });
459
473
  const before = sequence.tokenMeter.getState();
474
+ const functions = mapToolsToLlamaFunctions(context);
460
475
  let textStarted = false;
461
476
  const partial = () => buildMessage({
462
477
  model,
@@ -488,15 +503,22 @@ function createLlamaCppStreamFn(params) {
488
503
  });
489
504
  };
490
505
  try {
491
- const result = await chat.generateResponse(mapContextToLlamaChatHistory(context), {
492
- functions: mapToolsToLlamaFunctions(context),
493
- documentFunctionParams: true,
506
+ const grammar = functions || !options?.responseFormat ? void 0 : await resolveLlamaCppResponseGrammar({
507
+ llama: loaded.llama,
508
+ responseFormat: options.responseFormat
509
+ });
510
+ const generationOptions = {
494
511
  signal: options?.signal,
495
512
  maxTokens: options?.maxTokens ?? model.maxTokens,
496
513
  temperature: options?.temperature,
497
514
  customStopTriggers: options?.stop,
498
- onTextChunk: appendTextDelta
499
- });
515
+ onTextChunk: appendTextDelta,
516
+ ...functions ? {
517
+ functions,
518
+ documentFunctionParams: true
519
+ } : grammar ? { grammar } : {}
520
+ };
521
+ const result = await chat.generateResponse(mapContextToLlamaChatHistory(context), generationOptions);
500
522
  if (result.metadata.stopReason === "abort" || signal?.aborted) {
501
523
  generationAborted = true;
502
524
  throw signal?.reason ?? /* @__PURE__ */ new Error("Request was aborted");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/llama-cpp-provider",
3
- "version": "2026.7.2-beta.3",
3
+ "version": "2026.7.2-beta.5",
4
4
  "description": "OpenClaw llama.cpp text inference and embedding provider plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,10 +23,10 @@
23
23
  "minHostVersion": ">=2026.6.2"
24
24
  },
25
25
  "compat": {
26
- "pluginApi": ">=2026.7.2-beta.3"
26
+ "pluginApi": ">=2026.7.2-beta.5"
27
27
  },
28
28
  "build": {
29
- "openclawVersion": "2026.7.2-beta.3"
29
+ "openclawVersion": "2026.7.2-beta.5"
30
30
  },
31
31
  "release": {
32
32
  "bundleRuntimeDependencies": false,
@@ -40,11 +40,10 @@
40
40
  "files": [
41
41
  "dist/**",
42
42
  "openclaw.plugin.json",
43
- "npm-shrinkwrap.json",
44
43
  "README.md"
45
44
  ],
46
45
  "peerDependencies": {
47
- "openclaw": ">=2026.7.2-beta.3"
46
+ "openclaw": ">=2026.7.2-beta.5"
48
47
  },
49
48
  "peerDependenciesMeta": {
50
49
  "openclaw": {