dsh-connect-workbuddy 5.21.4 → 5.22.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 +67 -0
- package/README.en.md +4 -2
- package/README.md +3 -3
- package/lib/bin.js +1 -1
- package/lib/client.js +417 -80
- package/lib/{host-heartbeat-Dq3ITRhF.js → host-heartbeat-CYnq7iGq.js} +76 -2
- package/lib/index.d.ts +59 -14
- package/lib/index.js +353 -112
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.22.0 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
> 版本号是 **minor**:新增两项用户可见的功能(选号顺序的两态开关、生图模型选择),另修一处缓存行为缺陷。
|
|
6
|
+
|
|
7
|
+
### 新增:选号顺序做成「自动 / 手动」两态开关(issue #240)
|
|
8
|
+
|
|
9
|
+
- 原来的做法只能从「有没有手动排过」去猜当前处于哪种规则,而且自动态下还画着一组没有意义的 ↑/↓——用户看到箭头就会去点,点完却什么也没改变。现在两格常驻、当前态高亮,「当前是哪种规则」一眼可见,箭头只在该有意义的那一态出现。
|
|
10
|
+
- 切到**手动排序**时把**当前屏幕上的顺序**直接确立为你的选择,而不是让你从空白开始重排;切到**自动排序**只清空手动顺序,不动勾选。池里没有可排成员时手动那一格禁用,避免切进一个箭头都不存在的空模式。
|
|
11
|
+
- 顺带修掉 `exclusionOf` 的排序缺陷:两个都被排除的账号之间原来不比较「谁先恢复」,导致永久排除的(凭据被拒)排在只需等 30 分钟的账号前面。现在按恢复时间排,无法恢复的垫底。
|
|
12
|
+
|
|
13
|
+
### 新增:生图模型可选 v3.0 以去掉水印(issue #241)
|
|
14
|
+
|
|
15
|
+
- **上游没有水印开关**:`watermark` / `extra_parameters.watermark` / `LogoAdd` 全部 HTTP 200 但无效,官方 CLI 的 `ImageService` 请求体里根本没有这个字段,`/v3/config` 也没有相关 feature。水印是网关落盘后的后处理,不是模型画的。所以「去掉水印」唯一等价的做法是换模型。
|
|
16
|
+
- 卡片新增「生图模型(水印)」下拉框(仅国内区):选 `hunyuan-image-v3.0` 出同样的图但不带水印。**默认值一处没改**——换模型同时改了价格和尺寸能力(约 11.1 积分/张 vs 约 6,边长上限 2048 vs 2560),这两件事该由用户决定。
|
|
17
|
+
- v3.0 的尺寸上限小得多,`1024x1536` 这类常用竖版会撞 `14402`。尺寸范围改成按**本次选中的模型**计算:同一张 `1024x1536`,走 alpha 原样发送,走 v3.0 自动等比缩成 `836x1254`(比例不变,实测可用),并把改动写进提示。
|
|
18
|
+
- v3.0 在改图接口上会**静默忽略输入图**(仍扣 11.31 积分),所以它只登记 `text-to-image`,改图继续走 `hunyuan-image-alpha-edit`。
|
|
19
|
+
- 每次出图都如实说明水印情况:用 alpha 时提示里直接写「上游没有关闭它的参数」并给出换模型的出路,不承诺能去掉。
|
|
20
|
+
|
|
21
|
+
### 修复:工具声明变化会让整个上下文按原价重算(缓存前缀失效)
|
|
22
|
+
|
|
23
|
+
- **国内区**的模型描述符现在声明 `compat.supportsMidConvoSystemMessages`。`dsh-llm-pi-ai` 由这个标志推导请求的 `systemPromptUpdate: 'in-history'`,从而在系统提示词变化时把新提示词**追加到已缓存历史之后**,而不是重写第 0 号系统节点。此前每次工具声明变化(装/卸插件、增删 MCP server、改技能)都会让上游的前缀缓存从第一个变化的 token 起全部失效,整包上下文按原价重算——长会话上表现为单轮几十积分。
|
|
24
|
+
- 上游确实把历史之后的 `system` 消息当作生效提示词:实测在 CN 区把 `system(B)` 放在历史之后,模型按 B 回答;随后同一形状的请求缓存命中从 49% 升到 93%。
|
|
25
|
+
- **国际区没有跟着声明,这是有意的。** 这个标志不是「一句声明、字节不变」:不声明时中间位置的 `system` 会被折进 `<system-reminder>` 的 user 消息,声明后直接以 `system` 角色发出——请求形状真的变了。而只有网关读「位置无关的最新 system」时追加才生效;只读头节点的网关会让模型**继续按旧提示词跑**,比它要省的那笔钱糟得多。国际区是另一套上游,没有测过,所以保持原样,等有人在那里实测。
|
|
26
|
+
|
|
27
|
+
### 新增:prompt cache 重算的审计与实测脚本
|
|
28
|
+
|
|
29
|
+
- `scripts/audit-prompt-cache.mjs`:离线扫描 `<DSH_HOME>/sessions` 的全部会话日志,列出「整包上下文按未缓存价重算」的请求,并按 `prompt-changed` / `cache-expired` 归因(前者可由 `in-history` 消除,后者是上游缓存过期)。只读、不花积分;未给 `--credits-per-k` 时只报 token,不编造单价,且 `--json` 里不会出现 `credits` 字段(`0` 会被读成「免费」)。
|
|
30
|
+
- `scripts/probe-mid-convo-system.mjs`:实测网关是否把历史之后的 `system` 消息当作生效提示词,并对比同一形状两次请求的缓存读数。只打印计数器与该轮回复,不打印提示词正文或凭证。
|
|
31
|
+
- `docs/PROMPT-CACHE.md`:两种成因、可避免的是哪一种、以及如何复测。里面附了两台机器的实测对照——`prompt-changed` 的占比高度依赖你多久改一次插件和技能,**不要拿单机数字当普遍预期**。
|
|
32
|
+
|
|
33
|
+
### 修复:签到或充值到账后,账号仍被判为积分耗尽(来自 #237)
|
|
34
|
+
|
|
35
|
+
- 签到或充值到账后的正余额查询会解除旧的 `out-of-credit` 记录,并在手动或自动签到后刷新选号与界面状态。持锁重读会保留查询期间新发生的失败,避免旧查询覆盖新状态。
|
|
36
|
+
- 积分耗尽的恢复提示依据签到状态显示操作条件,月度套餐刷新时间不再代表账号必须等待的期限。
|
|
37
|
+
- 排名、界面和错误说明继续共用 `exclusionOf`,零余额本身不排除可使用免费模型的账号。请求前会限频核对耗尽成员,无需打开卡片即可恢复;模型测试行也不再显示月度恢复倒计时,输入框面板只保留一套 usage 轮询。
|
|
38
|
+
- 账号池已有可用账号时,耗尽恢复查询在后台执行,不再阻塞正常请求;恢复读数会同步更新选号余额缓存,并保留更新的界面查询结果。客户端断开连接会停止等待共享恢复查询。
|
|
39
|
+
- 输入框面板按完整刷新周期防止重入;关闭或重新打开面板后,取消的 usage 查询会被新的读取替代,切换区域后也不会应用旧区域的迟到结果。手动换号会在设置写入后重新查询状态,不会复用换号前的轮询结果。
|
|
40
|
+
- 这一项的开发过程中,维护者补完了 review 的五条意见,并修掉三处「代码改了、文案和注释没跟着改」的遗留:池表无候选提示、排序规则第 1 条、`quotaRefreshAtMs` 两处注释。另外 `scripts/check-pii.mjs` 不再扫描 `.git` 指针文件——在 `git worktree` 里 `.git` 是个**文件**,内容是 `gitdir:` 加本机绝对路径,旧扫描器只跳过同名**目录**,于是每个 worktree 检出的隐私门禁都是红的且没人能修。
|
|
41
|
+
|
|
42
|
+
## 5.21.5 (2026-11-12) — 未发布到 npm
|
|
43
|
+
|
|
44
|
+
> ⚠️ **这一版没有发布到 npm**:它连同 #246、#247、#248、#249 一起作为 **5.22.0** 发布,
|
|
45
|
+
> 所以 registry 上 5.21.4 之后直接是 5.22.0,中间没有 5.21.5。这里保留记录,是因为下面修的是
|
|
46
|
+
> 真实的行为缺陷,而不是一次可以悄悄吞掉的中间态。
|
|
47
|
+
>
|
|
48
|
+
> 版本号是 **patch**:修「积分到账后账号仍被排除」的判定,不动配置键与路由语义。
|
|
49
|
+
> 来自 PR #237(kiwaro / limu)。作者未答复 review 的五条意见,维护者按意见补完后合入。
|
|
50
|
+
|
|
51
|
+
### 修复:签到或充值到账后,账号仍被判为积分耗尽
|
|
52
|
+
|
|
53
|
+
- 签到或充值到账后的正余额查询会解除旧的 `out-of-credit` 记录,并在手动或自动签到后刷新选号与界面状态。持锁重读会保留查询期间新发生的失败,避免旧查询覆盖新状态。
|
|
54
|
+
- 积分耗尽的恢复提示依据签到状态显示操作条件,月度套餐刷新时间不再代表账号必须等待的期限。
|
|
55
|
+
- 排名、界面和错误说明继续共用 `exclusionOf`,零余额本身不排除可使用免费模型的账号。请求前会限频核对耗尽成员,无需打开卡片即可恢复;模型测试行也不再显示月度恢复倒计时,输入框面板只保留一套 usage 轮询。
|
|
56
|
+
- 账号池已有可用账号时,耗尽恢复查询在后台执行,不再阻塞正常请求;恢复读数会同步更新选号余额缓存,并保留更新的界面查询结果。客户端断开连接会停止等待共享恢复查询。
|
|
57
|
+
- 输入框面板按完整刷新周期防止重入;关闭或重新打开面板后,取消的 usage 查询会被新的读取替代,切换区域后也不会应用旧区域的迟到结果。手动换号会在设置写入后重新查询状态,不会复用换号前的轮询结果。
|
|
58
|
+
|
|
59
|
+
### 维护者补完的部分(作者未答复 review)
|
|
60
|
+
|
|
61
|
+
- **`rankPool` 的零余额旁路已移除**,`exclusionOf` 仍是唯一的判定,并补了一条会咬的用例:余额为 0 且 `probe.outcome === 'ok'` 的账号**不能**被排除(免费模型那一格)。变异验证:把那行加回去,`tests/account-pool.spec.ts` 立刻红。
|
|
62
|
+
- **「或一次成功的模型请求」这句注释已删除**。它描述的解除路径在全仓库并不存在,`writePoolProbes` 的三个调用者都不会因一次 chat 成功而触发;现在注释只说真正有效的两条(正余额读数、手动测试)。
|
|
63
|
+
- **三处仍在承诺「按月度刷新时间回池」的文案已改**:池表无候选时的整段提示(`row.poolNoCandidateHint`)、排序规则第 1 条(`row.poolOrderRuleUsable`)都不再把「积分耗尽」和按时间恢复的那几类并列——改了行为就必须改这句话,否则用户会在「什么都用不了」的屏幕上读到一件池子永远不会做的事。
|
|
64
|
+
- **`quotaRefreshAtMs` 的三处注释已对齐**(`web-status.ts`、`index.ts` 两处):它是上游给的**包周期证据**,不是最早恢复时间,池子不会因为这一刻过去就放行。
|
|
65
|
+
- **删掉两个死掉的 locale key**(`row.probeOutOfCreditAt` / `row.probeOutOfCreditUnknown`):模型行改用 `availabilityLine` 之后已无引用。原测试断言「结果里不包含 `row.probeOutOfCreditAt`」因此变成永真——键已经不存在了,删掉实现也能通过。改为断言整行文本**完全等于**期望值,任何日期或倒计时都会让它红。
|
|
66
|
+
- **`probe-reason.ts` 与 `retrySuffix` 的说明已改**:`out-of-credit` 留在这个集合里的理由不再「它带着重置时刻」,而是「它的正文只是同一个配额信封,会淹掉那句可操作的提示」。
|
|
67
|
+
- **`scripts/check-pii.mjs` 不再扫描 `.git` 指针文件**。在 `git worktree`(以及 submodule)里 `.git` 是一个文件,内容是 git 自己写的 `gitdir: /Users/<真名>/…`;扫描器只跳过名为 `.git` 的**目录**,于是每个 worktree 检出都会让隐私门禁变红——而这条红了之后没人能修,正是隐私门禁被关掉的开始。补了一条会咬的用例,并同时断言 `.git` 前缀的普通文件仍会被扫。
|
|
68
|
+
|
|
69
|
+
|
|
3
70
|
## 5.21.4 (2026-11-11)
|
|
4
71
|
|
|
5
72
|
> 版本号是 **patch**:修一个开关的取值时机、一条预热链的启动时机,不动配置键与路由语义。
|
package/README.en.md
CHANGED
|
@@ -170,7 +170,7 @@ The last two rows are deliberate: check-in and testing are MANUAL actions over t
|
|
|
170
170
|
|
|
171
171
|
1. **Usable first** — an account a measurement rules out (limited with its cooldown unexpired, credential rejected, upstream unreachable) sorts last and is not chosen;
|
|
172
172
|
2. **Expiring credits first** — points lapsing within three days are lost if unspent, so an account holding any comes first, the soonest-lapsing one ahead of the rest, and between two of them the larger amount at risk wins;
|
|
173
|
-
3. **Higher credit balance first.** Among accounts with nothing expiring, the largest balance goes first. Credits take part **only when a fresh reading exists** (what the card's poll, a batch test or a save collected; valid for 10 minutes).
|
|
173
|
+
3. **Higher credit balance first.** Among accounts with nothing expiring, the largest balance goes first. Credits take part **only when a fresh reading exists** (what the card's poll, a batch test or a save collected; valid for 10 minutes). Normal ranking uses cached balances; a separate throttled recovery read checks only members with recorded credit exhaustion;
|
|
174
174
|
4. **Freshest credential first**;
|
|
175
175
|
5. The account id closes the order, making it **total** and reproducible rather than jittering with the roster's order.
|
|
176
176
|
|
|
@@ -184,12 +184,14 @@ The last two rows are deliberate: check-in and testing are MANUAL actions over t
|
|
|
184
184
|
| --- | --- |
|
|
185
185
|
| Usable | Eligible |
|
|
186
186
|
| Rate limited | Out of the pool **temporarily**, returning on the reset time the upstream stated (and when it states none, the card says so rather than **inventing a countdown**) |
|
|
187
|
-
| Out of credit |
|
|
187
|
+
| Out of credit | Excluded until a later positive balance confirms replenishment; the monthly refresh is not a recovery countdown |
|
|
188
188
|
| Credential rejected / model not found / upstream unreachable / failed | Out of the pool until a later probe refreshes the result |
|
|
189
189
|
| **Account restricted upstream** | **Benched for good; waiting fixes nothing** (5.8.0). The upstream names this ACCOUNT ("unusual activity"), so automatic failover **does** route around it. That is the opposite of a channel-verification refusal, which is about the REQUEST: switching accounts there would only burn credit on the same 400, so the plugin does not switch. The only real way back is a **manual "test"** of that account: the pool id is a hash of `uin`/`uid`, so re-authorising produces the same id and nothing clears the stored measurement (a re-login does **not** lift this bench). Re-test after the upstream lifts the restriction and it becomes a candidate again. The plugin **invents no countdown**; the bench only removes it from rotation — with no usable candidate left the request still falls to your saved account |
|
|
190
190
|
|
|
191
191
|
The key line: **"rate limited" is not "unusable"**. It is precisely the state most worth waiting on — treating it as permanently dead throws away the accounts that would have served you best.
|
|
192
192
|
|
|
193
|
+
Credit recovery requires balance evidence, not elapsed time. Manual and automatic check-in immediately refresh balances and selection, and card refreshes also reconcile credit failures. With no card open, requests check only depleted members, at most once per minute per region; concurrent requests share the query. If a usable member already exists, recovery runs in the background; otherwise the request waits for that shared result until completion or client disconnection. Recovery updates existing ranking balances without extending the cache lifetime, and newer whole-pool readings take precedence. Zero, invalid or failed readings retain the failure. Recovery text distinguishes check-in, tomorrow's check-in and waiting for replenishment. Removing the latest failure leaves the row as untested; it does not fabricate a successful model test. A zero balance alone does not exclude an account, since free models may still work. An explicit successful pool test updates the verdict; ordinary chat success does not write a probe record.
|
|
194
|
+
|
|
193
195
|
### Manual selection: there is no account dropdown any more
|
|
194
196
|
|
|
195
197
|
Accounts are managed **in the account pool**: membership checkboxes are the selection surface, and re-detection lives there too. The old "account" dropdown had become self-contradictory once the pool existed — with the pool on, the ranking decides who serves, so changing it did nothing yet looked authoritative, and the status line above could name one account while the dropdown showed another.
|
package/README.md
CHANGED
|
@@ -171,7 +171,7 @@ DSH PiAiAdapter(每个 provider 一套)
|
|
|
171
171
|
|
|
172
172
|
1. **可用优先** —— 被测量判定为不可用(限流未到恢复时间、凭据被拒、连通性失败等)的排到最后,不参与选择;
|
|
173
173
|
2. **快过期的积分先花** —— 3 天内到期的积分用不掉就作废,所以**有临期积分的账号排在前面**,**先到期的先排**;两个都在临期时,**临期积分多的优先**;
|
|
174
|
-
3. **积分高者优先** —— 在没有临期积分的账号里,选积分最多的。**积分只在有新鲜读数时参与**(卡片轮询、批量测试或保存时读到的那份,10
|
|
174
|
+
3. **积分高者优先** —— 在没有临期积分的账号里,选积分最多的。**积分只在有新鲜读数时参与**(卡片轮询、批量测试或保存时读到的那份,10 分钟内有效):普通选号只读取缓存;独立的限频恢复查询只核对已记录积分耗尽的成员;
|
|
175
175
|
4. **凭据更晚过期的优先**;
|
|
176
176
|
5. 最后按账号 id 收尾,保证顺序是**全序**、可复现,不会因为账号表顺序变化而抖动。
|
|
177
177
|
|
|
@@ -206,14 +206,14 @@ DSH PiAiAdapter(每个 provider 一套)
|
|
|
206
206
|
| --- | --- |
|
|
207
207
|
| 可用 | 可入选 |
|
|
208
208
|
| 被限流 | **暂时**出池,按上游给出的重置时间自动回池(上游没说时间就按 30 分钟兜底,**不编造倒计时**) |
|
|
209
|
-
| 积分耗尽 |
|
|
209
|
+
| 积分耗尽 | 出池,后续正余额查询确认到账后回池;月度刷新时间不作为恢复倒计时 |
|
|
210
210
|
| 连不上上游 / 失败 | **暂时**出池,30 分钟后自动回池——这类结果说的往往不是账号,而是一次网络抖动或上游 5xx |
|
|
211
211
|
| 凭据被拒 / 模型不存在 | 出池,**只能靠手动「测试」回池**:一个需要重新登录,一个是本区域不再提供该模型,等待都修不好 |
|
|
212
212
|
| **账号被上游限制使用** | **停权,等待修不好**(5.8.0)。上游的话是「账号存在异常行为,已被限制使用」——它点名的是**这个账号**,所以自动换号**会**绕开它去用下一个。这与「渠道校验失败」正好相反:那条说的是**这个请求**,换号只会白烧一次额度,因此**不**换号。**回池的实际出路只有手动「测试」**:账号 id 是 `uin`/`uid` 的哈希,重新登录后仍是同一个 id,插件也不会因为重登清掉这条测量(「重新授权就回池」不成立);上游解除限制后测一次通过,它才会重新成为候选。插件**不给它编一个倒计时**,但停权只作用于轮换候选资格——全池没有可用账号时,请求仍会落到你保存的那个账号上 |
|
|
213
213
|
|
|
214
214
|
关键一条:**「被限流」「连不上上游」都不等于不可用**。它们恰恰是最值得等的那两类状态——当成永久失效剔除,正好丢掉池子里本来最能用的账号,而且**当池内每个成员都被这样剔除时,池子就没有任何候选,自动换号会无处可去**,你只会看到上游原始报错。
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
**自动恢复的依据**:限流和瞬时故障按各自的冷却规则回池。积分耗尽需要后续正余额作为到账证据:手动或自动签到后立即核对,卡片刷新时也会核对;没有打开卡片时,每次请求前只核对耗尽账号,同一区域至多每分钟一次,并发请求共享查询;已有可用账号时在后台执行恢复,全池无可用账号时才等待查询,客户端断开会解除等待。零余额、无效读数或查询失败均不解除旧失败,月度刷新时间经过本身也不会解除。恢复提示根据有效签到状态显示「签到后重试」「明日签到后重试」或「等待积分补充」。清除的是最近失败记录,恢复后会显示「未测试」,不会把余额到账伪装成模型测试成功。余额为零本身不排除账号,免费模型仍可使用;手动测试成功会更新测试结论,普通聊天成功不写测试记录。「凭据被拒」「模型不存在」仍需手动处理与重测。
|
|
217
217
|
|
|
218
218
|
### 保存与草稿:为什么卡片上有两个「保存」
|
|
219
219
|
|
package/lib/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as DEFAULT_WIRE_PROFILE,
|
|
2
|
+
import { $ as DEFAULT_WIRE_PROFILE, Dn as hostPeersInfo, F as WorkBuddyCredentialStore, J as workbuddyOwnAuthPath, N as WORKBUDDY_AUTH_FILE_ENV, On as resolveDshHome, P as WORKBUDDY_VAULT_DIRNAME, R as defaultDesktopAuthCandidates, T as FALLBACK_WORKBUDDY_MODELS_GLOBAL, W as legacyWorkbuddyOwnAuthPath, X as APP_VERSION, Y as workbuddyVaultDir, a as readHostHeartbeat, an as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, b as readDeviceSettings, c as WORKBUDDY_CONNECT_VERSION, cn as readDeviceSalt, d as rosterSeenPath, dn as inspectCredentialDirectory, f as WORKBUDDY_CN_BASE_ENV, fn as protectCredentialDirectory, g as createTuringSdk, ln as deriveDeviceId, m as piAiRuntimeInfo, nt as WorkBuddyUpstreamClient, o as workbuddyHostHeartbeatPath, on as readDeviceTokenFile, ot as describeRequestHeaderNames, p as resolveCnGateway, pn as WORKBUDDY_APP_EXECUTABLE_ENV, r as isHeartbeatProcessAlive, sn as ensureDeviceSalt, u as describeRosterSeenPayload, w as FALLBACK_WORKBUDDY_MODELS, yn as findWorkbuddyAppExecutableWithSource, z as defaultDesktopAuthDirs } from "./host-heartbeat-CYnq7iGq.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { realpathSync } from "node:fs";
|