dsh-connect-workbuddy 4.0.0 → 4.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 +50 -0
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/lib/bin.js +1 -1
- package/lib/client.js +824 -9
- package/lib/{host-heartbeat-vvVjdY_q.js → host-heartbeat-C4TXu8ew.js} +367 -25
- package/lib/index.d.ts +212 -2
- package/lib/index.js +787 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.2.0 (2026-10-10)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- **导入不再拒掉插件自己导出的账号:CN 聊天网关 `copilot.tencent.com` 现在被识别为国内站。**
|
|
8
|
+
- **现象**:卡片导出 8 个账号,再把同一个文件导入回来,结果是「导入 5 / 跳过 3」——**导出的文件自己导不回去**。用户反馈这 3 个账号在另一台电脑上完全正常。
|
|
9
|
+
- **根因**:`copilot.tencent.com` 不是第三个上游,它**就是本插件自己的国内聊天网关**(`CN_CHAT_BASE = 'https://copilot.tencent.com'`,见 `src/upstream.ts`),而真实凭据的 `domain` 字段就写着它。4.1.x 的导入闸门(`knownRegionOf`,为防伪冒域名而做的「正向识别」)只认 `workbuddy.cn` / `codebuddy.cn` / `workbuddy.ai` / `codebuddy.ai`,`copilot.tencent.com` 匹配不上任何一个 → 返回 `undefined` → 计入 `skipped`。于是插件导出得出、导入不认,自相矛盾。
|
|
10
|
+
- **为什么 4.2.0 而不是 4.1.3**:4.1.0 刚把「批量导出 / 导入」作为新功能交付,4.1.2 收紧区域闸门时把它变成了自身不可用——跨机器迁移这条主路径在 4.1.x 整条线上都是断的,属于功能级缺陷而非补丁级瑕疵。
|
|
11
|
+
- **修法**:`knownRegionOf` 的 CN 表加入 `copilot.tencent.com` 及其子域。仍按可注册域匹配,仿冒主机(`copilot.tencent.com.evil.com`、`evilcopilot.tencent.com`)依旧被拒,闸门没有放宽成默认归 CN。
|
|
12
|
+
- 回归测试两条:一条钉住网关域名与仿冒主机的判定(`tests/transfer.spec.ts`),一条复刻「5 个登录域名 + 3 个网关域名混在一个导出文件」的完整往返,确认导入 CN 得 8/0、导入 global 得 0/8。
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
- **导入不再拒掉插件自己导出的账号:CN 聊天网关 `copilot.tencent.com` 现在被识别为国内站。**
|
|
16
|
+
- **现象**:卡片导出 8 个账号,再把同一个文件导入回来,结果是「导入 5 / 跳过 3」——**导出的文件自己导不回去**。用户反馈这 3 个账号在另一台电脑上完全正常。
|
|
17
|
+
- **根因**:`copilot.tencent.com` 不是第三个上游,它**就是本插件自己的国内聊天网关**(`CN_CHAT_BASE = 'https://copilot.tencent.com'`,见 `src/upstream.ts`),而真实凭据的 `domain` 字段就写着它。4.1.2 的导入闸门(`knownRegionOf`,为防伪冒域名而做的「正向识别」)只认 `workbuddy.cn` / `codebuddy.cn` / `workbuddy.ai` / `codebuddy.ai`,`copilot.tencent.com` 匹配不上任何一个 → 返回 `undefined` → 计入 `skipped`。于是插件导出得出、导入不认,自相矛盾。
|
|
18
|
+
- **修法**:`knownRegionOf` 的 CN 表加入 `copilot.tencent.com` 及其子域。仍按可注册域匹配,仿冒主机(`copilot.tencent.com.evil.com`、`evilcopilot.tencent.com`)依旧被拒,闸门没有放宽成默认归 CN。
|
|
19
|
+
- 回归测试两条:一条钉住网关域名与仿冒主机的判定,一条复刻「5 个登录域名 + 3 个网关域名混在一个导出文件」的完整往返。
|
|
20
|
+
|
|
21
|
+
## 4.1.2 (2026-10-10)
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- **账号可自行添加、迁移与逐个管理,不必再装桌面 App。**(合并自 PR #38)
|
|
26
|
+
- **扫码添加账号**:卡片新增「扫码添加账号」,点开授权链接在浏览器完成登录即可,无需先装 WorkBuddy 桌面 App。会话只存在进程内(600 秒超时),拿到凭据即终结,token 不落独立账号库。
|
|
27
|
+
- **统一凭据库**:所有凭据统一落盘到 `$DSH_HOME/workbuddy-vault/<region>/<accountId>.json`,一账号一文件——扫码添加的、桌面扫描到的、插件刷新过的,都汇入同一目录。桌面 App 的认证文件**始终只读**,插件永不写入或删除它们。
|
|
28
|
+
- **账号行级「测试 / 删除」**:表格每行新增两个按钮。单账号测试复用批处理同一套探测依赖与模型解析,因此行级与批量测的是同一个模型、产生同一种测量。删除只删插件自己的 vault 副本;若该账号来自桌面端,下次扫描会重新出现,文案如实说明。
|
|
29
|
+
- **账号批量导出 / 导入**:多选导出 JSON 文件,选文件后给出**脱敏预览**(只展示字段与 `hasToken`,token 明文不进预览),再勾选导入。文件格式与同类凭据管理工具互通;`uin` 会从 `auth_raw` 恢复,保证「导出 → 换机 → 导入」收敛到同一账号 id,不产生影子账号。关闭 issue #41。
|
|
30
|
+
|
|
31
|
+
### Fixes
|
|
32
|
+
|
|
33
|
+
- **扫码添加账号与导出/导入账号移入「账号池设置」区块。**
|
|
34
|
+
- 两处原先夹在积分区与账号池表格之间,语义上是悬空的——上面是余额、下面是表格,它们自己像两个孤儿。现在归入账号池设置区块,与账号管理其它操作收在一起。
|
|
35
|
+
- **放在该区块的偏好设置之上**,这是有意的:区块开头写着「点保存才生效」,而扫码登录与导入导出是**即时生效**、没有草稿的动作。放在那句提示语之下,会让用户以为要点保存——反之亦然。
|
|
36
|
+
- 两者共用一个虚线边框容器,与下方「点保存」的实线设置行区分开:虚线标记「点了就生效」,实线标记「要保存」。
|
|
37
|
+
- **未登录时同样显示**:账号池区块在未登录时不渲染,而这恰恰是这两项最要紧的时候——扫码是不装桌面 App 时唯一能加账号的方式,从别的电脑导出的文件也是这台机器凭空获得账号的唯一途径。两种状态渲染的是同一个 `accountTools` 节点,顺序与容器完全一致,不会让用户以为这是两个功能。
|
|
38
|
+
- **扫码添加账号与导出/导入账号改为各占一行,不再各占一个大区块。**
|
|
39
|
+
- 原先两者各是一个带虚线边框、内边距 12px 的整块,静止状态下就要占掉三行(标题 + 说明 + 按钮),把账号表格和模型列表挤到需要滚动才能看完。现在两处都是**一行工具条**:标签、状态文字、按钮同处一行,按钮右对齐。
|
|
40
|
+
- **状态文字与标签同行**,并且是卡片变窄时**最先被截断**的那一段(`text-overflow: ellipsis`),而不是把整条栏撑成两行。
|
|
41
|
+
- 导出/导入的**静止说明文字从常驻栏移进了导出确认弹窗**:那句「文件里是账号凭据——请妥善保管」在凭据真正离开机器的那一刻才有意义,常驻只是白白占掉三分之一行。
|
|
42
|
+
- 弹窗本身保持块级布局不变:它要容纳可滚动的账号列表和逐条勾选框,塞不进一行。
|
|
43
|
+
- **修复每次重启都把全部账号重新刷一遍 token 的循环。**
|
|
44
|
+
- 插件刷新出的 token 会写入 vault,但**取用**时仍无条件让桌面 App 的 live 文件优先(该优先是实测结论:上游会吊销备份文件里的 token,不能推翻)。结果每次重启都重新读到桌面那份较旧的 token、判定临近过期、再刷一次,刷新循环从未真正停止。
|
|
45
|
+
- 修法是给 vault 条目加一个**来源标记**:记录该条目是对哪个桌面文件刷新后写下的。取用时若标记与当前读到的文件同名,说明这份副本就是它的刷新结果、必然更新,于是可以取代桌面那份;而**仅靠「活得更久」仍然不能**越过 live 文件。
|
|
46
|
+
- 回归测试模拟 5 次重启并断言刷新只发生 1 次——这正是此前没有任何测试守住的场景。
|
|
47
|
+
- **修复扫码登录与账号导入导出在界面上完全不可用。** 卡片的两处请求漏拼 `action` 参数,宿主一律返回 400。新增 `withWorkBuddyRouteAction` 统一构造,并补上**客户端 ↔ 宿主 URL 契约测试**:此前测试都是手写带 `action` 的 URL,客户端拼出来的地址从未被验证过。
|
|
48
|
+
- **导入的区域门禁由「默认归 CN」改为「正向识别」。** 原实现把无法识别的域名一律当作 CN,而导入文件里的 `domain` 是文件作者可控的伪造值,仿冒域名(如 `workbuddy.ai.evil.com`)会被写进 CN vault。现在只有**确认属于目标区域**的域名才入库,认不出的一律计入 `skipped`;`regionOf` 保持原样,因为它服务的是上游签发的域名。
|
|
49
|
+
- **修复删除账号时删除任意文件。** `accountId` 取自查询参数并直接拼进文件路径,`join` 会规范化 `..`,可越出 vault 目录。现在按账号 id 的真实形态(sha256 前 24 位十六进制)校验,路由层与存储层各一道。
|
|
50
|
+
- **删除账号改为在文件锁内进行。** 原实现绕过锁并删掉 `.lock`,与并发的刷新写入相撞时会让两个写者同时进入临界区。
|
|
51
|
+
- **导出响应加 `Cache-Control: no-store`。** 导出会把 access/refresh token 明文交给浏览器用于下载,不应进入任何缓存。
|
|
52
|
+
|
|
3
53
|
## 4.0.0 (2026-10-04)
|
|
4
54
|
|
|
5
55
|
### ⚠️ Breaking Changes
|
package/README.en.md
CHANGED
|
@@ -34,6 +34,7 @@ A [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) bund
|
|
|
34
34
|
<img src="docs/assets/dsh-connect-workbuddy-composer-credits.png" width="360" alt="Composer credit panel: a per-account balance table for the domestic region, with a refresh button and a last-refreshed time" />
|
|
35
35
|
- **Account pool: batch actions across several accounts, plus automatic failover** — tick the accounts you want into a pool and you get **one-click check-in for every account**, **one-click testing of every account against a model you choose** (defaulting to the region's zero-multiplier free model), and with **Enable the account pool** switched on, **automatic failover**: a request that fails upstream is retried against the pool's other usable accounts, in order, until one serves it or none is left. Membership starts **empty and is an explicit opt-in**: "signed in on this machine" is not the same as "spend this account's credits and claim its rewards". The pool's **ranking decides who serves every request** (usable first, then higher credits, soonest-expiring, freshest credential), and on a failure the next usable member is tried. It **never writes back your saved selection** — switch the pool off and your own account applies again immediately. **The switch only decides whether the PLUGIN chooses** — with it off, the plugin stops picking and switching accounts for you, but check-in and testing stay available (they are manual actions). Testing reuses the model rows' real-volume probe, so it **does cost real credits**; **automatic check-in is deliberately not offered** — a check-in claims real rewards, so it only ever runs when you press the button. See [Account pool](#account-pool).
|
|
36
36
|
- **Actionable advice when a credential is refused** — when the upstream rejects the selected account's token, the plugin actually **probes** the other local sign-ins: if one still answers, it tells you to switch to it (with a one-click switch) instead of vaguely asking you to sign in again — re-authenticating fixes nothing while you are pinned to a revoked backup. Only when there is genuinely no other local account does it ask you to sign in again.
|
|
37
|
+
- **Add accounts by QR sign-in, import/export them in bulk, test or delete them one by one** — the WorkBuddy desktop app is no longer a prerequisite: the card's **Add account by QR code** opens an authorization link and signing in finishes in the browser. Every credential lands in the plugin's own vault (`$DSH_HOME/workbuddy-vault/<region>/<accountId>.json`, one file per account), and the desktop app's auth files stay **read-only and are never modified**. Each row of the account table gains **Test** and **Remove**: a row test reuses the same probe as the batch run, so the two are comparable; removing deletes only the copy the plugin stored, and an account that came from the desktop app reappears on the next scan. **Export / import accounts** moves credentials to another machine: pick accounts to export a JSON file → choose a file and read a **redacted preview** (field names and whether a token is present; the token itself never enters the preview) → tick what to import. An import overwrites per account rather than duplicating, and **only a record positively identified as belonging to that region is stored** — a domain the plugin cannot classify is skipped and counted as skipped. See [Account pool](#account-pool).
|
|
37
38
|
- **Credits live in the account pool** — the member table shows each account's remaining credits and nearest expiry, and credits are the ranking's second key (more credits serves first). The queries are **read-only** and consume no credits.
|
|
38
39
|
- **Multi-candidate credential paths** — probes the platform defaults for macOS / Windows / Linux in turn, overridable by environment variable or directly in the card. **When nothing is found, the card lists which paths were probed and why each one failed**: five distinct reasons (absent / unreadable / no usable token / encrypted with no key available / belongs to the other region), so the easiest case to misdiagnose — signed in, but the desktop app is not present — says the app must be there instead of telling you to sign in again. The **belongs to the other region** reason is different in kind: that sign-in is real and usable, it is simply filed under the other tab, so the card states the fix outright — switch tabs, no need to sign in again. The list says it once: the paragraph states the conclusion, the collapsed list supplies the per-path detail, and the two never repeat each other.
|
|
39
40
|
- **Secure loopback shim** — one random port + in-process random secret per region; the real WorkBuddy token is never handed to pi-ai.
|
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
<img src="docs/assets/dsh-connect-workbuddy-composer-credits.png" width="360" alt="对话输入框积分面板:国内版账号余额表格、刷新积分按钮与最近刷新时间" />
|
|
42
42
|
- **账号池:多账号批量操作与自动换号** —— 把要用的账号勾进池子,即可**一键签到所有账号**、**一键测试所有账号 × 你指定的模型**(默认挑该区域倍率为 0 的免费模型);开启**启用账号池**即同时打开**自动换号**——某个请求在上游失败时,插件会依次用池内其他可用账号重试,直到有一个接手、或全部不可用为止,然后才把错误报给你。成员**默认一个都不含**、必须显式勾选(「本机有登录」不等于「要拿它去签到和花积分」);**开启后由池子的排序决定每一次请求用谁**(可用优先,其次积分高、快过期的积分包、凭据更新的);失败时依次用池内其他可用账号重试。排序**从不写回你保存的选择**——关掉开关,你选定的账号立刻完全生效。只有请求本身不合法(HTTP 400)不换号:同一个请求体换谁都是 400,重试只会白等。**这个开关只管「插件要不要自己决定」**:关掉它,插件不再替你选账号、也不再替你换号,但**签到与测试仍然可用**(它们是手动动作)。测试走的是与模型行同一套真实体积探测,因此**有真实成本**;**不提供自动签到**——签到会真实领取奖励,只在你点按钮时执行。详见[账号池](#账号池)。
|
|
43
43
|
- **凭据失效时给出可执行的建议** —— 上游拒绝当前账号的 token 时,插件会**实际探测**本机其他账号:若有账号仍然可用,就直接告诉你「切换到它即可」(并附一键切换),而不是笼统地让你重新登录——被钉在一个作废的旧备份上时,重新登录并不能解决问题。只有本机确实没有别的账号可切换时,才会提示重新登录。
|
|
44
|
+
- **扫码添加账号、批量导入导出、逐账号测试/删除** —— 不必先装 WorkBuddy 桌面 App:卡片里的「扫码添加账号」点开授权链接、在浏览器登录完成即可。所有凭据统一落到插件自己的凭据库(`$DSH_HOME/workbuddy-vault/<region>/<accountId>.json`,一账号一文件),**桌面 App 的认证文件始终只读、永不被改动**。账号表格每一行右侧有「测试」与「删除」:测试与批量测试走同一套探测,结果可比;删除只删插件自己存的那份,若账号来自桌面端,下次扫描会重新出现。「导出 / 导入账号」可把凭据搬到另一台机器:多选导出 JSON → 选文件后先看**脱敏预览**(只显示字段与是否有 token,明文不进预览)→ 勾选导入。导入按账号去重覆盖,**只有确认属于该区域**的记录才入库,认不出的域名会被跳过并如实计入「已跳过」。详见[账号池](#账号池)。
|
|
44
45
|
- **积分信息在账号池里** —— 成员表逐账号显示剩余积分与最近到期时间,排序的第二键就是积分(谁多谁优先)。查询是**只读**的、不消耗积分。
|
|
45
46
|
- **凭据路径多候选** —— macOS / Windows / Linux 逐一探测默认位置,也支持环境变量与卡片内直接指定。**未登录时卡片会列出「探测过哪些路径、各自为什么没成」**:五档原因(不存在 / 读不了 / 没有可用 token / 字段已加密且拿不到密钥 / 属于另一个地区)分开呈现,因此「已经登录了、但桌面 App 不在场」这种最容易误判的情况会明说需要 App 在场,而不是叫你重新登录一次。**属于另一个地区**那一档尤其不同:登录信息是真实可用的,只是挂在另一个标签页下,卡片会直接给出结论「切换标签页即可,不用重新登录」。列表只讲一次——提示段落说结论,折叠列表给路径细节,两处不重复同一件事。
|
|
46
47
|
- **安全 loopback shim** —— 每区域一个随机端口 + 进程内随机 secret,真实 WorkBuddy token 不交给 pi-ai。
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { C as defaultDesktopAuthDirs, F as WorkBuddyUpstreamClient, G as WORKBUDDY_APP_EXECUTABLE_ENV, O as legacyWorkbuddyOwnAuthPath, S as defaultDesktopAuthCandidates, Z as findWorkbuddyAppExecutableWithSource, a as readHostHeartbeat, c as WORKBUDDY_CONNECT_VERSION, d as FALLBACK_WORKBUDDY_MODELS_GLOBAL, j as workbuddyOwnAuthPath, l as piAiRuntimeInfo, o as workbuddyHostHeartbeatPath, r as isHeartbeatProcessAlive, u as FALLBACK_WORKBUDDY_MODELS, v as WORKBUDDY_AUTH_FILE_ENV, y as WorkBuddyCredentialStore } from "./host-heartbeat-C4TXu8ew.js";
|
|
3
3
|
import { realpathSync } from "node:fs";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
//#region src/bin.ts
|