Commit Graph
64 Commits
Author SHA1 Message Date
qiuhao-wang001andqiuhao-wang001 907847bdf5 trae 0.2.34: an enterprise account's usage is its console's seat pool (#1040)
An enterprise Trae CN sign-in names console.enterprise.trae.cn. For such an account, the usage card now reads the console's seat pool:
- the limit is seat_pool_currency_quota, where 9999999999 means unlimited;
- the spend is this seat's total_cost_currency from get_user_model_usage;
- the reset date is get_personal_core_data's ResetTime.

The consumer credits row stays beside it, marked aside, so magpie does not route on it. If the spend can't be read, the card shows "? / ¥800.00" with no share; it never reads as ¥0. The Trae Global console path is unverified: a refusal there is an error card and keeps the sign-in.

Run at b96d0e58 (mote, temp HOME, fake server only):
- bun test in packages/trae: 262 pass, 0 fail.
- bun scripts/check.mjs: exit 0.
- git merge-tree against origin/main 3632d53b: clean.
- 15 probe cases, among them a spend read failing with 500, 401, an error code, a list under data, and the seat's own row missing.

Broken by hand, one at a time: 10 changes. All but the error label turned a test red: the unknown spend, Global's sign-in being kept, CN's console 401, own-seat summing, a null pool, and whenOf reset times.

Not tried: a real Trae account, the real console, and the GUI card.

Co-authored-by: qiuhao-wang001 <qiuhao-wang001@users.noreply.github.com>
2026-11-12 14:32:29 +08:00
yetone 065758f58b trae 0.2.33: a model whose top level is extra_high reaches max, sent as extra_high
@avalongarden6 on X (11-09, with screenshots): TRAE CN's app offers
DeepSeek-V4.1-Flash, GLM-5.3 and Kimi-K3 思考强度 轻/高/极高, and 极高 is
the model's maximum. magpie ranged the Trae CN member of a routing group
低–很高 (low–xhigh) while WorkBuddy, Qoder and WENMAI members ranged
…–最高 (max). magpie offers a group the levels its members share
(buildGroupEntries in internal/provider/group.go), so with Trae CN in it
the group lost max for every member.

A list entry whose top level is extra_high and that names no max of its
own is now offered max beside low/high/xhigh (offered, in variantsOf), and
effortOf sends max as extra_high, as it sends xhigh. magpie reads the
variants' keys as the model's Efforts (internal/provider/plugins.go), so
the member ranges 低–最高 (effortSpan in app.js) and a group set to max
fits max to the member's own levels (fitFor, catalog.NearestEffort), finds
it, and the plugin sends Trae extra_high. An entry that names Trae's own
max keeps it: max is max, extra_high is xhigh. A model topping lower
(light/high) is offered no max and sent none for it, as before.

Trae has no mover in magpie (no trae in internal/provider/migrate*.go), so
no min is raised.

Run on mote: packages/trae bun test with HOME under a temp dir, 246 pass
0 fail; bun scripts/check.mjs trae ok (registry ok).
Broken by hand: without effortOf's max -> extra_high line, 4 reasoning
tests go red (the #434 chatBody case, the variant round trip, the new
max/xhigh mapping test and the fetch-level max test); with variantsOf
offering the entry's own levels only, 4 go red (the variant lists and the
new test).
Not tried: a real TRAE CN account (no request with extra_high from max
was sent to Trae itself), nor a magpie routing group end to end; the
range and the group's max are read from magpie's code, not seen in its
GUI. A user who ticked a Trae model's levels by hand in magpie keeps that
list, without max, until they tick it.
2026-11-09 14:51:21 +08:00
我是一条没有名字的区 087c36123d inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator):

- Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all.
  - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none.
  - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal.
- The body rewrite strips the reasoning fields and sets image detail to auto.
- A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key.
  - Neither browser method is offered when no Chromium-family browser is found (#825).
- The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry".
- The #826 metadata token read is kept, and its test is back.
- The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows.
- maxConcurrency is 4.
- The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included.

Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME:
- full bun test: 6853 pass / 0 fail; both checks exit 0
- bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0
- 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed)

Not tried: a real InkStone account or sign-in, Windows and Linux runs.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 e7004d9354 inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern
InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id
`intern-inkstone`. Community package by yunwang2442-creator.

What it does:
- Browser sign-in (Edge/Chrome, its own profile under
  $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or
  %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no
  debugging port. A headless CDP read takes the uaa-token cookie, and the
  same read renews it silently later.
- Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs.
- Chat: a pasted ink-* API key, or one the sign-in creates, named
  ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An
  idempotency clash (-15109) retries with a fresh name, up to three times.
  Pruning is on by default. It only touches this machine's and account's
  prefix, keeps the newest two and the key this sign-in created, and never
  deletes manual keys or keys of unknown age.
- Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover
  browsers are matched by --user-data-dir=<escaped profile>, and Windows
  uses .Contains().
- The login wait comes from an injected waitForLogin in tests. No env
  hook is left in production code.
- Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn,
  127.0.0.1 (CDP).

Outside the package: scripts/opencode2.mjs lets a prompt with
`required: false` stay optional (`p.required !== false`). Every package's
copy is synced byte for byte, so all 39 copies in the merged tree are blob
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
yetone 925d6a253f trae 0.2.32: a conversation keeps its session_id when the plugin restarts
baoguo on magpie's Discord: every call seemed to be a new Trae
conversation, billed and cached as fresh; asked for one Trae session per
agent session. The plugin already sends one session_id per conversation
(0.2.6, #58): the session magpie names (the agent's own header, Claude
Code's x-claude-code-session-id, Codex's session_id, DSH's
x-deepseek-harness-session-id, OpenCode's session; else magpie's hash of
how the conversation opens), with the account, hashed. But the hash's
salt was new in each process, and magpie restarts its plugins on every
update of magpie or of any plugin, so every conversation going on then
went on under a session_id of its own from that point.

Now the salt is made once, in ~/.config/magpie/trae-session-salt
(MAGPIE_TRAE_SESSION_SALT names another file), written to a temp name
and hard-linked into place so processes starting together all read the
one that won. A file that can't be read or made, or holds anything else,
is left as it is and the process has a salt of its own, as before. The
id is derived, not cached, so there is nothing to bound or expire: the
same agent session gives the same id for good. Tests now write their
salt in a temp folder (nonet.mjs).

Run: HOME=$(mktemp -d) bun test packages/trae on mote, 243 pass, 0 fail;
bun scripts/check.mjs trae ok; conversation.test.mjs on Windows
(xiaomi-gpu), 10 pass. Broken by hand: a salt new in each process makes
"a conversation keeps its session_id when the plugin's process starts
again" fail; overwriting the file on a race makes "processes starting at
once on no salt yet all take the one that was made" fail.
Not tried: a real Trae account (none in this magpie), so whether Trae's
prompt cache follows session_id is not measured. dsh-connect-trae's
probe (docs, 11-03) saw cache_read 0 on three same-prefix requests since
10-26, which no session id would change. Claude Code subagents still
share their lead's session, as magpie names them.

Reported-by: baoguo
2026-11-06 17:36:42 +08:00
yetone 4578b11de2 trae 0.2.31: a token_usage counting 0 read and 0 written is unknown, not a 0% miss
feng2787 on magpie's Discord: Trae through magpie shows cache hits always
zero. The plugin passes on what Trae's token_usage says. Since 10-27 Trae
answers cache_read_input_tokens 0 (and cache_creation_input_tokens 0) on
every turn while it still bills the turn at its cache price: a real Trae CN
account on 10-29, deepseek-v4.1-flash, a 146k prompt, 5.84 credits cold and
0.12 warm, cache_read 0 on both (dingminhua/dsh-connect-trae,
docs/ISSUE69_DIAGNOSIS.md; the ratio matches Trae's cache-read/input price,
0.006/0.30). 0.2.26 made a token_usage with no cache field unknown, but a
named 0 still went on as a counted miss, so magpie showed 0%.

Now a token_usage whose cache read and write are both 0 goes on with
magpie_cache_unknown: true, which magpie (v0.1.2396 and later) shows as
unknown, not 0%. A nonzero read or a write alone (a first turn that
wrote the cache) goes as before. The cache itself was never missed; magpie
cannot make Trae report it again.

Run: bun test in packages/trae on mote, 240 pass. Broken by hand: without
the new line, "a cache read and write of 0 is unknown" fails (8 pass, 1
fail in cache.test.mjs).
Not tried: a real Trae account (none here); the 0/0 shape and the billing
come from the third-party measurement above. A real cold, short turn that
Trae caches nothing of also shows unknown now, not 0%.

Reported-by: feng2787
2026-11-06 15:02:08 +08:00
yetone 13371a3e52 trae 0.2.30: a Trae CN check-in goes on a 15-digit device id (#709)
sept13-yu's bisect on #709 (2026-11-05): with the plugin's own headers
and body ({"req_source":1}), the same token and account, seconds apart,
only x-device-id changed, the account's own 16-digit id got 9074 and a
15-digit one (a random, never-registered one too) was taken. Three
accounts, two machines on two ISPs, magpie's headers and wild-work's
alike: 16 refused every time, 15 taken every time. Every account signed
in since 0.2.16 has a 16-digit id and ugDevice sent it as it was, so
every client-less account's first claim got 9074. 0.2.29's second claim
uses trae-mate's 15-digit uid-derived id, which is likely why it lands.

ugDevice (only used for the ug pages, status and claim, of a trae-cn
account no local client is signed in as) now keeps an id that is
already 15 digits and otherwise makes a 15-digit one from the account's
own device id and uid: the same derivation it used for pre-0.2.16
19-digit ids, now modulo 9e14 with a 1e14 floor, so the first digit is
never 0 (shapeDevice can start with 0, which as a number is 14 digits).
Stable per account, changes only with a new sign-in, never another
account's.

Left alone, and why:
- newDevice stays 16 digits. That id is registered at sign-in, sent on
  every chat request and bound into the renewed JWT; nothing measured
  says chat or renewal want 15, and the bisect showed registration
  doesn't matter for the claim.
- An account whose local Trae CN client is signed in as it keeps the
  client's own device (the bisect didn't touch that path).
- Trae Global: no check-in, 19 digits as before.
- 0.2.29's one extra claim in clientShapeHeaders after a 9074 stays as
  the fallback: the bisect never sent that request with a 16-digit id,
  so "nothing but the id matters in it" isn't measured. It costs one
  claim on a 9074 day only.

Run (mote, bun): packages/trae bun test, 240 pass 0 fail; bun
scripts/check.mjs, 44 packages ok.
Broken by hand: the old index.mjs under the new tests on mote, 11 red,
among them the new "signed in since 0.2.16 (16 digits) checks in on a
15-digit id" test and the request-header tests. Golden ids
(166487253502651, 245914665436526) worked out by a separate Python port
of the derivation, which also reproduces the old 2866487253502651.
Not tried: a real Trae CN account check-in (no account here); whether
the chat or renewal care about the id length.
2026-11-05 10:13:03 +08:00
yetone d677c436d3 trae 0.2.29: a 9074 with no client here is claimed once more as client-less tools send it (#709, #722)
With no Trae CN client on the machine, Trae CN answers the plugin's
check-in claim 9074 every day (#722: jiabaoyu, never once taken; #709:
two accounts on a headless box). The same accounts check in through
tools that also have no client: providers-hub daily (#722), wild-work
(#709). #709 first put this down to account-level rate limiting cleared
by wild-work's 8s retry, but its reporter's own log then showed every
wild-work claim taken first time (~100ms, no 9074 since 09-19), so the
retry never ran and waiting is not the difference. What the working
tools share and the plugin doesn't: body {}, x-user-region: CN, a
15-digit id, no Electron UA / 0.1.69, none of the IDE's device headers.
providers-hub sends luckymiaow/trae-mate's request (MIT): those headers
and an id made from the uid alone, never registered at a sign-in.

Now an account no client here is signed in as gets one more claim, at
once, after a 9074, in trae-mate's request as it is (clientShapeHeaders;
its device, market user and session ids from the uid). Once: a second
9074 is the day's answer; no other code is claimed again; an account
that rode its own client's device is not; an account with no uid is
not. The first claim is unchanged, so an account it already works for
sends nothing new. Which single field Trae CN wants is still #709's
bisect.

Run (mote, bun): packages/trae bun test, 239 pass 0 fail; bun
scripts/check.mjs, every package ok.
Broken by hand: the old index.mjs under the new tests, 5 red (the
claimed-once-more, two-claims-never-three, and three message/device
tests); the guard widened to any non-zero code, "only a 9074 is claimed
again" and the 9095 test red. The golden ids for uid u-1 were worked out
with a separate Python port of trae-mate's device_map.rs.
Not tried: a real Trae CN account (no account used); whether the whole
request or one field of it is what Trae CN takes.
2026-11-04 19:09:13 +08:00
shadyrispy ef673b2b59 trae 0.2.28: a model's rate comes from display_contact_config (#690)
A Trae model's rate (and the rate before a discount) now comes from its
list entry's display_contact_config: consumption_rate when enabled, the
member discount's consumption_rate when that discount is enabled, and an
off-peak activity's after/before price by its time_windows in its own
time zone, computed when the list is read. A field that throws (an
unknown time_zone) costs that model its rate only; the rest of the live
list stays. Fixtures are the reporter's literal display_contact_config
strings from batch_get_detail_param.

Run at the reviewed head f47880ff on mote:
- bun test packages/trae: 234 pass, 0 fail.
- Broken by hand: making traeRateOf's outer catch rethrow turns "a broken
  time zone costs that model its rate only, not the list" red (1 fail).
- Real samples probed under TZ=UTC and TZ=America/Los_Angeles: deepseek
  0.06/was 0.12 at 08:59, 12:30, 18:00 weekdays and all weekend
  (Asia/Shanghai), 0.12 at 09:00 and 14:00; glm-5.3 0.58/was 0.78; a
  Bogus/Zone entry gives 0.12; missing, bad JSON, null and arrays give
  nothing.

Not tried: a real Trae account through magpie. The rate is computed when
the host reads the list, so it can lag a window edge until the next read.
2026-11-04 12:20:06 +08:00
yetone 17e5ef7457 all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin
must export a default definition with an id and an effect or setup
function. (cause: SchemaError(Missing key at ["default"]))". 2.x
imports a package's exports["."] (a plugin dir and an npm install
alike) and has no V1 path at all, so every package here that serves
models failed the same way, not only trae.

Every one of the 32 model packages now has:
- opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an
  adapter that runs the package's V1 plugins inside 2.x's promise
  API. Config providers become 2.x providers (package pinned so the
  aisdk sdk hook runs), V1 auth methods become integration methods
  (oauth auto/code with forms; api without authorize as a key method),
  V1 credentials are kept in metadata.v1, the loader's baseURL,
  apiKey, headers and fetch are applied through the sdk hook, an
  auth.set renewal is stored per credential, and credential.switched
  /updated reload the account's own model list.
- opencode.mjs, main: re-exports the V1 plugin functions only.
  OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's
  main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin
  export is not a function"); the new main fixes that too.
- both files in "files"; patch version bumped. devin already had 2.x
  and is unchanged.

scripts/check.mjs fails a model package whose 2.x entry has no default
{id, setup}, whose opencode2.mjs differs from the canonical one, whose
entry is missing from files, or whose main exports a non-plugin.

Run at this head (mote):
- HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail
  (4914 tests, 374 files). A first run set globalThis.fetch for the
  whole process from opencode2.test and failed 528 tests in other
  packages; the block is now set and put back around that file's tests.
- bun scripts/check.mjs: every package passes. With the network
  blocked cloudflare-workers-ai fails on its fetched catalog, the same
  on origin/main.
- Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae
  0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN"
  and trae-global "Trae Global" with their browser sign-ins; `auth
  login` starts the trae.cn authorization and waits (cancelled there);
  with a fake credential POSTed to /api/credential, `opencode models`
  lists trae-cn's six models.
- Real 2.2.5 with a fake V1 key plugin through the same adapter
  against a local fake server: `auth login` with a key, `models`,
  `opencode run` reached /real/v1/chat/completions with the loader's
  "Bearer loader-sk-fake" and header, and printed the fake's reply;
  with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key
  from the loader. This run found the key method missing after 2.x's
  second integration transform (a once-only flag outside the
  transform); fixed, and opencode2.test checks a rebuild.
- Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models`
  lists trae-cn and trae-global models; 0.2.26 failed there.

Broken by hand (scratch copy, bun test scripts/ and check.mjs):
- trae's exports back to "./index.mjs": the trae 2.x test fails
  (default.id undefined), check fails trae with "OpenCode 2.x:
  ./index.mjs has no default {id, setup} (plugins#657)".
- zed's opencode2.mjs changed: the copies test fails, check fails zed
  "differs from scripts/opencode2.mjs".
- the key flag back outside the transform: the 1.x plugin test fails
  on the rebuilt sign-ins (key missing).

Not tried: a real sign-in with a real account on 2.x; Windows (the
reporter's OS); chat.headers, chat.params, usage and tool hooks, which
the adapter doesn't carry to 2.x; the tools/pages packages (calc,
goanyapi, layerfs, search1api, aelios, agent-console, chat,
fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
2026-11-03 13:54:26 +08:00
yetone 8693d77c00 trae 0.2.26: a token_usage naming no cache count is unknown, not a 0% miss (yetone/magpie#3991, #3979)
Trae CN users see cache read 0 / write 0 on every call since 10-28
(modeyang: 786 trae-cn calls on 10-29 all 0, 77 hits on 10-27; an
identical resend also 0). The plugin passes on what token_usage says:
cache_read_input_tokens / cache_creation_input_tokens. A token_usage
with no cache field at all (chansee97's real super_completion_query
capture in #455: {"prompt_tokens":1717,"completion_tokens":2,
"total_tokens":1719}) came out as a usage with no cache field, which
magpie can only read as a counted miss. CDX-5 (#434) reports Trae's
chat replies switched to that shape at 10-27 23:07; not verified with
raw bytes. Trae's own client (3.5.20, libai_agent.dylib) still has the
9-field TokenUsageEvent, so the fields exist in the protocol.

Now:
- no cache field named at all -> magpie_cache_unknown: true (as the
  Kiro plugin does), so magpie shows the cache as unknown;
- DeepSeek's prompt_cache_hit_tokens, cached_tokens and
  prompt/input_tokens_details.cached_tokens are read as cache reads
  (largest of them, so a 0 in one spelling never hides a hit);
- an explicit 0 stays a counted miss.

This cannot make Trae cache; if Trae no longer reports cache, the
plugin cannot know the hit rate.

Run (mote, bun 1.4.2):
- packages/trae bun test: 230 pass, 0 fail
- whole repo HOME=$(mktemp -d) bun test: 4324 pass, 9 skip, 0 fail
- bun scripts/check.mjs: exit 0
Broken by hand: the old index.mjs with the new tests fails 4 (3 new
cases + request.test's stream usage).

Not tried: a real Trae CN account (none available), so whether Trae
now omits the cache fields or sends 0 is not confirmed.
2026-10-31 20:21:40 +08:00
yetone 77c257c0c6 trae: README says the daily check-in is one per device (#436)
moxuanchen ran TRAE CN 3.4.4 with its own --user-data-dir on 10-29: the
second account's sign-in was kept apart, but its device id matched the
default folder's and the client said 本设备今日已签到. The README no
longer says that case is unknown, and says only the first account on a
machine gets the day's credits. Docs only; no version bump, nothing run.
2026-10-29 17:29:05 +08:00
yetone 644038d95a trae 0.2.25: a 9074 or 9095 says which device the check-in went on (#436)
moxuanchen (plugins#436, Windows 11, TRAE CN 3.4.4, plugin 0.2.24):
account A checked in (100 credits), account B got 9074. Learning why
took running clientDevice by hand: both of that machine's profiles
(Trae CN, TRAE SOLO CN) were signed in as A with one device, so B's
claim went on magpie's own device for it.

The 9074 and 9095 messages now end with the device the claim went on:
this machine's client's, signed in as the account, or magpie's own,
with how many client profiles were found and that none is the
account's. A client device another account's profile also has is named
as shared. No uid or device id is in the message. clientDevice now reads
through clientProfiles; its answers are unchanged.

Not done: explicit profile dirs or --user-data-dir discovery. Whether
TRAE CN keeps a separate, registered device in such a dir is unverified,
and the issue asks the reporter for that first.

Run at this tree (rebased onto ea9201d; nothing under packages/trae changed):
- mote-run, HOME=$(mktemp -d): packages/trae bun test 227 pass 0 fail;
  whole repo bun test 3184 pass 0 fail at the rebased head; bun scripts/check.mjs ok.
  `node scripts/check.mjs` fails with ERR_INVALID_ARG_TYPE here and on
  main 4a46212 alike (it uses Bun's import.meta.dir; CI runs it with bun).
- win-run (xiaomi-gpu, Windows 11), fresh HOME: packages/trae 227 pass.
- Broken by hand: deviceNote reading no profiles turns the four new
  #436 tests red (4 fail), green again restored.
Not tried: a real Trae CN account or client.
2026-10-29 13:45:18 +08:00
yetone 50e99c2524 trae: the token_usage TRAE CN's own client got keeps its cache read (#455)
chansee97's capture of TRAE CN's llm_utils_chat answer, byte for byte:
an id line and no space after any colon (id:30 / event:token_usage /
data:{...cache_read_input_tokens:4096...}). The plugin already reads it:
cache_read_input_tokens 4096 of prompt_tokens 4122 goes on to magpie,
streamed and not. No change to the plugin, so no version bump.

Run (mote, bun 1.4.2, sandbox HOME): bun test cache.test.mjs, 6 pass.
Broken by hand: an "event:" line with no space read as unknown makes both
new cases red (2 fail); the four older cases, built with a space, stay
green, so this is the only test of the no-space form.
Not tried: a real Trae CN account (none here).
2026-10-29 09:33:56 +08:00
yetone dd260b4a3a trae: #434's "max" is the app's 1M-window Max switch, not a level (comments)
hbw169 (#434) on trae 0.2.23, TRAE CN: magpie model efforts prints
"low high xhigh" for deepseek-v4.1-flash and deepseek-v4.1-flash-max.
Their screenshot of the TRAE CN app's DeepSeek V4.1 Flash card shows
思考强度 轻 / 高 / 极高 only (light / high / extra_high, the plugin's
low / high / xhigh), and a separate 更大上下文 (Max) switch: "1M window,
more credits". That switch is the plugin's deepseek-v4.1-flash-max model
(maxModel, the list's __max entry with context_window_tokens.max), which
the reporter already has. So the plugin offers exactly what the app does.

Magpie's side passes a plugin model's variants through unchanged
(internal/provider/plugins.go: c.Efforts = m.Variants; provider.Levels
holds max), so it doesn't narrow anything either.

0.2.23's comments said the app offers DeepSeek V4.1 Flash max as a level.
That was wrong; they now say what the screenshot shows. No code change,
no version bump: LEVELS keeps medium/max for a list that names them.

Run: packages/trae, HOME=$(mktemp -d) bun test on mote: 221 pass, 0 fail.
Broken by hand: nothing; comment-only.
Not tried: a real TRAE CN account's model list; the read rests on the
reporter's screenshot and the client binary's field names
(reasoning_effort_config, reasoning_effort_options,
default_reasoning_effort, context_window_tokens), not a captured list.
2026-10-29 01:13:35 +08:00
edx 68794bacfc trae 0.2.24: a Kimi model's tool schemas get the types Moonshot requires (code 4027) (#462)
Trae passed a request's tools to the model as they were. Moonshot (Kimi) refuses the whole request when a schema node has no type: Trae answers code 4027, "tools.function.parameters is not a valid moonshot flavored json schema … type is not defined". Claude Code's enum-only properties trigger it. For a model whose config, model_name or request model matches /kimi|moonshot/i, nativeTools now deep-clones each tool's parameters and rewrites them with kimi-work's moonshotSchema (ported). An enum or const with no type gets the type its values have, and a $ref beside a type and a type beside an anyOf are written the way Kimi takes them. Other models' tools, and schemas Kimi already accepts, go byte for byte. README note, new moonshot.test.mjs, and 0.2.23 -> 0.2.24.

By edifierx666 (#462).

Reviewed at 4c8dc7401f74fb44615bcb70ee0178337a017951. The only change since is 31c88fe84 (maintainer): the README's Kimi bullet moved after the native-tools bullet's continuation paragraph. The text is unchanged.

Run at 31c88fe84 (macOS, via mote-run, sandbox HOME): bun test packages/trae, 221 pass, 0 fail; bun scripts/check.mjs trae passes. Run at 4c8dc7401 as well: the same 221/0, plus check.
Broken by hand at 4c8dc7401, running moonshot.test.mjs:
- moonshotModel always false: 4 of 6 red.
- Always true: the non-Kimi test red.
- structuredClone dropped: red.
Edge cases run through chatBody, 18 schemas: null, mixed, object and empty enums; nullable; anyOf/oneOf; nested objects; arrays without items; untyped and self $refs; boolean schemas; properties named enum or const. glm-5's parameters are byte-identical in every case. For Kimi, enums and consts only gain a type.
Not tried: a live Trae CN or Trae Global request (the author ran Trae CN live, per the PR).
2026-10-28 22:30:12 +08:00
yetone c20fa331a0 trae 0.2.23: a model whose entry names max (or medium) offers it and sends it (#434)
huajii (#434): Trae's app offers DeepSeek V4.1 Flash at max, the plugin
does not.

Cause: LEVELS knew only light/high/extra_high, so levelsOf dropped any
other option an entry's reasoning_effort_config names, and effortOf never
sent it. Trae's client names five levels (its bundle's
reasoning_effort.{low,medium,high,extra_high,max}, handed out per model by
remote config, per dsh-connect-trae #60's read of the client bundle). An
entry naming max beside the three lost it.

Fix: LEVELS spells medium and max as themselves. They are offered only
for a model whose entry names them, and a model that names none still
sends nothing for them.

Run:
- packages/trae: bun test 215 pass, 0 fail. The two new tests in
  reasoning.test.mjs (levels/variants/chatBody with max and medium; max
  reaching llm_utils_chat through the loader's fetch) were red on the old
  LEVELS line (2 fail, max undefined), green with it.
- HOME=$(mktemp -d) bun test at the repo root: 2902 pass, 3 skip, 0 fail;
  bun scripts/check.mjs: ok.

Not tried: a real Trae account. The wire name "max" in options comes from
the client's i18n keys, not a captured list; on 10-25 a live CN list named
only light/high/extra_high (dsh-connect-trae #60, plugins #300). If Trae's
"max" in the app is the Max mode instead, the plugin's
deepseek-v4.1-flash-max model is that and is unchanged here.
2026-10-28 00:46:08 +08:00
moxuanchen 4ac4766217 trae 0.2.22: every client profile is read, a claim's code 0 is read back (#333)
moxuanchen's change for #361 (a second Trae CN account can't check in).

- Every Trae CN client profile is read (Trae CN, TRAE SOLO CN, trae-cn):
  the one signed in as the account gives its device. A profile signed in
  as someone else, or one that doesn't parse, no longer hides the rest.
- A claim's code 0 is read back from the status. Not in after the claim
  is `ineligible` for the day (no repeat claims); a failed read-back is
  ineligible too.
- 9074's message says Trae did not take the check-in for this account's
  device, and no longer sends people to Trae CN's app.
- Credit: the claim's credits, else its extra_credits, else the
  read-back's credits; never summed (matches 0.2.21).
- Version 0.2.22, README updated.

Run at the reviewed head 4006fef51 (rebased on ba9801c), sandbox HOME:
- packages/trae: bun test, 213 pass, 0 fail. bun scripts/check.mjs: trae ok.
- Broken by hand, each red: first profile decides (2 red), no read-back
  (2 red), failed read-back reported as failed (1 red), credits summed
  (2 red), TRAE SOLO CN folder dropped (1 red). Restored after.

Not tried: a real second Trae CN account, and TRAE SOLO CN's real
storage.json (its folder and keys are inferred, as the README says).
A status that lags a claim that did land would read ineligible once
that day; the README names it.
2026-10-25 14:04:10 +08:00
yetone ba9801c953 trae 0.2.21: a check-in's credit is the day's credits, not credits plus extra_credits (zhujiu on magpie's Discord)
zhujiu (magpie Discord #feedback, 10-25): "trae签到的积分为100而不是200 …
显示错误了". The card showed a claimed Trae CN check-in as 200 credits;
the account got 100.

Cause: auth.checkin's claimed outcome was the claim's credits +
extra_credits, falling back to the status's credits + extra_credits.
Trae CN's real claim answer names no credit at all ({"code":0,
"message":"success"}, plugins#194), so the fallback always ran, and a
real account's status carries both fields at 100 ({"checked_in": false,
"code": 0, "credits": 100, "did_checked_in": false, "enable": true,
"extra_credits": 100}, yetone/magpie#808): 100 + 100 = 200. magpie's own
Go check-in (internal/provider/trae_checkin.go, used only for plugins
before 0.2.17) fell back to the status's credits alone, and its real run
recorded credit 100 (plugins#194).

Now the credit is the claim's credits, else its extra_credits when it
names only that (#260's case), else the status's credits; the two are
never added. The done outcome already read credits alone. Trae Global
has no check-in, so this is CN only. What extra_credits means on Trae's
side is not known; nothing seen shows it granted on top.

Tests (native-checkin.test.mjs): the real status and claim answers give
credit 100; a claim naming both gives 100; a checked-in day with
extra_credits is done with 100. On origin/main's index.mjs the first two
fail (Expected credit 100, Received 200). HOME=<scratch> bun test in
packages/trae: 206 pass, 0 fail; bun scripts/check.mjs trae: ok.

Not tried with a real Trae CN account (none here); the shapes are the
real ones quoted in #808 and plugins#194. PR #333 touches the same
fallback line and needs a rebase.
2026-10-25 07:36:10 +08:00
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 b3afe11631 trae: stream.test breaks the connection by stopping its server, not by erroring the body (#268)
Cause: "a stream that breaks off" errored the fake's response body with
ctl.error(new Error("connection reset")). Bun prints a response body's
error on every run, even with an error handler on the server, so every
run of the file printed "error: connection reset" at that line while the
test passed. #268 read that print as a red. It was never a failure: 40
of 40 printed it and passed under load on origin/main.

The fake now stops its server mid-body, a real broken connection: the
plugin still ends with Trae CN's error and [DONE], and nothing is printed.

Run on macOS arm64, bun 1.4.2:
- origin/main: 8 parallel `bun test --rerun-each 40 -t "breaks off"`:
  every run printed the error, 0 fail.
- This change: 6 parallel `bun test --rerun-each 30
  packages/trae/stream.test.mjs` at load average ~55: 6 x 420 pass,
  0 fail, 0 printed.
- `HOME=$(mktemp -d) bun test` from the root: 1920 pass, 0 fail.
  `bun scripts/check.mjs`: ok.
Test-only, no version bump.
2026-10-21 07:39:22 +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
moxuanchen c7a7379733 trae: the two Windows roots of the client's storage.json are one when they name the same folder (#273, moxuanchen)
clientStoragePaths compares its two Windows roots (APPDATA and the home's
AppData\Roaming) ignoring separator, trailing separator and case, so the same
storage.json isn't read twice; the path test compares with this system's
separator, so it passes on Windows.

Run at the reviewed head 08b52ad, merged with #257 and #260 on main 68170b3:
bun test in packages/trae 173 pass 0 fail; check.mjs trae ok. Not run on
Windows here. A case/separator test that fails on main follows on main.
2026-10-20 22:06:08 +08:00
moxuanchen 40d7c528fb trae: a claim's extra_credits alone, the reasoning an empty field hid, a name that grows, the realm in an error (#260, moxuanchen)
A check-in claim answering extra_credits alone is credited (NaN before); an
empty reasoning_content no longer hides the event's reasoning; a native call's
name snapshot that grows takes the place of its first piece; a Global reply's
error names Trae Global.

Run at the reviewed head 2a0a835, merged with #257 and #273 on main 68170b3:
bun test in packages/trae 173 pass 0 fail; check.mjs trae ok. The new tests
fail on main's index.mjs. Not tried against a live Trae account.
2026-10-20 22:06:02 +08:00
WuJian1421 0b82ab8f6c trae: a tool call history goes back as the turns Trae made, not as text (#257, WuJian1421)
Trae accepts an assistant tool_calls turn and a role:"tool" result turn on
llm_utils_chat, and answers such a history with native calls; the text-form
bridge prompt is dropped. Assistant text folds into the calls turn after it,
consecutive calls turns join one list, a nameless call is dropped with its
result, and a tool result's images ride a user turn after the run of results
(Doubao-Seed doesn't read an image_url in a tool turn). Refs #38.

Run at the reviewed head d5d755a, merged with #260 and #273 on main 68170b3:
bun test in packages/trae 173 pass 0 fail; bun scripts/check.mjs trae ok.
Not tried live here (no Trae account); the live runs are the author's (CN and
Global, multi-turn, parallel calls) and wangjianjq's on #251. Follow-up on main:
an empty result's 4027, a request without tools, and a result answering no call.
2026-10-20 22:05:23 +08:00
yetone 992cff84af trae: the README's check-in outcomes and the 9074 test name say what the code does
#178's README called 9095 done and 9074 failed. The code answers both as
ineligible, the same as magpie's built-in check-in, so that 9074 isn't
asked again that day. The test asserting ineligible was named "is failed".
Docs and a test name only, so no version bump. bun test
packages/trae/native-checkin.test.mjs gives 9 pass, and check.mjs trae is ok.
2026-10-17 18:07:22 +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 103bb24b65 trae: ownclient's tests open one fake at a time, so global.test finds the realm's own hosts (0.2.14's publish run)
checkIn() opened a fake over the one the test had already opened; closing
the second put the first's 127.0.0.1 origin back as trae-cn's hosts, so
global.test.mjs, run after it in one process, read a fake host. The
publish run for 2009f49 went red on it and 0.2.14 never reached npm.
checkIn now closes the fake before it opens another.

Ran: HOME=$(mktemp -d) bun test at the repo root: 1509 pass, 0 fail.
Broken by hand: without the close, `bun test ./ownclient.test.mjs
./global.test.mjs` fails "the realm's table is its own" (26 pass, 1 fail),
as the publish run did.
2026-10-15 17:07:59 +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 9803210691 trae tests: a stream that breaks off breaks after the caller has its first event, not 30 ms after it was sent (#124)
The test's fake server sent one event, waited 30 ms and errored the body.
The plugin reads its first part before it answers. Under the whole repo's
`bun test` that read sometimes started after the reset, and Bun then drops
the event it had already received. The read threw ECONNRESET out of the
plugin's fetch instead of reaching the mid-stream path the test covers
(1259 pass, 1 fail at a6bed5e). The reset now waits until the caller has
read "half", so the plugin has always read it first. Only the test
changed. index.mjs is untouched, so there's no version bump.

Run at a6bed5e + this change, TMPDIR and HOME set to a scratch dir:
- before the change, repo-root `bun test`: 1259 pass, 1 fail (this test).
  A 200 ms pause put by hand before the plugin's first read failed it
  every time when run alone.
- after: repo-root `bun test` 1259 pass, 0 fail, 1 skip (exit 0);
  packages/trae `bun test` 129 pass; stream.test.mjs alone 3/3;
  `bun scripts/check.mjs` exit 0.
- with the same 200 ms pause in place: passes.
- broke it by hand: index.mjs ending a broken stream with finish "stop"
  and no error turns this test red.
- grep found no other test that resets a body on a timer.

Not tried: CI's Linux runner. CI's publish runs had passed this test so
far (e.g. 38572309548). Their red was the zed and zen-free Trusted
Publisher 404s.
2026-10-14 22:12:50 +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
YuCreateandyu b32b510c9d trae 0.2.12: the call a service left mid-wrapper in a native call's name is read as the call (#106)
trae-cn/glm-5.3 under DSH (2026-10-13): over three turns, 28 of 54 native calls
arrived with the model's call in `function.name` instead of `function.arguments`
— the JSON wrapper the tool prompt asks for, with GLM's own
<arg_key>/<arg_value> tags where Trae's service stopped reading it, and a value
whose close left off:

  {"name":"bash","arguments":{"command</arg_key><arg_value>ls -la</arg_value>
  {"name":"bash","arguments":{"command":"grep -n x a.ts | head -3</arg_value>
  {"name":"bash","arguments":{"command":"grep -n "x" a.ts","description":"…"}}
  bash_abstract_command_0>{"name":"bash","arguments":{"command":"…scan.mjs</description>Re-run scan</arg_value>

Each went out under a name no request declares, so the agent answered "unknown
tool" and the call was lost — twelve steps in a row before the model recovered.
All 28 sit in the context the session compacted at the end of turn 8: turn 9's
input went from ~5k to 94.5k tokens. Whether the compaction is what makes the
service hand a call back this way is not established — only that the two line
up, and that the session's earlier turns on workbuddy-ai/hy4-preview-f and
group/auto-hy4-preview-f sent 270 whole calls and none of this shape. No
workbuddy/glm-5.3 call was routed that day, so nothing is claimed about it.

- A name holding the wrapper is read as the call: the tool, then the fields the
  text between the tags still spells out. The tags are the service's own
  handoff, so what stands between them is the model's text as the model wrote
  it: a quote left unescaped is read as the quote it is, a value the service
  cut at its tag keeps the text it got, a comma inside a value is the model's
  own (`sed -n 1,9p` reads whole), and a closing tag that is a field's own
  (`</description>`) ends the value before it — what follows such a tag is the
  service's text, not the model's.
- A field the tool's schema says is no string is its JSON where the text is
  one, and its text where it isn't.
- The native call's own arguments are kept, and the name's fields are filled in
  beside them: the service moves the arguments it read into the call and leaves
  the rest in the name, so the two halves are one call (command in the name,
  description/workdir in the call).
- A name whose tool the request doesn't have, or one no field can be read from,
  goes on as written, as any other unknown tool does — including one the
  service cut before it wrote a value (at a key, at a colon, at an open quote),
  where an empty call read out of it would be a call the model never wrote.
  Calls already written into a session's history under a mangled name still go
  back on as that name; the plugin reads what it is handed and cannot rewrite
  what was already sent.
- What main already read of a whole name keeps reading the same (`input`,
  `parameters`, arguments given as a string, the flat fields, a wrapper written
  with a space), and a call's own arguments that are not a set of fields — text
  the service cut, a value that isn't a call's fields — go on as they stand, as
  main passed them, for the agent to answer.

The wrapper and the tags are upstream's; the plugin reads what it was handed.
The same shapes are already handled by the DSH-ecosystem relays (trae2api's
_ARG_KEY_VALUE_RE takes a key whose opening <arg_key> was dropped) and by
@ai-sdk-tool/parser's GLM-5 name resolution (a declared name followed by a
structural tag is that tool), which is where the fail-closed reading of an
unknown name comes from.

Run: namecall.test.mjs (16 tests; the real payloads, a name in front of the
wrapper, a field's closing tag cut into a value, a comma inside a value, the
whole-name shapes main reads, the shapes the reader must leave alone, and the
streamed path) — 11 of 16 fail on main's index.mjs, the five that pass being
the ones that pin what main reads.
HOME=<tmp> bun test, 125 pass 0 fail; bun scripts/check.mjs trae green. The 28
payloads this was drawn from were replayed through NativeCalls.take: 28
recovered into calls to tools the request declares, and the 270 calls that
arrived whole in the same session unchanged, byte for byte. Against the same
names and calls main can take (187 pairs) the only differences are the fields
the name's side fills in beside the call's own, and the names main could not
read at all.

Co-authored-by: yu <wowyuarm@users.noreply.github.com>
2026-10-14 18:36:39 +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