mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
c2de3206d4
* feat(llama-cpp): add external server provider * feat(llama-cpp): document external server setup * refactor(llama-cpp): harden external provider boundaries * fix(llama-cpp): support external structured output * fix(llama-cpp): isolate replacement endpoint credentials * test(llama-cpp): register external live shard * fix(llama-cpp): preserve explicit endpoint authorization * fix(llama-cpp): clear disabled inline credentials * fix(llama-cpp): preserve external local service configs * test(llama-cpp): cover retained external configs * test(llama-cpp): cover authorization precedence
67 lines
2.1 KiB
TypeScript
67 lines
2.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { normalizeLlamaServerProviderConfig, resolveLlamaServerEndpoint } from "./endpoint.js";
|
|
|
|
describe("llama-server endpoint", () => {
|
|
it.each([
|
|
["http://127.0.0.1:8080", "http://127.0.0.1:8080", "http://127.0.0.1:8080/v1"],
|
|
["http://127.0.0.1:8080/v1/", "http://127.0.0.1:8080", "http://127.0.0.1:8080/v1"],
|
|
["localhost:8010/v1", "http://localhost:8010", "http://localhost:8010/v1"],
|
|
[
|
|
"https://models.example.com/llama/v1",
|
|
"https://models.example.com/llama",
|
|
"https://models.example.com/llama/v1",
|
|
],
|
|
])("normalizes %s", (input, origin, inferenceBaseUrl) => {
|
|
expect(resolveLlamaServerEndpoint(input)).toEqual({ origin, inferenceBaseUrl });
|
|
});
|
|
|
|
it("rejects embedded credentials", () => {
|
|
const endpoint = new URL("http://localhost:8080/v1");
|
|
endpoint.username = "user";
|
|
endpoint.password = "secret";
|
|
expect(() => resolveLlamaServerEndpoint(endpoint.toString())).toThrow(
|
|
"must not contain credentials",
|
|
);
|
|
});
|
|
|
|
it("rejects non-HTTP schemes", () => {
|
|
expect(() => resolveLlamaServerEndpoint("ftp://localhost:8080/v1")).toThrow(
|
|
"Unsupported llama-server protocol",
|
|
);
|
|
});
|
|
|
|
it("normalizes provider transport and private-network request policy", () => {
|
|
expect(
|
|
normalizeLlamaServerProviderConfig({
|
|
baseUrl: "http://localhost:8080/",
|
|
api: "openai-responses",
|
|
models: [],
|
|
}),
|
|
).toEqual({
|
|
baseUrl: "http://localhost:8080/v1",
|
|
api: "openai-completions",
|
|
models: [],
|
|
request: { allowPrivateNetwork: true },
|
|
});
|
|
});
|
|
|
|
it("preserves explicitly configured local service compatibility", () => {
|
|
expect(
|
|
normalizeLlamaServerProviderConfig({
|
|
baseUrl: "http://localhost:8080/v1",
|
|
api: "openai-completions",
|
|
models: [],
|
|
localService: {
|
|
command: "/usr/local/bin/llama-server",
|
|
healthUrl: "http://localhost:8080/health",
|
|
},
|
|
}),
|
|
).toMatchObject({
|
|
localService: {
|
|
command: "/usr/local/bin/llama-server",
|
|
healthUrl: "http://localhost:8080/health",
|
|
},
|
|
});
|
|
});
|
|
});
|