5b67ff41aa0704efea27c45bb31ea3e8fb0aeffb
17
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3e6a8d0e03 |
trae: a model keeps the name its lists agree on (#62)
Trae's usage page books a request under the name of the list it was served through, and its lists name a model differently: chat_v3 calls deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", where the SOLO lists call it "DeepSeek-V4.1-Flash" (yetone/magpie#681). On 2026-10-09 Trae renamed its official entries — DeepSeek-V4-Flash-Official is "DeepSeek-V4-Flash" now — which left chat_v3 the only list still calling deepseek-v4.1-flash by another's name, so the collision the misnamed test leans on no longer matches and chat_v3's entry won on list order alone: the page then showed "DeepSeek-V4-Flash 正式版" for every request, where Trae's own client, served through a SOLO list, shows "DeepSeek-V4.1-Flash". A model's name is now the one most of its lists give it — the name Trae's own client is served under — and the entry carrying it is preferred for the model's window, reply limit and serving function, as is the Max entry asked for it. deepseek-v4.1-flash goes back to "DeepSeek-V4.1-Flash", a 200K window and a 32K reply limit (was 116K/16K from chat_v3's entry), asked through the SOLO list that names its __dev/__max models. Co-authored-by: 李 <oncwnuKMG1gRkPtw27nJROKWWRUM@git.weixin.qq.com> |
||
|
|
d3711248aa |
trae: one conversation keeps one session_id (#58)
* trae: one conversation keeps one session_id The plugin gave every request a fresh `randomUUID()` for both `request_id` and `session_id` (chatBody), so each request of one agent turn reached Trae as a different session. Trae counts a conversation by the session its requests name: a user send that takes several steps (a tool result sent back, a retry, another function answering) was counted as several conversations, each a row of its own in the usage detail with no conversation under it — which is what showed as "Prompt" where the IDE's own sessions show their title. `session_id` is now the conversation's, as the IDE keeps one per conversation: the session magpie (or OpenCode) names the request by, carried from a new `chat.headers` hook, else the chat's first user message, which every later turn repeats. Nothing is made up when neither names one — a made-up conversation of the request's own is the splitting this ends — and the caller then makes a fresh id per request, as before. The id is salted, so it says nothing of the words it was made from, and keeps the UUID shape `randomUUID()` returned. `request_id` stays the request's own. The title column is not this fix: the IDE's titles are generated by its agent (`session_title_message`) and reported through its hub, which has no call on the path this plugin takes. With the session stable, Trae has one conversation to hang a title on, once it is sent one. * trae: a conversation is named with the account answering it too The id a chat's session_id is made of was the conversation alone, so when magpie failed over, or rotated, between two Trae accounts inside one conversation, both accounts were sent the same session_id — an id the fresh random one before it never linked, and one Trae can read one account's conversation as another's. The account (its uid, else its name) is now part of what the id is made of: conversationID(req, session, who), who being the account already resolved just above the request. The cost, as the comment says: a conversation answered by two accounts is counted as two again, which is what it did before it was named at all. Two tests: two accounts of one conversation (named by magpie's session and by the chat's own first message, and an account named by its name alone) are two conversations to Trae, and one account's two conversations stay two. The first fails with the account left out of the id. --------- Co-authored-by: tearslee <16331052+tearslee@users.noreply.github.com> Co-authored-by: 李 <oncwnuKMG1gRkPtw27nJROKWWRUM@git.weixin.qq.com> |
||
|
|
e2c01edc83 |
trae 0.2.5: a tool call written into the text that can't be read ends the turn as an error, never as the answer (#38) (#46)
#38 (deepseek-v4.1-flash on trae-cn): 64 of 3112 turns came back with the model's text-form <tool_call> block as the answer, no call made, as a 200 with a normal finish, so the gateway had nothing to fail over on. ARNO (trae-cn, Discord) sent two more: a write whose JSON is whole but has no </tool_call> (the stream ended), and a closed write block. ARNO's two replies, as sent (content redacted to xxxx), are read as calls by 0.2.4 too, whole or one character at a time, with the tool declared as write or Write; prose before the block and arguments as an object don't matter. What breaks the closed one is in its content: a written-out analysis with a quote left unescaped ("官方"), a backslash JSON doesn't know (\| \_ C:\Users) or a JSON sample of its own makes JSON.parse fail, and 0.2.4 then printed the block as text. Those are the fixtures here. TextTools now: - reads a block as models get its JSON wrong: every quote escaped ({\"name\":…}, #38's most common shape), unknown backslash escapes doubled, and quotes inside a string escaped unless they end it (a key's before its colon, a value's before closing braces and the end or a comma and the next key); - takes an opener with attributes, <tool_call name="bash"> with <parameter name="k">v</parameter>, and DeepSeek's {"name":"x"}> head with parameters (magpie's paramCall, #917), its values typed by the tool's schema; - when a block is closed but can't be read, or is cut short at the end (JSON not whole, a parameter not closed), returns an error instead of the text: parts() yields it, so a stream ends with the error event and [DONE] and no finish, and a body is a 502; - leaves a <tool_call> in backticks or a code fence, or named in prose with no JSON after it, as text. Not done: #38's fourth point (text on done/response_done events): there is no raw event showing Trae puts text there, and reading it blind could send a whole reply twice. textcall.test.mjs builds from ARNO's literal bytes and #38's repro cases. Against 0.2.4's index.mjs 4 of its 6 tests fail (the two that pass are ARNO's literal replies, which 0.2.4 already reads). HOME=$(mktemp -d) bun test: 870 pass, 0 fail; bun scripts/check.mjs passes. Not tried with a real Trae CN account. |
||
|
|
be58adc8d3 |
trae 0.2.4: a model outside the fallback list is served with capabilities, so magpie reads it as one that reasons (#28)
magpie's host builds a provider's models from the plugin's config first (internal/plugin/host.js: the config's flat fields are spread into capabilities), then lets the provider.models hook replace the list. The hook handed back each model without capabilities, and magpie reads capabilities.reasoning alone for a model a plugin lists, so every model the site's fallback table doesn't have was listed as one that doesn't reason. On Trae CN that was every model but the table's six; on Trae Global every model but its five. A routing group with one of them in it lost reasoning for the whole group (magpie's groups take a member that thinks), and the agent turned thinking off for it. modelOf now gives each model it builds capabilities: the fallback table's own where it has an entry, else MODEL's flat fields (reasoning, temperature, tool_call, the input modalities) with an empty variants, as Trae's request takes no effort or thinking level. The Max twin takes them through the same path. packages/trae/models.test.mjs (5 tests) fails without the change: capabilities.reasoning is undefined for deepseek-v4-flash-0731-max, for the whole list, and for the Max twin; the fallback table's own entry and Trae Global's models pass either way. bun test packages/trae: 79 pass. bun scripts/check.mjs: every package ok. The whole suite has the same 40 failures before and after (Windows-only, other packages). |
||
|
|
c78a7a32d4 |
trae 0.2.3: Trae CN renews the JWT bound to the account's device, so the daily check-in claim isn't answered 9074 (yetone/magpie#808, #821)
mintonight found the cause on #808: a JWT renewed at /cloudide/api/v3/trae/oauth/ExchangeToken carries no device, and Trae CN answers its check-in claim 9074 every time, while the client's own token is let through. Trae CN now renews as its clients do: POST /trae/api/v3/oauth/ExchangeToken with DeviceInfo (the device id, machine id and a per-account ECDSA P-256 public key, PEM) and DeviceProof (the key's ECDSA-SHA256 signature, base64, of POST, the path, ClientID, RefreshToken, Timestamp and Nonce, one to a line), as TRAE SOLO CN (en1oxy7wnw8j9n, SOLO_PC) first, then Trae CN's IDE (ono9krqynydwx5, IDE_PC). That renewal keeps the refresh token. The key pair is made at sign-in, or at the first renewal of an account signed in before, and kept with the sign-in through auth.refresh's fields; a sign-in's token is bound at once. When Trae turns the bound renewal away, the plugin renews at /cloudide/ as before. Since the refresh token can stay the same, a renewal made here is told from the sign-in by its token rather than by the refresh token. Trae Global is unchanged. device.test.mjs is new: 5 of its 6 tests fail on 0.2.2 (the Trae Global one passes on both). No Trae account to test with; mintonight is asked to verify on #808. |
||
|
|
3acb0fc377 |
trae 0.2.1: the daily check-in is sent as Trae CN's IDE sends it, with a client's User-Agent, not Bun's (yetone/magpie#808, whqtian on Discord)
Trae CN's check-in answered magpie with 9074 「当前参与用户太多,请稍后再试」
every time: whqtian's three accounts never got in (the fourth only when
checked in by hand in Trae), Moody-Sin's never did. magpie retried every
30 minutes and got 9074 again. The plugin sent the check-in with Bun's own
User-Agent (Bun/1.x), the chat's headers (x-uid, x-ide-token, versions…)
and {}. Trae CN's IDE 3.3.104 (main.js, read from the official linux
build) sends /trae/api/v2/ug/checkin_credits/status and /claim with only
its Cloud-IDE-JWT and its device (fb: x-device-id, x-device-brand,
x-device-type, x-os-version, x-app-version) through its own client, body
{req_source: 1}; qilimixingkong/trae-checkin found that a check-in without
a real client's User-Agent is taken for a script and answered 9074. A
growth page (/trae/api/v2/ug/…) now goes with those headers, a TRAE SOLO
CN Electron User-Agent and {req_source: 1} for an empty body; Trae's
other pages still go with the chat's headers. 0.1.7 tried the IDE's
headers and body without a User-Agent and was put back in 0.1.9; the
User-Agent is what neither had. No device id is changed to get round a
9074 or a 9095. No Trae CN account was at hand, so it isn't tried
against a real one: api.trae.cn answers the new request without a token
with its usual 1001. checkin.test.mjs checks the body, the IDE's headers,
the User-Agent and none of the chat's (fails on 0.2.0), a body given as
is, and Trae's other pages unchanged; bun test (66) and
bun scripts/check.mjs trae pass.
|
||
|
|
42783f0033 |
trae: one package, two realms — Trae Global folds into packages/trae (#23)
* trae: one package, two realms — Trae Global folds into packages/trae The review asked for this and it is the right shape: the two deployments share one implementation. 86 of the 89 top-level names were already the same code; what differed was a table's worth of values (hosts, client, versions, usage page, fallback models, error codes) and two realm-only branches. A separate copy meant every request, stream and tool-call fix had to be made twice, and it had already drifted (the 0.1.15 Max fix came back as a bug there). packages/trae now holds a SITES table with two entries — trae-cn and trae-global — and makePlugin(site) builds a provider from one. Exported as TraeCNAuthPlugin and TraeGlobalAuthPlugin. The CN values are moved verbatim, not re-derived: same hosts, client id, app id, IDE/client versions, plugin version, brand, functions, fallback models, credits page, and its own check-in pages. The international entry carries what only it has: the second (US) deployment and the region that selects it, the dollar billing's entitlements page, its own model names, and its extra lapse/quota codes (20101, 4011). The CN plugin needs the stream fix too (the review's point), so the AbortController the loader now builds per request, openai()'s abort, and sse()'s finally are in this one implementation for both realms — as is the wrong-function retry releasing the read it leaves behind. fake.mjs takes a realm id, defaulting to CN so every test written before the fold is unchanged. The global tests move to global.test.mjs, plus new ones for what only the international realm does: the US/SG routing of a request and of a saved sign-in, its own error codes and error name, the dollar usage page, and its fallback model list. chatModel gains the picker's invisible-entry filter (paygo/auto twins, search agents) and the config hook names the realm's own provider. The acceptance test: packages/trae/*.test.mjs' 48 CN tests are untouched and green — that is the proof the refactor changed no CN behaviour, with its constants verified line by line against HEAD. bun test: 63 pass (48 CN + 15 global); bun scripts/check.mjs trae: ok. registry.json: one entry, providers [trae-cn, trae-global]. README: both realms, each realm's endpoints, usage page and codes; the verification range stated honestly (CN never run live; Global on one Free SG account, no Pro and no US account). * trae: Trae CN's model lists stay whole; only Global hides is_invisible_to_user The fold filtered is_invisible_to_user for both realms, which took 40 of Trae CN's 76 models out of its list. CN is served as before; Global (a site flag, hidesInvisible) keeps the filter. Also: the unsupported-request error names the realm, and two duplicated/merged comments are tidied. --------- Co-authored-by: yetone <yetoneful@gmail.com> |
||
|
|
436a861e2d | trae 0.1.15: a model's Max is found across the lists that name it (ARNO on magpie's Discord: no deepseek-v4.1-flash-max) — 0.1.14 looked for it only in the entry the model is asked through, which needs both a __max model and a bigger context_window_tokens.max. Trae CN lists deepseek-v4.1-flash in several functions (yetone/magpie#681) whose entries needn't agree: chat_v3 names the __max model, while the SOLO entry it is asked through names only __dev (and that is where the windows are), so no Max was listed. The __max model is now the first any of its entries names (the one asked through first), the windows the first any gives, and the Max is asked through the function that names the __max model. A __max model with no bigger window anywhere is still no Max. 1 new test fails on 0.1.14; bun test (48 pass) and bun scripts/check.mjs trae pass. Not tried with a real Trae CN account (none here). | ||
|
|
4c4e91689e | trae 0.1.14: GLM's own <arg_key>/<arg_value> calls are calls, answer text under unnamed events isn't lost, reasoning written into the text isn't the answer, a failed reply doesn't say stop, and a model's Max context is a model of its own (歧路亡羊 on magpie's Discord) — GLM wrote <tool_call>read<arg_key>path</arg_key><arg_value>a</arg_value></tool_call>, its own template, which wasn't read: the call went to the agent as text. It is now a call (a string argument as written, other types read as JSON, split over events or not), as is a native call whose name holds the whole call (as JSON or in that template). A call to a requested tool named but for case or punctuation (Read) goes on as the request's (read); any other name goes on as written, so the agent can tell the model it doesn't exist. Text under an event named delta, message, content… or none was skipped; it is the answer's now. A {"reasoning_content":"…"} object in the text is reasoning, and reasoning Trae sends again is sent once. done's finish_reason length/max_tokens is length; a reply that fails (an error event, or Trae's stream breaking off) ends with the error and [DONE], not a stop and its usage, and the stream is closed whatever happens (an agent going away stops the read). A config with a __max model and a bigger context_window_tokens.max (deepseek-v4.1-flash: 1M, 64K–128K out) is listed again as <id>-max, "… (Max)", with that window and output; it asks the config's __max model with max_tokens set and user_message_context.model_info.prompt_max_tokens = window − max_tokens. Reasoning effort: Trae's request takes no level, so no variants are listed (as before) and the README says a picked level does nothing. 9 new tests fail on 0.1.13; bun test (46 pass) and bun scripts/check.mjs trae pass. Not tried with a real Trae CN account (none here). | ||
|
|
64c9e6c34c | trae 0.1.9: the daily check-in goes as it did on 0.1.6, with the chat's headers and {} (yetone/magpie#808, Hu9956 on magpie 0.1.880: TraeCN自动签到失效,中午还行来着,更新后就不行了) — 0.1.7 (published 13:12 Beijing on 10-04) sent api.trae.cn's /trae/api/v2/ug/ pages with only the JWT and the device's headers (ugHeaders: no x-uid, x-app-id, x-ide-token, x-machine-id, yet x-app-version still SOLO's 0.1.69) and {req_source:1} (ugBody); Hu9956's check-in, which went through at noon on 0.1.6, has failed since. Both are taken out: the check-in is sent as every other Trae page is (ideHeaders, the body magpie gives), and the test that checks it goes as the account with {} and x-uid is back (it fails on 0.1.8). bun test (30 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae CN account (none here); the reporter's account is the check. | ||
|
|
709e4dc79b | trae 0.1.7: the daily check-in is sent as Trae CN's IDE sends it (Discord, ARNO on magpie v0.1.813: trae-cn的签到功能会失败) — ownRequest sent api.trae.cn's check-in pages with the chat's headers (x-uid, x-app-id, X-Cloudide-Token, x-ide-token, x-machine-id, x-ide-version… as TRAE SOLO CN's ai-agent sends llm_utils_chat) and the body magpie gave ({}). Trae CN 3.3.104's own client (out/main.js, eb()/fb(), from the linux tarball the version API names) posts /trae/api/v2/ug/checkin_credits/status and /claim with {req_source: 1} (2 only for SOLO Lite/enterprise) and only Content-Type, Authorization: Cloud-IDE-JWT and the device's x-device-id, x-device-brand, x-device-type, x-os-version, x-app-version. Pages under /trae/api/v2/ug/ now go with those headers (ugHeaders) and {req_source:1} where none or {} was given (ugBody); Trae's other pages are sent as before. Trae's 9074 (当前参与用户太多) is a device-level risk control that both open-source check-in clients say trips on requests that don't look like the client's; whether that is what ARNO saw is not known (no error text, and no Trae CN account to try with). checkin.test.mjs gains "the check-in is sent as Trae CN's IDE sends it" (body and header set; fails on 0.1.6); bun test (30 pass) and bun scripts/check.mjs trae under a temp HOME pass; the plugin's fetch against the real api.trae.cn with a placeholder token answers 200 code 1001 marked expired, so the route is reached. Not tried with a real Trae CN account. | ||
|
|
2caced14ef | trae 0.1.6: the usage card says Trae CN's credits in the Credits row, as WorkBuddy's, not as an English balance line under it (yetone/magpie#694, Hu9956 on magpie 0.1.784: 积分显示的样式有点不一样 — WorkBuddy's cards read "积分 1,689.01 / 2,400 积分 · 剩余 70.4%", Trae CN's "积分 剩余 60.7%" with "余额 2307.42 of 3800 credits left" in large type below) — usage gave the share alone on its Credits window and the count as a balance string, "<left> of <limit> credits left", which magpie shows as a separate 余额 row (balanceRow, beside windows) in the plugin's own English and number format, and never flips with 已用/剩余. The window now carries the count as WorkBuddy's does (amount = credits used, limit = the packs' total, unit "credits", magpie#659), so magpie's quotaCount writes "2,307.42 / 3,800 积分 · 剩余 60.7%" (or "1,492.58 / 3,800 积分 · 已用 39.3%"; "credits" in English) in the row itself, and the balance is left out; an unlimited account still says "unlimited" as its balance. No magpie change needed: plugin_usage.go already passes a plugin window's amount, limit and unit to the card. usage.test.mjs now expects the window's amount/limit/unit and no balance (fails on 0.1.5); HOME=$(mktemp -d) bun test (465 pass) and bun scripts/check.mjs trae pass. Checked in magpie's Usage page (webkit, zh and en, API faked with the old and new shapes beside WorkBuddy and WorkBuddy AI cards): the Trae CN card's row reads like WorkBuddy's and the 余额 line is gone. Not tried with a real Trae CN account. | ||
|
|
503ad3eed3 | trae 0.1.4: the account's fetch sends Trae CN's own pages on api.trae.cn as the account, for magpie's daily check-in (yetone/magpie#694, Hu9956: TRAE cn 也有每天签到送100积分) — the loader's fetch served chat completions only (400 for anything else), so magpie had no way to ask Trae as a signed-in account. A URL on api.trae.cn under /trae/api/ (ownPage) is now sent as it is, with the IDE's headers (Authorization: Cloud-IDE-JWT, x-device-id, x-uid, x-app-id …; the token renewed first when near its end, as a chat is) and the body given ({} when none), and Trae's answer comes back as it is, X-Magpie-Sign-In expired on a 401 or code 1001, renewed or kept otherwise; any other URL that isn't a chat is still refused. magpie asks POST /trae/api/v2/ug/checkin_credits/status, then /claim, both with {} — the endpoints autumnsentiment/Trae2api-cn (whose protocol this plugin follows) and qilimixingkong/trae-checkin both call; an unauthenticated POST to /status answers 200 {code:1001, enable:false, checked_in:false}, and a made-up sibling path 404s. Code 9095 (this device is in today) is left as Trae's answer: nothing sends another device id to get round it. checkin.test.mjs (status and claim sent as the account and answered as they are; 1001 marks the sign-in; a token near its end renewed first; another path refused with nothing sent); bun test (28 pass) and scripts/check.mjs trae pass. Not run with a real Trae CN account: none was signed in to try with. README gains a Daily check-in section. | ||
|
|
6596a31c84 |
trae 0.1.3: the model lists are asked as TRAE SOLO CN asks them, in one batch, as client 0.1.69 (yetone/magpie#681)
0.1.2 still showed no DeepSeek V4.1 Flash: its lists came from get_detail_param, one function at a time, sent as the Trae CN IDE 3.3.65 (version code 20260401). The reporter's TRAE SOLO CN 0.1.69 (version code 20260917, same app id) asks POST /api/ide/v1/batch_get_detail_param on trae-api-cn.mchost.guru (its ai-agent log, get_model_list -> batch_get_model_detail_param; 290 configs cached), and picks deepseek-v4.1-flash from it; two other open tools that list it (smart-open/TraeWorkAssistant, zhengwuji/Jet-Hub) ask the same batch, as a 0.1.5x SOLO client, and find it under solo_agent with model_name deepseek-v4.1-flash__dev. Now the lists come from batch_get_detail_param (functions chat_v3, solo_work_lite, solo_agent, solo_agent_lite; agent_type "", access_type 0, show_custom_model), with get_detail_param per function when the batch gives none; the model host is told the client is 0.1.69 / 20260917 (x-ide-version, x-app-version and their codes). A model several functions list is asked through the first whose entry names a __dev model, and that model goes as model_name. The IDE's helpers (usage other than chat_completion: summary, fast_apply...), configs switched off and custom-model slots are left out of the list; names come from display_config.display_name, context from context_window_tokens.dev (max is Max mode's), output from the __dev model's max_tokens. usage.test.mjs: the batch test (one ask, its body and version headers, DeepSeek-V4.1-Flash listed with 200000/64000 and asked through solo_agent as deepseek-v4.1-flash__dev) and the signed-out batch test fail on 0.1.2 and pass; bun test (24 pass) and scripts/check.mjs trae pass. Not tried with a real Trae CN account (none here). |
||
|
|
c8ff2c63ab |
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. |
||
|
|
a6ebbc55d8 |
trae 0.1.1: SOLO's models are listed too, and asked through SOLO's function (yetone/magpie#681)
DeepSeek-V4.1-Flash, which Trae CN's SOLO picker offers, was missing from magpie's list: the plugin read the account's models from /api/ide/v1/get_detail_param for chat_v3 (the classic IDE's chat) only, and SOLO's models (the user's list showed DeepSeek-V4-Flash-Official and the custom_model_* entries of chat_v3, no V4.1) come under solo_work_lite. Now the list is asked for every chat function (chat_v3, solo_work_lite) and put together, chat_v3's first; one list failing leaves the other's, a lapsed sign-in still throws. A model only SOLO lists is asked through solo_work_lite first, the 4001/4023/1005 fallback kept. usage.test.mjs "SOLO's models are listed too" fails on 0.1.0 (V4.1 absent) and passes; bun test: 21 pass. Not tried with a real Trae CN account (none signed in here). |
||
|
|
6c048c7fc2 |
trae 0.1.0: Trae CN (trae.cn) accounts, free tier included, with Trae's browser sign-in (experimental; Discord pdzebkbd0701)
Sign-in is trae.cn's authorization page back to a 127.0.0.1 /authorize callback (userJwt + userInfo, or a refresh token exchanged), with a device made at sign-in and kept for the account. ExchangeToken renews the JWT through auth.refresh (refreshLead 10 min, one renewal per refresh token). Requests go to the IDE agent's llm_utils_chat (chat_v3, then solo_work_lite on 4001/4023/1005), its SSE events turned into OpenAI chunks; tools named natively and as <tool_call> blocks. Usage is the entitlement packs' credits. Worked out from wangqi233/trae2api and autumnsentiment/Trae2api-cn; not run against a real account. |