diff --git a/packages/trae/enterprise.test.mjs b/packages/trae/enterprise.test.mjs index 82000cd..2bf5646 100644 --- a/packages/trae/enterprise.test.mjs +++ b/packages/trae/enterprise.test.mjs @@ -94,6 +94,17 @@ test("a sign-in naming an enterprise Trae CN host keeps it, and requests go ther expect(String(e?.message)).toContain("https://ent-acme.trae.cn/api/agent/v3/llm_utils_chat") }) +// #1127 (shadow1606, a real Trae CN enterprise seat): the console the +// sign-in names answers every llm_utils_chat with 4245, and its list names +// the tenant's configs, which the consumer gateway refuses. Its models and +// chats go to the gateway, which takes the same login; usage stays on the +// console. +test("an enterprise sign-in naming the console itself chats on the consumer gateway", async () => { + expect(CN.apiOf({ api: ENT, host: ENT })).toBe(CN.hosts.api) + expect(CN.apiOf({ api: "https://Console.Enterprise.Trae.CN" })).toBe(CN.hosts.api) + expect(CN.apiOf({ api: "https://ent-acme.trae.cn" })).toBe("https://ent-acme.trae.cn") +}) + test("a personal sign-in is as before", async () => { f = fakeTrae() const got = await signIn({ UserID: "u-1", ScreenName: "Ann", Region: "CN", Host: "https://api.trae.cn" }) diff --git a/packages/trae/index.mjs b/packages/trae/index.mjs index 2f605a5..a285d99 100644 --- a/packages/trae/index.mjs +++ b/packages/trae/index.mjs @@ -99,9 +99,17 @@ const SITES = { "DeepSeek-V4-Flash": { name: "DeepSeek V4 Flash" }, }, // the model host for an account: Trae CN's own hosts serve no models, - // so only a host that is one is taken, else the one gateway + // so only a host that is one is taken, else the one gateway. The + // enterprise console an enterprise (SaaS) sign-in names is not one + // either: a real tenant's seat answered every llm_utils_chat there with + // 4245, for every function and model, as TRAE SOLO chats through an + // agent protocol of its own instead; and the list it gives names the + // tenant's configs, which the gateway turns away (4001). The gateway + // takes the same login, so its models and chats go there, while its + // usage stays the console's (#1127) apiOf: (a) => { const h = traeHost(a?.api) + if (h && new URL(h).hostname.toLowerCase() === SITES["trae-cn"].consoleHost) return SITES["trae-cn"].hosts.api return h && SITES["trae-cn"].modelHost(h) ? h : SITES["trae-cn"].hosts.api }, // whether a host named by a sign-in is one of the model hosts: an https diff --git a/packages/trae/package.json b/packages/trae/package.json index 94fea6b..35b5a27 100644 --- a/packages/trae/package.json +++ b/packages/trae/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-trae-auth", - "version": "0.2.35", + "version": "0.2.36", "description": "OpenCode provider plugins for Trae: Trae CN (trae.cn) and Trae Global (trae.ai), free tier included, with Trae's own browser sign-in", "type": "module", "main": "./opencode.mjs",