Files
openclaw/extensions/llama-cpp/doctor-contract-api.test.ts
T
Peter Steinberger 1348387076 refactor(plugins): replace node-llama-cpp with managed llama-server (#123105)
Move llama.cpp chat and local embeddings onto a verified externally managed llama-server runtime. Remove the in-process native runtime, forked embedding workers, and node-llama-cpp dependency while preserving guided setup, local GGUF models, tool-capable agent runs, diagnostics, and operator docs.
2026-08-13 16:58:20 -07:00

53 lines
1.8 KiB
TypeScript

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
import { describe, expect, it } from "vitest";
import { legacyConfigRules, normalizeCompatibilityConfig } from "./doctor-contract-api.js";
describe("llama.cpp doctor migration", () => {
it("moves the shipped local URL to an absolute managed service", () => {
const cfg: OpenClawConfig = {
models: {
providers: {
"llama-cpp": {
baseUrl: "local://llama-cpp",
api: "openai-completions",
models: [],
},
},
},
};
const result = normalizeCompatibilityConfig({ cfg });
const provider = result.config.models?.providers?.["llama-cpp"];
expect(provider).toMatchObject({
baseUrl: "http://127.0.0.1:19432/v1",
localService: {
command: expect.stringMatching(/llama-server(?:\.exe)?$/u),
args: expect.arrayContaining(["--models-preset", "--metrics"]),
healthUrl: "http://127.0.0.1:19432/health",
},
});
expect(
provider?.localService?.command.startsWith("/") ||
/^[A-Z]:\\/iu.test(provider?.localService?.command ?? ""),
).toBe(true);
expect(result.changes).toHaveLength(1);
expect(normalizeCompatibilityConfig({ cfg: result.config }).changes).toEqual([]);
});
it("does not rewrite explicit HTTP llama.cpp servers", () => {
const cfg: OpenClawConfig = {
models: {
providers: {
"llama-cpp": {
baseUrl: "http://gpu-box.local:8080/v1",
api: "openai-completions",
models: [],
},
},
},
};
expect(normalizeCompatibilityConfig({ cfg })).toEqual({ config: cfg, changes: [] });
expect(legacyConfigRules[0]?.match?.("http://gpu-box.local:8080/v1")).toBe(false);
});
});