mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-12 09:52:59 +03:00
Compare commits
1 Commits
fix/12702-
...
fix/12196-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdca029cbd |
1
changelog.d/fixes/12196-opencode-go-gpt56luna.md
Normal file
1
changelog.d/fixes/12196-opencode-go-gpt56luna.md
Normal file
@@ -0,0 +1 @@
|
||||
- fix(providers): route opencode-go/gpt-5.6-luna to /responses instead of /chat/completions (#12196)
|
||||
@@ -1 +0,0 @@
|
||||
- fix(oauth): align codebuddy-cn OAuth User-Agent with the chat/usage CLI version to avoid WAF false positives (#12702)
|
||||
@@ -1,4 +1,3 @@
|
||||
import { CODEBUDDY_CN_USER_AGENT } from "@/lib/oauth/constants/oauth";
|
||||
import type { RegistryEntry } from "../../shared.ts";
|
||||
|
||||
/**
|
||||
@@ -21,7 +20,7 @@ export const codebuddy_cnProvider: RegistryEntry = {
|
||||
authType: "oauth",
|
||||
authHeader: "bearer",
|
||||
headers: {
|
||||
"User-Agent": CODEBUDDY_CN_USER_AGENT,
|
||||
"User-Agent": "CLI/2.108.1 CodeBuddy/2.108.1",
|
||||
"X-Product": "SaaS",
|
||||
"X-IDE-Type": "CLI",
|
||||
"X-IDE-Name": "CLI",
|
||||
|
||||
@@ -250,6 +250,16 @@ export const opencode_goProvider: RegistryEntry = {
|
||||
supportedThinkingEfforts: ["none", "low", "high", "max"],
|
||||
targetFormat: "openai-responses",
|
||||
},
|
||||
// #12196: the Go upstream serves this model only on /responses —
|
||||
// /chat/completions 500s for it. github already declares the same model
|
||||
// id with targetFormat:"openai-responses" (see github/index.ts).
|
||||
{
|
||||
id: "gpt-5.6-luna",
|
||||
name: "GPT-5.6 Luna",
|
||||
supportsReasoning: true,
|
||||
targetFormat: "openai-responses",
|
||||
maxOutputTokens: 128000,
|
||||
},
|
||||
// Console Go free GLM-tier model (live-verified 2026-08-23): the upstream
|
||||
// rejects every reasoning_effort outside {low, high, max} whenever tools
|
||||
// are present — "[1210] This model always engages in thinking and cannot
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* packs, "Bonus Pack N" for bonus packs (soonest-expiring first).
|
||||
*/
|
||||
|
||||
import { CODEBUDDY_CN_USER_AGENT } from "@/lib/oauth/constants/oauth";
|
||||
|
||||
const USAGE_URL = "https://copilot.tencent.com/v2/billing/meter/get-user-resource";
|
||||
|
||||
interface TencentAccount {
|
||||
@@ -132,7 +130,7 @@ export async function getCodeBuddyCnUsage(
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"User-Agent": CODEBUDDY_CN_USER_AGENT,
|
||||
"User-Agent": "CLI/2.108.1 CodeBuddy/2.108.1",
|
||||
"X-Product": "SaaS",
|
||||
"X-IDE-Type": "CLI",
|
||||
"X-IDE-Name": "CLI",
|
||||
|
||||
@@ -106,21 +106,12 @@ export const QODER_CONFIG = {
|
||||
// CodeBuddy CN (Tencent — copilot.tencent.com) OAuth Configuration
|
||||
// (Custom Device-Auth Flow: POST stateUrl → open authUrl → GET pollUrl?state=).
|
||||
// No client_id/secret — the upstream CLI ships none.
|
||||
//
|
||||
// CODEBUDDY_CN_USER_AGENT is the single source of truth for the CLI/CodeBuddy version
|
||||
// string. It MUST stay identical across OAuth (this file), chat completions
|
||||
// (open-sse/config/providers/registry/codebuddy-cn/index.ts) and usage/quota
|
||||
// (open-sse/services/usage/codebuddy-cn.ts) — a mismatched version string across a
|
||||
// single account's auth vs. chat calls is exactly the kind of internally-inconsistent
|
||||
// client fingerprint Tencent's WAF flags as anomalous (#12702).
|
||||
export const CODEBUDDY_CN_USER_AGENT = "CLI/2.108.1 CodeBuddy/2.108.1";
|
||||
|
||||
export const CODEBUDDY_CN_CONFIG = {
|
||||
baseUrl: "https://copilot.tencent.com",
|
||||
stateUrl: "https://copilot.tencent.com/v2/plugin/auth/state",
|
||||
tokenUrl: "https://copilot.tencent.com/v2/plugin/auth/token",
|
||||
refreshUrl: "https://copilot.tencent.com/v2/plugin/auth/token/refresh",
|
||||
userAgent: CODEBUDDY_CN_USER_AGENT,
|
||||
userAgent: "CLI/2.63.2 CodeBuddy/2.63.2",
|
||||
platform: "CLI",
|
||||
pollInterval: 5000,
|
||||
};
|
||||
|
||||
@@ -585,38 +585,3 @@ test("codebuddy-cn is treated as a managed dual-auth provider (oauth + apikey ac
|
||||
"codebuddy-cn must be admitted by the dual-auth gate"
|
||||
);
|
||||
});
|
||||
|
||||
test("#12702: codebuddy-cn presents the same CLI/CodeBuddy version across OAuth, chat and usage calls", async () => {
|
||||
// A mismatched version string across a single account's auth vs. chat calls is exactly the
|
||||
// kind of internally-inconsistent client fingerprint Tencent's WAF flags as anomalous
|
||||
// (code 11128 "request illegal" / "blocked by security policy"). All three surfaces must
|
||||
// read from the same CODEBUDDY_CN_USER_AGENT constant so they can never drift apart again.
|
||||
const oauthUserAgent = CODEBUDDY_CN_CONFIG.userAgent;
|
||||
const chatUserAgent = REGISTRY["codebuddy-cn"].headers?.["User-Agent"];
|
||||
assert.equal(
|
||||
oauthUserAgent,
|
||||
chatUserAgent,
|
||||
`codebuddy-cn OAuth User-Agent (${oauthUserAgent}) must match the chat User-Agent (${chatUserAgent})`
|
||||
);
|
||||
|
||||
const { CODEBUDDY_CN_USER_AGENT } = await import("../../src/lib/oauth/constants/oauth.ts");
|
||||
assert.equal(oauthUserAgent, CODEBUDDY_CN_USER_AGENT);
|
||||
|
||||
const origFetch = globalThis.fetch;
|
||||
let capturedUserAgent: string | undefined;
|
||||
globalThis.fetch = (async (_url: unknown, init?: RequestInit) => {
|
||||
capturedUserAgent = (init?.headers as Record<string, string> | undefined)?.["User-Agent"];
|
||||
return new Response(JSON.stringify({}), { status: 200 });
|
||||
}) as typeof fetch;
|
||||
try {
|
||||
const { getCodeBuddyCnUsage } = await import("../../open-sse/services/usage/codebuddy-cn.ts");
|
||||
await getCodeBuddyCnUsage("ACCESS_TOKEN", undefined, undefined);
|
||||
assert.equal(
|
||||
capturedUserAgent,
|
||||
CODEBUDDY_CN_USER_AGENT,
|
||||
"codebuddy-cn usage/quota User-Agent must match the shared constant"
|
||||
);
|
||||
} finally {
|
||||
globalThis.fetch = origFetch;
|
||||
}
|
||||
});
|
||||
|
||||
33
tests/unit/issue-12196-opencode-go-gpt56luna.test.ts
Normal file
33
tests/unit/issue-12196-opencode-go-gpt56luna.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
|
||||
import { resolveOpencodeTargetFormat } from "../../open-sse/executors/opencode.ts";
|
||||
|
||||
// Issue #12196: opencode-go/gpt-5.6-luna is served by the Go upstream ONLY on
|
||||
// /responses — /chat/completions 500s for this model. The github provider
|
||||
// already declares targetFormat:"openai-responses" for the same model id, and
|
||||
// opencode-go already does the same for deepseek-v4-pro/deepseek-v4-flash on
|
||||
// this exact provider — but gpt-5.6-luna itself is missing from the
|
||||
// opencode-go registry, so getModelTargetFormat() falls through to null and
|
||||
// resolveOpencodeTargetFormat() defaults to "openai", which makes
|
||||
// OpencodeExecutor.buildUrl() post to /chat/completions instead of /responses.
|
||||
test("opencode-go/gpt-5.6-luna must resolve to the openai-responses target format", () => {
|
||||
const resolved = resolveOpencodeTargetFormat("opencode-go", "gpt-5.6-luna");
|
||||
assert.equal(
|
||||
resolved,
|
||||
"openai-responses",
|
||||
"opencode-go/gpt-5.6-luna resolved to '" +
|
||||
resolved +
|
||||
"' instead of 'openai-responses' — OpencodeExecutor.buildUrl() will post to " +
|
||||
"/chat/completions, which the Go upstream 500s on for this model (issue #12196)"
|
||||
);
|
||||
});
|
||||
|
||||
// Control: the sibling deepseek-v4-flash entry on the SAME opencode-go
|
||||
// provider already declares targetFormat:"openai-responses" and must keep
|
||||
// working — proves the assertion above isn't failing for an unrelated reason
|
||||
// (e.g. a broken import or alias resolution).
|
||||
test("control: opencode-go/deepseek-v4-flash already resolves to openai-responses", () => {
|
||||
const resolved = resolveOpencodeTargetFormat("opencode-go", "deepseek-v4-flash");
|
||||
assert.equal(resolved, "openai-responses");
|
||||
});
|
||||
Reference in New Issue
Block a user