* Add Trae Global (trae.ai) plugin — trae-global provider Trae international (trae.ai, ByteDance's AI IDE international build) as a provider plugin: sign in with Trae's own browser flow, free tier included, models served through the international llm_utils_chat gateway. Same plugin contract and request/response machinery as the Trae CN plugin (packages/trae), a separate deployment: different domains, OAuth client, model catalog, plus a US region (coreva) routed by the account's AIRegion. The usage card reads the dollar billing's entitlements (basic+bonus allowance) from the pay host, with the Free plan's /month allowance riding it. bun test: 41 pass; bun scripts/check.mjs trae-global: ok * trae-global: a stream the agent walks away from closes Trae's connection The bug: an answer whose tool call the agent acts on is cancelled mid-read, and the read to Trae was left hanging. A generator's return cannot break a read that is already waiting on reader.read(), so the SSE reader kept its half of the connection open, and the host the next ask reused was one Trae had dropped — a stream that runs, then dies, exactly around tool calls. The fix: the answer's fetch is what gets stopped. The loader builds one AbortController per request, follows the caller's abort signal into it, and openai() aborts it when the stream is cancelled. sse() also lets its reader go in a finally, for the paths that end the generator rather than the fetch. stream.test.mjs: the agent reads, then cancels with nothing more coming, so only aborting Trae's fetch can release the read — red before, green after. bun test (42 pass); bun scripts/check.mjs trae-global: ok * trae-global: the review's three blockers — planLocked, the 0.1.15 Max, usage's error code planLocked is gone. It read display_contact_config's identity_list and assumed every account is Free (identity 0), so a paying account lost exactly the models it pays for — gpt-5.5, the gpt-5.6 family, gpt-6, glm-5.2 — and could never pick them. The plugin is never told the account's own identity (not at sign-in, not in the entitlement answer), so nothing is filtered on identity now: the list is the account's own, the IDE greys out what the plan locks, and a locked model answers Trae's own 1005 when asked. The picker's invisible entries (paygo/auto twins, search agents) stay out, as before. maxModel takes the 0.1.15 fix: a model's Max is found across every list that names it, not just the one entry the model is listed through — chat_v3 can name the __max model while the SOLO list names only __dev, and the window can be another entry's again. Without it the same "no -max model" bug the CN plugin fixed in 0.1.15 comes back here. maxes holds each model's Max for the models hook, as CN's does. usage: a 200 carrying an error code (e.code !== "0") now says Trae's own message instead of "no entitlement pack in the answer", as CN's does. README: the verification range is stated honestly — one Free account, SG realm, no Pro and no US account tried; paid-account behaviour is implemented from the interface's shape, not confirmed on a live one. registry.json marks Trae Global experimental, as Trae CN is. usage.test.mjs: the locked-model test now asserts the paying account's list, and a new one asks a paid account's gpt-5.5 through the gateway. stream.test.mjs: a Max split across lists is listed and asked where its __max model is named. Each red before its fix, green after. bun test (46 pass); bun scripts/check.mjs trae-global: ok
Trae Global (trae.ai) for OpenCode / magpie
Trae 国际版(trae.ai,ByteDance 的 AI IDE 国际部署)作为 OpenCode provider 插件:
用 Trae 国际版 IDE 自己的浏览器登录流程签入你的账号,免费额度可用,
模型走国际版的 llm_utils_chat 网关。
与 @magpie-community/opencode-trae-auth(Trae CN)的关系:同一套插件契约与
同一套请求/应答机制,另一套部署。国际版与国内版是完全独立的服务(不同域名、
不同 client 生态、模型目录几乎不重叠),所以是一个独立插件,不是配置项。机制
部分(工具调用解析、流收尾、max 档位、reply limit)跟随 CN 0.1.15。
验证范围
本插件目前只在一个 Free 账号上实测过(SG realm)。未在 Pro / 付费账号上 验证,也未验证 US realm 的账号。付费账号相关的行为(模型列表里付费模型的可用性、 付费额度的显示)依据 Trae 接口的结构实现,未经真机确认。故 registry 标 实验性,与 Trae CN 一致。
计划:把国际版并入 packages/trae,一个包用两个 provider id
(trae-cn + trae-global),按 realm 分表(hosts、client、版本号、usage 页面、
兜底模型、错误码)。那样每个请求 / 流 / 工具调用的修复会同时作用于两个版本,
也消除两份代码的漂移。
端点(与 CN 版的差异)
| 项 | Trae CN | Trae Global (本插件) |
|---|---|---|
| 授权页 | https://www.trae.cn |
https://www.trae.ai |
| token/账号/积分 | https://api.trae.cn |
https://growsg-normal.trae.ai |
| 模型网关(SG) | https://trae-api-cn.mchost.guru |
https://coresg-normal.trae.ai |
| 模型网关(US) | — | https://coreva-normal.trae.ai(按账号 region 自动路由) |
| OAuth ClientID | SOLO: en1oxy7wnw8j9n / IDE: ono9krqynydwx5 |
两者同: ono9krqynydwx5 |
| IDE 版本 | 3.3.x | 3.5.x |
依据:wangqi233/trae2api 的 realm 表(cn/sg 双区域实测),本插件按 SG realm 配置。
登录
auth.login 选 Trae Global account (browser):本插件起一个 127.0.0.1 回调,
打开 trae.ai 的授权页,你在浏览器里登录国际版 Trae 账号并允许,页面会把
token 送回本机,签入自动完成。token 过期前插件自动续期(ExchangeToken)。
前提:你的账号是 trae.ai(国际版) 的账号。trae.cn 的账号签不进 trae.ai。
美区账号:回调的 AIRegion 为 US(或 Host 是 api-us-east.trae.ai 这类认证
主机)时,模型请求自动走 coreva-normal.trae.ai;SG 账号不受影响。
模型
签入后模型列表从国际版网关实时拉取(get_detail_param / batch_get_detail_param,
跨 chat_v3、solo_work_lite、solo_agent、solo_agent_lite 四个 function 合并)。
国际版常见模型是 GPT / Gemini / Kimi / MiniMax / DeepSeek-V3 系列(与 CN 版的
GLM/Qwen/Doubao/Kimi-K2.7 几乎不重叠)。未签入时显示内置的静态表。
一个模型在清单里带 __max 条目和更大的 context_window_tokens.max 时,会作为
第二个模型列出(<id>-max,名字加 "(Max)",窗口与输出上限取 max 档的):
请求它时改发该模型的 __max,并按 IDE 的 Max 模式带上
user_message_context.model_info.prompt_max_tokens(max 窗口 − max_tokens)。
模型的回复上限取清单给的 __dev 条目的 max_tokens;清单没给的就是没有(0),
magpie 会从 models.dev 补,插件不编一个数。
工具调用
Trae 的 chat 没有原生 tool-call 轮次:工具原生带给它、也写进系统提示词,模型
可能以 <tool_call>{...}</tool_call> 文本块(含 GLM 的 arg_key/arg_value
模板、DeepSeek 的 DSML 标签收尾)或原生分片事件回复,两种都解析成 OpenAI 的
tool calls;写在正文里的 {"reasoning_content":...} JSON 是思维链不是回答;
未命名/错名事件里的正文不丢;失败的回复以错误和 [DONE] 收尾,不谎报 stop。
思考强度(reasoning effort)
Trae 的请求不接收思考强度:本插件不给模型声明任何档位,客户端的思考档选择 对 Trae 无效(选了也照常回答)。dev/max 是上下文档位,不是思考档。
用量
用法卡片显示账号的 Dollar Usage(美元额度,2026-02 起国际版的计费方式):
各 entitlement pack 的额度(basic_usage_limit + bonus_usage_limit)与已用
(basic_usage_amount + bonus_usage_amount),在 Credits 式的窗口行里按
百分比展示。免费计划是 $1/月的额度池(另有 10 次快速 + 50 次慢速 + 1000 次
高级模型的请求次数限制,插件暂不展示次数)。
接口走 api-sg-central.trae.ai(美区账号走 api-us-east.trae.ai)的
/trae/api/v1/pay/user_current_entitlement_list——认证主机自己的
/cloudide/api/v2/pay/* 对插件 scope 返回 403 Api Scope Forbidden。
图标
package.json 的 magpie.icon 是 Trae 官网的 favicon(lf16-web-neutral.traecdn.ai
的 48×48 PNG)以 data URI 内嵌——与 MiMo 插件同一做法,magpie 直接取用,不联网抓图。
本地开发
bun test # 全部测试(fake 掉所有 Trae 主机,不出网)
改完源码接入本机 magpie 验证时(file: 依赖是 copyfile 安装,必须重跑):
bun install --cwd ~/.config/magpie/plugins --backend=copyfile --force
然后完全重启 magpie(插件模块被进程缓存)。