dsh-connect-trae 4.4.6 → 4.4.7
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 +35 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/lib/client.js +96 -29
- package/lib/index.d.ts +78 -0
- package/lib/index.js +90 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.4.7 (2026-10-24)
|
|
4
|
+
|
|
5
|
+
> **4.4.6 把「读不出来的账号副本」改名留住了,但这件事一直是静默的——现在卡片会把它点名,
|
|
6
|
+
> 包括未登录那一屏。被顶掉的账号「去哪了」,从此不必再去 `~/.dsh` 里翻文件名。**
|
|
7
|
+
>
|
|
8
|
+
> 这一版不改任何账号、刷新、镜像的行为:读不懂的文件依然被隔离、依然不被覆盖。
|
|
9
|
+
> 改的是**看得见**:隔离发生的证据本来就在磁盘上,只是没人告诉用户它在那儿。
|
|
10
|
+
|
|
11
|
+
### 新增
|
|
12
|
+
|
|
13
|
+
- **隔离过的账号副本会被点名**(`feat(card)`)。
|
|
14
|
+
- 宿主侧新增 `TraeCredentialStore.quarantinedCopies()`:**扫描**副本文件旁边的
|
|
15
|
+
`.corrupt-*` 兄弟文件——不另设一本账,**证据本身就是证据**,用户删掉留存文件,提示也就跟着
|
|
16
|
+
消失,没有第二处状态要清理。报告内容是它原来的路径、现在的路径、字节数,以及
|
|
17
|
+
**能读成 JSON 时的账号数**(读不成就不猜:一个猜错的账号数比没有更糟)。
|
|
18
|
+
- 状态文档新增 `quarantined` 字段,**signed-in 与 signed-out 两种形状都带**。
|
|
19
|
+
- 卡片「诊断」栏新增一行「损坏副本留存」,点名那份留存文件。
|
|
20
|
+
- **未登录那一屏也显示同一条通知**:账号消失之后用户落地的正是那一屏,而那一屏根本不渲染分栏,
|
|
21
|
+
诊断栏根本看不到——只把通知放进诊断栏,等于没做。
|
|
22
|
+
- 一台健康的机器上什么都不显示:没有通知,也没有空盒子。
|
|
23
|
+
|
|
24
|
+
### 测试
|
|
25
|
+
|
|
26
|
+
- 新增 **9** 例:`tests/auth.spec.ts`(2 条——报告隔离文件、用户删掉后通知随之消失)、
|
|
27
|
+
`tests/web-status.spec.ts`(2 条——signed-out 与 signed-in 文档都带上通知)、
|
|
28
|
+
`tests/card-quarantine.spec.tsx`(5 条——诊断栏点名、未登录屏可见、账号数可读/不可读、健机器保持沉默)。
|
|
29
|
+
- 全仓 **1093** 例 / 85 个测试文件通过,双 tsconfig 类型检查通过。
|
|
30
|
+
|
|
31
|
+
### 文档
|
|
32
|
+
|
|
33
|
+
- `README.md` / `README.en.md` 的诊断栏说明补上这一行新事实,以及「未登录那一屏也会显示」。
|
|
34
|
+
|
|
35
|
+
> **给 #56 报告人的补充**:4.4.6 的隔离是静默的,所以「出现过隔离文件」这件事过去只能靠翻目录发现。
|
|
36
|
+
> 4.4.7 之后,卡片会直接把那份文件指给你——如果你的 `~/.dsh` 下已经有 `.corrupt-*` 文件,
|
|
37
|
+
> 升级后打开设置页就能看到它曾经存在,不必再自己找。
|
|
3
38
|
## 4.4.6 (2026-10-24)
|
|
4
39
|
|
|
5
40
|
> **对齐宿主 DSH 0.2.1-rc.3(纯版本推进,插件代码零改动),并修掉账号链路上三处
|
package/README.en.md
CHANGED
|
@@ -36,7 +36,7 @@ A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bund
|
|
|
36
36
|
- **Enterprise is a separate billing channel, not an alias for CN** — the same CN credential, when it belongs to a `tob_online` tenant, is served by **two** gateways: the consumer pool (billed against personal credits) and the tenant pool (billed against the enterprise allowance). Same model, two payers, so **you** choose who pays; the plugin never guesses. `trae` never touches the enterprise gateway, and `trae-enterprise` **never falls back** — a refusal is reported as a refusal instead of quietly re-running on personal credits. Enterprise is **off by default**: a personal-only account cannot use the tenant pool, so shipping it enabled would mean handing everyone a provider that fails on first use.
|
|
37
37
|
- **Any panel can be switched off on its own** — each tab carries its own checkbox (CN and international checked by default, enterprise not): unchecking **withdraws that provider from the DSH model picker entirely** (not merely hiding the tab) and stops all of its requests; checking it again restores it with the account, directory, picks, and context budgets intact. If you never use the international side, just uncheck it.
|
|
38
38
|
- **Tabbed settings card** — the card's top carries a "Domestic / Enterprise / 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. CN and enterprise share one CN credential pool but keep **separate account bindings and model picks**: the two rosters differ (`DeepSeek-V4.1-Flash` is listed only on the enterprise pool), so picks never overwrite each other.
|
|
39
|
-
- **The card then splits into "Account / Models / Diagnostics"** (learned from the sibling `dsh-connect-workbuddy`). The region row above is the **scope** — which provider this whole card is about — while these are sections of that one card: Account covers who serves, what is left, the check-in and the pool; Models covers which models to tick, image input, the context budget and Save; Diagnostics read-only lists the panel, the provider id, the serving account, both token deadlines, the catalog/enabled model counts, whether the pool and the check-in are offered, and the **verbatim** text of this panel's last reported failure. The split exists because the two halves **commit differently**: an account change lands on the click, a catalog change is a draft until Save — so a single long column put the save button three screens away from what it saves. Switching sections never refetches, never drops a half-filled model draft, and never rebuilds the pool's log. A signed-out card renders no section strip, so its one screen of instructions cannot be hidden behind a tab the user cannot see. **The Models section lays every model out at once, with no inner scrollbar** — it is not a little window scrolling inside a page that already scrolls; the card's own page is the only scroll.
|
|
39
|
+
- **The card then splits into "Account / Models / Diagnostics"** (learned from the sibling `dsh-connect-workbuddy`). The region row above is the **scope** — which provider this whole card is about — while these are sections of that one card: Account covers who serves, what is left, the check-in and the pool; Models covers which models to tick, image input, the context budget and Save; Diagnostics read-only lists the panel, the provider id, the serving account, both token deadlines, the catalog/enabled model counts, whether the pool and the check-in are offered, and the **verbatim** text of this panel's last reported failure. **As of 4.4.7 the diagnostics section carries one more line, "quarantined copies"**: a credential copy that could not be read — and was therefore renamed aside instead of being erased — is named there, together with how many accounts it still holds. "Where did the account I remember go?" is now answered by the card instead of by browsing `~/.dsh` for a file name; the signed-out screen shows the same notice, because that is the screen a user lands on after an account disappears. The split exists because the two halves **commit differently**: an account change lands on the click, a catalog change is a draft until Save — so a single long column put the save button three screens away from what it saves. Switching sections never refetches, never drops a half-filled model draft, and never rebuilds the pool's log. A signed-out card renders no section strip, so its one screen of instructions cannot be hidden behind a tab the user cannot see. **The Models section lays every model out at once, with no inner scrollbar** — it is not a little window scrolling inside a page that already scrolls; the card's own page is the only scroll.
|
|
40
40
|
- **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.
|
|
41
41
|
- **Promotion badge** — Trae publishes its discount rules in the model directory (`activity_discount`: pay ratio, list price, off-peak windows with their time zone). The plugin judges them against **the clock at render time** and paints one capsule beside the model name (`5 折` / `off-peak 5 折` / `limited 5 折`), with the old price, the new price and the window on hover. Judging at render time is what keeps a night-time discount from still hanging there the next morning; when upstream says nothing is discounted right now no badge is painted, the multiplier is never used to guess a promotion, and no campaign without an end time is labelled "limited". It is information only: no request and no billing changes, and the international region (subscription) has no such data and therefore shows no badge. See [docs/PROMO_BADGE.md](docs/PROMO_BADGE.md).
|
|
42
42
|
- **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.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
- **企业版是独立计费通道,不是国内版的别名** —— 同一张 CN 凭据若属于 `tob_online` 租户,会被**两个**网关同时服务:消费池(扣个人积分)与租户池(扣企业额度)。同一模型、两种付费方,所以「谁付钱」由你显式选,插件不替你猜。`trae` 永不碰企业网关;`trae-enterprise` **不回落**,被拒绝就如实报错,不会悄悄改用个人额度重跑。企业版**默认关闭**——纯个人账号用不了企业池,默认放开等于塞一条一用就失败的 provider。
|
|
37
37
|
- **可单独关闭任一面板** —— 三个 tab 各带一个勾选(国内版与国际版默认勾选,企业版默认不勾):取消勾选即把该面板的供应商**整个从 DSH 模型选择器撤掉**(不是只藏起 tab),并且不再发起任何请求;重新勾选即恢复,账号、目录、勾选与上下文预算全部保留。用不到国际版就把国际版关掉即可。
|
|
38
38
|
- **插件卡片 tab 切换** —— 设置卡片顶部为「国内版 / 企业版 / 国际版」三个 tab,各含独立的账号选择、用量概览与模型管理;每个 tab 的账号、目录、勾选与未保存草稿完全隔离——在一个 tab 里切账号或刷新模型,不会触碰另一边的运行时目录与会话。国内版与企业版共用同一份 CN 凭据池,但**各有各的账号绑定与模型勾选**:两个池的名录并不相同(`DeepSeek-V4.1-Flash` 只有企业池列),所以勾选互不覆盖。
|
|
39
|
-
- **卡片内再按「账号 / 模型 / 诊断」分栏**(学自同族 `dsh-connect-workbuddy`)—— 上面那排地区是**作用域**(这张卡片讲的是哪个供应商),这一排是同一张卡片里的**分栏**:账号栏管「谁在服务、还剩多少、签到与账号池」,模型栏管「勾哪些模型、图片输入、上下文预算、保存」,诊断栏只读地列出面板名、供应商 id
|
|
39
|
+
- **卡片内再按「账号 / 模型 / 诊断」分栏**(学自同族 `dsh-connect-workbuddy`)—— 上面那排地区是**作用域**(这张卡片讲的是哪个供应商),这一排是同一张卡片里的**分栏**:账号栏管「谁在服务、还剩多少、签到与账号池」,模型栏管「勾哪些模型、图片输入、上下文预算、保存」,诊断栏只读地列出面板名、供应商 id、服务账号、两种令牌到期时间、目录/已启用模型数、账号池与签到支持与否,以及本面板最近一次报错的**原文**。**4.4.7 起诊断栏还多一行「损坏副本留存」**:读不出来、因此被改名留存的账号副本会在这里被点名(连同它曾经保存了几个账号)——被顶掉的账号「去哪了」这个问题,从此不用再去 `~/.dsh` 里翻文件名;未登录那一屏也会显示同一条通知,因为账号消失之后用户落地的正是那一屏。分栏的理由是**提交语义不同**:账号改动点一下即生效,模型改动是草稿、必须点「保存」——一列长页会把保存按钮放到离它要保存的东西三屏之外。切栏不重新拉取、不丢未保存的模型草稿、账号池日志也不重建;未登录时不出分栏,那一屏说明不会被看不见的 tab 藏起来。**模型栏把所有模型一次性铺开,没有内层滚动条**——不再是一个套在滚动页面里的小窗口,唯一滚动的就是卡片自己那一页。
|
|
40
40
|
- **账号池:自动选号 + 失败换号(默认关闭)** —— 本机读完几个账号后,「该用谁的额度」可以交给插件按规则排序:**先排除不可用的**(凭据被拒、套餐不覆盖、账号已不存在、限流未到重试时间、额度耗尽),再在可用账号里**优先快到期的那点额度**(与其放着过期,不如先花掉),最后才比总额、token 新鲜度,并以账号 id 兜底成**全序**(同样的输入永远得到同样的顺序,不会在两行之间来回抖)。三个面板**各有各的池**:国内版与企业版共用同一份 CN 凭据,但企业版只挑租户账号、国内版不会漂到租户号上。开着池时,发请求前先按上面的顺序选中一个账号,并且**真实请求失败会换下一个账号重试(最多 3 个)**——只有账号级失败才换(`401` 凭据被拒、额度耗尽、限流、上游 5xx);模型 id 写错、请求本身不合法**不换号**,因为那不是账号的问题,换号只会把同一个错误烧两遍、还冤枉一个没机会服务的账号。换号失败的真相会写进池的探针记录,下一次排序直接把它排到后面,而每一次结论都能在卡片上看到:`可用` / `限流` / `额度耗尽` / `凭据被拒` / `套餐不覆盖` / `上游不提供` / `本次未测出`,以及「什么时候可以重试」。**关掉池就回到严格绑定**,不会有任何残留 override。卡片里的「全部测速」会把每个成员按目标模型各测一次,结果**边跑边显示**(一行一个答案,不等整批跑完),并落盘成下次排序的依据。
|
|
41
41
|
|
|
42
42
|
> 池是**显式选择**:默认关闭。它不会替你在没打开池的情况下换账号——「换账号等于换人计费」,所以这件事只能由你点头。池打开后卡片会明确写出**当前是谁在付费**(Host 报告的是「下一个真正发送请求的账号」,不是保存的那个绑定)。
|
package/lib/client.js
CHANGED
|
@@ -1183,6 +1183,16 @@ window.__ModuleLoader__.load({
|
|
|
1183
1183
|
.dsm-trae-searched-list li{display:flex;flex-direction:column;gap:1px;min-width:0}
|
|
1184
1184
|
.dsm-trae-searched-list code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#b8b8b8);word-break:break-all}
|
|
1185
1185
|
.dsm-trae-searched-reason{color:var(--dsw-alias-label-tertiary,#999);font-size:11px}
|
|
1186
|
+
/* The quarantine notice: a copy that was kept aside instead of being erased.
|
|
1187
|
+
It borrows the "probed paths" look but stands on its own class, because it
|
|
1188
|
+
is a different KIND of fact — and because a screen may carry both. */
|
|
1189
|
+
.dsm-trae-quarantine{margin-top:8px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#999)}
|
|
1190
|
+
.dsm-trae-quarantine>summary{cursor:pointer;color:var(--dsw-alias-label-secondary,#b8b8b8);user-select:none}
|
|
1191
|
+
.dsm-trae-quarantine-hint{margin:6px 0 4px;color:var(--dsw-alias-label-tertiary,#999)}
|
|
1192
|
+
.dsm-trae-quarantine-list{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:4px}
|
|
1193
|
+
.dsm-trae-quarantine-list li{display:flex;flex-direction:column;gap:1px;min-width:0}
|
|
1194
|
+
.dsm-trae-quarantine-list code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#b8b8b8);word-break:break-all}
|
|
1195
|
+
.dsm-trae-quarantine-reason{color:var(--dsw-alias-label-tertiary,#999);font-size:11px}
|
|
1186
1196
|
.dsm-trae-usage-cheer:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:2px}
|
|
1187
1197
|
.dsm-trae-checkin{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 16px;border:1px solid var(--dsw-alias-border-l2,#3a3d45);border-radius:14px;background:var(--dsw-alias-bg-layer-2,#24262c)}
|
|
1188
1198
|
.dsm-trae-checkin-copy{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
@@ -5805,6 +5815,19 @@ window.__ModuleLoader__.load({
|
|
|
5805
5815
|
children: failures.join(" · ")
|
|
5806
5816
|
});
|
|
5807
5817
|
})()]
|
|
5818
|
+
}),
|
|
5819
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
5820
|
+
className: "dsm-trae-diag-row",
|
|
5821
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5822
|
+
className: "dsm-trae-diag-label",
|
|
5823
|
+
children: t("row.diagQuarantine")
|
|
5824
|
+
}), status.quarantined === void 0 || status.quarantined.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5825
|
+
className: "dsm-trae-diag-value",
|
|
5826
|
+
children: t("row.diagQuarantineNone")
|
|
5827
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
5828
|
+
className: "dsm-trae-diag-value dsm-trae-diag-bad dsm-trae-diag-mono",
|
|
5829
|
+
children: status.quarantined.map((item) => item.quarantinedAs).join(" · ")
|
|
5830
|
+
})]
|
|
5808
5831
|
})
|
|
5809
5832
|
]
|
|
5810
5833
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
@@ -5817,35 +5840,65 @@ window.__ModuleLoader__.load({
|
|
|
5817
5840
|
role: "status",
|
|
5818
5841
|
children: t("row.accountsLoading")
|
|
5819
5842
|
}) }) : null,
|
|
5820
|
-
status.status === "signed-out" && !loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5843
|
+
status.status === "signed-out" && !loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
5844
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5845
|
+
className: "dsm-trae-usage-text",
|
|
5846
|
+
children: status.message ?? t("row.signedOutHint")
|
|
5847
|
+
}),
|
|
5848
|
+
status.quarantined && status.quarantined.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
5849
|
+
className: "dsm-trae-quarantine",
|
|
5850
|
+
open: true,
|
|
5851
|
+
children: [
|
|
5852
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
5853
|
+
t("row.quarantineTitle"),
|
|
5854
|
+
" (",
|
|
5855
|
+
status.quarantined.length,
|
|
5856
|
+
")"
|
|
5857
|
+
] }),
|
|
5858
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5859
|
+
className: "dsm-trae-quarantine-hint",
|
|
5860
|
+
children: t("row.quarantineHint")
|
|
5861
|
+
}),
|
|
5862
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
5863
|
+
className: "dsm-trae-quarantine-list",
|
|
5864
|
+
children: status.quarantined.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: item.quarantinedAs }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
5865
|
+
className: "dsm-trae-quarantine-reason",
|
|
5866
|
+
children: [
|
|
5867
|
+
item.accounts === void 0 ? t("row.quarantineAccountsUnknown") : t("row.quarantineAccounts", { count: item.accounts }),
|
|
5868
|
+
" · ",
|
|
5869
|
+
t("row.quarantineBytes", { bytes: item.bytes })
|
|
5870
|
+
]
|
|
5871
|
+
})] }, item.quarantinedAs))
|
|
5872
|
+
})
|
|
5873
|
+
]
|
|
5874
|
+
}) : null,
|
|
5875
|
+
status.searched && status.searched.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
5876
|
+
className: "dsm-trae-searched",
|
|
5877
|
+
children: [
|
|
5878
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", { children: [
|
|
5879
|
+
t("row.searchedTitle"),
|
|
5880
|
+
" (",
|
|
5881
|
+
status.searched.length,
|
|
5882
|
+
")"
|
|
5883
|
+
] }),
|
|
5884
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5885
|
+
className: "dsm-trae-searched-hint",
|
|
5886
|
+
children: t("row.searchedHint")
|
|
5887
|
+
}),
|
|
5888
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
5889
|
+
className: "dsm-trae-searched-list",
|
|
5890
|
+
children: status.searched.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: item.path }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
5891
|
+
className: "dsm-trae-searched-reason",
|
|
5892
|
+
children: [
|
|
5893
|
+
t(item.source === "cli" ? "row.sourceCli" : "row.sourceDesktop"),
|
|
5894
|
+
" · ",
|
|
5895
|
+
t(item.reason === "missing" ? "row.reasonMissing" : item.reason === "unreadable" ? "row.reasonUnreadable" : "row.reasonInvalid")
|
|
5896
|
+
]
|
|
5897
|
+
})] }, `${item.source}:${item.path}`))
|
|
5898
|
+
})
|
|
5899
|
+
]
|
|
5900
|
+
}) : null
|
|
5901
|
+
] }) : null,
|
|
5849
5902
|
status.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
5850
5903
|
className: "dsm-trae-usage-error",
|
|
5851
5904
|
children: status.message
|
|
@@ -6583,6 +6636,8 @@ window.__ModuleLoader__.load({
|
|
|
6583
6636
|
"row.diagRawOff": "not checked",
|
|
6584
6637
|
"row.diagFailures": "Last reported failure",
|
|
6585
6638
|
"row.diagNoFailures": "none",
|
|
6639
|
+
"row.diagQuarantine": "Quarantined copies",
|
|
6640
|
+
"row.diagQuarantineNone": "none",
|
|
6586
6641
|
"row.diagHint": "Everything above is read-only and can be quoted verbatim into a bug report. The values are this panel’s own last refresh, not a summary of it.",
|
|
6587
6642
|
"row.settingsWriteFailed": "The setting was not saved: {message}",
|
|
6588
6643
|
"row.signedOut": "Not signed in",
|
|
@@ -6590,6 +6645,11 @@ window.__ModuleLoader__.load({
|
|
|
6590
6645
|
"row.searchedTitle": "Paths checked",
|
|
6591
6646
|
"row.searchedHint": "No sign-in was found. These locations were probed; if your Trae stores its login elsewhere, please report the path.",
|
|
6592
6647
|
"row.searchedMore": "Show {count} more",
|
|
6648
|
+
"row.quarantineTitle": "Quarantined credential copies",
|
|
6649
|
+
"row.quarantineHint": "A credential copy could not be read, so the plugin did not overwrite it — it was renamed aside with its bytes intact. The accounts it held exist only in that file; delete it once you have them back.",
|
|
6650
|
+
"row.quarantineAccounts": "{count} account(s)",
|
|
6651
|
+
"row.quarantineAccountsUnknown": "account count unreadable",
|
|
6652
|
+
"row.quarantineBytes": "{bytes} bytes",
|
|
6593
6653
|
"row.reasonMissing": "not found",
|
|
6594
6654
|
"row.reasonUnreadable": "unreadable",
|
|
6595
6655
|
"row.reasonInvalid": "unreadable format",
|
|
@@ -6953,6 +7013,8 @@ window.__ModuleLoader__.load({
|
|
|
6953
7013
|
"row.diagRawOff": "未检测",
|
|
6954
7014
|
"row.diagFailures": "最近一次报错",
|
|
6955
7015
|
"row.diagNoFailures": "无",
|
|
7016
|
+
"row.diagQuarantine": "损坏副本留存",
|
|
7017
|
+
"row.diagQuarantineNone": "无",
|
|
6956
7018
|
"row.diagHint": "以上全部只读,可整段原样贴进反馈。数值来自本面板最近一次刷新,不是概括。",
|
|
6957
7019
|
"row.settingsWriteFailed": "设置未能保存:{message}",
|
|
6958
7020
|
"row.signedOut": "未登录",
|
|
@@ -6960,6 +7022,11 @@ window.__ModuleLoader__.load({
|
|
|
6960
7022
|
"row.searchedTitle": "已检查的路径",
|
|
6961
7023
|
"row.searchedHint": "未找到登录信息。以下是插件探测过的位置;如果你的 Trae 把登录信息存在别处,请把该路径反馈给我们。",
|
|
6962
7024
|
"row.searchedMore": "展开其余 {count} 条",
|
|
7025
|
+
"row.quarantineTitle": "被隔离的账号副本",
|
|
7026
|
+
"row.quarantineHint": "有一份账号副本文件读不出来,插件没有覆盖它,而是改名留存(字节完整)。它曾经保存的账号只可能在那份文件里;确认已取回后删掉它即可不再提示。",
|
|
7027
|
+
"row.quarantineAccounts": "含 {count} 个账号",
|
|
7028
|
+
"row.quarantineAccountsUnknown": "账号数无法读取",
|
|
7029
|
+
"row.quarantineBytes": "{bytes} 字节",
|
|
6963
7030
|
"row.reasonMissing": "文件不存在",
|
|
6964
7031
|
"row.reasonUnreadable": "无法读取",
|
|
6965
7032
|
"row.reasonInvalid": "格式无法识别",
|
package/lib/index.d.ts
CHANGED
|
@@ -1081,6 +1081,29 @@ interface TraeWebSearchPath {
|
|
|
1081
1081
|
reason: 'missing' | 'unreadable' | 'invalid';
|
|
1082
1082
|
message?: string;
|
|
1083
1083
|
}
|
|
1084
|
+
/**
|
|
1085
|
+
* A plugin-owned credential copy that was found unreadable and moved aside.
|
|
1086
|
+
*
|
|
1087
|
+
* Since 4.4.6 such a copy is quarantined (renamed aside, bytes intact)
|
|
1088
|
+
* instead of being merged over, because merging over it would erase every
|
|
1089
|
+
* account it carried. The copy then exists ONLY in that quarantine file — so
|
|
1090
|
+
* the card says so, instead of the user discovering it by noticing accounts
|
|
1091
|
+
* missing (issue #56).
|
|
1092
|
+
*
|
|
1093
|
+
* Only facts about the plugin's own file cross to the browser: its path, the
|
|
1094
|
+
* size of the quarantine copy, and how many accounts it still shows. No token
|
|
1095
|
+
* material, and no path outside DSH's own home.
|
|
1096
|
+
*/
|
|
1097
|
+
interface TraeWebQuarantine {
|
|
1098
|
+
/** The live path the copy had before it was moved aside. */
|
|
1099
|
+
file: string;
|
|
1100
|
+
/** The quarantine copy's path; its name carries the moment it was taken. */
|
|
1101
|
+
quarantinedAs: string;
|
|
1102
|
+
/** Size of the quarantined copy in bytes (`0` when it could not be read). */
|
|
1103
|
+
bytes: number;
|
|
1104
|
+
/** Accounts the copy still shows, when it could be read as JSON. */
|
|
1105
|
+
accounts?: number;
|
|
1106
|
+
}
|
|
1084
1107
|
/**
|
|
1085
1108
|
* Peel ONE `{get(): T}` live reference, the shape DSH 0.1.7 delivers a
|
|
1086
1109
|
* volatile-marked settings field as (see {@link unwrapVolatileDeep}).
|
|
@@ -1229,6 +1252,12 @@ type TraeWebUsage = {
|
|
|
1229
1252
|
accounts: readonly TraeWebAccount[];
|
|
1230
1253
|
message?: string;
|
|
1231
1254
|
searched?: readonly TraeWebSearchPath[];
|
|
1255
|
+
/**
|
|
1256
|
+
* Copies that were found unreadable and moved aside. Present on BOTH
|
|
1257
|
+
* shapes on purpose: the signed-out screen is exactly where a user lands
|
|
1258
|
+
* after a lost copy, so that is where the notice has to be.
|
|
1259
|
+
*/
|
|
1260
|
+
quarantined?: readonly TraeWebQuarantine[];
|
|
1232
1261
|
enabled?: boolean;
|
|
1233
1262
|
} | {
|
|
1234
1263
|
status: 'signed-in';
|
|
@@ -1249,6 +1278,12 @@ type TraeWebUsage = {
|
|
|
1249
1278
|
accounts: readonly TraeWebAccount[];
|
|
1250
1279
|
models: readonly TraeWebModel[];
|
|
1251
1280
|
enabledModelIds: readonly string[];
|
|
1281
|
+
/**
|
|
1282
|
+
* Copies that were found unreadable and moved aside. Present on BOTH
|
|
1283
|
+
* shapes on purpose: the signed-out screen is exactly where a user lands
|
|
1284
|
+
* after a lost copy, so that is where the notice has to be.
|
|
1285
|
+
*/
|
|
1286
|
+
quarantined?: readonly TraeWebQuarantine[];
|
|
1252
1287
|
rawChat?: {
|
|
1253
1288
|
state: 'disabled' | 'unchecked' | 'available' | 'protocol-gated' | 'authentication' | 'credit' | 'rate' | 'transport' | 'server';
|
|
1254
1289
|
checkedAtMs?: number;
|
|
@@ -1786,6 +1821,34 @@ interface TraeCandidateFailure {
|
|
|
1786
1821
|
reason: 'missing' | 'unreadable' | 'invalid';
|
|
1787
1822
|
message?: string;
|
|
1788
1823
|
}
|
|
1824
|
+
/**
|
|
1825
|
+
* A plugin-owned copy that was found UNREADABLE and therefore moved aside.
|
|
1826
|
+
*
|
|
1827
|
+
* Since 4.4.6 a copy this build cannot parse is never merged over: it is
|
|
1828
|
+
* renamed to `<file>.corrupt-<stamp>` (bytes intact, recoverable) and the merge
|
|
1829
|
+
* restarts from a clean file. That trade — a quarantined copy instead of a
|
|
1830
|
+
* silently emptied one — is only fair if the USER can see it happened, because
|
|
1831
|
+
* the accounts the copy carried are, from that moment on, only in the
|
|
1832
|
+
* quarantine file.
|
|
1833
|
+
*
|
|
1834
|
+
* This notice is what makes that visible: the card's diagnostics panel shows
|
|
1835
|
+
* it, and so does the signed-out screen — which is exactly the state a user
|
|
1836
|
+
* lands in after the loss (issue #56).
|
|
1837
|
+
*/
|
|
1838
|
+
interface TraeQuarantineNotice {
|
|
1839
|
+
/** The live path the copy had before it was moved aside. */
|
|
1840
|
+
file: string;
|
|
1841
|
+
/** The quarantine copy's full path; its name carries the moment it was taken. */
|
|
1842
|
+
quarantinedAs: string;
|
|
1843
|
+
/** Size of the quarantined copy in bytes (`0` when it could not be read). */
|
|
1844
|
+
bytes: number;
|
|
1845
|
+
/**
|
|
1846
|
+
* How many accounts the quarantined copy held, when it could still be read
|
|
1847
|
+
* as JSON. A copy quarantined for being TORN cannot be counted, and this is
|
|
1848
|
+
* then absent rather than guessed.
|
|
1849
|
+
*/
|
|
1850
|
+
accounts?: number;
|
|
1851
|
+
}
|
|
1789
1852
|
/**
|
|
1790
1853
|
* Plugin-owned copy path for one region. Each region's store refreshes into
|
|
1791
1854
|
* its own file so two simultaneously signed-in regions never overwrite each
|
|
@@ -2209,6 +2272,21 @@ declare class TraeCredentialStore {
|
|
|
2209
2272
|
* files are skipped rather than propagated.
|
|
2210
2273
|
*/
|
|
2211
2274
|
private readOwns;
|
|
2275
|
+
/**
|
|
2276
|
+
* The copies that were found unreadable and moved aside.
|
|
2277
|
+
*
|
|
2278
|
+
* SCANNED, not remembered: the quarantine file is itself the durable
|
|
2279
|
+
* record (its name carries the moment it was taken), so the plugin does not
|
|
2280
|
+
* keep a second, parallel ledger that could disagree with the disk. The
|
|
2281
|
+
* notice therefore appears exactly as long as the evidence does — and
|
|
2282
|
+
* disappears when the user deletes the quarantined copy, which is what
|
|
2283
|
+
* "I have dealt with it" means.
|
|
2284
|
+
*
|
|
2285
|
+
* A notice is a FACT about the user's disk, never about their credentials:
|
|
2286
|
+
* it names a path, a size and a count, and the path is the one the plugin
|
|
2287
|
+
* owns (inside DSH's own home), never a Trae application directory.
|
|
2288
|
+
*/
|
|
2289
|
+
quarantinedCopies(): Promise<TraeQuarantineNotice[]>;
|
|
2212
2290
|
private refreshNow;
|
|
2213
2291
|
}
|
|
2214
2292
|
//#endregion
|
package/lib/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { openAICompletionsApi } from "@earendil-works/pi-ai/api/openai-completio
|
|
|
4
4
|
import { resolveRetryPolicy } from "@deepseek-ai/dsh-llm";
|
|
5
5
|
import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
-
import { dirname, join } from "node:path";
|
|
7
|
+
import { basename, dirname, join } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { copyFile, readFile, rename, rm, stat } from "node:fs/promises";
|
|
9
|
+
import { copyFile, readFile, readdir, rename, rm, stat } from "node:fs/promises";
|
|
10
10
|
import { createCipheriv, createDecipheriv, createHash, randomBytes, randomUUID, sign, timingSafeEqual } from "node:crypto";
|
|
11
11
|
import { withFileLock, writeFileAtomic } from "@deepseek-ai/dsh-atomic-write";
|
|
12
12
|
import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
|
|
@@ -2293,6 +2293,30 @@ async function writeOwn(path, credentials) {
|
|
|
2293
2293
|
dirMode: 448
|
|
2294
2294
|
});
|
|
2295
2295
|
}
|
|
2296
|
+
/**
|
|
2297
|
+
* How many accounts a quarantined copy still shows, when it can be read at all.
|
|
2298
|
+
*
|
|
2299
|
+
* A copy is quarantined because this build could not PARSE it — but not every
|
|
2300
|
+
* unparseable copy is unreadable: a file whose JSON is intact yet carries a
|
|
2301
|
+
* version this build does not know still parses as JSON, and its account rows
|
|
2302
|
+
* are then countable. That number is what tells the user whether one account
|
|
2303
|
+
* or five went missing, so it is worth the attempt.
|
|
2304
|
+
*
|
|
2305
|
+
* A torn copy yields nothing: the count is then ABSENT rather than guessed,
|
|
2306
|
+
* because a wrong count is worse than no count.
|
|
2307
|
+
*/
|
|
2308
|
+
function countStoredAccounts(text) {
|
|
2309
|
+
try {
|
|
2310
|
+
const parsed = JSON.parse(text);
|
|
2311
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
|
|
2312
|
+
const document = parsed;
|
|
2313
|
+
if (Array.isArray(document.credentials)) return document.credentials.length;
|
|
2314
|
+
if (document.credential !== void 0) return 1;
|
|
2315
|
+
return;
|
|
2316
|
+
} catch {
|
|
2317
|
+
return;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2296
2320
|
/** The key Trae stores the per-user region map under, beside the login itself. */
|
|
2297
2321
|
const TRAE_USERTAG_STORAGE_KEY = "iCubeAuthInfo://usertag";
|
|
2298
2322
|
/**
|
|
@@ -3115,6 +3139,54 @@ var TraeCredentialStore = class {
|
|
|
3115
3139
|
} catch {}
|
|
3116
3140
|
return copies;
|
|
3117
3141
|
}
|
|
3142
|
+
/**
|
|
3143
|
+
* The copies that were found unreadable and moved aside.
|
|
3144
|
+
*
|
|
3145
|
+
* SCANNED, not remembered: the quarantine file is itself the durable
|
|
3146
|
+
* record (its name carries the moment it was taken), so the plugin does not
|
|
3147
|
+
* keep a second, parallel ledger that could disagree with the disk. The
|
|
3148
|
+
* notice therefore appears exactly as long as the evidence does — and
|
|
3149
|
+
* disappears when the user deletes the quarantined copy, which is what
|
|
3150
|
+
* "I have dealt with it" means.
|
|
3151
|
+
*
|
|
3152
|
+
* A notice is a FACT about the user's disk, never about their credentials:
|
|
3153
|
+
* it names a path, a size and a count, and the path is the one the plugin
|
|
3154
|
+
* owns (inside DSH's own home), never a Trae application directory.
|
|
3155
|
+
*/
|
|
3156
|
+
async quarantinedCopies() {
|
|
3157
|
+
const notices = [];
|
|
3158
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3159
|
+
for (const path of this.ownCandidates()) {
|
|
3160
|
+
const directory = dirname(path);
|
|
3161
|
+
const prefix = `${basename(path)}.corrupt-`;
|
|
3162
|
+
let entries;
|
|
3163
|
+
try {
|
|
3164
|
+
entries = await readdir(directory);
|
|
3165
|
+
} catch {
|
|
3166
|
+
continue;
|
|
3167
|
+
}
|
|
3168
|
+
for (const name of entries) {
|
|
3169
|
+
if (!name.startsWith(prefix)) continue;
|
|
3170
|
+
const quarantinedAs = join(directory, name);
|
|
3171
|
+
if (seen.has(quarantinedAs)) continue;
|
|
3172
|
+
seen.add(quarantinedAs);
|
|
3173
|
+
let bytes = 0;
|
|
3174
|
+
let accounts;
|
|
3175
|
+
try {
|
|
3176
|
+
const text = await readFile(quarantinedAs, "utf8");
|
|
3177
|
+
bytes = Buffer.byteLength(text);
|
|
3178
|
+
accounts = countStoredAccounts(text);
|
|
3179
|
+
} catch {}
|
|
3180
|
+
notices.push({
|
|
3181
|
+
file: path,
|
|
3182
|
+
quarantinedAs,
|
|
3183
|
+
bytes,
|
|
3184
|
+
...accounts === void 0 ? {} : { accounts }
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
return notices;
|
|
3189
|
+
}
|
|
3118
3190
|
async refreshNow(credential) {
|
|
3119
3191
|
if (credential.refreshToken === void 0 || credential.refreshExpiresAtMs !== void 0 && credential.refreshExpiresAtMs <= Date.now()) {
|
|
3120
3192
|
if (credential.expiresAtMs > Date.now() + 3e4) return credential;
|
|
@@ -8010,12 +8082,26 @@ async function traeWebUsage(deps, panel, options = {}) {
|
|
|
8010
8082
|
* would offer a binding that cannot work.
|
|
8011
8083
|
*/
|
|
8012
8084
|
const accounts = (await store.accounts()).filter((account) => panel !== "enterprise" || account.enterprise);
|
|
8085
|
+
/**
|
|
8086
|
+
* Copies that were found unreadable and moved aside (4.4.6+).
|
|
8087
|
+
*
|
|
8088
|
+
* Read ONCE per document and never allowed to fail it: a notice is a fact
|
|
8089
|
+
* about the user's disk, and a card that failed to load would teach the user
|
|
8090
|
+
* nothing about it. It is also the one piece of the document that explains a
|
|
8091
|
+
* MISSING ACCOUNT, so it belongs on both shapes — the signed-out one
|
|
8092
|
+
* especially, because that is where a lost copy leaves the user (issue #56).
|
|
8093
|
+
*
|
|
8094
|
+
* The scan is a directory listing beside the plugin's OWN files: cheap, and
|
|
8095
|
+
* it reads nothing but file names and sizes.
|
|
8096
|
+
*/
|
|
8097
|
+
const quarantined = await Promise.resolve().then(() => store.quarantinedCopies()).catch(() => []);
|
|
8013
8098
|
if ((await store.status()).state !== "signed-in") {
|
|
8014
8099
|
const { failures } = await store.diagnose();
|
|
8015
8100
|
return {
|
|
8016
8101
|
status: "signed-out",
|
|
8017
8102
|
accounts,
|
|
8018
8103
|
enabled,
|
|
8104
|
+
quarantined,
|
|
8019
8105
|
searched: failures.map((failure) => ({
|
|
8020
8106
|
path: failure.path,
|
|
8021
8107
|
edition: failure.edition,
|
|
@@ -8034,6 +8120,7 @@ async function traeWebUsage(deps, panel, options = {}) {
|
|
|
8034
8120
|
status: "signed-out",
|
|
8035
8121
|
accounts,
|
|
8036
8122
|
enabled,
|
|
8123
|
+
quarantined,
|
|
8037
8124
|
message: safeMessage(error)
|
|
8038
8125
|
};
|
|
8039
8126
|
}
|
|
@@ -8050,6 +8137,7 @@ async function traeWebUsage(deps, panel, options = {}) {
|
|
|
8050
8137
|
...model.input === void 0 ? {} : { input: [...model.input] }
|
|
8051
8138
|
})),
|
|
8052
8139
|
enabledModelIds: [...deps.enabledModelIds(panel)],
|
|
8140
|
+
quarantined,
|
|
8053
8141
|
...deps.rawDiagnostic === void 0 ? {} : { rawChat: deps.rawDiagnostic(panel) }
|
|
8054
8142
|
};
|
|
8055
8143
|
if (fast) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dsh-connect-trae",
|
|
3
3
|
"displayName": "DSH Connect Trae",
|
|
4
4
|
"description": "把本机登录的 Trae 模型接入 DeepSeek Harness:国内版与国际版双供应商并行,提供用量/积分概览与每日签到领取。",
|
|
5
|
-
"version": "4.4.
|
|
5
|
+
"version": "4.4.7",
|
|
6
6
|
"author": "dingminhua",
|
|
7
7
|
"copyright": "Copyright (c) 2026 LaoDing",
|
|
8
8
|
"license": "MIT",
|