dsh-wtq-pool 1.3.0 → 1.3.6

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 CHANGED
@@ -1,5 +1,47 @@
1
1
  # 更新说明
2
2
 
3
+ ## [1.3.6]
4
+
5
+ - 安全:数据目录按 0700、签到记录按 0600 创建。
6
+ - 隐私:说明请求携带厂商账号与设备标识(账号 UID、机器码、设备 ID)。
7
+ - 成长中心:执行超过宿主等待时间后,任务结束时按钮恢复可用。
8
+ - 自动签到:上一轮仍在进行时,按钮显示运行中并保持不可点,结束后恢复。
9
+ - 文档:精简 README。
10
+
11
+ ## [1.3.5]
12
+
13
+ - 流式对话:收到 WorkBuddy、Trae、Qoder 的拒绝响应后及时关闭上游连接,避免换号或重试时遗留连接。
14
+ - WorkBuddy:扫描时从磁盘清除超过 30 天保留期的过期凭证归档。
15
+ - WorkBuddy:删除账号与重新登录同时进行时,保留新登录。
16
+ - 输入框积分:整轮刷新共用 15 秒等待上限,覆盖登录读取和账号查询。
17
+ - 面板:来源和区域选择器改用带状态的按钮组;页面标签支持方向键导航与 Enter/Space 激活。
18
+
19
+ ## [1.3.4]
20
+
21
+ - 流式对话:宿主采集响应流时,上游拒绝请求可及时返回错误,避免等待响应流结束而卡住。
22
+ - 取消请求:停止生成或取消响应流时,同时关闭上游连接,释放宿主采集与网络资源。
23
+
24
+ ## [1.3.3]
25
+
26
+ - Trae 对话:主路由失效后改用备用路由时,按备用路由的窗口启用 Max 模式,避免长对话被较小的默认窗口拒绝。
27
+ - Qoder:支持读取 macOS 国内版桌面登录。
28
+ - Trae 签到:设备 ID 迁移后同时存在数字设备号与非数字旧键时,使用唯一数字设备号,修复已签到仍显示可签到、领取返回 9074 的问题。
29
+ - Qoder:解密成功但登录内容缺少账号标识时,正确提示登录数据无效。
30
+ - 隐私:流式失败日志仅记录错误类别和 Trae 错误码;macOS 读取 Qoder 登录时需访问登录钥匙串。
31
+
32
+ ## [1.3.1]
33
+
34
+ - 账号池:两个区域共用一个账号池时,轮流使用与同一对话固定账号的轮转位置按区域分开;跳过刷新失败的登录后仍会轮到每个账号,两个区域也不会重复落在同一个账号上。
35
+ - 输入框积分:已有会话中点击读数可以正常打开换号弹窗,滚动或缩放窗口时不再报错。
36
+ - 积分读数:额度耗尽的账号在冷却期间仍会读取余额,充值后下一次读取即可解除挂起,面板的刷新判断不再把它当作无需更新。
37
+ - 积分读数:手动刷新后按最新结果重新计时,未读到的余额不会等满五分钟;请求未返回时切换模型或提供商,弹窗不再停留在切换中。
38
+ - 换号:登录失效返回 200 且刷新令牌成功、会话仍然失效时,该账号挂起并改用下一个,不再反复刷新同一账号。
39
+ - 模型:Trae、Qoder 保存的默认思考等级会写入声明,选中该模型时按设置的等级发送,不再回落到目录默认值。
40
+ - 换号:上游主机不可达时,尚未失败的网关仍有尝试机会,不再因同域名的连续超时错过健康账号。
41
+ - 账号池:同一对话固定账号命中时刷新使用顺序,长时间对话不会因绑定上限被换到新账号;不同区域的同名对话不再共用绑定。
42
+ - 设置:写入与当前值相同时不再影响对宿主修改的判断,插件保存后宿主刚做的修改不再丢失。
43
+ - 面板:登录链接缺失时按界面语言提示,不再显示英文原文。
44
+
3
45
  ## [1.3.0]
4
46
 
5
47
  - 账号池:升级前的停用、移除、保底与偏好设置按旧账号 ID 继续生效。
package/README.en.md CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  <h1 align="center">WTQ Pool</h1>
10
10
 
11
- <p align="center"><sub>For DeepSeek Harness · <a href="https://github.com/chengzhi-c/pi-desktop-wtq-pool">PI-Desktop edition</a></sub></p>
11
+ <p align="center"><sub>DeepSeek Harness edition · <a href="https://github.com/chengzhi-c/pi-desktop-wtq-pool">PI-Desktop edition</a></sub></p>
12
12
 
13
- <p align="center"><b>Use local WorkBuddy, Trae and Qoder sign-ins in DeepSeek Harness, with automatic failover when an account is rate-limited or out of quota.</b></p>
13
+ <p align="center"><b>Use local WorkBuddy, Trae and Qoder sign-ins in DeepSeek Harness, with account failover based on each sign-in's state.</b></p>
14
14
 
15
15
  <p align="center">
16
16
  <b>English</b> | <a href="README.md">简体中文</a>
@@ -18,8 +18,8 @@
18
18
 
19
19
  <p align="center">
20
20
  <a href="#install">Install</a> ·
21
- <a href="#features">Features</a> ·
22
21
  <a href="#usage">Usage</a> ·
22
+ <a href="#features">Features</a> ·
23
23
  <a href="#settings">Settings</a> ·
24
24
  <a href="CHANGELOG.md">Changelog</a> ·
25
25
  <a href="https://github.com/chengzhi-c/dsh-wtq-pool/issues">Issues</a>
@@ -27,205 +27,139 @@
27
27
 
28
28
  <p align="center">
29
29
  <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/v/dsh-wtq-pool?style=flat-square&amp;label=npm&amp;color=cb3837" alt="npm version"></a>
30
- <a href="https://www.npmjs.com/package/dsh-wtq-pool"><img src="https://img.shields.io/npm/d18m/dsh-wtq-pool?style=flat-square&amp;label=downloads&amp;color=cb3837" alt="npm downloads"></a>
31
30
  <a href="LICENSE"><img src="https://img.shields.io/github/license/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="MIT license"></a>
32
- <a href="https://github.com/chengzhi-c/dsh-wtq-pool/releases"><img src="https://img.shields.io/github/v/release/chengzhi-c/dsh-wtq-pool?style=flat-square&amp;label=release" alt="release"></a>
33
- <a href="https://github.com/chengzhi-c/dsh-wtq-pool/stargazers"><img src="https://img.shields.io/github/stars/chengzhi-c/dsh-wtq-pool?style=flat-square" alt="GitHub stars"></a>
34
31
  </p>
35
32
 
36
33
  > This project is for learning use only. Unofficial clients may trigger account restrictions. Review the risks and the relevant service terms before use.
37
34
 
38
- WorkBuddy fails over when an account is rate-limited, out of quota or answered with an upstream 5xx. Trae and Qoder select an account per request and move on to the next sign-in on an authentication failure, a rate limit or exhausted quota, while a problem with the request itself, such as an unknown model or a malformed body, is answered locally with 404 or 400. Each source has its own switch, with domestic and international accounts grouped separately.
39
-
40
- A rate limit cools for the wait the upstream stated, or the configured window when it stated none. Exhausted quota and a dead sign-in do not recover on their own: that account leaves rotation. A balance read releases an exhausted-quota hold; a successful token refresh, a fresh sign-in or a manual cooldown reset releases a refused-sign-in hold, and both lapse after six hours (WorkBuddy). The non-stream reads of credits, check-in state, the model catalogue and check-ins force one token refresh and one retry when a sign-in is refused: an account whose refresh token still works recovers on the spot and never leaves rotation, and only one whose refresh token is spent too is held. Trae and Qoder holds are accounted separately, demoting the sign-in only by the cooldown window (60 seconds by default, configurable up to 24 hours) or by the wait the upstream stated, and it is still used when it is the only one left. When the upstream host cannot be reached, that account is skipped for the request and the next one is tried; after two accounts fail that way, the turn ends with a network error. When the upstream says an account's plan does not include a model (11158), that model is disabled on that account for 24 hours while its other models keep serving; if no account includes it, the turn is answered with 400. A Trae sign-in expiry can arrive as one sentence with no error code; a frame matching the known wording is read as an expired sign-in and rotated past, and any other wording is answered as upstream failure with 502.
41
-
42
- ## Preview
43
-
44
- The settings panel in its default light theme:
45
-
46
- ![Account pool](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-pool.png)
47
-
48
- The panel reads the host's `app.getAppearance()` when it loads, which fixes its palette and its language. After a host theme switch, press "Reload panel" on the card to read it again:
49
-
50
- ![Dark theme](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-dark.png)
51
-
52
- The model page edits each model's display and publishing settings. A Trae directory row states only its plan default, which differs per model (116k to 400k). A model that states no larger tier is published with a 1M ceiling. A Trae model whose directory states a rate carries a cost tag such as `x0.79`; models whose directory states none, and every Qoder model, stay unlabelled:
53
-
54
- ![Model settings](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-models.png)
35
+ Providers are registered separately by vendor and region. When an account is rate-limited, out of credits or signed out, requests fail over according to that source's rules.
55
36
 
56
- Growth centre:
57
-
58
- ![Growth centre](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-growth.png)
59
-
60
- Live preview: <https://chengzhi-c.github.io/dsh-wtq-pool/>.
61
-
62
- `docs/index.html` drives the actual panel code with synthetic demo data. It supports source switching, model settings and theme previews.
37
+ ## Install
63
38
 
64
- ![Preview page](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-page.png)
39
+ Supports DeepSeek Harness `0.2.0` and the `0.2.2` series, including prereleases allowed by `engines.dsh`. Requires Node `^22.19.0 || >=24.0.0`, as well as the Node version required by the host.
65
40
 
66
- To run the preview locally, clone the repository, run `node docs/serve.cjs`, and open the address it prints. The page cannot be opened over `file://`, because a browser will not let it read the panel files beside it.
41
+ ### Desktop app
67
42
 
68
- ## Features
43
+ On the **Plugins** page, select **Add plugin** → **Install third-party plugin**, enter `dsh-wtq-pool` and install, then enable the plugin.
69
44
 
70
- - Reuse local sign-ins from the three desktop apps. WorkBuddy also supports Add account in the panel, which uses its official login page and saves the sign-in in the plugin's own directory.
71
- - Register model groups by region: each region of each vendor becomes its own provider, and several can be on at once; a region with no account is not registered. A domestic model runs only on domestic accounts, and an international model only on international ones.
72
- - Account distribution: WorkBuddy supports priority, round-robin, expiring credits first and conversation-sticky accounts, and fails over on a rate limit, exhausted quota or upstream 5xx. Trae and Qoder support priority, round-robin and expiring credits first, and move on to the next sign-in on an authentication failure, a rate limit or exhausted quota.
73
- - Gateway responses are SSE streams of `chat.completion.chunk`; the `stream` field in the request body does not change the format.
74
- - Credit automation: automatic check-in is off by default. When enabled, scheduled runs perform check-ins and WorkBuddy growth claims. Streak days advance through upstream conversations, so each pass posts one activity report per account before reading its tiers; a tier becomes claimable the moment it unlocks. A make-up card is spent only when yesterday is missing and a card is available. After streak tiers are claimed, available lottery draws are used. Cat travel is available only for domestic accounts.
75
- - Token keep-alive: on demand, on a card of its own. A snapshot the desktop client left behind is adopted into the plugin's own sign-in directory when the pool scans, and the plugin renews it from then on; the desktop app renews the sign-in it is using. "Refresh now" works on the plugin's own copies and judges by issue time: anything signed more than six hours ago is refreshed, and a token within five minutes of expiry takes the same path. The answer is written back into the sign-in file the plugin owns, so a sign-in the upstream refused is found the same day. When one account has sign-ins in several places, the newest issue time wins. Disabled accounts, disabled regions and accounts whose sign-in the upstream refused stay out.
76
- - Composer credits: with `showComposerPoints` on, the composer toolbar shows the balance of the account behind the current model; click it to switch accounts. In round-robin and conversation-sticky modes it names the account that serves next or served last. Switching the feature off hides the readout and slows the poll to once every five minutes, so switching it back on recovers without a model change.
77
- - Panel: account and pool state, model selection, the connection check and the growth centre all live in the account-pool card on the plugin page. The model catalogue loads at startup and refreshes on demand once its cache expires; it does not poll while idle. Disabled accounts and accounts whose sign-in the upstream refused are never probed.
78
- - Connection check: every finding carries a verdict. A gateway that is not listening, a catalogue that could not be read, a published address that differs from the one actually bound, and a provider the host did not accept all count as failures and say what to change. A gateway whose start failed is reported with the reason, and the panel surfaces address drift as a reload hint. A check that fails on its own becomes a finding, and the rest of the report still appears.
45
+ ### CLI
79
46
 
80
- ## Install
81
-
82
- For a local package, run these in the source directory:
47
+ Requires the DSH CLI (`@deepseek-ai/dsh`). The CLI manages non-desktop profiles such as `web` and `tui`; the `desktop` profile is reserved by the desktop app, so install there through its plugin page.
83
48
 
84
49
  ```powershell
85
- pnpm install
86
- pnpm run build
87
- New-Item -ItemType Directory -Force dist | Out-Null
88
- npm pack --pack-destination dist
50
+ dsh plugin --profile web add dsh-wtq-pool
89
51
  ```
90
52
 
91
- Then install the generated `.tgz`:
53
+ `web` is the DSH profile; replace it with the profile you use. Open **dsh-wtq-pool** on the **Plugins** page. After upgrading from 1.1.x to 1.2.0, provider IDs changed to `wtqpool-*`; select your models again.
92
54
 
93
- ```powershell
94
- $package = (Get-ChildItem .\dist\*.tgz | Sort-Object LastWriteTime | Select-Object -Last 1).FullName
95
- dsh plugin --profile desktop add $package
96
- ```
55
+ ## Usage
97
56
 
98
- Supports DeepSeek Harness on the 0.2.0 and 0.2.2 prerelease lines (`engines.dsh` in `package.json`: `>=0.2.0-rc.1 <0.2.1-0 || >=0.2.2-rc.1 <0.2.3-0`) with its matching dependencies. npm's `latest` tag currently points to `0.2.2-rc.1`, which requires Node `>=24.9.0`; the plugin's Node requirement `^22.19.0 || >=24.0.0` also applies. The stable 0.2.2 release is not published yet; the semver range will cover it once released.
57
+ Sign in to WorkBuddy, Trae or Qoder, then select **Detect accounts again**. WorkBuddy supports multiple sign-ins; domestic Trae reads Trae CN and TRAE SOLO CN separately. Each Qoder installation and the international WorkBuddy edition retain one sign-in, so switching accounts replaces it.
99
58
 
100
- > After upgrading from 1.1.x to 1.2.0, provider ids are `wtqpool-*`; reselect your model once.
59
+ WorkBuddy 5.6+ `$wbEncrypted` sign-ins need a decryption key from the local WorkBuddy installation. On Windows, only signed installations with a supported key on a fixed local drive are used; decryption is skipped when the host runs elevated. On macOS, the local app is run to read the key without signature verification; root processes on macOS and Linux also skip decryption. Use a trusted installation.
101
60
 
102
- Replace `desktop` with the profile name actually in use. If `dsh` is not on `PATH`, use the CLI in its installation directory. The npm name `dsh-wtq-pool` and the repository URL also work as install sources; a repository-URL install uses the committed `lib/` as is.
61
+ ### Add an account
103
62
 
104
- **Where the panel is**: open **Plugins** in the sidebar, then open the **dsh-wtq-pool** card, or the **Configure** control beside it; the full panel is embedded in that card. If the model groups do not appear, reload the plugin as the note at the top of the panel says.
63
+ Add one through the official sign-in page in the panel, or import an `.info` file containing `{auth, account}`. Run this from a source checkout:
105
64
 
106
- ## Usage
65
+ ```powershell
66
+ $dshHome = if ($env:DSH_HOME) { $env:DSH_HOME } else { Join-Path $HOME ".dsh" }
67
+ $pluginData = Join-Path $dshHome "dsh-wtq-pool"
68
+ $accountFile = Read-Host "Sign-in file path"
69
+ node .\tools\import-signins.cjs --data $pluginData --from $accountFile
70
+ ```
107
71
 
108
- Sign in inside each vendor's desktop app, then click "Detect accounts again". WorkBuddy reads several saved sign-ins; a `$wbEncrypted` sign-in from 5.6 on is read with a key obtained from the locally installed WorkBuddy. The domestic Trae build has two sign-in slots, Trae CN and TRAE SOLO CN. Qoder keeps one sign-in per installation, so signing in again in the app overwrites the previous one. The international WorkBuddy client keeps a single sign-in file, so switching accounts overwrites the previous one. The plugin archives a sign-in as it is overwritten, and that account keeps serving until its token expires; signing it in again in the app renews it.
72
+ Optional arguments: `--region cn|global|all`, `--dry-run`, `--force`.
109
73
 
110
- On Windows, decrypting sign-ins requires a WorkBuddy executable on a fixed local drive with a valid signature and a supported signing key. The plugin does not decrypt these sign-ins when the host runs elevated on Windows or as root on macOS or Linux. If WorkBuddy changes its signing key, update the plugin before decrypting them. On macOS the plugin runs the locally installed WorkBuddy executable to read the key without verifying its signature; only run installations you trust.
74
+ Files in `signins/` contain usable access and refresh tokens; protect them like account passwords. Plugin-owned sign-ins can be deleted after a second confirmation; the desktop app's active sign-in cannot be deleted from the panel.
111
75
 
112
- An account can also be added without the desktop app: "Add account" in the panel's WorkBuddy header opens the vendor's login page in a new tab, and the account joins the pool once that page completes. The credential is written under `signins/` in the plugin's own data directory and takes part in distribution on the same terms as a desktop sign-in. Such an account also carries a "Delete" action, which confirms on a second press; see the Data section for what it removes. An account the desktop app is signed into right now has no Delete: that session belongs to the app. The account is added to the region currently selected, so the domestic region signs in a domestic account and the international region an international one.
76
+ ### Panel
113
77
 
114
- To migrate accounts left behind by another tool, write the files into that directory: `signins/` is the import format, and one `{auth, account}` document named `*.info` dropped there becomes an ordinary account on the next scan. `tools/import-signins.cjs` reads those account files (`--from` accepts files or directories) and writes them in the shape this plugin reads, skipping any account the plugin's own data directory already holds; `--dry-run` shows what would change and `--force` overwrites. The script is not shipped in the `.tgz`; clone the repository and install its development dependencies to run it:
78
+ **Account pool** manages sign-ins and account status. **Models** controls published models and display options; **Connection check** reports gateways, catalogues, addresses and host registration; **Growth centre** manages WorkBuddy rewards.
115
79
 
116
- ```
117
- node tools/import-signins.cjs --data "<plugin data dir>" --from "<account file or directory>" [--region cn|global|all] [--dry-run] [--force]
118
- ```
80
+ Automatic check-in is off by default, defaults to 09:00 Beijing time and can be changed in the panel; check-in and **Run now** may claim rewards using make-up cards or lottery draws. Domestic Trae allows one check-in per device each day; Qoder commonly opens at 10:00 Beijing time.
119
81
 
120
- To back them up, copy the `signins/` directory. Those files hold live tokens whose reach equals that of the account itself.
82
+ **Refresh now** renews plugin-owned sign-ins issued at least six hours ago or expiring within five minutes; the desktop app renews its active sign-in.
121
83
 
122
- - **Account pool**: each account's label, remaining credits, quota expiry, cooldown state and check-in status. An account can be disabled on its own or removed, and a region can be pinned to one preferred account. An account whose sign-in the upstream refused shows a "re-login needed" badge, the reason and a "held until" time; credits and check-in stay blank while held. An account the upstream restricted instead shows a "restricted" badge and a "restricted by the upstream until" stamp, is retried every six hours, and needs an appeal in the WorkBuddy console. When two Trae or Qoder accounts share a display name, each label carries a `#` and the last eight characters of the user id.
123
- - **Models**: select which models this region exposes; anything unselected stays out of the model picker. The display name, context window, output limit, thinking levels and image support are editable. A model group publishes at most 64 models; any beyond that are marked "not published" while the gateway still serves them.
124
- - **Connection check**: reports line by line whether each gateway is listening, how many models its catalogue returned, whether the registered address matches the one actually bound, and whether the host accepted each provider, and can copy the whole report.
125
- - **Growth centre**: applies to WorkBuddy only. It lists one row per account, and expanding a row shows that account's streak tiers. "Read state" reads the current tiers and what is due; "Run now" claims them and runs the growth stage, reporting every step: the make-up card, the gift and compensation, the activity report, and the streak tiers with their draws. An account whose sign-in the upstream refused is skipped in that round.
84
+ ## Features
126
85
 
127
- Check-in runs per account, or for a whole source from the title bar. Automatic check-in is off by default; when on it claims at 09:00 (Beijing time), and a slot missed earlier the same day is still claimed at the next start, while one from a previous day is not. Trae's daily check-in is once per device; a Qoder round opens at the `startAt` its campaign list returns, commonly 10:00 (Beijing time). Whether a check-in appears depends on the activity state the upstream returns for that account. An account whose sign-in the upstream refused is skipped in that round.
86
+ - Distribution: priority, round robin, expiring credits first and WorkBuddy conversation stickiness.
87
+ - Composer credits show and switch the active account's balance; when disabled, balances are read every five minutes.
88
+ - Each model group publishes up to 64 models; catalogues refresh on demand and gateways return SSE `chat.completion.chunk` responses.
128
89
 
129
- The domestic WorkBuddy host reads the system and assistant turns for wording that belongs to a client it does not serve, and answers 11128 (channel check failed), whether the refusal arrives as HTTP 400 or as a JSON envelope with HTTP 200. When it lands, the plugin retries once: the system messages fold into the first user message, a `developer` role folds into `system`, the client name in assistant history becomes `DeepSeek`, and the request keeps one neutral system message. An accepted prompt is cached per region, so the same prompt does not pay that round trip again. Check-in, the growth centre and the keep-alive use their own endpoints.
90
+ ### Failover and recovery
130
91
 
131
- "Refresh now" reports refreshed, already fresh, failed and without a refresh token separately.
92
+ | Condition | Behaviour |
93
+ | --- | --- |
94
+ | Invalid request or Trae/Qoder model missing from the catalogue | Return 400 or 404 without sending a chat request |
95
+ | WorkBuddy rate limit, upstream 5xx or host unavailable | Try the next account; rate limits follow the upstream wait time or configured cooldown |
96
+ | WorkBuddy exhausted credits | Hold the account for up to six hours; a positive balance or manual cooldown reset releases the hold |
97
+ | WorkBuddy expired sign-in | Hold the account for up to six hours; successful refresh, a new sign-in or manual cooldown reset releases the hold |
98
+ | WorkBuddy plan excludes a model (11158) | Disable that model on the account for 24 hours; return 400 if no account supports it |
99
+ | Trae/Qoder authentication failure, rate limit, exhausted credits or empty response | Try the next sign-in and lower its priority for the cooldown; a sole sign-in is still used |
100
+ | Trae/Qoder upstream 5xx | Return the upstream failure |
132
101
 
133
- A read stays in the host process, so reloading the panel still paints the last figures. Entering the tab re-reads figures older than two minutes, figures a later pass has outdated, or figures from a region since disabled.
102
+ Trae/Qoder cooldowns default to 60 seconds and can be set up to 24 hours. WorkBuddy refreshes once after an expired sign-in; domestic error 11128 retries once for the channel check without holding the account.
134
103
 
135
104
  ## Settings
136
105
 
137
- Every key below is editable in the plugin page or the DSH settings page and saved on confirm:
138
-
139
- | Key | Default (effective) | Meaning |
140
- | --- | --- | --- |
141
- | `enabled` | `true` | Off: the gateways do not start |
142
- | `sourceWorkbuddy` / `sourceTrae` / `sourceQoder` | `true` | Off: that source is not scanned, published or requested |
143
- | `distribution` | `priority` | How the WorkBuddy pool spreads requests: `priority` uses one account first, `round-robin` spreads evenly, `expiry` spends expiring credits first, `sticky` pins one account per conversation |
144
- | `sourceDistributions` | `{}` | Trae/Qoder distribution: `priority` / `round-robin` / `expiry`; unset behaves as `priority` |
145
- | `cooldownSeconds` | `60` | Rate-limit cooldown. A reset time the upstream reports takes precedence; with none, consecutive limits double it up to 15 minutes (a longer configured window is left alone). A reported reset is capped at two hours; a spent balance or a refused sign-in is held for six hours instead |
146
- | `creditReserves` | `{}` | Per-account credit floor, keyed by account id; an account at or below its floor is not distributed to |
147
- | `authFile` | `""` | WorkBuddy sign-in file path; every `.info` sign-in in its directory is scanned. Empty discovers it |
148
- | `autoCheckin` | `{"enabled":false,"hours":[9]}` | Automatic check-in switch and times; `hours` are Beijing-time hours, empty means 09:00 |
149
- | `showComposerPoints` | `false` | Show the active account's credits in the composer |
150
- | `disabledAccountIds` | `[]` | Account ids disabled in the panel |
151
- | `disabledRegions` | `[]` | Regions disabled on their own, as `source:region` keys |
152
- | `modelSelection` | `{}` | Which models each gateway publishes, plus display name, context window and other overrides |
153
- | `preferredAccountIds` | `{}` | Preferred WorkBuddy account per region |
154
- | `preferredSourceAccounts` | `{}` | Preferred Trae/Qoder account per region, keyed by `source:region` |
155
- | `removedAccounts` | `[]` | Accounts removed from the pool, with label and region kept so the panel can offer a restore |
156
-
157
- The default column lists effective values: `autoCheckin.hours` is stored as an empty array and normalises to `[9]`, and an unset or empty `authFile` means auto-discovery.
158
-
159
- Model selection and preferred accounts are saved by the panel.
106
+ Edit settings on the plugin page or DSH settings page: source switches, WorkBuddy distribution, cooldowns, automatic check-in and composer credits. Complete definitions and defaults are in the [settings source](https://github.com/chengzhi-c/dsh-wtq-pool/blob/main/src/index.ts).
160
107
 
161
108
  ## Ports
162
109
 
163
- ```
164
- WorkBuddy 42831 / 42841
165
- Trae 42851 / 42861
166
- Qoder 42871 / 42881
167
- ```
168
-
169
- These are the preferred ports. When one is taken, the gateway binds an ephemeral port and runtime provider registration uses that address, which the panel reports as the fallback.
170
-
171
- When another process takes a port between the reservation and the listen, that gateway's start fails: its model group is dropped, the connection check reports the reason, and the panel surfaces address drift. Requests reach the new address only after the plugin is reloaded and the host re-reads its declaration.
110
+ | Source | Domestic | International |
111
+ | --- | ---: | ---: |
112
+ | WorkBuddy | `42831` | `42841` |
113
+ | Trae | `42851` | `42861` |
114
+ | Qoder | `42871` | `42881` |
172
115
 
173
- The PI-Desktop edition uses a separate port range starting at 41831. Both editions can be installed together, but settings and credentials are stored separately and are not synchronized. If both use the same WorkBuddy sign-in, upstream refresh-token rotation may invalidate the other copy. When an edition asks for a new sign-in, add the account again there rather than overwriting it with old `signins/` files. The editions may show different token expiry times.
116
+ If a preferred port is occupied, the gateway uses an ephemeral port and runtime registration and the panel report the actual address; if a port is taken after reservation but before listening, that model group is not published. The PI-Desktop edition uses a separate range starting at `41831`; the editions keep settings and credentials separately, and sharing a WorkBuddy sign-in can let refresh-token rotation invalidate the other edition.
174
117
 
175
- ## Data and outbound requests
118
+ ## Privacy and data
176
119
 
177
- The plugin reads the vendors' local sign-in files. Providers are registered at runtime; the host persists plugin settings in the profile. Tokens are held by the plugin and go only to the relevant vendor endpoints. Gateways listen on `127.0.0.1`, so other local processes can call them and spend account quota. The panel accepts loopback requests only. The plugin is designed for a single-user desktop and does not separate other OS users on the same machine; use separate OS accounts on a shared machine.
120
+ The plugin sends conversation content to the selected vendor and does not save local chat history. Requests also carry the selected vendor's account and device identifiers (account uid, machine id, device id), as the vendor's own desktop client does. On macOS, reading a Qoder sign-in accesses the login Keychain and may prompt for access.
178
121
 
179
- The plugin's own data directory, `~/.dsh/dsh-wtq-pool/` (or `$DSH_HOME/dsh-wtq-pool/` when set), holds four data files. An interrupted archive, delete-record or sign-in write can leave temporary files behind: writing the same file again clears leftovers older than ten minutes, and a scan does the same for sign-in temps in the plugin's own directory; deleting an account removes its sign-in temps with it. `checkin-slots.json` records the check-in slots already collected and the pending Qoder retry time; slots are kept for three days. `doctor.txt` is the most recent connection report, item by item, and lists no account label. `credentials-archive.json` keeps the sign-ins a later account switch overwrote: access and refresh tokens, account identifiers (nickname, uin/uid, enterprise id) and the local sign-in path. Entries are kept by token expiry, dropping each 30 days after it; an entry with no stated expiry is kept until the account is deleted. `deleted-signins.json` records deleted sign-ins as a token digest, the sign-in's issue time, a delete time and a random record id, so a scan cannot take the same superseded snapshot back over from the desktop app; a scan clears the entry after the account signs in again with a different token and a newer issue time; deletes for one account that cannot be ordered by issue time are kept together, so a stale one cannot replace a newer one; a record written by 1.2.3 matches only by token digest and is not cleared automatically. These files carry no additional encryption; access is bounded by the operating system's file ACLs.
122
+ Gateways listen only on `127.0.0.1`, but local processes and OS users can still call them and spend account quota. Sign-in files and token archives have no additional encryption and rely on OS file permissions; restrict the plugin data directory ACL on Windows.
180
123
 
181
- Every sign-in the plugin writes lives in `signins/` beside it: ones added from the panel, snapshots adopted from the desktop app, and renewed copies. Each file is named after the account's billing identity and read on the same terms as a desktop sign-in. These files are not additionally encrypted either; access is bounded by the operating system's file ACLs. "Delete" in the panel removes that file together with its archive entry, and the snapshot the desktop app left behind stops being adopted; signing the account in again brings it back. "Remove" only disables the account, and "Removed accounts" restores it.
124
+ The data directory is `~/.dsh/dsh-wtq-pool/`, or `$DSH_HOME/dsh-wtq-pool/` when `DSH_HOME` is set. `signins/` and `credentials-archive.json` contain usable sign-in tokens; filenames may include billing identity. Archives remain for 30 days after the later recorded access or refresh expiry; records without an expiry are cleared when deleted.
182
125
 
183
- The plugin sends requests only to the vendor endpoints; panel links open only when clicked. A login page URL is accepted only on the vendor's own hosts.
184
-
185
- Tokens go only to the hosts below:
126
+ Panel **Delete** removes a plugin-owned sign-in and its archive entry and prevents an old desktop snapshot from rejoining; **Remove** only excludes it from distribution. External links open on click; sign-in pages and token requests use only these vendor hosts:
186
127
 
187
128
  - WorkBuddy: `copilot.tencent.com`, `www.codebuddy.cn`, `www.codebuddy.ai`, `www.workbuddy.ai`
188
129
  - Trae: `api.trae.cn`, `solo.trae.cn`, `trae-api-cn.mchost.guru`, `coresg-normal.trae.ai`, `growsg-normal.trae.ai`
189
130
  - Qoder: `gateway.qoder.com.cn`, `openapi.qoder.com.cn`, `api3.qoder.sh`, `openapi.qoder.sh`
190
131
 
132
+ ## Preview
133
+
134
+ ![Account pool](https://github.com/chengzhi-c/dsh-wtq-pool/raw/main/docs/preview-pool.png)
135
+
136
+ The [live preview](https://chengzhi-c.github.io/dsh-wtq-pool/) runs the actual panel code with demo data.
137
+
191
138
  ## Development
192
139
 
193
140
  ```sh
194
141
  pnpm install
195
- pnpm run build # emits lib/ (host half as ESM, client half as CJS)
196
- pnpm run typecheck # host half
142
+ pnpm run build
143
+ pnpm run typecheck
197
144
  pnpm run typecheck:client
198
- pnpm test # Node's own test runner, offline regressions
145
+ pnpm test
199
146
  ```
200
147
 
201
- `src/host.ts` is the engine (account discovery, the pool, the gateways, the panel channels), `src/index.ts` is the Cordis entry (settings schema, provider registration, panel routes), and `src/pi-compat.ts` adapts the host's capabilities to the calls the engine makes. `renderer/` is the panel itself, `index.html`, `panel.js` and `panel.css`, in plain JavaScript with no build step, mounted by `src/web-panel.ts` on the host's web server and served to the plugin card as a same-origin iframe. `src/client/` is the React half: the plugin-page card that embeds that iframe (`index.tsx`), its address construction (`panel-url.ts`), and the composer readout (`composer.tsx`). `lib/` is emitted by `tsdown`, listed in `package.json`'s `files` and committed, so it must be rebuilt after changing `src/`.
202
-
203
- The host-agnostic core:
204
-
205
- | Module | Responsibility |
206
- | --- | --- |
207
- | `loopback.ts` | The loopback security model (Host and Origin checks), response writing, stream relay and message redaction |
208
- | `accounts.ts` | WorkBuddy sign-in parsing, the account pool and its cooldowns |
209
- | `upstream.ts` | The WorkBuddy upstream client, error classification, rate-limit reset parsing |
210
- | `catalog.ts` | The model catalogue and its static fallback list |
211
- | `shim.ts` | The WorkBuddy gateway's OpenAI-compatible endpoint |
212
- | `at-rest.ts` | Unsealing 5.6+ encrypted sign-in fields |
213
- | `promo.ts` | Promotion window matching |
214
- | `trae-*.ts` / `qoder-*.ts` | Sign-in discovery, protocol clients, SSE decoding and gateways for both vendors |
148
+ `src/` contains plugin logic, `renderer/` the plain JavaScript panel and `lib/` the `tsdown` build shipped in the package. Rebuild `lib/` after changing `src/`. `typecheck` excludes `src/host.ts`; `typecheck:client` checks the client code. Tests use Node's built-in runner and run offline.
215
149
 
216
150
  ## Credits
217
151
 
218
- Several modules are ported from or reference the MIT projects below:
152
+ | Project | Reference |
153
+ | --- | --- |
154
+ | [XDTrees/dsh-xdpool](https://github.com/XDTrees/dsh-xdpool) | WorkBuddy pool and porting base |
155
+ | [corrinehu/dsh-workbuddy-connect](https://github.com/corrinehu/dsh-workbuddy-connect) | Loopback endpoint security model |
156
+ | [dingminhua/dsh-connect-workbuddy](https://github.com/dingminhua/dsh-connect-workbuddy) | WorkBuddy API and error classification |
157
+ | [dingminhua/dsh-connect-trae](https://github.com/dingminhua/dsh-connect-trae) | Trae protocol |
158
+ | [eghrhegpe/dsh-connect-qoder](https://github.com/eghrhegpe/dsh-connect-qoder) | Qoder protocol |
159
+ | [ardeyouxipianyi/workbuddy2api-hub](https://github.com/ardeyouxipianyi/workbuddy2api-hub) | Growth centre, account retention and international activity reports |
219
160
 
220
- | Project | Copyright | Used for |
221
- | --- | --- | --- |
222
- | [XDTrees/dsh-workbuddy-xdpool](https://github.com/XDTrees/dsh-workbuddy-xdpool) | (c) 2026 XDTrees | WorkBuddy account pool and the port this plugin came from |
223
- | [corrinehu/dsh-workbuddy-connect](https://github.com/corrinehu/dsh-workbuddy-connect) | (c) 2026 Corrine Hu | The loopback endpoint's security model |
224
- | [dingminhua/dsh-connect-workbuddy](https://github.com/dingminhua/dsh-connect-workbuddy) | (c) 2026 LaoDing | Upstream API and error classification |
225
- | [dingminhua/dsh-connect-trae](https://github.com/dingminhua/dsh-connect-trae) | (c) 2026 dingminhua | Trae protocol reference |
226
- | [eghrhegpe/dsh-connect-qoder](https://github.com/eghrhegpe/dsh-connect-qoder) | (c) 2026 eghrhegpe | Qoder protocol reference |
227
- | [ardeyouxipianyi/workbuddy2api-hub](https://github.com/ardeyouxipianyi/workbuddy2api-hub) | (c) 2026 ardeyouxipianyi | Growth centre and streak loop (make-up cards, gift, compensation, lottery), multi-account credential retention, activity reporting for international accounts |
161
+ Copyright and license notices for ported code shipped with the plugin are in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). Other projects are listed as references.
228
162
 
229
163
  ## License
230
164
 
231
- MIT, see [LICENSE](./LICENSE).
165
+ This project is licensed under MIT; see [LICENSE](./LICENSE). Third-party notices for ported code shipped with the plugin are in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).