dsh-connect-trae 2.0.6 → 2.2.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 +62 -0
- package/README.en.md +25 -3
- package/README.md +25 -3
- package/lib/client.js +293 -38
- package/lib/index.d.ts +147 -5
- package/lib/index.js +225 -41
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.0 (2026-09-24)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
- **支持 DSH 0.1.7 线,且同一个构建同时服务 0.1.5 与 0.1.7**(修复 [issue #13](https://github.com/dingminhua/dsh-connect-trae/issues/13))。这不是「多支持一个版本」的可选增强——**在 0.1.7 上插件的浏览器半侧此前根本不激活**:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
web boot: 1 entry did not activate
|
|
11
|
+
dsh-connect-trae: pending (waiting for service: settingsScope)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- **根因:`settingsScope` 被整个移除,而 Cordis 的依赖闸门是硬闸。** DSH **0.1.7-alpha.1** 起客户端设置服务换成 `configForms`,`settingsScope` **不再存在**(不是弃用、没有兼容层;0.1.6-alpha.2 还有,0.1.7-alpha.1 起包内已无此符号)。插件 `inject` 里仍声明它,于是 fiber 永远停在 `PENDING`——**不是某个功能坏掉,是整个客户端插件不激活**,因此「重新登录」「重装插件」一概无效。修法与 workbuddy 一致:`inject` 收窄为两条线都有的 `['slots', 'locale']`,设置面改由 `ctx.get()` **按能力软探测**(属性访问会抛 `cannot get property X without inject`,`?.` 挡不住;`ctx.get` 对缺失服务返回 `undefined`)。
|
|
15
|
+
- **0.1.7 上另有三处断裂,issue 只报了第一处。** 逐项对照 workbuddy 的实测(该仓库已用同一套适配跑通 0.1.7):
|
|
16
|
+
|
|
17
|
+
| # | 位置 | 0.1.5 | 0.1.7 |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| 1 | 客户端设置服务 | `settingsScope` | `configForms` |
|
|
20
|
+
| 2 | 客户端槽位名 | `settings.plugin.item` | `plugins.bundle.config` / `plugins.row.config` |
|
|
21
|
+
| 3 | 宿主端注册 | `installSection()` | `configure({auto}, owner)` |
|
|
22
|
+
| 4 | schema 可写声明 | 无需 | 必须标 `volatile()` |
|
|
23
|
+
| 5 | primitives 图标名 | `…Outline14` | `…OutlineRegular` |
|
|
24
|
+
|
|
25
|
+
- **第 2 条(槽位名)最容易被漏掉**:两条线声明的槽位集合**互不相交**(0.1.5 只有 `settings.plugin.item`;0.1.7 只有 `plugins.*`)。就算设置服务改对了,槽位名不改卡片依然渲染不出来。现在三个槽位**各自独立 try/catch** 逐个注册——一条线上不存在的槽位不能把另一条线的注册一起带走。
|
|
26
|
+
- **第 3 条(宿主端)在 0.1.7 上是静默失败**:`installSection` 被 `SettingsForms.configure()` 取代。由于该调用位于嵌套的 `ctx.inject` 回调内,抛出的 `installSection is not a function` 落在**那个子 fiber** 上——外层插件照常加载、两个 provider 照常注册,**但 `trae` 设置命名空间从未注册**,表现为卡片设置区无声消失。现在按能力探测:有 `configure` 走 `configure`,否则回落 `installSection`。
|
|
27
|
+
- **第 4 条(易失声明)**:0.1.7 的 settings 写入门要求插件 schema 把可写字段标为 volatile,否则**写入被直接拒绝**(`Plugin entry "trae" has no volatile fields`),而 `scope.set()` 却正常 resolve——用户会看到开关翻过去又静默复原。新增 `asVolatile()`:运行时探测 `schema.volatile()`,**有则调用、无则退化为 identity no-op**(`volatile()` 自 schemastery 3.18.3 起才有,0.1.5 线锁在 3.18.2)。**故意不手写 `meta.volatile = true`**——那会绕过 schemastery 自身的 `validateVolatileSchema` 校验,产出一个它自己都不认的 schema。
|
|
28
|
+
- **0.1.7 以「活引用」交付配置值。** 该线把 volatile 字段以 `{get(): T}` 形式交给消费方;不解包则 `config.regions`、`value.accounts[region]`、`config.authFile` 静默变成对象或 `undefined`,表现为「设置明明写了却读不到」。更隐蔽的是**展开一个活引用得到的是 `{get: <function>}` 而不是值**——卡片「写一个区域、保留另一个」的合并会因此**丢掉兄弟区域并把函数泄进设置文档**。新增 `unwrapVolatile()` / `unwrapVolatileDeep()` 并在所有读取与合并路径上解包,同时监听 `loader/volatile-update` 在每次写入后重读选择。
|
|
29
|
+
- **第 5 条(图标)会让整个客户端包挂掉**:两条线 primitives 的图标名不重叠(`IconChevronDownOutline14` vs `IconChevronDownOutlineRegular`),**没有任何一个静态 import 能同时服务两边**——静态导入 0.1.5 的名字会让 0.1.7 上的客户端包解析失败,整个卡片随之消失。折叠箭头改为**纯 CSS caret**(`border` + `rotate`),与版本无关。
|
|
30
|
+
- **设置写入改为「写入后回读校验」**:`set()` 的 promise resolve **不代表值已落盘**(0.1.7 上被拒绝的写入会重新加载 Host 状态然后正常返回,0.1.5 上则可能被文件占用丢弃)。四处写入(账号选择、账号重扫、区域开关、模型目录)统一走 `writeSettingsField()`:写入后回读,未落盘即抛错并在卡片上明确显示,而不是「点了没反应」。0.1.7 的 `set()` 还会返回显式布尔值,`false` 同样按拒绝处理。
|
|
31
|
+
- **卡片的 `view` 属性**:0.1.7 的插件管理器通过 owner props 向每个配置条目索取两种视图(`summary` 一句话简介 / `page` 带保存控件的完整表单)。卡片接受该属性并在 `page` 下默认展开——否则在 0.1.7 的插件页里卡片会是折叠的一行。
|
|
32
|
+
- **开发环境的 schemastery 从 3.18.2 提到 3.18.4**(`pnpm-workspace.yaml` 的 override,与 `devDependencies` 对齐)。此前 dev 树锁在 3.18.2,那里没有 `volatile()`,`asVolatile()` 退化为 no-op——**于是 volatile 真正生效的那条路径(每个 0.1.7 用户都会走的那条)在本地从未被执行过**,这类缺陷可以同时躲过评审与 CI。这与 workbuddy 记录的教训同源。
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
|
|
36
|
+
测试总数 282 → 310。
|
|
37
|
+
|
|
38
|
+
- **新增 `tests/client-activation.spec.tsx`(3 例,本次最关键的一组)**:用真实的 cordis `Context` **启动真实的客户端入口模块**,分别对 0.1.7 形态(有 `configForms`、**无** `settingsScope`)、0.1.5 形态(有 `settingsScope`、无 `configForms`)、以及**两者都没有**的形态断言 fiber 到达 `ACTIVE`、槽位注册齐全、scope 取自正确的服务。之所以能直接导入真实入口,是因为它运行期只依赖 React 与本地文件,所有 DSH 包都是**类型导入**、构建时即被擦除。
|
|
39
|
+
- 此前 `client-fallback.spec.ts` 抓不到这个缺陷:它**手工镜像**入口函数体,因此验证的是「思路」而**从不执行真实的 `inject` 数组**——而恰恰是那个数组让 fiber 卡在 PENDING。
|
|
40
|
+
- **变异验证**:把 `inject` 改回 `['slots','locale','settingsScope']`,0.1.7 与「无设置面」两例立即变红(fiber 停在 0/1,永远到不了 `ACTIVE`),0.1.5 那例仍绿——精确复现了 issue 报的现象。
|
|
41
|
+
- **新增 `tests/dsh-017-compat.spec.ts`(13 例)**:活引用的单层/深层解包、数组与嵌套、**不就地改写调用方对象**;`regionEnabledOf` / `regionStateOf` / `regionEnabled` 穿透活引用读值;合并时**保留兄弟区域且不泄露函数**;`asVolatile()` 的两条分支按运行时能力确定性断言;以及**宿主端 `configure()` 优先于 `installSection()`**(用一个只有 `configure` 的真 Service 装配,断言走的是 `configure({auto:true})` 且没有 `installSection` 报错)。
|
|
42
|
+
- **变异验证**:把 `configure` 探测改回无保护裸调 `installSection` → 1 条立即变红;把 `nextRegionSlots` 的深解包去掉 → 1 条立即变红。
|
|
43
|
+
- `client-fallback.spec.ts` 的镜像同步更新,并补 2 例:**两条线都提供时 `configForms` 优先**(0.1.7 的写入闸门只认它),以及 **`configForms` 缺席时回落 `settingsScope.bind()`**。
|
|
44
|
+
- **`card-region-switch.spec.tsx` 新增 8 例**(渲染真组件、点真按钮):穿透活引用读区域开关;合并时**保留兄弟区域且不泄露函数**;Host 明确拒绝(`set()` 返回 `false`)与**「接受了但没落盘」**(`set()` 返回 `true` 而文档未变)两种失败都必须显式报错;0.1.5 的 `void` 返回视为成功;`view: 'page'` 时默认展开、无 `view` 时默认折叠;无设置面时渲染为只读。
|
|
45
|
+
- **变异验证**:去掉 `regionsMapOf` 的解包 → 1 条失败;去掉 `view` 判断 → 1 条失败;去掉 `false` 判断 → 0 条失败(回读校验兜住了,说明两层防护确实互补);去掉回读校验 → 1 条失败;**两层都去掉 → 1 条失败**。
|
|
46
|
+
- 顺带移除了该文件对 `dsh-client-ui-primitives` 的整包 `vi.mock`:图标已改纯 CSS,不再需要这个桩。
|
|
47
|
+
|
|
48
|
+
**双版本验证**:同一份代码在 schemastery **3.18.4**(volatile 生效)与 **3.18.2**(no-op 分支)下**均为 310 通过**。
|
|
49
|
+
|
|
50
|
+
## 2.1.0 (2026-09-24)
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
- **新增「每日签到领取」**(对齐 `dsh-connect-workbuddy` 的签到能力):
|
|
55
|
+
- **交互**:国内版卡片在积分面板下方多一行签到:显示每日奖励(基础 + 额外,本机实测 `150 + 50`)与一个「立即领取」按钮;领取中显示「领取中…」,当日已领取显示「今日已领取」并禁用。国际版没有签到活动,因此**不显示该行**。
|
|
56
|
+
- **这是插件里唯一的写操作**,也是唯一会改变账号状态的调用(`POST /trae/api/v2/ug/checkin_credits/claim`);其余查询全部只读。README 顶部与特性列表都按此措辞改写,不再把整个用量面板称为「只读」。
|
|
57
|
+
- **根因级发现:缺 `x-device-id` 会被静默拒绝**。同一份 Authorization,只加这一个头,结果从「HTTP 200 + 业务码 `9004`(The submitted order parameters are incorrect)」变成「`code: 0`,奖励到账」——**HTTP 状态始终是 200**,只看状态码会把它误判为成功。设备号取自本机 `iCubeAuthInfo://icube-dc:<id>`,即 `identity.ts` 里聊天通道同源的那个 `deviceId`(官方客户端在 `main.js` 的 `fb(headers)` 里给每个 ug 请求都补上它)。`deviceId` 由 `index.ts` 惰性注入;读不到时降级为不发该头——**只影响领取,不影响状态查询**(状态接口两种情况下都正常返回)。
|
|
58
|
+
- **领取前的守卫比上游更强**:路由 `POST /plugins/dsh-connect-trae/checkin` 仅接受 POST、仅接受回环来源、仅服务 `cn` 区域,并且**先读状态**——已领取(`checked_in` 或 `did_checked_in` 任一为真)就直接返回 `alreadyCheckedIn` 且**根本不发领取请求**;活动关闭答 409。国际版直接答 404 并说明原因,而不是把上游的 HTML 404 当成网络故障抛给用户。
|
|
59
|
+
- **已实测上游按北京自然日幂等**:重复领取仍回 `code: 0`,而权益总额(`total=1600, consumed=390.8`)逐字节不变,**不会重复发放**。插件仍然自行守卫——「不会重复发放」是上游的行为,不是插件可以依赖的保证。
|
|
60
|
+
- **业务拒绝不当成故障**:`claimed: false` + 原始业务码与 message 原样回给卡片并显示出来,而不是包成 500。否则用户只会看到「领取失败」,而丢掉唯一能解释原因的 `9004`。
|
|
61
|
+
- **对齐官方客户端的状态判定**:`checked_in` 与 `did_checked_in` 是**两个独立字段**,官方在「今日已领取」上同时看后者(即使状态读回 `checked_in: false` 也保持按钮禁用)。插件在**卡片与路由两侧都**按同一规则判定,`extra_credits` 也一并展示,避免把当天实际到账的 200 说成 150。
|
|
62
|
+
- 卡片新增 8 条真实点击测试(`tests/card-checkin.spec.tsx`,渲染**真组件**、`fireEvent.click` 真按钮、断言真发出去的请求),`usage.spec.ts` 补 6 条、`web-status.spec.ts` 补 7 条,共 21 条新测试(全仓 261 → 282)。做过**变异验证**:去掉路由的 `did_checked_in` 守卫 → 2 条失败;去掉卡片的同款判定 → 1 条失败;把卡片的 `POST` 改成 `GET` → 1 条失败;删掉「已领取则不发请求」的守卫 → 2 条失败。
|
|
63
|
+
- 取证与接口契约:`docs/USAGE_API_RESEARCH.md` 新增「每日签到领取」一节(含决定性请求头对照表、幂等性实测表、区域限制与官方字段语义)。
|
|
64
|
+
|
|
3
65
|
## 2.0.6 (2026-09-22)
|
|
4
66
|
|
|
5
67
|
### Features
|
package/README.en.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">dsh-connect-trae</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center"><b>Connect locally signed-in Trae models to DeepSeek Harness with local DSH tools and
|
|
7
|
+
<p align="center"><b>Connect locally signed-in Trae models to DeepSeek Harness with local DSH tools, a credits overview, and daily check-in claiming.</b></p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="README.md">中文</a> ·
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
<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>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
|
-
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
|
|
27
|
+
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 usage overview (Work/general credits on CN, subscription status on international), daily check-in claiming, and a 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.
|
|
28
|
+
|
|
29
|
+
> Apart from the daily check-in claim, every query this plugin makes is read-only and consumes nothing; the claim only happens when you click the button.
|
|
28
30
|
|
|
29
31
|
## Features
|
|
30
32
|
|
|
@@ -37,6 +39,7 @@ A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bund
|
|
|
37
39
|
- **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.
|
|
38
40
|
- **Account switching** — refreshes the token list and lets users select an account without storing tokens in DSH settings.
|
|
39
41
|
- **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.
|
|
42
|
+
- **Daily check-in claiming** — a one-click claim on the CN card (the button shows the daily reward, and reads "Claimed today" and disables itself once done). This is the plugin's **only** operation that changes account state, and it runs only when you click. The international side has no check-in activity, so no button is shown there.
|
|
40
43
|
- **Secure loopback shim** — one random port + in-process random secret per region; the real Trae token is never handed to pi-ai.
|
|
41
44
|
|
|
42
45
|
## How it works
|
|
@@ -54,7 +57,7 @@ DSH PiAiAdapter (one stack per provider)
|
|
|
54
57
|
|
|
55
58
|
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**.
|
|
56
59
|
|
|
57
|
-
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).
|
|
60
|
+
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); the daily check-in claim is the one write among them, going to `POST /trae/api/v2/ug/checkin_credits/claim` with this installation's device id (`x-device-id`, the same identity the chat path sends). 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).
|
|
58
61
|
|
|
59
62
|
> See `docs/IMPLEMENTATION_PLAN.md`, `docs/SOLO_ROUTE_DECISION.md`, `docs/USAGE_API_RESEARCH.md`.
|
|
60
63
|
|
|
@@ -91,6 +94,25 @@ npm install dsh-connect-trae
|
|
|
91
94
|
|
|
92
95
|
Restart the DSH process after install/update/uninstall.
|
|
93
96
|
|
|
97
|
+
## DSH version compatibility
|
|
98
|
+
|
|
99
|
+
**One build serves both the DSH 0.1.5 and 0.1.7 lines** — no per-version package.
|
|
100
|
+
|
|
101
|
+
The two lines differ in their settings machinery, and the plugin probes for capability at runtime instead of assuming either:
|
|
102
|
+
|
|
103
|
+
| | 0.1.5 line | 0.1.7 line |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| Client settings service | `settingsScope` | `configForms` |
|
|
106
|
+
| Config card slots | `settings.plugin.item` | `plugins.bundle.config` / `plugins.row.config` |
|
|
107
|
+
| Host registration | `installSection()` | `configure({auto}, owner)` |
|
|
108
|
+
| Schema writable marker | not needed | `volatile()` required |
|
|
109
|
+
| Primitives icon names | `…Outline14` | `…OutlineRegular` |
|
|
110
|
+
|
|
111
|
+
Two decisions matter most:
|
|
112
|
+
|
|
113
|
+
- **`inject` declares only the services BOTH lines provide** (`slots` / `locale`); the settings surface is probed with `ctx.get()`. Cordis' dependency gate is hard — any `inject` entry the running line does not provide keeps `apply()` from ever running (0.1.7 removed `settingsScope`, which is why 2.1.0 and earlier sat at `pending (waiting for service: settingsScope)` on that line).
|
|
114
|
+
- **The collapse caret is pure CSS**, with no static icon import: the two lines' icon names do not overlap, so any static import fails to resolve on one of them.
|
|
115
|
+
|
|
94
116
|
## Windows notes
|
|
95
117
|
|
|
96
118
|
- **Account data directory**: the plugin reads `%APPDATA%\Trae CN` / `%APPDATA%\TRAE SOLO CN` → `User\globalStorage\storage.json` (unrelated to the install directory). The folder names match macOS, so no extra config is needed; if the name does not match, point the `authFile` + `edition` plugin options at the exact path.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">dsh-connect-trae</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center"><b>把本机登录的 Trae 模型接入 DeepSeek Harness
|
|
7
|
+
<p align="center"><b>把本机登录的 Trae 模型接入 DeepSeek Harness,并提供用量/积分概览与每日签到领取。</b></p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="README.en.md">English</a> ·
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
<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>
|
|
25
25
|
</p>
|
|
26
26
|
|
|
27
|
-
一个独立的 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle 插件。它把本机已登录的 Trae 账号(**国内版与国际版均支持**)接到 DSH 的模型选择器:模型负责生成结构化工具调用,`bash` / `read` / `write` / `edit` 等工具由 DSH
|
|
27
|
+
一个独立的 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle 插件。它把本机已登录的 Trae 账号(**国内版与国际版均支持**)接到 DSH 的模型选择器:模型负责生成结构化工具调用,`bash` / `read` / `write` / `edit` 等工具由 DSH 本地执行;同时提供用量概览(国内版 Work/通用积分、国际版订阅状态)、每日签到领取与模型管理界面。**国内版与国际版是两个并行的供应商(`trae` / `trae-global`),可同时使用**;插件设置卡片以 tab 区分两者,方便统一管理。
|
|
28
|
+
|
|
29
|
+
> 除每日签到领取外,插件的所有查询都是只读的、不消耗额度;签到领取也只在你点击按钮时才发生。
|
|
28
30
|
|
|
29
31
|
## 功能特性
|
|
30
32
|
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
- **目录与勾选按区域隔离** —— 国内版与国际版各一套模型目录、勾选、图片开关与上下文预算,两个供应商各自读各自的槽位。
|
|
38
40
|
- **多账号切换** —— 支持重新读取 Token 列表并选择账号;Token 不写入 DSH 设置。
|
|
39
41
|
- **只读用量与模型管理** —— 国内版查看 Work 积分与通用积分,国际版查看订阅/试用状态;刷新/启用 Trae 模型;只读查询不消耗额度。
|
|
42
|
+
- **每日签到领取** —— 国内版卡片上一键领取当日签到积分(按钮显示每日奖励,已领取则显示「今日已领取」并禁用);这是插件里**唯一会改变账号状态**的操作,由你主动点击触发。国际版没有签到活动,因此不显示该按钮。
|
|
40
43
|
- **安全 loopback shim** —— 每区域一个随机端口 + 进程内随机 secret,真实 Trae token 不交给 pi-ai。
|
|
41
44
|
|
|
42
45
|
## 工作原理
|
|
@@ -54,7 +57,7 @@ DSH PiAiAdapter(每个 provider 一套)
|
|
|
54
57
|
|
|
55
58
|
国内版与国际版各持一套完整的运行时栈——凭据 store、模型 catalog、wire 映射、上游客户端、回环 shim、adapter——按凭证自带的区域声明隔离可见账号,所以**两个区域的账号可以同时在线、同时被不同会话使用**。
|
|
56
59
|
|
|
57
|
-
用量概览走 `https://api.trae.cn/trae/api/v2/pay/*` 与 `/trae/api/v2/ug/*`
|
|
60
|
+
用量概览走 `https://api.trae.cn/trae/api/v2/pay/*` 与 `/trae/api/v2/ug/*` 只读接口(国际账号走其自有网关的订阅状态端点);每日签到领取是其中唯一的写操作,走 `POST /trae/api/v2/ug/checkin_credits/claim`,需要携带本机安装的设备号(`x-device-id`,与聊天通道同源)。刷新得到的 token 按区域存放在 `$DSH_HOME/.trae-auth.cn.json` 与 `$DSH_HOME/.trae-auth.ai.json`(两个账号同时在线互不覆盖;旧的单文件 `.trae-auth.json` 作为迁移来源保留读取)。
|
|
58
61
|
|
|
59
62
|
> 详见 `docs/IMPLEMENTATION_PLAN.md`、`docs/SOLO_ROUTE_DECISION.md`、`docs/USAGE_API_RESEARCH.md`。
|
|
60
63
|
|
|
@@ -93,6 +96,25 @@ npm install dsh-connect-trae
|
|
|
93
96
|
|
|
94
97
|
安装、更新或卸载 bundle 后,需要重启对应的 DSH 进程。
|
|
95
98
|
|
|
99
|
+
## DSH 版本兼容
|
|
100
|
+
|
|
101
|
+
**同一个构建同时服务 DSH 0.1.5 与 0.1.7 两条线**,无需按版本安装不同的包。
|
|
102
|
+
|
|
103
|
+
两条线的设置体系不同,插件在运行期按能力探测,而不是假定某一条:
|
|
104
|
+
|
|
105
|
+
| | 0.1.5 线 | 0.1.7 线 |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| 客户端设置服务 | `settingsScope` | `configForms` |
|
|
108
|
+
| 配置卡片槽位 | `settings.plugin.item` | `plugins.bundle.config` / `plugins.row.config` |
|
|
109
|
+
| 宿主端注册 | `installSection()` | `configure({auto}, owner)` |
|
|
110
|
+
| schema 可写声明 | 无需 | 必须标 `volatile()` |
|
|
111
|
+
| primitives 图标名 | `…Outline14` | `…OutlineRegular` |
|
|
112
|
+
|
|
113
|
+
两处关键做法:
|
|
114
|
+
|
|
115
|
+
- **`inject` 只声明两条线都有的服务**(`slots` / `locale`),设置面用 `ctx.get()` 软探测。Cordis 的依赖闸门是硬闸——`inject` 里任一服务在运行线上不存在,`apply()` 就永远不会执行(0.1.7 上 `settingsScope` 已被移除,这正是 2.1.0 及更早版本在 0.1.7 上卡在 `pending (waiting for service: settingsScope)` 的原因)。
|
|
116
|
+
- **折叠箭头用纯 CSS**,不静态导入任何图标:两条线的图标名不重叠,静态导入必然在其中一条线上解析失败。
|
|
117
|
+
|
|
96
118
|
## Windows 说明
|
|
97
119
|
|
|
98
120
|
- **账号数据目录**:插件读取 `%APPDATA%\Trae CN` / `%APPDATA%\TRAE SOLO CN` 下的 `User\globalStorage\storage.json`(与安装目录无关)。目录名与 macOS 一致,无需额外配置;若目录名对不上,可用插件配置项 `authFile` + `edition` 直接指定完整路径。
|