dsh-connect-trae 1.4.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -5
- package/README.en.md +15 -9
- package/README.md +15 -9
- package/lib/client.js +268 -76
- package/lib/index.d.ts +345 -51
- package/lib/index.js +781 -234
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0 (2026-09-15)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- **为什么是 2.0.0**:本版在「国际版支持」之上完成架构级变更——插件由「单 provider 单活区域」变为「双 provider 并行」,运行形态与外部可见契约均有变化,按语义化版本升主版本号:
|
|
8
|
+
- **运行形态**:插件现在注册两个 provider 路由(`trae` + `trae-global`)并打开**两个**回环端口(原先各一个)。下游脚本若假定「只存在一个 trae provider」,需适配新增的 `trae-global`。
|
|
9
|
+
- **设置 schema 扩展**:新增 `accounts.{cn,ai}` 每区域账号选择。旧的单 `accountId` 仍被读取并按其账号实际区域自动归位(软迁移,非硬破坏);`regions` 分槽结构不变。
|
|
10
|
+
- **CLI 不可见面**:卡片路由全部按 `?region=cn|ai` 参数化(未知区域 400);这是 host↔卡片之间的私有契约,对用户透明。
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **🆕 国内版与国际版拆分为两个并行供应商,可同时使用**——此前一个 provider 一次只能活一个区域(选哪个账号整个 `trae` 就服务于哪个区域,切账号 = 翻转整个运行时目录)。现在两侧是两套完全独立的实例,**互不干扰**:
|
|
15
|
+
|
|
16
|
+
- **双 provider 注册**:国内版保持 `trae`(老 id 不变,存量会话的默认模型与已保存选择全部继续有效),国际版新增 `trae-global`(displayName `Trae Global`)。**两边模型同时出现在 DSH 模型选择器里**——不同会话 / 子代理可以各选一边,互不干扰。
|
|
17
|
+
- **每个区域一套完整运行时栈**:凭据 store、模型 catalog、wire 映射(display id/name → `llm_utils_chat` config_name)、Remote/SOLO 客户端、回环 shim、adapter 各一份。store 按凭据自带的区域声明过滤可见账号,两个区域的账号可同时在线。
|
|
18
|
+
- **插件卡片 tab 化**:设置卡片顶部新增「国内版 / 国际版」tab 栏(带各自登录状态圆点)。每个 tab 有独立的账号选择、用量/订阅概览与模型管理;**切 tab 不丢另一侧未保存的草稿**(模型勾选 / 图片开关 / 上下文预算的草稿按区域隔离保存)。
|
|
19
|
+
- **「减少刷新变化」**:一个 tab 里切账号、刷新模型、轮询用量,完全不触碰另一边的运行时目录——绑定另一边模型的进行中会话不受任何影响(单 provider 架构做不到这一点)。
|
|
20
|
+
- **账号选择按区域独立**:配置新增 `accounts.{cn,ai}`,每个 tab 各选各的账号。旧的单 `accountId` 在启动时按其实际所属区域归位(另一区域保持「首个发现账号」的默认,绝不静默继承错区域的选中账号)。
|
|
21
|
+
- **凭据刷新副本按区域分文件**:`$DSH_HOME/.trae-auth.cn.json` 与 `.trae-auth.ai.json`,双账号同时在线互不覆盖(此前单文件只存一个账号的刷新结果,后写者赢);旧单文件 `.trae-auth.json` 作为迁移来源保留读取(只被其凭据所属的区域采纳),`logout` 清除全部。
|
|
22
|
+
- **身份解析按区域收窄**:机器/设备 identity 的候选安装先按区域过滤,国内栈不会去读国际安装的 identity(反之亦然),避免跨安装取错 deviceId/machineId。
|
|
23
|
+
- **Raw Chat 探测仅在国内栈**:探测模型 `qwen-3.7-plus` 仅国内可用,且该路径本就 `enabled: false`;国际栈固定报告 `disabled`,不再触碰 raw 端点。
|
|
24
|
+
|
|
25
|
+
- **国际版支持(国内与国际账号对等)**——沿用本版已完成的区域化工作,**零配置、零开关**:
|
|
26
|
+
|
|
27
|
+
> **🆕 正式支持 Trae 国际版(www.trae.ai)**——国内版与国际版账号在本插件中获得完全对等的支持:
|
|
28
|
+
|
|
29
|
+
- **怎么用**:在插件卡片对应区域的 tab 里选账号(Trae / TRAE SOLO 国际版安装的登录即国际版;Trae CN / TRAE SOLO CN 即国内版)。区域判定完全跟随凭证自带的 `userRegion` 声明(`SG` → 国际,`CN` → 国内,host 后缀与 edition 标签兜底),无需任何手动设置。
|
|
30
|
+
- **国际账号可用的完整功能**(目录/网关/订阅状态均经 2026-09-15 实测取证,见 `docs/INTL_SG_EVIDENCE.md`):
|
|
31
|
+
- **模型接入**:聊天与目录请求自动走国际网关 `https://coresg-normal.trae.ai`;国际版 remote 目录(Gemini-3.1-Pro / Gemini-3-Flash / MiniMax-M3 / M2.7 / Kimi-K2.5 / GPT-5.4 / GPT-5.2)进入 DSH 模型选择器;CN 版解析器直通国际响应(`wireConfigName` 机制命中 `gemini-3.1-pro → custom_model_gemini`)。
|
|
32
|
+
- **订阅状态**:国际账号无 Work 积分包(订阅制),卡片显示订阅/试用状态(`ide_user_pay_status`,官方 App 同款端点)。
|
|
33
|
+
- **请求头零分叉**:CN 版整套请求头(`x-app-id`、identity 头、`Cloud-IDE-JWT`)被国际网关原样接受;`storage.json` 解密器四版通用。
|
|
34
|
+
- **目录与勾选按区域隔离(国内 / 国际各一套)**:`regions.cn` / `regions.ai` 两套独立槽位(目录、勾选、图片开关、上下文预算各一份),切换账号互不干扰;旧的扁平字段保留为**国内区域的迁移来源**(区域拆分前的配置一律来自国内端点),国际区域绝不继承。
|
|
35
|
+
- **凭证层**:四个桌面版安装(Trae CN / Trae / TRAE SOLO CN / TRAE SOLO)全部纳入账号扫描;国际 CLI(`~/.trae`)因默认 host 未验证暂不支持(给出可诊断错误而非静默误路由)。
|
|
36
|
+
- **refresh 契约按 edition 分叉**:TRAE SOLO 国际版走 `/trae/api/v3/oauth/ExchangeToken` + ClientID `en1oxy7wnw8j9n` + DeviceInfo(官方 App 日志直证);其余三版维持 `/cloudide/api/v3/trae/oauth/ExchangeToken` + `ono9krqynydwx5`。
|
|
37
|
+
- **端到端实测(2026-09-15)**:SOLO 国际版有效凭证经本项目正式代码路径(`prepareSoloBody` + `buildTraeHeaders` + `REGION_GATEWAYS.ai.chat`)发最小 `solo_work_lite` 请求:`gpt-5.4` 走 `coresg-normal.trae.ai` 返回 HTTP 200 + 完整 SSE(`output("OK")` / `usage` / `done`),`SseDecoder` 原样可用。账号扫描实测:`edition: auto` 下四版安装共发现 5 个账号(含 2 个国际版,region 正确标 `ai`)。
|
|
38
|
+
- 测试:region 判定(userRegion 大小写不敏感/host 后缀/edition 三级兜底)、regionStateOf 迁移语义(扁平读作 cn、ai 绝不继承、显式槽优先)、fallback 目录区域隔离与实测快照、solo/remote/usage 的 ai 网关路由断言、refresh 四版契约断言、web-status 的 ai 分派与降级、nextRegionSlots 保存合并语义。220/220 全绿(含双 provider 注册、跨区域隔离、区域路由分派、区域化 store 与旧副本迁移)。
|
|
39
|
+
|
|
40
|
+
## 1.4.2 (2026-09-14)
|
|
41
|
+
|
|
42
|
+
> **版本号说明**:`v1.4.1` ~ `v1.4.4` 四个 git tag 曾推送到远端,但对应代码已整体回档到 `1.4.0`、
|
|
43
|
+
> 从未发布到 npm。发布前已删除这四个废弃 tag(备份见 `backup/abandoned-v1.4.1-v1.4.4` 分支
|
|
44
|
+
> 及 `abandoned-tags-v1.4.1-4.bundle`)。
|
|
45
|
+
>
|
|
46
|
+
> 本次实际使用 `1.4.2` 而非 `1.4.1`:`1.4.1` 在 npm 上处于 **staged 状态**
|
|
47
|
+
> (由一次未完成的发布预占,`npm view` 查不到该版本,但 `npm publish` 报
|
|
48
|
+
> `E409 Cannot publish over previously staged version`),该编号已无法复用。
|
|
9
49
|
|
|
10
50
|
### Fixes
|
|
11
51
|
|
package/README.en.md
CHANGED
|
@@ -23,30 +23,36 @@
|
|
|
23
23
|
<a href="https://dshfind.com/plugins/dingminhua/dsh-connect-trae"><img src="https://dshfind.com/api/badge/dingminhua/dsh-connect-trae" alt="dshfind plugin"></a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
|
-
A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle plugin that connects locally signed-in Trae CN
|
|
26
|
+
A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle plugin that connects locally signed-in Trae models (**both CN and international installs**) to the DSH model picker. Trae generates structured tool calls while DSH executes its own local tools, with a read-only usage overview (Work/general credits on CN, subscription status on international) and model-management panel. **The CN and international sides are two parallel providers (`trae` / `trae-global`) that can be used at the same time**; the settings card separates them with tabs for convenient management.
|
|
27
27
|
|
|
28
28
|
## Features
|
|
29
29
|
|
|
30
|
-
- **
|
|
30
|
+
- **Dual parallel providers** — the CN side registers as the `trae` provider (e.g. `DeepSeek-V4-Flash`, `DeepSeek-V4-Pro`), the international side as `trae-global` (the Gemini/GPT/MiniMax roster), and **both rosters appear in the DSH model picker simultaneously**: different sessions can each pick a side without interfering.
|
|
31
|
+
- **Tabbed settings card** — the card's top carries a "Domestic / Global" tab bar; each tab holds its own account picker, usage overview, and model management. Account, directory, selection, and unsaved drafts are fully isolated per tab — switching accounts or refreshing models on one tab never touches the other side's runtime catalog or sessions.
|
|
31
32
|
- **Multiplier in the model name** — model names show the credit multiplier in Trae's own menu format (e.g. `GLM-5.2 · x0.79`), updated with each directory refresh.
|
|
32
33
|
- **DSH local tool loop** — gets pending structured `tool_calls` from Trae `llm_utils_chat`, lets DSH execute its own local tools, then returns tool results to the model.
|
|
33
|
-
- **
|
|
34
|
-
- **
|
|
35
|
-
- **
|
|
34
|
+
- **Dual-region detection (CN / international)** — detects local sign-ins across Trae CN, TRAE SOLO CN, Trae, and TRAE SOLO installs. The region is derived from the credential's own `userRegion` claim (host suffix and edition label as fallbacks), with no manual switch.
|
|
35
|
+
- **Region-isolated directories and selections** — CN and international each keep their own model directory, enabled picks, image opt-ins, and context budgets, and each provider reads only its own slot.
|
|
36
|
+
- **Account switching** — refreshes the token list and lets users select an account without storing tokens in DSH settings.
|
|
37
|
+
- **Read-only usage and model management** — Work/general credits on CN accounts, subscription/trial status on international ones; enable Trae models freely. Read-only queries consume nothing.
|
|
38
|
+
- **Secure loopback shim** — one random port + in-process random secret per region; the real Trae token is never handed to pi-ai.
|
|
36
39
|
|
|
37
40
|
## How it works
|
|
38
41
|
|
|
39
42
|
```text
|
|
40
|
-
DSH PiAiAdapter
|
|
41
|
-
-> secure loopback shim
|
|
43
|
+
DSH PiAiAdapter (one stack per provider)
|
|
44
|
+
-> secure loopback shim (one random port + in-process random secret per region)
|
|
42
45
|
-> TraeSoloBridge
|
|
43
|
-
-> https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
46
|
+
-> CN: https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
47
|
+
-> Global: https://coresg-normal.trae.ai/api/agent/v3/llm_utils_chat
|
|
44
48
|
-> Trae SSE / pending function_call
|
|
45
49
|
-> OpenAI SSE tool_calls
|
|
46
50
|
-> DSH executes local tools and returns their results
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
The CN and international sides each own a complete runtime stack — credential store, model catalog, wire map, upstream clients, loopback shim, adapter — with visibility filtered by the credential's own region claim, so **both regions' accounts can be signed in and used by different sessions at the same time**.
|
|
54
|
+
|
|
55
|
+
Usage overview hits the read-only `https://api.trae.cn/trae/api/v2/pay/*` and `/trae/api/v2/ug/*` endpoints (international accounts read their own gateway's subscription status). Refreshed tokens are kept per region in `$DSH_HOME/.trae-auth.cn.json` and `$DSH_HOME/.trae-auth.ai.json` (two simultaneously signed-in accounts never overwrite each other; the legacy single file `.trae-auth.json` is still read as a migration source).
|
|
50
56
|
|
|
51
57
|
> See `docs/IMPLEMENTATION_PLAN.md`, `docs/SOLO_ROUTE_DECISION.md`, `docs/USAGE_API_RESEARCH.md`.
|
|
52
58
|
|
package/README.md
CHANGED
|
@@ -23,30 +23,36 @@
|
|
|
23
23
|
<a href="https://dshfind.com/plugins/dingminhua/dsh-connect-trae"><img src="https://dshfind.com/api/badge/dingminhua/dsh-connect-trae" alt="dshfind plugin"></a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
|
-
一个独立的 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle 插件。它把本机已登录的 Trae
|
|
26
|
+
一个独立的 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle 插件。它把本机已登录的 Trae 账号(**国内版与国际版均支持**)接到 DSH 的模型选择器:模型负责生成结构化工具调用,`bash` / `read` / `write` / `edit` 等工具由 DSH 本地执行;同时提供**只读**的用量概览(国内版 Work/通用积分、国际版订阅状态)与模型管理界面。**国内版与国际版是两个并行的供应商(`trae` / `trae-global`),可同时使用**;插件设置卡片以 tab 区分两者,方便统一管理。
|
|
27
27
|
|
|
28
28
|
## 功能特性
|
|
29
29
|
|
|
30
|
-
-
|
|
30
|
+
- **双供应商并行接入** —— 国内版注册为 DSH 的 `trae` provider(`DeepSeek-V4-Flash`、`DeepSeek-V4-Pro` 等),国际版注册为 `trae-global`(Gemini / GPT / MiniMax 阵容),**两边模型同时出现在 DSH 模型选择器里**:不同会话可以各选一边,互不干扰。
|
|
31
|
+
- **插件卡片 tab 切换** —— 设置卡片顶部为「国内版 / 国际版」两个 tab,各含独立的账号选择、用量概览与模型管理;每个 tab 的账号、目录、勾选与未保存草稿完全隔离——在一个 tab 里切账号或刷新模型,不会触碰另一边的运行时目录与会话。
|
|
31
32
|
- **倍率内嵌模型名** —— 模型名称按 Trae 自身菜单的格式显示积分倍率(如 `GLM-5.2 · x0.79`),倍率随目录刷新更新。
|
|
32
33
|
- **DSH 本地工具循环** —— 通过 Trae `llm_utils_chat` 获取待执行的结构化 `tool_calls`,交由 DSH 自带的本地工具执行,再将工具结果回传模型。
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
34
|
+
- **国内国际双区域自动识别** —— 自动发现 Trae CN / TRAE SOLO CN / Trae / TRAE SOLO 四个本地安装的登录账号;区域由凭证自带的 `userRegion` 声明自动判定(host 后缀与 edition 标签兜底),无需手动指定。
|
|
35
|
+
- **目录与勾选按区域隔离** —— 国内版与国际版各一套模型目录、勾选、图片开关与上下文预算,两个供应商各自读各自的槽位。
|
|
36
|
+
- **多账号切换** —— 支持重新读取 Token 列表并选择账号;Token 不写入 DSH 设置。
|
|
37
|
+
- **只读用量与模型管理** —— 国内版查看 Work 积分与通用积分,国际版查看订阅/试用状态;刷新/启用 Trae 模型;只读查询不消耗额度。
|
|
38
|
+
- **安全 loopback shim** —— 每区域一个随机端口 + 进程内随机 secret,真实 Trae token 不交给 pi-ai。
|
|
36
39
|
|
|
37
40
|
## 工作原理
|
|
38
41
|
|
|
39
42
|
```text
|
|
40
|
-
DSH PiAiAdapter
|
|
41
|
-
-> 安全 loopback shim
|
|
43
|
+
DSH PiAiAdapter(每个 provider 一套)
|
|
44
|
+
-> 安全 loopback shim(每区域一个随机端口 + 进程内随机 secret)
|
|
42
45
|
-> TraeSoloBridge
|
|
43
|
-
-> https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
46
|
+
-> 国内版 https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
47
|
+
-> 国际版 https://coresg-normal.trae.ai/api/agent/v3/llm_utils_chat
|
|
44
48
|
-> Trae SSE / pending function_call
|
|
45
49
|
-> OpenAI SSE tool_calls
|
|
46
50
|
-> DSH 本地执行工具并回传结果
|
|
47
51
|
```
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
国内版与国际版各持一套完整的运行时栈——凭据 store、模型 catalog、wire 映射、上游客户端、回环 shim、adapter——按凭证自带的区域声明隔离可见账号,所以**两个区域的账号可以同时在线、同时被不同会话使用**。
|
|
54
|
+
|
|
55
|
+
用量概览走 `https://api.trae.cn/trae/api/v2/pay/*` 与 `/trae/api/v2/ug/*` 只读接口(国际账号走其自有网关的订阅状态端点)。刷新得到的 token 按区域存放在 `$DSH_HOME/.trae-auth.cn.json` 与 `$DSH_HOME/.trae-auth.ai.json`(两个账号同时在线互不覆盖;旧的单文件 `.trae-auth.json` 作为迁移来源保留读取)。
|
|
50
56
|
|
|
51
57
|
> 详见 `docs/IMPLEMENTATION_PLAN.md`、`docs/SOLO_ROUTE_DECISION.md`、`docs/USAGE_API_RESEARCH.md`。
|
|
52
58
|
|