trae: an enterprise sign-in naming the console chats on the consumer gateway (#1127)
shadow1606's real Trae CN enterprise (SaaS) seat named
console.enterprise.trae.cn as its model host. There, every
/api/agent/v3/llm_utils_chat answered {"code":4245}, for every function
and model: TRAE SOLO chats through create_agent_task/workflow with
encrypted bodies instead. The list the console gives names the tenant's
configs, which the consumer gateway then refuses (4001). The consumer
gateway takes the same login, and the reporter verified full completions
by pointing `api` at it. That is now what apiOf does for the console host
itself. The account's usage stays on the console (`host`, seat pool in
yuan), as before. Chats there count against the login's consumer
Credits, not the seat pool; that is said on the issue.
Not changed: any other trae.cn tenant host a sign-in names (ent-acme in
the tests) is still taken as the model host, as no real account shows
otherwise. Trae Global's console.enterprise.trae.ai is not measured. Its
issue was filed with this commit.
Run (WSL, bun 1.4.2, HOME=$(mktemp -d)): packages/trae bun test 266
pass 0 fail; scripts/check.mjs trae ok. Broken by hand: without the
console line, the new enterprise test fails (19 pass 1 fail).
Not tried: a real enterprise account (no seat here); the reporter's run
is the end-to-end evidence.
This commit is contained in:
@@ -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" })
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user