fix(opencode): route Union Alpha through Messages API
Route union-alpha to /zen/v1/messages with targetFormat claude, add anthropic-version header, and register model capabilities (vision, 262K context, 131K max output).
This commit is contained in:
@@ -63,6 +63,39 @@ describe("OpenCode Free Muse Spark thinking", () => {
|
||||
expect(out.max_tokens).toBeUndefined();
|
||||
});
|
||||
|
||||
it("routes Union Alpha through Anthropic Messages", () => {
|
||||
const caps = getCapabilitiesForModel(PROVIDER, "union-alpha");
|
||||
expect(caps.vision).toBe(true);
|
||||
expect(caps.contextWindow).toBe(262144);
|
||||
expect(caps.maxOutput).toBe(131072);
|
||||
|
||||
const executor = new OpenCodeExecutor();
|
||||
|
||||
expect(getModelTargetFormat("oc", "union-alpha")).toBe(FORMATS.CLAUDE);
|
||||
const url = executor.buildUrl("union-alpha");
|
||||
expect(url).toBe("https://opencode.ai/zen/v1/messages");
|
||||
expect(executor.buildHeaders({}, true, url)).toMatchObject({
|
||||
"anthropic-version": "2023-06-01",
|
||||
});
|
||||
expect(executor.buildHeaders({}, true, executor.buildUrl("big-pickle")))
|
||||
.not.toHaveProperty("anthropic-version");
|
||||
|
||||
const translated = translateRequest(
|
||||
FORMATS.OPENAI,
|
||||
FORMATS.CLAUDE,
|
||||
"union-alpha",
|
||||
{ messages: [{ role: "user", content: "ping" }], max_tokens: 1 },
|
||||
false,
|
||||
{},
|
||||
PROVIDER,
|
||||
);
|
||||
expect(translated).toMatchObject({
|
||||
model: "union-alpha",
|
||||
messages: [{ role: "user", content: [{ type: "text", text: "ping" }] }],
|
||||
max_tokens: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves the other free models on Chat Completions", () => {
|
||||
const executor = new OpenCodeExecutor();
|
||||
const body = { messages: [{ role: "user", content: "hi" }], max_tokens: 1024 };
|
||||
|
||||
Reference in New Issue
Block a user