trae 0.1.2: the TRAE agent's models (solo_agent) are listed too, so DeepSeek V4.1 Flash shows (yetone/magpie#681)
Trae CN 3.3.104's agent-type map (libai_agent.dylib manifests/mapping.json) files deepseek-v4.1-flash under the "trae" agent only, which is function solo_agent; solo_work_lite (SOLO Work) lists DeepSeek-V4-Flash-Official and the custom_model_deepseek_* ones the issue shows. get_detail_param is now asked for chat_v3, solo_work_lite and solo_agent, merged, and a model is asked through the function that lists it. Not tried with a real account.
This commit is contained in:
@@ -33,9 +33,9 @@ agent's `POST https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat`:
|
||||
- The messages go as `{role, content: [{type: "text", text}]}`.
|
||||
- The model goes as `config_name` and `model`.
|
||||
- The function is the one whose model list has the model (`chat_v3`, the
|
||||
classic IDE's, first; else `solo_work_lite`, SOLO's). If Trae answers
|
||||
4001, 4023 or 1005, the plugin tries the other once and remembers which
|
||||
one worked.
|
||||
classic IDE's, first; else `solo_work_lite`, SOLO's Work mode; else
|
||||
`solo_agent`, the TRAE agent's). If Trae answers 4001, 4023 or 1005,
|
||||
the plugin tries the others once and remembers which one worked.
|
||||
- **Headers:** the IDE's: `Authorization: Cloud-IDE-JWT …`,
|
||||
`X-Cloudide-Token`, `x-app-id`, `x-ide-version`, the device headers and
|
||||
`x-uid`.
|
||||
@@ -56,8 +56,9 @@ agent's `POST https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat`:
|
||||
- Images aren't sent.
|
||||
|
||||
The model list is the account's own, from `/api/ide/v1/get_detail_param`,
|
||||
asked for both functions and put together: SOLO lists models `chat_v3`
|
||||
doesn't (DeepSeek-V4.1-Flash). When neither can be read, the plugin uses the models Trae CN's `chat_v3` is
|
||||
asked for each of those functions and put together: SOLO and the TRAE
|
||||
agent list models `chat_v3` doesn't (deepseek-v4.1-flash is the TRAE
|
||||
agent's, `solo_agent`). When neither can be read, the plugin uses the models Trae CN's `chat_v3` is
|
||||
known to serve: GLM-5.2, GLM-5, Kimi K2.6, Qwen 3.7 Plus, DeepSeek V4 Pro
|
||||
and DeepSeek V4 Flash.
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@ const SIGN_IN_TIMEOUT = 10 * 60 * 1000
|
||||
const EARLY_MS = 2 * 60 * 1000 // a token this close to its end is renewed before a request
|
||||
const LEAD_MS = 10 * 60 * 1000 // and this close, magpie renews it ahead of time (auth.refresh)
|
||||
const DAY = 24 * 3600 * 1000
|
||||
// the IDE's chat functions: the classic IDE's agent, then SOLO's
|
||||
const FUNCTIONS = ["chat_v3", "solo_work_lite"]
|
||||
// the IDE's chat functions: the classic IDE's agent, then SOLO's Work
|
||||
// mode, then the TRAE agent (solo_agent): Trae CN 3.3.104's agent-type map
|
||||
// files its models under "trae", and only that one has deepseek-v4.1-flash
|
||||
const FUNCTIONS = ["chat_v3", "solo_work_lite", "solo_agent"]
|
||||
|
||||
const MODEL = { attachment: false, tool_call: true, reasoning: true, temperature: true, limit: { context: 128_000, output: 32_000 }, modalities: { input: ["text"], output: ["text"] } }
|
||||
// what Trae CN's chat_v3 is known to serve; the live list replaces it
|
||||
@@ -689,7 +691,7 @@ async function openai(req, it) {
|
||||
return new Response(stream, { status: 200, headers: { "content-type": "text/event-stream", "cache-control": "no-cache" } })
|
||||
}
|
||||
|
||||
// a model or function this account's chat_v3 doesn't take: SOLO's may
|
||||
// a model or function this account's chat_v3 doesn't take: another may
|
||||
const wrongFunction = (code) => ["4001", "4023", "1005"].includes(String(code))
|
||||
|
||||
// ---- usage ------------------------------------------------------------------------
|
||||
@@ -828,8 +830,8 @@ export const TraeCNAuthPlugin = async ({ client }) => {
|
||||
}
|
||||
|
||||
// liveModels is the account's model list: every chat function's, since
|
||||
// SOLO lists models the classic IDE's chat_v3 doesn't (DeepSeek-V4.1-Flash
|
||||
// came to SOLO first, yetone/magpie#681); a model listed by one function
|
||||
// SOLO lists models the classic IDE's chat_v3 doesn't (deepseek-v4.1-flash
|
||||
// came to the TRAE agent's first, yetone/magpie#681); a model listed by one function
|
||||
// only is asked through that one. One function's list failing leaves the
|
||||
// others'; all failing is the error.
|
||||
const liveModels = async (a) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-trae-auth",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "OpenCode provider plugin for Trae CN (trae.cn): your Trae CN account's models, free tier included, with Trae's own browser sign-in",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
@@ -58,27 +58,31 @@ test("the config declares the known models; the live list replaces them", async
|
||||
const live = await hooks.provider.models(p, { auth: signedIn() })
|
||||
expect(Object.keys(live)).toEqual(["glm-5.2", "DeepSeek-V4-Pro"])
|
||||
expect(live["glm-5.2"].limit.context).toBe(200000)
|
||||
expect(f.seen.map((r) => r.json.function).sort()).toEqual(["chat_v3", "solo_work_lite"])
|
||||
expect(f.seen.map((r) => r.json.function).sort()).toEqual(["chat_v3", "solo_agent", "solo_work_lite"])
|
||||
})
|
||||
|
||||
test("SOLO's models are listed too, and asked through SOLO's function (yetone/magpie#681)", async () => {
|
||||
test("SOLO's and the TRAE agent's models are listed too, and asked through the function that lists them (yetone/magpie#681)", async () => {
|
||||
f = fakeTrae()
|
||||
f.route("POST /api/ide/v1/get_detail_param", (r) => json({ config_info_list: r.json.function === "chat_v3"
|
||||
? [{ config_name: "glm-5.2", display_name: "GLM-5.2" }, { config_name: "DeepSeek-V4-Flash-Official", display_name: "DeepSeek-V4-Flash-Official" }]
|
||||
: [{ config_name: "glm-5.2", display_name: "GLM-5.2" }, { config_name: "DeepSeek-V4.1-Flash", display_name: "DeepSeek-V4.1-Flash", context_window_size: { max: [1000000] } }] }))
|
||||
const lists = {
|
||||
chat_v3: [{ config_name: "glm-5.2", display_name: "GLM-5.2" }],
|
||||
solo_work_lite: [{ config_name: "glm-5.2", display_name: "GLM-5.2" }, { config_name: "DeepSeek-V4-Flash-Official", display_name: "DeepSeek-V4-Flash-Official" }],
|
||||
solo_agent: [{ config_name: "glm-5.2", display_name: "GLM-5.2" }, { config_name: "deepseek-v4.1-flash", display_name: "DeepSeek V4.1 Flash", context_window_size: { max: [1000000] } }],
|
||||
}
|
||||
f.route("POST /api/ide/v1/get_detail_param", (r) => json({ config_info_list: lists[r.json.function] ?? [] }))
|
||||
f.route("POST /api/agent/v3/llm_utils_chat", (r) => sse([["output", { response: r.json.function }], ["done", {}]]))
|
||||
const hooks = await TraeCNAuthPlugin({ client: {} })
|
||||
const p = await given(hooks)
|
||||
const live = await hooks.provider.models(p, { auth: signedIn() })
|
||||
expect(Object.keys(live)).toEqual(["glm-5.2", "DeepSeek-V4-Flash-Official", "DeepSeek-V4.1-Flash"])
|
||||
expect(live["DeepSeek-V4.1-Flash"].name).toBe("DeepSeek-V4.1-Flash")
|
||||
expect(live["DeepSeek-V4.1-Flash"].limit.context).toBe(1000000)
|
||||
expect(Object.keys(live)).toEqual(["glm-5.2", "DeepSeek-V4-Flash-Official", "deepseek-v4.1-flash"])
|
||||
expect(live["deepseek-v4.1-flash"].name).toBe("DeepSeek V4.1 Flash")
|
||||
expect(live["deepseek-v4.1-flash"].limit.context).toBe(1000000)
|
||||
const opts = await hooks.auth.loader(async () => signedIn())
|
||||
const ask = async (model) => {
|
||||
const res = await opts.fetch(opts.baseURL + "/chat/completions", { method: "POST", body: JSON.stringify({ model, messages: [{ role: "user", content: "hi" }] }) })
|
||||
return (await res.json()).choices[0].message.content
|
||||
}
|
||||
expect(await ask("DeepSeek-V4.1-Flash")).toBe("solo_work_lite")
|
||||
expect(await ask("deepseek-v4.1-flash")).toBe("solo_agent")
|
||||
expect(await ask("DeepSeek-V4-Flash-Official")).toBe("solo_work_lite")
|
||||
expect(await ask("glm-5.2")).toBe("chat_v3")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user