mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
5f1bbed42d
* fix(gateway): expose startup blockers before cutover * fix(gateway): include session blockers in preflight * fix(gateway): keep preflight finding type private * fix(gateway): preflight startup auth blockers * fix(gateway): complete startup preflight readiness * fix(llama-cpp): keep preflight remediation private * fix(gateway): keep preflight passive and activation-aware * fix(gateway): apply startup guard in preflight * fix(gateway): align auth mode preflight * fix(gateway): keep preflight state reads isolated Share the read-only inspection snapshot scope across duplicated runtime chunks so blocked gateway preflight remains non-mutating when bundled provider artifacts read canonical state. * fix(gateway): keep startup preflight passive * fix(gateway): ignore inactive embedding owner shadows * fix(gateway): preserve startup preflight parity * fix(llama-cpp): keep cache inspection types private * fix(gateway): close startup preflight parity gaps * fix(gateway): handle uninitialized memory databases * test(gateway): observe shell fallback portably * fix(llama-cpp): normalize embedding model paths * refactor(gateway): drop broad startup preflight surface * fix(doctor): report missing managed local embedding setup * style(memory): simplify setup enablement check * fix(memory): keep diagnostic result type private * fix(memory): inspect local setup with remote secret refs * fix(memory): keep doctor index inspection immutable * fix(memory): make readiness inspection owner-aware * fix(doctor): mirror memory slot allowlist policy * test(doctor): use canonical memory slot id * fix(doctor): normalize memory provider ids * fix(doctor): resolve external embedding readiness owner * fix(plugins): keep embedding inspection result internal * fix(doctor): isolate plugin state during lint * fix(doctor): route lint metadata through snapshot * fix(cli): keep doctor lint startup source-only * fix(cli): keep doctor lint compile-cache free * fix(doctor): keep local embedding readiness opt-in * test(doctor): preserve plugin artifact roots during lint * fix(doctor): refresh memory readiness registration * test(doctor): type nullable provider policy mock * fix(doctor): scope lint state snapshot to provider check * fix(doctor): isolate selected plugin state checks * test(doctor): restore only scoped environment * fix(doctor): defer readiness state inspection * fix(doctor): keep deferred config reads isolated * fix(doctor): keep plugin state mode internal * fix(config): preserve default plugin validation
107 lines
3.5 KiB
TypeScript
107 lines
3.5 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";
|
|
import { inspectEmbeddingProviderSetup } from "./provider-policy-api.js";
|
|
import { buildLlamaCppProviderConfig } from "./src/defaults.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);
|
|
});
|
|
|
|
it("reports the direct-start managed setup blocker with the supported CLI remediation", async () => {
|
|
expect(
|
|
inspectEmbeddingProviderSetup({
|
|
config: {},
|
|
env: {},
|
|
agentId: "main",
|
|
provider: "local",
|
|
}),
|
|
).toEqual({
|
|
provider: "local",
|
|
reason: expect.stringContaining("Local embeddings need the managed llama.cpp server config"),
|
|
requirement: "managed-llama-cpp-setup",
|
|
fixHint:
|
|
"Run `openclaw models --agent main auth login --provider llama-cpp --method local` in an interactive terminal, then rerun this check.",
|
|
});
|
|
});
|
|
|
|
it("accepts managed config produced by the models auth CLI without mutating it", async () => {
|
|
const provider = buildLlamaCppProviderConfig(undefined, {
|
|
command: "/managed/llama-server",
|
|
baseUrl: "http://127.0.0.1:19432/v1",
|
|
healthUrl: "http://127.0.0.1:19432/health",
|
|
args: ["--models-preset", "/managed/models.ini"],
|
|
});
|
|
const config: OpenClawConfig = {
|
|
models: { providers: { "llama-cpp": provider } },
|
|
};
|
|
const configBefore = JSON.stringify(config);
|
|
|
|
expect(
|
|
inspectEmbeddingProviderSetup({
|
|
config,
|
|
env: {},
|
|
agentId: "main",
|
|
provider: "local",
|
|
}),
|
|
).toBeNull();
|
|
|
|
expect(JSON.stringify(config)).toBe(configBefore);
|
|
});
|
|
|
|
it("does not apply managed llama.cpp setup to a non-local memory provider", async () => {
|
|
expect(
|
|
inspectEmbeddingProviderSetup({
|
|
config: {},
|
|
env: {},
|
|
agentId: "main",
|
|
provider: "openai",
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|