dsh-connect-trae 1.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 +39 -0
- package/LICENSE +21 -0
- package/README.en.md +76 -0
- package/README.md +95 -0
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/cordis.patch.yml +4 -0
- package/docs/assets/dsh-connect-trae-usage-card.png +0 -0
- package/lib/client.js +752 -0
- package/lib/index.d.ts +975 -0
- package/lib/index.js +3118 -0
- package/package.json +111 -0
- package/screenshots.json +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-08-30)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- 首个稳定版本:将本机当前登录的 Trae 中国区模型接入 DSH,并通过安全 loopback shim 提供模型调用。
|
|
8
|
+
- 接入 `llm_utils_chat` 原生函数调用通道,将 Trae `function_call` 转换为 DSH 可执行的 OpenAI `tool_calls`,支持工具结果回传与连续 Agent 循环。
|
|
9
|
+
- 自动发现 Trae CN / TRAE SOLO CN 本地登录账号,支持刷新 Token 列表、选择账号,并优先使用具有通用积分的账号。
|
|
10
|
+
- 提供 DSH Connect Trae 插件卡片,分别展示 Work 积分与 DSH 可使用的通用积分,并支持模型目录刷新和启用选择。
|
|
11
|
+
- 支持 DeepSeek-V4-Flash 等 Trae 模型、只读用量接口及中英文界面。
|
|
12
|
+
|
|
13
|
+
### Fixes
|
|
14
|
+
|
|
15
|
+
- 凭据选择优先使用可供 `llm_utils_chat` 计费的通用积分账号;单个损坏、过期或已退出的本地凭据不会阻断其他账号。
|
|
16
|
+
- 规范化 DSH 的 `developer` 消息角色为 Trae 接受的 `system`,避免模型请求持续 400 重试。
|
|
17
|
+
- 正确处理 Trae 流式错误事件,配额错误不再被误报为 `EMPTY_RESPONSE`。
|
|
18
|
+
|
|
19
|
+
### Docs
|
|
20
|
+
|
|
21
|
+
- 发布元数据、双语 README、发布流程、第三方 Trae 相关项目声明与 npm 打包白名单均已补齐。
|
|
22
|
+
- 项目以 MIT 许可证发布,版权归属明确为 `Copyright (c) 2026 LaoDing`。
|
|
23
|
+
|
|
24
|
+
## 0.1.0-dev.1 (2026-08-28)
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
- **新版 SOLO 远程会话通道**:`TraeSoloRemoteClient` + `TraeSoloRemoteBridge`,把 `solo.trae.cn/api/remote/v1/chat_sessions` 的轮询结果转换为 OpenAI SSE,接入安全 loopback shim,成为第一可用上游路线。
|
|
29
|
+
- **本地模型目录**:`DeepSeek-V4-Flash` / `DeepSeek-V4-Pro` / `Doubao_1_6` / `kimi-k2.6` / `qwen-3.6-plus` / `glm-5.1` / `minimax-m2.7`。
|
|
30
|
+
- **只读用量概览**:`TraeUsageClient` 查询总可用额度、积分来源、每日签到与奖励活动(`web_user_ent_usage` / `checkin_credits/status` / `activity/info`),只读、不消耗积分。
|
|
31
|
+
- **插件设置卡片**(对齐 `dsh-subagent-default-model` 外部形象):在 `settings.plugin.item` 注册折叠卡片(key `trae`),带 LD 品牌图标与 `dsm-plugin-card` 卡片外壳,展开后展示总可用/已消耗、各项积分进度条、每日签到与奖励活动;Host 侧通过 `webServer` 只读路由 `/plugins/dsh-connect-trae/usage` 提供脱敏数据。
|
|
32
|
+
- **SSE 扩展**:解析 `token_usage` 与 `tool_calls` 事件。
|
|
33
|
+
- **安全骨架**:随机 loopback 端口、进程内随机 secret、Host/Origin/Content-Type 校验、请求取消、body 上限。
|
|
34
|
+
|
|
35
|
+
### Docs
|
|
36
|
+
|
|
37
|
+
- 新增 `docs/SOLO_ROUTE_DECISION.md`、`docs/USAGE_API_RESEARCH.md`、`docs/HANDOFF.md`。
|
|
38
|
+
- README 中英双语双文件,对齐插件外部形象标准。
|
|
39
|
+
- 新增 `THIRD_PARTY_NOTICES.md` 第三方开源声明:只记录与 Trae 接入直接相关的架构/协议参考项目及其许可证与合规说明;README 增加对应章节,发布包 `files` 白名单纳入该文件。
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LaoDing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# dsh-connect-trae
|
|
2
|
+
|
|
3
|
+
[English](README.en.md) | 中文
|
|
4
|
+
|
|
5
|
+
A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle plugin that connects locally signed-in Trae CN models to the DSH model picker. Trae generates structured tool calls while DSH executes its own local tools, with a read-only Work/general credits and model-management panel.
|
|
6
|
+
|
|
7
|
+
## Preview
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="docs/assets/dsh-connect-trae-usage-card.png" alt="DSH Connect Trae plugin card showing account selection, Work and general credits, and model management" width="900">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center"><sub>Settings → Plugins → DSH Connect Trae: switch local Trae accounts, view Work/general credits, and manage the Trae models enabled in DSH.</sub></p>
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Trae model provider** — registers locally signed-in Trae models as the `trae` provider (e.g. `DeepSeek-V4-Flash`, `DeepSeek-V4-Pro`).
|
|
18
|
+
- **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.
|
|
19
|
+
- **Trae CN account switching** — detects local Trae CN and TRAE SOLO CN sign-ins, refreshes the token list, and lets users select an account without storing tokens in DSH settings.
|
|
20
|
+
- **Read-only credits and model management** — shows Work credits separately from the general credits usable by DSH, and manages which Trae models are enabled. Read-only queries do not consume credits.
|
|
21
|
+
- **Secure loopback shim** — random port + in-process random secret; the real Trae token is never handed to pi-ai.
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
DSH PiAiAdapter
|
|
27
|
+
-> secure loopback shim
|
|
28
|
+
-> TraeSoloBridge
|
|
29
|
+
-> https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
30
|
+
-> Trae SSE / pending function_call
|
|
31
|
+
-> OpenAI SSE tool_calls
|
|
32
|
+
-> DSH executes local tools and returns their results
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Usage overview hits the read-only `https://api.trae.cn/trae/api/v2/pay/*` and `/trae/api/v2/ug/*` endpoints.
|
|
36
|
+
|
|
37
|
+
> See `docs/IMPLEMENTATION_PLAN.md`, `docs/SOLO_ROUTE_DECISION.md`, `docs/USAGE_API_RESEARCH.md`.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
dsh plugin --profile desktop add dsh-connect-trae
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or directly via npm:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install dsh-connect-trae
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Restart the DSH process after install/update/uninstall.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
pnpm install
|
|
57
|
+
pnpm run check # typecheck + test + build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Local dev via a `link:` install to the desktop profile (restart DSH Desktop after editing):
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-connect-trae
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Acknowledgements
|
|
67
|
+
|
|
68
|
+
- [Wang-JQ77/dsh-trae-api](https://github.com/Wang-JQ77/dsh-trae-api) (MIT) — Reference implementation for research into Trae authentication, sessions, and model protocols.
|
|
69
|
+
|
|
70
|
+
## Third-party open-source dependencies
|
|
71
|
+
|
|
72
|
+
The open-source projects referenced for Trae integration (architecture/protocol research), together with their licenses and compliance notes, are recorded in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). When introducing new Trae-related external dependencies or reusing code from other projects, update that file accordingly and honor the upstream licenses.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
This project is licensed under the [MIT License](LICENSE). Copyright: **Copyright (c) 2026 LaoDing**.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<b>dsh-connect-trae</b>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">dsh-connect-trae</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><b>把本机登录的 Trae 模型接入 DeepSeek Harness,并提供只读的用量/积分概览。</b></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="README.en.md">English</a> ·
|
|
11
|
+
<a href="#安装">安装</a> ·
|
|
12
|
+
<a href="#工作原理">工作原理</a> ·
|
|
13
|
+
<a href="CHANGELOG.md">更新日志</a> ·
|
|
14
|
+
<a href="https://github.com/dingminhua/dsh-connect-trae/issues">问题反馈</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://www.npmjs.com/package/dsh-connect-trae"><img src="https://img.shields.io/npm/v/dsh-connect-trae?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
|
|
19
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/dingminhua/dsh-connect-trae?style=flat-square" alt="MIT license"></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
一个独立的 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bundle 插件。它把本机已登录的 Trae 中国区账号接到 DSH 的模型选择器:模型负责生成结构化工具调用,`bash` / `read` / `write` / `edit` 等工具由 DSH 本地执行;同时提供**只读**的 Work/通用积分与模型管理界面。
|
|
23
|
+
|
|
24
|
+
## 效果预览
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img src="docs/assets/dsh-connect-trae-usage-card.png" alt="DSH Connect Trae 插件卡片:Trae 账号、Work 与通用积分以及模型管理" width="900">
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<p align="center"><sub>设置 → 插件配置 → DSH Connect Trae:切换本机 Trae 账号、查看 Work/通用积分,并管理 DSH 中启用的 Trae 模型。</sub></p>
|
|
31
|
+
|
|
32
|
+
## 功能特性
|
|
33
|
+
|
|
34
|
+
- **Trae 模型接入** —— 把本机登录的 Trae 模型注册为 DSH 的 `trae` provider,模型选择器出现 `DeepSeek-V4-Flash`、`DeepSeek-V4-Pro` 等。
|
|
35
|
+
- **DSH 本地工具循环** —— 通过 Trae `llm_utils_chat` 获取待执行的结构化 `tool_calls`,交由 DSH 自带的本地工具执行,再将工具结果回传模型。
|
|
36
|
+
- **中国区多账号切换** —— 自动发现 Trae CN 与 TRAE SOLO CN 本地登录账号,支持重新读取 Token 列表并选择账号;Token 不写入 DSH 设置。
|
|
37
|
+
- **只读积分与模型管理** —— 插件设置面板可分别查看 Work 积分与 DSH 可使用的通用积分,并刷新/启用 Trae 模型;只读查询不消耗积分。
|
|
38
|
+
- **安全 loopback shim** —— 随机端口 + 进程内随机 secret,真实 Trae token 不交给 pi-ai。
|
|
39
|
+
|
|
40
|
+
## 工作原理
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
DSH PiAiAdapter
|
|
44
|
+
-> 安全 loopback shim
|
|
45
|
+
-> TraeSoloBridge
|
|
46
|
+
-> https://trae-api-cn.mchost.guru/api/agent/v3/llm_utils_chat
|
|
47
|
+
-> Trae SSE / pending function_call
|
|
48
|
+
-> OpenAI SSE tool_calls
|
|
49
|
+
-> DSH 本地执行工具并回传结果
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
用量概览走 `https://api.trae.cn/trae/api/v2/pay/*` 与 `/trae/api/v2/ug/*` 只读接口。
|
|
53
|
+
|
|
54
|
+
> 详见 `docs/IMPLEMENTATION_PLAN.md`、`docs/SOLO_ROUTE_DECISION.md`、`docs/USAGE_API_RESEARCH.md`。
|
|
55
|
+
|
|
56
|
+
## 安装
|
|
57
|
+
|
|
58
|
+
推荐使用 DSH 插件命令安装 npm 已发布版本:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
dsh plugin --profile desktop add dsh-connect-trae
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
或直接通过 npm 安装:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
npm install dsh-connect-trae
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
安装、更新或卸载 bundle 后,需要重启对应的 DSH 进程。
|
|
71
|
+
|
|
72
|
+
## 开发
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pnpm install
|
|
76
|
+
pnpm run check # typecheck + test + build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
本地开发用 `link:` 安装到 desktop profile(改码后重启 DSH Desktop 生效):
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
dsh plugin --profile desktop add /Users/dmh2002/DshProject/dsh-connect-trae
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 致谢
|
|
86
|
+
|
|
87
|
+
- [Wang-JQ77/dsh-trae-api](https://github.com/Wang-JQ77/dsh-trae-api)(MIT)— Trae 认证、会话和模型协议研究的参照实现。
|
|
88
|
+
|
|
89
|
+
## 第三方开源依赖
|
|
90
|
+
|
|
91
|
+
本项目参考的与 Trae 接入直接相关的开源项目,以及它们的许可证与合规说明,见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。引入新的 Trae 相关外部依赖或复用其他项目代码时,请同步更新该文件并遵守对应许可证要求。
|
|
92
|
+
|
|
93
|
+
## 许可证
|
|
94
|
+
|
|
95
|
+
本项目采用 [MIT](LICENSE) 许可证,版权归属:**Copyright (c) 2026 LaoDing**。
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 第三方开源声明(Third-Party Notices)
|
|
2
|
+
|
|
3
|
+
> 本文件只记录与 Trae 接入直接相关的开源项目及其许可证,确保符合各上游项目的开源许可要求(署名保留、许可文本随分发携带等)。通用平台与构建依赖(`@deepseek-ai/*`、`react`、`typescript`、`tsdown`、`vitest` 等)的许可证随各自 npm 包自动携带,不属于本文档记录范围。若你对本文件的完整性有疑问或发现遗漏,请提交 issue 或 PR。
|
|
4
|
+
|
|
5
|
+
## 与 Trae 接入相关的参考项目
|
|
6
|
+
|
|
7
|
+
本项目在设计与实现过程中参考了以下与 Trae 接入直接相关的开源项目,主要用于**架构模式与上游协议研究**。参考方式为"借鉴设计思路 + 独立实现",未整体复制其源码(关键模块均为本项目独立编写,并在源码注释中标注了所参考的既有模式)。这些项目的版权属于其各自的作者,本项目代码不构成对它们的再分发。
|
|
8
|
+
|
|
9
|
+
| 参考项目 | 仓库 | 参考内容 | 许可证 |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `dsh-trae-api` | <https://github.com/Wang-JQ77/dsh-trae-api> | Trae 上游协议(认证、会话、模型目录)的参考与失败样本分析(见 `docs/ANALYSIS.md`、`docs/ANALYSIS_CONCLUSION.md`、`docs/SOLO_ROUTE_DECISION.md`) | MIT |
|
|
12
|
+
| `laojichao/trae-local-api` | <https://github.com/laojichao/trae-local-api> | `dsh-trae-api` 的直接上游,仅作为 Trae 协议调研线索,本项目未复用其代码(见 `docs/SOLO_ROUTE_DECISION.md`) | 未声明(保留所有权利) |
|
|
13
|
+
|
|
14
|
+
## 合规说明
|
|
15
|
+
|
|
16
|
+
- `dsh-trae-api` 使用 **MIT** 宽松许可,与项目自身的 MIT 许可证兼容;`laojichao/trae-local-api` 未声明许可证(保留所有权利),本项目仅将其作为协议调研线索,未复制、修改或分发其代码。
|
|
17
|
+
- MIT 许可要求保留上游版权声明。本项目**不重新打包或再分发**上述参考项目的源码,仅参考其架构思路与协议信息;`docs/` 中的分析文档亦为独立撰写。
|
|
18
|
+
- 若后续引入新的与 Trae 接入相关的依赖或复用其他项目的代码,必须在引入时同步更新本文件,并遵守对应许可证的署名与声明要求。
|
package/cordis.patch.yml
ADDED
|
Binary file
|