feat(opencode-go): complete Go catalog (40 models) with auto-fetch + family endpoint regex
- Add 12 missing models from live /zen/go/v1/models (glm-5, kimi-k2.5, mimo v2/v2.6 line, qwen3.5-plus, grok-4.5/4.7, omen-alpha, ...) - modelsFetcher + passthroughModels + "opencode-go" suggested-models filter - Family regex fallback (opencodeFamilyFormats) keeps unknown/passthrough ids on the right endpoint lane (/responses, /messages, /chat/completions); curated registry entries always win - isResponsesModel now routes passthrough grok/gpt ids to /responses Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -3,10 +3,13 @@ import REGISTRY from "../providers/registry/index.js";
|
||||
// PROVIDER_MODELS now built from providers/registry (transport + models co-located)
|
||||
import { PROVIDER_MODELS } from "../providers/index.js";
|
||||
import { modelQuotaFamily, modelStrip, modelTargetFormat, modelSupportedFormats, normalizeModelId } from "../providers/models/schema.js";
|
||||
import { CODEX_REVIEW_SUFFIX, isMuseSparkModel } from "../providers/models/helpers.js";
|
||||
import { CODEX_REVIEW_SUFFIX, isMuseSparkModel, opencodeFamilyFormats } from "../providers/models/helpers.js";
|
||||
import { FORMATS } from "../translator/formats.js";
|
||||
export { PROVIDER_MODELS };
|
||||
|
||||
// OpenCode providers sharing the endpoint-family fallback for unknown model ids
|
||||
const isOpenCodeAlias = (aliasOrId) => !aliasOrId || ["oc", "opencode", "ocg", "opencode-go", "ocz", "opencode-zen"].includes(aliasOrId);
|
||||
|
||||
|
||||
// Helper functions
|
||||
export function getProviderModels(aliasOrId) {
|
||||
@@ -53,20 +56,29 @@ export function findModelName(aliasOrId, modelId) {
|
||||
}
|
||||
|
||||
export function getModelTargetFormat(aliasOrId, modelId) {
|
||||
if ((!aliasOrId || aliasOrId === "oc" || aliasOrId === "opencode" || aliasOrId === "ocg" || aliasOrId === "opencode-go" || aliasOrId === "ocz" || aliasOrId === "opencode-zen") && isMuseSparkModel(modelId)) {
|
||||
if (isOpenCodeAlias(aliasOrId) && isMuseSparkModel(modelId)) {
|
||||
return FORMATS.OPENAI_RESPONSES;
|
||||
}
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
return modelTargetFormat(findModel(models, modelId, aliasOrId));
|
||||
const found = findModel(models, modelId, aliasOrId);
|
||||
if (found) return modelTargetFormat(found);
|
||||
// Family fallback keeps modelsFetcher/passthrough ids on their endpoint lane
|
||||
if (isOpenCodeAlias(aliasOrId)) return opencodeFamilyFormats(modelId)?.targetFormat || null;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Declared upstream formats for a model (registry `supportedFormats`). Drives the
|
||||
// per-model guard on the sourceFormat-matched transport; null when undeclared.
|
||||
// Unknown OpenCode ids fall back to the family regex (chat lane by default) so
|
||||
// auto-fetched models never wrongly use the sourceFormat-matched transport.
|
||||
export function getModelSupportedFormats(aliasOrId, modelId) {
|
||||
const models = PROVIDER_MODELS[aliasOrId];
|
||||
if (!models) return null;
|
||||
return modelSupportedFormats(findModel(models, modelId, aliasOrId));
|
||||
const found = findModel(models, modelId, aliasOrId);
|
||||
if (found) return modelSupportedFormats(found);
|
||||
if (isOpenCodeAlias(aliasOrId)) return opencodeFamilyFormats(modelId)?.supportedFormats || [FORMATS.OPENAI];
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getModelType(aliasOrId, modelId) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import crypto from "node:crypto";
|
||||
import { DefaultExecutor } from "./default.js";
|
||||
import { resolveSessionId } from "../utils/sessionManager.js";
|
||||
import { modelTargetFormat } from "../providers/models/schema.js";
|
||||
import { getProviderModels } from "../config/providerModels.js";
|
||||
import { getModelTargetFormat } from "../config/providerModels.js";
|
||||
import { FORMATS } from "../translator/formats.js";
|
||||
import {
|
||||
normalizeResponsesInput,
|
||||
clampResponsesCallId,
|
||||
@@ -41,16 +41,10 @@ function translatedSession(sessionId, clientTool) {
|
||||
return `ses_${digest}`;
|
||||
}
|
||||
|
||||
// Strip the thinking suffix "model(level)" so checks hit the base id.
|
||||
function baseModelId(model) {
|
||||
return String(model || "").replace(/\([^()]+\)\s*$/, "").trim();
|
||||
}
|
||||
|
||||
// Responses-only per the provider registry (grok-4.6, gpt-5.6-luna, muse-spark, …).
|
||||
// Reading the registry keeps this in sync with config — never hardcode model ids here.
|
||||
// Responses-only per the provider registry (grok-4.6, gpt-5.6-luna, muse-spark, …),
|
||||
// including the family-regex fallback for passthrough ids — never hardcode model ids here.
|
||||
function isResponsesModel(model) {
|
||||
const entry = getProviderModels("opencode-go").find((m) => m.id === baseModelId(model));
|
||||
return modelTargetFormat(entry) === "openai-responses";
|
||||
return getModelTargetFormat("opencode-go", model) === FORMATS.OPENAI_RESPONSES;
|
||||
}
|
||||
|
||||
// Flatten Chat Completions tool declarations into the Responses flat shape and
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { FORMATS } from "../../translator/formats.js";
|
||||
|
||||
// Codex auto-generates a "-review" variant for each llm model (review quota family)
|
||||
export const CODEX_REVIEW_SUFFIX = "-review";
|
||||
|
||||
@@ -25,3 +27,20 @@ export function isMuseSparkModel(modelId) {
|
||||
const base = clean.includes("/") ? clean.split("/").pop() : clean;
|
||||
return /^muse[-_]?spark(?:$|[-_:.\s])/i.test(base);
|
||||
}
|
||||
|
||||
// Endpoint families for OpenCode models outside the curated registry (modelsFetcher /
|
||||
// passthrough ids) — regex keeps auto-fetched models on the right endpoint:
|
||||
// /responses (gpt/grok/muse-spark), /messages (minimax/qwen), /chat/completions (rest).
|
||||
// Curated registry entries always win; this is the unknown-id fallback only.
|
||||
const OPENCODE_FAMILIES = [
|
||||
{ match: /^(grok|gpt|muse[-_]?spark)/i, supportedFormats: [FORMATS.OPENAI_RESPONSES], targetFormat: FORMATS.OPENAI_RESPONSES },
|
||||
{ match: /^deepseek-v4-(pro|flash)/, supportedFormats: [FORMATS.OPENAI, FORMATS.CLAUDE, FORMATS.OPENAI_RESPONSES] },
|
||||
{ match: /^(minimax|qwen)/, supportedFormats: [FORMATS.OPENAI, FORMATS.CLAUDE] },
|
||||
{ match: /^claude-/i, supportedFormats: [FORMATS.CLAUDE] },
|
||||
];
|
||||
|
||||
export function opencodeFamilyFormats(modelId) {
|
||||
if (!modelId || typeof modelId !== "string") return null;
|
||||
const base = modelId.replace(/\([^()]+\)\s*$/, "").trim();
|
||||
return OPENCODE_FAMILIES.find((f) => f.match.test(base)) || null;
|
||||
}
|
||||
|
||||
@@ -35,20 +35,27 @@ export default {
|
||||
],
|
||||
// supportedFormats follow the endpoint table in https://opencode.ai/docs/go/
|
||||
models: [
|
||||
{ id: "deepseek-flash", name: "DeepSeek V4.1 Flash", supportedFormats: ["openai"] },
|
||||
{ id: "deepseek-flash", name: "DeepSeek Flash", supportedFormats: ["openai"] },
|
||||
{ id: "glm-5.3-flash", name: "GLM 5.3 Flash (Vision)", supportedFormats: ["openai"] },
|
||||
{ id: "glm-5.3", name: "GLM 5.3", supportedFormats: ["openai"] },
|
||||
{ id: "glm-5.2", name: "GLM 5.2", supportedFormats: ["openai"] },
|
||||
{ id: "glm-5.1", name: "GLM 5.1", supportedFormats: ["openai"] },
|
||||
{ id: "glm-5", name: "GLM 5", supportedFormats: ["openai"] },
|
||||
{ id: "kimi-k2.7-code", name: "Kimi K2.7 Code", supportedFormats: ["openai"] },
|
||||
{ id: "kimi-k2.6", name: "Kimi K2.6", supportedFormats: ["openai"] },
|
||||
{ id: "kimi-k2.5", name: "Kimi K2.5", supportedFormats: ["openai"] },
|
||||
{ id: "kimi-k3", name: "Kimi K3", supportedFormats: ["openai"] },
|
||||
{ id: "deepseek-v4-pro", name: "DeepSeek V4 Pro", supportedFormats: ["openai", "claude", "openai-responses"] },
|
||||
{ id: "deepseek-v4-flash", name: "DeepSeek V4 Flash", supportedFormats: ["openai", "claude", "openai-responses"] },
|
||||
{ id: "deepseek-v4-flash-vision-exp", name: "DeepSeek V4 Flash Vision (Exp)", supportedFormats: ["openai", "claude", "openai-responses"] },
|
||||
{ id: "deepseek-v4.1-flash", name: "DeepSeek V4.1 Flash", supportedFormats: ["openai"] },
|
||||
{ id: "longcat-2.0", name: "LongCat 2.0", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2.6-flash", name: "MiMo V2.6 Flash", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2.6-pro", name: "MiMo V2.6 Pro", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2.5", name: "MiMo V2.5", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2.5-pro", name: "MiMo V2.5 Pro", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2-pro", name: "MiMo V2 Pro", supportedFormats: ["openai"] },
|
||||
{ id: "mimo-v2-omni", name: "MiMo V2 Omni", supportedFormats: ["openai"] },
|
||||
{ id: "minimax-m3", name: "MiniMax M3", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "minimax-m2.7", name: "MiniMax M2.7", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "minimax-m2.5", name: "MiniMax M2.5", supportedFormats: ["openai", "claude"] },
|
||||
@@ -57,15 +64,25 @@ export default {
|
||||
{ id: "qwen3.7-max", name: "Qwen 3.7 Max", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "qwen3.7-plus", name: "Qwen 3.7 Plus", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "qwen3.6-plus", name: "Qwen 3.6 Plus", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "qwen3.5-plus", name: "Qwen 3.5 Plus", supportedFormats: ["openai", "claude"] },
|
||||
{ id: "hy4-preview", name: "Hy4 Preview", supportedFormats: ["openai"] },
|
||||
{ id: "hy3", name: "Hy3", supportedFormats: ["openai"] },
|
||||
{ id: "hy3-preview", name: "Hy3 Preview", supportedFormats: ["openai"] },
|
||||
// In /zen/go/v1/models but absent from the docs endpoint table — chat lane is the fallback guess
|
||||
{ id: "omen-alpha", name: "Omen Alpha", supportedFormats: ["openai"] },
|
||||
// Served by /zen/go/v1/responses only — the responses-only entry forces chatCore
|
||||
// past the sourceFormat-matched transports into translation (see chatCore guard).
|
||||
{ id: "grok-4.7", name: "Grok 4.7", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "grok-4.6", name: "Grok 4.6", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "grok-4.5", name: "Grok 4.5", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "gpt-5.6-luna", name: "GPT 5.6 Luna", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "muse-spark-1.2-contributor", name: "Muse Spark 1.2 Contributor", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
{ id: "muse-spark-1.3-contributor", name: "Muse Spark 1.3 Contributor", targetFormat: "openai-responses", supportedFormats: ["openai-responses"] },
|
||||
],
|
||||
// Live catalogue; ids outside this curated list get their endpoint lane from the
|
||||
// family regex in providers/models/helpers.js (opencodeFamilyFormats).
|
||||
modelsFetcher: { url: "https://opencode.ai/zen/go/v1/models", type: "opencode-go" },
|
||||
passthroughModels: true,
|
||||
features: {
|
||||
usage: true,
|
||||
usageApikey: true,
|
||||
|
||||
@@ -21,6 +21,13 @@ export const FILTERS = {
|
||||
.filter((m) => (m.id?.endsWith("-free") || KNOWN_FREE_OPENCODE_MODELS.includes(m.id)) && !DEAD_FREE_OPENCODE_MODELS.has(m.id))
|
||||
.map((m) => ({ id: m.id, name: m.id })),
|
||||
|
||||
// Go subscription catalogue — every /models id is selectable; the endpoint lane
|
||||
// per model is resolved by the family regex (see open-sse/providers/models/helpers.js)
|
||||
"opencode-go": (models) =>
|
||||
(Array.isArray(models) ? models : [])
|
||||
.filter((m) => typeof m?.id === "string")
|
||||
.map((m) => ({ id: m.id, name: m.id })),
|
||||
|
||||
// models.dev returns a large catalog; keep only mimo models
|
||||
"mimo-free": (models) =>
|
||||
(Array.isArray(models) ? models : [])
|
||||
|
||||
@@ -4,11 +4,12 @@ import { PROVIDERS } from "../../open-sse/config/providers.js";
|
||||
import { resolveTransport } from "../../open-sse/services/provider.js";
|
||||
|
||||
// Chat-only models (no /messages, no /responses support on opencode-go)
|
||||
const CHAT_ONLY = ["glm-5.3", "glm-5.2", "glm-5.1", "kimi-k2.7-code", "kimi-k2.6", "kimi-k3",
|
||||
"deepseek-flash", "longcat-2.0", "mimo-v2.5", "mimo-v2.5-pro", "hy4-preview", "hy3"];
|
||||
const CHAT_ONLY = ["glm-5.3", "glm-5.2", "glm-5.1", "glm-5", "kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "kimi-k3",
|
||||
"deepseek-flash", "deepseek-v4.1-flash", "longcat-2.0", "mimo-v2.6-flash", "mimo-v2.6-pro",
|
||||
"mimo-v2.5", "mimo-v2.5-pro", "mimo-v2-pro", "mimo-v2-omni", "hy4-preview", "hy3", "hy3-preview", "omen-alpha"];
|
||||
// Models that also expose the Anthropic /messages endpoint
|
||||
const CLAUDE_CAPABLE = ["minimax-m3", "minimax-m2.7", "minimax-m2.5",
|
||||
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus"];
|
||||
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus", "qwen3.5-plus"];
|
||||
// Models that also expose the OpenAI /responses endpoint
|
||||
const RESPONSES_CAPABLE = ["deepseek-v4-pro", "deepseek-v4-flash"];
|
||||
|
||||
@@ -25,18 +26,42 @@ describe("OpenCode Go model catalog", () => {
|
||||
const ids = (PROVIDER_MODELS["opencode-go"] || []).map((m) => m.id);
|
||||
expect(ids).toEqual([
|
||||
"deepseek-flash",
|
||||
"glm-5.3-flash", "glm-5.3", "glm-5.2", "glm-5.1", "kimi-k2.7-code", "kimi-k2.6", "kimi-k3",
|
||||
"deepseek-v4-pro", "deepseek-v4-flash", "deepseek-v4-flash-vision-exp",
|
||||
"longcat-2.0", "mimo-v2.5", "mimo-v2.5-pro",
|
||||
"glm-5.3-flash", "glm-5.3", "glm-5.2", "glm-5.1", "glm-5", "kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "kimi-k3",
|
||||
"deepseek-v4-pro", "deepseek-v4-flash", "deepseek-v4-flash-vision-exp", "deepseek-v4.1-flash",
|
||||
"longcat-2.0", "mimo-v2.6-flash", "mimo-v2.6-pro", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2-pro", "mimo-v2-omni",
|
||||
"minimax-m3", "minimax-m2.7", "minimax-m2.5",
|
||||
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus",
|
||||
"hy4-preview", "hy3",
|
||||
"grok-4.6", "gpt-5.6-luna",
|
||||
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus", "qwen3.5-plus",
|
||||
"hy4-preview", "hy3", "hy3-preview", "omen-alpha",
|
||||
"grok-4.7", "grok-4.6", "grok-4.5", "gpt-5.6-luna",
|
||||
"muse-spark-1.2-contributor", "muse-spark-1.3-contributor",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("OpenCode Go family fallback (unknown/passthrough ids)", () => {
|
||||
it("routes unknown grok/gpt ids to the responses lane", () => {
|
||||
expect(getModelSupportedFormats("opencode-go", "grok-4.8")).toEqual(["openai-responses"]);
|
||||
expect(getModelTargetFormat("opencode-go", "gpt-6-foo")).toBe("openai-responses");
|
||||
});
|
||||
|
||||
it("gives unknown chat-family ids the chat-only lane, never /messages", () => {
|
||||
for (const m of ["kimi-k4", "glm-6", "mimo-v3", "omen-beta"]) {
|
||||
expect(getModelSupportedFormats("opencode-go", m)).toEqual(["openai"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps unknown minimax/qwen ids on the /messages lane too", () => {
|
||||
for (const m of ["minimax-m9", "qwen4-max"]) {
|
||||
expect(getModelSupportedFormats("opencode-go", m)).toEqual(["openai", "claude"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("curated entries win over the family regex", () => {
|
||||
expect(getModelSupportedFormats("opencode-go", "deepseek-v4.1-flash")).toEqual(["openai"]);
|
||||
expect(getModelSupportedFormats("opencode-go", "deepseek-v4-pro")).toEqual(["openai", "claude", "openai-responses"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("OpenCode Go thinking-suffix model lookup", () => {
|
||||
it("preserves Responses routing for gpt-5.6-luna thinking variants", () => {
|
||||
expect(getModelSupportedFormats("opencode-go", "gpt-5.6-luna(high)")).toEqual(["openai-responses"]);
|
||||
@@ -108,7 +133,7 @@ describe("OpenCode Go per-model transport guard (chatCore logic)", () => {
|
||||
});
|
||||
|
||||
it("routes Muse Spark (responses-only) to /responses, never to /messages", () => {
|
||||
for (const m of ["muse-spark-1.2-contributor", "muse-spark-1.3-contributor", "grok-4.6", "gpt-5.6-luna"]) {
|
||||
for (const m of ["muse-spark-1.2-contributor", "muse-spark-1.3-contributor", "grok-4.7", "grok-4.6", "grok-4.5", "gpt-5.6-luna"]) {
|
||||
expect(getModelSupportedFormats("opencode-go", m)).toEqual(["openai-responses"]);
|
||||
expect(pickTransport("opencode-go", "openai-responses", "opencode-go", m)?.baseUrl).toBe("https://opencode.ai/zen/go/v1/responses");
|
||||
expect(pickTransport("opencode-go", "claude", "opencode-go", m)).toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user