Commit Graph
37 Commits
Author SHA1 Message Date
hspnick 8e479f1171 trae 0.2.20: every chat function's roster is read, and a model's levels are kept (#300)
Every chat function's roster is read, so each model's reasoning levels come from Trae's own config, and a model keeps its levels in magpie and in plain OpenCode (#300, sphuang1030-prog).

- A model in the fallback table keeps the levels its entry names, even though the host hands every model `variants: {}`.
- A variant's value is OpenCode's name (low/high/xhigh); effortOf takes either spelling and sends Trae's (light/high/extra_high), and nothing for a level the model doesn't name.
- The token-keyed record check that never fired is gone; the host's strict refresh reads the list again after a re-sign-in.

Reviewed at 4b968adb: bun test in packages/trae (temp HOME/TMPDIR) 203 pass / 0 fail on bun 1.4.2; bun scripts/check.mjs exit 0. The three new tests go red on the previous head 41904d9. Probes through the loader's fetch: low→light, high→high, xhigh→extra_high; medium/__proto__ send nothing; glm-5.2 fallback gives high, xhigh (was []). merge-tree against main clean; npm latest trae 0.2.19.
Not tried: a real Trae account; OpenCode's own source (whether it fills default variants first).
2026-10-23 09:57:37 +08:00
yetone 26e3e5f91a trae 0.2.19: Qwen's <function=…> and Anthropic's <function_calls><invoke> calls written as text are read as calls
01huadalang (magpie's Discord, trae 0.2.18, dsh, Kimi K3 and MiMo 2.6
Pro, sometimes): tool calls came back as the reply's text. The two
screenshots show the shapes:

  <function=compress><parameter=content>[{"endId": "m03680", …
  <function_calls><invoke name="mcp__magpie-image__generation_result">
  <parameter name="id">image-6636-24</parameter> </invoke> … </function_calls>

Root cause: TextTools only knew <tool_call> blocks (JSON, GLM's
arg_key/arg_value, name-attribute + <parameter>) and DeepSeek's DSML.
Neither shape opens with <tool_call>, so both went through as text; a
Qwen <function=…> inside <tool_call> lost the opener and leaked too.

- TextTools.xmlCall reads <function_calls> around one or more
  <invoke name="…"><parameter name="k">v</parameter></invoke> (each
  invoke a call; closes left off between invokes still split them), and
  Qwen's <function=name><parameter=k>v</parameter></function>, bare or
  in <tool_call>. Values go through paramArgs: text where the tool's
  schema says string, else JSON (compress's content array is an array).
- Only for a tool the request declared (toolNamed's match); an
  undeclared name, no tools at all, a tag in backticks or a code fence,
  or a tag with no parameter and no close stays text. This is stricter
  than <tool_call>, whose block is a call under any name: these tags
  are common in prose about the formats.
- Held back while streaming (MARKS, XML_HOLD), so a tag split across
  chunks never reaches the text; the closes and the wrapper are dropped
  as leftovers after a call. A parameter left open when the stream ends
  is cut short: the turn ends with the error plugins#38 gives, never text.
- README says so.

Sibling: qoder has its own Splitter that reads <function=…> only inside
<tool_call> and neither shape bare; not changed here, filed as
plugins#323. No other package parses text-written calls.

Run at this commit (base origin/main 1b06308), sandbox HOME/TMPDIR:
- packages/trae: bun test, 183 pass 0 fail (20 files; new
  xmlcall.test.mjs, 8 tests). Fixtures are the reporter's literal bytes:
  both samples whole and in pieces of 1/2/3/5/7/13/64, each split in two
  at every offset, sample 1 as shown (cut) and closed, a cut inside the
  second invoke, undeclared tools, prose/backticks/fence mentions, and
  sample 2 through the plugin over the fake Trae streamed and not
  (finish tool_calls, no text).
- bun scripts/check.mjs: 21 packages ok.
- Broken by hand, each red then restored: XML_AT never matching (6 of 8
  red), the declared-tool check removed (undeclared test red), the
  closes dropped from LEFTOVER (samples test red), XML_AT/XML_HOLD left
  out of the stream hold (5 of 8 red).

Not tried: a real Kimi K3 or MiMo 2.6 Pro turn on Trae; dsh's compress
tool schema wasn't found locally, so the test declares content as an
array (a string schema would keep it as text, as declared).
2026-10-23 00:26:05 +08:00
yetone 5ec8377093 trae 0.2.18: native tool turns (#257), a result with no output isn't empty (#251), no tools keeps the text form
Releases #257 (WuJian1421), #260 and #273 (moxuanchen), with three fixes on
top of #257's native tool turns:

- A tool result with no text went out as an empty text part. wangjianjq
  measured on live Trae CN (#251) that Trae then refuses the whole request
  with 4027 ("insufficient tool messages following tool_calls message"),
  for either of two parallel results; " " or "0" passes. An empty result
  now goes as "(no output)", or "(the result's image follows)" when its
  image rides the user turn after the run. Credit wangjianjq (#251).
- A request whose body names no tools (none sent, or tool_choice "none",
  such as a summary) still sends past calls and results as text, as 0.2.17
  did: every live run of the native turns carried the tools in the body.
- A tool result answering no call the history sends goes back as a user
  text turn ("Result of ... (call id)"), not as a tool turn naming no call.
- A Windows APPDATA spelled with other case, separators or a trailing
  separator is the same root as the home's AppData\Roaming (test for #273's
  fix; it fails on 0.2.17's clientStoragePaths).

Run at this commit on origin/main c7a7379: bun test in packages/trae 175
pass 0 fail; bun scripts/check.mjs trae ok. Broken by hand: with the
merged #257 index.mjs, the three new request tests and the image placeholder
test fail (4 of 28 in request+images); with 0.2.17's index.mjs the new
APPDATA case fails. Not tried against a live Trae account (none here); the
live evidence is the PR authors'.
2026-10-20 22:06:55 +08:00
Euraxluo 1d58133eaa trae 0.2.17: Trae CN's daily check-in through the plugin (#178)
Trae CN's daily check-in moves into the plugin as auth.checkin. It asks
/trae/api/v2/ug/checkin_credits/status and then /claim through ownRequest,
so it carries the same JWT renewal, IDE headers, {req_source: 1} body and
16-digit ugDevice (#194) as every other ug page. Trae Global answers
inactive. 9095 on the claim is ineligible, the same as magpie's built-in
traeRefused. 9074 on the claim is an answer for the day: ineligible, with a
hint to check in in the Trae CN app. The built-in calls that own-app, which
the plugin protocol doesn't have. trae 0.2.17.

Run at the reviewed head 4e9bb87 (on top of origin/main 63a3d2a..c397e96):
- bun test packages/trae: 160 pass, 0 fail. The global.test.mjs and
  stream.test.mjs failures the author saw did not reproduce.
- bun scripts/check.mjs trae: ok.
- Broken by hand, one at a time, and each turned native-checkin.test.mjs red:
  9074 mapped to failed; the ugDevice line in ownRequest removed; the
  unreadable-claim guard removed.
- magpie's plugin host (yetone/magpie 85eef5d87 build, sandbox HOME, a copy
  of the package pointed at a fake Trae on 127.0.0.1:18764), via
  `magpie accounts checkin --json`. The results were claimed 100, 9074
  ineligible with the app hint, 9095 ineligible, and checked_in done 100
  with no claim sent. Status and claim both went out with
  x-device-id 2866487253502651 and {"req_source":1}.
2026-10-17 18:06:54 +08:00
yetone 63a3d2aeb9 trae 0.2.16: a Trae CN account checks in on its own device in the client's 16-digit shape (#194)
XcodeFish's A/B on one account (#194): with the same Cloud-IDE-JWT,
headers and body, Trae CN answered a claim 9074 on the plugin's
19-digit x-device-id and took it (code 0, +100) on a 16-digit one.
The IDE's own id is server-issued: Trae's main process registers at
log.snssdk.com/service/2/desktop/device_register (read in Trae.app's
out/main.js, iCubeDeviceRegisterMainService). Real clients keep it as
iCubeAuthInfo://icube-dc:<id>, and the ids seen in #808 and #1705 are
15 or 16 digits.

- A new Trae CN sign-in names a 16-digit device_id. Trae Global keeps
  19 digits, since nothing says its ids are shaped otherwise.
- ugDevice: a check-in from an account the local client isn't signed
  in as goes on the account's own id when that is 15 or 16 digits.
  Otherwise (19 digits, signed in before 0.2.16) it goes on a 16-digit
  id hashed from that account's device id and uid. The id is the same
  on every check-in, never rotated and never another account's. A 9095
  is still the day's answer. Chat pages and the renewal keep the
  device the account signed in with.
- README: the Sign-in and Daily check-in sections say this.

Run:
- bun test packages/trae: 151 pass, 0 fail. Breaking it by hand: with
  the ugDevice line removed, 7 tests fail; with newDevice back to
  digits(19), 4 fail.
- bun scripts/check.mjs: ok.
- magpie's plugin host (origin/main 7660399a1, sandbox HOME), with the
  plugin's web/auth hosts pointed at a local fake:
  - signed in on 0.2.15 (device 9375744633732288271), claim on 19 digits;
  - added 0.2.16 over it: status/claim/claim all went on 2849759837088686,
    and the pay page kept 9375744633732288271;
  - a new 0.2.16 sign-in named 2348824360597085 (16 digits) and used it
    for check-in and chat.
- Not tried against the real api.trae.cn; there are no real accounts
  here. The 16-digit claim being taken is the reporter's measurement.
2026-10-17 15:31:04 +08:00
yetone 9fd59cf6e8 trae 0.2.15: a model Trae's list marks multimodal takes images, and they reach it (#161)
Reported on magpie's Discord (#help): through magpie, Trae CN's doubao
model said it couldn't read images, while in Trae it reads them.

Every model was listed as text-only (MODEL's modalities), and partText
put "[an image, which this model can't see]" in every image's place, so
no image ever reached Trae.

What changed:
- Trae's lists mark each entry `multimodal` true or false
  (config_info_list). A listed model's flag now decides
  capabilities.input.image, attachment and modalities, over a fallback
  entry's word. Doubao-Seed, Kimi K3/K2.6, Qwen 3.7 Plus and MiniMax M3
  are true; GLM-5.x and DeepSeek V4 are false.
- An image sent to a model that takes images goes to llm_utils_chat as
  an OpenAI image_url part ({url}) after the text part. That is the
  shape TRAE's ai-agent carries (LLMRawMultiContent/LLMRawChatImageURL,
  in the ai-agent binary's strings) and what autumnsentiment/Trae2api-cn
  passes llm_utils_chat unchanged.
- A model marked false still gets the placeholder.
- The fallback list marks kimi-k2.6 and qwen-3.7-plus as taking images,
  as Trae's SOLO list does.

The list fixture is two entries of a relay's capture of the SOLO list
(wangqi233/trae2api scripts/_solo-models-clean.json).

Run:
- images.test.mjs: 6 pass on this change; 5 of 6 fail on 0.2.14's
  index.mjs (only the text-only case passes there).
- packages/trae: 146 tests, 0 fail.
- HOME=$(mktemp -d) bun test across the repo: 1616 pass, 0 fail.
- bun scripts/check.mjs: ok.

Not tried: a real Trae account. Magpie's owner has none signed in, so no
real image request was sent to Trae.
2026-10-16 15:41:00 +08:00
yetone 2009f49751 trae 0.2.14: the account Trae CN's own client is signed in as checks in on the client's device, not one the plugin made up (yetone/magpie#1920)
On one account Trae CN's desktop client's claim went through while the
plugin's, on a device id it had made up (digits(19)) with a hard-coded
brand and OS, came back 9074 every day (MiFaZhan on yetone/magpie#808;
aliceh1 on #1920, where Buddy Switch reads the local client). Now, for a
check-in (/trae/api/v2/ug/*) only, the account whose uid matches the
userId of this machine's Trae CN client sends the client's own device id,
the one Trae's device service registered: the digits in the client's
storage.json key iCubeAuthInfo://icube-dc:<id> (seen in real clients'
files, #808 and #1705). x-device-type and x-os-version are this machine's
(Windows' product name, else its build; elsewhere the kernel release),
and no brand is sent, as the client's fb leaves it out with no model.

The uid comes from the client's sign-in envelope
(iCubeAuthInfo://icube.cloudide), plain JSON or the client's fixed
AES-128-CBC codec, read as dingminhua/dsh-connect-trae (MIT) reads it;
only userId is looked at, the client's token is never used. The file is
only read, never written. Every other account keeps its own device; a
missing or unreadable file, one that can't be made out, a failed
integrity check, or zero or several icube-dc keys change nothing. No id
is made up, changed or rotated (the owner's ruling on #1705 stands).

Ran: bun test in packages/trae, 140 pass (11 new in ownclient.test.mjs);
bun scripts/check.mjs trae ok. Broken by hand: matching every account
instead of the client's uid fails "an account the client isn't signed in
as keeps its own device"; not passing the client's device to ugHeaders
fails the two matched-account tests. Tests never read this machine's
client (fake.mjs points ownClient.paths at nothing). Not tried: a real
Trae CN client or account (none here), so whether the claim now goes
through for the matched account is unproven; the Linux paths are guesses.
2026-10-15 16:57:55 +08:00
yetone 98911ae4d4 trae 0.2.13: publish #106 (the call a service left mid-wrapper in a native call's name)
#106 merged as 0.2.12, which main had already published for the cache
fix (4df82ce), so it needs its own version to reach npm. Version bump
only. Ran: bun test in packages/trae, 129 pass.
2026-10-14 18:36:53 +08:00
yetone 4df82ce1b5 trae 0.2.12: what Trae's token_usage says the prompt cache read and wrote reaches magpie (01huadalang on magpie's Discord: K3, 53 calls, every one 0 cache hits)
tokensOf kept only prompt_tokens, completion_tokens and total_tokens of
Trae's token_usage, so every request reached magpie with no cache count
and Usage/Routing showed 0 hits. Trae's event carries more: TRAE SOLO
CN 3.5.20's ai-agent (libai_agent.dylib, the serde field list of
infrastructure/adapter/llm/event.rs's TokenUsageEvent, read from the
binary's __DATA_CONST) is name, prompt_tokens, completion_tokens,
total_tokens, reasoning_tokens, cache_creation_input_tokens,
cache_read_input_tokens, prompt_tokens_total, completion_tokens_total.

cache_read_input_tokens and cache_creation_input_tokens now go on in the
OpenAI usage under those names; magpie's gateway (chat.go cUsage) reads
them beside prompt_tokens as it reads a relay's in front of Claude, and
judges there whether prompt_tokens counts them too. An OpenAI
prompt_tokens_details.cached_tokens, if Trae sends one, is kept as it
came, and reasoning_tokens goes as completion_tokens_details. No cache
count adds no field.

cache.test.mjs (stream and single answer with the TokenUsageEvent's
fields, OpenAI's details, none) fails 3 of 4 on 0.2.11 and passes;
bun test (113 pass) and bun scripts/check.mjs trae under a temp HOME pass.
Not tried with a real Trae account (none here): that Trae fills the
cache fields for K3 in particular is not known.
2026-10-14 17:05:06 +08:00
yetone c3bcb5cdf3 trae 0.2.11: what GLM leaves before </tool_call> is dropped, not sent as the answer, and a call whose JSON closed early is read whole or not at all (magpie#1945)
XcodeFish (trae-cn/glm-5.3-flash under Codex) saw eight texts of their own
beside real calls: ]</tool_call>, </tool_call>, }</tool_call>,
]}]}}"}}}}</tool_call>, }}</tool_call>, "></tool_call>. And an
exec_command's heredoc reached Codex cut wrong.

- After a call's JSON, braces, brackets, quotes, a > and blanks up to the
  close are taken with the close (held while only those have come).
- A close with no call open is dropped with that leftover before it: when
  nothing but blanks came since the start or the last call (the tail of a
  call Trae's service read itself), or when the leftover is right before
  it. A close a sentence names in passing, or one in backticks, stays.
- A call's object that ends early, with other text after it before the
  close, is a quote inside a string left unescaped: the block is read up
  to the close (quoteFix reads the heredoc whole), and when it can't be,
  the turn fails as unreadable, so the gateway can try again, instead of
  a cut command plus the rest as text.

Not reproduced: the issue's cmd that swallowed ","yield_time_ms":180000}.
No mutation of quotes and backslashes in a JSON or string-encoded call
(624 tried) gives it through this parser; it may have come from Trae's own
tool_calls. Asked the reporter for the raw stream.

Run: tailjunk.test.mjs (6 tests, the issue's tails at piece sizes 0/1/3/7,
a native call with its tail split across events, the heredoc) fails 5 of
6 on the old index.mjs; HOME=<tmpdir home> bun test for the repo, 1184
pass 0 fail; bun scripts/check.mjs green.
2026-10-13 15:45:53 +08:00
yetone 7b09c423c8 trae 0.2.10: the sign-in page offers the enterprise (SaaS) sign-in (@shad70w0 on X)
@shad70w0 on X: "magpie + Trae 插件实测没办法走企业订阅" - a Trae enterprise
subscription couldn't be used through this plugin. The sign-in URL sent
hide_saas_login=true (copied from the relays in 6c048c7), which hides the
enterprise/SSO sign-in on www.trae.cn/authorization and
www.trae.ai/authorization, so an enterprise user could only sign in as a
personal account.

What changed:
- the authorization URL sends hide_saas_login=false.
- traeHost: a host a sign-in names is taken only when it is a well-formed
  https host (no port, credentials, query) on trae.cn, trae.ai or
  mchost.guru; anything else is ignored and the consumer host used, as
  before.
- Trae CN: a sign-in host on mchost.guru / trae-api-*, or another trae.cn
  host than www/api/grow*, is the account's model host. Trae Global: a
  trae.ai host other than www/api-*/grow* is too, after the existing
  US/coresg rules. Personal hosts (api.trae.cn, api-us-east, api-sg-central,
  growsg-normal, coresg-normal) route as before.
- the sign-in's host (host), a token host the callback names (authHost /
  auth_host / userInfo.AuthHost, on the realm's own domain only) and the
  userInfo's tenant/enterprise/login-type fields (account; no field that
  looks like a secret) are kept in the auth record. Renewal (sign-in and
  refresh) goes to authHost when one is kept. Nothing new is sent.
- README: enterprise sign-in is offered, not tried with a real enterprise
  account.

Run: bun test in packages/trae (103 pass, 6 new in enterprise.test.mjs);
the whole repo's bun test with HOME under a scratch TMPDIR (1168 pass, 0
fail); bun scripts/check.mjs. Each change broken by hand turns
enterprise.test.mjs red: hide_saas_login back to true, no enterprise CN
host, no domain check, http allowed, refresh at the consumer host, no
account kept, api.trae.cn taken as a model host, a secret-looking field kept.

Not tried: no real enterprise account. Which host(s) and fields an
enterprise sign-in sends back is unknown; the hosts in the tests are made
up, and whether the callback ever names an auth host is a guess.
2026-10-13 11:13:49 +08:00
yetone 0e2a52efdc trae 0.2.9: <toolcall> without the underscore is read as <tool_call>, and a reply that ends inside an opener is cut short, not the answer (#38)
XcodeFish's two leaks on 0.2.6, still on 0.2.8: glm-5.3-flash wrote
<toolcall></toolcall>, and a reply ended at "<tool_call name". Both went
out as the answer with a 200.

- The opener, close, leftovers and held marks take <toolcall> and
  </toolcall> too; an empty block is dropped as <tool_call></tool_call>
  is, one with JSON or parameters is a call, one that can't be read is
  the error it is for <tool_call>.
- At the end of a reply, an opener still open (<tool_call, <tool_call
  name) outside backticks or a fence ends the turn with the cut-short
  error.

Run: the issue's repro (A-G) on main and on this; the new test fails on
the old index.mjs (1 fail) and passes here; HOME=$(mktemp -d) bun test
for the repo, 1153 pass 0 fail; bun scripts/check.mjs green.
2026-10-13 04:40:26 +08:00
yetone d7e7eaf5f8 trae 0.2.8: a tool call's arguments wrapped once more by the model reach the agent bare (bee2an on X)
Asked to write each call as {"name":…,"arguments":{…}}, a model on Trae
sometimes wrote the arguments wrapped again, {"arguments":{…}}, and the
plugin passed that on: bee2an's agent got
{"arguments":{"content":"P\n\n","path":"…/trail2.txt"}} for its write and
wrote nothing useful.

Every call, from a block in the text or from Trae's native tool_calls,
streamed or not, now goes through one step in parts(): a lone arguments,
input, parameters or args key holding an object (or a JSON string of one)
is taken off, up to three layers, when the request's tool has no
parameter of that name. A tool whose own parameter is called input keeps
it, and a call to a tool the request doesn't list is left as it is.

Run: bun test in packages/trae, 96 pass. unwrap.test.mjs uses the
reporter's arguments byte for byte; its three tests fail with the step
stubbed out.
2026-10-10 18:14:24 +08:00
tearsleeand李 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>
2026-10-09 22:32:20 +08:00
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>
2026-10-09 11:48:59 +08:00
yetone 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.
2026-10-08 11:23:03 +08:00
如是 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).
2026-10-06 02:25:35 +08:00
yetone 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.
2026-10-06 01:08:15 +08:00
yetone 82330dfa3f trae 0.2.2: a tool call Trae sends again whole, its punctuation not the partial one's, replaces the partial arguments instead of being appended to them (#24, Zhangwier)
Trae's llm_utils_chat streams a call's arguments as snapshots, and may send
the whole call again written apart from the partial one (U+2212 for -,
U+2032 for '), which neither extends it nor follows a whole one, so
NativeCalls joined the two and the call's arguments came out twice. A
whole JSON object under the same first key as the partial arguments, which
the two joined don't make whole, now replaces them. A piece that is a
JSON value of its own (12, "ls", {}) still joins the call: it doesn't
open with the call's first key. The new test of the resent snapshot fails
without the change; the one of pieces that are values of their own
passes either way. bun test (trae: 68) and bun scripts/check.mjs pass.
2026-10-05 22:01:28 +08:00
yetone 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.
2026-10-05 21:15:36 +08:00
如是andyetone 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>
2026-10-05 17:18:12 +08:00
yetone 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). 2026-10-05 13:10:38 +08:00
yetone 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). 2026-10-05 11:41:17 +08:00
yetone 9d429b8663 trae 0.1.13: a <tool_call> with only DeepSeek's closing tags after it says nothing, and one wrapping DeepSeek's own invoke is the call (magpie#823 again, Dazzle-sys: Trae CN's DeepSeek V4.1 Flash in Pi showed <tool_call> </|DSML|parameter> </|DSML|invoke> </ as its reply) — the reply (17 tokens out) was our opener with no JSON in it, then DeepSeek's closes, cut short. A <tool_call> was read only for a JSON object, so with none it was held to the end and handed on as text, which the agent showed and the model read back. A <tool_call> whose content starts with a tag (or is empty at the end) now has its opener dropped and what follows read as it is: an invoke in it is a call, stray tags are dropped, and a tag cut short at the end (</) after them too. A block holding plain text stays as it was. The new test fails on 0.1.12; bun test (36 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae CN account (none here). 2026-10-05 05:05:53 +08:00
yetone c172d93901 trae 0.1.12: a reply limit Trae doesn't give is none, not a made-up 32K, and a request asking more than Trae's is held to it (ARNO on magpie's Discord: Trae CN's deepseek-v4.1-flash said maxTokens 32000) — a model whose list names no __dev max_tokens (deepseek-v4.1-flash in chat_v3, kimi-k2.6, the fallback list's) was given MODEL's 32_000, which agents were told as its reply limit. It is now 0, which magpie reads as unknown and fills from models.dev (DeepSeek V4.1 Flash's 384K); one Trae gives (glm-5.2__dev's 32000, deepseek-v4.1-flash__dev's 64000 in solo_agent) is kept, and a request asking more than it is sent with Trae's. The new test fails on 0.1.11; bun test (35 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae CN account (none here). 2026-10-05 04:29:12 +08:00
yetone 20cd6f1bb2 trae 0.1.11: a tool call DeepSeek closes with its own tags, or writes as its own invoke, is a call, and its tags don't reach the agent (magpie#823, Dazzle-sys: Trae CN's DeepSeek V4.1 Flash in a group, in Pi, ended the session) — DeepSeek V4.1 Flash wrote <tool_call>{"name":"bash",…}</|DSML|parameter></|DSML|invoke, closing our block with its own tags rather than </tool_call>, or its own <|DSML|invoke name="…"> with <|DSML|parameter>s: neither was read, so the call went to the agent as text. A <tool_call> block is now taken once its JSON object is whole, whatever closes it; DSML invokes (full-width or plain bars, in function_calls or not, several in a row) are calls, a string="true" parameter its text and any other its JSON; the tags and blanks left around a call are dropped, a stray tag too. The new test fails on 0.1.10; bun test (34 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae CN account (none here). 2026-10-05 03:23:58 +08:00
yetone 32aaeda5a6 trae 0.1.10: a tool call written as a tagged block with a file's content raw, or with its arguments beside the name, goes on whole, and an argument piece that names no call joins the one being written (magpie#799, mintonight: pi's write went out as {} and was refused, the turn ended mid-sentence; earlier <tool_call> blocks showed up as text) — a model writing a file through <tool_call>{"name":"write","arguments":{"content":"…"}}</tool_call> puts real newlines and tabs in the JSON string, which JSON.parse refuses: the block went to the agent as text, and a call parsed with nothing under arguments went as {}. Blocks are now read leniently (raw control characters inside strings taken as escaped), a block that gives its arguments beside the name has them taken, and a string of arguments is normalised. Native calls: a piece with neither id nor name (or an index its call's first event didn't give) joins the call still being written instead of being dropped, and arguments still not JSON at the end are read the same lenient way. Three tests fail on 0.1.9; bun test (33 pass) and bun scripts/check.mjs trae under a temp HOME pass. Not tried with a real Trae CN account (none here). 2026-10-05 02:11:07 +08:00
yetone 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. 2026-10-05 00:34:11 +08:00
yetone b14b4d80c5 trae 0.1.8: a tool call Trae streams over several events goes on whole, not as its first event (magpie#799, mintonight: Trae CN models fail many tool calls — bash got echo "T, read got C:/Users/j, edit got {}) — Trae sends a native tool call in several output events under one id or index, each carrying the arguments so far or only the new piece; the plugin sent the first event of each id on and dropped the rest as repeats, so a call whose arguments came in more than one piece reached the agent cut short. NativeCalls now puts each call together across events (arguments that start with what came before replace it, a piece is appended, a repeat is ignored, a piece without a name joins its call by index) and sends the calls once the answer is whole. A test streaming one call cumulatively and one in pieces fails on 0.1.7; bun test (32 pass) and bun scripts/check.mjs trae pass. 2026-10-05 00:02:33 +08:00
yetone 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. 2026-10-04 13:12:51 +08:00
yetone 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. 2026-10-04 13:07:10 +08:00
yetone d2449d53e6 trae 0.1.5: a model chat_v3 gives another model's name is named and asked as SOLO lists it (yetone/magpie#681, ChenstarMr: Trae's usage page booked magpie's DeepSeek V4.1 Flash as "DeepSeek-V4-Flash 正式版") — Trae CN's chat_v3 list names deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", the name it gives DeepSeek-V4-Flash-Official too, while solo_work_lite, solo_agent and solo_agent_lite name it DeepSeek-V4.1-Flash (the reporter's batch_get_detail_param answer). Both entries name the same upstream model, deepseek-v4.1-flash__dev, so the request reached V4.1 Flash, but the list showed two models with one name, and Trae's usage page booked the request under chat_v3's name (TraeCode), where SOLO's request was booked as DeepSeek-V4.1-Flash (TraeWork). liveModels now marks an entry misnamed when another model in the same list has its name and another list names it otherwise, and takes for each model the first function whose entry names a __dev model and isn't misnamed (else the first naming a __dev model, else the first, as before): deepseek-v4.1-flash is named DeepSeek-V4.1-Flash and asked through solo_work_lite with deepseek-v4.1-flash__dev, while DeepSeek-V4-Flash-Official, named alike everywhere, stays on chat_v3. usage.test.mjs gains the reporter's shape; it fails on 0.1.4 and passes; bun test (29 pass) and bun scripts/check.mjs trae pass. Not tried with a real Trae CN account (none here). 2026-10-04 10:26:56 +08:00
yetone 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. 2026-10-04 03:44:28 +08:00
yetone 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).
2026-10-04 01:13:59 +08:00
yetone 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.
2026-10-03 22:30:10 +08:00
yetone 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).
2026-10-03 21:17:55 +08:00
yetone 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.
2026-10-03 14:34:31 +08:00