Skip to content

registry: magpie-traecode (Trae CN / Global, rebuilt on llm-api's trae channel) - #1320

Open
ruoxhub wants to merge 1 commit into
magpie-community:mainfrom
ruoxhub:registry/traecode
Open

ruoxhub wants to merge 1 commit into
magpie-community:mainfrom
ruoxhub:registry/traecode

Conversation

@ruoxhub

@ruoxhub ruoxhub commented Nov 18, 2026

Copy link
Copy Markdown

Adds magpie-traecode to registry.json beside the existing Trae entry
(@magpie-community/opencode-trae-auth). Both sign in to the same Trae
accounts; this one differs in how it talks to the service, which is what
this note is for.

What it shares

  • The same channel: Trae CN (trae.cn) and Trae Global (trae.ai), provider
    ids trae-cn / trae-global.
  • Trae's own browser sign-in, the same account and the same free tier.

What it does differently

opencode-trae-auth magpie-traecode
Request body plain JSON envelope AES-256-GCM encrypted (x-request-pin / x-requested-at), as the IDE sends it
Built from two open-source relays llm-api's internal/relay/channel/trae (the channel that runs in production)
Version headers pinned constants probed: local product.json, else Trae's own update check
Model list id + name id, name, context window, output limit, images, credits rate, reasoning levels read from the real entry
Check-in device account's device id the 15-digit id that endpoint accepts (16-digit / 32-hex get 9074)
Errors pass-through classified: 1001/20101 → re-sign-in, 4008/1005/4011 → 429

Verification

  • npm test: 115 unit cases on a local fake upstream, asserting the bytes
    actually sent (the ciphertext is decrypted with the response's own pin/at).
  • Real-account e2e (scripts/e2e-live.mjs): model list (20 models with the
    capability fields above), streaming and non-streaming chat, tool calls,
    check-in status and credits.
  • Cross-language parity: a body encrypted by this package decrypts with
    llm-api's Go DecryptBody, and its SOLO header set matches
    applySoloHeaders key for key.
  • Cross-checked against a capture of the real Trae CN IDE's own traffic
    (via proxycli): the IDE's encrypted request body decrypts with this
    package's decryptBody.

Listing

… channel

A second package for the Trae channel, listed beside
@magpie-community/opencode-trae-auth. Same accounts, different way of
talking to the service: it is built on the trae channel of llm-api, so it
sends the SOLO llm_utils_chat request with its AES-256-GCM encrypted body
(x-request-pin / x-requested-at) instead of the relay's plain envelope, and
reads the model table's real capability fields (context window, output
limit, images, credits rate, reasoning levels) rather than a fixed list.

It also differs in what it does around the chat: the IDE version headers
are probed (the local install's product.json, else Trae's own update check)
instead of pinned to a constant, the check-in uses the 15-digit device id
that endpoint accepts, and errors are classified (1001/20101 lapsed,
4008/1005/4011 quota) so a lapsed sign-in asks for a new one instead of
surfacing a 502.
@ruoxhub

ruoxhub commented Nov 18, 2026

Copy link
Copy Markdown
Author

Note on the version this listing points at: magpie-traecode@0.1.0 had a broken paste-JSON import — its authorize returned { type: "success" } directly instead of handing back a callback, so magpie reported trae-cn's sign-in gave nothing to finish it with (host.js: if (typeof a?.callback !== "function")) and OpenCode 2 hit r.callback is not a function. 0.1.1 fixes it: the credential is still validated up front (parse, region, token exchange, GetUserInfo) and errors still come back as { type: "failed", error }, but the result is delivered through callback as the contract expects. Two regression tests cover it (both red on 0.1.0) and the live e2e now imports a real account and immediately chats with the credential it got back. 0.1.1 is staged on npm awaiting 2FA approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant